CMS 3D CMS Logo

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