LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
GeometryCore.h
Go to the documentation of this file.
1 
19 #ifndef LARCOREALG_GEOMETRY_GEOMETRYCORE_H
20 #define LARCOREALG_GEOMETRY_GEOMETRYCORE_H
21 
22 // LArSoft libraries
32 #include "larcorealg/Geometry/GeometryDataContainers.h" // geo::TPCDataContainer
35 #include "larcorealg/Geometry/ReadoutDataContainers.h" // readout::ROPDataContainer
41 #include "larcorealg/Geometry/geo_vectors_utils.h" // geo::vect namespace
42 #include "larcoreobj/SimpleTypesAndConstants/RawTypes.h" // raw::ChannelID_t
46 
47 // Framework and infrastructure libraries
48 #include "fhiclcpp/ParameterSet.h"
49 
50 // C/C++ standard libraries
51 #include <cstddef> // size_t
52 #include <iterator> // std::forward_iterator_tag
53 #include <memory> // std::shared_ptr<>
54 #include <set>
55 #include <string>
56 #include <type_traits> // std::is_base_of<>
57 #include <utility>
58 #include <vector>
59 
60 // ROOT class prototypes
61 class TGeoManager;
62 class TGeoNode;
63 class TGeoVolume;
64 class TGeoMaterial;
65 
67 namespace geo {
68 
69  // BEGIN Geometry group ------------------------------------------------------
72 
73  //
74  // GeometryCore
75  //
76 
119  class GeometryCore {
120  public:
122  template <typename Point>
123  struct Segment : public std::pair<Point, Point> {
124 
125  // use the base class constructors
126  using std::pair<Point, Point>::pair;
127 
128  Point const& start() const { return this->first; }
129  Point& start() { return this->first; }
130 
131  Point const& end() const { return this->second; }
132  Point& end() { return this->second; }
133 
134  }; // struct Segment_t
135 
137 
142 
145  static constexpr std::size_t MaxWireDepthInGDML = 20U;
146 
154  explicit GeometryCore(fhicl::ParameterSet const& pset);
155 
156  // this object is not copiable nor moveable (see also issue #14384);
157  // currently, auxiliary detectors are stored as bare pointers,
158  // which prevents trivial copy or move.
159  GeometryCore(GeometryCore const&) = delete;
160  GeometryCore(GeometryCore&&) = delete;
161  GeometryCore& operator=(GeometryCore const&) = delete;
162  GeometryCore& operator=(GeometryCore&&) = delete;
163 
175  double DefaultWiggle() const { return fPositionWiggle; }
176 
184  std::string const& ROOTFile() const { return fROOTfile; }
185 
193  std::string const& GDMLFile() const { return fGDMLfile; }
194 
195  // BEGIN Detector information
198 
199  //
200  // global features
201  //
203  std::string const& DetectorName() const { return fDetectorName; }
204 
205  //
206  // position
207  //
208 
210  TGeoVolume const* WorldVolume() const;
211 
230  void WorldBox(double* xlo, double* xhi, double* ylo, double* yhi, double* zlo, double* zhi)
231  const;
232 
235  BoxBoundedGeo WorldBox() const;
236 
250  //
251  Length_t SurfaceY() const { return fSurfaceY; }
252 
253  //
254  // object description and information
255  //
256 
258  TGeoManager* ROOTGeoManager() const;
259 
261  const std::string GetWorldVolumeName() const;
262 
266  BoxBoundedGeo DetectorEnclosureBox(std::string const& name = "volDetEnclosure") const;
267 
269 
277  std::string VolumeName(Point_t const& point) const;
279 
289  std::vector<TGeoNode const*> FindAllVolumes(std::set<std::string> const& vol_names) const;
290 
304  std::vector<std::vector<TGeoNode const*>> FindAllVolumePaths(
305  std::set<std::string> const& vol_names) const;
306 
308  TGeoMaterial const* Material(Point_t const& point) const;
310 
314  std::string MaterialName(Point_t const& point) const;
316 
318  double TotalMass() const { return TotalMass(GetWorldVolumeName()); }
320  double TotalMass(std::string vol) const;
322 
324 
337  double MassBetweenPoints(Point_t const& p1, Point_t const& p2) const;
339 
341  template <typename Stream>
342  void Print(Stream&& out, std::string indent = " ") const;
343 
346  std::string Info(std::string indent = " ") const;
347 
349  // END Detector information
350 
356  template <typename GeoID>
357  GeoID GetBeginID() const
358  {
359  GeoID id;
360  GetBeginID(id);
361  return id;
362  }
363 
370  template <typename GeoID>
371  GeoID GetNextID(GeoID const& id) const
372  {
373  auto nextID(id);
374  IncrementID(nextID);
375  return nextID;
376  }
377 
384  template <typename GeoID>
385  GeoID GetEndID() const
386  {
387  GeoID id;
388  GetEndID(id);
389  return id;
390  }
391 
399  template <typename GeoID, typename ContextID>
400  GeoID GetBeginID(ContextID const& id) const;
401 
411  template <typename GeoID, typename ContextID>
412  GeoID GetEndID(ContextID const& id) const;
413 
416 
417  //
418  // group features
419  //
420 
422 
430  unsigned int Ncryostats() const { return Cryostats().size(); }
431  unsigned int NElements() const { return Ncryostats(); }
432  unsigned int NSiblingElements(CryostatID const&) const { return Ncryostats(); }
434 
435  //
436  // access
437  //
438 
440 
446  bool HasCryostat(CryostatID const& cryoid) const { return cryoid.Cryostat < Ncryostats(); }
447  bool HasElement(CryostatID const& cryoid) const { return HasCryostat(cryoid); }
449 
451 
463  static constexpr CryostatID cryostat_zero{0};
464  CryostatGeo const& Cryostat(CryostatID const& cryoid = cryostat_zero) const;
465  CryostatGeo const& GetElement(CryostatID const& cryoid) const { return Cryostat(cryoid); }
467 
469 
477  CryostatGeo const* CryostatPtr(CryostatID const& cryoid) const
478  {
479  return HasCryostat(cryoid) ? &(Cryostats()[cryoid.Cryostat]) : nullptr;
480  }
481  CryostatGeo const* GetElementPtr(CryostatID const& cryoid) const { return CryostatPtr(cryoid); }
483 
491  CryostatGeo const* PositionToCryostatPtr(Point_t const& point) const;
492 
500  CryostatID PositionToCryostatID(Point_t const& point) const;
501 
503 
511  CryostatGeo const& PositionToCryostat(Point_t const& point) const;
512 
513  //
514  // iterators
515  //
516 
518  void GetBeginID(CryostatID& id) const { id = CryostatID(0, HasCryostat(CryostatID(0))); }
519 
521  void GetEndID(CryostatID& id) const { id = CryostatID(Ncryostats(), false); }
522 
525  bool IncrementID(CryostatID& id) const; // inline implementation
526 
527  // FIXME: Need Doxygen comments
528  template <typename T>
530  {
532  }
533 
534  template <typename T>
536  {
538  }
539 
540  template <typename T>
542  {
544  }
545 
546  template <typename T, typename BaseID>
547  details::begin_type<T> begin(BaseID const& id) const
548  {
550  }
551 
552  template <typename T, typename BaseID>
553  details::end_type<T> end(BaseID const& id) const
554  {
555  return details::IteratorMaker<T>::create_end(this, id);
556  }
557 
558  template <typename T, typename ID>
559  details::range_type<T> Iterate(ID const& id) const
560  {
562  }
563 
564  //
565  // single object features
566  //
567 
572 
577 
579  Length_t CryostatLength(CryostatID const& cid = cryostat_zero) const;
582 
583  //
584  // object description
585  //
586 
588 
598  std::string GetCryostatVolumeName(CryostatID const& cid) const;
600 
602 
605 
606  //
607  // group features
608  //
609 
611  unsigned int MaxTPCs() const;
612 
614  unsigned int TotalNTPC() const;
615 
644  template <typename T>
646  {
647  return {Ncryostats(), MaxTPCs()};
648  }
649 
669  template <typename T>
670  TPCDataContainer<T> makeTPCData(T const& defValue) const
671  {
672  return {Ncryostats(), MaxTPCs(), defValue};
673  }
674 
676 
686  unsigned int NTPC(CryostatID const& cryoid = cryostat_zero) const
687  {
688  CryostatGeo const* pCryo = GetElementPtr(cryoid);
689  return pCryo ? pCryo->NElements() : 0;
690  }
691  unsigned int NElements(CryostatID const& cryoid) const { return NTPC(cryoid); }
692  unsigned int NSiblingElements(TPCID const& tpcid) const { return NTPC(tpcid); }
694 
695  //
696  // access
697  //
699  bool HasTPC(TPCID const& tpcid) const
700  {
701  CryostatGeo const* pCryo = CryostatPtr(tpcid);
702  return pCryo ? pCryo->HasTPC(tpcid) : false;
703  }
704 
706  bool HasElement(TPCID const& tpcid) const { return HasTPC(tpcid); }
707 
709 
721  static constexpr TPCID tpc_zero{cryostat_zero, 0};
722  TPCGeo const& TPC(TPCID const& tpcid = tpc_zero) const { return Cryostat(tpcid).TPC(tpcid); }
723  TPCGeo const& GetElement(TPCID const& tpcid) const { return TPC(tpcid); }
725 
727 
735  TPCGeo const* TPCPtr(TPCID const& tpcid) const
736  {
737  CryostatGeo const* pCryo = CryostatPtr(tpcid);
738  return pCryo ? pCryo->TPCPtr(tpcid) : nullptr;
739  }
740  TPCGeo const* GetElementPtr(TPCID const& tpcid) const { return TPCPtr(tpcid); }
742 
744 
749  TPCID FindTPCAtPosition(Point_t const& point) const;
751 
757  TPCGeo const* PositionToTPCptr(Point_t const& point) const;
758 
760 
766  TPCGeo const& PositionToTPC(Point_t const& point) const;
768 
775  TPCID PositionToTPCID(Point_t const& point) const;
776 
780 
782  void GetBeginID(TPCID& id) const
783  {
784  GetBeginID(id.asCryostatID());
785  id.TPC = 0;
786  }
787 
789  void GetEndID(TPCID& id) const;
790 
793  bool IncrementID(TPCID& id) const; // inline implementation
794 
796  TPCID GetBeginTPCID(CryostatID const& id) const { return {id, 0}; }
797 
800  TPCID GetEndTPCID(CryostatID const& id) const;
801 
802  //
803  // single object features
804  //
805 
807 
820  Length_t DetHalfWidth(TPCID const& tpcid = tpc_zero) const;
822 
824 
839  Length_t DetHalfHeight(TPCID const& tpcid = tpc_zero) const;
841 
843 
858  Length_t DetLength(TPCID const& tpcid = tpc_zero) const;
860 
862 
872  Point_t GetTPCFrontFaceCenter(TPCID const& tpcid) const
873  {
874  return TPC(tpcid).GetFrontFaceCenter();
875  }
877 
878  //
879  // object description
880  //
881 
883 
894  std::string GetLArTPCVolumeName(TPCID const& tpcid = tpc_zero) const;
896 
898 
901 
902  //
903  // group features
904  //
905 
907  unsigned int MaxPlanes() const;
908 
936  template <typename T>
938  {
939  return {Ncryostats(), MaxTPCs(), MaxPlanes()};
940  }
941 
960  template <typename T>
961  PlaneDataContainer<T> makePlaneData(T const& defValue) const
962  {
963  return {Ncryostats(), MaxTPCs(), MaxPlanes(), defValue};
964  }
965 
967 
977  unsigned int Nplanes(TPCID const& tpcid = tpc_zero) const
978  {
979  TPCGeo const* pTPC = GetElementPtr(tpcid);
980  return pTPC ? pTPC->NElements() : 0;
981  }
982  unsigned int NElements(TPCID const& tpcid) const { return Nplanes(tpcid); }
983  unsigned int NSiblingElements(PlaneID const& planeid) const { return Nplanes(planeid); }
985 
997  unsigned int Nviews() const;
998 
999  //
1000  // access
1001  //
1002 
1004 
1011  bool HasPlane(PlaneID const& planeid) const
1012  {
1013  TPCGeo const* pTPC = TPCPtr(planeid);
1014  return pTPC ? pTPC->HasPlane(planeid) : false;
1015  }
1016  bool HasElement(PlaneID const& planeid) const { return HasPlane(planeid); }
1018 
1020 
1034  PlaneGeo const& Plane(PlaneID const& planeid) const { return TPC(planeid).Plane(planeid); }
1035  PlaneGeo const& GetElement(PlaneID const& planeid) const { return Plane(planeid); }
1037 
1039 
1047  PlaneGeo const* PlanePtr(PlaneID const& planeid) const
1048  {
1049  TPCGeo const* pTPC = TPCPtr(planeid);
1050  return pTPC ? pTPC->PlanePtr(planeid) : nullptr;
1051  }
1052  PlaneGeo const* GetElementPtr(PlaneID const& planeid) const { return PlanePtr(planeid); }
1054 
1055  //
1056  // iterators
1057  //
1058 
1060  void GetBeginID(PlaneID& id) const
1061  {
1062  GetBeginID(id.asTPCID());
1063  id.Plane = 0;
1064  }
1065 
1067  void GetEndID(PlaneID& id) const;
1068 
1071  bool IncrementID(PlaneID& id) const; // inline implementation
1072 
1074  PlaneID GetBeginPlaneID(CryostatID const& id) const { return {GetBeginTPCID(id), 0}; }
1075 
1078  PlaneID GetEndPlaneID(CryostatID const& id) const;
1079 
1081  PlaneID GetBeginPlaneID(TPCID const& id) const { return {id, 0}; }
1082 
1085  PlaneID GetEndPlaneID(TPCID const& id) const;
1086 
1087  //
1088  // single object features
1089  //
1090 
1092 
1107  Length_t PlanePitch(TPCID const& tpcid,
1108  PlaneID::PlaneID_t p1 = 0,
1109  PlaneID::PlaneID_t p2 = 1) const;
1110  Length_t PlanePitch(PlaneID const& pid1, PlaneID const& pid2) const;
1112 
1118  View_t View(PlaneID const& pid) const;
1119 
1129  SigType_t SignalType(PlaneID const& pid) const;
1130 
1132 
1135 
1136  //
1137  // group features
1138  //
1139 
1141 
1151  unsigned int Nwires(PlaneID const& planeid) const
1152  {
1153  PlaneGeo const* pPlane = GetElementPtr(planeid);
1154  return pPlane ? pPlane->NElements() : 0;
1155  }
1156  unsigned int NElements(PlaneID const& planeid) const { return Nwires(planeid); }
1157  unsigned int NSiblingElements(WireID const& wireid) const { return Nwires(wireid); }
1158 
1160  unsigned int MaxWires() const;
1161 
1163 
1164  //
1165  // access
1166  //
1167 
1169 
1175  bool HasWire(WireID const& wireid) const
1176  {
1177  PlaneGeo const* pPlane = PlanePtr(wireid);
1178  return pPlane ? pPlane->HasWire(wireid) : false;
1179  }
1180  bool HasElement(WireID const& wireid) const { return HasWire(wireid); }
1182 
1184 
1192  WireGeo const* WirePtr(WireID const& wireid) const
1193  {
1194  PlaneGeo const* pPlane = PlanePtr(wireid);
1195  return pPlane ? pPlane->WirePtr(wireid) : nullptr;
1196  } // WirePtr()
1197  WireGeo const* GetElementPtr(WireID const& wireid) const { return WirePtr(wireid); }
1199 
1201 
1210  WireGeo const& Wire(WireID const& wireid) const { return Plane(wireid).Wire(wireid); }
1211  WireGeo const& WireIDToWireGeo(WireID const& wireid) const { return Wire(wireid); }
1212  WireGeo const& GetElement(WireID const& wireid) const { return Wire(wireid); }
1214 
1215  //
1216  // iterators
1217  //
1218 
1220  void GetBeginID(WireID& id) const
1221  {
1222  GetBeginID(id.asPlaneID());
1223  id.Wire = 0;
1224  }
1225 
1227  void GetEndID(WireID& id) const;
1228 
1231  bool IncrementID(WireID& id) const; // inline implementation
1232 
1234  WireID GetBeginWireID(CryostatID const& id) const { return {GetBeginPlaneID(id), 0}; }
1235 
1238  WireID GetEndWireID(CryostatID const& id) const;
1239 
1241  WireID GetBeginWireID(TPCID const& id) const { return {PlaneID(id, 0), 0}; }
1242 
1245  WireID GetEndWireID(TPCID const& id) const;
1246 
1248  WireID GetBeginWireID(PlaneID const& id) const { return {id, 0}; }
1249 
1252  WireID GetEndWireID(PlaneID const& id) const;
1253 
1254  //
1255  // single object features
1256  //
1257 
1259 
1275  static constexpr PlaneID plane_zero{tpc_zero, 0};
1276  Length_t WirePitch(PlaneID const& planeid = plane_zero) const;
1278 
1291  Length_t WirePitch(View_t view) const;
1292 
1294 
1310  double WireAngleToVertical(View_t view, TPCID const& tpcid) const;
1312 
1314 
1325 
1327  //
1328  // simple geometry queries
1329  //
1330 
1343  void WireEndPoints(WireID const& wireid, double* xyzStart, double* xyzEnd) const;
1344 
1346 
1358  Segment<Point_t> WireEndPoints(WireID const& wireID) const;
1359 
1361 
1362  //
1363  // closest wire
1364  //
1365 
1404  WireID NearestWireID(Point_t const& point, PlaneID const& planeid) const;
1405 
1407 
1418  Length_t WireCoordinate(Point_t const& pos, PlaneID const& planeid) const;
1420 
1421  //
1422  // wire intersections
1423  //
1424 
1426 
1461  bool WireIDsIntersect(WireID const& wid1, WireID const& wid2, Point_t& intersection) const;
1463 
1465 
1487  bool WireIDsIntersect(WireID const& wid1,
1488  WireID const& wid2,
1489  WireIDIntersection& widIntersect) const;
1491 
1509  bool IntersectionPoint(WireID const& wid1, WireID const& wid2, double& y, double& z) const;
1510 
1522  PlaneID ThirdPlane(PlaneID const& pid1, PlaneID const& pid2) const;
1523 
1542  double ThirdPlaneSlope(PlaneID const& pid1,
1543  double slope1,
1544  PlaneID const& pid2,
1545  double slope2,
1546  PlaneID const& output_plane) const;
1547 
1565  double ThirdPlaneSlope(PlaneID const& pid1,
1566  double slope1,
1567  PlaneID const& pid2,
1568  double slope2) const;
1569 
1571 
1587  double slope1,
1588  PlaneID::PlaneID_t plane2,
1589  double slope2,
1590  TPCID const& tpcid) const
1591  {
1592  return ThirdPlaneSlope(PlaneID(tpcid, plane1), slope1, PlaneID(tpcid, plane2), slope2);
1593  }
1595 
1612  double ThirdPlane_dTdW(PlaneID const& pid1,
1613  double slope1,
1614  PlaneID const& pid2,
1615  double slope2,
1616  PlaneID const& output_plane) const;
1617 
1635  double ThirdPlane_dTdW(PlaneID const& pid1,
1636  double slope1,
1637  PlaneID const& pid2,
1638  double slope2) const;
1639 
1651  static double ComputeThirdPlaneSlope(double angle1,
1652  double slope1,
1653  double angle2,
1654  double slope2,
1655  double angle_target);
1656 
1673  static double ComputeThirdPlane_dTdW(double angle1,
1674  double pitch1,
1675  double dTdW1,
1676  double angle2,
1677  double pitch2,
1678  double dTdW2,
1679  double angle_target,
1680  double pitch_target);
1681 
1683 
1701 
1703  //
1704  // group features
1705  //
1706 
1708  unsigned int NOpDets() const;
1709 
1710  //
1711  // access
1712  //
1718  OpDetGeo const& OpDetGeoFromOpChannel(unsigned int OpChannel) const;
1719 
1725  OpDetGeo const& OpDetGeoFromOpDet(unsigned int OpDet) const;
1726 
1728 
1739  unsigned int GetClosestOpDet(Point_t const& point) const;
1741 
1742  //
1743  // object description
1744  //
1745 
1754  std::string OpDetGeoName(CryostatID const& cid = cryostat_zero) const;
1755 
1757 
1760 
1762 
1763  //
1764  // group features
1765  //
1766 
1775  unsigned int NAuxDets() const { return AuxDets().size(); }
1776 
1783  unsigned int NAuxDetSensitive(size_t const& aid) const;
1784 
1785  //
1786  // access
1787  //
1788 
1797  AuxDetGeo const& AuxDet(unsigned int const ad = 0) const;
1798 
1808  unsigned int FindAuxDetAtPosition(Point_t const& point, double tolerance = 0) const;
1809 
1817  void FindAuxDetSensitiveAtPosition(Point_t const& point,
1818  std::size_t& adg,
1819  std::size_t& sv,
1820  double tolerance = 0) const;
1821 
1831  AuxDetGeo const& PositionToAuxDet(Point_t const& point,
1832  unsigned int& ad,
1833  double tolerance = 0) const;
1834 
1846  size_t& ad,
1847  size_t& sv,
1848  double tolerance = 0) const;
1849 
1850  const AuxDetGeo& ChannelToAuxDet(
1851  std::string const& auxDetName,
1852  uint32_t const& channel) const; // return the AuxDetGeo for the given detector
1853  // name and channel
1854 
1856  std::string const& auxDetName,
1857  uint32_t const& channel) const; // return the AuxDetSensitiveGeo for the given
1858 
1860 
1863 
1864  //
1865  // group features
1866  //
1867 
1869  unsigned int Nchannels() const;
1870 
1873  unsigned int Nchannels(readout::ROPID const& ropid) const;
1874 
1876  std::vector<raw::ChannelID_t> ChannelsInTPCs() const;
1877  //
1882  std::set<View_t> const& Views() const { return allViews; }
1883 
1884  //
1885  // access
1886  //
1887 
1896  bool HasChannel(raw::ChannelID_t channel) const;
1897 
1899 
1910  raw::ChannelID_t PlaneWireToChannel(WireID const& wireid) const;
1912 
1913  //
1914  // single object features
1915  //
1916 
1924  SigType_t SignalType(raw::ChannelID_t const channel) const;
1925 
1934  View_t View(raw::ChannelID_t const channel) const;
1935 
1942  std::vector<WireID> ChannelToWire(raw::ChannelID_t const channel) const;
1943 
1947 
1948  //
1949  // geometry queries
1950  //
1951 
1960  raw::ChannelID_t NearestChannel(Point_t const& worldLoc, PlaneID const& planeid) const;
1961 
1975  bool ChannelsIntersect(raw::ChannelID_t c1, raw::ChannelID_t c2, double& y, double& z) const;
1976 
1978 
1981 
1982  //
1983  // group features
1984  //
1985 
1987 
1995  unsigned int NTPCsets(geo::CryostatID const& cryoid) const;
1996  unsigned int NSiblingElements(readout::TPCsetID const& tpcsetid) const
1997  {
1998  return NTPCsets(tpcsetid);
1999  }
2001 
2003  unsigned int MaxTPCsets() const;
2004 
2025  template <typename T>
2027  {
2028  return {Ncryostats(), MaxTPCsets()};
2029  }
2030 
2045  template <typename T>
2047  {
2048  return {Ncryostats(), MaxTPCsets(), defValue};
2049  }
2050 
2051  //
2052  // access
2053  //
2056  bool HasTPCset(readout::TPCsetID const& tpcsetid) const;
2057 
2059  bool HasElement(readout::TPCsetID const& tpcsetid) const { return HasTPCset(tpcsetid); }
2060 
2066  readout::TPCsetID FindTPCsetAtPosition(Point_t const& worldLoc) const;
2067 
2068  //
2069  // mapping
2070  //
2072  readout::TPCsetID TPCtoTPCset(TPCID const& tpcid) const;
2073 
2084  std::vector<TPCID> TPCsetToTPCs(readout::TPCsetID const& tpcsetid) const;
2085 
2089 
2092  {
2093  GetBeginID(id.asCryostatID());
2094  id.TPCset = 0;
2095  }
2096 
2098  void GetEndID(readout::TPCsetID& id) const
2099  {
2100  GetEndID(id.asCryostatID());
2101  id.TPCset = 0;
2102  }
2103 
2106  bool IncrementID(readout::TPCsetID& id) const; // inline implementation
2107 
2109  readout::TPCsetID GetBeginTPCsetID(CryostatID const& id) const { return {id, 0}; }
2110 
2113  readout::TPCsetID GetEndTPCsetID(CryostatID const& id) const { return {id.Cryostat + 1, 0}; }
2114 
2116 
2119 
2120  //
2121  // group features
2122  //
2123 
2125 
2135  unsigned int NROPs(readout::TPCsetID const& tpcsetid) const;
2136  unsigned int NSiblingElements(readout::ROPID const& ropid) const { return NROPs(ropid); }
2138 
2140  unsigned int MaxROPs() const;
2141 
2163  template <typename T>
2165  {
2166  return {Ncryostats(), MaxTPCsets(), MaxROPs()};
2167  }
2168 
2183  template <typename T>
2185  {
2186  return {Ncryostats(), MaxTPCsets(), MaxROPs(), defValue};
2187  }
2188 
2189  //
2190  // access
2191  //
2194  bool HasROP(readout::ROPID const& ropid) const;
2195 
2198  bool HasElement(readout::ROPID const& ropid) const { return HasROP(ropid); }
2199 
2200  //
2201  // mapping
2202  //
2213  readout::ROPID WirePlaneToROP(PlaneID const& planeid) const;
2214 
2225  std::vector<PlaneID> ROPtoWirePlanes(readout::ROPID const& ropid) const;
2226 
2237  std::vector<TPCID> ROPtoTPCs(readout::ROPID const& ropid) const;
2238 
2250 
2254 
2256  void GetBeginID(readout::ROPID& id) const
2257  {
2258  GetBeginID(id.asTPCsetID());
2259  id.ROP = 0;
2260  }
2261 
2263  void GetEndID(readout::ROPID& id) const
2264  {
2265  GetEndID(id.asTPCsetID());
2266  id.ROP = 0;
2267  }
2268 
2271  bool IncrementID(readout::ROPID& id) const; // inline implementation
2272 
2274  readout::ROPID GetBeginROPID(CryostatID const& id) const { return {GetBeginTPCsetID(id), 0}; }
2275 
2278  readout::ROPID GetEndROPID(CryostatID const& id) const { return {GetEndTPCsetID(id), 0}; }
2279 
2281  readout::ROPID GetBeginROPID(readout::TPCsetID const& id) const { return {id, 0}; }
2282 
2285  readout::ROPID GetEndROPID(readout::TPCsetID const& id) const { return {GetNextID(id), 0}; }
2286 
2299  View_t View(readout::ROPID const& ropid) const;
2300 
2313  SigType_t SignalType(readout::ROPID const& ropid) const;
2314 
2316 
2322 
2325  //
2326  // group features
2327  //
2328 
2330  unsigned int NOpChannels() const;
2331 
2333  unsigned int MaxOpChannel() const;
2334 
2335  // Number of hardware channels for a given optical detector
2336  unsigned int NOpHardwareChannels(int opDet) const;
2337 
2338  //
2339  // access
2340  //
2341 
2343  bool IsValidOpChannel(int opChannel) const;
2344 
2346  unsigned int OpChannel(int detNum, int hardwareChannel) const;
2347 
2349  unsigned int OpDetFromOpChannel(int opChannel) const;
2350 
2352  unsigned int HardwareChannelFromOpChannel(int opChannel) const;
2353 
2355  unsigned int OpDetFromCryo(unsigned int o, unsigned int c) const;
2356 
2358 
2359  //
2360  // unsorted methods
2361  //
2362 
2365 
2390  void LoadGeometryFile(std::string gdmlfile,
2391  std::string rootfile,
2392  GeometryBuilder& builder,
2393  bool bForceReload = false);
2394 
2406  void LoadGeometryFile(std::string gdmlfile, std::string rootfile, bool bForceReload = false);
2407 
2419  void ApplyChannelMap(std::unique_ptr<ChannelMapAlg> pChannelMap);
2421 
2422  private:
2425  CryostatList_t const& Cryostats() const { return fGeoData.cryostats; }
2426 
2429  AuxDetList_t const& AuxDets() const { return fGeoData.auxDets; }
2430 
2432 
2433  double fSurfaceY;
2434  std::string fDetectorName;
2435  std::string fGDMLfile;
2436  std::string fROOTfile;
2437  double fMinWireZDist;
2438  double fPositionWiggle;
2440 
2444  std::unique_ptr<const ChannelMapAlg> fChannelMapAlg;
2446 
2447  // cached values
2448  std::set<View_t> allViews;
2449 
2450  std::vector<TGeoNode const*> FindDetectorEnclosure(
2451  std::string const& name = "volDetEnclosure") const;
2452 
2453  bool FindFirstVolume(std::string const& name, std::vector<const TGeoNode*>& path) const;
2454 
2457  void BuildGeometry(GeometryBuilder& builder);
2458 
2460  bool WireIDIntersectionCheck(const WireID& wid1, const WireID& wid2) const;
2461 
2463  void SortGeometry(GeoObjectSorter const& sorter);
2464 
2466  void UpdateAfterSorting();
2467 
2469  void ClearGeometry();
2470 
2471  }; // class GeometryCore
2472 
2474  // END Geometry group --------------------------------------------------------
2475 
2476 } // namespace geo
2477 
2478 //******************************************************************************
2479 //*** inline implementation
2480 //***
2482 {
2483  ++id.Cryostat;
2484  if (id) id.isValid = HasCryostat(id); // if invalid already, it stays so
2485  return bool(id);
2486 }
2487 
2489 {
2490  unsigned int const nTPCsInCryo = NTPC(id);
2491  if (++id.TPC < nTPCsInCryo) return bool(id); // if was invalid, it stays so
2492  // no more TPCs in this cryostat
2493  id.TPC = 0;
2494  return IncrementID(id.asCryostatID()); // also sets validity
2495 }
2496 
2498 {
2499  // this implementation is non-optimal, in that the cryostat lookup is
2500  // performed both here and, potentially, in IncrementID(TPCID)
2501  unsigned int const nPlanesInTPC = Nplanes(id);
2502  if (++id.Plane < nPlanesInTPC) return bool(id); // if was invalid, stays so
2503  // no more planes in this TPCs
2504  id.Plane = 0;
2505  return IncrementID(id.asTPCID()); // also sets validity
2506 }
2507 
2509 {
2510  // this implementation is non-optimal, in that the TPC lookup is
2511  // performed both here and, potentially, in IncrementID(PlaneID)
2512  unsigned int const nWiresInPlane = Nwires(id);
2513  if (++id.Wire < nWiresInPlane) return bool(id); // if was invalid, stays so
2514  // no more wires in this plane
2515  id.Wire = 0;
2516  return IncrementID(id.asPlaneID()); // also sets validity
2517 }
2518 
2520 {
2521  unsigned int const nTPCsetsInCryo = NTPCsets(id);
2522  if (++id.TPCset < nTPCsetsInCryo) return bool(id); // if was invalid, it stays so
2523  // no more TPC sets in this cryostat
2524  id.TPCset = 0;
2525  return IncrementID(id.asCryostatID()); // also sets validity
2526 }
2527 
2529 {
2530  // this implementation is non-optimal, in that the cryostat lookup is
2531  // performed both here and, potentially, in IncrementID(TPCsetID)
2532  unsigned int const nROPinTPC = NROPs(id);
2533  if (++id.ROP < nROPinTPC) return bool(id); // if was invalid, stays so
2534  // no more readout planes in this TPC set
2535  id.ROP = 0;
2536  return IncrementID(id.asTPCsetID()); // also sets validity
2537 }
2538 
2539 //******************************************************************************
2540 //*** template implementation
2541 //***
2542 //------------------------------------------------------------------------------
2543 //------------------------------------------------------------------------------
2544 // template member function specializations
2545 namespace geo {
2546 
2547  // TPCID
2548  template <>
2549  inline TPCID GeometryCore::GetBeginID<TPCID, CryostatID>(CryostatID const& id) const
2550  {
2551  return GetBeginTPCID(id);
2552  }
2553 
2554  template <>
2555  inline TPCID GeometryCore::GetEndID<TPCID, CryostatID>(CryostatID const& id) const
2556  {
2557  return GetEndTPCID(id);
2558  }
2559 
2560  // PlaneID
2561  template <>
2562  inline PlaneID GeometryCore::GetBeginID<PlaneID, CryostatID>(CryostatID const& id) const
2563  {
2564  return GetBeginPlaneID(id);
2565  }
2566 
2567  template <>
2568  inline PlaneID GeometryCore::GetBeginID<PlaneID, TPCID>(TPCID const& id) const
2569  {
2570  return GetBeginPlaneID(id);
2571  }
2572 
2573  template <>
2574  inline PlaneID GeometryCore::GetEndID<PlaneID, CryostatID>(CryostatID const& id) const
2575  {
2576  return GetEndPlaneID(id);
2577  }
2578 
2579  template <>
2580  inline PlaneID GeometryCore::GetEndID<PlaneID, TPCID>(TPCID const& id) const
2581  {
2582  return GetEndPlaneID(id);
2583  }
2584 
2585  // WireID
2586  template <>
2587  inline WireID GeometryCore::GetBeginID<WireID, CryostatID>(CryostatID const& id) const
2588  {
2589  return GetBeginWireID(id);
2590  }
2591 
2592  template <>
2593  inline WireID GeometryCore::GetBeginID<WireID, TPCID>(TPCID const& id) const
2594  {
2595  return GetBeginWireID(id);
2596  }
2597 
2598  template <>
2599  inline WireID GeometryCore::GetBeginID<WireID, PlaneID>(PlaneID const& id) const
2600  {
2601  return GetBeginWireID(id);
2602  }
2603 
2604  template <>
2605  inline WireID GeometryCore::GetEndID<WireID, CryostatID>(CryostatID const& id) const
2606  {
2607  return GetEndWireID(id);
2608  }
2609 
2610  template <>
2611  inline WireID GeometryCore::GetEndID<WireID, TPCID>(TPCID const& id) const
2612  {
2613  return GetEndWireID(id);
2614  }
2615 
2616  template <>
2617  inline WireID GeometryCore::GetEndID<WireID, PlaneID>(PlaneID const& id) const
2618  {
2619  return GetEndWireID(id);
2620  }
2621 
2622  // TPCsetID
2623  template <>
2624  inline readout::TPCsetID GeometryCore::GetBeginID<readout::TPCsetID, CryostatID>(
2625  CryostatID const& id) const
2626  {
2627  return GetBeginTPCsetID(id);
2628  }
2629 
2630  template <>
2631  inline readout::TPCsetID GeometryCore::GetEndID<readout::TPCsetID, CryostatID>(
2632  CryostatID const& id) const
2633  {
2634  return GetEndTPCsetID(id);
2635  }
2636 
2637  // ROPID
2638  template <>
2639  inline readout::ROPID GeometryCore::GetBeginID<readout::ROPID, CryostatID>(
2640  CryostatID const& id) const
2641  {
2642  return GetBeginROPID(id);
2643  }
2644 
2645  template <>
2646  inline readout::ROPID GeometryCore::GetEndID<readout::ROPID, CryostatID>(
2647  CryostatID const& id) const
2648  {
2649  return GetEndROPID(id);
2650  }
2651 
2652  template <>
2653  inline readout::ROPID GeometryCore::GetBeginID<readout::ROPID, readout::TPCsetID>(
2654  readout::TPCsetID const& id) const
2655  {
2656  return GetBeginROPID(id);
2657  }
2658 
2659  template <>
2660  inline readout::ROPID GeometryCore::GetEndID<readout::ROPID, readout::TPCsetID>(
2661  readout::TPCsetID const& id) const
2662  {
2663  return GetEndROPID(id);
2664  }
2665 
2666 } // namespace geo
2667 
2669  WireID const& wireid) const
2670 {
2671  WireGeo const& wire = Wire(wireid);
2672  return {wire.GetStart(), wire.GetEnd()};
2673 }
2674 
2675 //------------------------------------------------------------------------------
2676 template <typename Stream>
2677 void geo::GeometryCore::Print(Stream&& out, std::string indent /* = " " */) const
2678 {
2679 
2680  out << "Detector " << DetectorName() << " has " << Ncryostats() << " cryostats and " << NAuxDets()
2681  << " auxiliary detectors:";
2682 
2683  auto const& detEnclosureBox = DetectorEnclosureBox();
2684  out << "\n"
2685  << indent << "Detector enclosure: " << detEnclosureBox.Min() << " -- "
2686  << detEnclosureBox.Max() << " cm => ( " << detEnclosureBox.SizeX() << " x "
2687  << detEnclosureBox.SizeY() << " x " << detEnclosureBox.SizeZ() << " ) cm^3";
2688 
2689  for (auto const& cryostat : Iterate<CryostatGeo>()) {
2690  out << "\n" << indent;
2691  cryostat.PrintCryostatInfo(std::forward<Stream>(out), indent + " ", cryostat.MaxVerbosity);
2692 
2693  const unsigned int nTPCs = cryostat.NTPC();
2694  for (unsigned int t = 0; t < nTPCs; ++t) {
2695  const TPCGeo& tpc = cryostat.TPC(t);
2696 
2697  out << "\n" << indent << " ";
2698  tpc.PrintTPCInfo(std::forward<Stream>(out), indent + " ", tpc.MaxVerbosity);
2699 
2700  const unsigned int nPlanes = tpc.Nplanes();
2701  for (unsigned int p = 0; p < nPlanes; ++p) {
2702  const PlaneGeo& plane = tpc.Plane(p);
2703  const unsigned int nWires = plane.Nwires();
2704 
2705  out << "\n" << indent << " ";
2706  plane.PrintPlaneInfo(std::forward<Stream>(out), indent + " ", plane.MaxVerbosity);
2707  SigType_t const sigType = SignalType(plane.ID());
2708  out << "\n"
2709  << indent << " "
2710  << "signal type: " << SignalTypeName(sigType) << " (" << static_cast<int>(sigType)
2711  << ")";
2712 
2713  for (unsigned int w = 0; w < nWires; ++w) {
2714  const WireGeo& wire = plane.Wire(w);
2715  WireID wireID(plane.ID(), w);
2716 
2717  // the wire should be aligned on z axis, half on each side of 0,
2718  // in its local frame
2719  out << "\n" << indent << " " << wireID << " ";
2720  wire.PrintWireInfo(std::forward<Stream>(out), indent + " ", wire.MaxVerbosity);
2721  } // for wire
2722  } // for plane
2723  } // for TPC
2724 
2725  unsigned int nOpDets = cryostat.NOpDet();
2726  for (unsigned int iOpDet = 0; iOpDet < nOpDets; ++iOpDet) {
2727  OpDetGeo const& opDet = cryostat.OpDet(iOpDet);
2728  out << "\n" << indent << " [OpDet #" << iOpDet << "] ";
2729  opDet.PrintOpDetInfo(std::forward<Stream>(out), indent + " ", opDet.MaxVerbosity);
2730  } // for
2731  } // for cryostat
2732 
2733  unsigned int const nAuxDets = NAuxDets();
2734  for (unsigned int iDet = 0; iDet < nAuxDets; ++iDet) {
2735  AuxDetGeo const& auxDet = AuxDet(iDet);
2736 
2737  out << "\n" << indent << "[#" << iDet << "] ";
2738  auxDet.PrintAuxDetInfo(std::forward<Stream>(out), indent + " ", auxDet.MaxVerbosity);
2739 
2740  unsigned int const nSensitive = auxDet.NSensitiveVolume();
2741  switch (nSensitive) {
2742  case 0: break;
2743  case 1: {
2744  AuxDetSensitiveGeo const& auxDetS = auxDet.SensitiveVolume(0U);
2745  out << "\n" << indent << " ";
2746  auxDetS.PrintAuxDetInfo(std::forward<Stream>(out), indent + " ", auxDetS.MaxVerbosity);
2747  break;
2748  }
2749  default:
2750  for (unsigned int iSens = 0; iSens < nSensitive; ++iSens) {
2751  out << "\n" << indent << "[#" << iSens << "] ";
2752  AuxDetSensitiveGeo const& auxDetS = auxDet.SensitiveVolume(iSens);
2753  auxDetS.PrintAuxDetInfo(std::forward<Stream>(out), indent + " ", auxDetS.MaxVerbosity);
2754  } // for
2755  break;
2756  } // if sensitive detectors
2757 
2758  } // for auxiliary detector
2759 
2760  out << '\n';
2761 
2762 } // geo::GeometryCore::Print()
2763 
2764 #endif // LARCOREALG_GEOMETRY_GEOMETRYCORE_H
unsigned int NAuxDetSensitive(size_t const &aid) const
Returns the number of sensitive components of auxiliary detector.
CryostatGeo const * PositionToCryostatPtr(Point_t const &point) const
Returns the cryostat at specified location.
WireID GetBeginWireID(CryostatID const &id) const
Returns the ID of the first wire in the specified cryostat.
geo::WirePtr WirePtr(unsigned int iwire) const
Returns the wire number iwire from this plane.
Definition: PlaneGeo.h:293
unsigned int NElements() const
Number of wires in this plane.
Definition: PlaneGeo.h:243
details::range_type< T > Iterate() const
Initializes the specified ID with the ID of the first cryostat.
Definition: GeometryCore.h:541
Geometry description of a TPC wireThe wire is a single straight segment on a wire plane...
Definition: WireGeo.h:114
bool HasElement(readout::TPCsetID const &tpcsetid) const
Returns whether we have the specified TPC set.
bool HasElement(PlaneID const &planeid) const
Returns whether we have the specified plane.
GeoID GetEndID() const
Returns the (possibly invalid) ID after the last subelement of the detector.
Definition: GeometryCore.h:385
std::string GetLArTPCVolumeName(TPCID const &tpcid=tpc_zero) const
Return the name of specified LAr TPC volume.
bool HasPlane(unsigned int iplane) const
Returns whether a plane with index iplane is present in this TPC.
Definition: TPCGeo.h:147
readout::TPCsetDataContainer< T > makeTPCsetData(T const &defValue) const
Returns a container with one entry per TPC set.
IDparameter< geo::CryostatID > CryostatID
Member type of validated geo::CryostatID parameter.
void LoadGeometryFile(std::string gdmlfile, std::string rootfile, GeometryBuilder &builder, bool bForceReload=false)
Loads the geometry information from the specified files.
unsigned int NTPC(CryostatID const &cryoid=cryostat_zero) const
Returns the total number of TPCs in the specified cryostat.
Definition: GeometryCore.h:686
Length_t WireCoordinate(Point_t const &pos, PlaneID const &planeid) const
Returns the index of the nearest wire to the specified position.
void PrintWireInfo(Stream &&out, std::string indent="", unsigned int verbosity=1) const
Prints information about this wire.
Definition: WireGeo.h:486
OpDetGeo const & OpDetGeoFromOpDet(unsigned int OpDet) const
Returns the geo::OpDetGeo object for the given detector number.
WireGeo const & WireIDToWireGeo(WireID const &wireid) const
Returns the specified wire.
void PrintTPCInfo(Stream &&out, std::string indent="", unsigned int verbosity=1) const
Prints information about this TPC.
Definition: TPCGeo.h:656
void GetBeginID(CryostatID &id) const
Initializes the specified ID with the ID of the first cryostat.
Definition: GeometryCore.h:518
void SortGeometry(GeoObjectSorter const &sorter)
Runs the sorting of geometry with the sorter provided by channel mapping.
unsigned int TotalNTPC() const
Returns the total number of TPCs in the detector.
GeometryData_t fGeoData
The detector description data.
Container with one element per readout TPC set.
unsigned int NElements(TPCID const &tpcid) const
Returns the largest number of planes among all TPCs in this detector.
Definition: GeometryCore.h:982
std::vector< PlaneID > ROPtoWirePlanes(readout::ROPID const &ropid) const
Returns a list of ID of planes belonging to the specified ROP.
std::vector< WireID > ChannelToWire(raw::ChannelID_t const channel) const
Returns a list of wires connected to the specified TPC channel.
bool HasPlane(PlaneID const &planeid) const
Returns whether we have the specified plane.
Encapsulate the construction of a single cyostat.
double Length_t
Type used for coordinates and distances. They are measured in centimeters.
Definition: geo_vectors.h:133
Encapsulate the geometry of the sensitive portion of an auxiliary detector.
GeoID GetBeginID() const
Returns the ID of the first element of the detector.
Definition: GeometryCore.h:357
bool HasWire(WireID const &wireid) const
Returns whether we have the specified wire.
Classes identifying readout-related concepts.
unsigned int FindAuxDetAtPosition(Point_t const &point, double tolerance=0) const
Returns the index of the auxiliary detector at specified location.
WireGeo const * GetElementPtr(WireID const &wireid) const
Returns the specified wire.
void Print(Stream &&out, std::string indent=" ") const
Prints geometry information with maximum verbosity.
WireGeo const & Wire(unsigned int iwire) const
Definition: PlaneGeo.cxx:465
enum geo::_plane_proj View_t
Enumerate the possible plane projections.
void BuildGeometry(GeometryBuilder &builder)
readout::TPCsetID GetBeginTPCsetID(CryostatID const &id) const
Returns the ID of the first TPC set in the specified cryostat.
AuxDetSensitiveGeo const & SensitiveVolume(size_t sv) const
Definition: AuxDetGeo.h:143
unsigned int Nplanes() const
Number of planes in this tpc.
Definition: TPCGeo.h:137
PlaneGeo const * PlanePtr(PlaneID const &planeid) const
Returns the specified plane.
Container with one element per readout plane.
double ThirdPlaneSlope(PlaneID::PlaneID_t plane1, double slope1, PlaneID::PlaneID_t plane2, double slope2, TPCID const &tpcid) const
Returns the slope on the third plane, given it in the other two.
Float_t y
Definition: compare.C:6
static double ComputeThirdPlane_dTdW(double angle1, double pitch1, double dTdW1, double angle2, double pitch2, double dTdW2, double angle_target, double pitch_target)
Returns the slope on the third plane, given it in the other two.
Length_t DetHalfWidth(TPCID const &tpcid=tpc_zero) const
Returns the half width of the active volume of the specified TPC.
Double_t z
Definition: plot.C:276
AuxDetList_t auxDets
The auxiliary detectors.
Definition: GeometryData.h:38
readout::ROPDataContainer< T > makeROPdata() const
Returns a container with one entry per readout plane.
Simple data structure holding the data of the geometry.
unsigned int PlaneID_t
Type for the ID number.
Definition: geo_types.h:464
PlaneGeo const & GetElement(PlaneID const &planeid) const
Returns the specified wire.
unsigned int GetClosestOpDet(Point_t const &point) const
Find the nearest OpChannel to some point.
CryostatGeo const * GetElementPtr(CryostatID const &cryoid) const
Returns the specified cryostat.
Definition: GeometryCore.h:481
The data type to uniquely identify a Plane.
Definition: geo_types.h:463
Geometry information for a single TPC.
Definition: TPCGeo.h:36
Length_t CryostatHalfWidth(CryostatID const &cid=cryostat_zero) const
Returns the half width of the cryostat (x direction)
bool WireIDsIntersect(WireID const &wid1, WireID const &wid2, Point_t &intersection) const
Computes the intersection between two wires.
std::vector< TPCID > TPCsetToTPCs(readout::TPCsetID const &tpcsetid) const
Returns a list of ID of TPCs belonging to the specified TPC set.
readout::ROPDataContainer< T > makeROPdata(T const &defValue) const
Returns a container with one entry per readout plane.
unsigned int MaxROPs() const
Returns the largest number of ROPs a TPC set in the detector has.
std::set< View_t > allViews
All views in the detector.
Class identifying a set of TPC sharing readout channels.
Definition: readout_types.h:72
BoxBoundedGeo DetectorEnclosureBox(std::string const &name="volDetEnclosure") const
const std::string GetWorldVolumeName() const
Return the name of the world volume (needed by Geant4 simulation)
Point const & start() const
Definition: GeometryCore.h:128
std::vector< TGeoNode const * > FindDetectorEnclosure(std::string const &name="volDetEnclosure") const
unsigned int NOpHardwareChannels(int opDet) const
Number of electronics channels for all the optical detectors.
bool ChannelsIntersect(raw::ChannelID_t c1, raw::ChannelID_t c2, double &y, double &z) const
Returns an intersection point of two channels.
std::vector< geo::CryostatGeo > CryostatList_t
Type of list of cryostats.
Definition: GeometryData.h:33
std::string const & ROOTFile() const
Returns the full directory path to the geometry file source.
Definition: GeometryCore.h:184
double fSurfaceY
The point where air meets earth for this detector.
TGeoVolume const * WorldVolume() const
Returns a pointer to the world volume.
Interface for geometry extractor classes.
CryostatID_t Cryostat
Index of cryostat.
Definition: geo_types.h:211
details::begin_type< T > begin() const
Initializes the specified ID with the ID of the first cryostat.
Definition: GeometryCore.h:529
unsigned int MaxWires() const
Returns the largest number of wires among all planes in this detector.
WireID GetBeginWireID(PlaneID const &id) const
Returns the ID of the first wire of the specified wire plane.
TPCID GetEndTPCID(CryostatID const &id) const
readout::TPCsetID FindTPCsetAtPosition(Point_t const &worldLoc) const
Returns the ID of the TPC set at specified location.
bool WireIDIntersectionCheck(const WireID &wid1, const WireID &wid2) const
Wire ID check for WireIDsIntersect methods.
const AuxDetSensitiveGeo & ChannelToAuxDetSensitive(std::string const &auxDetName, uint32_t const &channel) const
Returns the number of auxiliary detectors.
static constexpr std::size_t MaxWireDepthInGDML
Definition: GeometryCore.h:145
readout::ROPID GetEndROPID(CryostatID const &id) const
Point const & end() const
Definition: GeometryCore.h:131
CryostatList_t cryostats
The detector cryostats.
Definition: GeometryData.h:37
bool FindFirstVolume(std::string const &name, std::vector< const TGeoNode * > &path) const
Container with one element per geometry wire plane.
details::range_type< T > Iterate(ID const &id) const
Initializes the specified ID with the ID of the first cryostat.
Definition: GeometryCore.h:559
bool HasElement(WireID const &wireid) const
Returns whether we have the specified wire.
TGeoMaterial const * Material(Point_t const &point) const
Returns the material at the specified position.
Geometry information for a single cryostat.
Definition: CryostatGeo.h:43
WireGeo const & Wire(WireID const &wireid) const
Returns the specified wire.
CryostatGeo const & GetElement(CryostatID const &cryoid) const
Returns the specified cryostat.
Definition: GeometryCore.h:465
unsigned int Ncryostats() const
Returns the number of cryostats in the detector.
Definition: GeometryCore.h:430
CryostatGeo const & Cryostat(CryostatID const &cryoid=cryostat_zero) const
Returns the specified cryostat.
CryostatGeo const & PositionToCryostat(Point_t const &point) const
Returns the cryostat at specified location.
Point_t GetStart() const
Returns the world coordinate of one end of the wire [cm].
Definition: WireGeo.h:226
Point_t GetEnd() const
Returns the world coordinate of one end of the wire [cm].
Definition: WireGeo.h:231
unsigned int NOpChannels() const
Number of electronics channels for all the optical detectors.
Length_t CryostatHalfHeight(CryostatID const &cid=cryostat_zero) const
Returns the height of the cryostat (y direction)
void GetBeginID(readout::TPCsetID &id) const
Initializes the specified ID with the ID of the first TPC set.
TGeoManager * ROOTGeoManager() const
Access to the ROOT geometry description manager.
unsigned int NElements(PlaneID const &planeid) const
Returns the total number of wires in the specified plane.
Length_t DetLength(TPCID const &tpcid=tpc_zero) const
Returns the length of the active volume of the specified TPC.
Length_t SurfaceY() const
The position of the detector respect to earth surface.
Definition: GeometryCore.h:251
static end_type create_end(Geom const *geom)
Class for approximate comparisons.
unsigned int OpDetFromCryo(unsigned int o, unsigned int c) const
Get unique opdet number from cryo and internal count.
std::string OpDetGeoName(CryostatID const &cid=cryostat_zero) const
Returns gdml string which gives sensitive opdet name.
unsigned int NSiblingElements(readout::TPCsetID const &tpcsetid) const
Returns the total number of TPC sets in the specified cryostat.
unsigned int NElements() const
Returns the number of cryostats in the detector.
Definition: GeometryCore.h:431
TPCGeo const & GetElement(TPCID const &tpcid) const
Returns the specified TPC.
Definition: GeometryCore.h:723
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.
PlaneDataContainer< T > makePlaneData(T const &defValue) const
Returns a container with one entry per wire plane.
Definition: GeometryCore.h:961
unsigned int NSiblingElements(TPCID const &tpcid) const
Returns the largest number of TPCs a cryostat in the detector has.
Definition: GeometryCore.h:692
void GetBeginID(TPCID &id) const
Initializes the specified ID with the ID of the first TPC.
Definition: GeometryCore.h:782
TPCGeo const & TPC(TPCID const &tpcid=tpc_zero) const
Returns the specified TPC.
Definition: GeometryCore.h:722
IDparameter< geo::PlaneID > PlaneID
Member type of validated geo::PlaneID parameter.
double TotalMass() const
Returns the total mass [kg] of the specified volume (default: world).
Definition: GeometryCore.h:319
void GetBeginID(readout::ROPID &id) const
Initializes the specified ID with the ID of the first readout plane.
CryostatList_t const & Cryostats() const
Interface to algorithm class for sorting geo::XXXGeo objects.
std::vector< TPCID > ROPtoTPCs(readout::ROPID const &ropid) const
Returns a list of ID of TPCs the specified ROP spans.
bool HasElement(CryostatID const &cryoid) const
Returns whether we have the specified cryostat.
Definition: GeometryCore.h:447
bool HasElement(readout::ROPID const &ropid) const
AuxDetList_t const & AuxDets() const
Containers to hold one datum per TPC or plane.
PlaneGeo const & Plane(PlaneID const &planeid) const
Returns the specified wire.
bool HasROP(readout::ROPID const &ropid) const
double WireAngleToVertical(View_t view, TPCID const &tpcid) const
Returns the angle of the wires in the specified view from vertical.
std::string VolumeName(Point_t const &point) const
Returns the name of the deepest volume containing specified point.
Container with one element per geometry TPC.
TPCID FindTPCAtPosition(Point_t const &point) const
Returns the ID of the TPC at specified location.
std::unique_ptr< const ChannelMapAlg > fChannelMapAlg
Object containing the channel to wire mapping.
unsigned int MaxPlanes() const
Returns the largest number of planes among all TPCs in this detector.
void GetEndID(readout::TPCsetID &id) const
Initializes the specified ID with the invalid ID after the last TPC set.
readout::ROPID GetBeginROPID(readout::TPCsetID const &id) const
Returns the ID of the first readout plane of the specified TPC set.
TCanvas * c1
Definition: plotHisto.C:7
void GetBeginID(WireID &id) const
Initializes the specified ID with the ID of the first wire.
TCanvas * c2
Definition: plot_hist.C:75
GeometryData_t::CryostatList_t CryostatList_t
Type of list of cryostats.
Definition: GeometryCore.h:139
TPCGeo const * GetElementPtr(TPCID const &tpcid) const
Returns the specified TPC.
Definition: GeometryCore.h:740
typename IteratorMaker< T >::begin_type begin_type
const AuxDetSensitiveGeo & PositionToAuxDetSensitive(Point_t const &point, size_t &ad, size_t &sv, double tolerance=0) const
Returns the auxiliary detector at specified location.
Definitions of geometry vector data types.
raw::ChannelID_t FirstChannelInROP(readout::ROPID const &ropid) const
Returns the ID of the first channel in the specified readout plane.
void ClearGeometry()
Deletes the detector geometry structures.
unsigned int HardwareChannelFromOpChannel(int opChannel) const
Convert unique channel to hardware channel.
GeometryCore(fhicl::ParameterSet const &pset)
Initialize geometry from a given configuration.
enum geo::_plane_sigtype SigType_t
Enumerate the possible plane projections.
TPCGeo const & PositionToTPC(Point_t const &point) const
Returns the TPC at specified location.
CryostatGeo const * CryostatPtr(CryostatID const &cryoid) const
Returns the specified cryostat.
Definition: GeometryCore.h:477
void FindAuxDetSensitiveAtPosition(Point_t const &point, std::size_t &adg, std::size_t &sv, double tolerance=0) const
Fills the indices of the sensitive auxiliary detector at location.
WireID GetBeginWireID(TPCID const &id) const
Returns the ID of the first wire of the specified TPC.
std::string MaterialName(Point_t const &point) const
Name of the deepest material containing the point xyz.
std::string indent(std::size_t const i)
Geometry information for a single wire plane.The plane is represented in the geometry by a solid whic...
Definition: PlaneGeo.h:78
unsigned int NElements() const
Alias for NTPC().
Definition: CryostatGeo.h:177
unsigned int NSiblingElements(WireID const &wireid) const
Returns the total number of wires in the specified plane.
void PrintOpDetInfo(Stream &&out, std::string indent="", unsigned int verbosity=0) const
Prints information about this optical detector.
Definition: OpDetGeo.h:275
Utilities to extend the interface of geometry vectors.
TPCGeo const * TPCPtr(unsigned int itpc) const
Returns the TPC number itpc from this cryostat.
Definition: CryostatGeo.h:256
bool IncrementID(CryostatID &id) const
TPCDataContainer< T > makeTPCData(T const &defValue) const
Returns a container with one entry per TPC.
Definition: GeometryCore.h:670
TPCID GetBeginTPCID(CryostatID const &id) const
Returns the ID of the first TPC in the specified cryostat.
Definition: GeometryCore.h:796
PlaneID GetBeginPlaneID(CryostatID const &id) const
Returns the ID of the first plane of the specified cryostat.
unsigned int MaxOpChannel() const
Largest optical channel number.
unsigned int NSiblingElements(CryostatID const &) const
Returns the number of cryostats in the detector.
Definition: GeometryCore.h:432
size_t NSensitiveVolume() const
Definition: AuxDetGeo.h:144
PlaneID GetBeginPlaneID(TPCID const &id) const
Returns the ID of the first plane of the specified TPC.
bool HasCryostat(CryostatID const &cryoid) const
Returns whether we have the specified cryostat.
Definition: GeometryCore.h:446
std::string Info(std::string indent=" ") const
Returns a string with complete geometry information.
The data type to uniquely identify a TPC.
Definition: geo_types.h:381
Description of geometry of one entire detector.
Definition: GeometryCore.h:119
details::end_type< T > end() const
Initializes the specified ID with the ID of the first cryostat.
Definition: GeometryCore.h:535
static begin_type create_begin(Geom const *geom)
void UpdateAfterSorting()
Performs all the updates needed after sorting.
Definition of data types for geometry description.
void GetEndID(CryostatID &id) const
Initializes the specified ID with the invalid ID after the last cryostat.
Definition: GeometryCore.h:521
TPCDataContainer< T > makeTPCData() const
Returns a container with one entry per TPC.
Definition: GeometryCore.h:645
readout::ROPID WirePlaneToROP(PlaneID const &planeid) const
Returns the ID of the ROP planeid belongs to.
AuxDetList_t & AuxDets()
Return the internal auxdet list.
double DefaultWiggle() const
Returns the tolerance used in looking for positions.
Definition: GeometryCore.h:175
Class identifying a set of planes sharing readout channels.
AuxDetGeo const & AuxDet(unsigned int const ad=0) const
Returns the specified auxiliary detector.
void PrintAuxDetInfo(Stream &&out, std::string indent="", unsigned int verbosity=0) const
Prints information about this auxiliary sensitive detector.
unsigned int NOpDets() const
Number of OpDets in the whole detector.
Provides a base class aware of world box coordinates.
double fPositionWiggle
accounting for rounding errors when testing positions
Encapsulate the geometry of an auxiliary detector.
Encapsulate the geometry of a wire.
GeometryData_t::AuxDetList_t AuxDetList_t
Type of list of auxiliary detectors.
Definition: GeometryCore.h:141
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.
GeometryCore & operator=(GeometryCore const &)=delete
readout::ROPID ChannelToROP(raw::ChannelID_t channel) const
unsigned int OpChannel(int detNum, int hardwareChannel) const
Convert detector number and hardware channel to unique channel.
AuxDetGeo const & PositionToAuxDet(Point_t const &point, unsigned int &ad, double tolerance=0) const
Returns the auxiliary detector at specified location.
Encapsulate the geometry of an optical detector.
std::string fGDMLfile
path to geometry file used for Geant4 simulation
typename IteratorMaker< T >::end_type end_type
details::end_type< T > end(BaseID const &id) const
Initializes the specified ID with the ID of the first cryostat.
Definition: GeometryCore.h:553
BoxBoundedGeo WorldBox() const
CryostatID PositionToCryostatID(Point_t const &point) const
Returns the ID of the cryostat at specified location.
ROOT::Math::PositionVector3D< ROOT::Math::Cartesian3D< double >, ROOT::Math::GlobalCoordinateSystemTag > Point_t
Type for representation of position in physical 3D space.
Definition: geo_vectors.h:180
unsigned int NSiblingElements(PlaneID const &planeid) const
Returns the largest number of planes among all TPCs in this detector.
Definition: GeometryCore.h:983
double MassBetweenPoints(Point_t const &p1, Point_t const &p2) const
Returns the column density between two points.
raw::ChannelID_t PlaneWireToChannel(WireID const &wireid) const
Returns the ID of the TPC channel connected to the specified wire.
SigType_t SignalType(PlaneID const &pid) const
Returns the type of signal on the channels of specified TPC plane.
unsigned int NTPCsets(geo::CryostatID const &cryoid) const
Returns the total number of TPC sets in the specified cryostat.
WireID NearestWireID(Point_t const &point, PlaneID const &planeid) const
Returns the ID of wire closest to position in the specified TPC.
WireGeo const & GetElement(WireID const &wireid) const
Returns the specified wire.
readout::TPCsetDataContainer< T > makeTPCsetData() const
Returns a container with one entry per TPC set.
static constexpr unsigned int MaxVerbosity
Maximum verbosity supported by PrintAuxDetInfo().
A base class aware of world box coordinatesAn object describing a simple shape can inherit from this ...
Definition: BoxBoundedGeo.h:33
Encapsulate the construction of a single detector plane.
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.
readout::ROPID GetEndROPID(readout::TPCsetID const &id) const
bool HasWire(unsigned int iwire) const
Returns whether a wire with index iwire is present in this plane.
Definition: PlaneGeo.h:252
void PrintPlaneInfo(Stream &&out, std::string indent="", unsigned int verbosity=1) const
Returns a volume including all the wires in the plane.
Definition: PlaneGeo.h:1384
PlaneGeo const * PlanePtr(unsigned int iplane) const
Returns the plane number iplane from this TPC.
Definition: TPCGeo.h:190
double ThirdPlane_dTdW(PlaneID const &pid1, double slope1, PlaneID const &pid2, double slope2, PlaneID const &output_plane) const
Returns dT/dW on the third plane, given it in the other two.
const TPCGeo & TPC(unsigned int itpc) const
Return the itpc&#39;th TPC in the cryostat.
Definition: CryostatGeo.cxx:84
void GetEndID(readout::ROPID &id) const
Initializes the specified ID with the invalid ID after the last ROP.
Length_t CryostatLength(CryostatID const &cid=cryostat_zero) const
Returns the length of the cryostat (z direction)
TPCGeo const * TPCPtr(TPCID const &tpcid) const
Returns the specified TPC.
Definition: GeometryCore.h:735
void ApplyChannelMap(std::unique_ptr< ChannelMapAlg > pChannelMap)
Initializes the geometry to work with this channel map.
std::tuple< double, double, const reco::ClusterHit3D * > Point
Definitions used by the VoronoiDiagram algorithm.
Definition: DCEL.h:42
static constexpr unsigned int MaxVerbosity
Maximum verbosity supported by PrintOpDetInfo().
Definition: OpDetGeo.h:222
geo::PlaneID const & ID() const
Returns the identifier of this plane.
Definition: PlaneGeo.h:184
Length_t PlanePitch(TPCID const &tpcid, PlaneID::PlaneID_t p1=0, PlaneID::PlaneID_t p2=1) const
Returns the distance between two planes.
bool HasElement(TPCID const &tpcid) const
Returns whether we have the specified TPC.
Definition: GeometryCore.h:706
unsigned int MaxTPCsets() const
Returns the largest number of TPC sets any cryostat in the detector has.
View_t View(PlaneID const &pid) const
Returns the view (wire orientation) on the channels of specified TPC plane.
static constexpr unsigned int MaxVerbosity
Maximum verbosity supported by PrintAuxDetInfo().
Definition: AuxDetGeo.h:184
unsigned int Nwires() const
Number of wires in this plane.
Definition: PlaneGeo.h:242
double ThirdPlaneSlope(PlaneID const &pid1, double slope1, PlaneID const &pid2, double slope2, PlaneID const &output_plane) const
Returns the slope on the third plane, given it in the other two.
unsigned int NElements() const
Number of planes in this tpc.
Definition: TPCGeo.h:138
CryostatList_t & Cryostats()
Return the internal cryostat list.
Simple class with two points (a pair with aliases).
Definition: GeometryCore.h:123
unsigned int Nwires(PlaneID const &planeid) const
Returns the total number of wires in the specified plane.
PlaneID ThirdPlane(PlaneID const &pid1, PlaneID const &pid2) const
Returns the plane that is not in the specified arguments.
details::begin_type< T > begin(BaseID const &id) const
Initializes the specified ID with the ID of the first cryostat.
Definition: GeometryCore.h:547
readout::TPCsetID TPCtoTPCset(TPCID const &tpcid) const
Returns the ID of the TPC set tpcid belongs to.
const AuxDetGeo & ChannelToAuxDet(std::string const &auxDetName, uint32_t const &channel) const
Returns the number of auxiliary detectors.
raw::ChannelID_t NearestChannel(Point_t const &worldLoc, PlaneID const &planeid) const
Returns the ID of the channel nearest to the specified position.
std::string const & GDMLFile() const
Returns the full directory path to the GDML file source.
Definition: GeometryCore.h:193
std::string fDetectorName
Name of the detector.
std::set< View_t > const & Views() const
Returns a list of possible views in the detector.
Manages the extraction of LArSoft geometry information from ROOT.
static constexpr unsigned int MaxVerbosity
Maximum verbosity supported by PrintWireInfo().
Definition: WireGeo.h:336
Point_t GetTPCFrontFaceCenter(TPCID const &tpcid) const
Returns the center of side of the detector facing the beam.
Definition: GeometryCore.h:872
unsigned int Nplanes(TPCID const &tpcid=tpc_zero) const
Returns the total number of planes in the specified TPC.
Definition: GeometryCore.h:977
std::vector< std::vector< TGeoNode const * > > FindAllVolumePaths(std::set< std::string > const &vol_names) const
Returns paths of all nodes with volumes with the specified names.
Length_t DetHalfHeight(TPCID const &tpcid=tpc_zero) const
Returns the half height of the active volume of the specified TPC.
unsigned int NROPs(readout::TPCsetID const &tpcsetid) const
Returns the total number of ROP in the specified TPC set.
std::vector< geo::AuxDetGeo > AuxDetList_t
Type of list of auxiliary detectors.
Definition: GeometryData.h:35
PlaneGeo const & Plane(geo::View_t view) const
Return the plane in the tpc with View_t view.
Definition: TPCGeo.cxx:252
bool HasTPC(unsigned int itpc) const
Returns whether a TPC with index itpc is present in this cryostat.
Definition: CryostatGeo.h:184
std::string const & DetectorName() const
Returns a string with the name of the detector, as configured.
Definition: GeometryCore.h:203
Interface to algorithm class for a specific detector channel mapping.
bool IntersectionPoint(WireID const &wid1, WireID const &wid2, double &y, double &z) const
Returns the intersection point of two wires.
Data in the geometry description.
Definition: GeometryData.h:30
unsigned int NElements(CryostatID const &cryoid) const
Returns the largest number of TPCs a cryostat in the detector has.
Definition: GeometryCore.h:691
unsigned int Nviews() const
Returns the number of views (different wire orientations)
static constexpr TPCID tpc_zero
Returns the specified TPC.
Definition: GeometryCore.h:721
unsigned int ChannelID_t
Type representing the ID of a readout channel.
Definition: RawTypes.h:28
void GetBeginID(PlaneID &id) const
Initializes the specified ID with the ID of the first plane.
readout::TPCsetID GetEndTPCsetID(CryostatID const &id) const
WireGeo const * WirePtr(WireID const &wireid) const
Returns the specified wire.
GeoID GetNextID(GeoID const &id) const
Returns the ID next to the specified one.
Definition: GeometryCore.h:371
WireID GetEndWireID(CryostatID const &id) const
Containers to hold one datum per TPC set or readout plane.
second_as<> second
Type of time stored in seconds, in double precision.
Definition: spacetime.h:82
static constexpr unsigned int MaxVerbosity
Maximum value for print verbosity.
Definition: PlaneGeo.h:725
unsigned int NSiblingElements(readout::ROPID const &ropid) const
Returns the total number of ROP in the specified TPC set.
TPCGeo const * PositionToTPCptr(Point_t const &point) const
Returns the TPC at specified location.
static constexpr unsigned int MaxVerbosity
Maximum verbosity supported by PrintTPCInfo().
Definition: TPCGeo.h:566
Namespace collecting geometry-related classes utilities.
fhicl::ParameterSet fBuilderParameters
typename IteratorMaker< T >::range_type range_type
Float_t w
Definition: plot.C:20
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
std::string GetCryostatVolumeName(CryostatID const &cid) const
Return the name of LAr TPC volume.
Length_t WirePitch(PlaneID const &planeid=plane_zero) const
Returns the distance between two consecutive wires.
bool IsValidOpChannel(int opChannel) const
Is this a valid OpChannel number?
readout::ROPID GetBeginROPID(CryostatID const &id) const
Returns the ID of the first readout plane of the specified cryostat.
TPCID PositionToTPCID(Point_t const &point) const
Returns the ID of the TPC at specified location.
bool HasTPC(TPCID const &tpcid) const
Returns whether we have the specified TPC.
Definition: GeometryCore.h:699
geo::Point_t GetFrontFaceCenter() const
Returns the center of the active TPC volume side facing negative z.
Definition: TPCGeo.h:257
void PrintAuxDetInfo(Stream &&out, std::string indent="", unsigned int verbosity=1) const
Prints information about this auxiliary detector.
Definition: AuxDetGeo.h:211
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.
std::string SignalTypeName(geo::SigType_t sigType)
Returns the name of the specified signal type.
Definition: geo_types.cxx:18
unsigned int NAuxDets() const
Returns the number of auxiliary detectors.
void WireEndPoints(WireID const &wireid, double *xyzStart, double *xyzEnd) const
Fills two arrays with the coordinates of the wire end points.
Encapsulate the construction of a single detector plane.
The data type to uniquely identify a cryostat.
Definition: geo_types.h:192
PlaneGeo const * GetElementPtr(PlaneID const &planeid) const
Returns the specified plane.
static constexpr CryostatID cryostat_zero
Returns the specified cryostat.
Definition: GeometryCore.h:463
static constexpr PlaneID plane_zero
Returns the distance between two consecutive wires.
static range_type create_range(Geom const *geom)
bool HasTPCset(readout::TPCsetID const &tpcsetid) const
PlaneDataContainer< T > makePlaneData() const
Returns a container with one entry per wire plane.
Definition: GeometryCore.h:937
PlaneID GetEndPlaneID(CryostatID const &id) const