CMS 3D CMS Logo

List of all members | Public Member Functions
HGCalPassive Struct Reference

Public Member Functions

 HGCalPassive ()
 
 HGCalPassive (cms::DDParsingContext &ctxt, xml_h e)
 

Detailed Description

Definition at line 22 of file DDHGCalPassive.cc.

Constructor & Destructor Documentation

◆ HGCalPassive() [1/2]

HGCalPassive::HGCalPassive ( )
inline

Definition at line 23 of file DDHGCalPassive.cc.

References Exception.

23 { throw cms::Exception("HGCalGeom") << "Wrong initialization to HGCalPassive"; }

◆ HGCalPassive() [2/2]

HGCalPassive::HGCalPassive ( cms::DDParsingContext ctxt,
xml_h  e 
)
inline

Definition at line 24 of file DDHGCalPassive.cc.

References funct::abs(), cms::DDNamespace::addSolidNS(), writedatasetfile::args, ALPAKA_ACCELERATOR_NAMESPACE::brokenline::constexpr(), cms::convert2mm(), angle_units::operators::convertRadToDeg(), funct::cos(), MillePedeFileConverter_cfg::e, HGCalGeometryMode::ExtrudedPolygon, mps_fire::i, testProducerWithPsetDescEmpty_cfi::i1, testProducerWithPsetDescEmpty_cfi::i2, testProducerWithPsetDescEmpty_cfi::i3, dqmiolumiharvest::j, isotrackApplyRegressor::k, GetRecoTauVFromDQM_MC_cff::kk, MainPageGenerator::l, cms::DDNamespace::material(), g4SimHits_cfi::Material, PixelTestBeamValidation_cfi::Position, position, cms::DDNamespace::prepend(), isotrackNtupler::scale, mergeVDriftHistosByStation::sectors, funct::sin(), AlCaHLTBitMon_QueryRunRegistry::string, to_string(), and zw().

