CMS 3D CMS Logo

CmsDetConstruction.cc
Go to the documentation of this file.
7 #include <memory>
8 
9 template <class FilteredView>
11  GeometricDet* mother,
12  const std::string& attribute) {
13  auto det = std::make_unique<GeometricDet>(&fv,
16  if (det->stereo()) {
17  uint32_t temp = 1;
18  det->setGeographicalID(DetId(temp));
19  } else {
20  uint32_t temp = 2;
21  det->setGeographicalID(DetId(temp));
22  }
23 
24  mother->addComponent(det.release());
25 }
26 
27 template <class FilteredView>
29  GeometricDet* mother,
30  const std::string& attribute) {
31  auto det = std::make_unique<GeometricDet>(&fv,
34 
35  if (det->isLowerSensor()) {
36  uint32_t temp = 1;
37  det->setGeographicalID(DetId(temp));
38  } else if (det->isUpperSensor()) {
39  uint32_t temp = 2;
40  det->setGeographicalID(DetId(temp));
41  } else {
42  edm::LogError("DetConstruction") << " module defined in a Stack but not upper either lower!? ";
43  }
44  mother->addComponent(det.release());
45 }
46 
47 template <class FilteredView>
49  GeometricDet* mother,
50  const std::string& attribute) {
51  auto det = std::make_unique<GeometricDet>(&fv,
54 
55  if (det->isFirstSensor()) {
56  uint32_t temp = 1;
57  det->setGeographicalID(DetId(temp));
58  } else if (det->isSecondSensor()) {
59  uint32_t temp = 2;
60  det->setGeographicalID(DetId(temp));
61  } else {
62  edm::LogError("DetConstruction") << " module defined in a 3D module but not first or second sensor!? ";
63  }
64  mother->addComponent(det.release());
65 }
66 
67 /*
68  * OLD DD.
69  * Module with 2 sensors: calculate the sensor local ID, and add the sensor to its mother volume (module).
70  * Module with 1 sensor: just add the sensor to to its mother volume (ladder).
71  */
72 template <>
74  GeometricDet* mother,
75  const std::string& attribute) {
76  // Mother volume
77  // Module with 2 sensors: the mother volume is the module volume.
78  // Module with 1 sensor: the mother volume is the ladder volume.
79  const std::string& myTopologicalNameInXMLs = ExtractStringFromDDD<DDFilteredView>::getString(attribute, &fv);
80  const GeometricDet::GDEnumType& myTopologicalType =
82 
83  auto det = std::make_unique<GeometricDet>(&fv, myTopologicalType);
84 
85  const bool isPhase1ModuleWith2Sensors = (myTopologicalType == GeometricDet::mergedDet);
86  const bool isPhase2ModuleWith2Sensors = (myTopologicalType == GeometricDet::OTPhase2Stack);
87  const bool isPhase2BarrelModuleWith2Sensors = (myTopologicalType == GeometricDet::ITPhase2Combined);
88 
89  // CASE A: MODULE HAS 2 SENSORS
90  if (isPhase1ModuleWith2Sensors || isPhase2ModuleWith2Sensors || isPhase2BarrelModuleWith2Sensors) {
91  // Go down in hierarchy: from module to sensor
92  bool dodets = fv.firstChild(); // very important
93  while (dodets) {
94  // PHASE 1 (MERGEDDET)
95  if (isPhase1ModuleWith2Sensors) {
96  buildSmallDetsforGlued(fv, det.get(), attribute);
97  }
98  // PHASE 2 (STACKDET)
99  else if (isPhase2ModuleWith2Sensors) {
100  buildSmallDetsforStack(fv, det.get(), attribute);
101  } else if (isPhase2BarrelModuleWith2Sensors) {
102  buildSmallDetsfor3D(fv, det.get(), attribute);
103  }
104 
105  dodets = fv.nextSibling();
106  }
107 
108  fv.parent();
109  }
110 
111  // CASE B: MODULE HAS 1 SENSOR: NOTHING SPECIFIC TO DO
112  // Indeed, we are not going to sort sensors within module, if there is only 1 sensor!
113 
114  // ALL CASES: add sensor to its mother volume (module or ladder).
115  mother->addComponent(det.release());
116 }
117 
118 /*
119  * DD4hep.
120  * Module with 2 sensors: calculate the sensor local ID, and add the sensor to its mother volume (module).
121  * Module with 1 sensor: just add the sensor to its mother volume (ladder).
122  */
123 template <>
125  GeometricDet* mother,
126  const std::string& attribute) {
127  // Mother volume
128  // Module with 2 sensors: the mother volume is the module volume.
129  // Module with 1 sensor: the mother volume is the ladder volume.
130  const std::string& myTopologicalNameInXMLs = ExtractStringFromDDD<cms::DDFilteredView>::getString(attribute, &fv);
131  const GeometricDet::GDEnumType& myTopologicalType =
133  auto det = std::make_unique<GeometricDet>(&fv, myTopologicalType);
134 
135  const bool isPhase1ModuleWith2Sensors = (myTopologicalType == GeometricDet::mergedDet);
136  const bool isPhase2ModuleWith2Sensors = (myTopologicalType == GeometricDet::OTPhase2Stack);
137  const bool isPhase2BarrelModuleWith2Sensors = (myTopologicalType == GeometricDet::ITPhase2Combined);
138 
139  // CASE A: MODULE HAS 2 SENSORS
140  if (isPhase1ModuleWith2Sensors || isPhase2ModuleWith2Sensors || isPhase2BarrelModuleWith2Sensors) {
141  // Go down in hierarchy: from module to sensor
142  if (!fv.firstChild()) { // very important
143  edm::LogError("CmsDetConstruction::buildComponent. Cannot go down to sensor volume.");
144  return;
145  }
146 
147  // This is the sensor hierarchy level
148  const int sensorHierarchyLevel = fv.level();
149 
150  // Loop on all siblings (ie, on all sensors)
151  while (fv.level() == sensorHierarchyLevel) {
152  // PHASE 1 (MERGEDDET)
153  if (isPhase1ModuleWith2Sensors) {
154  buildSmallDetsforGlued(fv, det.get(), attribute);
155  }
156  // PHASE 2 (STACKDET)
157  else if (isPhase2ModuleWith2Sensors) {
158  buildSmallDetsforStack(fv, det.get(), attribute);
159  } else if (isPhase2BarrelModuleWith2Sensors) {
160  buildSmallDetsfor3D(fv, det.get(), attribute);
161  }
162 
163  // Go to the next volume in FilteredView.
164  // NB: If this volume is another sensor of the same module, will stay in the loop.
165  // Otherwise, it is very important to access the next volume to be treated anyway.
166  fv.firstChild();
167  }
168  }
169 
170  // CASE B: MODULE HAS 1 SENSOR: NOTHING SPECIFIC TO DO
171  // Indeed, we are not going to sort sensors within module, if there is only 1 sensor!
172  else {
173  // Go to the next volume in FilteredView.
174  fv.firstChild();
175  }
176 
177  // ALL CASES: add sensor to its mother volume (module or ladder).
178  mother->addComponent(det.release());
179 }
static std::string getString(const std::string &, FilteredView *)
void addComponent(GeometricDet *)
void buildSmallDetsforStack(FilteredView &, GeometricDet *, const std::string &)
Log< level::Error, false > LogError
void buildSmallDetsfor3D(FilteredView &, GeometricDet *, const std::string &)
void buildSmallDetsforGlued(FilteredView &, GeometricDet *, const std::string &)
Definition: DetId.h:17
void buildComponent(FilteredView &, GeometricDet *, const std::string &) override