CMS 3D CMS Logo

Functions
DDAHcalModuleAlgo.cc File Reference
#include "DataFormats/Math/interface/angle_units.h"
#include "DD4hep/DetFactoryHelper.h"
#include "DetectorDescription/DDCMS/interface/DDPlugins.h"
#include "DetectorDescription/DDCMS/interface/DDutils.h"
#include "FWCore/MessageLogger/interface/MessageLogger.h"
#include "FWCore/Utilities/interface/Exception.h"
#include "Geometry/HGCalCommonData/interface/AHCalParameters.h"

Go to the source code of this file.

Functions

static long algorithm (dd4hep::Detector &, cms::DDParsingContext &ctxt, xml_h e)
 
 DD4HEP_OPEN_PLUGIN (dd4hep, ddcms_det_element_DDCMS_hgcal_DDAHcalModuleAlgo)
 

Function Documentation

◆ algorithm()

static long algorithm ( dd4hep::Detector &  ,
cms::DDParsingContext ctxt,
xml_h  e 
)
static

Definition at line 18 of file DDAHcalModuleAlgo.cc.

References cms::DDNamespace::addSolidNS(), writedatasetfile::args, ALPAKA_ACCELERATOR_NAMESPACE::brokenline::constexpr(), cms::convert2mm(), filterCSVwithJSON::copy, MillePedeFileConverter_cfg::e, mps_fire::i, cuy::ii, AHCalParameters::kColumn_, AHCalParameters::kRowColumn_, AHCalParameters::kSignRowColumn_, hgcalTBTopologyTester_cfi::layers, cms::DDNamespace::material(), g4SimHits_cfi::Material, mergeVDriftHistosByStation::name, cms::DDNamespace::name(), names, EgHLTOffHistBins_cfi::nr, PixelTestBeamValidation_cfi::Position, cms::DDNamespace::prepend(), idealTransformation::rotation, cms::s_executed, AlCaHLTBitMon_QueryRunRegistry::string, to_string(), cms::DDNamespace::volume(), and geometryCSVtoXML::zz.