24  {
25  cms::DDNamespace ns(ctxt, e, true);
27 #ifdef EDM_ML_DEBUG
28  edm::LogVerbatim("HGCalGeom") << "DDHGCalPassive: Creating an instance";
29 #endif
30  std::string parentName = args.parentName();
31  std::string moduleMaterial = args.value<std::string>("ModuleMaterial"); // Material name for mother volume
32  double moduleThick = args.value<double>("ModuleThick"); // Thickness of the overall module
33  int sectors = args.value<int>("Sectors"); // number of phi sectors (cassettes)
34  std::vector<std::string> tagsector; // Tag of the sector (to be added to name)
35  for (int k = 0; k < sectors; ++k)
36  tagsector.emplace_back("F" + std::to_string(k));
37  int position = args.value<int>("Position"); // 0 if -z; 1 if +z
38  std::vector<std::string> tagpos; // Tags for the modules
39  std::vector<int> xsignpos; // sign of the x-value;
40  if (position == 0) {
41  tagpos.emplace_back("PN");
42  xsignpos.emplace_back(-1);
43  } else {
44  tagpos.emplace_back("PP");
45  xsignpos.emplace_back(1);
46  }
47  double phi0 = args.value<double>("PhiStart"); // Start phi of the first cassette
48  double dphi = (2._pi) / tagsector.size(); // delta phi of the cassette
49 #ifdef EDM_ML_DEBUG
50  std::ostringstream st0, st1;
51  for (unsigned int k = 0; k < tagsector.size(); ++k)
52  st0 << ": " << tagsector[k];
53  for (unsigned int k = 0; k < tagpos.size(); ++k)
54  st1 << " " << tagpos[k] << ":" << xsignpos[k];
55  edm::LogVerbatim("HGCalGeom") << "DDHGCalPassive: " << tagpos.size() << " Modules with base name " << parentName
56  << " made of " << moduleMaterial << " T " << moduleThick << " having " << sectors
57  << " sectors" << st0.str() << " phi0 " << convertRadToDeg(phi0) << " dphi "
58  << convertRadToDeg(dphi) << " Tags:" << st1.str();
59 #endif
60  std::vector<std::string> layerNames = args.value<std::vector<std::string>>("LayerNames"); // Names of the layers
61  std::vector<std::string> layerMaterials =
62  args.value<std::vector<std::string>>("LayerMaterials"); // Materials of the layers
63  std::vector<double> layerThick = args.value<std::vector<double>>("LayerThickness"); // Thickness of layers
64  std::vector<int> layerType = args.value<std::vector<int>>("LayerType"); // Layer types
65 #ifdef EDM_ML_DEBUG
66  edm::LogVerbatim("HGCalGeom") << "DDHGCalPassive: " << layerNames.size() << " types of volumes";
67  for (unsigned int i = 0; i < layerNames.size(); ++i)
68  edm::LogVerbatim("HGCalGeom") << "Volume [" << i << "] " << layerNames[i] << " of thickness " << layerThick[i]
69  << " filled with " << layerMaterials[i];
70  std::ostringstream st2;
71  for (unsigned int i = 0; i < layerType.size(); ++i)
72  st2 << " [" << i << "] " << layerType[i];
73  edm::LogVerbatim("HGCalGeom") << "There are " << layerType.size() << " blocks" << st2.str();
74 #endif
75 
76  std::vector<std::string> absNames =
77  args.value<std::vector<std::string>>("AbsorberName"); // Names of the absorber layers
78  std::vector<int> absN = args.value<std::vector<int>>("AbsorberN"); // Number of point in each layer
79  std::vector<double> absX = args.value<std::vector<double>>("AbsorberX"); // x coordinates of abs layers
80  std::vector<double> absY = args.value<std::vector<double>>("AbsorberY"); // y coordinates of abs layers
81 #ifdef EDM_ML_DEBUG
82  edm::LogVerbatim("HGCalGeom") << "There are " << absNames.size() << " basic absorber shapes:";
83  unsigned int j(0);
84  for (unsigned int k = 0; k < absNames.size(); ++k) {
85  std::ostringstream st3;
86  st3 << absNames[k] << " with " << absN[k] << " points:";
87  for (int i = 0; i < absN[k]; ++i)
88  st3 << " (" << absX[j + i] << ", " << absY[j + i] << ")";
89  j += absN[k];
90  edm::LogVerbatim("HGCalGeom") << st3.str();
91  }
92 #endif
93 
94  static constexpr double tol = 0.00001;
95 
96  // Loop over positions
97  for (unsigned int i1 = 0; i1 < tagpos.size(); ++i1) {
98  // Loop over sectors
99  for (int i2 = 0; i2 < sectors; ++i2) {
100  double phi = phi0 + i2 * dphi;
101  double cphi = std::cos(phi);
102  double sphi = std::sin(phi);
103  // Loop over passive volumes
104  int j(0);
105  for (unsigned i3 = 0; i3 < absNames.size(); ++i3) {
106  //First make the mother
107  std::string parentname = parentName + absNames[i3] + tagsector[i2] + tagpos[i1];
108  std::vector<double> zw = {-0.5 * moduleThick, 0.5 * moduleThick};
109  std::vector<double> zx(2, 0), zy(2, 0), scale(2, 1.0);
110  std::vector<double> xM(absN[i3], 0), yM(absN[i3], 0);
111  for (int k = 0; k < absN[i3]; ++k) {
112  xM[k] = xsignpos[i1] * (cphi * absX[j + k] + sphi * absY[j + k]);
113  yM[k] = -sphi * absX[j + k] + cphi * absY[j + k];
114  }
115  j += absN[i3];
116  dd4hep::Solid solid = dd4hep::ExtrudedPolygon(xM, yM, zw, zx, zy, scale);
117  ns.addSolidNS(ns.prepend(parentname), solid);
118  dd4hep::Material matter = ns.material(moduleMaterial);
119  dd4hep::Volume glogM = dd4hep::Volume(solid.name(), solid, matter);
120 #ifdef EDM_ML_DEBUG
121  edm::LogVerbatim("HGCalGeom") << "DDHGCalPassive: " << solid.name() << " extruded polygon made of "
122  << matter.name() << " z|x|y|s (0) " << zw[0] << ":" << zx[0] << ":" << zy[0]
123  << ":" << scale[0] << " z|x|y|s (1) " << zw[1] << ":" << zx[1] << ":" << zy[1]
124  << ":" << scale[1] << " and " << xM.size() << " edges";
125  for (unsigned int kk = 0; kk < xM.size(); ++kk)
126  edm::LogVerbatim("HGCalGeom") << "[" << kk << "] " << xM[kk] << ":" << yM[kk];
127 #endif
128  // Then the layers
129  std::vector<dd4hep::Volume> glogs(layerMaterials.size());
130  std::vector<int> copyNumber(layerMaterials.size(), 1);
131  double zi(-0.5 * moduleThick), thickTot(0.0);
132  for (unsigned int l = 0; l < layerType.size(); l++) {
133  unsigned int i = layerType[l];
134  if (copyNumber[i] == 1) {
135  zw[0] = -0.5 * layerThick[i];
136  zw[1] = 0.5 * layerThick[i];
137  std::string layerName = parentname + layerNames[i];
138  solid = dd4hep::ExtrudedPolygon(xM, yM, zw, zx, zy, scale);
139  ns.addSolidNS(ns.prepend(layerName), solid);
140  matter = ns.material(layerMaterials[i]);
141  glogs[i] = dd4hep::Volume(solid.name(), solid, matter);
142 #ifdef EDM_ML_DEBUG
143  edm::LogVerbatim("HGCalGeom")
144  << "DDHGCalPassive: Layer " << i << ":" << l << ":" << solid.name() << " extruded polygon made of "
145  << matter.name() << " z|x|y|s (0) " << zw[0] << ":" << zx[0] << ":" << zy[0] << ":" << scale[0]
146  << " z|x|y|s (1) " << zw[1] << ":" << zx[1] << ":" << zy[1] << ":" << scale[1] << " and " << xM.size()
147  << " edges";
148  for (unsigned int kk = 0; kk < xM.size(); ++kk)
149  edm::LogVerbatim("HGCalGeom") << "[" << kk << "] " << xM[kk] << ":" << yM[kk];
150 #endif
151  }
152  dd4hep::Position tran0(0, 0, (zi + 0.5 * layerThick[i]));
153  glogM.placeVolume(glogs[i], copyNumber[i], tran0);
154 #ifdef EDM_ML_DEBUG
155  edm::LogVerbatim("HGCalGeom")
156  << "DDHGCalPassive: " << glogs[i].name() << " number " << copyNumber[i] << " positioned in "
157  << glogM.name() << " at (0, 0, " << cms::convert2mm(zi + 0.5 * layerThick[i]) << ") with no rotation";
158 #endif
159  ++copyNumber[i];
160  zi += layerThick[i];
161  thickTot += layerThick[i];
162  }
163  if ((std::abs(thickTot - moduleThick) >= tol) && (!layerType.empty())) {
164  if (thickTot > moduleThick) {
165  edm::LogError("HGCalGeom") << "Thickness of the partition " << moduleThick << " is smaller than "
166  << thickTot << ": thickness of all its components **** ERROR ****";
167  } else {
168  edm::LogWarning("HGCalGeom") << "Thickness of the partition " << moduleThick << " does not match with "
169  << thickTot << " of the components";
170  }
171  }
172  }
173  }
174  }
175  }
Log< level::Info, true > LogVerbatim
constexpr NumType convertRadToDeg(NumType radians)
Definition: angle_units.h:21
constexpr NumType convert2mm(NumType length)
Definition: DDutils.h:7
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
Log< level::Error, false > LogError
static std::string to_string(const XMLCh *ch)
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
dd4hep::Volume Volume
static int position[264][3]
Definition: ReadPGInfo.cc:289
auto zw(V v) -> Vec2< typename std::remove_reference< decltype(v[0])>::type >
Definition: ExtVec.h:84
Log< level::Warning, false > LogWarning