25 #include "cetlib_except/exception.h" 30 #include <TGeoManager.h> 32 #include <TGeoVolume.h> 33 #include <TGeoMatrix.h> 35 #include <TGeoVolume.h> 62 : fSurfaceY (pset.
get< double >(
"SurfaceY" ))
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)
98 if (gdmlfile.empty()) {
100 <<
"No GDML Geometry file specified!\n";
103 if (rootfile.empty()) {
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);
130 gGeoManager->LockGeometry();
138 mf::LogInfo(
"GeometryCore") <<
"New detector geometry loaded from " 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();
326 <<
" does not exist\n";
345 <<
" does not exist\n";
356 if (!cryo)
return {};
360 if (tpcid)
return tpcid;
402 (
double const worldLoc[3])
const 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 465 <<
"Can't find any cryostat at position " << point <<
"\n";
478 throw cet::exception(
"GeometryCore") <<
"Can't find Cryostat for position (" 479 << worldLoc[0] <<
"," 480 << worldLoc[1] <<
"," 481 << worldLoc[2] <<
")\n";
487 (
double const worldLoc[3],
unsigned int &cstat)
const 500 std::array<double, 3U> worldPos = {{ point.X(), point.Y(), point.Z() }};
520 (
double const worldLoc[3],
unsigned int &ad,
double tolerance)
const 525 (
geo::Point_t const& point, std::size_t& adg, std::size_t& sv,
double tolerance)
const 530 std::array<double, 3U>
const worldPos = {{ point.X(), point.Y(), point.Z() }};
536 (
double const worldPos[3],
size_t& adg,
size_t& sv,
double tolerance)
const 542 (
geo::Point_t const& point,
size_t& ad,
size_t& sv,
double tolerance)
const 551 (
double const worldLoc[3],
size_t& ad,
size_t& sv,
double tolerance)
const 559 return this->
AuxDet(adIdx);
584 if (!ropid.isValid) {
586 <<
"SignalType(): Mapping of wire plane " <<
std::string(pid)
587 <<
" to readout plane failed!\n";
634 <<
"DetectorEnclosureBox(): can't find enclosure volume '" << name <<
"'\n";
637 TGeoVolume
const* pEncl = path.back()->GetVolume();
638 auto const* pBox =
dynamic_cast<TGeoBBox
const*
>(pEncl->GetShape());
644 << name <<
"' is not a box! (it is a " << pEncl->GetShape()->IsA()->GetName()
650 const double halfwidth = pBox->GetDX();
651 const double halfheight = pBox->GetDY();
652 const double halflength = pBox->GetDZ();
656 trans.LocalToWorld(
geo::Point_t{ +halfwidth, +halfheight, +halflength })
665 : vol_names(&names) {}
668 bool operator() (TGeoNode
const& node)
const 670 if (!vol_names)
return true;
671 return vol_names->find(node.GetVolume()->GetName()) != vol_names->end();
682 void operator() (TGeoNode
const& node)
683 {
if (matcher(node)) nodes.push_back(&node); }
686 { operator() (**iter); }
693 std::vector<std::vector<TGeoNode const*>>
paths;
699 {
if (matcher(**iter)) paths.push_back(iter.
get_path()); }
706 (std::set<std::string>
const& vol_names)
const 711 TGeoNode
const* pCurrentNode;
713 while ((pCurrentNode = *iNode)) {
714 node_collector(*pCurrentNode);
718 return node_collector.
nodes;
723 (std::set<std::string>
const& vol_names)
const 730 path_collector(iNode);
734 return path_collector.
paths;
817 unsigned int cstat)
const 848 for (
unsigned int p = 0;
p < TPC.
Nplanes(); ++
p) {
850 if (plane.
View() == view)
return plane.
ThetaZ();
852 throw cet::exception(
"GeometryCore") <<
"WireAngleToVertical(): no view \"" 859 unsigned int maxTPCs = 0;
861 unsigned int maxTPCsInCryo = cryo.NTPC();
862 if (maxTPCsInCryo > maxTPCs) maxTPCs = maxTPCsInCryo;
873 {
return sum + cryo.
NTPC(); }
879 unsigned int maxPlanes = 0;
881 unsigned int maxPlanesInCryo = cryo.MaxPlanes();
882 if (maxPlanesInCryo > maxPlanes) maxPlanes = maxPlanesInCryo;
889 unsigned int maxWires = 0;
891 unsigned int maxWiresInCryo = cryo.MaxWires();
892 if (maxWiresInCryo > maxWires) maxWires = maxWiresInCryo;
910 TGeoShape
const*
s = world->GetShape();
916 double x1,
x2, y1, y2, z1, z2;
917 s->GetAxisRange(1, x1, x2);
918 s->GetAxisRange(2, y1, y2);
919 s->GetAxisRange(3, z1, z2);
927 double* ylo,
double* yhi,
928 double* zlo,
double* zhi)
const 931 if (xlo) *xlo = box.
MinX();
932 if (ylo) *ylo = box.
MinY();
933 if (zlo) *zlo = box.
MinZ();
934 if (xhi) *xhi = box.
MaxX();
935 if (yhi) *yhi = box.
MaxY();
936 if (zhi) *zhi = box.
MaxZ();
944 double halflength = ((TGeoBBox*)volWorld->GetShape())->GetDZ();
945 double halfheight = ((TGeoBBox*)volWorld->GetShape())->GetDY();
946 double halfwidth = ((TGeoBBox*)volWorld->GetShape())->GetDX();
947 if(
std::abs(point.x()) > halfwidth ||
951 mf::LogWarning(
"GeometryCoreBadInputPoint") <<
"point (" << point.x() <<
"," 952 << point.y() <<
"," << point.z() <<
") " 953 <<
"is not inside the world volume " 954 <<
" half width = " << halfwidth
955 <<
" half height = " << halfheight
956 <<
" half length = " << halflength
957 <<
" returning unknown volume name";
962 return gGeoManager->FindNode(point.X(), point.Y(), point.Z())->GetName();
967 auto const pNode = gGeoManager->FindNode(point.X(), point.Y(), point.Z());
968 if (!pNode)
return nullptr;
969 auto const pMedium = pNode->GetMedium();
970 return pMedium? pMedium->GetMaterial():
nullptr;
980 <<
"point " << point <<
" is not inside the world volume " 981 << worldBox.
Min() <<
" -- " << worldBox.
Max()
982 <<
"; returning unknown material name";
983 return {
"unknownMaterial" };
985 auto const pMaterial =
Material(point);
988 <<
"material for point " << point
989 <<
" not found! returning unknown material name";
990 return {
"unknownMaterial" };
992 return pMaterial->GetName();
1000 std::vector<TGeoNode const*> path {
ROOTGeoManager()->GetTopNode() };
1009 assert(!path.empty());
1011 auto const* pCurrent = path.back();
1014 if (strncmp(name.c_str(), pCurrent->GetName(), name.length()) == 0)
1018 auto const* pCurrentVolume = pCurrent->GetVolume();
1019 unsigned int nd = pCurrentVolume->GetNdaughters();
1020 for(
unsigned int i = 0; i < nd; ++i) {
1021 path.push_back(pCurrentVolume->GetNode(i));
1046 TGeoVolume *gvol = gGeoManager->FindVolumeFast(vol.c_str());
1047 if(gvol)
return gvol->Weight();
1049 throw cet::exception(
"GeometryCore") <<
"could not find specified volume '" 1051 <<
" 'to determine total mass\n";
1064 double columnD = 0.;
1069 double const dxyz[3] = { dir.X(), dir.Y(), dir.Z() };
1070 double const cp1[3] = { p1.X(), p1.Y(), p1.Z() };
1071 gGeoManager->InitTrack(cp1, dxyz);
1074 TGeoNode *node = gGeoManager->GetCurrentNode();
1079 while(!gGeoManager->IsSameLocation(p2.X(), p2.Y(), p2.Z())){
1080 gGeoManager->FindNextBoundary();
1081 columnD += gGeoManager->GetStep()*node->GetMedium()->GetMaterial()->GetDensity();
1084 node = gGeoManager->Step();
1091 double const lastStep = (p2 - last).
R();
1092 columnD += lastStep*node->GetMedium()->GetMaterial()->GetDensity();
1099 std::ostringstream sstr;
1100 Print(sstr, indent);
1158 if(worldPos.size() > 3)
throw cet::exception(
"GeometryCore") <<
"bad size vector for " 1160 << worldPos.size() <<
"\n";
1175 if(worldPos.size() > 3)
throw cet::exception(
"GeometryCore") <<
"bad size vector for " 1177 << worldPos.size() <<
"\n";
1199 if(worldPos.size() > 3)
throw cet::exception(
"GeometryCore") <<
"bad size vector for " 1201 << worldPos.size() <<
"\n";
1238 return (value>=min) && (value<=
max);
1247 xyzStart[0] = result.
start().X();
1248 xyzStart[1] = result.
start().Y();
1249 xyzStart[2] = result.
start().Z();
1250 xyzEnd[0] = result.
end().X();
1251 xyzEnd[1] = result.
end().Y();
1252 xyzEnd[2] = result.
end().Z();
1254 if(xyzEnd[2]<xyzStart[2]){
1260 if(xyzEnd[1]<xyzStart[1] &&
std::abs(xyzEnd[2]-xyzStart[2])<0.01){
1280 if (chan1wires.empty()) {
1282 <<
"1st channel " << c1 <<
" maps to no wire (is it a real one?)";
1286 if (chan2wires.empty()) {
1288 <<
"2nd channel " << c2 <<
" maps to no wire (is it a real one?)";
1292 if (chan1wires.size() > 1) {
1294 <<
"1st channel " << c1 <<
" maps to " << chan2wires.size()
1295 <<
" wires; using the first!";
1298 if (chan2wires.size() > 1) {
1300 <<
"2nd channel " << c2 <<
" maps to " << chan2wires.size()
1301 <<
" wires; using the first!";
1321 double A_start_x,
double A_start_y,
double A_end_x,
double A_end_y,
1322 double B_start_x,
double B_start_y,
double B_end_x,
double B_end_y,
1323 double&
x,
double&
y 1331 double const denom = (A_start_x - A_end_x)*(B_start_y - B_end_y)
1332 - (A_start_y - A_end_y)*(B_start_x - B_end_x);
1336 double const A = (A_start_x * A_end_y - A_start_y * A_end_x) / denom;
1337 double const B = (B_start_x * B_end_y - B_start_y * B_end_x) / denom;
1339 x = (B_start_x - B_end_x) * A - (A_start_x - A_end_x) *
B;
1340 y = (B_start_y - B_end_y) * A - (A_start_y - A_end_y) *
B;
1348 double A_start_x,
double A_start_y,
double A_end_x,
double A_end_y,
1349 double B_start_x,
double B_start_y,
double B_end_x,
double B_end_y,
1350 double&
x,
double&
y 1354 A_start_x, A_start_y, A_end_x, A_end_y,
1355 B_start_x, B_start_y, B_end_x, B_end_y,
1360 mf::LogWarning(
"IntersectSegments") <<
"The segments are parallel!";
1365 A_start_x, A_start_y, A_end_x, A_end_y,
1366 B_start_x, B_start_y, B_end_x, B_end_y,
1380 std::numeric_limits<decltype(widIntersect.
y)>::has_infinity,
1381 "the vector coordinate type can't represent infinity!" 1383 constexpr
auto infinity
1384 = std::numeric_limits<decltype(widIntersect.
y)>::infinity();
1387 widIntersect.
y = widIntersect.
z = infinity;
1401 widIntersect.
y, widIntersect.
z 1404 widIntersect.
y = widIntersect.
z = infinity;
1411 widIntersect.
y, widIntersect.
z 1438 std::numeric_limits<decltype(intersection.X())>::has_infinity,
1439 "the vector coordinate type can't represent infinity!" 1441 constexpr
auto infinity
1442 = std::numeric_limits<decltype(intersection.X())>::infinity();
1445 intersection = { infinity, infinity, infinity };
1455 intersection = intersectionAndOffset.
point;
1457 bool const within = (
1485 const unsigned int nPlanes =
Nplanes(pid1);
1488 <<
"ThirdPlane() supports only TPCs with 3 planes, and I see " 1489 << nPlanes <<
" instead\n";
1494 if ((iPlane == pid1.
Plane) || (iPlane == pid2.
Plane))
continue;
1495 if (target_plane != nPlanes) {
1497 <<
"ThirdPlane() found too many planes that are not " 1499 <<
"! (first " << target_plane <<
", then " << iPlane <<
")\n";
1501 target_plane = iPlane;
1503 if (target_plane == nPlanes) {
1505 <<
"ThirdPlane() can't find a plane that is not " <<
std::string(pid1)
1518 << caller <<
" needs two planes on the same TPC (got " 1523 << caller <<
" needs two different planes, got " 1569 double angle[3], pitch[3];
1576 for (
size_t i = 0; i < 3; ++i) {
1577 angle[i] = planes[i]->
PhiZ();
1582 angle[0], pitch[0], slope1,
1583 angle[1], pitch[1], slope2,
1607 (
double angle1,
double slope1,
double angle2,
double slope2,
double angle3)
1612 if ((
std::abs(slope1) < 0.001) && (
std::abs(slope2)) < 0.001)
return 0.001;
1616 double slope3 = 0.001;
1620 + (1./slope1)*std::sin(angle3-angle2)
1621 - (1./slope2)*std::sin(angle3-angle1)
1622 ) / std::sin(angle1-angle2)
1625 if (slope3 != 0.) slope3 = 1./slope3;
1633 double angle1,
double pitch1,
double dTdW1,
1634 double angle2,
double pitch2,
double dTdW2,
1635 double angle_target,
double pitch_target
1644 (angle1, dTdW1 / pitch1, angle2, dTdW2 / pitch2, angle_target);
1659 double &
y,
double &
z)
const 1691 (
double const worldLoc[3])
const 1790 static bool Loaded=
false;
1791 static std::vector<unsigned int> LowestID;
1792 static unsigned int NCryo;
1794 if(Loaded ==
false){
1800 LowestID.resize(NCryo + 1);
1802 for(
size_t cryo=0; cryo!=NCryo; ++cryo){
1808 if( (c < NCryo) && (o <
Cryostat(c).NOpDet())){
1809 return LowestID.at(c)+o;
1812 throw cet::exception(
"OpDetCryoToOpID Error") <<
"Coordinates c=" << c
1814 <<
" out of range. Abort\n";
1832 static bool Loaded=
false;
1833 static std::vector<unsigned int> LowestID;
1834 static size_t NCryo;
1836 if(Loaded ==
false){
1842 LowestID.resize(NCryo + 1);
1844 for(
size_t cryo = 0; cryo != NCryo; ++cryo){
1850 for(
size_t i=0; i!=NCryo; ++i){
1851 if( (OpDet >= LowestID[i]) && (OpDet < LowestID[i+1]) ){
1853 int o = OpDet-LowestID[i];
1858 throw cet::exception(
"OpID To OpDetCryo error")<<
"OpID out of range, "<< OpDet <<
"\n";
1888 <<
"Comparing two wires on different TPCs: return failure.";
1893 <<
"Comparing two wires in the same plane: return failure";
1898 <<
"1st wire " << wid1 <<
" does not exist (max wire number: " 1904 <<
"2nd wire " << wid2 <<
" does not exist (max wire number: " 1914 double A_start_x,
double A_start_y,
double A_end_x,
double A_end_y,
1915 double B_start_x,
double B_start_y,
double B_end_x,
double B_end_y,
1939 if (current_path.empty())
return *
this;
1940 if (current_path.size() == 1) { current_path.pop_back();
return *
this; }
1946 if (++(current.
sibling) < parent.
self->GetNdaughters()) {
1949 reach_deepest_descendant();
1951 else current_path.pop_back();
1959 std::vector<TGeoNode const*> node_path(current_path.size());
1961 std::transform(current_path.begin(), current_path.end(), node_path.begin(),
1962 [](
NodeInfo_t const& node_info){
return node_info.self; });
1970 Node_t descendent = current_path.back().self;
1971 while (descendent->GetNdaughters() > 0) {
1972 descendent = descendent->GetDaughter(0);
1973 current_path.emplace_back(descendent, 0U);
1979 current_path.clear();
1980 if (!start_node)
return;
1981 current_path.emplace_back(start_node, 0U);
1982 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.
end
while True: pbar.update(maxval-len(onlies[E][S])) #print iS, "/", len(onlies[E][S]) found = False for...
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...
unsigned int GetClosestOpDet(geo::Point_t const &point) const
Utilities to extend the interface of geometry vectors.
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.
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.
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.
unsigned int TotalNTPC() const
Returns the total number of TPCs in the detector.
GeometryData_t fGeoData
The detector description data.
static constexpr TPCID_t InvalidID
Special code for an invalid ID.
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.
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.
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].
MaybeLogger_< ELseverityLevel::ELsev_info, false > LogInfo
AuxDetSensitiveGeo const & SensitiveVolume(size_t sv) const
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.
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.
virtual void SortAuxDets(std::vector< geo::AuxDetGeo > &adgeo) const =0
WireID_t Wire
Index of the wire within its plane.
const AuxDetSensitiveGeo & ChannelToAuxDetSensitive(std::string const &auxDetName, uint32_t const &channel) const
Point const & end() const
ROOT::Math::DisplacementVector3D< ROOT::Math::Cartesian3D< double >, ROOT::Math::GlobalCoordinateSystemTag > Vector_t
Type for representation of momenta in 3D space.
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.
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.
unsigned int OpDetFromOpChannel(int opChannel) const
Convert unique channel to detector number.
GENVECTOR_CONSTEXPR::geo::Point_t makePointFromCoords(Coords &&coords)
Creates a geo::Point_t from its coordinates (see makeFromCoords()).
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.
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.
geo::TPCID FindTPCAtPosition(double const worldLoc[3]) const
Returns the ID of the TPC at specified location.
virtual geo::GeoObjectSorter const & Sorter() const =0
Returns the object to sort geometry with.
virtual void SortCryostats(std::vector< geo::CryostatGeo > &cgeo) const =0
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.
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.
Encapsulate the geometry of the sensitive portion of an auxiliary detector.
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.
constexpr ProductStatus unknown() noexcept
void swap(Handle< T > &a, Handle< T > &b)
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.
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)
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.
Encapsulate the geometry of an auxiliary detector.
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.
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.
static int max(int a, int b)
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
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.
Specializations of geo_vectors_utils.h for ROOT old vector types.
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.
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.
double HalfL() const
Returns half the length of the wire [cm].
ROOT::Math::PositionVector3D< ROOT::Math::Cartesian3D< double >, ROOT::Math::GlobalCoordinateSystemTag > Point_t
Type for representation of position in physical 3D space.
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
double Length_t
Type used for coordinates and distances. They are measured in centimeters.
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::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.
T min(sqlite3 *const db, std::string const &table_name, std::string const &column_name)
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.
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.
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)
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
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.
Access the description of detector geometry.
detail::Node< FrameID, bool > PlaneID
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.
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.
decltype(auto) constexpr begin(T &&obj)
ADL-aware version of std::begin.
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.
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.
static std::vector< std::string > const names
auto const & get(AssnsNode< L, R, D > const &r)
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.
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.
void reach_deepest_descendant()
LArSoft geometry interface.
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.
def parent(G, child, parent_type)
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.
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.
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::IntersectionPointAndOffsets< geo::Point_t > WiresIntersectionAndOffsets(geo::WireGeo const &wireA, geo::WireGeo const &wireB)
Returns the point of wireA that is closest to wireB.
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