CMS 3D CMS Logo

CmsMTDLevelBuilder.cc
Go to the documentation of this file.
6 
7 #include <cmath>
8 
10 {
11  // it relies on the fact that the GeometricTimingDet::GDEnumType
12  // enumerators used to identify the subdetectors in the upgrade geometries
13  // are equal to the ones of the present detector + n*100
14  return a->type() < b->type();
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 GeometricTimingDet*> 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 GeometricTimingDet*> 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 
148 bool CmsMTDLevelBuilder::isLessR(const GeometricTimingDet* a, const GeometricTimingDet* b) { return a->rho() < b->rho(); }
149 
151 {
152 
153  LogTrace("GeometricTimingDetBuilding")
154  << std::string(3 * fv.history().size(), '-') << "+ " << ExtractStringFromDDD::getString(attribute, &fv) << " "
155  << tracker->type() << " " << tracker->name() << std::endl;
156 
157  bool doLayers = fv.firstChild(); // descend to the next Layer
158 
159  while (doLayers) {
160  buildComponent(fv, tracker, attribute);
161  doLayers = fv.nextSibling(); // go to the next adjacent thingy
162  }
163 
164  fv.parent();
165 
166  sortNS(fv, tracker);
167 }
bool parent()
set the current node to the parent node ...
static bool subDetByType(const GeometricTimingDet *a, const GeometricTimingDet *b)
static bool phiSortNP(const GeometricTimingDet *a, const GeometricTimingDet *b)
static bool isLessR(const GeometricTimingDet *a, const GeometricTimingDet *b)
bool nextSibling()
set the current node to the next sibling ...
static double getPhi(const GeometricTimingDet *a)
GeometricTimingEnumType type() const
static double getPhiGluedModule(const GeometricTimingDet *a)
static double getPhiGluedModuleMirror(const GeometricTimingDet *a)
const std::vector< DDGeoHistory > & history() const
ConstGeometricTimingDetContainer & components()
static std::string getString(std::string const &, DDFilteredView *)
DDTranslation const & translation() const
ConstGeometricTimingDetContainer deepComponents() const
virtual void sortNS(DDFilteredView &, GeometricTimingDet *)
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
static bool isLessRModule(const GeometricTimingDet *a, const GeometricTimingDet *b)
#define LogTrace(id)
void build(DDFilteredView &, GeometricTimingDet *, std::string) override
static bool isLessZ(const GeometricTimingDet *a, const GeometricTimingDet *b)
#define M_PI
static double getPhiModule(const GeometricTimingDet *a)
double b
Definition: hdecay.h:120
virtual void buildComponent(DDFilteredView &, GeometricTimingDet *, std::string)=0
DDName const & name() const
double a
Definition: hdecay.h:121
static bool isLessModZ(const GeometricTimingDet *a, const GeometricTimingDet *b)
bool firstChild()
set the current node to the first child ...
static double getPhiModuleMirror(const GeometricTimingDet *a)
static double getPhiMirror(const GeometricTimingDet *a)