8 #ifndef LARCOREALG_GEOMETRY_OPDETGEO_H 9 #define LARCOREALG_GEOMETRY_OPDETGEO_H 22 #include "TGeoMatrix.h" 23 #include "TGeoSphere.h" 31 #include <type_traits> 81 double ThetaZ(
bool degrees)
const;
126 TGeoShape
const*
Shape()
const {
return Node()->GetVolume()->GetShape(); }
143 template <
typename ShapeObj>
160 template <
typename ShapeObj>
164 bool isTube()
const {
return isShapeLike<TGeoTube>(); }
167 bool isBar()
const {
return isShape<TGeoBBox>(); }
170 bool isSphere()
const {
return isShape<TGeoSphere>(); }
197 template <
typename Stream>
206 std::string
OpDetInfo(std::string
indent =
"",
unsigned int verbosity = 0)
const;
222 TGeoTube
const*
asTube()
const {
return dynamic_cast<TGeoTube const*
>(
Shape()); }
225 TGeoSphere
const*
asSphere()
const {
return dynamic_cast<TGeoSphere const*
>(
Shape()); }
228 TGeoBBox
const*
asBox()
const {
return dynamic_cast<TGeoBBox const*
>(
Shape()); }
238 template <
typename ShapeObj>
241 static_assert(std::is_base_of_v<TGeoShape, std::decay_t<ShapeObj>>);
244 TGeoShape
const* shape =
Shape();
245 return typeid(*shape) ==
typeid(std::decay_t<ShapeObj>);
249 template <
typename ShapeObj>
252 static_assert(std::is_base_of_v<TGeoShape, std::decay_t<ShapeObj>>);
255 return dynamic_cast<std::decay_t<ShapeObj> const*
>(
Shape()) !=
nullptr;
259 template <
typename Stream>
262 unsigned int verbosity
269 out <<
"optical detector " <<
ID() <<
" centered at " <<
GetCenter() <<
" cm";
271 if (verbosity-- <= 0)
return;
275 out <<
", radius: " <<
RMax() <<
" cm";
277 out <<
", length: " <<
Length() <<
" cm";
280 out <<
", bar size " <<
Width() <<
" x " <<
Height() <<
" x " <<
Length() <<
" cm";
282 else if (TGeoSphere
const* sphere =
asSphere(); sphere) {
284 auto const [th1, th2] =
std::minmax({sphere->GetTheta1(), sphere->GetTheta2()});
287 if (cmp.
zero(th1) && cmp.
equal(th2, 180.0))
289 else if ((cmp.
zero(th1) && cmp.
equal(th2, 90.0)) ||
290 (cmp.
equal(th1, 90.0) && cmp.
equal(th2, 180.0))) {
291 out <<
"hemispherical";
294 out <<
"spherical portion (" << th1 <<
" -> " << th2 <<
" degree)";
295 out <<
" with external radius " <<
RMax() <<
" cm";
298 out <<
", shape: '" <<
Shape()->IsA()->GetName() <<
"'";
300 if (verbosity-- <= 0)
return;
303 out <<
", theta(z): " <<
ThetaZ() <<
" rad";
313 #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.
OpDetGeo(TGeoNode const *node, TransformationMatrix &&trans)
bool isShapeLike() const
Returns whether the detector inherits from the specified shape.
bool isShape() const
Returns whether the detector has the specified shape.
Point_t toWorldCoords(LocalPoint_t const &local) const
Transform point from local optical detector frame to world frame.
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.
Point_t const & GetCenter() const
OpticalVector_t LocalVector_t
Type of displacement vectors in the local GDML TPC frame.
const TGeoNode * fOpDetNode
Pointer to theopdet node.
Point_t fCenter
Stored geometric center of the optical detector.
OpDetID fID
Identifier of this optical detector.
Class for approximate comparisons.
bool isSphere() const
Returns whether the detector shape is a hemisphere (TGeoSphere).
Definitions of vector data types for optical detectors.
double DistanceToPoint(Point_t const &point) const
Returns the distance of the specified point from detector center [cm].
Definitions of geometry vector data types.
TGeoBBox const * asBox() const
Returns the geometry object as TGeoBBox, nullptr if not box-derived.
void UpdateAfterSorting(OpDetID opdetid)
Performs all updates after cryostat has sorted the optical detectors.
std::string indent(std::size_t const i)
Vector_t toWorldCoords(LocalVector_t const &local) const
Transform direction vector from local to world.
void PrintOpDetInfo(Stream &&out, std::string indent="", unsigned int verbosity=0) const
Prints information about this optical detector.
Definition of data types for geometry description.
OpticalPoint_t LocalPoint_t
Type of points in the local GDML TPC frame.
OpDetID const & ID() const
Returns the geometry ID of this optical detector.
LocalVector_t toLocalCoords(Vector_t const &world) const
Transform direction vector from world to local.
ROOT::Math::PositionVector3D< ROOT::Math::Cartesian3D< double >, ROOT::Math::GlobalCoordinateSystemTag > Point_t
Type for representation of position in physical 3D space.
double CosThetaFromNormal(Point_t const &point) const
Get cos(angle) to normal of this detector - used for solid angle calcs.
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.
LocalPoint_t toLocalCoords(Point_t const &world) const
Transform point from world frame to local optical detector frame.
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.
TGeoShape const * Shape() const
Returns the geometry object as TGeoShape.
ROOT::Math::Transform3D TransformationMatrix
Type of transformation matrix used in geometry.