CMS 3D CMS Logo

CmsMTDConstruction.cc
Go to the documentation of this file.
1 //#define EDM_ML_DEBUG
2 
7 
11 
13 
15 
16 template <class FilteredView>
17 CmsMTDConstruction<FilteredView>::CmsMTDConstruction() : btlScheme_(), etlScheme_(), baseNumber_() {}
18 
19 template <class FilteredView>
21  bool order = (a->translation().z() == b->translation().z()) ? a->translation().rho() < b->translation().rho()
22  : a->translation().z() < b->translation().z();
23  return order;
24 }
25 
26 template <class FilteredView>
28  MTDDetId id1(a->geographicalId());
29  MTDDetId id2(b->geographicalId());
30  return id1.mtdRR() < id2.mtdRR();
31 }
32 
33 template <class FilteredView>
35  MTDDetId id1(a->geographicalId());
36  MTDDetId id2(b->geographicalId());
37  return (id1.mtdRR() == id2.mtdRR()) && (angle0to2pi::make0To2pi(a->phi()) < angle0to2pi::make0To2pi(b->phi()));
38 }
39 
40 template <class FilteredView>
42  return static_cast<int>(convertRadToDeg(angle0to2pi::make0To2pi(a->phi()))) <
43  static_cast<int>(convertRadToDeg(angle0to2pi::make0To2pi(b->phi())));
44 }
45 
46 template <class FilteredView>
48  bool order = (static_cast<int>(convertRadToDeg(angle0to2pi::make0To2pi(a->phi()))) ==
49  static_cast<int>(convertRadToDeg(angle0to2pi::make0To2pi(b->phi())))) &&
50  (a->translation().z() < b->translation().z());
51  return order;
52 }
53 
54 template <>
56  std::string nodeName(fv.name());
57  GeometricTimingDet* det =
58  new GeometricTimingDet(&fv, theCmsMTDStringToEnum.type(nodeName.substr(0, CmsMTDStringToEnum::kModStrLen)));
59 
60  if (isBTLV2(fv)) {
61  auto& gh = fv.geoHistory();
62 
63  baseNumber_.reset();
64  baseNumber_.setSize(gh.size());
65 
66  for (uint i = gh.size(); i-- > 0;) {
67  baseNumber_.addLevel(gh[i].logicalPart().name().name(), gh[i].copyno());
68 #ifdef EDM_ML_DEBUG
69  edm::LogVerbatim("CmsMTDConstruction") << gh[i].logicalPart().name().name() << " " << gh[i].copyno();
70 #endif
71  }
72 
73  det->setGeographicalID(BTLDetId(btlScheme_.getUnitID(baseNumber_)));
74 
75  } else {
76  const auto& copyNumbers = fv.copyNumbers();
77  auto module_number = copyNumbers[copyNumbers.size() - 2];
78 
79  constexpr char positive[] = "PositiveZ";
80  constexpr char negative[] = "NegativeZ";
81 
82  const std::string& modname(fv.name());
83  size_t delim1 = modname.find("BModule");
84  size_t delim2 = modname.find("Layer");
85  module_number += atoi(modname.substr(delim1 + CmsMTDStringToEnum::kModStrLen, delim2).c_str()) - 1;
86 
87 #ifdef EDM_ML_DEBUG
88  edm::LogVerbatim("CmsMTDConstruction")
89  << "BTLModule = " << modname << " " << copyNumbers[copyNumbers.size() - 3] << " " << module_number;
90 #endif
91 
92  if (modname.find(positive) != std::string::npos) {
93  det->setGeographicalID(BTLDetId(1, copyNumbers[copyNumbers.size() - 3], module_number, 0, 1));
94  } else if (modname.find(negative) != std::string::npos) {
95  det->setGeographicalID(BTLDetId(0, copyNumbers[copyNumbers.size() - 3], module_number, 0, 1));
96  } else {
97  throw cms::Exception("CmsMTDConstruction::buildBTLModule")
98  << "BTL Module " << module_number << " is neither positive nor negative in Z!";
99  }
100  }
101 
102  mother->addComponent(det);
103 }
104 
105 template <>
107  std::string nodeName(fv.name());
108  GeometricTimingDet* det =
109  new GeometricTimingDet(&fv, theCmsMTDStringToEnum.type(nodeName.substr(0, CmsMTDStringToEnum::kModStrLen)));
110 
111  if (isBTLV2(fv)) {
112  baseNumber_.reset();
113  baseNumber_.setSize(fv.copyNos().size());
114 
115  for (uint i = 0; i < fv.copyNos().size(); i++) {
116  std::string_view name((fv.geoHistory()[i])->GetName());
117  size_t ipos = name.rfind('_');
118  baseNumber_.addLevel(name.substr(0, ipos), fv.copyNos()[i]);
119 #ifdef EDM_ML_DEBUG
120  edm::LogVerbatim("CmsMTDConstruction") << name.substr(0, ipos) << " " << fv.copyNos()[i];
121 #endif
122  }
123 
124  det->setGeographicalID(BTLDetId(btlScheme_.getUnitID(baseNumber_)));
125 
126  } else {
127  const auto& copyNumbers = fv.copyNumbers();
128  auto module_number = copyNumbers[1];
129 
130  constexpr char positive[] = "PositiveZ";
131  constexpr char negative[] = "NegativeZ";
132 
133  const std::string modname(fv.name());
134  size_t delim1 = modname.find("BModule");
135  size_t delim2 = modname.find("Layer");
136  module_number += atoi(modname.substr(delim1 + CmsMTDStringToEnum::kModStrLen, delim2).c_str()) - 1;
137 
138 #ifdef EDM_ML_DEBUG
139  edm::LogVerbatim("MTDNumbering") << fv.path() << "\nBTLModule = " << modname << " " << copyNumbers[2] << " "
140  << module_number;
141 #endif
142 
143  if (modname.find(positive) != std::string::npos) {
144  det->setGeographicalID(BTLDetId(1, copyNumbers[2], module_number, 0, 1));
145  } else if (modname.find(negative) != std::string::npos) {
146  det->setGeographicalID(BTLDetId(0, copyNumbers[2], module_number, 0, 1));
147  } else {
148  throw cms::Exception("CmsMTDConstruction::buildBTLModule")
149  << "BTL Module " << module_number << " is neither positive nor negative in Z!";
150  }
151  }
152 
153  mother->addComponent(det);
154 }
155 
156 template <>
158  std::string nodeName(fv.name());
159  GeometricTimingDet* det =
160  new GeometricTimingDet(&fv, theCmsMTDStringToEnum.type(nodeName.substr(0, CmsMTDStringToEnum::kModStrLen)));
161 
162  if (isETLtdr(fv)) {
163  //
164  // For the TDR ETL geometry
165  // in principle this method works also for the new geometry, if the main loop points to "Timingactive"
166  // but backward compatibility is kept in order to avoid change in volume name and number of siblings
167  //
168 
169  auto& gh = fv.geoHistory();
170 
171  baseNumber_.reset();
172  baseNumber_.setSize(gh.size());
173 
174  for (uint i = gh.size(); i-- > 0;) {
175  baseNumber_.addLevel(gh[i].logicalPart().name().name(), gh[i].copyno());
176 #ifdef EDM_ML_DEBUG
177  edm::LogVerbatim("CmsMTDConstruction") << gh[i].logicalPart().name().name() << " " << gh[i].copyno();
178 #endif
179  }
180 
181  det->setGeographicalID(ETLDetId(etlScheme_.getUnitID(baseNumber_)));
182 
183  } else {
184  const auto& copyNumbers = fv.copyNumbers();
185  auto module_number = copyNumbers[copyNumbers.size() - 2];
186 
187  size_t delim_ring = det->name().find("EModule");
188  size_t delim_disc = det->name().find("Disc");
189 
190  std::string ringN = det->name().substr(delim_ring + CmsMTDStringToEnum::kModStrLen, delim_disc);
191 
192  const uint32_t side = det->translation().z() > 0 ? 1 : 0;
193 
194  // label geographic detid is front or back (even though it is one module per entry here)
195  det->setGeographicalID(ETLDetId(side, atoi(ringN.c_str()), module_number, 0));
196  }
197 
198  mother->addComponent(det);
199 }
200 
201 template <>
203  std::string nodeName(fv.name());
204  GeometricTimingDet* det =
205  new GeometricTimingDet(&fv, theCmsMTDStringToEnum.type(nodeName.substr(0, CmsMTDStringToEnum::kModStrLen)));
206 
207  baseNumber_.reset();
208  baseNumber_.setSize(fv.copyNos().size());
209 
210  for (uint i = 0; i < fv.copyNos().size(); i++) {
211  std::string_view name((fv.geoHistory()[i])->GetName());
212  size_t ipos = name.rfind('_');
213  baseNumber_.addLevel(name.substr(0, ipos), fv.copyNos()[i]);
214 #ifdef EDM_ML_DEBUG
215  edm::LogVerbatim("CmsMTDConstruction") << name.substr(0, ipos) << " " << fv.copyNos()[i];
216 #endif
217  }
218 
219  det->setGeographicalID(ETLDetId(etlScheme_.getUnitID(baseNumber_)));
220 
221  mother->addComponent(det);
222 }
223 
224 template <class FilteredView>
226  std::string nodeName(fv.name());
227  auto thisDet = theCmsMTDStringToEnum.type(nodeName);
228  GeometricTimingDet* subdet = new GeometricTimingDet(&fv, thisDet);
229 
230  if (thisDet == GeometricTimingDet::BTL) {
231  subdet->setGeographicalID(BTLDetId(0, 0, 0, 0, 0));
232  } else if (thisDet == GeometricTimingDet::ETL) {
233  const uint32_t side = subdet->translation().z() > 0 ? 1 : 0;
234  subdet->setGeographicalID(ETLDetId(side, 0, 0, 0));
235  } else {
236  throw cms::Exception("CmsMTDConstruction") << " ERROR - I was expecting a SubDet, I got a " << fv.name();
237  }
238 
239  return subdet;
240 }
241 
242 template <class FilteredView>
244  std::string nodeName(fv.name());
245  auto thisDet = theCmsMTDStringToEnum.type(nodeName);
246  GeometricTimingDet* layer = new GeometricTimingDet(&fv, thisDet);
247 
248  if (thisDet != GeometricTimingDet::BTLLayer && thisDet != GeometricTimingDet::ETLDisc) {
249  throw cms::Exception("CmsMTDConstruction") << " ERROR - I was expecting a SubDet, I got a " << fv.name();
250  }
251 
252  uint32_t nLayer;
253  if (thisDet == GeometricTimingDet::BTLLayer) {
254  //
255  // only one layer in BTL
256  //
257  nLayer = 1;
258  layer->setGeographicalID(nLayer);
259  } else if (thisDet == GeometricTimingDet::ETLDisc) {
260  //
261  // no change for pre TDR scenarios, otherwise identifiy layer with disc
262  //
263  nLayer = (fv.name().find("Disc1") != std::string::npos) ? 1 : 2;
264  layer->setGeographicalID(nLayer);
265  }
266 
267  return layer;
268 }
269 
270 template <class FilteredView>
272  return (fv.name().substr(0, 9) == "BTLModule");
273 }
274 
275 template <class FilteredView>
277  return (fv.name() == "EModule_Timingactive");
278 }
279 
Log< level::Info, true > LogVerbatim
bool isBTLV2(FilteredView &)
nav_type copyNumbers() const
return the stack of copy numbers
const std::vector< int > copyNos() const
The list of the volume copy numbers.
void buildBTLModule(FilteredView &, GeometricTimingDet *)
GeometricTimingDet * buildSubdet(FilteredView &)
const std::string path() const
The full path to the current node.
constexpr NumType convertRadToDeg(NumType radians)
Definition: angle_units.h:21
const std::vector< const Node * > geoHistory() const
const std::string & name() const
The name of a logical-part of the current node in the filtered-view.
static constexpr size_t kModStrLen
Detector identifier base class for the MIP Timing Layer.
Definition: MTDDetId.h:21
std::string_view name() const
void addComponent(GeometricTimingDet *)
bool isETLtdr(FilteredView &)
GeometricTimingDet * buildLayer(FilteredView &)
void setGeographicalID(DetId id)
void buildETLModule(FilteredView &, GeometricTimingDet *)
Translation const & translation() const
const DDGeoHistory & geoHistory() const
The list of ancestors up to the root-node of the current node.
double b
Definition: hdecay.h:120
static bool mtdOrderZ(const GeometricTimingDet *a, const GeometricTimingDet *b)
constexpr valType make0To2pi(valType angle)
Definition: deltaPhi.h:67
static bool mtdOrderRR(const GeometricTimingDet *a, const GeometricTimingDet *b)
Detector identifier class for the Endcap Timing Layer.
Definition: ETLDetId.h:15
double a
Definition: hdecay.h:121
Detector identifier class for the Barrel Timing Layer. The crystal count must start from 0...
Definition: BTLDetId.h:19
auto copyNumbers(Ts &&... ts) const -> decltype(copyNos(std::forward< Ts >(ts)...))
static bool btlOrderPhi(const GeometricTimingDet *a, const GeometricTimingDet *b)
static bool btlOrderZ(const GeometricTimingDet *a, const GeometricTimingDet *b)
static bool mtdOrderPhi(const GeometricTimingDet *a, const GeometricTimingDet *b)