CMS 3D CMS Logo

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  std::string name(gh[i].logicalPart().name().name());
126  int copyN(gh[i].copyno());
127  baseNumber_.addLevel(name, copyN);
128 #ifdef EDM_ML_DEBUG
129  edm::LogVerbatim("CmsMTDConstruction") << name << " " << copyN;
130 #endif
131  }
132 
133  det->setGeographicalID(ETLDetId(etlScheme_.getUnitID(baseNumber_)));
134 
135  } else {
136  const auto& copyNumbers = fv.copyNumbers();
137  auto module_number = copyNumbers[copyNumbers.size() - 2];
138 
139  size_t delim_ring = det->name().find("EModule");
140  size_t delim_disc = det->name().find("Disc");
141 
142  std::string ringN = det->name().substr(delim_ring + CmsMTDStringToEnum::kModStrLen, delim_disc);
143 
144  const uint32_t side = det->translation().z() > 0 ? 1 : 0;
145 
146  // label geographic detid is front or back (even though it is one module per entry here)
147  det->setGeographicalID(ETLDetId(side, atoi(ringN.c_str()), module_number, 0));
148  }
149 
150  mother->addComponent(det);
151 }
152 
153 template <>
155  std::string nodeName(fv.name());
156  GeometricTimingDet* det =
157  new GeometricTimingDet(&fv, theCmsMTDStringToEnum.type(nodeName.substr(0, CmsMTDStringToEnum::kModStrLen)));
158 
159  baseNumber_.reset();
160  baseNumber_.setSize(fv.copyNos().size());
161 
162  for (uint i = 0; i < fv.copyNos().size(); i++) {
163  std::string name((fv.geoHistory()[i])->GetName());
164  name.assign(name.erase(name.rfind('_')));
165  int copyN(fv.copyNos()[i]);
166  baseNumber_.addLevel(name, copyN);
167 #ifdef EDM_ML_DEBUG
168  edm::LogVerbatim("CmsMTDConstruction") << name << " " << copyN;
169 #endif
170  }
171 
172  det->setGeographicalID(ETLDetId(etlScheme_.getUnitID(baseNumber_)));
173 
174  mother->addComponent(det);
175 }
176 
177 template <class FilteredView>
179  std::string nodeName(fv.name());
180  auto thisDet = theCmsMTDStringToEnum.type(nodeName);
181  GeometricTimingDet* subdet = new GeometricTimingDet(&fv, thisDet);
182 
183  if (thisDet == GeometricTimingDet::BTL) {
184  subdet->setGeographicalID(BTLDetId(0, 0, 0, 0, 0));
185  } else if (thisDet == GeometricTimingDet::ETL) {
186  const uint32_t side = subdet->translation().z() > 0 ? 1 : 0;
187  subdet->setGeographicalID(ETLDetId(side, 0, 0, 0));
188  } else {
189  throw cms::Exception("CmsMTDConstruction") << " ERROR - I was expecting a SubDet, I got a " << fv.name();
190  }
191 
192  return subdet;
193 }
194 
195 template <class FilteredView>
197  std::string nodeName(fv.name());
198  auto thisDet = theCmsMTDStringToEnum.type(nodeName);
199  GeometricTimingDet* layer = new GeometricTimingDet(&fv, thisDet);
200 
201  if (thisDet != GeometricTimingDet::BTLLayer && thisDet != GeometricTimingDet::ETLDisc) {
202  throw cms::Exception("CmsMTDConstruction") << " ERROR - I was expecting a SubDet, I got a " << fv.name();
203  }
204 
205  uint32_t nLayer;
206  if (thisDet == GeometricTimingDet::BTLLayer) {
207  //
208  // only one layer in BTL
209  //
210  nLayer = 1;
211  layer->setGeographicalID(nLayer);
212  } else if (thisDet == GeometricTimingDet::ETLDisc) {
213  //
214  // no change for pre TDR scenarios, otherwise identifiy layer with disc
215  //
216  nLayer = (fv.name().find("Disc1") != std::string::npos) ? 1 : 2;
217  layer->setGeographicalID(nLayer);
218  }
219 
220  return layer;
221 }
222 
223 template <class FilteredView>
225  return (fv.name() == "EModule_Timingactive");
226 }
227 
GeometricTimingDet::addComponent
void addComponent(GeometricTimingDet *)
Definition: GeometricTimingDet.cc:224
BTLDetId.h
mps_fire.i
i
Definition: mps_fire.py:355
CmsMTDStringToEnum::kModStrLen
static constexpr size_t kModStrLen
Definition: CmsMTDStringToEnum.h:12
CmsMTDConstruction::mtdOrderPhi
static bool mtdOrderPhi(const GeometricTimingDet *a, const GeometricTimingDet *b)
Definition: CmsMTDConstruction.cc:32
cms::DDFilteredView::path
const std::string path() const
The full path to the current node.
Definition: DDFilteredView.cc:76
CmsMTDConstruction::buildETLModule
void buildETLModule(FilteredView &, GeometricTimingDet *)
CmsMTDConstruction::mtdOrderRR
static bool mtdOrderRR(const GeometricTimingDet *a, const GeometricTimingDet *b)
Definition: CmsMTDConstruction.cc:25
cms::DDFilteredView::geoHistory
const std::vector< const Node * > geoHistory() const
Definition: DDFilteredView.cc:561
globals_cff.id1
id1
Definition: globals_cff.py:32
DDFilteredView::copyNumbers
nav_type copyNumbers() const
return the stack of copy numbers
Definition: DDFilteredView.cc:193
CmsMTDConstruction::buildBTLModule
void buildBTLModule(FilteredView &, GeometricTimingDet *)
ETLDetId
Detector identifier class for the Endcap Timing Layer.
Definition: ETLDetId.h:15
cms::DDFilteredView
Definition: DDFilteredView.h:65
ETLDetId.h
parallelization.uint
uint
Definition: parallelization.py:124
ExtractStringFromDD.h
cms::DDFilteredView::name
std::string_view name() const
Definition: DDFilteredView.cc:606
BTLDetId
Detector identifier class for the Barrel Timing Layer. The crystal count must start from 0,...
Definition: BTLDetId.h:18
GeometricTimingDet::ETLDisc
Definition: GeometricTimingDet.h:60
DDFilteredView.h
cms::DDFilteredView::copyNos
const std::vector< int > copyNos() const
The list of the volume copy numbers.
Definition: DDFilteredView.cc:89
DDFilteredView.h
CmsMTDConstruction::buildLayer
GeometricTimingDet * buildLayer(FilteredView &)
Definition: CmsMTDConstruction.cc:196
b
double b
Definition: hdecay.h:118
CmsMTDConstruction::CmsMTDConstruction
CmsMTDConstruction()
Definition: CmsMTDConstruction.cc:15
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
GeometricTimingDet::translation
Translation const & translation() const
Definition: GeometricTimingDet.h:99
GeometricTimingDet::ETL
Definition: GeometricTimingDet.h:59
a
double a
Definition: hdecay.h:119
CmsMTDConstruction::isETLtdr
bool isETLtdr(FilteredView &)
Definition: CmsMTDConstruction.cc:224
eventshapeDQM_cfi.order
order
Definition: eventshapeDQM_cfi.py:8
cms::DDFilteredView::copyNumbers
auto copyNumbers(Ts &&... ts) const -> decltype(copyNos(std::forward< Ts >(ts)...))
Definition: DDFilteredView.h:89
edm::LogVerbatim
Definition: MessageLogger.h:297
GeometricTimingDet
Definition: GeometricTimingDet.h:28
DDFilteredView::geoHistory
const DDGeoHistory & geoHistory() const
The list of ancestors up to the root-node of the current node.
Definition: DDFilteredView.cc:30
angle0to2pi::make0To2pi
constexpr valType make0To2pi(valType angle)
Definition: deltaPhi.h:67
CmsMTDConstruction::mtdOrderZ
static bool mtdOrderZ(const GeometricTimingDet *a, const GeometricTimingDet *b)
Definition: CmsMTDConstruction.cc:18
MTDBaseNumber.h
GeometricTimingDet::BTLLayer
Definition: GeometricTimingDet.h:54
MTDDetId
Detector identifier base class for the MIP Timing Layer.
Definition: MTDDetId.h:21
Exception
Definition: hltDiff.cc:246
GeometricTimingDet::BTL
Definition: GeometricTimingDet.h:53
Skims_PA_cff.name
name
Definition: Skims_PA_cff.py:17
DDFilteredView
Definition: DDFilteredView.h:20
CmsMTDConstruction.h
globals_cff.id2
id2
Definition: globals_cff.py:33
CmsMTDConstruction
Definition: CmsMTDConstruction.h:13
CmsMTDConstruction::buildSubdet
GeometricTimingDet * buildSubdet(FilteredView &)
Definition: CmsMTDConstruction.cc:178
timingPdfMaker.modname
modname
Definition: timingPdfMaker.py:218
GeometricTimingDet::setGeographicalID
void setGeographicalID(DetId id)
Definition: GeometricTimingDet.h:76
deltaPhi.h
DDFilteredView::name
const std::string & name() const
The name of a logical-part of the current node in the filtered-view.
Definition: DDFilteredView.cc:18