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::SensitiveDetector &)
 
 DD4HEP_OPEN_PLUGIN (dd4hep, ddcms_det_element_DDCMS_hgcal_DDAHcalModuleAlgo)
 

Function Documentation

◆ algorithm()

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

Definition at line 18 of file DDAHcalModuleAlgo.cc.

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

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, makeMuonMisalignmentScenario::rot, idealTransformation::rotation, 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 172 of file DDAHcalModuleAlgo.cc.

writedatasetfile.args
args
Definition: writedatasetfile.py:18
mps_fire.i
i
Definition: mps_fire.py:355
geometryCSVtoXML.zz
zz
Definition: geometryCSVtoXML.py:19
g4SimHits_cfi.Material
Material
Definition: g4SimHits_cfi.py:547
filterCSVwithJSON.copy
copy
Definition: filterCSVwithJSON.py:36
cms::DDNamespace
Definition: DDNamespace.h:16
names
const std::string names[nVars_]
Definition: PhotonIDValueMapProducer.cc:122
PixelTestBeamValidation_cfi.Position
Position
Definition: PixelTestBeamValidation_cfi.py:62
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
edm::LogWarning
Definition: MessageLogger.h:141
cms::Volume
dd4hep::Volume Volume
Definition: DDFilteredView.h:45
AHCalParameters::kSignRowColumn_
static constexpr int kSignRowColumn_
Definition: AHCalParameters.h:31
idealTransformation.rotation
dictionary rotation
Definition: idealTransformation.py:1
edm::LogError
Definition: MessageLogger.h:183
EgHLTOffHistBins_cfi.nr
nr
Definition: EgHLTOffHistBins_cfi.py:4
edm::LogVerbatim
Definition: MessageLogger.h:297
cms::DDAlgoArguments
Definition: DDAlgoArguments.h:28
AHCalParameters::kColumn_
static constexpr int kColumn_
Constants used.
Definition: AHCalParameters.h:27
module
Definition: vlib.h:198
MTDTopologyMode::Mode::tile
diffTwoXMLs.r1
r1
Definition: diffTwoXMLs.py:53
makeMuonMisalignmentScenario.rot
rot
Definition: makeMuonMisalignmentScenario.py:322
Skims_PA_cff.name
name
Definition: Skims_PA_cff.py:17
AHCalParameters::kRowColumn_
static constexpr int kRowColumn_
Definition: AHCalParameters.h:30
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