41 #ifndef GEO_GEOMETRYCORE_H 42 #define GEO_GEOMETRYCORE_H 45 #include "Geometry/LocalTransformation.h" 62 #include <type_traits> 78 class SegmentationAlg;
117 absorberThickness(0),
118 inner_nRadiationLengths(0),
119 inner_nInteractionLengths(0),
120 outer_nRadiationLengths(0),
121 outer_nInteractionLengths(0),
124 sensitive_thickness(0),
191 template <
typename GEOIDITER>
196 template <
typename GEOIDITER>
199 GEOIDITER
const& id_iter
201 template <
typename GEOIDITER>
204 {
return iter == id_iter; }
209 template <
typename GEOIDITER>
212 GEOIDITER
const& id_iter
214 template <
typename GEOIDITER>
216 GEOIDITER
const& id_iter,
219 {
return iter != id_iter; }
238 template <
typename GEOIDITER>
247 "template class for geometry_element_iterator" 248 " must be a geometry iterator" 256 using GeoID_t =
typename id_iterator_t::GeoID_t;
289 : id_iter(geom, start_from)
321 if (ptr)
return *ptr;
323 <<
"iterator attempted to obtain geometry element " 331 iterator& operator++ () { ++id_iterator();
return *
this; }
335 {
iterator old(*
this); ++id_iterator();
return old; }
339 {
return bool(id_iterator()) && (id_iterator().get() !=
nullptr); }
370 template <
typename Iter, Iter (GeometryCore::*BeginFunc)() const, Iter (GeometryCore::*EndFunc)() const>
376 b((geom->*BeginFunc)()),
e((geom->*EndFunc)()) {}
520 void WorldBox(
float* xlo,
float* xhi,
521 float* ylo,
float* yhi,
522 float* zlo,
float* zhi)
const;
546 TGeoManager* ROOTGeoManager()
const;
628 std::map< gar::geo::LayeredCalorimeterData::LayoutType, std::shared_ptr<gar::geo::LayeredCalorimeterData> >
GetECALLayeredCalorimeterData()
const {
return fECALLayeredCalorimeterData; }
651 const std::string VolumeName(TVector3
const& point)
const;
665 bool FindFirstVolume(
std::string const&
name, std::vector<const TGeoNode*>& path)
const;
667 void StoreECALNodes(std::map<
std::string, std::vector<const TGeoNode*>> &map)
const;
678 std::vector<TGeoNode const*> FindAllVolumes(std::set<std::string>
const& vol_names)
const;
693 std::vector<std::vector<TGeoNode const*>> FindAllVolumePaths(std::set<std::string>
const& vol_names)
const;
696 template <
typename T>
700 TGeoNode*
FindNode(std::array<double, 3>
const& point)
const;
703 TGeoNode*
FindNode(TVector3
const& point)
const;
719 const std::string MaterialName(TVector3
const& point);
724 TGeoMaterial
const* Material(
double x,
double y,
double z)
const;
728 double TotalMass(
const char* vol =
"volWorld")
const;
742 double MassBetweenPoints(
double *p1,
double *p2)
const;
795 unsigned int NChannels()
const;
827 unsigned int NearestChannel(
float const worldLoc[3])
const;
828 unsigned int NearestChannel(std::vector<float>
const& worldLoc)
const;
829 unsigned int NearestChannel(TVector3
const& worldLoc)
const;
837 float GetIROCInnerRadius()
const;
838 float GetIROCOuterRadius()
const;
839 float GetOROCInnerRadius()
const;
840 float GetOROCOuterRadius()
const;
841 float GetOROCPadHeightChangeRadius()
const;
851 unsigned int GapChannelNumber()
const;
853 void ChannelToPosition(
unsigned int const channel,
float*
const worldLoc)
const;
872 bool ValueInRange(
double value,
double min,
double max)
const;
900 void LoadGeometryFile(
std::string const& gdmlfile,
std::string const& rootfile,
bool bForceReload =
false);
920 void ApplyChannelMap(std::shared_ptr<gar::geo::seg::ChannelMapAlg> pChannelMap);
923 void ApplyECALSegmentationAlg(std::shared_ptr<gar::geo::seg::SegmentationAlg> pECALSegmentationAlg);
925 void ApplyMinervaSegmentationAlg(std::shared_ptr<gar::geo::seg::SegmentationAlg> pMinervaSegmentationAlg);
927 void ApplyMuIDSegmentationAlg(std::shared_ptr<gar::geo::seg::SegmentationAlg> pMuIDSegmentationAlg);
1021 bool PointInWorld(TVector3
const& point)
const;
1023 bool PointInDetEnclosure(TVector3
const& point)
const;
1025 bool PointInMPD(TVector3
const& point)
const;
1027 bool PointInGArTPC(TVector3
const& point)
const;
1029 bool PointInLArTPC(TVector3
const& point)
const;
1031 bool PointInECALBarrel(TVector3
const& point)
const;
1033 bool PointInECALEndcap(TVector3
const& point)
const;
1035 float GetSensVolumeThickness(
const TVector3& point)
const;
1037 const std::array<double, 3> FindShapeSize(
const TGeoNode *node)
const;
1039 gar::raw::CellID_t GetCellID(
const TGeoNode *node,
const unsigned int& det_id,
const unsigned int& stave,
const unsigned int& module,
const unsigned int& layer,
const unsigned int& slice,
const std::array<double, 3>& localPosition)
const;
1043 const std::string GetMinervaCellIDEncoding()
const;
1047 std::array<double, 3> GetPosition(
const TGeoNode *node,
const gar::raw::CellID_t &cID)
const;
1049 bool isTile(
const std::array<double, 3>& point,
const gar::raw::CellID_t& cID)
const;
1051 double getStripWidth(
const std::array<double, 3>& point)
const;
1053 double getTileSize(
const std::array<double, 3>& point)
const;
1055 double getStripLength(
const std::array<double, 3>& point,
const gar::raw::CellID_t &cID)
const;
1057 std::pair<TVector3, TVector3> GetStripEnds(
const std::array<double, 3>& point,
const gar::raw::CellID_t &cID)
const;
1059 std::pair<float, float> CalculateLightPropagation(
const std::array<double, 3>& point,
const std::array<double, 3> &local,
const gar::raw::CellID_t &cID)
const;
1061 std::array<double, 3> ReconstructStripHitPosition(
const std::array<double, 3>& point,
const std::array<double, 3>& local,
const float &xlocal,
const gar::raw::CellID_t &cID)
const;
1068 void GetGeometryParameters();
1069 void FinalizeGeometryParameters();
1071 void PrintGeometry()
const;
1073 void StoreTPCParameters();
1074 void GetDetectorsPresent();
1078 void InitVariables();
1081 void ClearGeometry();
1083 void StoreECALParameters();
1085 void StoreMuIDParameters();
1086 void StoreOtherParameters();
1088 void SetDetectorOrigin();
1090 bool FindWorldVolume();
1092 bool FindRockVolume();
1094 bool FindEnclosureVolume();
1096 bool FindMPDVolume();
1098 bool FindLArTPCVolume();
1100 bool FindActiveTPCVolume();
1102 bool FindActiveLArTPCVolume();
1104 bool FindGasTPCVolume();
1106 bool FindECALVolume();
1108 bool FindMuIDVolume();
1111 bool FindECALInnerBarrelRadius();
1114 bool FindECALOuterBarrelRadius();
1117 bool FindECALInnerEndcapRadius();
1120 bool FindECALOuterEndcapRadius();
1123 bool FindPVThickness();
1126 bool FindECALInnerSymmetry();
1129 bool FindECALEndcapStartX();
1132 bool FindECALEndcapOuterX();
1135 bool FindECALnLayers();
1138 bool MakeECALLayeredCalorimeterData();
1141 bool FindMuIDInnerBarrelRadius();
1144 bool FindMuIDOuterBarrelRadius();
1147 bool FindMuIDInnerSymmetry();
1150 bool FindMuIDnLayers();
1152 bool FindTrackerScVolume();
1154 bool FindTrackerScnPlanes();
1166 float fOriginX = 0.;
1167 float fOriginY = 0.;
1168 float fOriginZ = 0.;
1170 float fTPCRadius = 0.;
1171 float fTPCLength = 0.;
1173 int fTPCNumDriftVols = 2;
1178 float fTPCXCent = 0.;
1179 float fTPCYCent = 0.;
1180 float fTPCZCent = 0.;
1190 float fEnclosureX = 0.;
1191 float fEnclosureY = 0.;
1192 float fEnclosureZ = 0.;
1198 float fLArTPCX = 0.;
1199 float fLArTPCY = 0.;
1200 float fLArTPCZ = 0.;
1202 float fLArTPCXCent = 0.;
1203 float fLArTPCYCent = 0.;
1204 float fLArTPCZCent = 0.;
1206 float fWorldHalfWidth = 0.;
1207 float fWorldHalfHeight = 0.;
1208 float fWorldLength = 0.;
1210 float fRockHalfWidth = 0.;
1211 float fRockHalfHeight = 0.;
1212 float fRockLength = 0.;
1214 float fEnclosureHalfWidth = 0.;
1215 float fEnclosureHalfHeight = 0.;
1216 float fEnclosureLength = 0.;
1218 float fMPDHalfWidth = 0.;
1219 float fMPDHalfHeight = 0.;
1220 float fMPDLength = 0.;
1222 float fLArTPCHalfWidth = 0.;
1223 float fLArTPCHalfHeight = 0.;
1224 float fLArTPCLength = 0.;
1226 float fLArTPCActiveHalfWidth = 0.;
1227 float fLArTPCActiveHalfHeight = 0.;
1228 float fLArTPCActiveLength = 0.;
1230 float fGArLiteXCent = 0;
1231 float fGArLiteYCent = 0;
1232 float fGArLiteZCent = 0;
1234 float fGArLiteRadius = 0;
1235 float fGArLiteLength = 0;
1285 template<> TGeoNode* GeometryCore::FindNode<float>(
float const &
x,
float const &
y,
float const &
z)
const;
1286 template<> TGeoNode* GeometryCore::FindNode<double>(
double const &
x,
double const &
y,
double const &
z)
const;
1316 TGeoNode
const*
operator* ()
const {
return current_path.empty()?
nullptr: current_path.back().self; }
1322 std::vector<TGeoNode const*> get_path()
const;
1329 : self(new_self), sibling(new_sibling) {}
1335 void reach_deepest_descendant();
1337 void init(TGeoNode
const* start_node);
1353 template <
typename GEOIDITER>
1354 bool gar::geo::details::operator==
1360 template <
typename GEOIDITER>
1361 bool gar::geo::details::operator!=
1369 #endif // GEO_GEOMETRYCORE_H
std::vector< gar::geo::ChanWithPos > ChanWithNeighbors
float GetActiveLArTPCHalfHeight() const
bool fECALEndcapOutside
Is the ECAL Endcap outside the PV.
float GetActiveLArTPCZ() const
float GetEnclosureX() const
float GetEnclosureHalfWidth() const
float fMuIDRouter
Minimum radius of the MuID outer barrel.
float GetRockHalfWidth() const
constexpr auto undefined_pos
std::shared_ptr< const gar::geo::seg::ChannelMapAlg > ChannelMapPtr
typename id_iterator_t::GeoID_t GeoID_t
double outer_nInteractionLengths
Base class for geometry iterators, containing some type definitions.
float GetMPDLength() const
std::string GetGArTPCVolumeName() const
Return the name of GAr TPC volume.
float fECALEndcapOuterX
Position of the end xplane of the ECAL endcap.
MinervaSegmentationAlgPtr fMinervaSegmentationAlg
Object containing the segmentation for the Sc Tracker.
int GetECALInnerSymmetry() const
bool HasLArTPCDetector() const
geometry_element_iterator(id_iterator_t &&iter)
float GetActiveLArTPCHalfWidth() const
float fMuIDRinner
Minimum radius of the MuID inner barrel.
float GetRockLength() const
geometry_iterator_base()
Default constructor; do not use a default-constructed iterator as-is!
float GetMuIDInnerBarrelRadius() const
double inner_nInteractionLengths
int TPCNumDriftVols() const
Returns number of TPC drift volumes.
std::shared_ptr< const gar::geo::seg::SegmentationAlg > MinervaSegmentationAlgPtr
id_iterator_t & id_iterator()
float fPVThickness
Pressure Vessel thickness.
typename id_iterator_t::EndPos_t EndPos_t
typename std::remove_pointer< ElementPtr_t >::type Element_t
Geometry class pointed by the iterator.
float GetLArTPCHalfWidth() const
float GArLiteLength() const
ECALSegmentationAlgPtr fECALSegmentationAlg
Object containing the segmentation for the ECAL.
xmlNodePtr FindNode(xmlDocPtr xml_doc, string node_path)
std::vector< Layer > layers
float TPCXCent() const
Returns the X location of the center of the TPC in cm.
float GArLiteYCent() const
Description of geometry of one entire detector.
double sensitive_thickness
gar::geo::ROCType roctype
bool fPointInWarnings
Generate warnings from failed inputs to PointIn* methods.
float GetECALOuterEndcapRadius() const
bool HasEnclosure() const
bool HasGasTPCDetector() const
float GetPVThickness() const
struct gar::geo::ChanWithPos_ ChanWithPos
geometry_element_iterator(gar::geo::GeometryCore const *geom)
Constructor: points to begin.
float GetMuIDInnerAngle() const
float fECALRouter
Minimum radius of the ECAL outer barrel.
Forward iterator browsing all geometry elements in the detector.
std::string fROOTfile
path to geometry file for geometry in GeometryCore
float fECALEndcapStartX
Position of the start xplane of the ECAL endcap.
details::geometry_iterator_types::EndPos_t EndPos_t
float GetECALInnerAngle() const
details::geometry_iterator_types::BeginPos_t BeginPos_t
unsigned int fTrackerScnPlanes
geometry_iterator_base(const gar::geo::GeometryCore *geom)
Constructor: associates with the specified geometry.
typename id_iterator_t::BeginPos_t BeginPos_t
gar::geo::seg::ChannelMapAlg const * ChannelMap() const
Returns the object handling the channel map.
static constexpr double as
float GetECALBarrelApothemLength() const
double outer_nRadiationLengths
std::vector< NodeInfo_t > current_path
which node, which sibling?
float TPCRadius() const
Returns the radius of the TPC (y or z direction)
float GetECALInnerEndcapRadius() const
unsigned int fECALnLayers
number of ECAL layers from the seg algorithm
ECALLayeredCalorimeterData fECALLayeredCalorimeterData
IteratorBox(GeometryCore const *geom)
std::string fDetectorName
Name of the detector.
id_iterator_t id_iter
iterator performing the job
std::string GDMLFile() const
Returns the full directory path to the GDML file source.
std::map< gar::geo::LayeredCalorimeterData::LayoutType, std::shared_ptr< gar::geo::LayeredCalorimeterData > > ECALLayeredCalorimeterData
float GetActiveLArTPCLength() const
enum gar::geo::ROCType_ ROCType
ROOTGeoNodeForwardIterator(TGeoNode const *start_node)
Constructor: start from this node.
float TPCZCent() const
Returns the Z location of the center of the TPC in cm.
double SurfaceY() const
The position of the detector respect to earth surface.
float GetRockHalfHeight() const
float GetEnclosureZ() const
Iterator to navigate through all the nodes.
float fECALRinner
Minimum radius of the ECAL inner barrel.
bool HasTrackerScDetector() const
float GetWorldHalfHeight() const
unsigned int fMuIDnLayers
number of MuID layers from the seg algorithm
Definition of basic calo raw digits.
double distance(double x1, double y1, double z1, double x2, double y2, double z2)
static int max(int a, int b)
gar::geo::seg::SegmentationAlg const * ECALSegmentationAlg() const
Returns the object handling the ECAL segmentation.
float GetWorldLength() const
int fECALSymmetry
Number of sides of the Barrel.
MuIDSegmentationAlgPtr fMuIDSegmentationAlg
Object containing the segmentation for the Sc Tracker.
typename id_iterator_t::UndefinedPos_t UndefinedPos_t
gar::geo::seg::SegmentationAlg const * MinervaSegmentationAlg() const
Returns the object handling the Sc Tracker segmentation.
float GetEnclosureHalfHeight() const
typename id_iterator_t::ElementPtr_t ElementPtr_t
double DefaultWiggle() const
Returns the tolerance used in looking for positions.
float GetECALEndcapStartX() const
float GetMuIDOuterBarrelRadius() const
float GetActiveLArTPCY() const
int fMuIDSymmetry
Number of sides of the MuID Barrel.
float GetECALEndcapApothemLength() const
float GetECALOuterBarrelRadius() const
float GetMuIDBarrelSideLength() const
General GArSoft Utilities.
details::geometry_iterator_types::UndefinedPos_t UndefinedPos_t
bool HasECALDetector() const
std::shared_ptr< const gar::geo::seg::SegmentationAlg > ECALSegmentationAlgPtr
std::map< std::string, std::vector< const TGeoNode * > > fECALNodePath
Stored map of vectors of nodes for the ecal to speedup node searching.
double fMinWireZDist
to look for the closest wire
float GetEnclosureY() const
T min(sqlite3 *const db, std::string const &table_name, std::string const &column_name)
float GArLiteXCent() const
bool operator!=(GEOIDITER const &id_iter, geometry_element_iterator< GEOIDITER > const &iter)
Comparison operator: geometry ID and element point to different IDs.
double inner_nRadiationLengths
float TPCYCent() const
Returns the Y location of the center of the TPC in cm.
float GetEnclosureLength() const
geometry_element_iterator(id_iterator_t const &iter)
Constructor: points to the same element as the specified ID iterator.
bool HasMuonDetector() const
id_iterator_t const & id_iterator() const
Access to the base ID iterator.
std::string DetectorName() const
Returns a string with the name of the detector, as configured.
float GetMuIDBarrelApothemLength() const
Base class for geometry iterators (note: this is not an iterator)
float GetMPDHalfHeight() const
float GetECALInnerBarrelRadius() const
void SetDetectorName(std::string new_name)
Sets the detector name.
float GetLArTPCLength() const
std::string fGDMLfile
path to geometry file used for Geant4 simulation
float TPCLength() const
Returns the length of the TPC (x direction)
NodeInfo_t(Node_t new_self, int new_sibling)
LocalID_t const & ID() const
Returns the ID of the pointed geometry element.
float GetECALBarrelSideLength() const
double fSurfaceY
The point where air meets earth for this detector.
double fPositionWiggle
accounting for rounding errors when testing positions
Structures to distinguish the constructors.
QuadExpr operator*(double v, const QuadExpr &e)
LArSoft geometry interface.
int GetMuIDInnerSymmetry() const
ChannelMapPtr fChannelMapAlg
Object containing the channel to wire mapping.
gar::geo::seg::SegmentationAlg const * MuIDSegmentationAlg() const
Returns the object handling the MuID segmentation.
geo::GeometryCore const * geometry() const
Returns a pointer to the geometry.
bool operator==(GEOIDITER const &id_iter, geometry_element_iterator< GEOIDITER > const &iter)
Comparison operator: geometry ID and element point to the same ID.
std::string GetWorldVolumeName() const
std::string ROOTFile() const
Returns the full directory path to the geometry file source.
float GetActiveLArTPCX() const
float GetMPDHalfWidth() const
std::shared_ptr< const gar::geo::seg::SegmentationAlg > MuIDSegmentationAlgPtr
bool fHasTrackerScDetector
cet::coded_exception< error, detail::translate > exception
std::map< gar::geo::LayeredCalorimeterData::LayoutType, std::shared_ptr< gar::geo::LayeredCalorimeterData > > GetECALLayeredCalorimeterData() const
float GetECALEndcapOuterX() const
float GetLArTPCHalfHeight() const
float GetWorldHalfWidth() const
float GArLiteRadius() const
typename id_iterator_t::LocalID_t LocalID_t
types mirrored from the ID iterator
float GetECALEndcapSideLength() const
float GArLiteZCent() const
LayeredCalorimeterStruct LayeredCalorimeterData