CMS 3D CMS Logo

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