9 #ifndef LARCOREALG_GEOMETRY_OPDETGEO_H 10 #define LARCOREALG_GEOMETRY_OPDETGEO_H 23 #include "TGeoMatrix.h" 24 #include "TGeoSphere.h" 32 #include <type_traits> 82 double ThetaZ(
bool degrees)
const;
139 TGeoShape
const*
Shape()
const {
return Node()->GetVolume()->GetShape(); }
156 template <
typename ShapeObj>
173 template <
typename ShapeObj>
177 bool isTube()
const {
return isShapeLike<TGeoTube>(); }
180 bool isBar()
const {
return isShape<TGeoBBox>(); }
183 bool isSphere()
const {
return isShape<TGeoSphere>(); }
210 template <
typename Stream>
219 std::string
OpDetInfo(std::string
indent =
"",
unsigned int verbosity = 0)
const;
235 TGeoTube
const*
asTube()
const {
return dynamic_cast<TGeoTube const*
>(
Shape()); }
238 TGeoSphere
const*
asSphere()
const {
return dynamic_cast<TGeoSphere const*
>(
Shape()); }
241 TGeoBBox
const*
asBox()
const {
return dynamic_cast<TGeoBBox const*
>(
Shape()); }
251 template <
typename ShapeObj>
254 static_assert(std::is_base_of_v<TGeoShape, std::decay_t<ShapeObj>>);
257 TGeoShape
const* shape =
Shape();
258 return typeid(*shape) ==
typeid(std::decay_t<ShapeObj>);
263 template <
typename ShapeObj>
266 static_assert(std::is_base_of_v<TGeoShape, std::decay_t<ShapeObj>>);
269 return dynamic_cast<std::decay_t<ShapeObj> const*
>(
Shape()) !=
nullptr;
274 template <
typename Stream>
277 unsigned int verbosity
284 out <<
"optical detector " <<
ID() <<
" centered at " <<
GetCenter() <<
" cm";
286 if (verbosity-- <= 0)
return;
290 out <<
", radius: " <<
RMax() <<
" cm";
292 out <<
", length: " <<
Length() <<
" cm";
295 out <<
", bar size " <<
Width() <<
" x " <<
Height() <<
" x " <<
Length() <<
" cm";
297 else if (TGeoSphere
const* sphere =
asSphere(); sphere) {
299 auto const [th1, th2] =
std::minmax({sphere->GetTheta1(), sphere->GetTheta2()});
302 if (cmp.
zero(th1) && cmp.
equal(th2, 180.0))
304 else if ((cmp.
zero(th1) && cmp.
equal(th2, 90.0)) ||
305 (cmp.
equal(th1, 90.0) && cmp.
equal(th2, 180.0))) {
306 out <<
"hemispherical";
309 out <<
"spherical portion (" << th1 <<
" -> " << th2 <<
" degree)";
310 out <<
" with external radius " <<
RMax() <<
" cm";
313 out <<
", shape: '" <<
Shape()->IsA()->GetName() <<
"'";
315 if (verbosity-- <= 0)
return;
318 out <<
", theta(z): " <<
ThetaZ() <<
" rad";
328 #endif // LARCOREALG_GEOMETRY_OPDETGEO_H const TGeoNode * Node() const
Returns the ROOT object describing the detector geometry.
TGeoSphere const * asSphere() const
Returns the geometry object as TGeoSphere, nullptr if not a sphere.
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.
ROOT::Math::DisplacementVector3D< ROOT::Math::Cartesian3D< double >, ROOT::Math::GlobalCoordinateSystemTag > Vector_t
Type for representation of momenta in 3D space.
std::pair< float, float > minmax(const float a, const float b)
minmax
bool isTube() const
Returns whether the detector shape is a cylinder (TGeoTube).
Provides simple real number checks.
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)
std::string indent(std::size_t const i)
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.
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].
ROOT::Math::PositionVector3D< ROOT::Math::Cartesian3D< double >, ROOT::Math::GlobalCoordinateSystemTag > Point_t
Type for representation of position in physical 3D space.
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.
Namespace collecting geometry-related classes utilities.
geo::OpDetID fID
Identifier of this optical detector.
TGeoShape const * Shape() const
Returns the geometry object as TGeoShape.
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.