CMS 3D CMS Logo

CmsTrackerLevelBuilder.cc
Go to the documentation of this file.
6 
7 #include <cmath>
8 
10 {
11  // it relies on the fact that the GeometricDet::GDEnumType enumerators used
12  // to identify the subdetectors in the upgrade geometries are equal to the
13  // ones of the present detector + n*100
14  return a->type() % 100 < b->type() % 100;
15 }
16 
17 // NP** Phase2 BarrelEndcap
19 {
20  if (std::abs(a->translation().rho() - b->translation().rho()) < 0.01
21  && (std::abs(a->translation().phi() - b->translation().phi()) < 0.01
22  || std::abs(a->translation().phi() - b->translation().phi()) > 6.27)
23  && a->translation().z() * b->translation().z() > 0.0) {
24  return (std::abs(a->translation().z()) < std::abs(b->translation().z()));
25  } else
26  return false;
27 }
28 
30 {
31  // NP** change for Phase 2 Tracker
32  if (a->translation().z() == b->translation().z()) {
33  return a->translation().rho() < b->translation().rho();
34  } else {
35  // Original version
36  return a->translation().z() < b->translation().z();
37  }
38 }
39 
41 {
42  return std::abs(a->translation().z()) < std::abs(b->translation().z());
43 }
44 
46 {
47  double phi = a->phi();
48  return (phi >= 0 ? phi : phi + 2 * M_PI);
49 }
50 
52 {
53  std::vector<const GeometricDet*> const& comp = a->components().back()->components();
54  float phi = 0.;
55  bool sum = true;
56 
57  for (auto i : comp) {
58  if (std::abs(i->phi()) > M_PI / 2.) {
59  sum = false;
60  break;
61  }
62  }
63 
64  if (sum) {
65  for (auto i : comp) {
66  phi += i->phi();
67  }
68 
69  double temp = phi / float(comp.size()) < 0. ? 2 * M_PI + phi / float(comp.size()) : phi / float(comp.size());
70  return temp;
71 
72  } else {
73  for (auto i : comp) {
74  double phi1 = i->phi() >= 0 ? i->phi() : i->phi() + 2 * M_PI;
75  phi += phi1;
76  }
77 
78  double com = comp.front()->phi() >= 0 ? comp.front()->phi() : 2 * M_PI + comp.front()->phi();
79  double temp
80  = std::abs(phi / float(comp.size()) - com) > 2. ? M_PI - phi / float(comp.size()) : phi / float(comp.size());
81  temp = temp >= 0 ? temp : 2 * M_PI + temp;
82  return temp;
83  }
84 }
85 
87 {
88  std::vector<const GeometricDet*> comp;
89  a->deepComponents(comp);
90  float phi = 0.;
91  bool sum = true;
92 
93  for (auto& i : comp) {
94  if (std::abs(i->phi()) > M_PI / 2.) {
95  sum = false;
96  break;
97  }
98  }
99 
100  if (sum) {
101  for (auto& i : comp) {
102  phi += i->phi();
103  }
104 
105  double temp = phi / float(comp.size()) < 0. ? 2 * M_PI + phi / float(comp.size()) : phi / float(comp.size());
106  return temp;
107 
108  } else {
109  for (auto& i : comp) {
110  double phi1 = i->phi() >= 0 ? i->phi() : i->translation().phi() + 2 * M_PI;
111  phi += phi1;
112  }
113 
114  double com = comp.front()->phi() >= 0 ? comp.front()->phi() : 2 * M_PI + comp.front()->phi();
115  double temp
116  = std::abs(phi / float(comp.size()) - com) > 2. ? M_PI - phi / float(comp.size()) : phi / float(comp.size());
117  temp = temp >= 0 ? temp : 2 * M_PI + temp;
118  return temp;
119  }
120 }
121 
123 {
124  double phi = a->phi();
125  phi = (phi >= 0 ? phi : phi + 2 * M_PI); // (-pi,pi] --> [0,2pi)
126  return ((M_PI - phi) >= 0 ? (M_PI - phi) : (M_PI - phi) + 2 * M_PI); // (-pi,pi] --> [0,2pi)
127 }
128 
130 {
131  double phi = getPhiModule(a); // [0,2pi)
132  phi = (phi <= M_PI ? phi : phi - 2 * M_PI); // (-pi,pi]
133  return (M_PI - phi);
134 }
135 
137 {
138  double phi = getPhiGluedModule(a); // [0,2pi)
139  phi = (phi <= M_PI ? phi : phi - 2 * M_PI); // (-pi,pi]
140  return (M_PI - phi);
141 }
142 
144 {
145  return a->deepComponents().front()->rho() < b->deepComponents().front()->rho();
146 }
147 
149 {
150  return a->rho() < b->rho();
151 }
152 
154 {
155 
156  LogTrace("GeometricDetBuilding") << std::string(3 * fv.history().size(), '-') << "+ "
157  << ExtractStringFromDDD::getString(attribute, &fv) << " " << tracker->type() << " "
158  << tracker->name() << std::endl;
159 
160  bool doLayers = fv.firstChild(); // descend to the first Layer
161 
162  while (doLayers) {
163  buildComponent(fv, tracker, attribute);
164  doLayers = fv.nextSibling(); // go to next layer
165  }
166 
167  fv.parent();
168 
169  sortNS(fv, tracker);
170 }
static std::string getString(std::string const &, DDFilteredView *)
bool parent()
set the current node to the parent node ...
static double getPhiMirror(const GeometricDet *a)
static bool isLessZ(const GeometricDet *a, const GeometricDet *b)
void build(DDFilteredView &, GeometricDet *, std::string) override
static double getPhi(const GeometricDet *a)
bool nextSibling()
set the current node to the next sibling ...
virtual void sortNS(DDFilteredView &, GeometricDet *)
static bool isLessModZ(const GeometricDet *a, const GeometricDet *b)
const std::vector< DDGeoHistory > & history() const
static double getPhiModule(const GeometricDet *a)
ConstGeometricDetContainer & components()
Definition: GeometricDet.h:176
DDName const & name() const
Definition: GeometricDet.h:146
static bool isLessRModule(const GeometricDet *a, const GeometricDet *b)
static bool isLessR(const GeometricDet *a, const GeometricDet *b)
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
DDTranslation const & translation() const
Definition: GeometricDet.h:125
static double getPhiModuleMirror(const GeometricDet *a)
#define LogTrace(id)
#define M_PI
static double getPhiGluedModuleMirror(const GeometricDet *a)
static bool subDetByType(const GeometricDet *a, const GeometricDet *b)
double b
Definition: hdecay.h:120
double phi() const
Definition: GeometricDet.h:129
ConstGeometricDetContainer deepComponents() const
static bool phiSortNP(const GeometricDet *a, const GeometricDet *b)
double a
Definition: hdecay.h:121
static double getPhiGluedModule(const GeometricDet *a)
bool firstChild()
set the current node to the first child ...
GeometricEnumType type() const
Definition: GeometricDet.h:142
double rho() const
Definition: GeometricDet.h:133
virtual void buildComponent(DDFilteredView &, GeometricDet *, std::string)=0