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  auto& gh = fv.geoHistory();
163 
164  baseNumber_.reset();
165  baseNumber_.setSize(gh.size());
166 
167  for (uint i = gh.size(); i-- > 0;) {
168  baseNumber_.addLevel(gh[i].logicalPart().name().name(), gh[i].copyno());
169 #ifdef EDM_ML_DEBUG
170  edm::LogVerbatim("CmsMTDConstruction") << gh[i].logicalPart().name().name() << " " << gh[i].copyno();
171 #endif
172  }
173 
174  det->setGeographicalID(ETLDetId(etlScheme_.getUnitID(baseNumber_)));
175 
176  mother->addComponent(det);
177 }
178 
179 template <>
181  std::string nodeName(fv.name());
182  GeometricTimingDet* det =
183  new GeometricTimingDet(&fv, theCmsMTDStringToEnum.type(nodeName.substr(0, CmsMTDStringToEnum::kModStrLen)));
184 
185  baseNumber_.reset();
186  baseNumber_.setSize(fv.copyNos().size());
187 
188  for (uint i = 0; i < fv.copyNos().size(); i++) {
189  std::string_view name((fv.geoHistory()[i])->GetName());
190  size_t ipos = name.rfind('_');
191  baseNumber_.addLevel(name.substr(0, ipos), fv.copyNos()[i]);
192 #ifdef EDM_ML_DEBUG
193  edm::LogVerbatim("CmsMTDConstruction") << name.substr(0, ipos) << " " << fv.copyNos()[i];
194 #endif
195  }
196 
197  det->setGeographicalID(ETLDetId(etlScheme_.getUnitID(baseNumber_)));
198 
199  mother->addComponent(det);
200 }
201 
202 template <class FilteredView>
204  std::string nodeName(fv.name());
205  auto thisDet = theCmsMTDStringToEnum.type(nodeName);
206  GeometricTimingDet* subdet = new GeometricTimingDet(&fv, thisDet);
207 
208  if (thisDet == GeometricTimingDet::BTL) {
209  subdet->setGeographicalID(BTLDetId(0, 0, 0, 0, 0));
210  } else if (thisDet == GeometricTimingDet::ETL) {
211  const uint32_t side = subdet->translation().z() > 0 ? 1 : 0;
212  subdet->setGeographicalID(ETLDetId(side, 0, 0, 0));
213  } else {
214  throw cms::Exception("CmsMTDConstruction") << " ERROR - I was expecting a SubDet, I got a " << fv.name();
215  }
216 
217  return subdet;
218 }
219 
220 template <class FilteredView>
222  std::string nodeName(fv.name());
223  auto thisDet = theCmsMTDStringToEnum.type(nodeName);
224  GeometricTimingDet* layer = new GeometricTimingDet(&fv, thisDet);
225 
226  if (thisDet != GeometricTimingDet::BTLLayer && thisDet != GeometricTimingDet::ETLDisc) {
227  throw cms::Exception("CmsMTDConstruction") << " ERROR - I was expecting a SubDet, I got a " << fv.name();
228  }
229 
230  uint32_t nLayer;
231  if (thisDet == GeometricTimingDet::BTLLayer) {
232  //
233  // only one layer in BTL
234  //
235  nLayer = 1;
236  layer->setGeographicalID(nLayer);
237  } else if (thisDet == GeometricTimingDet::ETLDisc) {
238  //
239  // no change for pre TDR scenarios, otherwise identifiy layer with disc
240  //
241  nLayer = (fv.name().find("Disc1") != std::string::npos) ? 1 : 2;
242  layer->setGeographicalID(nLayer);
243  }
244 
245  return layer;
246 }
247 
248 template <class FilteredView>
250  return (fv.name().substr(0, 9) == "BTLModule");
251 }
252 
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 *)
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)