9 #ifndef LARCOREALG_GEOMETRY_OPDETGEO_H
10 #define LARCOREALG_GEOMETRY_OPDETGEO_H
21 #include "TGeoMatrix.h"
23 #include "TGeoSphere.h"
33 #include <type_traits>
74 void GetCenter(
double* xyz,
double localz=0.0)
const;
87 double ThetaZ(
bool degrees)
const;
154 TGeoShape
const*
Shape()
const {
return Node()->GetVolume()->GetShape(); }
171 template <
typename ShapeObj>
188 template <
typename ShapeObj>
192 bool isTube()
const {
return isShapeLike<TGeoTube>(); }
195 bool isBar()
const {
return isShape<TGeoBBox>(); }
198 bool isSphere()
const {
return isShape<TGeoSphere>(); }
226 template <
typename Stream>
228 (
Stream&& out, std::string indent =
"",
unsigned int verbosity = 0)
const;
237 (std::string indent =
"",
unsigned int verbosity = 0)
const;
254 {
return dynamic_cast<TGeoTube
const*
>(
Shape()); }
258 {
return dynamic_cast<TGeoSphere
const*
>(
Shape()); }
262 {
return dynamic_cast<TGeoBBox
const*
>(
Shape()); }
273 template <
typename ShapeObj>
275 static_assert(std::is_base_of_v<TGeoShape, std::decay_t<ShapeObj>>);
278 TGeoShape
const* shape =
Shape();
279 return typeid(*shape) ==
typeid(std::decay_t<ShapeObj>);
284 template <
typename ShapeObj>
286 static_assert(std::is_base_of_v<TGeoShape, std::decay_t<ShapeObj>>);
289 return dynamic_cast<std::decay_t<ShapeObj>
const*
>(Shape()) !=
nullptr;
295 template <
typename Stream>
299 unsigned int verbosity
305 out <<
"optical detector " << ID() <<
" centered at " << GetCenter() <<
" cm";
307 if (verbosity-- <= 0)
return;
311 out <<
", radius: " << RMax() <<
" cm";
312 if (cmp.
nonZero(RMin())) out <<
" (inner: " << RMin() <<
" cm)";
313 out <<
", length: " <<
Length() <<
" cm";
316 out <<
", bar size " << Width() <<
" x " << Height() <<
" x " <<
Length()
319 else if (TGeoSphere
const* sphere = asSphere(); sphere) {
321 auto const [ th1, th2 ]
322 =
std::minmax({ sphere->GetTheta1(), sphere->GetTheta2() });
325 if (cmp.
zero(th1) && cmp.
equal(th2, 180.0)) out <<
"spherical";
326 else if ((cmp.
zero(th1) && cmp.
equal(th2, 90.0))
327 || (cmp.
equal(th1, 90.0) && cmp.
equal(th2, 180.0)))
329 out <<
"hemispherical";
331 else out <<
"spherical portion (" << th1 <<
" -> " << th2 <<
" degree)";
332 out <<
" with external radius " << RMax() <<
" cm";
334 else out <<
", shape: '" << Shape()->IsA()->GetName() <<
"'";
336 if (verbosity-- <= 0)
return;
339 out <<
", theta(z): " << ThetaZ() <<
" rad";
350 #endif // LARCOREALG_GEOMETRY_OPDETGEO_H
const TGeoNode * Node() const
Returns the ROOT object describing the detector geometry.
ROOT::Math::DisplacementVector3D< ROOT::Math::Cartesian3D< double >, ROOT::Math::GlobalCoordinateSystemTag > Vector_t
Type for representation of momenta in 3D space.
TGeoSphere const * asSphere() const
Returns the geometry object as TGeoSphere, nullptr if not a sphere.
float Length(const PFPStruct &pfp)
bool isShapeLike() const
Returns whether the detector inherits from the specified shape.
double CosThetaFromNormal(geo::Point_t const &point) const
Get cos(angle) to normal of this detector - used for solid angle calcs.
bool isShape() const
Returns whether the detector has the specified shape.
std::pair< float, float > minmax(const float a, const float b)
minmax
bool isTube() const
Returns whether the detector shape is a cylinder (TGeoTube).
bool isBar() const
Returns whether the detector shape is a bar (TGeoBBox).
constexpr bool zero(Value_t value) const
Returns whether the value is no farther from 0 than the threshold.
const TGeoNode * fOpDetNode
Pointer to theopdet node.
geo::OpticalVector_t LocalVector_t
Type of displacement vectors in the local GDML TPC frame.
LocalVector_t toLocalCoords(geo::Vector_t const &world) const
Transform direction vector from world to local.
Class for approximate comparisons.
geo::Vector_t toWorldCoords(LocalVector_t const &local) const
Transform direction vector from local to world.
bool isSphere() const
Returns whether the detector shape is a hemisphere (TGeoSphere).
Definitions of vector data types for optical detectors.
Definitions of geometry vector data types.
TGeoBBox const * asBox() const
Returns the geometry object as TGeoBBox, nullptr if not box-derived.
OpDetGeo(TGeoNode const &node, geo::TransformationMatrix &&trans)
void WorldToLocal(const double *world, double *opdet) const
Transform point from world frame to local optical detector frame.
void PrintOpDetInfo(Stream &&out, std::string indent="", unsigned int verbosity=0) const
Prints information about this optical detector.
geo::Point_t fCenter
Stored geometric center of the optical detector.
void LocalToWorldVect(const double *opdet, double *world) const
Transform direction vector from local to world.
geo::Point_t toWorldCoords(LocalPoint_t const &local) const
Transform point from local optical detector frame to world frame.
Definition of data types for geometry description.
void UpdateAfterSorting(geo::OpDetID opdetid)
Performs all updates after cryostat has sorted the optical detectors.
geo::Point_t const & GetCenter() const
double DistanceToPoint(geo::Point_t const &point) const
Returns the distance of the specified point from detector center [cm].
geo::OpticalPoint_t LocalPoint_t
Type of points in the local GDML TPC frame.
TGeoTube const * asTube() const
Returns the geometry object as TGeoTube, nullptr if not a tube.
static constexpr unsigned int MaxVerbosity
Maximum verbosity supported by PrintOpDetInfo().
constexpr bool nonZero(Value_t value) const
Returns whether the value is farther from 0 than the threshold.
geo::OpDetID const & ID() const
Returns the geometry ID of this optical detector.
OpticalPoint3DBase_t< double > OpticalPoint_t
Type of optical 3D point with representation in double precision.
LocalTransformation_t fTrans
Optical-detector-to-world transformation.
OpticalVector3DBase_t< double > OpticalVector_t
constexpr bool equal(Value_t a, Value_t b) const
Returns whether a and b are no farther than the threshold.
std::string OpDetInfo(std::string indent="", unsigned int verbosity=0) const
Returns a string with optical detector information.
The data type to uniquely identify a optical detector.
ROOT::Math::PositionVector3D< ROOT::Math::Cartesian3D< double >, ROOT::Math::GlobalCoordinateSystemTag > Point_t
Type for representation of position in physical 3D space.
void WorldToLocalVect(const double *world, double *opdet) const
Transform direction vector from world to local.
geo::OpDetID fID
Identifier of this optical detector.
TGeoShape const * Shape() const
Returns the geometry object as TGeoShape.
void LocalToWorld(const double *opdet, double *world) const
Transform point from local optical detector frame to world frame.
LocalPoint_t toLocalCoords(geo::Point_t const &world) const
Transform point from world frame to local optical detector frame.
ROOT::Math::Transform3D TransformationMatrix
Type of transformation matrix used in geometry.