24 #include "cetlib_except/exception.h" 28 #include <TGeoManager.h> 30 #include <TGeoVolume.h> 31 #include <TGeoMatrix.h> 33 #include <TGeoVolume.h> 51 inline T
sqr(T v) {
return v * v; }
64 : fSurfaceY (pset.get< double >(
"SurfaceY" ))
65 , fDetectorName (pset.get<
std::string >(
"Name" ))
66 , fMinWireZDist (pset.get< double >(
"MinWireZDist", 3.0 ))
67 , fPositionWiggle (pset.get< double >(
"PositionEpsilon", 1.
e-4))
82 (std::shared_ptr<geo::ChannelMapAlg> pChannelMap)
93 std::string gdmlfile, std::string rootfile,
97 if (gdmlfile.empty()) {
99 <<
"No GDML Geometry file specified!\n";
102 if (rootfile.empty()) {
104 <<
"No ROOT Geometry file specified!\n";
112 if( !gGeoManager || bForceReload ){
113 if (gGeoManager) TGeoManager::UnlockGeometry();
114 TGeoManager::Import(rootfile.c_str());
115 gGeoManager->LockGeometry();
119 path[0] = gGeoManager->GetTopNode();
126 mf::LogInfo(
"GeometryCore") <<
"New detector geometry loaded from " 139 std::default_delete<AuxDetGeo>());
148 mf::LogInfo(
"GeometryCore") <<
"Sorting volumes...";
161 cryo.SortSubVolumes(sorter);
177 auto const& TPCviews = tpc.Views();
178 allViews.insert(TPCviews.cbegin(), TPCviews.cend());
206 for(
size_t cstat=0; cstat!=
Ncryostats(); cstat++)
258 throw cet::exception(
"Geometry") <<
"Requested AuxDet index " << aid
259 <<
" is out of range: " <<
NAuxDets();
261 return AuxDets()[aid]->NSensitiveVolume();
285 <<
" does not exist\n";
304 <<
" does not exist\n";
315 if (!cryo)
return {};
319 if (tpcid)
return tpcid;
361 (
double const worldLoc[3])
const 383 <<
"Can't find any TPC at position " << point <<
"\n";
391 (
double const worldLoc[3],
TPCID& tpcid)
const 401 (
double const worldLoc[3],
unsigned int &tpc,
unsigned int &cstat)
const 424 <<
"Can't find any cryostat at position " << point <<
"\n";
437 throw cet::exception(
"GeometryCore") <<
"Can't find Cryostat for position (" 438 << worldLoc[0] <<
"," 439 << worldLoc[1] <<
"," 440 << worldLoc[2] <<
")\n";
446 (
double const worldLoc[3],
unsigned int &cstat)
const 459 std::array<double, 3U> worldPos = {{ point.X(), point.Y(), point.Z() }};
479 (
double const worldLoc[3],
unsigned int &ad)
const 489 std::array<double, 3U>
const worldPos = {{ point.X(), point.Y(), point.Z() }};
495 (
double const worldPos[3],
size_t& adg,
size_t& sv)
const 510 (
double const worldLoc[3],
size_t& ad,
size_t& sv)
const 515 uint32_t
const& channel)
const 518 return this->
AuxDet(adIdx);
523 uint32_t
const& channel)
const 543 if (!ropid.isValid) {
545 <<
"SignalType(): Mapping of wire plane " << std::string(pid)
546 <<
" to readout plane failed!\n";
582 return std::string(
"volWorld");
588 (std::string
const& name )
const 593 <<
"DetectorEnclosureBox(): can't find enclosure volume '" << name <<
"'\n";
596 TGeoVolume
const* pEncl = path.back()->GetVolume();
597 auto const* pBox =
dynamic_cast<TGeoBBox const*
>(pEncl->GetShape());
603 << name <<
"' is not a box! (it is a " << pEncl->GetShape()->IsA()->GetName()
609 const double halfwidth = pBox->GetDX();
610 const double halfheight = pBox->GetDY();
611 const double halflength = pBox->GetDZ();
615 trans.LocalToWorld(
geo::Point_t{ +halfwidth, +halfheight, +halflength })
624 : vol_names(&names) {}
627 bool operator() (TGeoNode
const& node)
const 629 if (!vol_names)
return true;
630 return vol_names->find(node.GetVolume()->GetName()) != vol_names->end();
641 void operator() (TGeoNode
const& node)
642 {
if (matcher(node)) nodes.push_back(&node); }
645 { operator() (**iter); }
652 std::vector<std::vector<TGeoNode const*>>
paths;
658 {
if (matcher(**iter)) paths.push_back(iter.
get_path()); }
665 (std::set<std::string>
const& vol_names)
const 670 TGeoNode
const* pCurrentNode;
672 while ((pCurrentNode = *iNode)) {
673 node_collector(*pCurrentNode);
677 return node_collector.
nodes;
682 (std::set<std::string>
const& vol_names)
const 689 path_collector(iNode);
693 return path_collector.
paths;
701 return std::string(
TPC(tpcid).ActiveVolume()->GetName());
707 return std::string(
Cryostat(cid).Volume()->GetName());
776 unsigned int cstat)
const 807 for (
unsigned int p = 0; p < TPC.
Nplanes(); ++p) {
809 if (plane.
View() == view)
return plane.
ThetaZ();
811 throw cet::exception(
"GeometryCore") <<
"WireAngleToVertical(): no view \"" 813 <<
") in " << std::string(tpcid);
818 unsigned int maxTPCs = 0;
820 unsigned int maxTPCsInCryo = cryo.NTPC();
821 if (maxTPCsInCryo > maxTPCs) maxTPCs = maxTPCsInCryo;
832 {
return sum + cryo.
NTPC(); }
838 unsigned int maxPlanes = 0;
840 unsigned int maxPlanesInCryo = cryo.MaxPlanes();
841 if (maxPlanesInCryo > maxPlanes) maxPlanes = maxPlanesInCryo;
848 unsigned int maxWires = 0;
850 unsigned int maxWiresInCryo = cryo.MaxWires();
851 if (maxWiresInCryo > maxWires) maxWires = maxWiresInCryo;
869 TGeoShape
const*
s = world->GetShape();
876 s->GetAxisRange(1, x1, x2);
877 s->GetAxisRange(2, y1, y2);
878 s->GetAxisRange(3, z1, z2);
886 double* ylo,
double* yhi,
887 double* zlo,
double* zhi)
const 890 if (xlo) *xlo = box.
MinX();
891 if (ylo) *ylo = box.
MinY();
892 if (zlo) *zlo = box.
MinZ();
893 if (xhi) *xhi = box.
MaxX();
894 if (yhi) *yhi = box.
MaxY();
895 if (zhi) *zhi = box.
MaxZ();
903 double halflength = ((TGeoBBox*)volWorld->GetShape())->GetDZ();
904 double halfheight = ((TGeoBBox*)volWorld->GetShape())->GetDY();
905 double halfwidth = ((TGeoBBox*)volWorld->GetShape())->GetDX();
906 if(std::abs(point.x()) > halfwidth ||
907 std::abs(point.y()) > halfheight ||
908 std::abs(point.z()) > halflength
910 mf::LogWarning(
"GeometryCoreBadInputPoint") <<
"point (" << point.x() <<
"," 911 << point.y() <<
"," << point.z() <<
") " 912 <<
"is not inside the world volume " 913 <<
" half width = " << halfwidth
914 <<
" half height = " << halfheight
915 <<
" half length = " << halflength
916 <<
" returning unknown volume name";
917 const std::string
unknown(
"unknownVolume");
921 return gGeoManager->FindNode(point.X(), point.Y(), point.Z())->GetName();
926 auto const pNode = gGeoManager->FindNode(point.X(), point.Y(), point.Z());
927 if (!pNode)
return nullptr;
928 auto const pMedium = pNode->GetMedium();
929 return pMedium? pMedium->GetMaterial():
nullptr;
939 <<
"point " << point <<
" is not inside the world volume " 940 << worldBox.
Min() <<
" -- " << worldBox.
Max()
941 <<
"; returning unknown material name";
942 return {
"unknownMaterial" };
944 auto const pMaterial =
Material(point);
947 <<
"material for point " << point
948 <<
" not found! returning unknown material name";
949 return {
"unknownMaterial" };
951 return pMaterial->GetName();
957 (std::string
const& name )
const 959 std::vector<TGeoNode const*> path {
ROOTGeoManager()->GetTopNode() };
966 (std::string
const& name, std::vector<const TGeoNode*>& path)
const 968 assert(!path.empty());
970 auto const* pCurrent = path.back();
973 if (strncmp(name.c_str(), pCurrent->GetName(), name.length()) == 0)
977 auto const* pCurrentVolume = pCurrent->GetVolume();
978 unsigned int nd = pCurrentVolume->GetNdaughters();
979 for(
unsigned int i = 0; i < nd; ++i) {
980 path.push_back(pCurrentVolume->GetNode(i));
992 using Path_t = std::vector<TGeoNode const*>;
997 {
return toPath(pRoot, pathIndex); }
1001 assert(!path.empty());
1003 auto itParent = path.begin();
1004 auto itDaughter = itParent;
1005 while (++itDaughter != path.end()) {
1006 indices.push_back(findDaughterIndex(*itDaughter, *itParent));
1007 itParent = itDaughter;
1016 path.push_back(rootNode);
1017 TGeoNode
const* pCurrentNode = path.back();
1018 for (std::size_t daughterIndex: pathIndex) {
1019 pCurrentNode = pCurrentNode->GetVolume()->GetNode(daughterIndex);
1020 path.push_back(pCurrentNode);
1029 TGeoNode
const* pRoot =
nullptr;
1031 static std::size_t findDaughterIndex
1032 (TGeoNode
const* pDaughter, TGeoNode
const* pParent)
1035 std::size_t
n = pParent->GetNdaughters();
1036 for (std::size_t i = 0U; i <
n; ++i) {
1037 if (pParent->GetDaughter(i) == pDaughter)
return i;
1039 throw std::runtime_error(
"Node is not daughter of specified parent!");
1049 const char* nm = path[depth]->GetName();
1050 if( (strncmp(nm,
"volCryostat", 11) == 0) ){
1056 unsigned int deeper = depth+1;
1057 if(deeper >= path.size()){
1058 throw cet::exception(
"GeometryCore") <<
"exceeded maximum TGeoNode depth\n";
1061 const TGeoVolume *v = path[depth]->GetVolume();
1062 int nd = v->GetNdaughters();
1063 for(
int i = 0; i < nd; ++i){
1064 path[deeper] = v->GetNode(i);
1080 const char* nm = path[depth]->GetName();
1081 if( (strncmp(nm,
"volAuxDet", 9) == 0) ){
1087 unsigned int deeper = depth+1;
1088 if(deeper >= path.size()){
1089 throw cet::exception(
"GeometryCore") <<
"exceeded maximum TGeoNode depth\n";
1092 const TGeoVolume *v = path[depth]->GetVolume();
1093 int nd = v->GetNdaughters();
1094 for(
int i = 0; i < nd; ++i){
1095 path[deeper] = v->GetNode(i);
1116 TGeoVolume *gvol = gGeoManager->FindVolumeFast(vol.c_str());
1117 if(gvol)
return gvol->Weight();
1119 throw cet::exception(
"GeometryCore") <<
"could not find specified volume '" 1121 <<
" 'to determine total mass\n";
1134 double columnD = 0.;
1139 double const dxyz[3] = { dir.X(), dir.Y(), dir.Z() };
1140 double const cp1[3] = { p1.X(), p1.Y(), p1.Z() };
1141 gGeoManager->InitTrack(cp1, dxyz);
1144 TGeoNode *node = gGeoManager->GetCurrentNode();
1149 while(!gGeoManager->IsSameLocation(p2.X(), p2.Y(), p2.Z())){
1150 gGeoManager->FindNextBoundary();
1151 columnD += gGeoManager->GetStep()*node->GetMedium()->GetMaterial()->GetDensity();
1154 node = gGeoManager->Step();
1161 double const lastStep = (p2 - last).
R();
1162 columnD += lastStep*node->GetMedium()->GetMaterial()->GetDensity();
1219 if(worldPos.size() > 3)
throw cet::exception(
"GeometryCore") <<
"bad size vector for " 1221 << worldPos.size() <<
"\n";
1222 TVector3 wp(&(worldPos[0]));
1237 if(worldPos.size() > 3)
throw cet::exception(
"GeometryCore") <<
"bad size vector for " 1239 << worldPos.size() <<
"\n";
1240 TVector3 wp(&(worldPos[0]));
1262 if(worldPos.size() > 3)
throw cet::exception(
"GeometryCore") <<
"bad size vector for " 1264 << worldPos.size() <<
"\n";
1265 TVector3 wp(&(worldPos[0]));
1300 if(min>max) std::swap(min,max);
1301 if (std::abs(value-min)<1
e-6||std::abs(value-max)<1
e-6)
return true;
1302 return (value>=min) && (value<=
max);
1311 xyzStart[0] = result.
start().X();
1312 xyzStart[1] = result.
start().Y();
1313 xyzStart[2] = result.
start().Z();
1314 xyzEnd[0] = result.
end().X();
1315 xyzEnd[1] = result.
end().Y();
1316 xyzEnd[2] = result.
end().Z();
1318 if(xyzEnd[2]<xyzStart[2]){
1320 std::swap(xyzStart[0],xyzEnd[0]);
1321 std::swap(xyzStart[1],xyzEnd[1]);
1322 std::swap(xyzStart[2],xyzEnd[2]);
1324 if(xyzEnd[1]<xyzStart[1] && std::abs(xyzEnd[2]-xyzStart[2])<0.01){
1326 std::swap(xyzStart[0],xyzEnd[0]);
1327 std::swap(xyzStart[1],xyzEnd[1]);
1328 std::swap(xyzStart[2],xyzEnd[2]);
1344 if (chan1wires.empty()) {
1346 <<
"1st channel " << c1 <<
" maps to no wire (is it a real one?)";
1350 if (chan2wires.empty()) {
1352 <<
"2nd channel " << c2 <<
" maps to no wire (is it a real one?)";
1356 if (chan1wires.size() > 1) {
1358 <<
"1st channel " << c1 <<
" maps to " << chan2wires.size()
1359 <<
" wires; using the first!";
1362 if (chan2wires.size() > 1) {
1364 <<
"2nd channel " << c2 <<
" maps to " << chan2wires.size()
1365 <<
" wires; using the first!";
1385 double A_start_x,
double A_start_y,
double A_end_x,
double A_end_y,
1386 double B_start_x,
double B_start_y,
double B_end_x,
double B_end_y,
1387 double&
x,
double&
y 1395 double const denom = (A_start_x - A_end_x)*(B_start_y - B_end_y)
1396 - (A_start_y - A_end_y)*(B_start_x - B_end_x);
1400 double const A = (A_start_x * A_end_y - A_start_y * A_end_x) / denom;
1401 double const B = (B_start_x * B_end_y - B_start_y * B_end_x) / denom;
1403 x = (B_start_x - B_end_x) * A - (A_start_x - A_end_x) *
B;
1404 y = (B_start_y - B_end_y) * A - (A_start_y - A_end_y) *
B;
1412 double A_start_x,
double A_start_y,
double A_end_x,
double A_end_y,
1413 double B_start_x,
double B_start_y,
double B_end_x,
double B_end_y,
1414 double&
x,
double&
y 1418 A_start_x, A_start_y, A_end_x, A_end_y,
1419 B_start_x, B_start_y, B_end_x, B_end_y,
1424 mf::LogWarning(
"IntersectSegments") <<
"The segments are parallel!";
1429 A_start_x, A_start_y, A_end_x, A_end_y,
1430 B_start_x, B_start_y, B_end_x, B_end_y,
1443 std::numeric_limits<decltype(widIntersect.
y)>::has_infinity,
1444 "the vector coordinate type can't represent infinity!" 1446 constexpr
auto infinity
1447 = std::numeric_limits<decltype(widIntersect.
y)>::infinity();
1450 widIntersect.
y = widIntersect.
z = infinity;
1464 widIntersect.
y, widIntersect.
z 1467 widIntersect.
y = widIntersect.
z = infinity;
1474 widIntersect.
y, widIntersect.
z 1501 std::numeric_limits<decltype(intersection.X())>::has_infinity,
1502 "the vector coordinate type can't represent infinity!" 1504 constexpr
auto infinity
1505 = std::numeric_limits<decltype(intersection.X())>::infinity();
1508 intersection = { infinity, infinity, infinity };
1538 auto const dc =
c2 -
c1;
1542 double const w1w2 =
dot(w1, w2);
1543 double const cscAngle2 = 1.0 / (1.0 -
sqr(w1w2));
1544 double const dcw1 =
dot(dc, w1);
1545 double const dcw2 =
dot(dc, w2);
1546 double const t = (dcw1 - (dcw2 * w1w2)) * cscAngle2;
1547 double const u = (-dcw2 + (dcw1 * w1w2)) * cscAngle2;
1549 intersection = c1 + t * w1;
1552 = (std::abs(t) <= wire1.
HalfL()) && (std::abs(u) <= wire2.
HalfL());
1577 const unsigned int nPlanes =
Nplanes(pid1);
1580 <<
"ThirdPlane() supports only TPCs with 3 planes, and I see " 1581 << nPlanes <<
" instead\n";
1586 if ((iPlane == pid1.
Plane) || (iPlane == pid2.
Plane))
continue;
1587 if (target_plane != nPlanes) {
1589 <<
"ThirdPlane() found too many planes that are not " 1590 << std::string(pid1) <<
" nor " << std::string(pid2)
1591 <<
"! (first " << target_plane <<
", then " << iPlane <<
")\n";
1593 target_plane = iPlane;
1595 if (target_plane == nPlanes) {
1597 <<
"ThirdPlane() can't find a plane that is not " << std::string(pid1)
1598 <<
" nor " << std::string(pid2) <<
"!\n";
1610 << caller <<
" needs two planes on the same TPC (got " 1611 << std::string(pid1) <<
" and " << std::string(pid2) <<
")\n";
1615 << caller <<
" needs two different planes, got " 1616 << std::string(pid1) <<
" twice\n";
1661 double angle[3], pitch[3];
1668 for (
size_t i = 0; i < 3; ++i) {
1669 angle[i] = planes[i]->
PhiZ();
1674 angle[0], pitch[0], slope1,
1675 angle[1], pitch[1], slope2,
1699 (
double angle1,
double slope1,
double angle2,
double slope2,
double angle3)
1704 if ((std::abs(slope1) < 0.001) && (std::abs(slope2)) < 0.001)
return 0.001;
1708 double slope3 = 0.001;
1709 if (std::abs(slope1) > 0.001 && std::abs(slope2) > 0.001) {
1712 + (1./slope1)*std::sin(angle3-angle2)
1713 - (1./slope2)*std::sin(angle3-angle1)
1714 ) / std::sin(angle1-angle2)
1717 if (slope3 != 0.) slope3 = 1./slope3;
1725 double angle1,
double pitch1,
double dTdW1,
1726 double angle2,
double pitch2,
double dTdW2,
1727 double angle_target,
double pitch_target
1736 (angle1, dTdW1 / pitch1, angle2, dTdW2 / pitch2, angle_target);
1751 double &
y,
double &
z)
const 1783 (
double const worldLoc[3])
const 1882 static bool Loaded=
false;
1883 static std::vector<unsigned int> LowestID;
1884 static unsigned int NCryo;
1886 if(Loaded ==
false){
1892 LowestID.resize(NCryo + 1);
1894 for(
size_t cryo=0; cryo!=NCryo; ++cryo){
1900 if( (c < NCryo) && (o <
Cryostat(c).NOpDet())){
1901 return LowestID.at(c)+o;
1904 throw cet::exception(
"OpDetCryoToOpID Error") <<
"Coordinates c=" << c
1906 <<
" out of range. Abort\n";
1924 static bool Loaded=
false;
1925 static std::vector<unsigned int> LowestID;
1926 static size_t NCryo;
1928 if(Loaded ==
false){
1934 LowestID.resize(NCryo + 1);
1936 for(
size_t cryo = 0; cryo != NCryo; ++cryo){
1942 for(
size_t i=0; i!=NCryo; ++i){
1943 if( (OpDet >= LowestID[i]) && (OpDet < LowestID[i+1]) ){
1945 int o = OpDet-LowestID[i];
1950 throw cet::exception(
"OpID To OpDetCryo error")<<
"OpID out of range, "<< OpDet <<
"\n";
1980 <<
"Comparing two wires on different TPCs: return failure.";
1985 <<
"Comparing two wires in the same plane: return failure";
1990 <<
"1st wire " << wid1 <<
" does not exist (max wire number: " 1996 <<
"2nd wire " << wid2 <<
" does not exist (max wire number: " 2006 double A_start_x,
double A_start_y,
double A_end_x,
double A_end_y,
2007 double B_start_x,
double B_start_y,
double B_end_x,
double B_end_y,
2031 if (current_path.empty())
return *
this;
2032 if (current_path.size() == 1) { current_path.pop_back();
return *
this; }
2037 NodeInfo_t const& parent = current_path[current_path.size() - 2];
2038 if (++(current.
sibling) < parent.
self->GetNdaughters()) {
2041 reach_deepest_descendant();
2043 else current_path.pop_back();
2051 std::vector<TGeoNode const*> node_path(current_path.size());
2053 std::transform(current_path.begin(), current_path.end(), node_path.begin(),
2054 [](
NodeInfo_t const& node_info){
return node_info.self; });
2062 Node_t descendent = current_path.back().self;
2063 while (descendent->GetNdaughters() > 0) {
2064 descendent = descendent->GetDaughter(0);
2065 current_path.emplace_back(descendent, 0U);
2071 current_path.clear();
2072 if (!start_node)
return;
2073 current_path.emplace_back(start_node, 0U);
2074 reach_deepest_descendant();
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.
geo::Length_t WireCoordinate(double YPos, double ZPos, geo::PlaneID const &planeid) const
Returns the index of the nearest wire to the specified position.
std::set< PlaneID > const & PlaneIDs() const
Returns a list of possible PlaneIDs in the detector.
Geometry description of a TPC wireThe wire is a single straight segment on a wire plane...
void FindCryostat(std::vector< const TGeoNode * > &path, unsigned int depth)
ROOT::Math::DisplacementVector3D< ROOT::Math::Cartesian3D< double >, ROOT::Math::GlobalCoordinateSystemTag > Vector_t
Type for representation of momenta in 3D space.
unsigned int GetClosestOpDet(geo::Point_t const &point) const
std::vector< geo::TPCID > ROPtoTPCs(readout::ROPID const &ropid) const
Returns a list of ID of TPCs the specified ROP spans.
PlaneID const & planeID() const
geo::Length_t CryostatHalfHeight(geo::CryostatID const &cid) const
Returns the height of the cryostat (y direction)
Specializations of geo_vectors_utils.h for ROOT old vector types.
double z
z position of intersection
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
Number of OpDets in the whole detector.
virtual void SortCryostats(std::vector< geo::CryostatGeo * > &cgeo) const =0
constexpr auto dot(Vector const &a, Vector const &b)
Return cross product of two vectors.
static std::string ViewName(geo::View_t view)
Returns the name of the specified view.
static constexpr UndefinedPos_t undefined_pos
PlaneGeo const & Plane(unsigned int const p, unsigned int const tpc=0, unsigned int const cstat=0) const
Returns the specified wire.
geo::Length_t DetHalfWidth(geo::TPCID const &tpcid) const
Returns the half width of the active volume of the specified TPC.
unsigned int TotalNTPC() const
Returns the total number of TPCs in the detector.
GeometryData_t fGeoData
The detector description data.
double Length_t
Type used for coordinates and distances. They are measured in centimeters.
void LoadGeometryFile(std::string gdmlfile, std::string rootfile, bool bForceReload=false)
Loads the geometry information from the specified files.
CryostatGeo const & PositionToCryostat(geo::Point_t const &point) const
Returns the cryostat at specified location.
Float_t y1[n_points_granero]
ROOTGeoNodeForwardIterator & operator++()
Points to the next node, or to nullptr if there are no more.
Encapsulate the geometry of the sensitive portion of an auxiliary detector.
geo::Length_t PlanePitch(geo::TPCID const &tpcid, geo::PlaneID::PlaneID_t p1=0, geo::PlaneID::PlaneID_t p2=1) const
Returns the distance between two planes.
ROOTGeoPathBuilder(TGeoNode const *rootNode)
static constexpr BeginPos_t begin_pos
enum geo::_plane_proj View_t
Enumerate the possible plane projections.
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]
std::string OpDetGeoName(unsigned int c=0) const
Returns gdml string which gives sensitive opdet name.
TPCID const & asTPCID() const
Conversion to TPCID (for convenience of notation).
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.
unsigned int CryostatID_t
Type for the ID number.
constexpr bool zero(Value_t value) const
Returns whether the value is no farther from 0 than the threshold.
AuxDetGeo const & PositionToAuxDet(geo::Point_t const &point, unsigned int &ad) const
Returns the auxiliary detector at specified location.
double MinX() const
Returns the world x coordinate of the start of the box.
The data type to uniquely identify a Plane.
Silly utility to sort vectors indirectly.
Geometry information for a single TPC.
unsigned int MaxROPs() const
Returns the largest number of ROPs a TPC set in the detector has.
geo::BoxBoundedGeo DetectorEnclosureBox(std::string const &name="volDetEnclosure") const
Class identifying a set of TPC sharing readout channels.
const std::string GetWorldVolumeName() const
Return the name of the world volume (needed by Geant4 simulation)
Point const & start() const
std::vector< std::size_t > PathIndex_t
std::vector< TGeoNode const * > FindDetectorEnclosure(std::string const &name="volDetEnclosure") const
double ThirdPlaneSlope(geo::PlaneID const &pid1, double slope1, geo::PlaneID const &pid2, double slope2, geo::PlaneID const &output_plane) const
Returns the slope on the third plane, given it in the other two.
static constexpr EndPos_t end_pos
unsigned int NOpHardwareChannels(int opDet) const
Number of electronics channels for all the optical detectors.
unsigned int NTPCsets(readout::CryostatID const &cryoid) const
Returns the total number of TPC sets in the specified cryostat.
readout::ROPID WirePlaneToROP(geo::PlaneID const &planeid) const
Returns the ID of the ROP planeid belongs to.
bool ChannelsIntersect(raw::ChannelID_t c1, raw::ChannelID_t c2, double &y, double &z) const
Returns an intersection point of two channels.
geo::TPCGeo const * PositionToTPCptr(geo::Point_t const &point) const
Returns the TPC at specified location.
TGeoVolume const * WorldVolume() const
Returns a pointer to the world volume.
std::vector< geo::WireID > ChannelToWire(raw::ChannelID_t const channel) const
Returns a list of wires connected to the specified TPC channel.
CryostatID_t Cryostat
Index of cryostat.
unsigned int MaxWires() const
Returns the largest number of wires among all planes in this detector.
geo::TPCID PositionToTPCID(geo::Point_t const &point) const
Returns the ID of the TPC at specified location.
double MaxX() const
Returns the world x coordinate of the end of the box.
WireID_t Wire
Index of the wire within its plane.
const AuxDetSensitiveGeo & ChannelToAuxDetSensitive(std::string const &auxDetName, uint32_t const &channel) const
Returns the number of auxiliary detectors.
static Path_t emptyPath()
static constexpr std::size_t MaxWireDepthInGDML
Point const & end() const
bool IntersectSegments(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) const
Computes the intersection between two segments on a plane.
bool FindFirstVolume(std::string const &name, std::vector< const TGeoNode * > &path) const
geo::CryostatID PositionToCryostatID(geo::Point_t const &point) const
Returns the ID of the cryostat at specified location.
SigType_t SignalType(geo::PlaneID const &pid) const
Returns the type of signal on the channels of specified TPC plane.
MaybeLogger_< ELseverityLevel::ELsev_error, false > LogError
unsigned int TPC
TPC of intersection.
Geometry information for a single cryostat.
std::set< std::string > const * vol_names
unsigned int Ncryostats() const
Returns the number of cryostats in the detector.
void FindAuxDet(std::vector< const TGeoNode * > &path, unsigned int depth)
readout::TPCsetID FindTPCsetAtPosition(double const worldLoc[3]) const
Returns the ID of the TPC set at specified location.
unsigned int NOpChannels() const
Number of electronics channels for all the optical detectors.
geo::PlaneID ThirdPlane(geo::PlaneID const &pid1, geo::PlaneID const &pid2) const
Returns the plane that is not in the specified arguments.
unsigned int GetClosestOpDet(geo::Point_t const &point) const
Find the nearest OpChannel to some point.
readout::TPCsetID TPCtoTPCset(geo::TPCID const &tpcid) const
Returns the ID of the TPC set tpcid belongs to.
TGeoManager * ROOTGeoManager() const
Access to the ROOT geometry description manager.
geo::Length_t WirePitch(geo::PlaneID const &planeid) const
Returns the distance between two consecutive wires.
unsigned int Nwires(unsigned int p, unsigned int tpc=0, unsigned int cstat=0) const
Returns the total number of wires in the specified plane.
unsigned int OpDetFromCryo(unsigned int o, unsigned int c) const
Get unique opdet number from cryo and internal count.
void CryostatBoundaries(double *boundaries, geo::CryostatID const &cid) const
Returns the boundaries of the specified cryostat.
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.
static 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).
std::vector< std::vector< TGeoNode const * > > paths
geo::TPCGeo const & PositionToTPC(geo::Point_t const &point) const
Returns the TPC at specified location.
constexpr bool withinSorted(Value_t value, Value_t lower, Value_t upper) const
Returns whether value is between bounds (included); bounds are sorted.
geo::TPCGeo const * PositionToTPCptr(geo::Point_t const &point, double wiggle) const
Returns a pointer to the TPC at specified location.
double ThetaZ() const
Angle of the wires from positive z axis; .
double TotalMass() const
Returns the total mass [kg] of the specified volume (default: world).
geo::CryostatID CryostatID
static lar::util::RealComparisons< geo::Length_t > coordIs
Value of tolerance for equality comparisons.
geo::TPCID FindTPCAtPosition(double const worldLoc[3]) const
Returns the ID of the TPC at specified location.
Access the description of detector geometry.
bool HasROP(readout::ROPID const &ropid) const
unsigned int PlaneID_t
Type for the ID number.
View_t View() const
Which coordinate does this plane measure.
std::string OpDetGeoName() const
Get name of opdet geometry element.
NodeNameMatcherClass matcher
virtual void SortAuxDets(std::vector< geo::AuxDetGeo * > &adgeo) const =0
void SortGeometry(geo::GeoObjectSorter const &sorter)
Runs the sorting of geometry with the sorter provided by channel mapping.
unsigned int Nplanes(unsigned int tpc=0, unsigned int cstat=0) const
Returns the total number of wire planes in the specified TPC.
constexpr ChannelID_t InvalidChannelID
ID of an invalid channel.
Offer iterators automatically dereferencing their values.
unsigned int MaxPlanes() const
Returns the largest number of planes among all TPCs in this detector.
Iterator to navigate through all the nodes.
std::set< geo::View_t > allViews
All views in the detector.
geo::Length_t DetHalfHeight(geo::TPCID const &tpcid) const
Returns the half height of the active volume of the specified TPC.
void SortByPointers(Coll &coll, Sorter sorter)
Applies sorting indirectly, minimizing data copy.
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.
const OpDetGeo & OpDet(unsigned int iopdet) const
Return the iopdet'th optical detector in the cryostat.
Path_t toPath(PathIndex_t const &pathIndex) const
double PhiZ() const
Angle from positive z axis of the wire coordinate axis, in radians.
const AuxDetSensitiveGeo & PositionToAuxDetSensitive(geo::Point_t const &point, size_t &ad, size_t &sv) const
Returns the auxiliary detector at specified location.
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.
IteratorBox< TPC_iterator,&GeometryCore::begin_TPC,&GeometryCore::end_TPC > IterateTPCs() const
Enables ranged-for loops on all TPCs of the detector.
void FindAuxDetSensitiveAtPosition(geo::Point_t const &point, std::size_t &adg, std::size_t &sv) const
Fills the indices of the sensitive auxiliary detector at location.
bool WireIDIntersectionCheck(const geo::WireID &wid1, const geo::WireID &wid2) const
Wire ID check for WireIDsIntersect methods.
double ActiveHalfWidth() const
Half width (associated with x coordinate) of active TPC volume [cm].
std::vector< evd::details::RawDigitInfo_t >::const_iterator begin(RawDigitCacheDataClass const &cache)
geo::WireID::WireID_t NearestWire(geo::Point_t const &point, geo::PlaneID const &planeid) const
Returns the index of wire closest to position in the specified TPC.
double HalfWidth() const
Half width of the cryostat [cm].
std::shared_ptr< const geo::ChannelMapAlg > fChannelMapAlg
Object containing the channel to wire mapping.
Geometry information for a single wire plane.The plane is represented in the geometry by a solid whic...
constexpr std::array< std::size_t, geo::vect::dimension< Vector >)> indices()
Returns a sequence of indices valid for a vector of the specified type.
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.
geo::Length_t DetLength(geo::TPCID const &tpcid) const
Returns the length of the active volume of the specified TPC.
CryostatGeo const & Cryostat(geo::CryostatID const &cryoid) const
Returns the specified cryostat.
unsigned int MaxOpChannel() const
Largest optical channel number.
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.
double MassBetweenPoints(geo::Point_t const &p1, geo::Point_t const &p2) const
Returns the column density between two points.
~GeometryCore()
Destructor.
bool IntersectionPoint(geo::WireID const &wid1, geo::WireID const &wid2, double &y, double &z) const
Returns the intersection point of two wires.
void UpdateAfterSorting()
Performs all the updates needed after sorting.
void markInvalid()
Sets the ID as invalid.
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) const
Computes the intersection between two lines on a plane.
View_t View(geo::PlaneID const &pid) const
Returns the view (wire orientation) on the channels of specified TPC plane.
AuxDetList_t & AuxDets()
Return the interfal auxiliary detectors list.
NodeNameMatcherClass matcher
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].
Vector Direction() const
Returns the wire direction as a norm-one vector.
unsigned int NOpDets() const
Number of OpDets in the whole detector.
void ApplyChannelMap(std::shared_ptr< geo::ChannelMapAlg > pChannelMap)
Initializes the geometry to work with this channel map.
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.
static PathIndex_t emptyPathIndex()
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.
double HalfL() const
Returns half the length of the wire [cm].
Encapsulate the geometry of an optical detector.
IteratorBox< cryostat_iterator,&GeometryCore::begin_cryostat,&GeometryCore::end_cryostat > IterateCryostats() const
Enables ranged-for loops on all cryostats of the detector.
std::string fGDMLfile
path to geometry file used for Geant4 simulation
bool WireIDsIntersect(WireID const &wid1, WireID const &wid2, geo::Point_t &intersection) const
Computes the intersection between two wires.
void MakeCryostat(std::vector< const TGeoNode * > &path, int depth)
WireGeo const & Wire(geo::WireID const &wireid) const
Returns the specified wire.
raw::ChannelID_t PlaneWireToChannel(WireID const &wireid) const
Returns the ID of the TPC channel connected to the specified wire.
geo::CryostatGeo const * PositionToCryostatPtr(geo::Point_t const &point) const
Returns the cryostat at specified location.
std::string value(boost::any const &)
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
geo::Length_t CryostatHalfWidth(geo::CryostatID const &cid) const
Returns the half width of the cryostat (x direction)
unsigned int NOpDet() const
Number of optical detectors in this TPC.
TVector3 toTVector3(Vector const &v)
Converts a vector into a TVector3.
static const CryostatID_t InvalidID
Special code for an invalid ID.
double y
y position of intersection
std::string GetCryostatVolumeName(geo::CryostatID const &cid) const
Return the name of LAr TPC volume.
double MaxZ() const
Returns the world z coordinate of the end of the box.
static PathIndex_t toPathIndex(Path_t const &path)
unsigned int MaxTPCsets() const
Returns the largest number of TPC sets any cryostat in the detector has.
void init(TGeoNode const *start_node)
MaybeLogger_< ELseverityLevel::ELsev_warning, false > LogWarning
CryostatList_t & Cryostats()
Return the internal cryostat list.
Simple class with two points (a pair with aliases).
const AuxDetGeo & ChannelToAuxDet(std::string const &auxDetName, uint32_t const &channel) const
Returns the number of auxiliary detectors.
static const TPCID_t InvalidID
Special code for an invalid ID.
void MakeAuxDet(std::vector< const TGeoNode * > &path, int depth)
static void CheckIndependentPlanesOnSameTPC(geo::PlaneID const &pid1, geo::PlaneID const &pid2, const char *caller)
void WireEndPoints(geo::WireID const &wireid, double *xyzStart, double *xyzEnd) const
Fills two arrays with the coordinates of the wire end points.
std::vector< geo::PlaneID > ROPtoWirePlanes(readout::ROPID const &ropid) const
Returns a list of ID of planes belonging to the specified ROP.
std::string fDetectorName
Name of the detector.
geo::Length_t CryostatLength(geo::CryostatID const &cid) const
Returns the length of the cryostat (z direction)
geo::WireID NearestWireID(geo::Point_t const &point, geo::PlaneID const &planeid) const
Returns the ID of wire closest to position in the specified TPC.
unsigned int FindAuxDetAtPosition(double const worldLoc[3]) const
Returns the index of the auxiliary detector at specified location.
TGeoMaterial const * Material(geo::Point_t const &point) const
Returns the material at the specified position.
Structures to distinguish the constructors.
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.
geo::BoxBoundedGeo const & Boundaries() const
Returns boundaries of the cryostat (in centimetres).
std::vector< evd::details::RawDigitInfo_t >::const_iterator end(RawDigitCacheDataClass const &cache)
TPCGeo const & TPC(unsigned int const tpc=0, unsigned int const cstat=0) const
Returns 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.
std::string MaterialName(TVector3 const &point) const
Name of the deepest material containing the point xyz.
void GetCenter(double *xyz, double localz=0.0) const
Fills the world coordinate of a point on the wire.
double WireCoordinate(Point const &point) const
Returns the coordinate of the point on the plane, in wire units.
bool ValueInRange(double value, double min, double max) const
Returns whether a value is within the specified range.
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)
std::vector< geo::TPCID > TPCsetToTPCs(readout::TPCsetID const &tpcsetid) const
Returns a list of ID of TPCs belonging to the specified TPC set.
Float_t x2[n_points_geant4]
raw::ChannelID_t NearestChannel(geo::Point_t const &worldLoc, geo::PlaneID const &planeid) const
Returns the ID of the channel nearest to the specified position.
std::vector< TGeoNode const * > Path_t
ROOT::Math::PositionVector3D< ROOT::Math::Cartesian3D< double >, ROOT::Math::GlobalCoordinateSystemTag > Point_t
Type for representation of position in physical 3D space.
void reach_deepest_descendant()
GENVECTOR_CONSTEXPR::geo::Point_t makePointFromCoords(Coords &&coords)
Creates a geo::Point_t from its coordinates (see makeFromCoords()).
Namespace collecting geometry-related classes utilities.
double MinY() const
Returns the world y coordinate of the start of the box.
geo::CryostatID::CryostatID_t FindCryostatAtPosition(geo::Point_t const &worldLoc) const
Returns the index of the cryostat at specified location.
double ThirdPlane_dTdW(geo::PlaneID const &pid1, double slope1, geo::PlaneID const &pid2, double slope2, geo::PlaneID const &output_plane) const
Returns dT/dW on the third plane, given it in the other two.
OpDetGeo const & OpDetGeoFromOpChannel(unsigned int OpChannel) const
Access the OpDetGeo object by OpDet or 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.
bool IsValidOpChannel(int opChannel) const
Is this a valid OpChannel number?
std::string VolumeName(geo::Point_t const &point) const
Returns the name of the deepest volume containing specified point.
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.
double WireAngleToVertical(geo::View_t view, geo::TPCID const &tpcid) const
Returns the angle of the wires in the specified view from vertical.
CryostatGeo const * CryostatPtr(geo::CryostatID const &cryoid) const
Returns the specified cryostat.
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.
The data type to uniquely identify a cryostat.
std::string GetLArTPCVolumeName(geo::TPCID const &tpcid) const
Return the name of specified LAr TPC volume.
bool HasWire(geo::WireID const &wireid) const
Returns whether we have the specified wire.
geo::CryostatID const & ID() const
Returns the identifier of this cryostat.
bool HasTPCset(readout::TPCsetID const &tpcsetid) const
geo::BoxBoundedGeo WorldBox() const