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 
17 
18 //#define EDM_ML_DEBUG
19 
21 #ifdef EDM_ML_DEBUG
22  edm::LogVerbatim("HGCalGeom") << "DDAHcalModuleAlgo: Creating an instance";
23 #endif
24 }
25 
27 
29  const DDVectorArguments& vArgs,
30  const DDMapArguments&,
31  const DDStringArguments& sArgs,
32  const DDStringVectorArguments& vsArgs) {
33  tile = sArgs["TileName"];
34 #ifdef EDM_ML_DEBUG
35  edm::LogVerbatim("HGCalGeom") << "DDAHcalModuleAlgo: Tile " << tile;
36 #endif
37  materials = vsArgs["MaterialNames"];
38  names = vsArgs["VolumeNames"];
39  thick = vArgs["Thickness"];
40  for (unsigned int i = 0; i < materials.size(); ++i) {
41  copyNumber.emplace_back(1);
42  }
43 #ifdef EDM_ML_DEBUG
44  edm::LogVerbatim("HGCalGeom")
45  << "DDAHcalModuleAlgo: " << materials.size() << " types of volumes";
46  for (unsigned int i = 0; i < names.size(); ++i)
47  edm::LogVerbatim("HGCalGeom")
48  << "Volume [" << i << "] " << names[i] << " of thickness " << thick[i]
49  << " filled with " << materials[i] << " first copy number "
50  << copyNumber[i];
51 #endif
52  layers = dbl_to_int(vArgs["Layers"]);
53  layerThick = vArgs["LayerThick"];
54 #ifdef EDM_ML_DEBUG
55  edm::LogVerbatim("HGCalGeom")
56  << "DDAHcalModuleAlgo: " << layers.size() << " blocks";
57  for (unsigned int i = 0; i < layers.size(); ++i)
58  edm::LogVerbatim("HGCalGeom")
59  << "Block [" << i << "] of thickness " << layerThick[i] << " with "
60  << layers[i] << " layers";
61 #endif
62  layerType = dbl_to_int(vArgs["LayerType"]);
63  layerSense = dbl_to_int(vArgs["LayerSense"]);
64 #ifdef EDM_ML_DEBUG
65  edm::LogVerbatim("HGCalGeom")
66  << "DDAHcalModuleAlgo: " << layerType.size() << " layers";
67  for (unsigned int i = 0; i < layerType.size(); ++i)
68  edm::LogVerbatim("HGCalGeom")
69  << "Layer [" << i << "] with material type " << layerType[i]
70  << " sensitive class " << layerSense[i];
71 #endif
72  widths = vArgs["Widths"];
73  heights = vArgs["Heights"];
74 #ifdef EDM_ML_DEBUG
75  edm::LogVerbatim("HGCalGeom")
76  << "DDAHcalModuleAlgo: " << widths.size() << " sizes for width "
77  << "and height:";
78  for (unsigned int i = 0; i < widths.size(); ++i)
79  edm::LogVerbatim("HGCalGeom")
80  << " [" << i << "] " << widths[i] << ":" << heights[i];
81 #endif
82  tileN = dbl_to_int(vArgs["TileN"]);
83  tileStep = vArgs["TileStep"];
84 #ifdef EDM_ML_DEBUG
85  edm::LogVerbatim("HGCalGeom")
86  << "DDAHcalModuleAlgo: " << tileN.size() << " tile positioning parameters";
87  for (unsigned int i = 0; i < tileN.size(); ++i)
88  edm::LogVerbatim("HGCalGeom")
89  << " [" << i << "] " << tileN[i] << ":" << tileStep[i];
90 #endif
91  zMinBlock = nArgs["zMinBlock"];
93 #ifdef EDM_ML_DEBUG
94  edm::LogVerbatim("HGCalGeom")
95  << "DDAHcalModuleAlgo: NameSpace " << idNameSpace;
96 #endif
97 }
98 
100 // DDAHcalModuleAlgo methods...
102 
104 #ifdef EDM_ML_DEBUG
105  edm::LogVerbatim("HGCalGeom") << "==>> Constructing DDAHcalModuleAlgo...";
106 #endif
107  constructLayers(parent(), cpv);
108 #ifdef EDM_ML_DEBUG
109  edm::LogVerbatim("HGCalGeom") <<"<<== End of DDAHcalModuleAlgo construction";
110 #endif
111 }
112 
114  DDCompactView& cpv) {
115 #ifdef EDM_ML_DEBUG
116  edm::LogVerbatim("HGCalGeom") << "DDAHcalModuleAlgo test: \t\tInside Layers";
117 #endif
118  double zi(zMinBlock);
119  int laymin(0);
120  for (unsigned int i = 0; i < layers.size(); i++) {
121  double zo = zi + layerThick[i];
122  int laymax = laymin + layers[i];
123  double zz = zi;
124  double thickTot(0);
125  for (int ly = laymin; ly < laymax; ++ly) {
126  int ii = layerType[ly];
127  int copy = copyNumber[ii];
128  zz += (0.5 * thick[ii]);
129  thickTot += thick[ii];
130 
131  std::string name = "HGCal" + names[ii] + std::to_string(copy);
132 #ifdef EDM_ML_DEBUG
133  edm::LogVerbatim("HGCalGeom")
134  << "DDAHcalModuleAlgo test: Layer " << ly << ":" << ii << " Front "
135  << zi << " Back " << zo << " superlayer thickness " << layerThick[i];
136 #endif
137  DDName matName(DDSplit(materials[ii]).first,
138  DDSplit(materials[ii]).second);
139  DDMaterial matter(matName);
140  DDLogicalPart glog;
141  if (layerSense[ly] == 0) {
142  DDSolid solid =
143  DDSolidFactory::box(DDName(name, idNameSpace), 0.5 * widths[0],
144  0.5 * heights[0], 0.5 * thick[ii]);
145  glog = DDLogicalPart(solid.ddname(), matter, solid);
146 #ifdef EDM_ML_DEBUG
147  edm::LogVerbatim("HGCalGeom")
148  << "DDAHcalModuleAlgo: " << solid.name() << " Box made of "
149  << matName << " of dimensions " << 0.5 * widths[0] << ", "
150  << 0.5 * heights[0] << ", " << 0.5 * thick[ii];
151 #endif
152  } else {
153  DDSolid solid =
154  DDSolidFactory::box(DDName(name, idNameSpace), 0.5 * widths[1],
155  0.5 * heights[1], 0.5 * thick[ii]);
156  glog = DDLogicalPart(solid.ddname(), matter, solid);
157 #ifdef EDM_ML_DEBUG
158  edm::LogVerbatim("HGCalGeom")
159  << "DDAHcalModuleAlgo: " << solid.name() << " Box made of "
160  << matName << " of dimensions " << 0.5 * widths[1] << ", "
161  << 0.5 * heights[1] << ", " << 0.5 * thick[ii];
162 #endif
163  positionSensitive(glog, cpv);
164  }
165  DDTranslation r1(0, 0, zz);
166  DDRotation rot;
167  cpv.position(glog, module, copy, r1, rot);
168  ++copyNumber[ii];
169 #ifdef EDM_ML_DEBUG
170  edm::LogVerbatim("HGCalGeom")
171  << "DDAHcalModuleAlgo: " << glog.name() << " number " << copy
172  << " positioned in " << module.name() << " at " << r1 << " with "
173  << rot;
174 #endif
175  zz += (0.5 * thick[ii]);
176  } // End of loop over layers in a block
177  zi = zo;
178  laymin = laymax;
179  if (fabs(thickTot - layerThick[i]) < 0.00001) {
180  } else if (thickTot > layerThick[i]) {
181  edm::LogError("HGCalGeom")
182  << "Thickness of the partition " << layerThick[i]
183  << " is smaller than thickness " << thickTot
184  << " of all its components **** ERROR ****\n";
185  } else if (thickTot < layerThick[i]) {
186  edm::LogWarning("HGCalGeom")
187  << "Thickness of the partition " << layerThick[i]
188  << " does not match with " << thickTot << " of the components\n";
189  }
190  } // End of loop over blocks
191 }
192 
194  DDCompactView& cpv) {
195  int ncol = tileN[0] / 2;
196  int nrow = tileN[1] / 2;
197 #ifdef EDM_ML_DEBUG
198  int kount(0);
199  edm::LogVerbatim("HGCalGeom")
200  << glog.ddname() << " Row " << nrow << " Column " << ncol;
201 #endif
202  for (int nr = -nrow; nr <= nrow; ++nr) {
203  int inr = (nr >= 0) ? nr : -nr;
204  double ypos =
205  (nr >= 0) ? (inr - 0.5) * tileStep[1] : -(inr - 0.5) * tileStep[1];
206  for (int nc = -ncol; nc <= ncol; ++nc) {
207  int inc = (nc >= 0) ? nc : -nc;
208  double xpos =
209  (nc >= 0) ? (inc - 0.5) * tileStep[0] : -(inc - 0.5) * tileStep[0];
210  if (nr != 0 && nc != 0) {
211  DDTranslation tran(xpos, ypos, 0.0);
213  int copy = inr * 10 + inc;
214  if (nc < 0) copy += 100;
215  if (nr < 0) copy += 1000;
217  cpv.position(name, glog.ddname(), copy, tran, rotation);
218 #ifdef EDM_ML_DEBUG
219  kount++;
220  edm::LogVerbatim("HGCalGeom")
221  << "DDAHcalModuleAlgo: " << name << " number " << copy
222  << " positioned in " << glog.ddname() << " at " << tran
223  << " with " << rotation;
224 #endif
225  }
226  }
227  }
228 #ifdef EDM_ML_DEBUG
229  edm::LogVerbatim("HGCalGeom")
230  << "DDAHcalModuleAlgo: " << kount << " tiles for " << glog.ddname();
231 #endif
232 }
std::vector< int > layerType
std::vector< std::string > materials
std::vector< double > widths
void constructLayers(const DDLogicalPart &, DDCompactView &cpv)
const N & name() const
Definition: DDBase.h:74
std::vector< int > copyNumber
def copy(args, dbName)
DDMaterial is used to define and access material information.
Definition: DDMaterial.h:43
~DDAHcalModuleAlgo() override
DDName is used to identify DDD entities uniquely.
Definition: DDName.h:15
std::vector< double > heights
void execute(DDCompactView &cpv) override
static std::string & ns()
Compact representation of the geometrical detector hierarchy.
Definition: DDCompactView.h:80
A DDSolid represents the shape of a part.
Definition: DDSolid.h:39
ROOT::Math::DisplacementVector3D< ROOT::Math::Cartesian3D< double > > DDTranslation
Definition: DDTranslation.h:7
Represents a uniquely identifyable rotation matrix.
Definition: DDTransform.h:68
U second(std::pair< T, U > const &p)
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
std::vector< double > thick
std::vector< std::string > names
void initialize(const DDNumericArguments &nArgs, const DDVectorArguments &vArgs, const DDMapArguments &mArgs, const DDStringArguments &sArgs, const DDStringVectorArguments &vsArgs) override
A DDLogicalPart aggregates information concerning material, solid and sensitveness ...
Definition: DDLogicalPart.h:93
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:704
ii
Definition: cuy.py:590
std::vector< double > layerThick
std::vector< double > tileStep
void position(const DDLogicalPart &self, const DDLogicalPart &parent, const std::string &copyno, const DDTranslation &trans, const DDRotation &rot, const DDDivision *div=0)
std::vector< int > layers
std::pair< std::string, std::string > DDSplit(const std::string &n)
split into (name,namespace), separator = &#39;:&#39;
Definition: DDSplit.cc:3
std::vector< int > tileN
Definition: vlib.h:208
std::vector< int > layerSense
void positionSensitive(DDLogicalPart &glog, DDCompactView &cpv)
std::string idNameSpace
const N & ddname() const
Definition: DDBase.h:76