CMS 3D CMS Logo

CmsTrackerLevelBuilder.h
Go to the documentation of this file.
1 #ifndef Geometry_TrackerNumberingBuilder_CmsTrackerLevelBuilder_H
2 #define Geometry_TrackerNumberingBuilder_CmsTrackerLevelBuilder_H
3 
8 #include <string>
13 typedef std::unary_function<const GeometricDet*, double> uFcn;
14 
16 public:
17  virtual void build(DDFilteredView& , GeometricDet*, std::string);
19 
20 
21  struct subDetByType{
22  bool operator()(const GeometricDet* a, const GeometricDet* b) const {
23  return a->type()%100 < b->type()%100; // it relies on the fact that the GeometricDet::GDEnumType enumerators used to identify the subdetectors in the upgrade geometries are equal to the ones of the present detector + n*100
24  }
25  };
26 
27  // NP** Phase2 BarrelEndcap
28  struct PhiSortNP{
29  bool operator()(const GeometricDet* a,const GeometricDet* b) const {
30  if ( fabs(a->translation().rho() - b->translation().rho()) < 0.01 &&
31  (fabs(a->translation().phi() - b->translation().phi()) < 0.01 ||
32  fabs(a->translation().phi() - b->translation().phi()) > 6.27 ) &&
33  a->translation().z() * b->translation().z() > 0.0 ) {
34  return ( fabs(a->translation().z()) < fabs(b->translation().z()) );
35  }
36  else
37  return false;
38  }
39  };
40 
41 
42  struct LessZ{
43  bool operator()(const GeometricDet* a, const GeometricDet* b) const
44  {
45  // NP** change for Phase 2 Tracker
46  if (a->translation().z() == b->translation().z())
47  {return a->translation().rho() < b->translation().rho();}
48  else{
49  // Original version
50  return a->translation().z() < b->translation().z();}
51  }
52  };
53 
54  struct LessModZ{
55  bool operator()(const GeometricDet* a, const GeometricDet* b) const
56  {
57  return fabs(a->translation().z()) < fabs(b->translation().z());
58  }
59  };
60 
61 
62  struct ExtractPhi:public uFcn{
63  double operator()(const GeometricDet* a)const{
64  const double pi = 3.141592653592;
65  double phi = a->phi();
66  return( phi>= 0 ? phi:phi+2*pi);
67  }
68  };
69 
70  struct ExtractPhiModule:public uFcn{
71  double operator()(const GeometricDet* a)const{
72  const double pi = 3.141592653592;
73  std::vector<const GeometricDet*> const & comp = a->components().back()->components();
74  float phi = 0.;
75  bool sum = true;
76 
77  for(unsigned int i=0;i<comp.size();i++){
78  if(fabs(comp[i]->phi())>pi/2.) {
79  sum = false;
80  break;
81  }
82  }
83 
84  if(sum){
85  for(unsigned int i=0;i<comp.size();i++){
86  phi+= comp[i]->phi();
87  }
88 
89  double temp = phi/float(comp.size()) < 0. ?
90  2*pi + phi/float(comp.size()):
91  phi/float(comp.size());
92  return temp;
93 
94  }else{
95  for(unsigned int i=0;i<comp.size();i++){
96  double phi1 = comp[i]->phi() >= 0 ? comp[i]->phi():
97  comp[i]->phi()+2*pi;
98  phi+= phi1;
99  }
100 
101  double com = comp.front()->phi() >= 0 ? comp.front()->phi():
102  2*pi + comp.front()->phi();
103  double temp = fabs(phi/float(comp.size()) - com) > 2. ?
104  pi - phi/float(comp.size()):
105  phi/float(comp.size());
106  temp = temp >= 0? temp:2*pi+temp;
107  return temp;
108  }
109  }
110  };
111 
113  double operator()(const GeometricDet* a)const{
114  const double pi = 3.141592653592;
115  std::vector<const GeometricDet*> comp;
116  a->deepComponents(comp);
117  float phi = 0.;
118  bool sum = true;
119 
120  for(unsigned int i=0;i<comp.size();i++){
121  if(fabs(comp[i]->phi())>pi/2.) {
122  sum = false;
123  break;
124  }
125  }
126 
127  if(sum){
128  for(unsigned int i=0;i<comp.size();i++){
129  phi+= comp[i]->phi();
130  }
131 
132  double temp = phi/float(comp.size()) < 0. ?
133  2*pi + phi/float(comp.size()):
134  phi/float(comp.size());
135  return temp;
136 
137  }else{
138  for(unsigned int i=0;i<comp.size();i++){
139  double phi1 = comp[i]->phi() >= 0 ? comp[i]->phi():
140  comp[i]->translation().phi()+2*pi;
141  phi+= phi1;
142  }
143 
144  double com = comp.front()->phi() >= 0 ? comp.front()->phi():
145  2*pi + comp.front()->phi();
146  double temp = fabs(phi/float(comp.size()) - com) > 2. ?
147  pi - phi/float(comp.size()):
148  phi/float(comp.size());
149  temp = temp >= 0? temp:2*pi+temp;
150  return temp;
151  }
152  }
153  };
154 
155  struct ExtractPhiMirror:public uFcn{
156  double operator()(const GeometricDet* a)const{
157  const double pi = 3.141592653592;
158  double phi = a->phi();
159  phi = (phi>= 0 ? phi : phi+2*pi); // (-pi,pi] --> [0,2pi)
160  return ( (pi-phi) >= 0 ? (pi-phi) : (pi-phi)+2*pi ); // (-pi,pi] --> [0,2pi)
161  }
162  };
163 
165  double operator()(const GeometricDet* a)const{
166  const double pi = 3.141592653592;
167  double phi = ExtractPhiModule()(a); // [0,2pi)
168  phi = ( phi <= pi ? phi : phi-2*pi ); // (-pi,pi]
169  return (pi-phi);
170  }
171  };
172 
174  double operator()(const GeometricDet* a)const{
175  const double pi = 3.141592653592;
176  double phi = ExtractPhiGluedModule()(a); // [0,2pi)
177  phi = ( phi <= pi ? phi : phi-2*pi ); // (-pi,pi]
178  return (pi-phi);
179  }
180  };
181 
182  struct LessR_module{
183  bool operator()(const GeometricDet* a, const GeometricDet* b) const
184  {
185  return a->deepComponents().front()->rho() <
186  b->deepComponents().front()->rho();
187  }
188  };
189 
190  struct LessR{
191  bool operator()(const GeometricDet* a, const GeometricDet* b) const
192  {
193  return a->rho() < b->rho();
194  }
195  };
196 
197 
198  private:
199  virtual void buildComponent(DDFilteredView& , GeometricDet*, std::string) = 0;
200 protected:
202 private:
203  virtual void sortNS(DDFilteredView& , GeometricDet*){}
205 };
206 
207 #endif
double operator()(const GeometricDet *a) const
double operator()(const GeometricDet *a) const
double operator()(const GeometricDet *a) const
virtual void sortNS(DDFilteredView &, GeometricDet *)
CmsTrackerStringToEnum _CmsTrackerStringToEnum
bool operator()(const GeometricDet *a, const GeometricDet *b) const
double operator()(const GeometricDet *a) const
ConstGeometricDetContainer & components()
Definition: GeometricDet.h:176
const Double_t pi
virtual void build(DDFilteredView &, GeometricDet *, std::string)
bool operator()(const GeometricDet *a, const GeometricDet *b) const
bool operator()(const GeometricDet *a, const GeometricDet *b) const
DDTranslation const & translation() const
Definition: GeometricDet.h:125
bool operator()(const GeometricDet *a, const GeometricDet *b) const
bool operator()(const GeometricDet *a, const GeometricDet *b) const
bool operator()(const GeometricDet *a, const GeometricDet *b) const
double operator()(const GeometricDet *a) const
double b
Definition: hdecay.h:120
double phi() const
Definition: GeometricDet.h:129
ConstGeometricDetContainer deepComponents() const
double a
Definition: hdecay.h:121
std::unary_function< const GeometricDet *, double > uFcn
GeometricEnumType type() const
Definition: GeometricDet.h:142
CmsTrackerStringToEnum theCmsTrackerStringToEnum
double rho() const
Definition: GeometricDet.h:133
virtual void buildComponent(DDFilteredView &, GeometricDet *, std::string)=0