CMS 3D CMS Logo

DDHGCalHEAlgo.cc
Go to the documentation of this file.
1 // File: DDHGCalHEAlgo.cc
3 // Description: Geometry factory class for HGCal (Mix)
4 // Author : Raman Sehgal
5 // DD4hep code for, HGCalHEAlgo, developed by Sunanda Banerjee
7 
8 #include <cmath>
9 #include <memory>
10 #include <string>
11 #include <unordered_set>
12 #include <vector>
13 
14 #include "DD4hep/DetFactoryHelper.h"
22 
23 //#define EDM_ML_DEBUG
24 using namespace cms_units::operators;
25 
26 struct HGCalHEAlgo {
27  HGCalHEAlgo() { throw cms::Exception("HGCalGeom") << "Wrong initialization to HGCalHEAlgo"; }
29  cms::DDNamespace ns(ctxt, e, true);
31 
32 #ifdef EDM_ML_DEBUG
33  edm::LogVerbatim("HGCalGeom") << "DDHGCalHEAlgo: Creating an instance";
34 #endif
35 
36  dd4hep::Volume mother = ns.volume(args.parentName());
37  waferNames_ = args.value<std::vector<std::string>>("WaferNames");
38 #ifdef EDM_ML_DEBUG
39  edm::LogVerbatim("HGCalGeom") << "DDHGCalHEAlgo: " << waferNames_.size() << " wafers";
40  for (unsigned int i = 0; i < waferNames_.size(); ++i)
41  edm::LogVerbatim("HGCalGeom") << "Wafer[" << i << "] " << waferNames_[i];
42 #endif
43  materials_ = args.value<std::vector<std::string>>("MaterialNames");
44  volumeNames_ = args.value<std::vector<std::string>>("VolumeNames");
45  thickness_ = args.value<std::vector<double>>("Thickness");
46  copyNumber_.resize(materials_.size(), 1);
47 #ifdef EDM_ML_DEBUG
48  edm::LogVerbatim("HGCalGeom") << "DDHGCalHEAlgo: " << materials_.size() << " types of volumes";
49  for (unsigned int i = 0; i < volumeNames_.size(); ++i)
50  edm::LogVerbatim("HGCalGeom") << "Volume [" << i << "] " << volumeNames_[i] << " of thickness " << thickness_[i]
51  << " filled with " << materials_[i] << " first copy number " << copyNumber_[i];
52 #endif
53  layerNumbers_ = args.value<std::vector<int>>("Layers");
54  layerThick_ = args.value<std::vector<double>>("LayerThick");
55  rMixLayer_ = args.value<std::vector<double>>("LayerRmix");
56 #ifdef EDM_ML_DEBUG
57  edm::LogVerbatim("HGCalGeom") << "There are " << layerNumbers_.size() << " blocks";
58  for (unsigned int i = 0; i < layerNumbers_.size(); ++i)
59  edm::LogVerbatim("HGCalGeom") << "Block [" << i << "] of thickness " << layerThick_[i] << " Rmid "
60  << rMixLayer_[i] << " with " << layerNumbers_[i] << " layers";
61 #endif
62  layerType_ = args.value<std::vector<int>>("LayerType");
63  layerSense_ = args.value<std::vector<int>>("LayerSense");
64  firstLayer_ = args.value<int>("FirstLayer");
65  absorbMode_ = args.value<int>("AbsorberMode");
66  sensitiveMode_ = args.value<int>("SensitiveMode");
67 #ifdef EDM_ML_DEBUG
68  edm::LogVerbatim("HGCalGeom") << "First Layer " << firstLayer_ << " and "
69  << "Absober:Sensitive mode " << absorbMode_ << ":" << sensitiveMode_;
70 #endif
71  layerCenter_ = args.value<std::vector<int>>("LayerCenter");
72 #ifdef EDM_ML_DEBUG
73  for (unsigned int i = 0; i < layerCenter_.size(); ++i)
74  edm::LogVerbatim("HGCalGeom") << "LayerCenter [" << i << "] " << layerCenter_[i];
75 #endif
76  if (firstLayer_ > 0) {
77  for (unsigned int i = 0; i < layerType_.size(); ++i) {
78  if (layerSense_[i] > 0) {
79  int ii = layerType_[i];
80  copyNumber_[ii] = firstLayer_;
81 #ifdef EDM_ML_DEBUG
82  edm::LogVerbatim("HGCalGeom") << "First copy number for layer type " << i << ":" << ii << " with "
83  << materials_[ii] << " changed to " << copyNumber_[ii];
84 #endif
85  break;
86  }
87  }
88  }
89 #ifdef EDM_ML_DEBUG
90  edm::LogVerbatim("HGCalGeom") << "There are " << layerType_.size() << " layers";
91  for (unsigned int i = 0; i < layerType_.size(); ++i)
92  edm::LogVerbatim("HGCalGeom") << "Layer [" << i << "] with material type " << layerType_[i] << " sensitive class "
93  << layerSense_[i];
94 #endif
95  materialsTop_ = args.value<std::vector<std::string>>("TopMaterialNames");
96  namesTop_ = args.value<std::vector<std::string>>("TopVolumeNames");
97  layerThickTop_ = args.value<std::vector<double>>("TopLayerThickness");
98  layerTypeTop_ = args.value<std::vector<int>>("TopLayerType");
99  copyNumberTop_.resize(materialsTop_.size(), 1);
100 #ifdef EDM_ML_DEBUG
101  edm::LogVerbatim("HGCalGeom") << "DDHGCalHEAlgo: " << materialsTop_.size() << " types of volumes in the top part";
102  for (unsigned int i = 0; i < materialsTop_.size(); ++i)
103  edm::LogVerbatim("HGCalGeom") << "Volume [" << i << "] " << namesTop_[i] << " of thickness " << layerThickTop_[i]
104  << " filled with " << materialsTop_[i] << " first copy number "
105  << copyNumberTop_[i];
106  edm::LogVerbatim("HGCalGeom") << "There are " << layerTypeTop_.size() << " layers in the top part";
107  for (unsigned int i = 0; i < layerTypeTop_.size(); ++i)
108  edm::LogVerbatim("HGCalGeom") << "Layer [" << i << "] with material type " << layerTypeTop_[i];
109 #endif
110  materialsBot_ = args.value<std::vector<std::string>>("BottomMaterialNames");
111  namesBot_ = args.value<std::vector<std::string>>("BottomVolumeNames");
112  layerTypeBot_ = args.value<std::vector<int>>("BottomLayerType");
113  layerSenseBot_ = args.value<std::vector<int>>("BottomLayerSense");
114  layerThickBot_ = args.value<std::vector<double>>("BottomLayerThickness");
115  copyNumberBot_.resize(materialsBot_.size(), 1);
116 #ifdef EDM_ML_DEBUG
117  edm::LogVerbatim("HGCalGeom") << "DDHGCalHEAlgo: " << materialsBot_.size()
118  << " types of volumes in the bottom part";
119  for (unsigned int i = 0; i < materialsBot_.size(); ++i)
120  edm::LogVerbatim("HGCalGeom") << "Volume [" << i << "] " << namesBot_[i] << " of thickness " << layerThickBot_[i]
121  << " filled with " << materialsBot_[i] << " first copy number "
122  << copyNumberBot_[i];
123  edm::LogVerbatim("HGCalGeom") << "There are " << layerTypeBot_.size() << " layers in the bottom part";
124  for (unsigned int i = 0; i < layerTypeBot_.size(); ++i)
125  edm::LogVerbatim("HGCalGeom") << "Layer [" << i << "] with material type " << layerTypeBot_[i]
126  << " sensitive class " << layerSenseBot_[i];
127 #endif
128  zMinBlock_ = args.value<double>("zMinBlock");
129  rad100to200_ = args.value<std::vector<double>>("rad100to200");
130  rad200to300_ = args.value<std::vector<double>>("rad200to300");
131  zMinRadPar_ = args.value<double>("zMinForRadPar");
132  choiceType_ = args.value<int>("choiceType");
133  nCutRadPar_ = args.value<int>("nCornerCut");
134  fracAreaMin_ = args.value<double>("fracAreaMin");
135  waferSize_ = args.value<double>("waferSize");
136  waferSepar_ = args.value<double>("SensorSeparation");
137  sectors_ = args.value<int>("Sectors");
138  alpha_ = (1._pi) / sectors_;
139  cosAlpha_ = cos(alpha_);
140 #ifdef EDM_ML_DEBUG
141  edm::LogVerbatim("HGCalGeom") << "DDHGCalHEAlgo: zStart " << zMinBlock_ << " radius for wafer type separation uses "
142  << rad100to200_.size() << " parameters; zmin " << zMinRadPar_ << " cutoff "
143  << choiceType_ << ":" << nCutRadPar_ << ":" << fracAreaMin_ << " wafer width "
144  << waferSize_ << " separations " << waferSepar_ << " sectors " << sectors_ << ":"
145  << convertRadToDeg(alpha_) << ":" << cosAlpha_;
146  for (unsigned int k = 0; k < rad100to200_.size(); ++k)
147  edm::LogVerbatim("HGCalGeom") << "[" << k << "] 100-200 " << rad100to200_[k] << " 200-300 " << rad200to300_[k];
148 #endif
149  slopeB_ = args.value<std::vector<double>>("SlopeBottom");
150  zFrontB_ = args.value<std::vector<double>>("ZFrontBottom");
151  rMinFront_ = args.value<std::vector<double>>("RMinFront");
152  slopeT_ = args.value<std::vector<double>>("SlopeTop");
153  zFrontT_ = args.value<std::vector<double>>("ZFrontTop");
154  rMaxFront_ = args.value<std::vector<double>>("RMaxFront");
155 #ifdef EDM_ML_DEBUG
156  for (unsigned int i = 0; i < slopeB_.size(); ++i)
157  edm::LogVerbatim("HGCalGeom") << "Block [" << i << "] Zmin " << zFrontB_[i] << " Rmin " << rMinFront_[i]
158  << " Slope " << slopeB_[i];
159  for (unsigned int i = 0; i < slopeT_.size(); ++i)
160  edm::LogVerbatim("HGCalGeom") << "Block [" << i << "] Zmin " << zFrontT_[i] << " Rmax " << rMaxFront_[i]
161  << " Slope " << slopeT_[i];
162  edm::LogVerbatim("HGCalGeom") << "DDHGCalHEAlgo: NameSpace " << ns.name();
163 #endif
164 
165  waferType_ = std::make_unique<HGCalWaferType>(
166  rad100to200_, rad200to300_, (waferSize_ + waferSepar_), zMinRadPar_, choiceType_, nCutRadPar_, fracAreaMin_);
167 
168 #ifdef EDM_ML_DEBUG
169  edm::LogVerbatim("HGCalGeom") << "==>> Constructing DDHGCalHEAlgo...";
170  copies_.clear();
171 #endif
172 
173  double zi(zMinBlock_);
174  int laymin(0);
175  for (unsigned int i = 0; i < layerNumbers_.size(); i++) {
176  double zo = zi + layerThick_[i];
177  double routF = HGCalGeomTools::radius(zi, zFrontT_, rMaxFront_, slopeT_);
178  int laymax = laymin + layerNumbers_[i];
179  double zz = zi;
180  double thickTot(0);
181  for (int ly = laymin; ly < laymax; ++ly) {
182  int ii = layerType_[ly];
183  int copy = copyNumber_[ii];
184  double hthick = 0.5 * thickness_[ii];
185  double rinB = HGCalGeomTools::radius(zo, zFrontB_, rMinFront_, slopeB_);
186  zz += hthick;
187  thickTot += thickness_[ii];
188 
189  std::string name = volumeNames_[ii] + std::to_string(copy);
190 
191 #ifdef EDM_ML_DEBUG
192  edm::LogVerbatim("HGCalGeom") << "DDHGCalHEAlgo: Layer " << ly << ":" << ii << " Front " << zi << ", " << routF
193  << " Back " << zo << ", " << rinB << " superlayer thickness " << layerThick_[i];
194 #endif
195 
196  dd4hep::Material matter = ns.material(materials_[ii]);
197  dd4hep::Volume glog;
198 
199  if (layerSense_[ly] < 1) {
200  std::vector<double> pgonZ, pgonRin, pgonRout;
201  if (layerSense_[ly] == 0 || absorbMode_ == 0) {
202  double rmax =
203  (std::min(routF, HGCalGeomTools::radius(zz + hthick, zFrontT_, rMaxFront_, slopeT_)) * cosAlpha_) -
204  tol1_;
205  pgonZ.emplace_back(-hthick);
206  pgonZ.emplace_back(hthick);
207  pgonRin.emplace_back(rinB);
208  pgonRin.emplace_back(rinB);
209  pgonRout.emplace_back(rmax);
210  pgonRout.emplace_back(rmax);
211  } else {
212  HGCalGeomTools::radius(zz - hthick,
213  zz + hthick,
214  zFrontB_,
215  rMinFront_,
216  slopeB_,
217  zFrontT_,
218  rMaxFront_,
219  slopeT_,
220  -layerSense_[ly],
221  pgonZ,
222  pgonRin,
223  pgonRout);
224  for (unsigned int isec = 0; isec < pgonZ.size(); ++isec) {
225  pgonZ[isec] -= zz;
226  pgonRout[isec] = pgonRout[isec] * cosAlpha_ - tol1_;
227  }
228  }
229 
230  dd4hep::Solid solid =
231  dd4hep::Polyhedra(sectors_, -alpha_, 2. * cms_units::piRadians, pgonZ, pgonRin, pgonRout);
232  ns.addSolidNS(ns.prepend(name), solid);
233  glog = dd4hep::Volume(solid.name(), solid, matter);
234  ns.addVolumeNS(glog);
235 #ifdef EDM_ML_DEBUG
236  edm::LogVerbatim("HGCalGeom") << "DDHGCalHEAlgo: " << solid.name() << " polyhedra of " << sectors_
237  << " sectors covering " << convertRadToDeg(-alpha_) << ":"
238  << convertRadToDeg(-alpha_ + 2._pi) << " with " << pgonZ.size() << " sections";
239  for (unsigned int k = 0; k < pgonZ.size(); ++k)
240  edm::LogVerbatim("HGCalGeom")
241  << "[" << k << "] z " << pgonZ[k] << " R " << pgonRin[k] << ":" << pgonRout[k];
242 #endif
243  } else {
244  double rins =
245  (sensitiveMode_ < 1) ? rinB : HGCalGeomTools::radius(zz + hthick, zFrontB_, rMinFront_, slopeB_);
246  double routs =
247  (sensitiveMode_ < 1) ? routF : HGCalGeomTools::radius(zz - hthick, zFrontT_, rMaxFront_, slopeT_);
248  dd4hep::Solid solid = dd4hep::Tube(rins, routs, hthick, 0.0, 2. * cms_units::piRadians);
249  ns.addSolidNS(ns.prepend(name), solid);
250  glog = dd4hep::Volume(solid.name(), solid, matter);
251  ns.addVolumeNS(glog);
252 
253 #ifdef EDM_ML_DEBUG
254  edm::LogVerbatim("HGCalGeom") << "DDHGCalHEAlgo: " << solid.name() << " Tubs made of " << matter.name()
255  << " of dimensions " << rinB << ":" << rins << ", " << routF << ":" << routs
256  << ", " << hthick << ", 0.0, 360.0 and positioned in: " << glog.name()
257  << " number " << copy;
258 #endif
259  positionMix(ctxt, e, glog, name, copy, thickness_[ii], matter, rins, rMixLayer_[i], routs, zz);
260  }
261 
262  dd4hep::Position r1(0, 0, zz);
263  mother.placeVolume(glog, copy, r1);
264  ++copyNumber_[ii];
265 #ifdef EDM_ML_DEBUG
266  edm::LogVerbatim("HGCalGeom") << "DDHGCalHEAlgo: " << glog.name() << " number " << copy << " positioned in "
267  << mother.name() << " at " << r1 << " with no rotation";
268 #endif
269  zz += hthick;
270  } // End of loop over layers in a block
271  zi = zo;
272  laymin = laymax;
273  if (std::abs(thickTot - layerThick_[i]) >= tol2_) {
274  if (thickTot > layerThick_[i]) {
275  edm::LogError("HGCalGeom") << "Thickness of the partition " << layerThick_[i] << " is smaller than "
276  << thickTot << ": thickness of all its components **** ERROR ****";
277  } else {
278  edm::LogWarning("HGCalGeom") << "Thickness of the partition " << layerThick_[i] << " does not match with "
279  << thickTot << " of the components";
280  }
281  }
282  } // End of loop over blocks
283 
284 #ifdef EDM_ML_DEBUG
285  edm::LogVerbatim("HGCalGeom") << "DDHGCalHEAlgo: " << copies_.size() << " different wafer copy numbers";
286  int k(0);
287  for (std::unordered_set<int>::const_iterator itr = copies_.begin(); itr != copies_.end(); ++itr, ++k) {
288  edm::LogVerbatim("HGCalGeom") << "Copy [" << k << "] : " << (*itr);
289  }
290  copies_.clear();
291  edm::LogVerbatim("HGCalGeom") << "<<== End of DDHGCalHEAlgo construction...";
292 #endif
293  }
294 
296  xml_h e,
297  const dd4hep::Volume& glog,
298  const std::string& nameM,
299  int copyM,
300  double thick,
301  const dd4hep::Material& matter,
302  double rin,
303  double rmid,
304  double rout,
305  double zz) {
306  cms::DDNamespace ns(ctxt, e, true);
307 
308  dd4hep::Volume glog1;
309  for (unsigned int ly = 0; ly < layerTypeTop_.size(); ++ly) {
310  int ii = layerTypeTop_[ly];
311  copyNumberTop_[ii] = copyM;
312  }
313  for (unsigned int ly = 0; ly < layerTypeBot_.size(); ++ly) {
314  int ii = layerTypeBot_[ly];
315  copyNumberBot_[ii] = copyM;
316  }
317  double hthick = 0.5 * thick;
318  // Make the top part first
319  std::string name = nameM + "Top";
320 
321  dd4hep::Solid solid = dd4hep::Tube(rmid, rout, hthick, 0.0, 2. * cms_units::piRadians);
322  ns.addSolidNS(ns.prepend(name), solid);
323  glog1 = dd4hep::Volume(solid.name(), solid, matter);
324  ns.addVolumeNS(glog1);
325 #ifdef EDM_ML_DEBUG
326  edm::LogVerbatim("HGCalGeom") << "DDHGCalHEAlgo: " << solid.name() << " Tubs made of " << matter.name()
327  << " of dimensions " << rmid << ", " << rout << ", " << hthick << ", 0.0, 360.0";
328 #endif
329  glog.placeVolume(glog1, 1);
330 
331 #ifdef EDM_ML_DEBUG
332  edm::LogVerbatim("HGCalGeom") << "DDHGCalHEAlgo: " << glog1.name() << " number 1 positioned in " << glog.name()
333  << " at (0, 0, 0) with no rotation";
334 #endif
335  double thickTot(0), zpos(-hthick);
336  for (unsigned int ly = 0; ly < layerTypeTop_.size(); ++ly) {
337  int ii = layerTypeTop_[ly];
338  int copy = copyNumberTop_[ii];
339  double hthickl = 0.5 * layerThickTop_[ii];
340  thickTot += layerThickTop_[ii];
341  name = namesTop_[ii] + std::to_string(copy);
342 #ifdef EDM_ML_DEBUG
343  edm::LogVerbatim("HGCalGeom") << "DDHGCalHEAlgo: Layer " << ly << ":" << ii << " R " << rmid << ":" << rout
344  << " Thick " << layerThickTop_[ii];
345 #endif
346 
347  dd4hep::Material matter1 = ns.material(materialsTop_[ii]);
348  solid = dd4hep::Tube(rmid, rout, hthickl, 0.0, 2. * cms_units::piRadians);
349  ns.addSolidNS(ns.prepend(name), solid);
350  dd4hep::Volume glog2 = dd4hep::Volume(solid.name(), solid, matter1);
351  ns.addVolumeNS(glog2);
352 
353 #ifdef EDM_ML_DEBUG
354  double eta1 = -log(tan(0.5 * atan(rmid / zz)));
355  double eta2 = -log(tan(0.5 * atan(rout / zz)));
356  edm::LogVerbatim("HGCalGeom") << name << " z|rin|rout " << zz << ":" << rmid << ":" << rout << " eta " << eta1
357  << ":" << eta2;
358  edm::LogVerbatim("HGCalGeom") << "DDHGCalHEAlgo: " << solid.name() << " Tubs made of " << matter1.name()
359  << " of dimensions " << rmid << ", " << rout << ", " << hthickl << ", 0.0, 360.0";
360 #endif
361  zpos += hthickl;
362 
363  dd4hep::Position r1(0, 0, zpos);
364  glog1.placeVolume(glog2, copy, r1);
365 
366 #ifdef EDM_ML_DEBUG
367  edm::LogVerbatim("HGCalGeom") << "DDHGCalHEAlgo: Position " << glog2.name() << " number " << copy << " in "
368  << glog1.name() << " at " << r1 << " with no rotation";
369 #endif
370  ++copyNumberTop_[ii];
371  zpos += hthickl;
372  }
373  if (std::abs(thickTot - thick) >= tol2_) {
374  if (thickTot > thick) {
375  edm::LogError("HGCalGeom") << "Thickness of the partition " << thick << " is smaller than " << thickTot
376  << ": thickness of all its components in the top part **** ERROR ****";
377  } else {
378  edm::LogWarning("HGCalGeom") << "Thickness of the partition " << thick << " does not match with " << thickTot
379  << " of the components in top part";
380  }
381  }
382 
383  // Make the bottom part next
384  name = nameM + "Bottom";
385 
386  solid = dd4hep::Tube(rin, rmid, hthick, 0.0, 2. * cms_units::piRadians);
387  ns.addSolidNS(ns.prepend(name), solid);
388  glog1 = dd4hep::Volume(solid.name(), solid, matter);
389  ns.addVolumeNS(glog1);
390 
391 #ifdef EDM_ML_DEBUG
392  edm::LogVerbatim("HGCalGeom") << "DDHGCalHEAlgo: " << solid.name() << " Tubs made of " << matter.name()
393  << " of dimensions " << rin << ", " << rmid << ", " << hthick << ", 0.0, 360.0";
394 #endif
395 
396  glog.placeVolume(glog1, 1);
397 #ifdef EDM_ML_DEBUG
398  edm::LogVerbatim("HGCalGeom") << "DDHGCalHEAlgo: " << glog1.name() << " number 1 positioned in " << glog.name()
399  << " at (0, 0, 0) with no rotation";
400 #endif
401  thickTot = 0;
402  zpos = -hthick;
403  for (unsigned int ly = 0; ly < layerTypeBot_.size(); ++ly) {
404  int ii = layerTypeBot_[ly];
405  int copy = copyNumberBot_[ii];
406  double hthickl = 0.5 * layerThickBot_[ii];
407  thickTot += layerThickBot_[ii];
408  name = namesBot_[ii] + std::to_string(copy);
409 #ifdef EDM_ML_DEBUG
410  edm::LogVerbatim("HGCalGeom") << "DDHGCalHEAlgo: Layer " << ly << ":" << ii << " R " << rin << ":" << rmid
411  << " Thick " << layerThickBot_[ii];
412 #endif
413 
414  dd4hep::Material matter1 = ns.material(materialsBot_[ii]);
415  solid = dd4hep::Tube(rin, rmid, hthickl, 0.0, 2. * cms_units::piRadians);
416  ns.addSolidNS(ns.prepend(name), solid);
417  dd4hep::Volume glog2 = dd4hep::Volume(solid.name(), solid, matter1);
418  ns.addVolumeNS(glog2);
419 
420 #ifdef EDM_ML_DEBUG
421  double eta1 = -log(tan(0.5 * atan(rin / zz)));
422  double eta2 = -log(tan(0.5 * atan(rmid / zz)));
423  edm::LogVerbatim("HGCalGeom") << name << " z|rin|rout " << zz << ":" << rin << ":" << rmid << " eta " << eta1
424  << ":" << eta2;
425  edm::LogVerbatim("HGCalGeom") << "DDHGCalHEAlgo: " << solid.name() << " Tubs made of " << matter1.name()
426  << " of dimensions " << rin << ", " << rmid << ", " << hthickl << ", 0.0, 360.0";
427 #endif
428  zpos += hthickl;
429 
430  dd4hep::Position r1(0, 0, zpos);
431  glog1.placeVolume(glog2, copy, r1);
432 #ifdef EDM_ML_DEBUG
433  edm::LogVerbatim("HGCalGeom") << "DDHGCalHEAlgo: Position " << glog2.name() << " number " << copy << " in "
434  << glog1.name() << " at " << r1 << " with no rotation";
435 #endif
436  if (layerSenseBot_[ly] != 0) {
437 #ifdef EDM_ML_DEBUG
438  edm::LogVerbatim("HGCalGeom") << "DDHGCalHEAlgo: z " << (zz + zpos) << " Center " << copy << ":"
439  << (copy - firstLayer_) << ":" << layerCenter_[copy - firstLayer_];
440 #endif
441  positionSensitive(ctxt, e, glog2, rin, rmid, zz + zpos, layerSenseBot_[ly], layerCenter_[copy - firstLayer_]);
442  }
443  zpos += hthickl;
444  ++copyNumberBot_[ii];
445  }
446  if (std::abs(thickTot - thick) >= tol2_) {
447  if (thickTot > thick) {
448  edm::LogError("HGCalGeom") << "Thickness of the partition " << thick << " is smaller than " << thickTot
449  << ": thickness of all its components in the top part **** ERROR ****";
450  } else {
451  edm::LogWarning("HGCalGeom") << "Thickness of the partition " << thick << " does not match with " << thickTot
452  << " of the components in top part";
453  }
454  }
455  }
456 
458  xml_h e,
459  const dd4hep::Volume& glog,
460  double rin,
461  double rout,
462  double zpos,
463  int layertype,
464  int layercenter) {
465  cms::DDNamespace ns(ctxt, e, true);
466  static const double sqrt3 = std::sqrt(3.0);
467  double r = 0.5 * (waferSize_ + waferSepar_);
468  double R = 2.0 * r / sqrt3;
469  double dy = 0.75 * R;
470  int N = (int)(0.5 * rout / r) + 2;
471  const auto& xyoff = geomTools_.shiftXY(layercenter, (waferSize_ + waferSepar_));
472 #ifdef EDM_ML_DEBUG
473  int ium(0), ivm(0), iumAll(0), ivmAll(0), kount(0), ntot(0), nin(0);
474  std::vector<int> ntype(6, 0);
475  edm::LogVerbatim("HGCalGeom") << "DDHGCalHEAlgo: " << glog.name() << " rout " << rout << " N " << N
476  << " for maximum u, v Offset; Shift " << xyoff.first << ":" << xyoff.second
477  << " WaferSize " << (waferSize_ + waferSepar_);
478 #endif
479  for (int u = -N; u <= N; ++u) {
480  for (int v = -N; v <= N; ++v) {
481  int nr = 2 * v;
482  int nc = -2 * u + v;
483  double xpos = xyoff.first + nc * r;
484  double ypos = xyoff.second + nr * dy;
485  const auto& corner = HGCalGeomTools::waferCorner(xpos, ypos, r, R, rin, rout, false);
486 #ifdef EDM_ML_DEBUG
487  int iu = std::abs(u);
488  int iv = std::abs(v);
489  ++ntot;
490 #endif
491  if (corner.first > 0) {
492  int type = waferType_->getType(xpos, ypos, zpos);
493  int copy = HGCalTypes::packTypeUV(type, u, v);
494 #ifdef EDM_ML_DEBUG
495  if (iu > ium)
496  ium = iu;
497  if (iv > ivm)
498  ivm = iv;
499  kount++;
500  if (copies_.count(copy) == 0)
501  copies_.insert(copy);
502 #endif
503  if (corner.first == (int)(HGCalParameters::k_CornerSize)) {
504 #ifdef EDM_ML_DEBUG
505  if (iu > iumAll)
506  iumAll = iu;
507  if (iv > ivmAll)
508  ivmAll = iv;
509  ++nin;
510 #endif
511 
512  dd4hep::Position tran(xpos, ypos, 0.0);
513  if (layertype > 1)
514  type += 3;
515  glog.placeVolume(ns.volume(waferNames_[type]), copy, tran);
516 
517 #ifdef EDM_ML_DEBUG
518  ++ntype[type];
519  edm::LogVerbatim("HGCalGeom") << "DDHGCalHEAlgo: " << glog.name() << " number " << copy << " positioned in "
520  << glog.name() << " at " << tran << " with no rotation";
521 #endif
522  }
523  }
524  }
525  }
526 #ifdef EDM_ML_DEBUG
527  edm::LogVerbatim("HGCalGeom") << "DDHGCalHEAlgo: Maximum # of u " << ium << ":" << iumAll << " # of v " << ivm
528  << ":" << ivmAll << " and " << nin << ":" << kount << ":" << ntot << " wafers ("
529  << ntype[0] << ":" << ntype[1] << ":" << ntype[2] << ":" << ntype[3] << ":"
530  << ntype[4] << ":" << ntype[5] << ") for " << glog.name() << " R " << rin << ":"
531  << rout;
532 #endif
533  }
534 
535  //Required data members to cache the values from XML file
537  std::unique_ptr<HGCalWaferType> waferType_;
538 
539  std::vector<std::string> waferNames_; // Wafer names
540  std::vector<std::string> materials_; // Materials
541  std::vector<std::string> volumeNames_; // Names
542  std::vector<double> thickness_; // Thickness of the material
543  std::vector<int> copyNumber_; // Initial copy numbers
544  std::vector<int> layerNumbers_; // Number of layers in a section
545  std::vector<double> layerThick_; // Thickness of each section
546  std::vector<double> rMixLayer_; // Partition between Si/Sci part
547  std::vector<int> layerType_; // Type of the layer
548  std::vector<int> layerSense_; // Content of a layer (sensitive?)
549  int firstLayer_; // Copy # of the first sensitive layer
550  int absorbMode_; // Absorber mode
551  int sensitiveMode_; // Sensitive mode
552  std::vector<std::string> materialsTop_; // Materials of top layers
553  std::vector<std::string> namesTop_; // Names of top layers
554  std::vector<double> layerThickTop_; // Thickness of the top sections
555  std::vector<int> layerTypeTop_; // Type of the Top layer
556  std::vector<int> copyNumberTop_; // Initial copy numbers (top section)
557  std::vector<std::string> materialsBot_; // Materials of bottom layers
558  std::vector<std::string> namesBot_; // Names of bottom layers
559  std::vector<double> layerThickBot_; // Thickness of the bottom sections
560  std::vector<int> layerTypeBot_; // Type of the bottom layers
561  std::vector<int> copyNumberBot_; // Initial copy numbers (bot section)
562  std::vector<int> layerSenseBot_; // Content of bottom layer (sensitive?)
563  std::vector<int> layerCenter_; // Centering of the wafers
564 
565  double zMinBlock_; // Starting z-value of the block
566  std::vector<double> rad100to200_; // Parameters for 120-200mum trans.
567  std::vector<double> rad200to300_; // Parameters for 200-300mum trans.
568  double zMinRadPar_; // Minimum z for radius parametriz.
569  int choiceType_; // Type of parametrization to be used
570  int nCutRadPar_; // Cut off threshold for corners
571  double fracAreaMin_; // Minimum fractional conatined area
572  double waferSize_; // Width of the wafer
573  double waferSepar_; // Sensor separation
574  int sectors_; // Sectors
575  std::vector<double> slopeB_; // Slope at the lower R
576  std::vector<double> zFrontB_; // Starting Z values for the slopes
577  std::vector<double> rMinFront_; // Corresponding rMin's
578  std::vector<double> slopeT_; // Slopes at the larger R
579  std::vector<double> zFrontT_; // Starting Z values for the slopes
580  std::vector<double> rMaxFront_; // Corresponding rMax's
581  std::unordered_set<int> copies_; // List of copy #'s
582  double alpha_, cosAlpha_;
583 
584  static constexpr double tol1_ = 0.01;
585  static constexpr double tol2_ = 0.00001;
586 };
587 
588 static long algorithm(dd4hep::Detector& /* description */, cms::DDParsingContext& ctxt, xml_h e) {
589  HGCalHEAlgo healgo(ctxt, e);
590  return cms::s_executed;
591 }
592 
593 DECLARE_DDCMS_DETELEMENT(DDCMS_hgcal_DDHGCalHEAlgo, algorithm)
HGCalHEAlgo::rMixLayer_
std::vector< double > rMixLayer_
Definition: DDHGCalHEAlgo.cc:546
writedatasetfile.args
args
Definition: writedatasetfile.py:18
HGCalGeomTools::waferCorner
static std::pair< int32_t, int32_t > waferCorner(double xpos, double ypos, double r, double R, double rMin, double rMax, bool oldBug=false)
Definition: HGCalGeomTools.cc:223
mps_fire.i
i
Definition: mps_fire.py:428
cms_units::operators
Definition: CMSUnits.h:13
HGCalHEAlgo::nCutRadPar_
int nCutRadPar_
Definition: DDHGCalHEAlgo.cc:570
geometryCSVtoXML.zz
zz
Definition: geometryCSVtoXML.py:19
g4SimHits_cfi.Material
Material
Definition: g4SimHits_cfi.py:560
MessageLogger.h
HGCalHEAlgo::absorbMode_
int absorbMode_
Definition: DDHGCalHEAlgo.cc:550
DECLARE_DDCMS_DETELEMENT
#define DECLARE_DDCMS_DETELEMENT(name, func)
Definition: DDPlugins.h:25
cms::DDNamespace::material
dd4hep::Material material(const std::string &name) const
Definition: DDNamespace.cc:116
filterCSVwithJSON.copy
copy
Definition: filterCSVwithJSON.py:36
HGCalHEAlgo::waferSize_
double waferSize_
Definition: DDHGCalHEAlgo.cc:572
min
T min(T a, T b)
Definition: MathUtil.h:58
cms::DDParsingContext
Definition: DDParsingContext.h:13
angle_units::operators::convertRadToDeg
constexpr NumType convertRadToDeg(NumType radians)
Definition: angle_units.h:21
cms::DDNamespace
Definition: DDNamespace.h:16
HGCalHEAlgo::waferNames_
std::vector< std::string > waferNames_
Definition: DDHGCalHEAlgo.cc:539
HGCalHEAlgo::zFrontT_
std::vector< double > zFrontT_
Definition: DDHGCalHEAlgo.cc:579
HGCalHEAlgo::layerNumbers_
std::vector< int > layerNumbers_
Definition: DDHGCalHEAlgo.cc:544
HGCalHEAlgo::layerThickTop_
std::vector< double > layerThickTop_
Definition: DDHGCalHEAlgo.cc:554
HGCalParameters::k_CornerSize
static constexpr uint32_t k_CornerSize
Definition: HGCalParameters.h:38
HGCalHEAlgo::geomTools_
HGCalGeomTools geomTools_
Definition: DDHGCalHEAlgo.cc:536
distTCMET_cfi.corner
corner
Definition: distTCMET_cfi.py:38
nin
int nin
Definition: CascadeWrapper.h:114
HGCalHEAlgo::copyNumberBot_
std::vector< int > copyNumberBot_
Definition: DDHGCalHEAlgo.cc:561
HGCalHEAlgo::waferSepar_
double waferSepar_
Definition: DDHGCalHEAlgo.cc:573
HGCalHEAlgo::materials_
std::vector< std::string > materials_
Definition: DDHGCalHEAlgo.cc:540
HGCalHEAlgo::copies_
std::unordered_set< int > copies_
Definition: DDHGCalHEAlgo.cc:581
findQualityFiles.v
v
Definition: findQualityFiles.py:179
edm::LogWarning
Log< level::Warning, false > LogWarning
Definition: MessageLogger.h:122
HGCalHEAlgo::zMinBlock_
double zMinBlock_
Definition: DDHGCalHEAlgo.cc:565
HGCalHEAlgo::fracAreaMin_
double fracAreaMin_
Definition: DDHGCalHEAlgo.cc:571
HGCalHEAlgo::rMinFront_
std::vector< double > rMinFront_
Definition: DDHGCalHEAlgo.cc:577
HGCalHEAlgo::layerTypeTop_
std::vector< int > layerTypeTop_
Definition: DDHGCalHEAlgo.cc:555
HGCalHEAlgo::materialsTop_
std::vector< std::string > materialsTop_
Definition: DDHGCalHEAlgo.cc:552
HGCalHEAlgo::HGCalHEAlgo
HGCalHEAlgo(cms::DDParsingContext &ctxt, xml_h e)
Definition: DDHGCalHEAlgo.cc:28
HGCalHEAlgo::rad200to300_
std::vector< double > rad200to300_
Definition: DDHGCalHEAlgo.cc:567
funct::cos
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
mathSSE::sqrt
T sqrt(T t)
Definition: SSEVec.h:19
HLT_FULL_cff.eta2
eta2
Definition: HLT_FULL_cff.py:9542
cms::DDNamespace::prepend
std::string prepend(const std::string &) const
Definition: DDNamespace.cc:60
HGCalWaferType.h
HGCalHEAlgo::layerSense_
std::vector< int > layerSense_
Definition: DDHGCalHEAlgo.cc:548
N
#define N
Definition: blowfish.cc:9
HGCalHEAlgo::HGCalHEAlgo
HGCalHEAlgo()
Definition: DDHGCalHEAlgo.cc:27
PixelTestBeamValidation_cfi.Position
Position
Definition: PixelTestBeamValidation_cfi.py:75
HGCalHEAlgo::layerThickBot_
std::vector< double > layerThickBot_
Definition: DDHGCalHEAlgo.cc:559
dqmdumpme.k
k
Definition: dqmdumpme.py:60
HGCalHEAlgo::volumeNames_
std::vector< std::string > volumeNames_
Definition: DDHGCalHEAlgo.cc:541
HGCalHEAlgo::layerCenter_
std::vector< int > layerCenter_
Definition: DDHGCalHEAlgo.cc:563
HGCalHEAlgo::positionMix
void positionMix(cms::DDParsingContext &ctxt, xml_h e, const dd4hep::Volume &glog, const std::string &nameM, int copyM, double thick, const dd4hep::Material &matter, double rin, double rmid, double rout, double zz)
Definition: DDHGCalHEAlgo.cc:295
HGCalTypes::packTypeUV
static int32_t packTypeUV(int type, int u, int v)
Definition: HGCalTypes.cc:3
HGCalHEAlgo::zMinRadPar_
double zMinRadPar_
Definition: DDHGCalHEAlgo.cc:568
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
HGCalHEAlgo::positionSensitive
void positionSensitive(cms::DDParsingContext &ctxt, xml_h e, const dd4hep::Volume &glog, double rin, double rout, double zpos, int layertype, int layercenter)
Definition: DDHGCalHEAlgo.cc:457
HGCalHEAlgo::copyNumberTop_
std::vector< int > copyNumberTop_
Definition: DDHGCalHEAlgo.cc:556
HLT_FULL_cff.eta1
eta1
Definition: HLT_FULL_cff.py:9541
angle_units::piRadians
constexpr long double piRadians(M_PIl)
HGCalHEAlgo::materialsBot_
std::vector< std::string > materialsBot_
Definition: DDHGCalHEAlgo.cc:557
HGCalHEAlgo::layerType_
std::vector< int > layerType_
Definition: DDHGCalHEAlgo.cc:547
cms::Volume
dd4hep::Volume Volume
Definition: DDFilteredView.h:47
HGCalHEAlgo::namesBot_
std::vector< std::string > namesBot_
Definition: DDHGCalHEAlgo.cc:558
HGCalHEAlgo::choiceType_
int choiceType_
Definition: DDHGCalHEAlgo.cc:569
EgHLTOffHistBins_cfi.nr
nr
Definition: EgHLTOffHistBins_cfi.py:4
HGCalHEAlgo::slopeB_
std::vector< double > slopeB_
Definition: DDHGCalHEAlgo.cc:575
algorithm
static long algorithm(dd4hep::Detector &, cms::DDParsingContext &ctxt, xml_h e)
Definition: DDHGCalHEAlgo.cc:588
type
type
Definition: SiPixelVCal_PayloadInspector.cc:37
HGCalHEAlgo::sectors_
int sectors_
Definition: DDHGCalHEAlgo.cc:574
gainCalibHelper::gainCalibPI::type
type
Definition: SiPixelGainCalibHelper.h:39
DDPlugins.h
funct::tan
Tan< T >::type tan(const T &t)
Definition: Tan.h:22
createfilelist.int
int
Definition: createfilelist.py:10
HGCalHEAlgo
Definition: DDHGCalHEAlgo.cc:26
HGCalHEAlgo::rad100to200_
std::vector< double > rad100to200_
Definition: DDHGCalHEAlgo.cc:566
HGCalGeomTools
Definition: HGCalGeomTools.h:8
cms::DDNamespace::addSolidNS
dd4hep::Solid addSolidNS(const std::string &name, dd4hep::Solid solid) const
Definition: DDNamespace.cc:221
cms::DDAlgoArguments
Definition: DDAlgoArguments.h:28
PVValHelper::dy
Definition: PVValidationHelpers.h:49
edm::LogError
Log< level::Error, false > LogError
Definition: MessageLogger.h:123
itr
std::vector< std::pair< float, float > >::iterator itr
Definition: HGCDigitizer.cc:29
cms::DDNamespace::addVolumeNS
dd4hep::Volume addVolumeNS(dd4hep::Volume vol) const
Definition: DDNamespace.cc:145
cms::s_executed
static constexpr long s_executed
Definition: DDAlgoArguments.h:16
alignCSCRings.r
r
Definition: alignCSCRings.py:93
HGCalHEAlgo::namesTop_
std::vector< std::string > namesTop_
Definition: DDHGCalHEAlgo.cc:553
HGCalHEAlgo::copyNumber_
std::vector< int > copyNumber_
Definition: DDHGCalHEAlgo.cc:543
HGCalHEAlgo::firstLayer_
int firstLayer_
Definition: DDHGCalHEAlgo.cc:549
HGCalHEAlgo::waferType_
std::unique_ptr< HGCalWaferType > waferType_
Definition: DDHGCalHEAlgo.cc:537
align::Detector
Definition: StructureType.h:86
HGCalGeomTools.h
HGCalGeomTools::radius
static void radius(double zf, double zb, std::vector< double > const &zFront1, std::vector< double > const &rFront1, std::vector< double > const &slope1, std::vector< double > const &zFront2, std::vector< double > const &rFront2, std::vector< double > const &slope2, int flag, std::vector< double > &zz, std::vector< double > &rin, std::vector< double > &rout)
Definition: HGCalGeomTools.cc:11
diffTwoXMLs.r1
r1
Definition: diffTwoXMLs.py:53
edm::LogVerbatim
Log< level::Info, true > LogVerbatim
Definition: MessageLogger.h:128
HGCalHEAlgo::slopeT_
std::vector< double > slopeT_
Definition: DDHGCalHEAlgo.cc:578
HGCalGeometryMode::Polyhedra
Definition: HGCalGeometryMode.h:35
HGCalHEAlgo::cosAlpha_
double cosAlpha_
Definition: DDHGCalHEAlgo.cc:582
Exception
Definition: hltDiff.cc:246
HGCalHEAlgo::layerTypeBot_
std::vector< int > layerTypeBot_
Definition: DDHGCalHEAlgo.cc:560
HGCalHEAlgo::layerThick_
std::vector< double > layerThick_
Definition: DDHGCalHEAlgo.cc:545
Skims_PA_cff.name
name
Definition: Skims_PA_cff.py:17
CMSUnits.h
dqm-mbProfile.log
log
Definition: dqm-mbProfile.py:17
funct::abs
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
HGCalHEAlgo::sensitiveMode_
int sensitiveMode_
Definition: DDHGCalHEAlgo.cc:551
HGCalHEAlgo::layerSenseBot_
std::vector< int > layerSenseBot_
Definition: DDHGCalHEAlgo.cc:562
HGCalTypes.h
edm::Log
Definition: MessageLogger.h:70
HGCalHEAlgo::zFrontB_
std::vector< double > zFrontB_
Definition: DDHGCalHEAlgo.cc:576
HGCalHEAlgo::rMaxFront_
std::vector< double > rMaxFront_
Definition: DDHGCalHEAlgo.cc:580
cms::DDNamespace::name
std::string_view name() const
Definition: DDNamespace.h:72
dttmaxenums::R
Definition: DTTMax.h:29
HGCalParameters.h
cuy.ii
ii
Definition: cuy.py:590
cms::DDNamespace::volume
dd4hep::Volume volume(const std::string &name, bool exc=true) const
Definition: DDNamespace.cc:205
HGCalHEAlgo::thickness_
std::vector< double > thickness_
Definition: DDHGCalHEAlgo.cc:542
MillePedeFileConverter_cfg.e
e
Definition: MillePedeFileConverter_cfg.py:37