CMS 3D CMS Logo

CmsTrackerLevelBuilder.cc
Go to the documentation of this file.
7 
8 #include <cmath>
9 
10 #define DEBUG false
11 
13  // it relies on the fact that the GeometricDet::GDEnumType enumerators used
14  // to identify the subdetectors in the upgrade geometries are equal to the
15  // ones of the present detector + n*100
16  return a->type() % 100 < b->type() % 100;
17 }
18 
19 // NP** Phase2 BarrelEndcap
21  if (std::abs(a->translation().rho() - b->translation().rho()) < 0.01 &&
22  (std::abs(a->translation().phi() - b->translation().phi()) < 0.01 ||
23  std::abs(a->translation().phi() - b->translation().phi()) > 6.27) &&
24  a->translation().z() * b->translation().z() > 0.0) {
25  return (std::abs(a->translation().z()) < std::abs(b->translation().z()));
26  } else
27  return false;
28 }
29 
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  return std::abs(a->translation().z()) < std::abs(b->translation().z());
42 }
43 
45  double phi = a->phi();
46  return (phi >= 0 ? phi : phi + 2 * M_PI);
47 }
48 
50  std::vector<const GeometricDet*> const& comp = a->components().back()->components();
51  float phi = 0.;
52  bool sum = true;
53 
54  for (auto i : comp) {
55  if (std::abs(i->phi()) > M_PI / 2.) {
56  sum = false;
57  break;
58  }
59  }
60 
61  if (sum) {
62  for (auto i : comp) {
63  phi += i->phi();
64  }
65 
66  double temp = phi / float(comp.size()) < 0. ? 2 * M_PI + phi / float(comp.size()) : phi / float(comp.size());
67  return temp;
68 
69  } else {
70  for (auto i : comp) {
71  double phi1 = i->phi() >= 0 ? i->phi() : i->phi() + 2 * M_PI;
72  phi += phi1;
73  }
74 
75  double com = comp.front()->phi() >= 0 ? comp.front()->phi() : 2 * M_PI + comp.front()->phi();
76  double temp =
77  std::abs(phi / float(comp.size()) - com) > 2. ? M_PI - phi / float(comp.size()) : phi / float(comp.size());
78  temp = temp >= 0 ? temp : 2 * M_PI + temp;
79  return temp;
80  }
81 }
82 
84  std::vector<const GeometricDet*> comp;
85  a->deepComponents(comp);
86  float phi = 0.;
87  bool sum = true;
88 
89  for (auto& i : comp) {
90  if (std::abs(i->phi()) > M_PI / 2.) {
91  sum = false;
92  break;
93  }
94  }
95 
96  if (sum) {
97  for (auto& i : comp) {
98  phi += i->phi();
99  }
100 
101  double temp = phi / float(comp.size()) < 0. ? 2 * M_PI + phi / float(comp.size()) : phi / float(comp.size());
102  return temp;
103 
104  } else {
105  for (auto& i : comp) {
106  double phi1 = i->phi() >= 0 ? i->phi() : i->translation().phi() + 2 * M_PI;
107  phi += phi1;
108  }
109 
110  double com = comp.front()->phi() >= 0 ? comp.front()->phi() : 2 * M_PI + comp.front()->phi();
111  double temp =
112  std::abs(phi / float(comp.size()) - com) > 2. ? M_PI - phi / float(comp.size()) : phi / float(comp.size());
113  temp = temp >= 0 ? temp : 2 * M_PI + temp;
114  return temp;
115  }
116 }
117 
119  double phi = a->phi();
120  phi = (phi >= 0 ? phi : phi + 2 * M_PI); // (-pi,pi] --> [0,2pi)
121  return ((M_PI - phi) >= 0 ? (M_PI - phi) : (M_PI - phi) + 2 * M_PI); // (-pi,pi] --> [0,2pi)
122 }
123 
125  double phi = getPhiModule(a); // [0,2pi)
126  phi = (phi <= M_PI ? phi : phi - 2 * M_PI); // (-pi,pi]
127  return (M_PI - phi);
128 }
129 
131  double phi = getPhiGluedModule(a); // [0,2pi)
132  phi = (phi <= M_PI ? phi : phi - 2 * M_PI); // (-pi,pi]
133  return (M_PI - phi);
134 }
135 
137  return a->deepComponents().front()->rho() < b->deepComponents().front()->rho();
138 }
139 
140 bool CmsTrackerLevelBuilderHelper::isLessR(const GeometricDet* a, const GeometricDet* b) { return a->rho() < b->rho(); }
141 
142 /*
143  * Old DD navigation.
144  */
145 template <>
148  const std::string& attribute) {
149  if (DEBUG) {
150  edm::LogVerbatim("CmsTrackerLevelBuilder")
151  << "CmsTrackerLevelBuilder::build called on volume"
152  << " tracker->name() = " << tracker->name() << " tracker->path() = " << fv.geoHistory()
153  << " tracker->type() = " << tracker->type();
154  }
155 
156  // Go down one level in hierarchy
157  bool doLayers = fv.firstChild();
158 
159  while (doLayers) {
160  if (DEBUG) {
161  edm::LogVerbatim("CmsTrackerLevelBuilder") << "Calling buildComponent, before";
162  }
163 
164  // Call build on sibling
165  buildComponent(fv, tracker, attribute);
166 
167  if (DEBUG) {
168  edm::LogVerbatim("CmsTrackerLevelBuilder") << "Calling buildComponent, after";
169  }
170 
171  // Go to next sibling
172  doLayers = fv.nextSibling();
173  }
174 
175  // Come back up
176  fv.parent();
177 
178  // Now that all GeometricDets of a given hierarchy level are built, sort them!
179  sortNS(fv, tracker);
180 
181  if (DEBUG) {
182  edm::LogVerbatim("CmsTrackerLevelBuilder")
183  << "CmsTrackerLevelBuilder::build: Exit, finished all buildComponents calls.";
184  }
185 }
186 
187 /*
188  * DD4hep navigation.
189  */
190 template <>
193  const std::string& attribute) {
194  if (DEBUG) {
195  edm::LogVerbatim("CmsTrackerLevelBuilder")
196  << "CmsTrackerLevelBuilder::build called on volume"
197  << " tracker->name() = " << tracker->name() << " tracker->path() = " << fv.geoHistory()
198  << " tracker->type() = " << tracker->type();
199  }
200 
201  // Go down one level in hierarchy
202  fv.firstChild();
203 
204  // This is the siblings hierarchy level
205  const int level = fv.level();
207 
208  // Treat all siblings of a given hierarchy level
209  while (fv.level() == level) {
210  if (DEBUG) {
211  edm::LogVerbatim("CmsTrackerLevelBuilder")
212  << "Calling buildComponent, before."
213  << " level = " << level << " type = " << type << " fv.level() = " << fv.level()
214  << " fv.type() = " << ExtractStringFromDDD<cms::DDFilteredView>::getString(attribute, &fv);
215  }
216 
217  // Call build on sibling
218  buildComponent(fv, tracker, attribute);
219 
220  if (DEBUG) {
221  edm::LogVerbatim("CmsTrackerLevelBuilder")
222  << "Calling buildComponent, after."
223  << " level = " << level << " type = " << type << " fv.level() = " << fv.level()
224  << " fv.type() = " << ExtractStringFromDDD<cms::DDFilteredView>::getString(attribute, &fv);
225  }
226  }
227 
228  // Now that all GeometricDets of a given hierarchy level are built, sort them!
229  sortNS(fv, tracker);
230 
231  if (DEBUG) {
232  edm::LogVerbatim("CmsTrackerLevelBuilder")
233  << "CmsTrackerLevelBuilder::build: Exit, finished all buildComponents calls.";
234  }
235 }
236 
personalPlayback.level
level
Definition: personalPlayback.py:22
ExtractStringFromDDD::getString
static std::string getString(const std::string &, FilteredView *)
CmsTrackerLevelBuilder
Definition: CmsTrackerLevelBuilder.h:31
CmsTrackerLevelBuilder.h
mps_fire.i
i
Definition: mps_fire.py:428
MessageLogger.h
dqmMemoryStats.float
float
Definition: dqmMemoryStats.py:127
CmsTrackerLevelBuilderHelper::getPhiModuleMirror
static double getPhiModuleMirror(const GeometricDet *a)
Definition: CmsTrackerLevelBuilder.cc:124
cms::DDFilteredView::geoHistory
const std::vector< const Node * > geoHistory() const
Definition: DDFilteredView.cc:671
cms::DDFilteredView
Definition: DDFilteredView.h:70
DDFilteredView::parent
bool parent()
set the current node to the parent node ...
Definition: DDFilteredView.cc:161
groupFilesInBlocks.temp
list temp
Definition: groupFilesInBlocks.py:142
CmsTrackerLevelBuilderHelper::isLessZ
static bool isLessZ(const GeometricDet *a, const GeometricDet *b)
Definition: CmsTrackerLevelBuilder.cc:30
CmsTrackerLevelBuilderHelper::getPhiGluedModule
static double getPhiGluedModule(const GeometricDet *a)
Definition: CmsTrackerLevelBuilder.cc:83
AlCaHLTBitMon_QueryRunRegistry.comp
comp
Definition: AlCaHLTBitMon_QueryRunRegistry.py:249
CmsTrackerLevelBuilderHelper::getPhiModule
static double getPhiModule(const GeometricDet *a)
Definition: CmsTrackerLevelBuilder.cc:49
DEBUG
#define DEBUG
Definition: CmsTrackerLevelBuilder.cc:10
CmsTrackerLevelBuilderHelper::getPhi
static double getPhi(const GeometricDet *a)
Definition: CmsTrackerLevelBuilder.cc:44
CmsTrackerLevelBuilderHelper::isLessR
static bool isLessR(const GeometricDet *a, const GeometricDet *b)
Definition: CmsTrackerLevelBuilder.cc:140
DDFilteredView::firstChild
bool firstChild()
set the current node to the first child ...
Definition: DDFilteredView.cc:86
DDFilteredView.h
CmsTrackerLevelBuilderHelper::subDetByType
static bool subDetByType(const GeometricDet *a, const GeometricDet *b)
Definition: CmsTrackerLevelBuilder.cc:12
cms::DDFilteredView::firstChild
bool firstChild()
set the current node to the first child
Definition: DDFilteredView.cc:268
GeometricDet
Definition: GeometricDet.h:31
DDFilteredView::nextSibling
bool nextSibling()
set the current node to the next sibling ...
Definition: DDFilteredView.cc:124
DDFilteredView.h
CmsTrackerLevelBuilderHelper::isLessModZ
static bool isLessModZ(const GeometricDet *a, const GeometricDet *b)
Definition: CmsTrackerLevelBuilder.cc:40
b
double b
Definition: hdecay.h:118
CmsTrackerLevelBuilderHelper::getPhiMirror
static double getPhiMirror(const GeometricDet *a)
Definition: CmsTrackerLevelBuilder.cc:118
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
PbPb_ZMuSkimMuonDPG_cff.tracker
tracker
Definition: PbPb_ZMuSkimMuonDPG_cff.py:60
CmsTrackerLevelBuilderHelper::getPhiGluedModuleMirror
static double getPhiGluedModuleMirror(const GeometricDet *a)
Definition: CmsTrackerLevelBuilder.cc:130
a
double a
Definition: hdecay.h:119
cms::DDFilteredView::level
const int level() const
get Iterator level
Definition: DDFilteredView.cc:636
CmsTrackerLevelBuilder::build
void build(FilteredView &, GeometricDet *, const std::string &) override
type
type
Definition: SiPixelVCal_PayloadInspector.cc:37
M_PI
#define M_PI
Definition: BXVectorInputProducer.cc:49
DDFilteredView::geoHistory
const DDGeoHistory & geoHistory() const
The list of ancestors up to the root-node of the current node.
Definition: DDFilteredView.cc:30
GeometricDet.h
CmsTrackerLevelBuilderHelper::isLessRModule
static bool isLessRModule(const GeometricDet *a, const GeometricDet *b)
Definition: CmsTrackerLevelBuilder.cc:136
DDAxes::phi
ExtractStringFromDDD.h
edm::LogVerbatim
Log< level::Info, true > LogVerbatim
Definition: MessageLogger.h:128
DDFilteredView
Definition: DDFilteredView.h:20
funct::abs
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
CmsTrackerLevelBuilderHelper::phiSortNP
static bool phiSortNP(const GeometricDet *a, const GeometricDet *b)
Definition: CmsTrackerLevelBuilder.cc:20