CMS 3D CMS Logo

CmsMTDLevelBuilder.cc
Go to the documentation of this file.
6 
7 #include <cmath>
8 
10  // it relies on the fact that the GeometricTimingDet::GDEnumType
11  // enumerators used to identify the subdetectors in the upgrade geometries
12  // are equal to the ones of the present detector + n*100
13  return a->type() < b->type();
14 }
15 
16 // NP** Phase2 BarrelEndcap
18  if (std::abs(a->translation().rho() - b->translation().rho()) < 0.01 &&
19  (std::abs(a->translation().phi() - b->translation().phi()) < 0.01 ||
20  std::abs(a->translation().phi() - b->translation().phi()) > 6.27) &&
21  a->translation().z() * b->translation().z() > 0.0) {
22  return (std::abs(a->translation().z()) < std::abs(b->translation().z()));
23  } else
24  return false;
25 }
26 
28  // NP** change for Phase 2 Tracker
29  if (a->translation().z() == b->translation().z()) {
30  return a->translation().rho() < b->translation().rho();
31  } else {
32  // Original version
33  return a->translation().z() < b->translation().z();
34  }
35 }
36 
38  return std::abs(a->translation().z()) < std::abs(b->translation().z());
39 }
40 
42  double phi = a->phi();
43  return (phi >= 0 ? phi : phi + 2 * M_PI);
44 }
45 
47  std::vector<const GeometricTimingDet*> const& comp = a->components().back()->components();
48  float phi = 0.;
49  bool sum = true;
50 
51  for (auto i : comp) {
52  if (std::abs(i->phi()) > M_PI / 2.) {
53  sum = false;
54  break;
55  }
56  }
57 
58  if (sum) {
59  for (auto i : comp) {
60  phi += i->phi();
61  }
62 
63  double temp = phi / float(comp.size()) < 0. ? 2 * M_PI + phi / float(comp.size()) : phi / float(comp.size());
64  return temp;
65 
66  } else {
67  for (auto i : comp) {
68  double phi1 = i->phi() >= 0 ? i->phi() : i->phi() + 2 * M_PI;
69  phi += phi1;
70  }
71 
72  double com = comp.front()->phi() >= 0 ? comp.front()->phi() : 2 * M_PI + comp.front()->phi();
73  double temp =
74  std::abs(phi / float(comp.size()) - com) > 2. ? M_PI - phi / float(comp.size()) : phi / float(comp.size());
75  temp = temp >= 0 ? temp : 2 * M_PI + temp;
76  return temp;
77  }
78 }
79 
81  std::vector<const GeometricTimingDet*> comp;
82  a->deepComponents(comp);
83  float phi = 0.;
84  bool sum = true;
85 
86  for (auto& i : comp) {
87  if (std::abs(i->phi()) > M_PI / 2.) {
88  sum = false;
89  break;
90  }
91  }
92 
93  if (sum) {
94  for (auto& i : comp) {
95  phi += i->phi();
96  }
97 
98  double temp = phi / float(comp.size()) < 0. ? 2 * M_PI + phi / float(comp.size()) : phi / float(comp.size());
99  return temp;
100 
101  } else {
102  for (auto& i : comp) {
103  double phi1 = i->phi() >= 0 ? i->phi() : i->translation().phi() + 2 * M_PI;
104  phi += phi1;
105  }
106 
107  double com = comp.front()->phi() >= 0 ? comp.front()->phi() : 2 * M_PI + comp.front()->phi();
108  double temp =
109  std::abs(phi / float(comp.size()) - com) > 2. ? M_PI - phi / float(comp.size()) : phi / float(comp.size());
110  temp = temp >= 0 ? temp : 2 * M_PI + temp;
111  return temp;
112  }
113 }
114 
116  double phi = a->phi();
117  phi = (phi >= 0 ? phi : phi + 2 * M_PI); // (-pi,pi] --> [0,2pi)
118  return ((M_PI - phi) >= 0 ? (M_PI - phi) : (M_PI - phi) + 2 * M_PI); // (-pi,pi] --> [0,2pi)
119 }
120 
122  double phi = getPhiModule(a); // [0,2pi)
123  phi = (phi <= M_PI ? phi : phi - 2 * M_PI); // (-pi,pi]
124  return (M_PI - phi);
125 }
126 
128  double phi = getPhiGluedModule(a); // [0,2pi)
129  phi = (phi <= M_PI ? phi : phi - 2 * M_PI); // (-pi,pi]
130  return (M_PI - phi);
131 }
132 
134  return a->deepComponents().front()->rho() < b->deepComponents().front()->rho();
135 }
136 
138  return a->rho() < b->rho();
139 }
140 
142  LogTrace("GeometricTimingDetBuilding") << std::string(3 * fv.history().size(), '-') << "+ "
143  << ExtractStringFromDDD::getString(attribute, &fv) << " " << tracker->type()
144  << " " << tracker->name() << std::endl;
145 
146  bool doLayers = fv.firstChild(); // descend to the next Layer
147 
148  while (doLayers) {
149  buildComponent(fv, tracker, attribute);
150  doLayers = fv.nextSibling(); // go to the next adjacent thingy
151  }
152 
153  fv.parent();
154 
155  sortNS(fv, tracker);
156 }
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
double phi() const
ConstGeometricTimingDetContainer & components()
ConstGeometricTimingDetContainer deepComponents() const
virtual void sortNS(DDFilteredView &, GeometricTimingDet *)
double rho() const
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
std::string const & name() const
static std::string getString(std::string const &, DDFilteredView *)
static double getPhiModule(const GeometricTimingDet *a)
double b
Definition: hdecay.h:118
virtual void buildComponent(DDFilteredView &, GeometricTimingDet *, std::string)=0
double a
Definition: hdecay.h:119
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)
Translation const & translation() const