CMS 3D CMS Logo

Functions
DDAHcalModuleAlgo.cc File Reference
#include "DataFormats/Math/interface/CMSUnits.h"
#include "DD4hep/DetFactoryHelper.h"
#include "DetectorDescription/DDCMS/interface/DDPlugins.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.

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

References cms::DDNamespace::addSolidNS(), writedatasetfile::args, filterCSVwithJSON::copy, MillePedeFileConverter_cfg::e, mps_fire::i, cuy::ii, AHCalParameters::kColumn_, AHCalParameters::kRowColumn_, AHCalParameters::kSignRowColumn_, hgcalTopologyTester_cfi::layers, cms::DDNamespace::material(), g4SimHits_cfi::Material, Skims_PA_cff::name, cms::DDNamespace::name(), names, EgHLTOffHistBins_cfi::nr, PixelTestBeamValidation_cfi::Position, cms::DDNamespace::prepend(), diffTwoXMLs::r1, idealTransformation::rotation, cms::s_executed, AlCaHLTBitMon_QueryRunRegistry::string, cms::DDNamespace::volume(), and geometryCSVtoXML::zz.

◆ DD4HEP_OPEN_PLUGIN()

DD4HEP_OPEN_PLUGIN ( dd4hep  ,
ddcms_det_element_DDCMS_hgcal_DDAHcalModuleAlgo   
)

Definition at line 169 of file DDAHcalModuleAlgo.cc.

writedatasetfile.args
args
Definition: writedatasetfile.py:18
mps_fire.i
i
Definition: mps_fire.py:428
geometryCSVtoXML.zz
zz
Definition: geometryCSVtoXML.py:19
g4SimHits_cfi.Material
Material
Definition: g4SimHits_cfi.py:560
filterCSVwithJSON.copy
copy
Definition: filterCSVwithJSON.py:36
cms::DDNamespace
Definition: DDNamespace.h:16
edm::LogWarning
Log< level::Warning, false > LogWarning
Definition: MessageLogger.h:122
names
const std::string names[nVars_]
Definition: PhotonIDValueMapProducer.cc:124
PixelTestBeamValidation_cfi.Position
Position
Definition: PixelTestBeamValidation_cfi.py:75
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
cms::Volume
dd4hep::Volume Volume
Definition: DDFilteredView.h:47
AHCalParameters::kSignRowColumn_
static constexpr int kSignRowColumn_
Definition: AHCalParameters.h:31
idealTransformation.rotation
dictionary rotation
Definition: idealTransformation.py:1
EgHLTOffHistBins_cfi.nr
nr
Definition: EgHLTOffHistBins_cfi.py:4
cms::DDAlgoArguments
Definition: DDAlgoArguments.h:28
edm::LogError
Log< level::Error, false > LogError
Definition: MessageLogger.h:123
AHCalParameters::kColumn_
static constexpr int kColumn_
Constants used.
Definition: AHCalParameters.h:27
cms::s_executed
static constexpr long s_executed
Definition: DDAlgoArguments.h:16
MTDTopologyMode::Mode::tile
diffTwoXMLs.r1
r1
Definition: diffTwoXMLs.py:53
edm::LogVerbatim
Log< level::Info, true > LogVerbatim
Definition: MessageLogger.h:128
Skims_PA_cff.name
name
Definition: Skims_PA_cff.py:17
AHCalParameters::kRowColumn_
static constexpr int kRowColumn_
Definition: AHCalParameters.h:30
edm::Log
Definition: MessageLogger.h:70
cuy.ii
ii
Definition: cuy.py:590
hgcalTopologyTester_cfi.layers
layers
Definition: hgcalTopologyTester_cfi.py:8
MillePedeFileConverter_cfg.e
e
Definition: MillePedeFileConverter_cfg.py:37