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");
590 : vol_names(&names) {}
593 bool operator() (TGeoNode
const& node)
const 595 if (!vol_names)
return true;
596 return vol_names->find(node.GetVolume()->GetName()) != vol_names->end();
607 void operator() (TGeoNode
const& node)
608 {
if (matcher(node)) nodes.push_back(&node); }
611 { operator() (**iter); }
618 std::vector<std::vector<TGeoNode const*>>
paths;
624 {
if (matcher(**iter)) paths.push_back(iter.
get_path()); }
633 (std::set<std::string>
const& vol_names)
const 638 TGeoNode
const* pCurrentNode;
640 while ((pCurrentNode = *iNode)) {
641 node_collector(*pCurrentNode);
645 return node_collector.
nodes;
650 (std::set<std::string>
const& vol_names)
const 657 path_collector(iNode);
661 return path_collector.
paths;
669 return std::string(
TPC(tpcid).ActiveVolume()->GetName());
675 return std::string(
Cryostat(cid).Volume()->GetName());
744 unsigned int cstat)
const 775 for (
unsigned int p = 0; p < TPC.
Nplanes(); ++p) {
777 if (plane.
View() == view)
return plane.
ThetaZ();
779 throw cet::exception(
"GeometryCore") <<
"WireAngleToVertical(): no view \"" 781 <<
") in " << std::string(tpcid);
786 unsigned int maxTPCs = 0;
788 unsigned int maxTPCsInCryo = cryo.NTPC();
789 if (maxTPCsInCryo > maxTPCs) maxTPCs = maxTPCsInCryo;
800 {
return sum + cryo.
NTPC(); }
806 unsigned int maxPlanes = 0;
808 unsigned int maxPlanesInCryo = cryo.MaxPlanes();
809 if (maxPlanesInCryo > maxPlanes) maxPlanes = maxPlanesInCryo;
816 unsigned int maxWires = 0;
818 unsigned int maxWiresInCryo = cryo.MaxWires();
819 if (maxWiresInCryo > maxWires) maxWires = maxWiresInCryo;
837 TGeoShape
const*
s = world->GetShape();
844 s->GetAxisRange(1, x1, x2);
845 s->GetAxisRange(2, y1, y2);
846 s->GetAxisRange(3, z1, z2);
854 double* ylo,
double* yhi,
855 double* zlo,
double* zhi)
const 858 if (xlo) *xlo = box.
MinX();
859 if (ylo) *ylo = box.
MinY();
860 if (zlo) *zlo = box.
MinZ();
861 if (xhi) *xhi = box.
MaxX();
862 if (yhi) *yhi = box.
MaxY();
863 if (zhi) *zhi = box.
MaxZ();
871 double halflength = ((TGeoBBox*)volWorld->GetShape())->GetDZ();
872 double halfheight = ((TGeoBBox*)volWorld->GetShape())->GetDY();
873 double halfwidth = ((TGeoBBox*)volWorld->GetShape())->GetDX();
874 if(std::abs(point.x()) > halfwidth ||
875 std::abs(point.y()) > halfheight ||
876 std::abs(point.z()) > halflength
878 mf::LogWarning(
"GeometryCoreBadInputPoint") <<
"point (" << point.x() <<
"," 879 << point.y() <<
"," << point.z() <<
") " 880 <<
"is not inside the world volume " 881 <<
" half width = " << halfwidth
882 <<
" half height = " << halfheight
883 <<
" half length = " << halflength
884 <<
" returning unknown volume name";
885 const std::string
unknown(
"unknownVolume");
889 return gGeoManager->FindNode(point.X(), point.Y(), point.Z())->GetName();
894 auto const pNode = gGeoManager->FindNode(point.X(), point.Y(), point.Z());
895 if (!pNode)
return nullptr;
896 auto const pMedium = pNode->GetMedium();
897 return pMedium? pMedium->GetMaterial():
nullptr;
907 <<
"point " << point <<
" is not inside the world volume " 908 << worldBox.
Min() <<
" -- " << worldBox.
Max()
909 <<
"; returning unknown material name";
910 return {
"unknownMaterial" };
912 auto const pMaterial =
Material(point);
915 <<
"material for point " << point
916 <<
" not found! returning unknown material name";
917 return {
"unknownMaterial" };
919 return pMaterial->GetName();
926 const char* nm = path[depth]->GetName();
927 if( (strncmp(nm,
"volCryostat", 11) == 0) ){
933 unsigned int deeper = depth+1;
934 if(deeper >= path.size()){
935 throw cet::exception(
"GeometryCore") <<
"exceeded maximum TGeoNode depth\n";
938 const TGeoVolume *v = path[depth]->GetVolume();
939 int nd = v->GetNdaughters();
940 for(
int i = 0; i < nd; ++i){
941 path[deeper] = v->GetNode(i);
957 const char* nm = path[depth]->GetName();
958 if( (strncmp(nm,
"volAuxDet", 9) == 0) ){
964 unsigned int deeper = depth+1;
965 if(deeper >= path.size()){
966 throw cet::exception(
"GeometryCore") <<
"exceeded maximum TGeoNode depth\n";
969 const TGeoVolume *v = path[depth]->GetVolume();
970 int nd = v->GetNdaughters();
971 for(
int i = 0; i < nd; ++i){
972 path[deeper] = v->GetNode(i);
993 TGeoVolume *gvol = gGeoManager->FindVolumeFast(vol.c_str());
994 if(gvol)
return gvol->Weight();
996 throw cet::exception(
"GeometryCore") <<
"could not find specified volume '" 998 <<
" 'to determine total mass\n";
1011 double columnD = 0.;
1016 double const dxyz[3] = { dir.X(), dir.Y(), dir.Z() };
1017 double const cp1[3] = { p1.X(), p1.Y(), p1.Z() };
1018 gGeoManager->InitTrack(cp1, dxyz);
1021 TGeoNode *node = gGeoManager->GetCurrentNode();
1026 while(!gGeoManager->IsSameLocation(p2.X(), p2.Y(), p2.Z())){
1027 gGeoManager->FindNextBoundary();
1028 columnD += gGeoManager->GetStep()*node->GetMedium()->GetMaterial()->GetDensity();
1031 node = gGeoManager->Step();
1038 double const lastStep = (p2 - last).
R();
1039 columnD += lastStep*node->GetMedium()->GetMaterial()->GetDensity();
1096 if(worldPos.size() > 3)
throw cet::exception(
"GeometryCore") <<
"bad size vector for " 1098 << worldPos.size() <<
"\n";
1099 TVector3 wp(&(worldPos[0]));
1114 if(worldPos.size() > 3)
throw cet::exception(
"GeometryCore") <<
"bad size vector for " 1116 << worldPos.size() <<
"\n";
1117 TVector3 wp(&(worldPos[0]));
1139 if(worldPos.size() > 3)
throw cet::exception(
"GeometryCore") <<
"bad size vector for " 1141 << worldPos.size() <<
"\n";
1142 TVector3 wp(&(worldPos[0]));
1177 if(min>max) std::swap(min,max);
1178 if (std::abs(value-min)<1
e-6||std::abs(value-max)<1
e-6)
return true;
1179 return (value>=min) && (value<=
max);
1188 xyzStart[0] = result.
start().X();
1189 xyzStart[1] = result.
start().Y();
1190 xyzStart[2] = result.
start().Z();
1191 xyzEnd[0] = result.
end().X();
1192 xyzEnd[1] = result.
end().Y();
1193 xyzEnd[2] = result.
end().Z();
1195 if(xyzEnd[2]<xyzStart[2]){
1197 std::swap(xyzStart[0],xyzEnd[0]);
1198 std::swap(xyzStart[1],xyzEnd[1]);
1199 std::swap(xyzStart[2],xyzEnd[2]);
1201 if(xyzEnd[1]<xyzStart[1] && std::abs(xyzEnd[2]-xyzStart[2])<0.01){
1203 std::swap(xyzStart[0],xyzEnd[0]);
1204 std::swap(xyzStart[1],xyzEnd[1]);
1205 std::swap(xyzStart[2],xyzEnd[2]);
1221 if (chan1wires.empty()) {
1223 <<
"1st channel " << c1 <<
" maps to no wire (is it a real one?)";
1227 if (chan2wires.empty()) {
1229 <<
"2nd channel " << c2 <<
" maps to no wire (is it a real one?)";
1233 if (chan1wires.size() > 1) {
1235 <<
"1st channel " << c1 <<
" maps to " << chan2wires.size()
1236 <<
" wires; using the first!";
1239 if (chan2wires.size() > 1) {
1241 <<
"2nd channel " << c2 <<
" maps to " << chan2wires.size()
1242 <<
" wires; using the first!";
1262 double A_start_x,
double A_start_y,
double A_end_x,
double A_end_y,
1263 double B_start_x,
double B_start_y,
double B_end_x,
double B_end_y,
1264 double&
x,
double&
y 1272 double const denom = (A_start_x - A_end_x)*(B_start_y - B_end_y)
1273 - (A_start_y - A_end_y)*(B_start_x - B_end_x);
1277 double const A = (A_start_x * A_end_y - A_start_y * A_end_x) / denom;
1278 double const B = (B_start_x * B_end_y - B_start_y * B_end_x) / denom;
1280 x = (B_start_x - B_end_x) * A - (A_start_x - A_end_x) *
B;
1281 y = (B_start_y - B_end_y) * A - (A_start_y - A_end_y) *
B;
1289 double A_start_x,
double A_start_y,
double A_end_x,
double A_end_y,
1290 double B_start_x,
double B_start_y,
double B_end_x,
double B_end_y,
1291 double&
x,
double&
y 1295 A_start_x, A_start_y, A_end_x, A_end_y,
1296 B_start_x, B_start_y, B_end_x, B_end_y,
1301 mf::LogWarning(
"IntersectSegments") <<
"The segments are parallel!";
1306 A_start_x, A_start_y, A_end_x, A_end_y,
1307 B_start_x, B_start_y, B_end_x, B_end_y,
1320 std::numeric_limits<decltype(widIntersect.
y)>::has_infinity,
1321 "the vector coordinate type can't represent infinity!" 1323 constexpr
auto infinity
1324 = std::numeric_limits<decltype(widIntersect.
y)>::infinity();
1327 widIntersect.
y = widIntersect.
z = infinity;
1341 widIntersect.
y, widIntersect.
z 1344 widIntersect.
y = widIntersect.
z = infinity;
1351 widIntersect.
y, widIntersect.
z 1378 std::numeric_limits<decltype(intersection.X())>::has_infinity,
1379 "the vector coordinate type can't represent infinity!" 1381 constexpr
auto infinity
1382 = std::numeric_limits<decltype(intersection.X())>::infinity();
1385 intersection = { infinity, infinity, infinity };
1415 auto const dc =
c2 -
c1;
1419 double const w1w2 =
dot(w1, w2);
1420 double const cscAngle2 = 1.0 / (1.0 -
sqr(w1w2));
1421 double const dcw1 =
dot(dc, w1);
1422 double const dcw2 =
dot(dc, w2);
1423 double const t = (dcw1 - (dcw2 * w1w2)) * cscAngle2;
1424 double const u = (-dcw2 + (dcw1 * w1w2)) * cscAngle2;
1426 intersection = c1 + t * w1;
1429 = (std::abs(t) <= wire1.
HalfL()) && (std::abs(u) <= wire2.
HalfL());
1454 const unsigned int nPlanes =
Nplanes(pid1);
1457 <<
"ThirdPlane() supports only TPCs with 3 planes, and I see " 1458 << nPlanes <<
" instead\n";
1463 if ((iPlane == pid1.
Plane) || (iPlane == pid2.
Plane))
continue;
1464 if (target_plane != nPlanes) {
1466 <<
"ThirdPlane() found too many planes that are not " 1467 << std::string(pid1) <<
" nor " << std::string(pid2)
1468 <<
"! (first " << target_plane <<
", then " << iPlane <<
")\n";
1470 target_plane = iPlane;
1472 if (target_plane == nPlanes) {
1474 <<
"ThirdPlane() can't find a plane that is not " << std::string(pid1)
1475 <<
" nor " << std::string(pid2) <<
"!\n";
1487 << caller <<
" needs two planes on the same TPC (got " 1488 << std::string(pid1) <<
" and " << std::string(pid2) <<
")\n";
1492 << caller <<
" needs two different planes, got " 1493 << std::string(pid1) <<
" twice\n";
1538 double angle[3], pitch[3];
1545 for (
size_t i = 0; i < 3; ++i) {
1546 angle[i] = planes[i]->
PhiZ();
1551 angle[0], pitch[0], slope1,
1552 angle[1], pitch[1], slope2,
1576 (
double angle1,
double slope1,
double angle2,
double slope2,
double angle3)
1581 if ((std::abs(slope1) < 0.001) && (std::abs(slope2)) < 0.001)
return 0.001;
1585 double slope3 = 0.001;
1586 if (std::abs(slope1) > 0.001 && std::abs(slope2) > 0.001) {
1589 + (1./slope1)*std::sin(angle3-angle2)
1590 - (1./slope2)*std::sin(angle3-angle1)
1591 ) / std::sin(angle1-angle2)
1594 if (slope3 != 0.) slope3 = 1./slope3;
1602 double angle1,
double pitch1,
double dTdW1,
1603 double angle2,
double pitch2,
double dTdW2,
1604 double angle_target,
double pitch_target
1613 (angle1, dTdW1 / pitch1, angle2, dTdW2 / pitch2, angle_target);
1628 double &
y,
double &
z)
const 1660 (
double const worldLoc[3])
const 1759 static bool Loaded=
false;
1760 static std::vector<unsigned int> LowestID;
1761 static unsigned int NCryo;
1763 if(Loaded ==
false){
1769 LowestID.resize(NCryo + 1);
1771 for(
size_t cryo=0; cryo!=NCryo; ++cryo){
1777 if( (c < NCryo) && (o <
Cryostat(c).NOpDet())){
1778 return LowestID.at(c)+o;
1781 throw cet::exception(
"OpDetCryoToOpID Error") <<
"Coordinates c=" << c
1783 <<
" out of range. Abort\n";
1801 static bool Loaded=
false;
1802 static std::vector<unsigned int> LowestID;
1803 static size_t NCryo;
1805 if(Loaded ==
false){
1811 LowestID.resize(NCryo + 1);
1813 for(
size_t cryo = 0; cryo != NCryo; ++cryo){
1819 for(
size_t i=0; i!=NCryo; ++i){
1820 if( (OpDet >= LowestID[i]) && (OpDet < LowestID[i+1]) ){
1822 int o = OpDet-LowestID[i];
1827 throw cet::exception(
"OpID To OpDetCryo error")<<
"OpID out of range, "<< OpDet <<
"\n";
1857 <<
"Comparing two wires on different TPCs: return failure.";
1862 <<
"Comparing two wires in the same plane: return failure";
1867 <<
"1st wire " << wid1 <<
" does not exist (max wire number: " 1873 <<
"2nd wire " << wid2 <<
" does not exist (max wire number: " 1883 double A_start_x,
double A_start_y,
double A_end_x,
double A_end_y,
1884 double B_start_x,
double B_start_y,
double B_end_x,
double B_end_y,
1908 if (current_path.empty())
return *
this;
1909 if (current_path.size() == 1) { current_path.pop_back();
return *
this; }
1914 NodeInfo_t const& parent = current_path[current_path.size() - 2];
1915 if (++(current.
sibling) < parent.
self->GetNdaughters()) {
1918 reach_deepest_descendant();
1920 else current_path.pop_back();
1928 std::vector<TGeoNode const*> node_path(current_path.size());
1930 std::transform(current_path.begin(), current_path.end(), node_path.begin(),
1931 [](
NodeInfo_t const& node_info){
return node_info.self; });
1939 Node_t descendent = current_path.back().self;
1940 while (descendent->GetNdaughters() > 0) {
1941 descendent = descendent->GetDaughter(0);
1942 current_path.emplace_back(descendent, 0U);
1948 current_path.clear();
1949 if (!start_node)
return;
1950 current_path.emplace_back(start_node, 0U);
1951 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.
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.
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
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 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.
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.
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...
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.
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.
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.
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