All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
GeoObjectSorterICARUS.cxx
Go to the documentation of this file.
1 ////////////////////////////////////////////////////////////////////////
2 /// \file GeoObjectSorterICARUS.cxx
3 /// \brief Interface to algorithm class for sorting standard geo::XXXGeo objects
4 ///
5 /// \version $Id: $
6 /// \author brebel@fnal.gov
7 ////////////////////////////////////////////////////////////////////////
8 
11 
18 
19 namespace geo{
20 
21  //----------------------------------------------------------------------------
22  // Define sort order for cryostats in standard configuration
23  static bool sortCryoStandard(const CryostatGeo& c1, const CryostatGeo& c2)
24  {
25  double xyz1[3] = {0.}, xyz2[3] = {0.};
26  double local[3] = {0.};
27  c1.LocalToWorld(local, xyz1);
28  c2.LocalToWorld(local, xyz2);
29 
30  return xyz1[0] < xyz2[0];
31  }
32 
33 
34  //----------------------------------------------------------------------------
35  // Define sort order for tpcs in standard configuration.
36  static bool sortTPCStandard(const TPCGeo& t1, const TPCGeo& t2)
37  {
38  double xyz1[3] = {0.};
39  double xyz2[3] = {0.};
40  double local[3] = {0.};
41  t1.LocalToWorld(local, xyz1);
42  t2.LocalToWorld(local, xyz2);
43 
44  // sort TPCs according to x
45  if(xyz1[0] < xyz2[0]) return true;
46 
47  return false;
48  }
49 
50  const double EPSILON = 0.000001;
51 
52  //----------------------------------------------------------------------------
53  // Define sort order for planes in standard configuration
54  static bool sortPlaneStandard(const PlaneGeo& p1, const PlaneGeo& p2)
55  {
56  double xyz1[3] = {0.};
57  double xyz2[3] = {0.};
58  double local[3] = {0.};
59  p1.LocalToWorld(local, xyz1);
60  p2.LocalToWorld(local, xyz2);
61 
62  //if the planes are in the same drift coordinate, lower Z is first plane
63  if( std::abs(xyz1[0] - xyz2[0]) < EPSILON)
64  return xyz1[2] < xyz2[2];
65 
66  //else
67  // drift direction is negative, plane number increases in drift direction
68  return xyz1[0] > xyz2[0];
69  }
70 
71 
72  //----------------------------------------------------------------------------
73  static bool sortWireStandard(WireGeo const& w1, WireGeo const& w2){
74  double xyz1[3] = {0.};
75  double xyz2[3] = {0.};
76 
77  w1.GetCenter(xyz1); w2.GetCenter(xyz2);
78 
79  //we have horizontal wires...
80  if( std::abs(xyz1[2]-xyz2[2]) < EPSILON)
81  return xyz1[1] < xyz2[1];
82 
83  //in the other cases...
84  return xyz1[2] < xyz2[2];
85  }
86 
87  //----------------------------------------------------------------------------
88  GeoObjectSorterICARUS::GeoObjectSorterICARUS(fhicl::ParameterSet const& p)
89  {
90  }
91 
92  //----------------------------------------------------------------------------
93  void GeoObjectSorterICARUS::SortAuxDets(std::vector<geo::AuxDetGeo> & adgeo) const
94  {
96  }
97 
98  //----------------------------------------------------------------------------
99  void GeoObjectSorterICARUS::SortAuxDetSensitive(std::vector<geo::AuxDetSensitiveGeo> & adsgeo) const
100  {
102  }
103 
104  //----------------------------------------------------------------------------
105  void GeoObjectSorterICARUS::SortCryostats(std::vector<geo::CryostatGeo> & cgeo) const
106  {
107  std::sort(cgeo.begin(), cgeo.end(), sortCryoStandard);
108  }
109 
110  //----------------------------------------------------------------------------
111  void GeoObjectSorterICARUS::SortTPCs(std::vector<geo::TPCGeo> & tgeo) const
112  {
113  std::sort(tgeo.begin(), tgeo.end(), sortTPCStandard);
114  }
115 
116  //----------------------------------------------------------------------------
117  void GeoObjectSorterICARUS::SortPlanes(std::vector<geo::PlaneGeo> & pgeo,
118  geo::DriftDirection_t const driftDir) const
119  {
120  // sort the planes to increase in drift direction
121  // The drift direction has to be set before this method is called. It is set when
122  // the CryostatGeo objects are sorted by the CryostatGeo::SortSubVolumes method
123  if (driftDir == geo::kPosX) std::sort(pgeo.rbegin(), pgeo.rend(), sortPlaneStandard);
124  else if(driftDir == geo::kNegX) std::sort(pgeo.begin(), pgeo.end(), sortPlaneStandard);
125  else if(driftDir == geo::kUnknownDrift)
126  throw cet::exception("TPCGeo") << "Drift direction is unknown, can't sort the planes\n";
127  }
128 
129  //----------------------------------------------------------------------------
130  void GeoObjectSorterICARUS::SortWires(std::vector<geo::WireGeo> & wgeo) const
131  {
132  std::sort(wgeo.begin(), wgeo.end(), sortWireStandard);
133  }
134 
135 }
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
Encapsulate the construction of a single cyostat.
Encapsulate the geometry of the sensitive portion of an auxiliary detector.
void SortWires(std::vector< geo::WireGeo > &wgeo) const
Functions for sorting ICARUS CRT modules (auxiliary detectors).
pdgs p
Definition: selectors.fcl:22
static bool sortWireStandard(WireGeo const &w1, WireGeo const &w2)
Geometry information for a single TPC.
Definition: TPCGeo.h:38
const double EPSILON
void SortAuxDets(std::vector< geo::AuxDetGeo > &adgeo) const
Drift towards negative X values.
Definition: geo_types.h:162
Geometry information for a single cryostat.
Definition: CryostatGeo.h:43
GeoObjectSorterICARUS(fhicl::ParameterSet const &p)
then local
void SortTPCs(std::vector< geo::TPCGeo > &tgeo) const
T abs(T value)
enum geo::driftdir DriftDirection_t
Drift direction: positive or negative.
void SortAuxDetsStandard(std::vector< geo::AuxDetGeo > &adgeo)
Sorts ICARUS CRT modules in standard configuration.
Geometry information for a single wire plane.The plane is represented in the geometry by a solid whic...
Definition: PlaneGeo.h:82
static bool sortPlaneStandard(const PlaneGeo &p1, const PlaneGeo &p2)
static bool sortCryoStandard(const CryostatGeo &c1, const CryostatGeo &c2)
Encapsulate the geometry of an auxiliary detector.
Encapsulate the geometry of a wire.
void LocalToWorld(const double *cryo, double *world) const
Transform point from local cryostat frame to world frame.
Definition: CryostatGeo.h:387
Drift towards positive X values.
Definition: geo_types.h:161
Encapsulate the construction of a single detector plane.
void SortAuxDetSensitiveStandard(std::vector< geo::AuxDetSensitiveGeo > &adsgeo)
Sorts ICARUS CRT submodules in standard configuration.
void SortPlanes(std::vector< geo::PlaneGeo > &pgeo, geo::DriftDirection_t driftDir) const
void SortAuxDetSensitive(std::vector< geo::AuxDetSensitiveGeo > &adsgeo) const
static bool sortTPCStandard(const TPCGeo &t1, const TPCGeo &t2)
void GetCenter(double *xyz, double localz=0.0) const
Fills the world coordinate of a point on the wire.
Definition: WireGeo.cxx:73
void SortCryostats(std::vector< geo::CryostatGeo > &cgeo) 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
physics associatedGroupsWithLeft p1
Encapsulate the construction of a single detector plane.
Interface to algorithm class for standard sorting of geo::XXXGeo objects.