All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
icaruscode/icaruscode/CRT/CRTGeoObjectSorter.cxx
Go to the documentation of this file.
1 ////////////////////////////////////////////////////////////////////////
2 /// \file CRTGeoObjectSorter.cxx
3 /// \brief Interface to algorithm class for sorting of AuxDetGeo objects
4 ///
5 /// Originally ported from AuxDetGeoObjectSorterLArIAT.h (Author: brebel@fnal.gov)
6 /// and modified for SBND (Author: mastbaum@uchicago.edu) then ICARUS
7 ///
8 /// \version $Id: 0.0 $
9 /// \author chilge@rams.colostate.edu
10 ////////////////////////////////////////////////////////////////////////
11 
15 
16 namespace geo{
17 
18  //----------------------------------------------------------------------------
19  // Define sort order for AuxDets in standard configuration
20  static bool sortAuxDetICARUS(const AuxDetGeo& ad1, const AuxDetGeo& ad2) {
21 
22  // sort based off of GDML name, module number
23  std::string ad1name = (ad1.TotalVolume())->GetName();
24  std::string ad2name = (ad2.TotalVolume())->GetName();
25  // assume volume name is "volAuxDet_<subsystem>_module_###_<region>"
26  std::string modulePrefix = "module_";
27 
28  int ad1Num = atoi( ad1name.substr(ad1name.find(modulePrefix)+modulePrefix.length(),3).c_str() );
29  int ad2Num = atoi( ad2name.substr(ad2name.find(modulePrefix)+modulePrefix.length(), 3).c_str() );
30 
31  return ad1Num < ad2Num;
32  }
33 
34  //----------------------------------------------------------------------------
35  // Define sort order for AuxDetSensitives in standard configuration
37  const AuxDetSensitiveGeo& ad2)
38  {
39  // sort based off of GDML name, assuming ordering is encoded
40  std::string ad1name = (ad1.TotalVolume())->GetName();
41  std::string ad2name = (ad2.TotalVolume())->GetName();
42  // assume volume name is "volAuxDetSensitive_<subsystem>_module_###_(<cut<###>,top or bot>_)strip_##"
43  std::string modulePrefix = "module_";
44  std::string stripPrefix = "strip_";
45 
46  int ad1Num = atoi( ad1name.substr(ad1name.find(modulePrefix)+modulePrefix.length(), 3).c_str() );
47  int ad2Num = atoi( ad2name.substr(ad2name.find(modulePrefix)+modulePrefix.length(), 3).c_str() );
48 
49  if(ad1Num!=ad2Num) return ad1Num < ad2Num;
50 
51  ad1Num = atoi( ad1name.substr(ad1name.find(stripPrefix)+stripPrefix.length(), 2).c_str() );
52  ad2Num = atoi( ad2name.substr(ad2name.find(stripPrefix)+stripPrefix.length(), 2).c_str() );
53 
54  return ad1Num < ad2Num;
55 
56  }
57 
58  //----------------------------------------------------------------------------
59  // Define sort order for AuxDets in co-ordinate system
60 
61  static bool CRTIncreaseX(const AuxDetGeo& ad1, const AuxDetGeo& ad2) {
62  double xyz1[3] = {0.};
63  double xyz2[3] = {0.};
64  ad1.GetCenter(xyz1); ad2.GetCenter(xyz2);
65  return xyz1[0] < xyz2[0];
66  }
67 
68  static bool CRTDecreaseY(const AuxDetGeo& ad1, const AuxDetGeo& ad2) {
69  double xyz1[3] = {0.};
70  double xyz2[3] = {0.};
71  ad1.GetCenter(xyz1); ad2.GetCenter(xyz2);
72  return xyz1[1] > xyz2[1];
73  }
74 
75  static bool CRTIncreaseZ(const AuxDetGeo& ad1, const AuxDetGeo& ad2) {
76  double xyz1[3] = {0.};
77  double xyz2[3] = {0.};
78 
79  ad1.GetCenter(xyz1); ad2.GetCenter(xyz2);
80  return xyz1[2] < xyz2[2];
81  }
82 
83 
84  //----------------------------------------------------------------------------
85  // Define sort order for AuxDetSensitive in co-ordinate system
86 
87  static bool CRTSensitiveIncreaseX(std::pair<int , geo::AuxDetSensitiveGeo> ads1,
88  std::pair<int , geo::AuxDetSensitiveGeo> ads2){
89  double xyz1[3] = {0.};
90  double xyz2[3] = {0.};
91  ads1.second.GetCenter(xyz1); ads2.second.GetCenter(xyz2);
92  return xyz1[0] < xyz2[0];
93  }
94 
95 
96  static bool CRTSensitiveDecreaseY(std::pair<int , geo::AuxDetSensitiveGeo> ads1,
97  std::pair<int , geo::AuxDetSensitiveGeo> ads2){
98  double xyz1[3] = {0.};
99  double xyz2[3] = {0.};
100  ads1.second.GetCenter(xyz1); ads2.second.GetCenter(xyz2);
101  return xyz1[1] > xyz2[1];
102  }
103 
104  static bool CRTSensitiveIncreaseZ(std::pair<int , geo::AuxDetSensitiveGeo> ads1,
105  std::pair<int , geo::AuxDetSensitiveGeo> ads2){
106  double xyz1[3] = {0.};
107  double xyz2[3] = {0.};
108 
109  ads1.second.GetCenter(xyz1); ads2.second.GetCenter(xyz2);
110  return xyz1[2] < xyz2[2];
111  }
112 
113 
114  //----------------------------------------------------------------------------
116  fhicl::ParameterSet const&) {}
117 
118  //----------------------------------------------------------------------------
119  void CRTGeoObjectSorter::SortAuxDets(std::vector<geo::AuxDetGeo> & adgeo) const {
120  std::sort(adgeo.begin(), adgeo.end(), sortAuxDetICARUS);
121  }
122 
123  //----------------------------------------------------------------------------
124  void CRTGeoObjectSorter::SortAuxDetSensitive(std::vector<geo::AuxDetSensitiveGeo> & adsgeo) const {
125  std::sort(adsgeo.begin(), adsgeo.end(), sortAuxDetSensitiveICARUS);
126  }
127 
128  //----------------------------------------------------------------------------
129  // sorting CRT co-ordiantes decreasing vertical coordinate,
130  // next increasing beam coordinate, and next increasing drift direction
131 
132  void CRTGeoObjectSorter::SortCRTs(std::vector<geo::AuxDetGeo> & adgeo) const {
133 
134  // 3. stable sort by increasing drift direction (_x_)
135  std::stable_sort (adgeo.begin(), adgeo.end(), CRTIncreaseX);
136 
137 
138  // 2. stable sort by increasing beam coordinate (_z_)
139  std::stable_sort (adgeo.begin(), adgeo.end(), CRTIncreaseZ);
140 
141  // 1. sort by decreasing vertical coordinate (_y_)
142  std::stable_sort (adgeo.begin(), adgeo.end(), CRTDecreaseY);
143  }
144 
145 
146  //----------------------------------------------------------------------------
147  // sorting CRTs Sensitive with co-ordiantes decreasing vertical coordinate,
148  // next increasing beam coordinate, and next increasing drift direction
149 
150  void CRTGeoObjectSorter::SortCRTSensitive(std::vector<std::pair <int ,geo::AuxDetSensitiveGeo> > & adsgeo) const {
151 
152  // 3. stable sort by increasing drift direction (_x_)
153  std::stable_sort (adsgeo.begin(), adsgeo.end(), CRTSensitiveIncreaseX);
154 
155 
156  // 2. stable sort by increasing beam coordinate (_z_)
157  std::stable_sort (adsgeo.begin(), adsgeo.end(), CRTSensitiveIncreaseZ);
158 
159  // 1. sort by decreasing vertical coordinate (_y_)
160  std::stable_sort (adsgeo.begin(), adsgeo.end(), CRTSensitiveDecreaseY);
161  }
162 
163 
164 } //namespace crt
165 //} //namespace icarus
void SortCRTSensitive(std::vector< std::pair< int, geo::AuxDetSensitiveGeo > > &adsgeo) const
static bool sortAuxDetICARUS(const AuxDetGeo &ad1, const AuxDetGeo &ad2)
Encapsulate the geometry of the sensitive portion of an auxiliary detector.
void SortAuxDets(std::vector< geo::AuxDetGeo > &adgeo) const
static bool CRTIncreaseX(const AuxDetGeo &ad1, const AuxDetGeo &ad2)
auto vector(Vector const &v)
Returns a manipulator which will print the specified array.
Definition: DumpUtils.h:265
void SortCRTs(std::vector< geo::AuxDetGeo > &adgeo) const
const TGeoVolume * TotalVolume() const
Encapsulate the geometry of an auxiliary detector.
const TGeoVolume * TotalVolume() const
Definition: AuxDetGeo.h:106
static bool CRTIncreaseZ(const AuxDetGeo &ad1, const AuxDetGeo &ad2)
static bool CRTSensitiveIncreaseX(std::pair< int, geo::AuxDetSensitiveGeo > ads1, std::pair< int, geo::AuxDetSensitiveGeo > ads2)
static bool CRTSensitiveIncreaseZ(std::pair< int, geo::AuxDetSensitiveGeo > ads1, std::pair< int, geo::AuxDetSensitiveGeo > ads2)
static bool sortAuxDetSensitiveICARUS(const AuxDetSensitiveGeo &ad1, const AuxDetSensitiveGeo &ad2)
void SortAuxDetSensitive(std::vector< geo::AuxDetSensitiveGeo > &adsgeo) const
void GetCenter(double *xyz, double localz=0.0) const
Return the center position of an AuxDet.
Definition: AuxDetGeo.cxx:62
static bool CRTSensitiveDecreaseY(std::pair< int, geo::AuxDetSensitiveGeo > ads1, std::pair< int, geo::AuxDetSensitiveGeo > ads2)
static bool CRTDecreaseY(const AuxDetGeo &ad1, const AuxDetGeo &ad2)