GeoObjectSorterAPA.cxx
Go to the documentation of this file.
1 ////////////////////////////////////////////////////////////////////////
2 /// \file GeoObjectSorterAPA.cxx
3 /// \brief Interface to algorithm class for sorting standard geo::XXXGeo objects
4 ///
5 /// \version $Id: $
6 /// \author brebel@fnal.gov
7 ////////////////////////////////////////////////////////////////////////
8 
16 
17 namespace geo{
18 
19  //----------------------------------------------------------------------------
20  static bool sortAuxDetAPA(const AuxDetGeo& ad1, const AuxDetGeo& ad2)
21  {
22 
23  // NOTE: This initial sorting is arbitrary, there
24  // are no APAAlg users using AuxDet yet
25 
26  double xyz1[3] = {0.};
27  double xyz2[3] = {0.};
28  double local[3] = {0.};
29  ad1.LocalToWorld(local, xyz1);
30  ad2.LocalToWorld(local, xyz2);
31 
32  // First sort all AuxDets into same-y groups
33  if(xyz1[1] < xyz2[1]) return true;
34 
35  // Within a same-y group, sort TPCs into same-z groups
36  if(xyz1[1] == xyz2[1] && xyz1[2] < xyz2[2]) return true;
37 
38  // Within a same-z, same-y group, sort TPCs according to x
39  if(xyz1[2] == xyz2[2] && xyz1[1] == xyz2[1] && xyz1[0] < xyz2[0]) return true;
40 
41  // none of those are true, so return false
42  return false;
43 
44  }
45 
46  //----------------------------------------------------------------------------
47  static bool sortAuxDetSensitiveAPA(const AuxDetSensitiveGeo& ad1, const AuxDetSensitiveGeo& ad2)
48  {
49 
50  // NOTE: This initial sorting is arbitrary, there
51  // are no APAAlg users using AuxDet yet
52 
53  double xyz1[3] = {0.};
54  double xyz2[3] = {0.};
55  double local[3] = {0.};
56  ad1.LocalToWorld(local, xyz1);
57  ad2.LocalToWorld(local, xyz2);
58 
59  // First sort all AuxDets into same-y groups
60  if(xyz1[1] < xyz2[1]) return true;
61 
62  // Within a same-y group, sort TPCs into same-z groups
63  if(xyz1[1] == xyz2[1] && xyz1[2] < xyz2[2]) return true;
64 
65  // Within a same-z, same-y group, sort TPCs according to x
66  if(xyz1[2] == xyz2[2] && xyz1[1] == xyz2[1] && xyz1[0] < xyz2[0]) return true;
67 
68  // none of those are true, so return false
69  return false;
70 
71  }
72 
73  //----------------------------------------------------------------------------
74  // Define sort order for cryostats in APA configuration
75  // same as standard
76  static bool sortCryoAPA(const CryostatGeo& c1, const CryostatGeo& c2)
77  {
78  double xyz1[3] = {0.}, xyz2[3] = {0.};
79  double local[3] = {0.};
80  c1.LocalToWorld(local, xyz1);
81  c2.LocalToWorld(local, xyz2);
82 
83  return xyz1[0] < xyz2[0];
84  }
85 
86 
87  //----------------------------------------------------------------------------
88  // Define sort order for tpcs in APA configuration.
89  static bool sortTPCAPA(const TPCGeo& t1, const TPCGeo& t2)
90  {
91  double xyz1[3] = {0.};
92  double xyz2[3] = {0.};
93  double local[3] = {0.};
94  t1.LocalToWorld(local, xyz1);
95  t2.LocalToWorld(local, xyz2);
96 
97  // The goal is to number TPCs first in the x direction so that,
98  // in the case of APA configuration, TPCs 2c and 2c+1 make up APA c.
99  // then numbering will go in y then in z direction.
100 
101  // First sort all TPCs into same-z groups
102  if(xyz1[2] < xyz2[2]) return true;
103 
104  // Within a same-z group, sort TPCs into same-y groups
105  if(xyz1[2] == xyz2[2] && xyz1[1] < xyz2[1]) return true;
106 
107  // Within a same-z, same-y group, sort TPCs according to x
108  if(xyz1[2] == xyz2[2] && xyz1[1] == xyz2[1] && xyz1[0] < xyz2[0]) return true;
109 
110  // none of those are true, so return false
111  return false;
112  }
113 
114 
115  //----------------------------------------------------------------------------
116  // Define sort order for planes in APA configuration
117  // same as standard, but implemented differently
118  static bool sortPlaneAPA(const PlaneGeo& p1, const PlaneGeo& p2)
119  {
120  double xyz1[3] = {0.};
121  double xyz2[3] = {0.};
122  double local[3] = {0.};
123  p1.LocalToWorld(local, xyz1);
124  p2.LocalToWorld(local, xyz2);
125 
126  return xyz1[0] > xyz2[0];
127  }
128 
129 
130  //----------------------------------------------------------------------------
131  bool sortWireAPA(WireGeo& w1, WireGeo& w2){
132  double xyz1[3] = {0.};
133  double xyz2[3] = {0.};
134 
135  w1.GetCenter(xyz1); w2.GetCenter(xyz2);
136 
137  // we want the wires to be sorted such that the smallest corner wire
138  // on the readout end of a plane is wire zero, with wire number
139  // increasing away from that wire.
140 
141  // if a top TPC, count from top down
142  if( xyz1[1]>0 && xyz1[1] > xyz2[1] ) return true;
143 
144  // if a bottom TPC, count from bottom up
145  if( xyz1[1]<0 && xyz1[1] < xyz2[1] ) return true;
146 
147  // sort the all vertical wires to increase in +z direction
148  if( xyz1[1] == xyz2[1] && xyz1[2] < xyz2[2] ) return true;
149 
150  return false;
151  }
152 
153 
154  //----------------------------------------------------------------------------
156  {
157  }
158 
159  //----------------------------------------------------------------------------
160  void GeoObjectSorterAPA::SortAuxDets(std::vector<geo::AuxDetGeo> & adgeo) const
161  {
162  std::sort(adgeo.begin(), adgeo.end(), sortAuxDetAPA);
163  }
164 
165  //----------------------------------------------------------------------------
166  void GeoObjectSorterAPA::SortAuxDetSensitive(std::vector<geo::AuxDetSensitiveGeo> & adgeo) const
167  {
168  std::sort(adgeo.begin(), adgeo.end(), sortAuxDetSensitiveAPA);
169  }
170 
171  //----------------------------------------------------------------------------
172  void GeoObjectSorterAPA::SortCryostats(std::vector<geo::CryostatGeo> & cgeo) const
173  {
174  std::sort(cgeo.begin(), cgeo.end(), sortCryoAPA);
175  }
176 
177  //----------------------------------------------------------------------------
178  void GeoObjectSorterAPA::SortTPCs(std::vector<geo::TPCGeo> & tgeo) const
179  {
180  std::sort(tgeo.begin(), tgeo.end(), sortTPCAPA);
181  }
182 
183  //----------------------------------------------------------------------------
184  void GeoObjectSorterAPA::SortPlanes(std::vector<geo::PlaneGeo> & pgeo,
185  geo::DriftDirection_t const driftDir) const
186  {
187  // sort the planes to increase in drift direction
188  // The drift direction has to be set before this method is called. It is set when
189  // the CryostatGeo objects are sorted by the CryostatGeo::SortSubVolumes method
190  if (driftDir == geo::kPosX) std::sort(pgeo.rbegin(), pgeo.rend(), sortPlaneAPA);
191  else if(driftDir == geo::kNegX) std::sort(pgeo.begin(), pgeo.end(), sortPlaneAPA);
192  else if(driftDir == geo::kUnknownDrift)
193  throw cet::exception("TPCGeo") << "Drift direction is unknown, can't sort the planes\n";
194  }
195 
196  //----------------------------------------------------------------------------
197  void GeoObjectSorterAPA::SortWires(std::vector<geo::WireGeo> & wgeo) const
198  {
199  std::sort(wgeo.begin(), wgeo.end(), sortWireAPA);
200  }
201 
202  //----------------------------------------------------------------------------
203  void GeoObjectSorterAPA::SortOpDets (std::vector<geo::OpDetGeo> & opdet) const {
204  std::sort(opdet.begin(), opdet.end(), sortorderOpDet);
205  }
206 
207 }
GeoObjectSorterAPA(fhicl::ParameterSet const &p)
Geometry description of a TPC wireThe wire is a single straight segment on a wire plane...
Definition: WireGeo.h:65
Drift direction is unknown.
Definition: geo_types.h:158
void LocalToWorld(const double *auxdet, double *world) const
Transform point from local auxiliary detector frame to world frame.
Definition: AuxDetGeo.h:120
Encapsulate the construction of a single cyostat.
static bool sortAuxDetAPA(const AuxDetGeo &ad1, const AuxDetGeo &ad2)
Geometry information for a single TPC.
Definition: TPCGeo.h:38
Interface to algorithm class for standard sorting of geo::XXXGeo objects.
Drift towards negative X values.
Definition: geo_types.h:162
Geometry information for a single cryostat.
Definition: CryostatGeo.h:43
void SortTPCs(std::vector< geo::TPCGeo > &tgeo) const
void SortAuxDetSensitive(std::vector< geo::AuxDetSensitiveGeo > &adgeo) const
enum geo::driftdir DriftDirection_t
Drift direction: positive or negative.
void SortOpDets(std::vector< geo::OpDetGeo > &opdet) const
static bool sortPlaneAPA(const PlaneGeo &p1, const PlaneGeo &p2)
Geometry information for a single wire plane.The plane is represented in the geometry by a solid whic...
Definition: PlaneGeo.h:82
bool sortorderOpDet(const OpDetGeo &t1, const OpDetGeo &t2)
Definition: OpDetSorter.h:10
Encapsulate the geometry of an auxiliary detector.
void SortAuxDets(std::vector< geo::AuxDetGeo > &adgeo) const
void SortCryostats(std::vector< geo::CryostatGeo > &cgeo) const
Encapsulate the geometry of a wire.
static bool sortAuxDetSensitiveAPA(const AuxDetSensitiveGeo &ad1, const AuxDetSensitiveGeo &ad2)
void LocalToWorld(const double *cryo, double *world) const
Transform point from local cryostat frame to world frame.
Definition: CryostatGeo.h:387
static bool sortTPCAPA(const TPCGeo &t1, const TPCGeo &t2)
void SortPlanes(std::vector< geo::PlaneGeo > &pgeo, geo::DriftDirection_t driftDir) const
Drift towards positive X values.
Definition: geo_types.h:161
Encapsulate the construction of a single detector plane.
static bool sortCryoAPA(const CryostatGeo &c1, const CryostatGeo &c2)
bool sortWireAPA(WireGeo &w1, WireGeo &w2)
void GetCenter(double *xyz, double localz=0.0) const
Fills the world coordinate of a point on the wire.
Definition: WireGeo.cxx:73
void LocalToWorld(const double *auxdet, double *world) const
Transform point from local auxiliary detector frame to world frame.
LArSoft geometry interface.
Definition: ChannelGeo.h:16
void SortWires(std::vector< geo::WireGeo > &wgeo) const
void LocalToWorld(const double *tpc, double *world) const
Transform point from local TPC frame to world frame.
Definition: TPCGeo.h:563
void LocalToWorld(const double *plane, double *world) const
Transform point from local plane frame to world frame.
Definition: PlaneGeo.h:1343
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33
Encapsulate the construction of a single detector plane.