25 #include "cetlib/pow.h" 26 #include "cetlib_except/exception.h" 32 #include <TGeoManager.h> 33 #include <TGeoMatrix.h> 35 #include <TGeoVolume.h> 53 void CheckIndependentPlanesOnSameTPC(
geo::PlaneID const& pid1,
59 << caller <<
" needs two planes on the same TPC (got " << std::string(pid1) <<
" and " 60 << std::string(pid2) <<
")\n";
64 << caller <<
" needs two different planes, got " << std::string(pid1) <<
" twice\n";
74 : fSurfaceY(pset.
get<double>(
"SurfaceY"))
75 , fDetectorName(pset.
get<
std::string>(
"Name"))
76 , fMinWireZDist(pset.
get<double>(
"MinWireZDist", 3.0))
77 , fPositionWiggle(pset.
get<double>(
"PositionEpsilon", 1.
e-4))
78 , fBuilderParameters(pset.
get<
fhicl::ParameterSet>(
"Builder",
fhicl::ParameterSet()))
99 if (gdmlfile.empty()) {
100 throw cet::exception(
"GeometryCore") <<
"No GDML Geometry file specified!\n";
103 if (rootfile.empty()) {
104 throw cet::exception(
"GeometryCore") <<
"No ROOT Geometry file specified!\n";
112 if (!gGeoManager || bForceReload) {
114 TGeoManager::UnlockGeometry();
125 TGeoManager::LockDefaultUnits(
false);
126 TGeoManager::SetDefaultUnits(TGeoManager::kRootUnits);
127 TGeoManager::LockDefaultUnits(
true);
129 TGeoManager::Import(rootfile.c_str());
130 gGeoManager->LockGeometry();
138 mf::LogInfo(
"GeometryCore") <<
"New detector geometry loaded from " 144 std::string rootfile,
165 mf::LogInfo(
"GeometryCore") <<
"Sorting volumes...";
172 cryo.SortSubVolumes(sorter);
185 for (
auto const& tpc : Iterate<TPCGeo>()) {
186 auto const& TPCviews = tpc.Views();
187 allViews.insert(TPCviews.cbegin(), TPCviews.cend());
212 std::vector<raw::ChannelID_t> channels;
215 for (
auto const& ts : Iterate<readout::TPCsetID>()) {
217 for (
auto const& wire : Iterate<WireID>(t)) {
222 std::sort(channels.begin(), channels.end());
223 auto last = std::unique(channels.begin(), channels.end());
224 channels.erase(last, channels.end());
232 for (
size_t cstat = 0; cstat !=
Ncryostats(); ++cstat)
284 <<
"Requested AuxDet index " << aid <<
" is out of range: " <<
NAuxDets();
305 if (
auto pCryo =
CryostatPtr(cryoid)) {
return *pCryo; }
321 throw cet::exception(
"GeometryCore") <<
"AuxDet " << ad <<
" does not exist\n";
330 if (!cryo)
return {};
334 if (tpcid)
return tpcid;
345 for (
auto const& cryostat : Iterate<CryostatGeo>()) {
346 if (cryostat.ContainsPosition(point, 1.0 +
fPositionWiggle))
return &cryostat;
369 throw cet::exception(
"GeometryCore") <<
"Can't find any TPC at position " << point <<
"\n";
376 return tpc ? tpc->
ID() :
TPCID{};
388 id.deepestIndex() = 0;
406 throw cet::exception(
"GeometryCore") <<
"Can't find any cryostat at position " << point <<
"\n";
418 double tolerance)
const 429 double tolerance)
const 439 double tolerance)
const 448 uint32_t
const& channel)
const 451 return this->
AuxDet(adIdx);
456 uint32_t
const& channel)
const 475 if (!ropid.isValid) {
476 throw cet::exception(
"GeometryCore") <<
"SignalType(): Mapping of wire plane " 477 << std::string(pid) <<
" to readout plane failed!\n";
505 return std::string(
"volWorld");
510 std::string
const& name )
const 515 <<
"DetectorEnclosureBox(): can't find enclosure volume '" << name <<
"'\n";
518 TGeoVolume
const* pEncl = path.back()->GetVolume();
519 auto const* pBox =
dynamic_cast<TGeoBBox const*
>(pEncl->GetShape());
525 <<
"Detector enclosure '" << name <<
"' is not a box! (it is a " 526 << pEncl->GetShape()->IsA()->GetName() <<
")\n";
531 const double halfwidth = pBox->GetDX();
532 const double halfheight = pBox->GetDY();
533 const double halflength = pBox->GetDZ();
536 trans.LocalToWorld(
Point_t{+halfwidth, +halfheight, +halflength})};
569 return current_path.empty() ?
nullptr : current_path.back().self;
576 std::vector<TGeoNode const*> get_path()
const;
580 TGeoNode
const*
self;
587 void reach_deepest_descendant();
598 if (!vol_names)
return true;
599 return vol_names->find(node.GetVolume()->GetName()) != vol_names->end();
612 if (matcher(node)) nodes.push_back(&node);
622 std::vector<std::vector<TGeoNode const*>>
paths;
629 if (matcher(**iter)) paths.push_back(iter.
get_path());
638 std::set<std::string>
const& vol_names)
const 643 TGeoNode
const* pCurrentNode;
645 while ((pCurrentNode = *iNode)) {
646 node_collector(*pCurrentNode);
650 return node_collector.
nodes;
655 std::set<std::string>
const& vol_names)
const 662 path_collector(iNode);
666 return path_collector.
paths;
726 id.deepestIndex() = 0;
786 for (
unsigned int p = 0; p < TPC.
Nplanes(); ++p) {
788 if (plane.
View() == view)
return plane.
ThetaZ();
791 <<
"WireAngleToVertical(): no view \"" <<
PlaneGeo::ViewName(view) <<
"\" (#" << ((int)view)
792 <<
") in " << std::string(tpcid);
798 unsigned int maxTPCs = 0;
800 unsigned int maxTPCsInCryo = cryo.NTPC();
801 if (maxTPCsInCryo > maxTPCs) maxTPCs = maxTPCsInCryo;
811 return std::accumulate(
813 return sum + cryo.
NTPC();
820 unsigned int maxPlanes = 0;
822 unsigned int maxPlanesInCryo = cryo.MaxPlanes();
823 if (maxPlanesInCryo > maxPlanes) maxPlanes = maxPlanesInCryo;
831 unsigned int maxWires = 0;
833 unsigned int maxWiresInCryo = cryo.MaxWires();
834 if (maxWiresInCryo > maxWires) maxWires = maxWiresInCryo;
848 id.deepestIndex() = 0;
895 TGeoShape
const* s = world->GetShape();
902 s->GetAxisRange(1, x1, x2);
903 s->GetAxisRange(2, y1, y2);
904 s->GetAxisRange(3, z1, z2);
919 if (xlo) *xlo = box.
MinX();
920 if (ylo) *ylo = box.
MinY();
921 if (zlo) *zlo = box.
MinZ();
922 if (xhi) *xhi = box.
MaxX();
923 if (yhi) *yhi = box.
MaxY();
924 if (zhi) *zhi = box.
MaxZ();
932 double halflength = ((TGeoBBox*)volWorld->GetShape())->GetDZ();
933 double halfheight = ((TGeoBBox*)volWorld->GetShape())->GetDY();
934 double halfwidth = ((TGeoBBox*)volWorld->GetShape())->GetDX();
938 <<
"point (" << point.x() <<
"," << point.y() <<
"," << point.z() <<
") " 939 <<
"is not inside the world volume " 940 <<
" half width = " << halfwidth <<
" half height = " << halfheight
941 <<
" half length = " << halflength <<
" returning unknown volume name";
942 return "unknownVolume";
945 return gGeoManager->FindNode(point.X(), point.Y(), point.Z())->GetName();
951 auto const pNode = gGeoManager->FindNode(point.X(), point.Y(), point.Z());
952 if (!pNode)
return nullptr;
953 auto const pMedium = pNode->GetMedium();
954 return pMedium ? pMedium->GetMaterial() :
nullptr;
964 <<
"point " << point <<
" is not inside the world volume " << worldBox.
Min() <<
" -- " 965 << worldBox.
Max() <<
"; returning unknown material name";
966 return {
"unknownMaterial"};
968 auto const pMaterial =
Material(point);
971 <<
"material for point " << point <<
" not found! returning unknown material name";
972 return {
"unknownMaterial"};
974 return pMaterial->GetName();
979 std::string
const& name )
const 981 std::vector<TGeoNode const*> path{
ROOTGeoManager()->GetTopNode()};
988 std::vector<const TGeoNode*>& path)
const 990 assert(!path.empty());
992 auto const* pCurrent = path.back();
995 if (strncmp(name.c_str(), pCurrent->GetName(), name.length()) == 0)
return true;
998 auto const* pCurrentVolume = pCurrent->GetVolume();
999 unsigned int nd = pCurrentVolume->GetNdaughters();
1000 for (
unsigned int i = 0; i < nd; ++i) {
1001 path.push_back(pCurrentVolume->GetNode(i));
1025 TGeoVolume* gvol = gGeoManager->FindVolumeFast(vol.c_str());
1026 if (gvol)
return gvol->Weight();
1029 <<
"could not find specified volume '" << vol <<
" 'to determine total mass\n";
1040 double columnD = 0.;
1045 double const dxyz[3] = {dir.X(), dir.Y(), dir.Z()};
1046 double const cp1[3] = {p1.X(), p1.Y(), p1.Z()};
1047 gGeoManager->InitTrack(cp1, dxyz);
1050 TGeoNode* node = gGeoManager->GetCurrentNode();
1055 while (!gGeoManager->IsSameLocation(p2.X(), p2.Y(), p2.Z())) {
1056 gGeoManager->FindNextBoundary();
1057 columnD += gGeoManager->GetStep() * node->GetMedium()->GetMaterial()->GetDensity();
1060 node = gGeoManager->Step();
1066 double const lastStep = (p2 - last).R();
1067 columnD += lastStep * node->GetMedium()->GetMaterial()->GetDensity();
1075 std::ostringstream sstr;
1076 Print(sstr, indent);
1134 xyzStart[0] = result.
start().X();
1135 xyzStart[1] = result.
start().Y();
1136 xyzStart[2] = result.
start().Z();
1137 xyzEnd[0] = result.
end().X();
1138 xyzEnd[1] = result.
end().Y();
1139 xyzEnd[2] = result.
end().Z();
1141 if (xyzEnd[2] < xyzStart[2]) {
1143 std::swap(xyzStart[0], xyzEnd[0]);
1144 std::swap(xyzStart[1], xyzEnd[1]);
1145 std::swap(xyzStart[2], xyzEnd[2]);
1147 if (xyzEnd[1] < xyzStart[1] &&
std::abs(xyzEnd[2] - xyzStart[2]) < 0.01) {
1149 std::swap(xyzStart[0], xyzEnd[0]);
1150 std::swap(xyzStart[1], xyzEnd[1]);
1151 std::swap(xyzStart[2], xyzEnd[2]);
1165 if (chan1wires.empty()) {
1167 <<
"1st channel " << c1 <<
" maps to no wire (is it a real one?)";
1171 if (chan2wires.empty()) {
1173 <<
"2nd channel " << c2 <<
" maps to no wire (is it a real one?)";
1177 if (chan1wires.size() > 1) {
1179 <<
"1st channel " << c1 <<
" maps to " << chan2wires.size() <<
" wires; using the first!";
1182 if (chan2wires.size() > 1) {
1184 <<
"2nd channel " << c2 <<
" maps to " << chan2wires.size() <<
" wires; using the first!";
1206 static_assert(std::numeric_limits<decltype(widIntersect.
y)>::has_infinity,
1207 "the vector coordinate type can't represent infinity!");
1208 constexpr
auto infinity = std::numeric_limits<decltype(widIntersect.
y)>::infinity();
1211 widIntersect.
y = widIntersect.
z = infinity;
1233 widIntersect.
y = widIntersect.
z = infinity;
1267 static_assert(std::numeric_limits<decltype(intersection.X())>::has_infinity,
1268 "the vector coordinate type can't represent infinity!");
1269 constexpr
auto infinity = std::numeric_limits<decltype(intersection.X())>::infinity();
1272 intersection = {infinity, infinity, infinity};
1282 intersection = intersectionAndOffset.
point;
1295 const unsigned int nPlanes =
Nplanes(pid1);
1298 <<
"ThirdPlane() supports only TPCs with 3 planes, and I see " << nPlanes <<
" instead\n";
1303 if ((iPlane == pid1.
Plane) || (iPlane == pid2.
Plane))
continue;
1304 if (target_plane != nPlanes) {
1306 <<
"ThirdPlane() found too many planes that are not " << std::string(pid1) <<
" nor " 1307 << std::string(pid2) <<
"! (first " << target_plane <<
", then " << iPlane <<
")\n";
1309 target_plane = iPlane;
1311 if (target_plane == nPlanes) {
1313 <<
"ThirdPlane() can't find a plane that is not " << std::string(pid1) <<
" nor " 1314 << std::string(pid2) <<
"!\n";
1317 return PlaneID(pid1, target_plane);
1325 PlaneID const& output_plane)
const 1327 CheckIndependentPlanesOnSameTPC(pid1, pid2,
"ThirdPlaneSlope()");
1345 double slope2)
const 1356 PlaneID const& output_plane)
const 1358 CheckIndependentPlanesOnSameTPC(pid1, pid2,
"ThirdPlane_dTdW()");
1362 double angle[3], pitch[3];
1363 PlaneGeo const*
const planes[3] = {
1369 for (
size_t i = 0; i < 3; ++i) {
1370 angle[i] = planes[i]->
PhiZ();
1375 angle[0], pitch[0], slope1, angle[1], pitch[1], slope2, angle[2], pitch[2]);
1382 double slope2)
const 1405 if ((
std::abs(slope1) < 0.001) && (
std::abs(slope2)) < 0.001)
return 0.001;
1409 double slope3 = 0.001;
1412 (+(1. / slope1) * std::sin(angle3 - angle2) - (1. / slope2) * std::sin(angle3 - angle1)) /
1413 std::sin(angle1 - angle2);
1416 slope3 = 1. / slope3;
1430 double angle_target,
1431 double pitch_target)
1438 return pitch_target *
1571 static bool Loaded =
false;
1572 static std::vector<unsigned int> LowestID;
1573 static unsigned int NCryo;
1577 if (Loaded ==
false) {
1583 LowestID.resize(NCryo + 1);
1585 for (
size_t cryo = 0; cryo != NCryo; ++cryo) {
1586 LowestID.at(cryo + 1) = LowestID.at(cryo) +
Cryostat(cid).
NOpDet();
1590 if ((c < NCryo) && (o <
Cryostat(cid).NOpDet())) {
return LowestID.at(c) + o; }
1593 <<
"Coordinates c=" << c <<
", o=" << o <<
" out of range. Abort\n";
1605 static bool Loaded =
false;
1606 static std::vector<unsigned int> LowestID;
1607 static size_t NCryo;
1609 if (Loaded ==
false) {
1615 LowestID.resize(NCryo + 1);
1617 for (
size_t cryo = 0; cryo != NCryo; ++cryo) {
1622 for (
size_t i = 0; i != NCryo; ++i) {
1623 if ((OpDet >= LowestID[i]) && (OpDet < LowestID[i + 1])) {
1625 int o = OpDet - LowestID[i];
1630 throw cet::exception(
"OpID To OpDetCryo error") <<
"OpID out of range, " << OpDet <<
"\n";
1638 if (!cryo)
return std::numeric_limits<unsigned int>::max();
1648 <<
"Comparing two wires on different TPCs: return failure.";
1653 <<
"Comparing two wires in the same plane: return failure";
1658 <<
"1st wire " << wid1 <<
" does not exist (max wire number: " <<
Nwires(wid1.
planeID())
1664 <<
"2nd wire " << wid2 <<
" does not exist (max wire number: " <<
Nwires(wid2.
planeID())
1678 current_path.push_back({start_node, 0U});
1679 reach_deepest_descendant();
1685 if (current_path.empty())
return *
this;
1686 if (current_path.size() == 1) {
1687 current_path.pop_back();
1694 NodeInfo_t const& parent = current_path[current_path.size() - 2];
1695 if (++(current.
sibling) < parent.
self->GetNdaughters()) {
1698 reach_deepest_descendant();
1701 current_path.pop_back();
1708 std::vector<TGeoNode const*> node_path(current_path.size());
1709 std::transform(current_path.begin(),
1712 [](
NodeInfo_t const& node_info) {
return node_info.self; });
1719 TGeoNode
const* descendent = current_path.back().self;
1720 while (descendent->GetNdaughters() > 0) {
1721 descendent = descendent->GetDaughter(0);
1722 current_path.push_back({descendent, 0U});
geo::TPCID const & ID() const
Returns the identifier of this TPC.
unsigned int NAuxDetSensitive(size_t const &aid) const
Returns the number of sensitive components of auxiliary detector.
CryostatGeo const * PositionToCryostatPtr(Point_t const &point) const
Returns the cryostat at specified location.
WireID GetBeginWireID(CryostatID const &id) const
Returns the ID of the first wire in the specified cryostat.
Geometry description of a TPC wireThe wire is a single straight segment on a wire plane...
GeoID GetEndID() const
Returns the (possibly invalid) ID after the last subelement of the detector.
unsigned int GetClosestOpDet(geo::Point_t const &point) const
std::string GetLArTPCVolumeName(TPCID const &tpcid=tpc_zero) const
Return the name of specified LAr TPC volume.
IDparameter< geo::CryostatID > CryostatID
Member type of validated geo::CryostatID parameter.
void LoadGeometryFile(std::string gdmlfile, std::string rootfile, GeometryBuilder &builder, bool bForceReload=false)
Loads the geometry information from the specified files.
Length_t WireCoordinate(Point_t const &pos, PlaneID const &planeid) const
Returns the index of the nearest wire to the specified position.
Specializations of geo_vectors_utils.h for ROOT old vector types.
double z
z position of intersection
Functions to help with numbers.
double PlanePitch(unsigned int p1=0, unsigned int p2=1) const
Returns the center of the TPC volume in world coordinates [cm].
OpDetGeo const & OpDetGeoFromOpDet(unsigned int OpDet) const
Returns the geo::OpDetGeo object for the given detector number.
static std::string ViewName(geo::View_t view)
Returns the name of the specified view.
TGeoNode const * operator*() const
Returns the pointer to the current node, or nullptr if none.
unsigned int TotalNTPC() const
Returns the total number of TPCs in the detector.
void SortGeometry(GeoObjectSorter const &sorter)
Runs the sorting of geometry with the sorter provided by channel mapping.
GeometryData_t fGeoData
The detector description data.
std::vector< PlaneID > ROPtoWirePlanes(readout::ROPID const &ropid) const
Returns a list of ID of planes belonging to the specified ROP.
static constexpr TPCID_t InvalidID
Special code for an invalid ID.
std::vector< NodeInfo_t > current_path
which node, which sibling?
std::vector< WireID > ChannelToWire(raw::ChannelID_t const channel) const
Returns a list of wires connected to the specified TPC channel.
bool operator()(TGeoNode const &node) const
Returns whether the specified node matches a set of names.
unsigned int MaxPlanes() const
Returns the largest number of planes among the TPCs in this cryostat.
double Length_t
Type used for coordinates and distances. They are measured in centimeters.
Float_t y1[n_points_granero]
ROOTGeoNodeForwardIterator & operator++()
Points to the next node, or to nullptr if there are no more.
ROOT::Math::DisplacementVector3D< ROOT::Math::Cartesian3D< double >, ROOT::Math::GlobalCoordinateSystemTag > Vector_t
Type for representation of momenta in 3D space.
Encapsulate the geometry of the sensitive portion of an auxiliary detector.
GeoID GetBeginID() const
Returns the ID of the first element of the detector.
bool HasWire(WireID const &wireid) const
Returns whether we have the specified wire.
unsigned int FindAuxDetAtPosition(Point_t const &point, double tolerance=0) const
Returns the index of the auxiliary detector at specified location.
void Print(Stream &&out, std::string indent=" ") const
Prints geometry information with maximum verbosity.
enum geo::_plane_proj View_t
Enumerate the possible plane projections.
void BuildGeometry(GeometryBuilder &builder)
double ActiveHalfHeight() const
Half height (associated with y coordinate) of active TPC volume [cm].
MaybeLogger_< ELseverityLevel::ELsev_info, false > LogInfo
AuxDetSensitiveGeo const & SensitiveVolume(size_t sv) const
unsigned int Nplanes() const
Number of planes in this tpc.
Float_t x1[n_points_granero]
PlaneGeo const * PlanePtr(PlaneID const &planeid) const
Returns the specified plane.
static double ComputeThirdPlane_dTdW(double angle1, double pitch1, double dTdW1, double angle2, double pitch2, double dTdW2, double angle_target, double pitch_target)
Returns the slope on the third plane, given it in the other two.
Length_t DetHalfWidth(TPCID const &tpcid=tpc_zero) const
Returns the half width of the active volume of the specified TPC.
double MinX() const
Returns the world x coordinate of the start of the box.
unsigned int PlaneID_t
Type for the ID number.
unsigned int GetClosestOpDet(Point_t const &point) const
Find the nearest OpChannel to some point.
The data type to uniquely identify a Plane.
Geometry information for a single TPC.
Length_t CryostatHalfWidth(CryostatID const &cid=cryostat_zero) const
Returns the half width of the cryostat (x direction)
bool WireIDsIntersect(WireID const &wid1, WireID const &wid2, Point_t &intersection) const
Computes the intersection between two wires.
std::vector< TPCID > TPCsetToTPCs(readout::TPCsetID const &tpcsetid) const
Returns a list of ID of TPCs belonging to the specified TPC set.
unsigned int MaxROPs() const
Returns the largest number of ROPs a TPC set in the detector has.
std::set< View_t > allViews
All views in the detector.
Class identifying a set of TPC sharing readout channels.
BoxBoundedGeo DetectorEnclosureBox(std::string const &name="volDetEnclosure") const
const std::string GetWorldVolumeName() const
Return the name of the world volume (needed by Geant4 simulation)
Point const & start() const
std::vector< TGeoNode const * > FindDetectorEnclosure(std::string const &name="volDetEnclosure") const
constexpr auto abs(T v)
Returns the absolute value of the argument.
unsigned int NOpHardwareChannels(int opDet) const
Number of electronics channels for all the optical detectors.
Cryostats_t extractCryostats(Path_t const &path)
Looks for all cryostats under the specified path.
bool ChannelsIntersect(raw::ChannelID_t c1, raw::ChannelID_t c2, double &y, double &z) const
Returns an intersection point of two channels.
TGeoVolume const * WorldVolume() const
Returns a pointer to the world volume.
CryostatID_t Cryostat
Index of cryostat.
details::begin_type< T > begin() const
Initializes the specified ID with the ID of the first cryostat.
unsigned int MaxWires() const
Returns the largest number of wires among all planes in this detector.
TPCID GetEndTPCID(CryostatID const &id) const
readout::TPCsetID FindTPCsetAtPosition(Point_t const &worldLoc) const
Returns the ID of the TPC set at specified location.
double MaxX() const
Returns the world x coordinate of the end of the box.
virtual void SortAuxDets(std::vector< geo::AuxDetGeo > &adgeo) const =0
bool WireIDIntersectionCheck(const WireID &wid1, const WireID &wid2) const
Wire ID check for WireIDsIntersect methods.
const AuxDetSensitiveGeo & ChannelToAuxDetSensitive(std::string const &auxDetName, uint32_t const &channel) const
Returns the number of auxiliary detectors.
Point const & end() const
double WireCoordinate(geo::Point_t const &point) const
Returns the coordinate of the point on the plane, in wire units.
bool FindFirstVolume(std::string const &name, std::vector< const TGeoNode * > &path) const
MaybeLogger_< ELseverityLevel::ELsev_error, false > LogError
TGeoMaterial const * Material(Point_t const &point) const
Returns the material at the specified position.
unsigned int TPC
TPC of intersection.
Geometry information for a single cryostat.
WireGeo const & Wire(WireID const &wireid) const
Returns the specified wire.
std::set< std::string > const * vol_names
unsigned int Ncryostats() const
Returns the number of cryostats in the detector.
CryostatGeo const & Cryostat(CryostatID const &cryoid=cryostat_zero) const
Returns the specified cryostat.
void operator()(TGeoNode const &node)
If the name of the node matches, records the end node.
CryostatGeo const & PositionToCryostat(Point_t const &point) const
Returns the cryostat at specified location.
unsigned int NOpChannels() const
Number of electronics channels for all the optical detectors.
bool PointWithinSegments(double A_start_x, double A_start_y, double A_end_x, double A_end_y, double B_start_x, double B_start_y, double B_end_x, double B_end_y, double x, double y)
Returns whether x and y are within both specified ranges (A and B).
Length_t CryostatHalfHeight(CryostatID const &cid=cryostat_zero) const
Returns the height of the cryostat (y direction)
TGeoManager * ROOTGeoManager() const
Access to the ROOT geometry description manager.
Length_t DetLength(TPCID const &tpcid=tpc_zero) const
Returns the length of the active volume of the specified TPC.
unsigned int OpDetFromCryo(unsigned int o, unsigned int c) const
Get unique opdet number from cryo and internal count.
std::string OpDetGeoName(CryostatID const &cid=cryostat_zero) const
Returns gdml string which gives sensitive opdet name.
Float_t y2[n_points_geant4]
unsigned int OpDetFromOpChannel(int opChannel) const
Convert unique channel to detector number.
unsigned int Nchannels() const
Returns the number of TPC readout channels in the detector.
std::vector< std::vector< TGeoNode const * > > paths
TPCGeo const & TPC(TPCID const &tpcid=tpc_zero) const
Returns the specified TPC.
double offset2
Distance from reference point of second line.
geo::TPCGeo const * PositionToTPCptr(geo::Point_t const &point, double wiggle) const
Returns a pointer to the TPC at specified location.
IDparameter< geo::PlaneID > PlaneID
Member type of validated geo::PlaneID parameter.
double ThetaZ() const
Angle of the wires from positive z axis; .
IntersectionPointAndOffsets< Point_t > WiresIntersectionAndOffsets(WireGeo const &wireA, WireGeo const &wireB)
Returns the point of wireA that is closest to wireB.
double TotalMass() const
Returns the total mass [kg] of the specified volume (default: world).
bool IntersectLines(double A_start_x, double A_start_y, double A_end_x, double A_end_y, double B_start_x, double B_start_y, double B_end_x, double B_end_y, double &x, double &y)
Computes the intersection between two lines on a plane.
std::vector< TPCID > ROPtoTPCs(readout::ROPID const &ropid) const
Returns a list of ID of TPCs the specified ROP spans.
Access the description of detector geometry.
void operator()(ROOTGeoNodeForwardIterator const &iter)
If the name of the node matches, records the node full path.
virtual void SortCryostats(std::vector< geo::CryostatGeo > &cgeo) const =0
PlaneGeo const & Plane(PlaneID const &planeid) const
Returns the specified wire.
bool HasROP(readout::ROPID const &ropid) const
double WireAngleToVertical(View_t view, TPCID const &tpcid) const
Returns the angle of the wires in the specified view from vertical.
View_t View() const
Which coordinate does this plane measure.
std::string OpDetGeoName() const
Get name of opdet geometry element.
NodeNameMatcherClass matcher
std::string VolumeName(Point_t const &point) const
Returns the name of the deepest volume containing specified point.
constexpr ChannelID_t InvalidChannelID
ID of an invalid channel.
TPCID FindTPCAtPosition(Point_t const &point) const
Returns the ID of the TPC at specified location.
std::unique_ptr< const ChannelMapAlg > fChannelMapAlg
Object containing the channel to wire mapping.
unsigned int MaxPlanes() const
Returns the largest number of planes among all TPCs in this detector.
Iterator to navigate through all the nodes.
const TGeoVolume * Volume() const
Pointer to ROOT's volume descriptor.
Classes to project and compose a vector on a plane.
geo::WireID NearestWireID(geo::Point_t const &pos) const
Returns the ID of wire closest to the specified position.
void operator()(ROOTGeoNodeForwardIterator const &iter)
const OpDetGeo & OpDet(unsigned int iopdet) const
Return the iopdet'th optical detector in the cryostat.
const AuxDetSensitiveGeo & PositionToAuxDetSensitive(Point_t const &point, size_t &ad, size_t &sv, double tolerance=0) const
Returns the auxiliary detector at specified location.
ROOTGeoNodeForwardIterator(TGeoNode const *start_node)
double PhiZ() const
Angle from positive z axis of the wire coordinate axis, in radians.
AuxDets_t extractAuxiliaryDetectors(Path_t const &path)
Looks for all auxiliary detectors under the specified path.
raw::ChannelID_t FirstChannelInROP(readout::ROPID const &ropid) const
Returns the ID of the first channel in the specified readout plane.
void ClearGeometry()
Deletes the detector geometry structures.
unsigned int HardwareChannelFromOpChannel(int opChannel) const
Convert unique channel to hardware channel.
GeometryCore(fhicl::ParameterSet const &pset)
Initialize geometry from a given configuration.
enum geo::_plane_sigtype SigType_t
Enumerate the possible plane projections.
TPCGeo const & PositionToTPC(Point_t const &point) const
Returns the TPC at specified location.
CryostatGeo const * CryostatPtr(CryostatID const &cryoid) const
Returns the specified cryostat.
void FindAuxDetSensitiveAtPosition(Point_t const &point, std::size_t &adg, std::size_t &sv, double tolerance=0) const
Fills the indices of the sensitive auxiliary detector at location.
double ActiveHalfWidth() const
Half width (associated with x coordinate) of active TPC volume [cm].
std::string MaterialName(Point_t const &point) const
Name of the deepest material containing the point xyz.
std::string indent(std::size_t const i)
double HalfWidth() const
Half width of the cryostat [cm].
Geometry information for a single wire plane.The plane is represented in the geometry by a solid whic...
NodeNameMatcherClass(std::set< std::string > const &names)
Utilities to extend the interface of geometry vectors.
double MinZ() const
Returns the world z coordinate of the start of the box.
unsigned int NTPC() const
Number of TPCs in this cryostat.
TPCID GetBeginTPCID(CryostatID const &id) const
Returns the ID of the first TPC in the specified cryostat.
PlaneID GetBeginPlaneID(CryostatID const &id) const
Returns the ID of the first plane of the specified cryostat.
unsigned int MaxOpChannel() const
Largest optical channel number.
const TGeoVolume * ActiveVolume() const
Half width (associated with x coordinate) of active TPC volume [cm].
std::string Info(std::string indent=" ") const
Returns a string with complete geometry information.
geo::Point_t Min() const
Returns the corner point with the smallest coordinates.
The data type to uniquely identify a TPC.
PlaneID_t Plane
Index of the plane within its TPC.
details::end_type< T > end() const
Initializes the specified ID with the ID of the first cryostat.
void UpdateAfterSorting()
Performs all the updates needed after sorting.
void markInvalid()
Sets the ID as invalid.
unsigned int MaxWires() const
Returns the largest number of wires among the planes in this TPC.
readout::ROPID WirePlaneToROP(PlaneID const &planeid) const
Returns the ID of the ROP planeid belongs to.
AuxDetList_t & AuxDets()
Return the internal auxdet list.
unsigned int MaxWires() const
Returns the largest number of wires among the TPCs in this cryostat.
NodeNameMatcherClass matcher
Point point
Intersection point.
Class identifying a set of planes sharing readout channels.
AuxDetGeo const & AuxDet(unsigned int const ad=0) const
Returns the specified auxiliary detector.
double ActiveLength() const
Length (associated with z coordinate) of active TPC volume [cm].
unsigned int NOpDets() const
Number of OpDets in the whole detector.
std::vector< TGeoNode const * > get_path() const
Returns the full path of the current node.
double fPositionWiggle
accounting for rounding errors when testing positions
double MaxY() const
Returns the world y coordinate of the end of the box.
Encapsulate the geometry of an auxiliary detector.
constexpr TPCID const & asTPCID() const
Conversion to TPCID (for convenience of notation).
std::vector< TGeoNode const * > FindAllVolumes(std::set< std::string > const &vol_names) const
Returns all the nodes with volumes with any of the specified names.
double HalfHeight() const
Half height of the cryostat [cm].
readout::ROPID ChannelToROP(raw::ChannelID_t channel) const
unsigned int OpChannel(int detNum, int hardwareChannel) const
Convert detector number and hardware channel to unique channel.
AuxDetGeo const & PositionToAuxDet(Point_t const &point, unsigned int &ad, double tolerance=0) const
Returns the auxiliary detector at specified location.
double HalfL() const
Returns half the length of the wire [cm].
Encapsulate the geometry of an optical detector.
std::string fGDMLfile
path to geometry file used for Geant4 simulation
BoxBoundedGeo WorldBox() const
CryostatID PositionToCryostatID(Point_t const &point) const
Returns the ID of the cryostat at specified location.
ROOT::Math::PositionVector3D< ROOT::Math::Cartesian3D< double >, ROOT::Math::GlobalCoordinateSystemTag > Point_t
Type for representation of position in physical 3D space.
double MassBetweenPoints(Point_t const &p1, Point_t const &p2) const
Returns the column density between two points.
unsigned int CryostatID_t
Type for the ID number.
raw::ChannelID_t PlaneWireToChannel(WireID const &wireid) const
Returns the ID of the TPC channel connected to the specified wire.
Standard implementation of geometry extractor.
SigType_t SignalType(PlaneID const &pid) const
Returns the type of signal on the channels of specified TPC plane.
decltype(auto) get(T &&obj)
ADL-aware version of std::to_string.
unsigned int NTPCsets(geo::CryostatID const &cryoid) const
Returns the total number of TPC sets in the specified cryostat.
WireID NearestWireID(Point_t const &point, PlaneID const &planeid) const
Returns the ID of wire closest to position in the specified TPC.
A base class aware of world box coordinatesAn object describing a simple shape can inherit from this ...
static double ComputeThirdPlaneSlope(double angle1, double slope1, double angle2, double slope2, double angle_target)
Returns the slope on the third plane, given it in the other two.
CollectNodesByName(std::set< std::string > const &names)
std::vector< TGeoNode const * > nodes
double ThirdPlane_dTdW(PlaneID const &pid1, double slope1, PlaneID const &pid2, double slope2, PlaneID const &output_plane) const
Returns dT/dW on the third plane, given it in the other two.
unsigned int NOpDet() const
Number of optical detectors in this TPC.
Length_t CryostatLength(CryostatID const &cid=cryostat_zero) const
Returns the length of the cryostat (z direction)
TPCGeo const * TPCPtr(TPCID const &tpcid) const
Returns the specified TPC.
double y
y position of intersection
void ApplyChannelMap(std::unique_ptr< ChannelMapAlg > pChannelMap)
Initializes the geometry to work with this channel map.
double MaxZ() const
Returns the world z coordinate of the end of the box.
Length_t PlanePitch(TPCID const &tpcid, PlaneID::PlaneID_t p1=0, PlaneID::PlaneID_t p2=1) const
Returns the distance between two planes.
unsigned int MaxTPCsets() const
Returns the largest number of TPC sets any cryostat in the detector has.
View_t View(PlaneID const &pid) const
Returns the view (wire orientation) on the channels of specified TPC plane.
unsigned int Nwires() const
Number of wires in this plane.
MaybeLogger_< ELseverityLevel::ELsev_warning, false > LogWarning
double ThirdPlaneSlope(PlaneID const &pid1, double slope1, PlaneID const &pid2, double slope2, PlaneID const &output_plane) const
Returns the slope on the third plane, given it in the other two.
CryostatList_t & Cryostats()
Return the internal cryostat list.
Simple class with two points (a pair with aliases).
unsigned int Nwires(PlaneID const &planeid) const
Returns the total number of wires in the specified plane.
PlaneID ThirdPlane(PlaneID const &pid1, PlaneID const &pid2) const
Returns the plane that is not in the specified arguments.
readout::TPCsetID TPCtoTPCset(TPCID const &tpcid) const
Returns the ID of the TPC set tpcid belongs to.
const AuxDetGeo & ChannelToAuxDet(std::string const &auxDetName, uint32_t const &channel) const
Returns the number of auxiliary detectors.
raw::ChannelID_t NearestChannel(Point_t const &worldLoc, PlaneID const &planeid) const
Returns the ID of the channel nearest to the specified position.
std::string fDetectorName
Name of the detector.
Data structure for return values of LineClosestPointAndOffsets().
Manages the extraction of LArSoft geometry information from ROOT.
unsigned int Nplanes(TPCID const &tpcid=tpc_zero) const
Returns the total number of planes in the specified TPC.
Representation of a node and its ancestry.
std::vector< std::vector< TGeoNode const * > > FindAllVolumePaths(std::set< std::string > const &vol_names) const
Returns paths of all nodes with volumes with the specified names.
Length_t DetHalfHeight(TPCID const &tpcid=tpc_zero) const
Returns the half height of the active volume of the specified TPC.
unsigned int NROPs(readout::TPCsetID const &tpcsetid) const
Returns the total number of ROP in the specified TPC set.
PlaneGeo const & Plane(geo::View_t view) const
Return the plane in the tpc with View_t view.
constexpr PlaneID const & planeID() const
bool IntersectionPoint(WireID const &wid1, WireID const &wid2, double &y, double &z) const
Returns the intersection point of two wires.
unsigned int Nviews() const
Returns the number of views (different wire orientations)
unsigned int ChannelID_t
Type representing the ID of a readout channel.
Vector cross(Vector const &a, Vector const &b)
Return cross product of two vectors.
TPCID_t TPC
Index of the TPC within its cryostat.
CollectPathsByName(std::set< std::string > const &names)
Collection of Physical constants used in LArSoft.
Float_t x2[n_points_geant4]
GeoID GetNextID(GeoID const &id) const
Returns the ID next to the specified one.
WireID GetEndWireID(CryostatID const &id) const
void reach_deepest_descendant()
GENVECTOR_CONSTEXPR::geo::Point_t makePointFromCoords(Coords &&coords)
Creates a geo::Point_t from its coordinates (see makeFromCoords()).
TPCGeo const * PositionToTPCptr(Point_t const &point) const
Returns the TPC at specified location.
Namespace collecting geometry-related classes utilities.
fhicl::ParameterSet fBuilderParameters
double MinY() const
Returns the world y coordinate of the start of the box.
double offset1
Distance from reference point of first line.
OpDetGeo const & OpDetGeoFromOpChannel(unsigned int OpChannel) const
Returns the geo::OpDetGeo object for the given channel number.
unsigned int MaxTPCs() const
Returns the largest number of TPCs a cryostat in the detector has.
std::string fROOTfile
path to geometry file for geometry in GeometryCore
geo::Point_t Max() const
Returns the corner point with the largest coordinates.
std::string GetCryostatVolumeName(CryostatID const &cid) const
Return the name of LAr TPC volume.
Length_t WirePitch(PlaneID const &planeid=plane_zero) const
Returns the distance between two consecutive wires.
bool IsValidOpChannel(int opChannel) const
Is this a valid OpChannel number?
geo::TPCID PositionToTPCID(geo::Point_t const &point, double wiggle) const
Returns the ID of the TPC at specified location.
bool ContainsPosition(geo::Point_t const &point, double wiggle=1.0) const
Returns whether this volume contains the specified point.
TPCID PositionToTPCID(Point_t const &point) const
Returns the ID of the TPC at specified location.
Extracts of LArSoft geometry information from ROOT.
std::vector< raw::ChannelID_t > ChannelsInTPCs() const
Returns an std::vector<ChannelID_t> in all TPCs in a TPCSet.
bool HasChannel(raw::ChannelID_t channel) const
Returns whether the specified channel exists and is valid.
cet::coded_exception< error, detail::translate > exception
double WirePitch() const
Return the wire pitch (in centimeters). It is assumed constant.
double Length() const
Length of the cryostat [cm].
unsigned int NAuxDets() const
Returns the number of auxiliary detectors.
void WireEndPoints(WireID const &wireid, double *xyzStart, double *xyzEnd) const
Fills two arrays with the coordinates of the wire end points.
The data type to uniquely identify a cryostat.
geo::CryostatID const & ID() const
Returns the identifier of this cryostat.
bool HasTPCset(readout::TPCsetID const &tpcsetid) const
PlaneID GetEndPlaneID(CryostatID const &id) const