24 #include "cetlib/pow.h"
25 #include "cetlib_except/exception.h"
26 #include "fhiclcpp/types/Table.h"
27 #include "messagefacility/MessageLogger/MessageLogger.h"
30 #include <TGeoManager.h>
32 #include <TGeoVolume.h>
33 #include <TGeoMatrix.h>
35 #include <TGeoVolume.h>
60 fhicl::ParameterSet
const& pset
62 : fSurfaceY (pset.
get< double >(
"SurfaceY" ))
63 , fDetectorName (pset.
get<
std::string >(
"Name" ))
64 , fMinWireZDist (pset.
get< double >(
"MinWireZDist", 3.0 ))
65 , fPositionWiggle (pset.
get< double >(
"PositionEpsilon", 1.
e-4))
67 (pset.
get<fhicl::ParameterSet>(
"Builder", fhicl::ParameterSet()))
82 (std::unique_ptr<geo::ChannelMapAlg> pChannelMap)
84 SortGeometry(pChannelMap->
Sorter());
87 fChannelMapAlg = move(pChannelMap);
92 std::string gdmlfile, std::string rootfile,
98 if (gdmlfile.empty()) {
99 throw cet::exception(
"GeometryCore")
100 <<
"No GDML Geometry file specified!\n";
103 if (rootfile.empty()) {
104 throw cet::exception(
"GeometryCore")
105 <<
"No ROOT Geometry file specified!\n";
113 if( !gGeoManager || bForceReload ){
114 if (gGeoManager) 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 "
147 std::string gdmlfile, std::string rootfile,
150 fhicl::Table<geo::GeometryBuilderStandard::Config>
const builderConfig
170 mf::LogInfo(
"GeometryCore") <<
"Sorting volumes...";
178 cryo.SortSubVolumes(sorter);
194 auto const& TPCviews = tpc.Views();
195 allViews.insert(TPCviews.cbegin(), TPCviews.cend());
223 std::vector<raw::ChannelID_t> channels;
236 std::sort(channels.begin(), channels.end());
237 auto last = std::unique(channels.begin(), channels.end());
238 channels.erase(last, channels.end());
247 for(
size_t cstat=0; cstat!=
Ncryostats(); cstat++)
299 throw cet::exception(
"Geometry") <<
"Requested AuxDet index " << aid
300 <<
" is out of range: " <<
NAuxDets();
302 return AuxDets()[aid].NSensitiveVolume();
324 throw cet::exception(
"GeometryCore") <<
"Cryostat #"
326 <<
" does not exist\n";
343 throw cet::exception(
"GeometryCore") <<
"AuxDet "
345 <<
" does not exist\n";
356 if (!cryo)
return {};
360 if (tpcid)
return tpcid;
375 if (cryostat.ContainsPosition(point, 1.0 + fPositionWiggle))
402 (
double const worldLoc[3])
const
423 throw cet::exception(
"GeometryCore")
424 <<
"Can't find any TPC at position " << point <<
"\n";
432 (
double const worldLoc[3],
TPCID& tpcid)
const
442 (
double const worldLoc[3],
unsigned int &tpc,
unsigned int &cstat)
const
485 throw cet::exception(
"GeometryCore")
486 <<
"Can't find any cryostat at position " << point <<
"\n";
499 throw cet::exception(
"GeometryCore") <<
"Can't find Cryostat for position ("
500 << worldLoc[0] <<
","
501 << worldLoc[1] <<
","
502 << worldLoc[2] <<
")\n";
504 return Cryostat(cid);
508 (
double const worldLoc[3],
unsigned int &cstat)
const
521 std::array<double, 3U> worldPos = {{ point.X(), point.Y(), point.Z() }};
535 ad = FindAuxDetAtPosition(point, tolerance);
541 (
double const worldLoc[3],
unsigned int &ad,
double tolerance)
const
546 (
geo::Point_t const& point, std::size_t& adg, std::size_t& sv,
double tolerance)
const
548 adg = FindAuxDetAtPosition(point, tolerance);
551 std::array<double, 3U>
const worldPos = {{ point.X(), point.Y(), point.Z() }};
552 sv = fChannelMapAlg->NearestSensitiveAuxDet(worldPos.data(), AuxDets(),
tolerance);
557 (
double const worldPos[3],
size_t& adg,
size_t& sv,
double tolerance)
const
563 (
geo::Point_t const& point,
size_t& ad,
size_t& sv,
double tolerance)
const
566 FindAuxDetSensitiveAtPosition(point, ad, sv, tolerance);
567 return AuxDet(ad).SensitiveVolume(sv);
572 (
double const worldLoc[3],
size_t& ad,
size_t& sv,
double tolerance)
const
577 uint32_t
const& channel)
const
580 return this->
AuxDet(adIdx);
585 uint32_t
const& channel)
const
605 if (!ropid.isValid) {
606 throw cet::exception(
"GeometryCore")
607 <<
"SignalType(): Mapping of wire plane " << std::string(pid)
608 <<
" to readout plane failed!\n";
644 return std::string(
"volWorld");
650 (std::string
const&
name )
const
652 auto const&
path = FindDetectorEnclosure(name);
654 throw cet::exception(
"GeometryCore")
655 <<
"DetectorEnclosureBox(): can't find enclosure volume '" << name <<
"'\n";
658 TGeoVolume
const* pEncl =
path.back()->GetVolume();
659 auto const* pBox =
dynamic_cast<TGeoBBox
const*
>(pEncl->GetShape());
664 throw cet::exception(
"GeometryCore") <<
"Detector enclosure '"
665 << name <<
"' is not a box! (it is a " << pEncl->GetShape()->IsA()->GetName()
671 const double halfwidth = pBox->GetDX();
672 const double halfheight = pBox->GetDY();
673 const double halflength = pBox->GetDZ();
677 trans.LocalToWorld(
geo::Point_t{ +halfwidth, +halfheight, +halflength })
714 std::vector<std::vector<TGeoNode const*>>
paths;
727 (std::set<std::string>
const& vol_names)
const
732 TGeoNode
const* pCurrentNode;
734 while ((pCurrentNode = *iNode)) {
735 node_collector(*pCurrentNode);
739 return node_collector.
nodes;
744 (std::set<std::string>
const& vol_names)
const
751 path_collector(iNode);
755 return path_collector.
paths;
763 return std::string(
TPC(tpcid).ActiveVolume()->GetName());
769 return std::string(
Cryostat(cid).Volume()->GetName());
794 return Cryostat(cid).HalfWidth();
801 return Cryostat(cid).HalfHeight();
866 unsigned int cstat)
const
897 for (
unsigned int p = 0;
p < TPC.
Nplanes(); ++
p) {
899 if (plane.
View() == view)
return plane.
ThetaZ();
901 throw cet::exception(
"GeometryCore") <<
"WireAngleToVertical(): no view \""
903 <<
") in " << std::string(tpcid);
908 unsigned int maxTPCs = 0;
910 unsigned int maxTPCsInCryo = cryo.NTPC();
911 if (maxTPCsInCryo > maxTPCs) maxTPCs = maxTPCsInCryo;
922 {
return sum + cryo.
NTPC(); }
928 unsigned int maxPlanes = 0;
930 unsigned int maxPlanesInCryo = cryo.MaxPlanes();
931 if (maxPlanesInCryo > maxPlanes) maxPlanes = maxPlanesInCryo;
938 unsigned int maxWires = 0;
940 unsigned int maxWiresInCryo = cryo.MaxWires();
941 if (maxWiresInCryo > maxWires) maxWires = maxWiresInCryo;
996 throw cet::exception(
"GeometryCore")
999 TGeoShape
const*
s = world->GetShape();
1001 throw cet::exception(
"GeometryCore")
1005 double x1, x2, y1, y2, z1, z2;
1006 s->GetAxisRange(1, x1, x2);
1007 s->GetAxisRange(2, y1, y2);
1008 s->GetAxisRange(3, z1, z2);
1016 double* ylo,
double* yhi,
1017 double* zlo,
double* zhi)
const
1020 if (xlo) *xlo = box.
MinX();
1021 if (ylo) *ylo = box.
MinY();
1022 if (zlo) *zlo = box.
MinZ();
1023 if (xhi) *xhi = box.
MaxX();
1024 if (yhi) *yhi = box.
MaxY();
1025 if (zhi) *zhi = box.
MaxZ();
1033 double halflength = ((TGeoBBox*)volWorld->GetShape())->GetDZ();
1034 double halfheight = ((TGeoBBox*)volWorld->GetShape())->GetDY();
1035 double halfwidth = ((TGeoBBox*)volWorld->GetShape())->GetDX();
1036 if(
std::abs(point.x()) > halfwidth ||
1037 std::abs(point.y()) > halfheight ||
1040 mf::LogWarning(
"GeometryCoreBadInputPoint") <<
"point (" << point.x() <<
","
1041 << point.y() <<
"," << point.z() <<
") "
1042 <<
"is not inside the world volume "
1043 <<
" half width = " << halfwidth
1044 <<
" half height = " << halfheight
1045 <<
" half length = " << halflength
1046 <<
" returning unknown volume name";
1047 const std::string
unknown(
"unknownVolume");
1051 return gGeoManager->FindNode(point.X(), point.Y(), point.Z())->GetName();
1056 auto const pNode = gGeoManager->FindNode(point.X(), point.Y(), point.Z());
1057 if (!pNode)
return nullptr;
1058 auto const pMedium = pNode->GetMedium();
1059 return pMedium? pMedium->GetMaterial():
nullptr;
1068 mf::LogWarning(
"GeometryCoreBadInputPoint")
1069 <<
"point " << point <<
" is not inside the world volume "
1070 << worldBox.
Min() <<
" -- " << worldBox.
Max()
1071 <<
"; returning unknown material name";
1072 return {
"unknownMaterial" };
1074 auto const pMaterial =
Material(point);
1076 mf::LogWarning(
"GeometryCoreBadInputPoint")
1077 <<
"material for point " << point
1078 <<
" not found! returning unknown material name";
1079 return {
"unknownMaterial" };
1081 return pMaterial->GetName();
1087 (std::string
const& name )
const
1089 std::vector<TGeoNode const*>
path { ROOTGeoManager()->GetTopNode() };
1090 if (!FindFirstVolume(name,
path))
path.clear();
1096 (std::string
const& name, std::vector<const TGeoNode*>&
path)
const
1098 assert(!path.empty());
1100 auto const* pCurrent = path.back();
1103 if (strncmp(name.c_str(), pCurrent->GetName(), name.length()) == 0)
1107 auto const* pCurrentVolume = pCurrent->GetVolume();
1108 unsigned int nd = pCurrentVolume->GetNdaughters();
1109 for(
unsigned int i = 0; i < nd; ++i) {
1110 path.push_back(pCurrentVolume->GetNode(i));
1111 if (FindFirstVolume(name, path))
return true;
1135 TGeoVolume *gvol = gGeoManager->FindVolumeFast(vol.c_str());
1136 if(gvol)
return gvol->Weight();
1138 throw cet::exception(
"GeometryCore") <<
"could not find specified volume '"
1140 <<
" 'to determine total mass\n";
1153 double columnD = 0.;
1158 double const dxyz[3] = { dir.X(), dir.Y(), dir.Z() };
1159 double const cp1[3] = { p1.X(), p1.Y(), p1.Z() };
1160 gGeoManager->InitTrack(cp1, dxyz);
1163 TGeoNode *node = gGeoManager->GetCurrentNode();
1168 while(!gGeoManager->IsSameLocation(p2.X(), p2.Y(), p2.Z())){
1169 gGeoManager->FindNextBoundary();
1170 columnD += gGeoManager->GetStep()*node->GetMedium()->GetMaterial()->GetDensity();
1173 node = gGeoManager->Step();
1180 double const lastStep = (p2 - last).R();
1181 columnD += lastStep*node->GetMedium()->GetMaterial()->GetDensity();
1188 std::ostringstream sstr;
1189 Print(sstr, indent);
1212 return Plane(planeid).WireCoordinate(pos);
1219 return fChannelMapAlg->WireCoordinate(YPos, ZPos, planeid);
1232 return NearestWireID(point, planeid).Wire;
1247 if(worldPos.size() > 3)
throw cet::exception(
"GeometryCore") <<
"bad size vector for "
1249 << worldPos.size() <<
"\n";
1250 return NearestWire(worldPos.data(), planeid);
1257 return Plane(planeid).NearestWireID(worldPos);
1264 if(worldPos.size() > 3)
throw cet::exception(
"GeometryCore") <<
"bad size vector for "
1266 << worldPos.size() <<
"\n";
1267 return NearestWireID(worldPos.data(), planeid);
1288 if(worldPos.size() > 3)
throw cet::exception(
"GeometryCore") <<
"bad size vector for "
1290 << worldPos.size() <<
"\n";
1291 return NearestChannel(worldPos.data(), planeid);
1310 geo::WireID const wireID = NearestWireID(worldPos, planeid);
1325 if(min>max) std::swap(min,max);
1327 return (value>=min) && (value<=max);
1334 Segment_t result = WireEndPoints(wireid);
1336 xyzStart[0] = result.
start().X();
1337 xyzStart[1] = result.
start().Y();
1338 xyzStart[2] = result.
start().Z();
1339 xyzEnd[0] = result.
end().X();
1340 xyzEnd[1] = result.
end().Y();
1341 xyzEnd[2] = result.
end().Z();
1343 if(xyzEnd[2]<xyzStart[2]){
1345 std::swap(xyzStart[0],xyzEnd[0]);
1346 std::swap(xyzStart[1],xyzEnd[1]);
1347 std::swap(xyzStart[2],xyzEnd[2]);
1349 if(xyzEnd[1]<xyzStart[1] &&
std::abs(xyzEnd[2]-xyzStart[2])<0.01){
1351 std::swap(xyzStart[0],xyzEnd[0]);
1352 std::swap(xyzStart[1],xyzEnd[1]);
1353 std::swap(xyzStart[2],xyzEnd[2]);
1369 if (chan1wires.empty()) {
1370 mf::LogError(
"ChannelsIntersect")
1371 <<
"1st channel " << c1 <<
" maps to no wire (is it a real one?)";
1375 if (chan2wires.empty()) {
1376 mf::LogError(
"ChannelsIntersect")
1377 <<
"2nd channel " << c2 <<
" maps to no wire (is it a real one?)";
1381 if (chan1wires.size() > 1) {
1382 mf::LogWarning(
"ChannelsIntersect")
1383 <<
"1st channel " << c1 <<
" maps to " << chan2wires.size()
1384 <<
" wires; using the first!";
1387 if (chan2wires.size() > 1) {
1388 mf::LogError(
"ChannelsIntersect")
1389 <<
"2nd channel " << c2 <<
" maps to " << chan2wires.size()
1390 <<
" wires; using the first!";
1410 double A_start_x,
double A_start_y,
double A_end_x,
double A_end_y,
1411 double B_start_x,
double B_start_y,
double B_end_x,
double B_end_y,
1412 double&
x,
double&
y
1420 double const denom = (A_start_x - A_end_x)*(B_start_y - B_end_y)
1421 - (A_start_y - A_end_y)*(B_start_x - B_end_x);
1425 double const A = (A_start_x * A_end_y - A_start_y * A_end_x) / denom;
1426 double const B = (B_start_x * B_end_y - B_start_y * B_end_x) / denom;
1428 x = (B_start_x - B_end_x) * A - (A_start_x - A_end_x) * B;
1429 y = (B_start_y - B_end_y) * A - (A_start_y - A_end_y) * B;
1437 double A_start_x,
double A_start_y,
double A_end_x,
double A_end_y,
1438 double B_start_x,
double B_start_y,
double B_end_x,
double B_end_y,
1439 double&
x,
double&
y
1443 A_start_x, A_start_y, A_end_x, A_end_y,
1444 B_start_x, B_start_y, B_end_x, B_end_y,
1449 mf::LogWarning(
"IntersectSegments") <<
"The segments are parallel!";
1454 A_start_x, A_start_y, A_end_x, A_end_y,
1455 B_start_x, B_start_y, B_end_x, B_end_y,
1469 std::numeric_limits<decltype(widIntersect.
y)>::has_infinity,
1470 "the vector coordinate type can't represent infinity!"
1472 constexpr
auto infinity
1473 = std::numeric_limits<decltype(widIntersect.
y)>::infinity();
1476 widIntersect.
y = widIntersect.
z = infinity;
1490 widIntersect.
y, widIntersect.
z
1493 widIntersect.
y = widIntersect.
z = infinity;
1500 widIntersect.
y, widIntersect.
z
1527 std::numeric_limits<decltype(intersection.X())>::has_infinity,
1528 "the vector coordinate type can't represent infinity!"
1530 constexpr
auto infinity
1531 = std::numeric_limits<decltype(intersection.X())>::infinity();
1534 intersection = { infinity, infinity, infinity };
1544 intersection = intersectionAndOffset.
point;
1546 bool const within = (
1563 bool res = WireIDsIntersect(wid1, wid2, p);
1574 const unsigned int nPlanes = Nplanes(pid1);
1576 throw cet::exception(
"GeometryCore")
1577 <<
"ThirdPlane() supports only TPCs with 3 planes, and I see "
1578 << nPlanes <<
" instead\n";
1583 if ((iPlane == pid1.
Plane) || (iPlane == pid2.
Plane))
continue;
1584 if (target_plane != nPlanes) {
1585 throw cet::exception(
"GeometryCore")
1586 <<
"ThirdPlane() found too many planes that are not "
1587 << std::string(pid1) <<
" nor " << std::string(pid2)
1588 <<
"! (first " << target_plane <<
", then " << iPlane <<
")\n";
1590 target_plane = iPlane;
1592 if (target_plane == nPlanes) {
1593 throw cet::exception(
"GeometryCore")
1594 <<
"ThirdPlane() can't find a plane that is not " << std::string(pid1)
1595 <<
" nor " << std::string(pid2) <<
"!\n";
1606 throw cet::exception(
"GeometryCore")
1607 << caller <<
" needs two planes on the same TPC (got "
1608 << std::string(pid1) <<
" and " << std::string(pid2) <<
")\n";
1611 throw cet::exception(
"GeometryCore")
1612 << caller <<
" needs two different planes, got "
1613 << std::string(pid1) <<
" twice\n";
1658 double angle[3], pitch[3];
1665 for (
size_t i = 0; i < 3; ++i) {
1666 angle[i] = planes[i]->
PhiZ();
1671 angle[0], pitch[0], slope1,
1672 angle[1], pitch[1], slope2,
1696 (
double angle1,
double slope1,
double angle2,
double slope2,
double angle3)
1701 if ((
std::abs(slope1) < 0.001) && (
std::abs(slope2)) < 0.001)
return 0.001;
1705 double slope3 = 0.001;
1709 + (1./slope1)*std::sin(angle3-angle2)
1710 - (1./slope2)*std::sin(angle3-angle1)
1711 ) / std::sin(angle1-angle2)
1714 if (slope3 != 0.) slope3 = 1./slope3;
1722 double angle1,
double pitch1,
double dTdW1,
1723 double angle2,
double pitch2,
double dTdW2,
1724 double angle_target,
double pitch_target
1733 (angle1, dTdW1 / pitch1, angle2, dTdW2 / pitch2, angle_target);
1748 double &
y,
double &
z)
const
1780 (
double const worldLoc[3])
const
1782 return TPCtoTPCset(FindTPCAtPosition(worldLoc));
1797 return fChannelMapAlg->TPCsetToTPCs(tpcsetid);
1833 return fChannelMapAlg->ROPtoWirePlanes(ropid);
1841 return fChannelMapAlg->ROPtoTPCs(ropid);
1849 return fChannelMapAlg->FirstChannelInROP(ropid);
1879 static bool Loaded=
false;
1880 static std::vector<unsigned int> LowestID;
1881 static unsigned int NCryo;
1883 if(Loaded ==
false){
1889 LowestID.resize(NCryo + 1);
1891 for(
size_t cryo=0; cryo!=NCryo; ++cryo){
1897 if( (c < NCryo) && (o <
Cryostat(c).NOpDet())){
1898 return LowestID.at(c)+o;
1901 throw cet::exception(
"OpDetCryoToOpID Error") <<
"Coordinates c=" << c
1903 <<
" out of range. Abort\n";
1921 static bool Loaded=
false;
1922 static std::vector<unsigned int> LowestID;
1923 static size_t NCryo;
1925 if(Loaded ==
false){
1931 LowestID.resize(NCryo + 1);
1933 for(
size_t cryo = 0; cryo != NCryo; ++cryo){
1939 for(
size_t i=0; i!=NCryo; ++i){
1940 if( (OpDet >= LowestID[i]) && (OpDet < LowestID[i+1]) ){
1942 int o = OpDet-LowestID[i];
1947 throw cet::exception(
"OpID To OpDetCryo error")<<
"OpID out of range, "<< OpDet <<
"\n";
1959 if (!cryo)
return std::numeric_limits<unsigned int>::max();
1976 mf::LogError(
"WireIDIntersectionCheck")
1977 <<
"Comparing two wires on different TPCs: return failure.";
1981 mf::LogError(
"WireIDIntersectionCheck")
1982 <<
"Comparing two wires in the same plane: return failure";
1985 if (!HasWire(wid1)) {
1986 mf::LogError(
"WireIDIntersectionCheck")
1987 <<
"1st wire " << wid1 <<
" does not exist (max wire number: "
1988 << Nwires(wid1.
planeID()) <<
")";
1991 if (!HasWire(wid2)) {
1992 mf::LogError(
"WireIDIntersectionCheck")
1993 <<
"2nd wire " << wid2 <<
" does not exist (max wire number: "
1994 << Nwires(wid2.
planeID()) <<
")";
2003 double A_start_x,
double A_start_y,
double A_end_x,
double A_end_y,
2004 double B_start_x,
double B_start_y,
double B_end_x,
double B_end_y,
2035 if (++(current.
sibling) < parent.
self->GetNdaughters()) {
2048 std::vector<TGeoNode const*> node_path(
current_path.size());
2051 [](
NodeInfo_t const& node_info){
return node_info.self; });
2060 while (descendent->GetNdaughters() > 0) {
2061 descendent = descendent->GetDaughter(0);
2069 if (!start_node)
return;
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.
void FindAuxDetSensitiveAtPosition(geo::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.
Geometry description of a TPC wireThe wire is a single straight segment on a wire plane...
process_name opflash particleana ie ie ie z
geo::TPCID GetEndTPCID(geo::CryostatID const &id) const
GeoID GetEndID() const
Returns the (possibly invalid) ID after the last subelement of the detector.
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.
IDparameter< geo::CryostatID > CryostatID
Member type of validated geo::CryostatID parameter.
double std(const std::vector< short > &wf, const double ped_mean, size_t start, size_t nsample)
geo::Length_t CryostatHalfHeight(geo::CryostatID const &cid) const
Returns the height of the cryostat (y direction)
std::unique_ptr< const geo::ChannelMapAlg > fChannelMapAlg
Object containing the channel to wire mapping.
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
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.
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.
BEGIN_PROLOG true icarus_rawdigitfilter FilterTools FilterPlane1 Plane
unsigned int TotalNTPC() const
Returns the total number of TPCs in the detector.
static constexpr TPCID_t InvalidID
Special code for an invalid ID.
std::vector< NodeInfo_t > current_path
which node, which sibling?
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.
unsigned int FindAuxDetAtPosition(double const worldLoc[3], double tolerance=0) const
Returns the index of the auxiliary detector at specified location.
CryostatGeo const & PositionToCryostat(geo::Point_t const &point) const
Returns the cryostat at specified location.
ROOTGeoNodeForwardIterator & operator++()
Points to the next node, or to nullptr if there are no more.
process_name opflash particleana ie x
Encapsulate the geometry of the sensitive portion of an auxiliary detector.
GeoID GetBeginID() const
Returns the ID of the first element of the 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.
virtual void SortCryostats(std::vector< geo::CryostatGeo > &cgeo) const =0
void Print(Stream &&out, std::string indent=" ") const
Prints geometry information with maximum verbosity.
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].
AuxDetSensitiveGeo const & SensitiveVolume(size_t sv) const
virtual geo::GeoObjectSorter const & Sorter() const =0
Returns the object to sort geometry with.
unsigned int Nplanes() const
Number of planes in this tpc.
std::string OpDetGeoName(unsigned int c=0) const
Returns gdml string which gives sensitive opdet name.
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.
constexpr bool zero(Value_t value) const
Returns whether the value is no farther from 0 than the threshold.
double MinX() const
Returns the world x coordinate of the start of the box.
unsigned int PlaneID_t
Type for the ID number.
The data type to uniquely identify a Plane.
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.
geo::PlaneID GetBeginPlaneID(geo::CryostatID const &id) const
Returns the ID of the first plane of the specified cryostat.
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
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
unsigned int NTPCsets(readout::CryostatID const &cryoid) const
Returns the total number of TPC sets in the specified cryostat.
Cryostats_t extractCryostats(Path_t const &path)
Looks for all cryostats under the specified path.
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.
const AuxDetSensitiveGeo & ChannelToAuxDetSensitive(std::string const &auxDetName, uint32_t const &channel) const
Point const & end() const
geo::WireID GetEndWireID(geo::CryostatID const &id) 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.
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 operator()(TGeoNode const &node)
If the name of the node matches, records the end node.
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 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.
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.
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; .
double TotalMass() const
Returns the total mass [kg] of the specified volume (default: world).
static lar::util::RealComparisons< geo::Length_t > coordIs
Value of tolerance for equality comparisons.
BEGIN_PROLOG triggeremu_data_config_icarus settings PMTADCthresholds sequence::icarus_stage0_multiTPC_TPC physics sequence::icarus_stage0_EastHits_TPC physics sequence::icarus_stage0_WestHits_TPC physics producers purityana0 caloskimCalorimetryCryoE physics caloskimCalorimetryCryoW physics path
geo::TPCID FindTPCAtPosition(double const worldLoc[3]) const
Returns the ID of the TPC at specified location.
Access the description of detector geometry.
void operator()(ROOTGeoNodeForwardIterator const &iter)
If the name of the node matches, records the node full path.
bool HasROP(readout::ROPID const &ropid) const
View_t View() const
Which coordinate does this plane measure.
IteratorBox< wire_id_iterator,&GeometryCore::begin_wire_id,&GeometryCore::end_wire_id > IterateWireIDs() const
Enables ranged-for loops on all wire IDs of the detector.
std::string OpDetGeoName() const
Get name of opdet geometry element.
NodeNameMatcherClass matcher
void SortGeometry(geo::GeoObjectSorter const &sorter)
Runs the sorting of geometry with the sorter provided by channel mapping.
PlaneGeo const * PlanePtr(geo::PlaneID const &planeid) const
Returns the specified plane.
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.
process_name opflash particleana ie ie y
Classes to project and compose a vector on a plane.
const OpDetGeo & OpDet(unsigned int iopdet) const
Return the iopdet'th optical detector in the cryostat.
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
IteratorBox< TPC_iterator,&GeometryCore::begin_TPC,&GeometryCore::end_TPC > IterateTPCs() const
Enables ranged-for loops on all TPCs of the detector.
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].
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.
virtual void SortAuxDets(std::vector< geo::AuxDetGeo > &adgeo) const =0
Geometry information for a single wire plane.The plane is represented in the geometry by a solid whic...
auto end(FixedBins< T, C > const &) noexcept
NodeNameMatcherClass(std::set< std::string > const &names)
process_name showerreco Particles Coinciding wih the Vertex services ScanOptions nu_mu unknown
Utilities to extend the interface of geometry vectors.
double MinZ() const
Returns the world z coordinate of the start of the box.
void BuildGeometry(geo::GeometryBuilder &builder)
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.
TPCGeo const * TPCPtr(geo::TPCID const &tpcid) const
Returns the specified TPC.
unsigned int MaxOpChannel() const
Largest optical channel number.
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.
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.
unsigned int MaxWires() const
Returns the largest number of wires among the planes in this TPC.
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.
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.
void LoadGeometryFile(std::string gdmlfile, std::string rootfile, geo::GeometryBuilder &builder, bool bForceReload=false)
Loads the geometry information from the specified files.
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.
readout::ROPID ChannelToROP(raw::ChannelID_t channel) const
auto begin(FixedBins< T, C > const &) noexcept
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.
std::string fGDMLfile
path to geometry file used for Geant4 simulation
static const std::vector< std::string > names
bool WireIDsIntersect(WireID const &wid1, WireID const &wid2, geo::Point_t &intersection) const
Computes the intersection between two wires.
AuxDetGeo const & PositionToAuxDet(geo::Point_t const &point, unsigned int &ad, double tolerance=0) const
Returns the auxiliary detector at specified location.
WireGeo const & Wire(geo::WireID const &wireid) const
Returns the specified wire.
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.
geo::WireID GetBeginWireID(geo::CryostatID const &id) const
Returns the ID of the first wire in the specified cryostat.
geo::CryostatGeo const * PositionToCryostatPtr(geo::Point_t const &point) const
Returns the cryostat at specified location.
A base class aware of world box coordinatesAn object describing a simple shape can inherit from this ...
void ApplyChannelMap(std::unique_ptr< geo::ChannelMapAlg > pChannelMap)
Initializes the geometry to work with this channel map.
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.
then echo File list $list not found else cat $list while read file do echo $file sed s
double y
y position of intersection
IteratorBox< TPCset_id_iterator,&GeometryCore::begin_TPCset_id,&GeometryCore::end_TPCset_id > IterateTPCsetIDs() const
Enables ranged-for loops on all TPC set IDs of the detector.
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.
unsigned int MaxTPCsets() const
Returns the largest number of TPC sets any cryostat in the detector has.
process_name largeant stream1 can override from command line with o or output physics producers generator N
const AuxDetSensitiveGeo & PositionToAuxDetSensitive(geo::Point_t const &point, size_t &ad, size_t &sv, double tolerance=0) const
Returns the auxiliary detector at specified location.
void init(TGeoNode const *start_node)
geo::TPCID GetBeginTPCID(geo::CryostatID const &id) const
Returns the ID of the first TPC in the specified cryostat.
unsigned int Nwires() const
Number of wires in this plane.
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
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)
Data structure for return values of LineClosestPointAndOffsets().
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.
Manages the extraction of LArSoft geometry information from ROOT.
Representation of a node and its ancestry.
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.
finds tracks best matching by angle
geo::BoxBoundedGeo const & Boundaries() const
Returns boundaries of the cryostat (in centimetres).
TPCGeo const & TPC(unsigned int const tpc=0, unsigned int const cstat=0) const
Returns the specified TPC.
static constexpr CryostatID_t InvalidID
Special code for an invalid ID.
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
std::string MaterialName(TVector3 const &point) const
Name of the deepest material containing the point xyz.
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.
Collection of Physical constants used in LArSoft.
GeoID GetNextID(GeoID const &id) const
Returns the ID next to the specified one.
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.
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()).
fhicl::ParameterSet fBuilderParameters
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.
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.
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.
Extracts of LArSoft geometry information from ROOT.
double WireAngleToVertical(geo::View_t view, geo::TPCID const &tpcid) const
Returns the angle of the wires in the specified view from vertical.
physics associatedGroupsWithLeft p1
CryostatGeo const * CryostatPtr(geo::CryostatID const &cryoid) const
Returns the specified cryostat.
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.
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.
virtual void Initialize(GeometryData_t const &geodata)=0
Geometry initialisation.
The data type to uniquely identify a cryostat.
std::string GetLArTPCVolumeName(geo::TPCID const &tpcid) const
Return the name of specified LAr TPC volume.
geo::PlaneID GetEndPlaneID(geo::CryostatID const &id) const
geo::IntersectionPointAndOffsets< geo::Point_t > WiresIntersectionAndOffsets(geo::WireGeo const &wireA, geo::WireGeo const &wireB)
Returns the point of wireA that is closest to wireB.
geo::CryostatID const & ID() const
Returns the identifier of this cryostat.
bool HasTPCset(readout::TPCsetID const &tpcsetid) const
geo::BoxBoundedGeo WorldBox() const