LArSoft  v06_85_00
Liquid Argon Software toolkit - http://larsoft.org/
GeoObjectSorterStandard.cxx
Go to the documentation of this file.
1 
15 
16 namespace {
17 
18  // Tolerance when comparing distances in geometry:
19  static constexpr double DistanceTol = 0.001; // cm
20 
21 } // local namespace
22 
23 namespace geo{
24 
25  //----------------------------------------------------------------------------
26  // Define sort order for cryostats in standard configuration
27  static bool sortAuxDetStandard(const AuxDetGeo* ad1, const AuxDetGeo* ad2)
28  {
29 
30  // sort based off of GDML name, assuming ordering is encoded
31  std::string ad1name = (ad1->TotalVolume())->GetName();
32  std::string ad2name = (ad2->TotalVolume())->GetName();
33 
34  // assume volume name is "volAuxDet##"
35  int ad1Num = atoi( ad1name.substr( 9, ad1name.size()).c_str() );
36  int ad2Num = atoi( ad2name.substr( 9, ad2name.size()).c_str() );
37 
38  return ad1Num < ad2Num;
39 
40  }
41 
42  //----------------------------------------------------------------------------
43  // Define sort order for cryostats in standard configuration
45  {
46 
47  // sort based off of GDML name, assuming ordering is encoded
48  std::string ad1name = (ad1->TotalVolume())->GetName();
49  std::string ad2name = (ad2->TotalVolume())->GetName();
50 
51  // assume volume name is "volAuxDetSensitive##"
52  int ad1Num = atoi( ad1name.substr( 9, ad1name.size()).c_str() );
53  int ad2Num = atoi( ad2name.substr( 9, ad2name.size()).c_str() );
54 
55  return ad1Num < ad2Num;
56 
57  }
58 
59  //----------------------------------------------------------------------------
60  // Define sort order for cryostats in standard configuration
61  static bool sortCryoStandard(const CryostatGeo* c1, const CryostatGeo* c2)
62  {
63  double xyz1[3] = {0.}, xyz2[3] = {0.};
64  double local[3] = {0.};
65  c1->LocalToWorld(local, xyz1);
66  c2->LocalToWorld(local, xyz2);
67 
68  return xyz1[0] < xyz2[0];
69  }
70 
71 
72  //----------------------------------------------------------------------------
73  // Define sort order for tpcs in standard configuration.
74  static bool sortTPCStandard(const TPCGeo* t1, const TPCGeo* t2)
75  {
76  double xyz1[3] = {0.};
77  double xyz2[3] = {0.};
78  double local[3] = {0.};
79  t1->LocalToWorld(local, xyz1);
80  t2->LocalToWorld(local, xyz2);
81 
82  // sort TPCs according to x
83  if(xyz1[0] < xyz2[0]) return true;
84 
85  return false;
86  }
87 
88 
89  //----------------------------------------------------------------------------
90  // Define sort order for planes in standard configuration
91  static bool sortPlaneStandard(const PlaneGeo* p1, const PlaneGeo* p2)
92  {
93  double xyz1[3] = {0.};
94  double xyz2[3] = {0.};
95  double local[3] = {0.};
96  p1->LocalToWorld(local, xyz1);
97  p2->LocalToWorld(local, xyz2);
98 
99  // drift direction is negative, plane number increases in drift direction
100  if(std::abs(xyz1[0]-xyz2[0]) > DistanceTol)
101  return xyz1[0] > xyz2[0];
102 
103  //if same drift, sort by z
104  if(std::abs(xyz1[2]-xyz2[2]) > DistanceTol)
105  return xyz1[2] < xyz2[2];
106 
107  //if same z, sort by y
108  return xyz1[1] < xyz2[1];
109  }
110 
111 
112  //----------------------------------------------------------------------------
114  double xyz1[3] = {0.};
115  double xyz2[3] = {0.};
116 
117  w1->GetCenter(xyz1); w2->GetCenter(xyz2);
118 
119  //sort by z first
120  if(std::abs(xyz1[2]-xyz2[2]) > DistanceTol)
121  return xyz1[2] < xyz2[2];
122 
123  //if same z sort by y
124  if(std::abs(xyz1[1]-xyz2[1]) > DistanceTol)
125  return xyz1[1] < xyz2[1];
126 
127  //if same y sort by x
128  return xyz1[0] < xyz2[0];
129  }
130 
131  //----------------------------------------------------------------------------
133  {
134  }
135 
136  //----------------------------------------------------------------------------
138  {
139  }
140 
141  //----------------------------------------------------------------------------
142  void GeoObjectSorterStandard::SortAuxDets(std::vector<geo::AuxDetGeo*> & adgeo) const
143  {
144  std::sort(adgeo.begin(), adgeo.end(), sortAuxDetStandard);
145 
146  return;
147  }
148 
149  //----------------------------------------------------------------------------
150  void GeoObjectSorterStandard::SortAuxDetSensitive(std::vector<geo::AuxDetSensitiveGeo*> & adsgeo) const
151  {
152  std::sort(adsgeo.begin(), adsgeo.end(), sortAuxDetSensitiveStandard);
153 
154  return;
155  }
156 
157  //----------------------------------------------------------------------------
158  void GeoObjectSorterStandard::SortCryostats(std::vector<geo::CryostatGeo*> & cgeo) const
159  {
160  std::sort(cgeo.begin(), cgeo.end(), sortCryoStandard);
161 
162  return;
163  }
164 
165  //----------------------------------------------------------------------------
166  void GeoObjectSorterStandard::SortTPCs(std::vector<geo::TPCGeo*> & tgeo) const
167  {
168 
169  std::sort(tgeo.begin(), tgeo.end(), sortTPCStandard);
170 
171  return;
172  }
173 
174  //----------------------------------------------------------------------------
175  void GeoObjectSorterStandard::SortPlanes(std::vector<geo::PlaneGeo*> & pgeo,
176  geo::DriftDirection_t const& driftDir) const
177  {
178  // sort the planes to increase in drift direction
179  // The drift direction has to be set before this method is called. It is set when
180  // the CryostatGeo objects are sorted by the CryostatGeo::SortSubVolumes method
181  if (driftDir == geo::kPosX) std::sort(pgeo.rbegin(), pgeo.rend(), sortPlaneStandard);
182  else if(driftDir == geo::kNegX) std::sort(pgeo.begin(), pgeo.end(), sortPlaneStandard);
183  else if(driftDir == geo::kUnknownDrift)
184  throw cet::exception("TPCGeo") << "Drift direction is unknown, can't sort the planes\n";
185 
186  return;
187  }
188 
189  //----------------------------------------------------------------------------
190  void GeoObjectSorterStandard::SortWires(std::vector<geo::WireGeo*> & wgeo) const
191  {
192  std::sort(wgeo.begin(), wgeo.end(), sortWireStandard);
193 
194  return;
195  }
196 
197 }
Geometry description of a TPC wireThe wire is a single straight segment on a wire plane...
Definition: WireGeo.h:61
Drift direction is unknown.
Definition: geo_types.h:105
TTree * t1
Definition: plottest35.C:26
Encapsulate the construction of a single cyostat.
Encapsulate the geometry of the sensitive portion of an auxiliary detector.
static bool sortTPCStandard(const TPCGeo *t1, const TPCGeo *t2)
Geometry information for a single TPC.
Definition: TPCGeo.h:37
void SortCryostats(std::vector< geo::CryostatGeo * > &cgeo) const
void SortWires(std::vector< geo::WireGeo * > &wgeo) const
Drift towards negative X values.
Definition: geo_types.h:109
Geometry information for a single cryostat.
Definition: CryostatGeo.h:36
void SortPlanes(std::vector< geo::PlaneGeo * > &pgeo, geo::DriftDirection_t const &driftDir) const
Interface to algorithm class for standard sorting of geo::XXXGeo objects.
TCanvas * c1
Definition: plotHisto.C:7
TCanvas * c2
Definition: plot_hist.C:75
static bool sortAuxDetStandard(const AuxDetGeo *ad1, const AuxDetGeo *ad2)
enum geo::driftdir DriftDirection_t
Drift direction: positive or negative.
bool sortWireStandard(WireGeo *w1, WireGeo *w2)
Geometry information for a single wire plane.The plane is represented in the geometry by a solid whic...
Definition: PlaneGeo.h:78
const TGeoVolume * TotalVolume() const
void SortTPCs(std::vector< geo::TPCGeo * > &tgeo) const
TTree * t2
Definition: plottest35.C:36
Encapsulate the geometry of an auxiliary detector.
Encapsulate the geometry of a wire.
void SortAuxDetSensitive(std::vector< geo::AuxDetSensitiveGeo * > &adsgeo) const
GeoObjectSorterStandard(fhicl::ParameterSet const &p)
void LocalToWorld(const double *cryo, double *world) const
Transform point from local cryostat frame to world frame.
Definition: CryostatGeo.h:321
Drift towards positive X values.
Definition: geo_types.h:108
Encapsulate the construction of a single detector plane.
const TGeoVolume * TotalVolume() const
Returns the distance of point from the center of the detector.
Definition: AuxDetGeo.h:94
void SortAuxDets(std::vector< geo::AuxDetGeo * > &adgeo) const
static bool sortPlaneStandard(const PlaneGeo *p1, const PlaneGeo *p2)
void GetCenter(double *xyz, double localz=0.0) const
Fills the world coordinate of a point on the wire.
Definition: WireGeo.cxx:68
Namespace collecting geometry-related classes utilities.
static bool sortAuxDetSensitiveStandard(const AuxDetSensitiveGeo *ad1, const AuxDetSensitiveGeo *ad2)
void LocalToWorld(const double *tpc, double *world) const
Transform point from local TPC frame to world frame.
Definition: TPCGeo.h:490
void LocalToWorld(const double *plane, double *world) const
Transform point from local plane frame to world frame.
Definition: PlaneGeo.h:1124
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33
Encapsulate the construction of a single detector plane.
static bool sortCryoStandard(const CryostatGeo *c1, const CryostatGeo *c2)