CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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() < b->type();
24  }
25  };
26 
27  struct LessZ{
28  bool operator()(const GeometricDet* a, const GeometricDet* b) const
29  {
30  return a->translation().z() < b->translation().z();
31  }
32  };
33 
34  struct LessModZ{
35  bool operator()(const GeometricDet* a, const GeometricDet* b) const
36  {
37  return fabs(a->translation().z()) < fabs(b->translation().z());
38  }
39  };
40 
41 
42  struct ExtractPhi:public uFcn{
43  double operator()(const GeometricDet* a)const{
44  const double pi = 3.141592653592;
45  double phi = a->phi();
46  return( phi>= 0 ? phi:phi+2*pi);
47  }
48  };
49 
50  struct ExtractPhiModule:public uFcn{
51  double operator()(const GeometricDet* a)const{
52  const double pi = 3.141592653592;
53  std::vector<const GeometricDet*> const & comp = a->components().back()->components();
54  float phi = 0.;
55  bool sum = true;
56 
57  for(unsigned int i=0;i<comp.size();i++){
58  if(fabs(comp[i]->phi())>pi/2.) {
59  sum = false;
60  break;
61  }
62  }
63 
64  if(sum){
65  for(unsigned int i=0;i<comp.size();i++){
66  phi+= comp[i]->phi();
67  }
68 
69  double temp = phi/float(comp.size()) < 0. ?
70  2*pi + phi/float(comp.size()):
71  phi/float(comp.size());
72  return temp;
73 
74  }else{
75  for(unsigned int i=0;i<comp.size();i++){
76  double phi1 = comp[i]->phi() >= 0 ? comp[i]->phi():
77  comp[i]->phi()+2*pi;
78  phi+= phi1;
79  }
80 
81  double com = comp.front()->phi() >= 0 ? comp.front()->phi():
82  2*pi + comp.front()->phi();
83  double temp = fabs(phi/float(comp.size()) - com) > 2. ?
84  pi - phi/float(comp.size()):
85  phi/float(comp.size());
86  temp = temp >= 0? temp:2*pi+temp;
87  return temp;
88  }
89  }
90  };
91 
92  struct ExtractPhiGluedModule:public uFcn{
93  double operator()(const GeometricDet* a)const{
94  const double pi = 3.141592653592;
95  std::vector<const GeometricDet*> comp;
96  a->deepComponents(comp);
97  float phi = 0.;
98  bool sum = true;
99 
100  for(unsigned int i=0;i<comp.size();i++){
101  if(fabs(comp[i]->phi())>pi/2.) {
102  sum = false;
103  break;
104  }
105  }
106 
107  if(sum){
108  for(unsigned int i=0;i<comp.size();i++){
109  phi+= comp[i]->phi();
110  }
111 
112  double temp = phi/float(comp.size()) < 0. ?
113  2*pi + phi/float(comp.size()):
114  phi/float(comp.size());
115  return temp;
116 
117  }else{
118  for(unsigned int i=0;i<comp.size();i++){
119  double phi1 = comp[i]->phi() >= 0 ? comp[i]->phi():
120  comp[i]->translation().phi()+2*pi;
121  phi+= phi1;
122  }
123 
124  double com = comp.front()->phi() >= 0 ? comp.front()->phi():
125  2*pi + comp.front()->phi();
126  double temp = fabs(phi/float(comp.size()) - com) > 2. ?
127  pi - phi/float(comp.size()):
128  phi/float(comp.size());
129  temp = temp >= 0? temp:2*pi+temp;
130  return temp;
131  }
132  }
133  };
134 
135  struct ExtractPhiMirror:public uFcn{
136  double operator()(const GeometricDet* a)const{
137  const double pi = 3.141592653592;
138  double phi = a->phi();
139  phi = (phi>= 0 ? phi : phi+2*pi); // (-pi,pi] --> [0,2pi)
140  return ( (pi-phi) >= 0 ? (pi-phi) : (pi-phi)+2*pi ); // (-pi,pi] --> [0,2pi)
141  }
142  };
143 
145  double operator()(const GeometricDet* a)const{
146  const double pi = 3.141592653592;
147  double phi = ExtractPhiModule()(a); // [0,2pi)
148  phi = ( phi <= pi ? phi : phi-2*pi ); // (-pi,pi]
149  return (pi-phi);
150  }
151  };
152 
154  double operator()(const GeometricDet* a)const{
155  const double pi = 3.141592653592;
156  double phi = ExtractPhiGluedModule()(a); // [0,2pi)
157  phi = ( phi <= pi ? phi : phi-2*pi ); // (-pi,pi]
158  return (pi-phi);
159  }
160  };
161 
162  struct LessR_module{
163  bool operator()(const GeometricDet* a, const GeometricDet* b) const
164  {
165  return a->deepComponents().front()->rho() <
166  b->deepComponents().front()->rho();
167  }
168  };
169 
170  struct LessR{
171  bool operator()(const GeometricDet* a, const GeometricDet* b) const
172  {
173  return a->rho() < b->rho();
174  }
175  };
176 
177 
178  private:
179  virtual void buildComponent(DDFilteredView& , GeometricDet*, std::string) = 0;
180 protected:
182 private:
183  virtual void sortNS(DDFilteredView& , GeometricDet*){}
185 };
186 
187 #endif
int i
Definition: DBlmapReader.cc:9
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
double operator()(const GeometricDet *a) const
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:112
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:116
ConstGeometricDetContainer deepComponents() const
GeometricDetContainer & components()
Definition: GeometricDet.h:163
double a
Definition: hdecay.h:121
std::unary_function< const GeometricDet *, double > uFcn
double pi
GeometricEnumType type() const
Definition: GeometricDet.h:129
CmsTrackerStringToEnum theCmsTrackerStringToEnum
double rho() const
Definition: GeometricDet.h:120
virtual void buildComponent(DDFilteredView &, GeometricDet *, std::string)=0
Definition: DDAxes.h:10