18  {
19  cms::DDNamespace ns(ctxt, e, true);
21  static constexpr double tol = 0.00001 * dd4hep::mm;
22 
23  const auto& tile = args.value<std::string>("TileName"); // Scintillator tile
24  const auto& materials = args.value<std::vector<std::string> >("MaterialNames"); // Materials
25  const auto& names = args.value<std::vector<std::string> >("VolumeNames"); // Names
26  const auto& thick = args.value<std::vector<double> >("Thickness"); // Thickness of the material
27  std::vector<int> copyNumber; // Initial copy numbers
28  copyNumber.resize(materials.size(), 1);
29 #ifdef EDM_ML_DEBUG
30  edm::LogVerbatim("HGCalGeom") << "DDAHcalModuleAlgo: Tile " << tile;
31  edm::LogVerbatim("HGCalGeom") << "DDAHcalModuleAlgo: " << materials.size() << " types of volumes";
32  for (unsigned int i = 0; i < names.size(); ++i)
33  edm::LogVerbatim("HGCalGeom") << "Volume [" << i << "] " << names[i] << " of thickness "
34  << cms::convert2mm(thick[i]) << " filled with " << materials[i]
35  << " first copy number " << copyNumber[i];
36 #endif
37  const auto& layers = args.value<std::vector<int> >("Layers"); // Number of layers in a section
38  const auto& layerThick = args.value<std::vector<double> >("LayerThick"); // Thickness of each section
39  const auto& layerType = args.value<std::vector<int> >("LayerType"); // Type of the layer
40  const auto& layerSense = args.value<std::vector<int> >("LayerSense"); // Content of a layer (sensitive?)
41 #ifdef EDM_ML_DEBUG
42  edm::LogVerbatim("HGCalGeom") << "DDAHcalModuleAlgo: " << layers.size() << " blocks";
43  for (unsigned int i = 0; i < layers.size(); ++i)
44  edm::LogVerbatim("HGCalGeom") << "Block [" << i << "] of thickness " << cms::convert2mm(layerThick[i]) << " with "
45  << layers[i] << " layers";
46  edm::LogVerbatim("HGCalGeom") << "DDAHcalModuleAlgo: " << layerType.size() << " layers";
47  for (unsigned int i = 0; i < layerType.size(); ++i)
48  edm::LogVerbatim("HGCalGeom") << "Layer [" << i << "] with material type " << layerType[i] << " sensitive class "
49  << layerSense[i];
50 #endif
51  const auto& widths = args.value<std::vector<double> >("Widths"); // Width (passive, active)
52  const auto& heights = args.value<std::vector<double> >("Heights"); // Heights (passive, active)
53  const auto& tileN = args.value<std::vector<int> >("TileN"); // # of tiles (along x, y)
54  const auto& tileStep = args.value<std::vector<double> >("TileStep"); // Separation between tiles (x, y)
55 #ifdef EDM_ML_DEBUG
56  edm::LogVerbatim("HGCalGeom") << "DDAHcalModuleAlgo: " << widths.size() << " sizes for width "
57  << "and height:";
58  for (unsigned int i = 0; i < widths.size(); ++i)
59  edm::LogVerbatim("HGCalGeom") << " [" << i << "] " << cms::convert2mm(widths[i]) << ":"
60  << cms::convert2mm(heights[i]);
61  edm::LogVerbatim("HGCalGeom") << "DDAHcalModuleAlgo: " << tileN.size() << " tile positioning parameters";
62  for (unsigned int i = 0; i < tileN.size(); ++i)
63  edm::LogVerbatim("HGCalGeom") << " [" << i << "] " << tileN[i] << ":" << cms::convert2mm(tileStep[i]);
64 #endif
65  const auto& zMinBlock = args.value<double>("zMinBlock"); // Starting z-value of the block
66 #ifdef EDM_ML_DEBUG
67  edm::LogVerbatim("HGCalGeom") << "DDHGCalModule: zStart " << cms::convert2mm(zMinBlock) << " NameSpace "
68  << ns.name();
69 #endif
70 
71  // Mother module
72  dd4hep::Volume module = ns.volume(args.parentName());
73 
74  double zi(zMinBlock);
75  int laymin(0);
76  for (unsigned int i = 0; i < layers.size(); i++) {
77  double zo = zi + layerThick[i];
78  int laymax = laymin + layers[i];
79  double zz = zi;
80  double thickTot(0);
81  for (int ly = laymin; ly < laymax; ++ly) {
82  int ii = layerType[ly];
83  int copy = copyNumber[ii];
84  zz += (0.5 * thick[ii]);
85  thickTot += thick[ii];
86 
87  std::string name = "HGCal" + names[ii] + std::to_string(copy);
88 #ifdef EDM_ML_DEBUG
89  edm::LogVerbatim("HGCalGeom") << "DDAHcalModuleAlgo test: Layer " << ly << ":" << ii << " Front "
90  << cms::convert2mm(zi) << " Back " << cms::convert2mm(zo)
91  << " superlayer thickness " << cms::convert2mm(layerThick[i]);
92 #endif
93  dd4hep::Material matter = ns.material(materials[ii]);
94  dd4hep::Volume glog;
95  if (layerSense[ly] == 0) {
96  dd4hep::Solid solid = dd4hep::Box(0.5 * widths[0], 0.5 * heights[0], 0.5 * thick[ii]);
97  ns.addSolidNS(ns.prepend(name), solid);
98  glog = dd4hep::Volume(solid.name(), solid, matter);
99 #ifdef EDM_ML_DEBUG
100  edm::LogVerbatim("HGCalGeom") << "DDAHcalModuleAlgo: " << solid.name() << " Box made of " << materials[ii]
101  << " of dimensions " << cms::convert2mm(0.5 * widths[0]) << ", "
102  << cms::convert2mm(0.5 * heights[0]) << ", " << cms::convert2mm(0.5 * thick[ii]);
103 #endif
104  } else {
105  dd4hep::Solid solid = dd4hep::Box(0.5 * widths[1], 0.5 * heights[1], 0.5 * thick[ii]);
106  ns.addSolidNS(ns.prepend(name), solid);
107  glog = dd4hep::Volume(solid.name(), solid, matter);
108 #ifdef EDM_ML_DEBUG
109  edm::LogVerbatim("HGCalGeom") << "DDAHcalModuleAlgo: " << solid.name() << " Box made of " << materials[ii]
110  << " of dimensions " << cms::convert2mm(0.5 * widths[1]) << ", "
111  << cms::convert2mm(0.5 * heights[1]) << ", " << cms::convert2mm(0.5 * thick[ii]);
112 #endif
113  int ncol = tileN[0] / 2;
114  int nrow = tileN[1] / 2;
115 #ifdef EDM_ML_DEBUG
116  int kount(0);
117  edm::LogVerbatim("HGCalGeom") << glog.name() << " Row " << nrow << " Column " << ncol;
118 #endif
119  for (int nr = -nrow; nr <= nrow; ++nr) {
120  int inr = (nr >= 0) ? nr : -nr;
121  double ypos = (nr >= 0) ? (inr - 0.5) * tileStep[1] : -(inr - 0.5) * tileStep[1];
122  for (int nc = -ncol; nc <= ncol; ++nc) {
123  int inc = (nc >= 0) ? nc : -nc;
124  double xpos = (nc >= 0) ? (inc - 0.5) * tileStep[0] : -(inc - 0.5) * tileStep[0];
125  if (nr != 0 && nc != 0) {
126  dd4hep::Position tran(xpos, ypos, 0.0);
127  dd4hep::Rotation3D rotation;
128  int copy = inr * AHCalParameters::kColumn_ + inc;
129  if (nc < 0)
131  if (nr < 0)
133  dd4hep::Volume glog1 = ns.volume(tile);
134  glog.placeVolume(glog1, copy, dd4hep::Transform3D(rotation, tran));
135 #ifdef EDM_ML_DEBUG
136  kount++;
137  edm::LogVerbatim("HGCalGeom")
138  << "DDAHcalModuleAlgo: " << tile << " number " << copy << " positioned in " << glog.name() << " at ("
139  << cms::convert2mm(xpos) << "," << cms::convert2mm(ypos) << ",0) with no rotation";
140 #endif
141  }
142  }
143  }
144 #ifdef EDM_ML_DEBUG
145  edm::LogVerbatim("HGCalGeom") << "DDAHcalModuleAlgo: " << kount << " tiles for " << glog.name();
146 #endif
147  }
148  dd4hep::Position r1(0, 0, zz);
149  module.placeVolume(glog, copy, r1);
150  ++copyNumber[ii];
151 #ifdef EDM_ML_DEBUG
152  edm::LogVerbatim("HGCalGeom") << "DDAHcalModuleAlgo: " << glog.name() << " number " << copy << " positioned in "
153  << module.name() << " at (0,0," << cms::convert2mm(zz) << ") with no rotation";
154 #endif
155  zz += (0.5 * thick[ii]);
156  } // End of loop over layers in a block
157  zi = zo;
158  laymin = laymax;
159  if (fabs(thickTot - layerThick[i]) > tol) {
160  if (thickTot > layerThick[i]) {
161  edm::LogError("HGCalGeom") << "Thickness of the partition " << cms::convert2mm(layerThick[i])
162  << " is smaller than thickness " << cms::convert2mm(thickTot)
163  << " of all its components **** ERROR ****\n";
164  } else {
165  edm::LogWarning("HGCalGeom") << "Thickness of the partition " << cms::convert2mm(layerThick[i])
166  << " does not match with " << cms::convert2mm(thickTot) << " of the components\n";
167  }
168  }
169  } // End of loop over blocks
170 
171  return cms::s_executed;
172 }
Log< level::Info, true > LogVerbatim
static constexpr int kSignRowColumn_
constexpr NumType convert2mm(NumType length)
Definition: DDutils.h:7
Log< level::Error, false > LogError
const std::string names[nVars_]
static std::string to_string(const XMLCh *ch)
static constexpr long s_executed
dd4hep::Volume Volume
ii
Definition: cuy.py:589
static constexpr int kRowColumn_
Log< level::Warning, false > LogWarning
static constexpr int kColumn_
Constants used.

◆ DD4HEP_OPEN_PLUGIN()

DD4HEP_OPEN_PLUGIN ( dd4hep  ,
ddcms_det_element_DDCMS_hgcal_DDAHcalModuleAlgo   
)

Definition at line 175 of file DDAHcalModuleAlgo.cc.