CMS 3D CMS Logo

DDAHcalModuleAlgo.cc
Go to the documentation of this file.
1 // File: DDAHcalModuleAlgo.cc
3 // Description: Geometry factory class for HGCal (EE and HESil)
5 
6 #include <algorithm>
7 #include <cmath>
8 #include <string>
9 #include <vector>
10 
23 
24 //#define EDM_ML_DEBUG
25 
26 class DDAHcalModuleAlgo : public DDAlgorithm {
27 public:
28  // Constructor and Destructor
29  DDAHcalModuleAlgo(); // const std::string & name);
30  ~DDAHcalModuleAlgo() override;
31 
32  void initialize(const DDNumericArguments& nArgs,
33  const DDVectorArguments& vArgs,
34  const DDMapArguments& mArgs,
35  const DDStringArguments& sArgs,
36  const DDStringVectorArguments& vsArgs) override;
37  void execute(DDCompactView& cpv) override;
38 
39 protected:
40  void constructLayers(const DDLogicalPart&, DDCompactView& cpv);
42 
43 private:
44  std::string tile; // Scintillator tile
45  std::vector<std::string> materials; // Materials
46  std::vector<std::string> names; // Names
47  std::vector<double> thick; // Thickness of the material
48  std::vector<int> copyNumber; // Initial copy numbers
49  std::vector<int> layers; // Number of layers in a section
50  std::vector<double> layerThick; // Thickness of each section
51  std::vector<int> layerType; // Type of the layer
52  std::vector<int> layerSense; // Content of a layer (sensitive?)
53  std::vector<double> widths; // Width (passive, active)
54  std::vector<double> heights; // Heights (passive, active)
55  std::vector<int> tileN; // # of tiles (along x, y)
56  std::vector<double> tileStep; // Separation between tiles (x, y)
57  double zMinBlock; // Starting z-value of the block
58  std::string idNameSpace; // Namespace of this and ALL sub-parts
59 };
60 
62 #ifdef EDM_ML_DEBUG
63  edm::LogVerbatim("HGCalGeom") << "DDAHcalModuleAlgo: Creating an instance";
64 #endif
65 }
66 
68 
70  const DDVectorArguments& vArgs,
71  const DDMapArguments&,
72  const DDStringArguments& sArgs,
73  const DDStringVectorArguments& vsArgs) {
74  tile = sArgs["TileName"];
75 #ifdef EDM_ML_DEBUG
76  edm::LogVerbatim("HGCalGeom") << "DDAHcalModuleAlgo: Tile " << tile;
77 #endif
78  materials = vsArgs["MaterialNames"];
79  names = vsArgs["VolumeNames"];
80  thick = vArgs["Thickness"];
81  for (unsigned int i = 0; i < materials.size(); ++i) {
82  copyNumber.emplace_back(1);
83  }
84 #ifdef EDM_ML_DEBUG
85  edm::LogVerbatim("HGCalGeom") << "DDAHcalModuleAlgo: " << materials.size() << " types of volumes";
86  for (unsigned int i = 0; i < names.size(); ++i)
87  edm::LogVerbatim("HGCalGeom") << "Volume [" << i << "] " << names[i] << " of thickness " << thick[i]
88  << " filled with " << materials[i] << " first copy number " << copyNumber[i];
89 #endif
90  layers = dbl_to_int(vArgs["Layers"]);
91  layerThick = vArgs["LayerThick"];
92 #ifdef EDM_ML_DEBUG
93  edm::LogVerbatim("HGCalGeom") << "DDAHcalModuleAlgo: " << layers.size() << " blocks";
94  for (unsigned int i = 0; i < layers.size(); ++i)
95  edm::LogVerbatim("HGCalGeom") << "Block [" << i << "] of thickness " << layerThick[i] << " with " << layers[i]
96  << " layers";
97 #endif
98  layerType = dbl_to_int(vArgs["LayerType"]);
99  layerSense = dbl_to_int(vArgs["LayerSense"]);
100 #ifdef EDM_ML_DEBUG
101  edm::LogVerbatim("HGCalGeom") << "DDAHcalModuleAlgo: " << layerType.size() << " layers";
102  for (unsigned int i = 0; i < layerType.size(); ++i)
103  edm::LogVerbatim("HGCalGeom") << "Layer [" << i << "] with material type " << layerType[i] << " sensitive class "
104  << layerSense[i];
105 #endif
106  widths = vArgs["Widths"];
107  heights = vArgs["Heights"];
108 #ifdef EDM_ML_DEBUG
109  edm::LogVerbatim("HGCalGeom") << "DDAHcalModuleAlgo: " << widths.size() << " sizes for width "
110  << "and height:";
111  for (unsigned int i = 0; i < widths.size(); ++i)
112  edm::LogVerbatim("HGCalGeom") << " [" << i << "] " << widths[i] << ":" << heights[i];
113 #endif
114  tileN = dbl_to_int(vArgs["TileN"]);
115  tileStep = vArgs["TileStep"];
116 #ifdef EDM_ML_DEBUG
117  edm::LogVerbatim("HGCalGeom") << "DDAHcalModuleAlgo: " << tileN.size() << " tile positioning parameters";
118  for (unsigned int i = 0; i < tileN.size(); ++i)
119  edm::LogVerbatim("HGCalGeom") << " [" << i << "] " << tileN[i] << ":" << tileStep[i];
120 #endif
121  zMinBlock = nArgs["zMinBlock"];
123 #ifdef EDM_ML_DEBUG
124  edm::LogVerbatim("HGCalGeom") << "DDHGCalModule: zStart " << zMinBlock << " NameSpace " << idNameSpace;
125 #endif
126 }
127 
129 // DDAHcalModuleAlgo methods...
131 
133 #ifdef EDM_ML_DEBUG
134  edm::LogVerbatim("HGCalGeom") << "==>> Constructing DDAHcalModuleAlgo...";
135 #endif
136  constructLayers(parent(), cpv);
137 #ifdef EDM_ML_DEBUG
138  edm::LogVerbatim("HGCalGeom") << "<<== End of DDAHcalModuleAlgo construction";
139 #endif
140 }
141 
143 #ifdef EDM_ML_DEBUG
144  edm::LogVerbatim("HGCalGeom") << "DDAHcalModuleAlgo test: \t\tInside Layers";
145 #endif
146  double zi(zMinBlock);
147  int laymin(0);
148  for (unsigned int i = 0; i < layers.size(); i++) {
149  double zo = zi + layerThick[i];
150  int laymax = laymin + layers[i];
151  double zz = zi;
152  double thickTot(0);
153  for (int ly = laymin; ly < laymax; ++ly) {
154  int ii = layerType[ly];
155  int copy = copyNumber[ii];
156  zz += (0.5 * thick[ii]);
157  thickTot += thick[ii];
158 
159  std::string name = "HGCal" + names[ii] + std::to_string(copy);
160 #ifdef EDM_ML_DEBUG
161  edm::LogVerbatim("HGCalGeom") << "DDAHcalModuleAlgo test: Layer " << ly << ":" << ii << " Front " << zi
162  << " Back " << zo << " superlayer thickness " << layerThick[i];
163 #endif
165  DDMaterial matter(matName);
166  DDLogicalPart glog;
167  if (layerSense[ly] == 0) {
168  DDSolid solid =
169  DDSolidFactory::box(DDName(name, idNameSpace), 0.5 * widths[0], 0.5 * heights[0], 0.5 * thick[ii]);
170  glog = DDLogicalPart(solid.ddname(), matter, solid);
171 #ifdef EDM_ML_DEBUG
172  edm::LogVerbatim("HGCalGeom") << "DDAHcalModuleAlgo: " << solid.name() << " Box made of " << matName
173  << " of dimensions " << 0.5 * widths[0] << ", " << 0.5 * heights[0] << ", "
174  << 0.5 * thick[ii];
175 #endif
176  } else {
177  DDSolid solid =
178  DDSolidFactory::box(DDName(name, idNameSpace), 0.5 * widths[1], 0.5 * heights[1], 0.5 * thick[ii]);
179  glog = DDLogicalPart(solid.ddname(), matter, solid);
180 #ifdef EDM_ML_DEBUG
181  edm::LogVerbatim("HGCalGeom") << "DDAHcalModuleAlgo: " << solid.name() << " Box made of " << matName
182  << " of dimensions " << 0.5 * widths[1] << ", " << 0.5 * heights[1] << ", "
183  << 0.5 * thick[ii];
184 #endif
185  positionSensitive(glog, cpv);
186  }
187  DDTranslation r1(0, 0, zz);
188  DDRotation rot;
189  cpv.position(glog, module, copy, r1, rot);
190  ++copyNumber[ii];
191 #ifdef EDM_ML_DEBUG
192  edm::LogVerbatim("HGCalGeom") << "DDAHcalModuleAlgo: " << glog.name() << " number " << copy << " positioned in "
193  << module.name() << " at " << r1 << " with " << rot;
194 #endif
195  zz += (0.5 * thick[ii]);
196  } // End of loop over layers in a block
197  zi = zo;
198  laymin = laymax;
199  if (fabs(thickTot - layerThick[i]) < 0.00001) {
200  } else if (thickTot > layerThick[i]) {
201  edm::LogError("HGCalGeom") << "Thickness of the partition " << layerThick[i] << " is smaller than thickness "
202  << thickTot << " of all its components **** ERROR ****\n";
203  } else if (thickTot < layerThick[i]) {
204  edm::LogWarning("HGCalGeom") << "Thickness of the partition " << layerThick[i] << " does not match with "
205  << thickTot << " of the components\n";
206  }
207  } // End of loop over blocks
208 }
209 
211  int ncol = tileN[0] / 2;
212  int nrow = tileN[1] / 2;
213 #ifdef EDM_ML_DEBUG
214  int kount(0);
215  edm::LogVerbatim("HGCalGeom") << glog.ddname() << " Row " << nrow << " Column " << ncol;
216 #endif
217  for (int nr = -nrow; nr <= nrow; ++nr) {
218  int inr = (nr >= 0) ? nr : -nr;
219  double ypos = (nr >= 0) ? (inr - 0.5) * tileStep[1] : -(inr - 0.5) * tileStep[1];
220  for (int nc = -ncol; nc <= ncol; ++nc) {
221  int inc = (nc >= 0) ? nc : -nc;
222  double xpos = (nc >= 0) ? (inc - 0.5) * tileStep[0] : -(inc - 0.5) * tileStep[0];
223  if (nr != 0 && nc != 0) {
224  DDTranslation tran(xpos, ypos, 0.0);
226  int copy = inr * AHCalParameters::kColumn_ + inc;
227  if (nc < 0)
229  if (nr < 0)
232  cpv.position(name, glog.ddname(), copy, tran, rotation);
233 #ifdef EDM_ML_DEBUG
234  kount++;
235  edm::LogVerbatim("HGCalGeom") << "DDAHcalModuleAlgo: " << name << " number " << copy << " positioned in "
236  << glog.ddname() << " at " << tran << " with " << rotation;
237 #endif
238  }
239  }
240  }
241 #ifdef EDM_ML_DEBUG
242  edm::LogVerbatim("HGCalGeom") << "DDAHcalModuleAlgo: " << kount << " tiles for " << glog.ddname();
243 #endif
244 }
245 
246 DEFINE_EDM_PLUGIN(DDAlgorithmFactory, DDAHcalModuleAlgo, "hgcal:DDAHcalModuleAlgo");
PluginFactory.h
DDAHcalModuleAlgo::execute
void execute(DDCompactView &cpv) override
Definition: DDAHcalModuleAlgo.cc:132
DDCurrentNamespace.h
mps_fire.i
i
Definition: mps_fire.py:355
geometryCSVtoXML.zz
zz
Definition: geometryCSVtoXML.py:19
MessageLogger.h
DDAHcalModuleAlgo::heights
std::vector< double > heights
Definition: DDAHcalModuleAlgo.cc:54
filterCSVwithJSON.copy
copy
Definition: filterCSVwithJSON.py:36
DDAHcalModuleAlgo::layerSense
std::vector< int > layerSense
Definition: DDAHcalModuleAlgo.cc:52
DDName
DDName is used to identify DDD entities uniquely.
Definition: DDName.h:15
DDAHcalModuleAlgo::positionSensitive
void positionSensitive(DDLogicalPart &glog, DDCompactView &cpv)
Definition: DDAHcalModuleAlgo.cc:210
DDSplit.h
DDAHcalModuleAlgo::tile
std::string tile
Definition: DDAHcalModuleAlgo.cc:44
DDAHcalModuleAlgo::materials
std::vector< std::string > materials
Definition: DDAHcalModuleAlgo.cc:45
DDAHcalModuleAlgo::widths
std::vector< double > widths
Definition: DDAHcalModuleAlgo.cc:53
edm::second
U second(std::pair< T, U > const &p)
Definition: ParameterSet.cc:215
DDAHcalModuleAlgo::initialize
void initialize(const DDNumericArguments &nArgs, const DDVectorArguments &vArgs, const DDMapArguments &mArgs, const DDStringArguments &sArgs, const DDStringVectorArguments &vsArgs) override
Definition: DDAHcalModuleAlgo.cc:69
dbl_to_int
std::vector< int > dbl_to_int(const std::vector< double > &vecdbl)
Converts a std::vector of doubles to a std::vector of int.
Definition: DDutils.h:7
dqmdumpme.first
first
Definition: dqmdumpme.py:55
DDAHcalModuleAlgo::copyNumber
std::vector< int > copyNumber
Definition: DDAHcalModuleAlgo.cc:48
DDAHcalModuleAlgo::zMinBlock
double zMinBlock
Definition: DDAHcalModuleAlgo.cc:57
DDAHcalModuleAlgo::~DDAHcalModuleAlgo
~DDAHcalModuleAlgo() override
Definition: DDAHcalModuleAlgo.cc:67
DDMaterial
DDMaterial is used to define and access material information.
Definition: DDMaterial.h:45
DDTranslation
ROOT::Math::DisplacementVector3D< ROOT::Math::Cartesian3D< double > > DDTranslation
Definition: DDTranslation.h:7
DDCompactView
Compact representation of the geometrical detector hierarchy.
Definition: DDCompactView.h:80
DDBase::name
const N & name() const
Definition: DDBase.h:59
DDSolid.h
DEFINE_EDM_PLUGIN
#define DEFINE_EDM_PLUGIN(factory, type, name)
Definition: PluginFactory.h:124
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
edm::LogWarning
Definition: MessageLogger.h:141
DDAHcalModuleAlgo::layers
std::vector< int > layers
Definition: DDAHcalModuleAlgo.cc:49
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
DDBase::ddname
const N & ddname() const
Definition: DDBase.h:61
DDAHcalModuleAlgo
Definition: DDAHcalModuleAlgo.cc:26
edmplugin::PluginFactory
Definition: PluginFactory.h:34
DDAHcalModuleAlgo::thick
std::vector< double > thick
Definition: DDAHcalModuleAlgo.cc:47
DDLogicalPart
A DDLogicalPart aggregates information concerning material, solid and sensitveness ....
Definition: DDLogicalPart.h:93
DDTypes.h
DDMaterial.h
DDutils.h
edm::LogVerbatim
Definition: MessageLogger.h:297
DDAHcalModuleAlgo::DDAHcalModuleAlgo
DDAHcalModuleAlgo()
Definition: DDAHcalModuleAlgo.cc:61
DDLogicalPart.h
AHCalParameters::kColumn_
static constexpr int kColumn_
Constants used.
Definition: AHCalParameters.h:27
module
Definition: vlib.h:198
DDAHcalModuleAlgo::names
std::vector< std::string > names
Definition: DDAHcalModuleAlgo.cc:46
ReadMapType< double >
DDAlgorithm.h
DDAHcalModuleAlgo::tileN
std::vector< int > tileN
Definition: DDAHcalModuleAlgo.cc:55
DDAHcalModuleAlgo::idNameSpace
std::string idNameSpace
Definition: DDAHcalModuleAlgo.cc:58
AHCalParameters.h
diffTwoXMLs.r1
r1
Definition: diffTwoXMLs.py:53
DDCurrentNamespace::ns
static std::string & ns()
Definition: DDCurrentNamespace.cc:3
makeMuonMisalignmentScenario.rot
rot
Definition: makeMuonMisalignmentScenario.py:322
DDAHcalModuleAlgo::layerType
std::vector< int > layerType
Definition: DDAHcalModuleAlgo.cc:51
Skims_PA_cff.name
name
Definition: Skims_PA_cff.py:17
DDSolid
A DDSolid represents the shape of a part.
Definition: DDSolid.h:39
DDRotation
Represents a uniquely identifyable rotation matrix.
Definition: DDTransform.h:57
DDAHcalModuleAlgo::constructLayers
void constructLayers(const DDLogicalPart &, DDCompactView &cpv)
Definition: DDAHcalModuleAlgo.cc:142
DDAHcalModuleAlgo::layerThick
std::vector< double > layerThick
Definition: DDAHcalModuleAlgo.cc:50
DDSolidFactory::box
static DDSolid box(const DDName &name, double xHalf, double yHalf, double zHalf)
Creates a box with side length 2*xHalf, 2*yHalf, 2*zHalf.
Definition: DDSolid.cc:533
AHCalParameters::kRowColumn_
static constexpr int kRowColumn_
Definition: AHCalParameters.h:30
DDAlgorithmFactory.h
class-composition.parent
parent
Definition: class-composition.py:88
cuy.ii
ii
Definition: cuy.py:590
DDAHcalModuleAlgo::tileStep
std::vector< double > tileStep
Definition: DDAHcalModuleAlgo.cc:56
DDSplit
std::pair< std::string, std::string > DDSplit(const std::string &n)
split into (name,namespace), separator = ':'
Definition: DDSplit.cc:3
DDCompactView::position
void position(const DDLogicalPart &self, const DDLogicalPart &parent, const std::string &copyno, const DDTranslation &trans, const DDRotation &rot, const DDDivision *div=nullptr)
Definition: DDCompactView.cc:66