15 #include "cetlib_except/exception.h" 34 double xyz1[3] = {0.}, xyz2[3] = {0.};
35 double local[3] = {0.};
40 return xyz1[2]>xyz2[2];
41 else if(xyz1[1]!=xyz2[1])
42 return xyz1[1]>xyz2[1];
44 return xyz1[0]>xyz2[0];
52 double xyz1[3] = {0.}, xyz2[3] = {0.};
53 double local[3] = {0.};
58 return xyz1[0]>xyz2[0];
59 else if(xyz1[2]!=xyz2[2])
60 return xyz1[2]>xyz2[2];
62 return xyz1[1]>xyz2[1];
73 fVolume = path[depth]->GetVolume();
75 throw cet::exception(
"CryostatGeo") <<
"cannot find cryostat outline volume\n";
98 [&sorter](
auto& coll){ std::sort(coll.begin(), coll.end(), sorter); }
109 const char* nm = path[depth]->GetName();
110 if( (strncmp(nm,
"volTPC", 6) == 0) ){
116 unsigned int deeper = depth+1;
117 if(deeper >= path.size()){
118 throw cet::exception(
"BadTGeoNode") <<
"exceeded maximum TGeoNode depth\n";
121 const TGeoVolume *v = path[depth]->GetVolume();
122 int nd = v->GetNdaughters();
123 for(
int i = 0; i < nd; ++i){
124 path[deeper] = v->GetNode(i);
133 fTPCs.emplace_back(path, depth);
167 for (
unsigned int tpc = 0; tpc <
NTPC(); ++tpc)
178 throw cet::exception(
"TPCOutOfRange") <<
"Request for non-existant TPC " 192 const char* nm = path[depth]->GetName();
199 unsigned int deeper = depth+1;
200 if(deeper >= path.size()){
201 throw cet::exception(
"BadTGeoNode") <<
"exceeded maximum TGeoNode depth\n";
204 const TGeoVolume *v = path[depth]->GetVolume();
205 int nd = v->GetNdaughters();
206 for(
int i = 0; i < nd; ++i){
207 path[deeper] = v->GetNode(i);
216 fOpDets.emplace_back(path, depth);
223 throw cet::exception(
"OpDetOutOfRange") <<
"Request for non-existant OpDet " 236 (
double const worldLoc[3],
double wiggle)
const 262 <<
"Can't find any TPC for position " << point <<
" within " <<
ID()
272 for (
auto const& tpc:
TPCs())
273 if (tpc.ContainsPosition(point, wiggle))
return &tpc;
280 unsigned int maxPlanes = 0;
283 if (maxPlanesInTPC > maxPlanes) maxPlanes = maxPlanesInTPC;
290 unsigned int maxWires = 0;
293 if (maxWiresInTPC > maxWires) maxWires = maxWiresInTPC;
301 return static_cast<TGeoBBox const*
>(
fVolume->GetShape())->GetDX();
307 return static_cast<TGeoBBox const*
>(
fVolume->GetShape())->GetDY();
313 return static_cast<TGeoBBox const*
>(
fVolume->GetShape())->GetDZ();
318 boundaries[0] =
MinX();
319 boundaries[1] =
MaxX();
320 boundaries[2] =
MinY();
321 boundaries[3] =
MaxY();
322 boundaries[4] =
MinZ();
323 boundaries[5] =
MaxZ();
343 for(
unsigned int o = 0U; o <
NOpDet(); ++o) {
345 if(ThisDist < ClosestDist) {
346 ClosestDist = ThisDist;
361 if (!dynamic_cast<TGeoBBox*>(
Volume()->GetShape())) {
363 throw cet::exception(
"CryostatGeo") <<
"Cryostat is not a box! (it is a " 364 <<
Volume()->GetShape()->IsA()->GetName() <<
")\n";
CryostatGeo(std::vector< const TGeoNode * > &path, int depth)
Construct a representation of a single cryostat of the detector.
geo::TPCID const & ID() const
Returns the identifier of this TPC.
void InitCryoBoundaries()
Fill the boundary information of the cryostat.
unsigned int GetClosestOpDet(geo::Point_t const &point) const
double HalfLength() const
Half height of the cryostat [cm].
Encapsulate the construction of a single cyostat.
unsigned int MaxPlanes() const
Returns the largest number of planes among the TPCs in this cryostat.
TGeoVolume * fVolume
Total volume of cryostat, called volCryostat in GDML file.
unsigned int Nplanes() const
Number of planes in this tpc.
double MinX() const
Returns the world x coordinate of the start of the box.
Silly utility to sort vectors indirectly.
Geometry information for a single TPC.
double MaxX() const
Returns the world x coordinate of the end of the box.
void SortSubVolumes(geo::GeoObjectSorter const &sorter)
Apply sorting to the PlaneGeo objects.
geo::TPCGeo const * PositionToTPCptr(geo::Point_t const &point, double wiggle) const
Returns a pointer to the TPC at specified location.
std::string fOpDetGeoName
Name of opdet geometry elements in gdml.
std::vector< OpDetGeo > fOpDets
List of opdets in this cryostat.
virtual void SortTPCs(std::vector< geo::TPCGeo * > &tgeo) const =0
void SortSubVolumes(geo::GeoObjectSorter const &sorter)
Method to sort TPCGeo objects.
std::string OpDetGeoName() const
Get name of opdet geometry element.
void SortByPointers(Coll &coll, Sorter sorter)
Applies sorting indirectly, minimizing data copy.
geo::OpDetGeo const * GetClosestOpDetPtr(geo::Point_t const &point) const
const TGeoVolume * Volume() const
Pointer to ROOT's volume descriptor.
const OpDetGeo & OpDet(unsigned int iopdet) const
Return the iopdet'th optical detector in the cryostat.
unsigned int TPCID_t
Type for the ID number.
geo::Point3DBase_t< CryostatGeoCoordinatesTag > LocalPoint_t
Type of points in the local GDML cryostat frame.
double HalfWidth() const
Half width of the cryostat [cm].
double MinZ() const
Returns the world z coordinate of the start of the box.
TPCGeo const * TPCPtr(unsigned int itpc) const
Returns the TPC number itpc from this cryostat.
unsigned int NTPC() const
Number of TPCs in this cryostat.
geo::CryostatID fID
ID of this cryostat.
The data type to uniquely identify a TPC.
unsigned int MaxWires() const
Returns the largest number of wires among the planes in this TPC.
void FindOpDet(std::vector< const TGeoNode * > &path, unsigned int depth)
unsigned int MaxWires() const
Returns the largest number of wires among the TPCs in this cryostat.
void UpdateAfterSorting(geo::CryostatID cryoid)
Performs all needed updates after geometry has sorted the cryostats.
static bool DUNE_opdet_sort(const OpDetGeo *t1, const OpDetGeo *t2)
double MaxY() const
Returns the world y coordinate of the end of the box.
double HalfHeight() const
Half height of the cryostat [cm].
geo::TPCID::TPCID_t FindTPCAtPosition(double const worldLoc[3], double const wiggle) const
Returns the index of the TPC at specified location.
double DistanceToPoint(geo::Point_t const &point) const
Returns the distance of the specified point from detector center [cm].
auto const & TPCs() const
Returns a container with references to all TPCs.
void FindTPC(std::vector< const TGeoNode * > &path, unsigned int depth)
static bool opdet_sort(const OpDetGeo *t1, const OpDetGeo *t2)
TPCList_t fTPCs
List of tpcs in this cryostat.
void SetBoundaries(Coord_t x_min, Coord_t x_max, Coord_t y_min, Coord_t y_max, Coord_t z_min, Coord_t z_max)
Sets the boundaries in world coordinates as specified.
const TPCGeo & TPC(unsigned int itpc) const
Return the itpc'th TPC in the cryostat.
unsigned int NOpDet() const
Number of optical detectors in this TPC.
double MaxZ() const
Returns the world z coordinate of the end of the box.
void MakeOpDet(std::vector< const TGeoNode * > &path, int depth)
static const TPCID_t InvalidID
Special code for an invalid ID.
geo::BoxBoundedGeo const & Boundaries() const
Returns boundaries of the cryostat (in centimetres).
TPCGeo const & PositionToTPC(geo::Point_t const &point, double wiggle) const
Returns the ID of the TPC at specified location.
TPCID_t TPC
Index of the TPC within its cryostat.
void MakeTPC(std::vector< const TGeoNode * > &path, int depth)
ROOT::Math::PositionVector3D< ROOT::Math::Cartesian3D< double >, ROOT::Math::GlobalCoordinateSystemTag > Point_t
Type for representation of position in physical 3D space.
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::Point_t toWorldCoords(LocalPoint_t const &local) const
Transform point from local cryostat frame to world frame.
geo::TPCID PositionToTPCID(geo::Point_t const &point, double wiggle) const
Returns the ID of the TPC at specified location.
void LocalToWorld(const double *opdet, double *world) const
Transform point from local optical detector frame to world frame.
cet::coded_exception< error, detail::translate > exception
The data type to uniquely identify a cryostat.
geo::CryostatID const & ID() const
Returns the identifier of this cryostat.