CMS 3D CMS Logo

DDEcalPreshowerAlgo.cc
Go to the documentation of this file.
1 #include <cmath>
2 #include <algorithm>
3 
8 #include <CLHEP/Units/SystemOfUnits.h>
9 #include <vector>
10 #include <string>
11 
14 
15 using CLHEP::cm;
16 using CLHEP::deg;
17 using CLHEP::mm;
18 //#define EDM_ML_DEBUG
19 
20 class DDEcalPreshowerAlgo : public DDAlgorithm {
21 public:
22  DDMaterial getMaterial(unsigned int i) const { return DDMaterial(materials_[i]); }
24  std::string getLayName(unsigned int i) const { return layName_[i]; }
25  std::string getLadPrefix(unsigned int i) const { return ladPfx_[i]; }
26 
28  void initialize(const DDNumericArguments& nArgs,
29  const DDVectorArguments& vArgs,
30  const DDMapArguments& mArgs,
31  const DDStringArguments& sArgs,
32  const DDStringVectorArguments& vsArgs) override;
33  void execute(DDCompactView& pos) override;
34 
35 private:
36  void doLayers(DDCompactView& pos);
38  void doSens(DDCompactView& pos);
39 
40  int nmat_; // number of preshower layers
41  double thickness_; // overall thickness of the preshower envelope
42  std::vector<std::string> materials_; // materials of the presh-layers
43  std::vector<std::string> layName_; // names of the presh-layers
44  std::vector<std::string> ladPfx_; // name prefix for ladders
45  std::string LaddMaterial_; // ladd material - air
46  std::vector<double> thickLayers_;
47  std::vector<double> abs1stx;
48  std::vector<double> abs1sty;
49  std::vector<double> abs2ndx;
50  std::vector<double> abs2ndy;
51  std::vector<double> asym_ladd_;
52  std::vector<double> rminVec;
53  std::vector<double> rmaxVec;
54  std::vector<double> noLaddInCol_;
55  std::vector<double> startOfFirstLadd_;
56  std::vector<std::string> types_l5_;
57  std::vector<std::string> types_l4_;
58  std::vector<double> ladd_l5_map_;
59  std::vector<double> ladd_l4_map_;
60  std::vector<std::string> typeOfLaddRow0;
61  std::vector<std::string> typeOfLaddRow1;
62  std::vector<std::string> typeOfLaddRow2;
63  std::vector<std::string> typeOfLaddRow3;
64 
72 };
73 
75 #ifdef EDM_ML_DEBUG
76  edm::LogVerbatim("EcalGeom") << "DDEcalPreshowerAlgo info: Creating an instance";
77 #endif
78 }
79 
81  const DDVectorArguments& vArgs,
82  const DDMapArguments& mArgs,
83  const DDStringArguments& sArgs,
84  const DDStringVectorArguments& vsArgs) {
85  edm::LogVerbatim("EcalGeom") << "DDEcalPreshowerAlgo info: Initialize";
86 
87  asym_ladd_ = vArgs["ASYMETRIC_LADDER"];
88  types_l5_ = vsArgs["TYPES_OF_LADD_L5"];
89  types_l4_ = vsArgs["TYPES_OF_LADD_L4"];
90  ladd_l5_map_ = vArgs["LADD_L5_MAP"];
91  ladd_l4_map_ = vArgs["LADD_L4_MAP"];
92  noLaddInCol_ = vArgs["NUMB_OF_LADD_IN_COL"];
93  startOfFirstLadd_ = vArgs["START_OF_1ST_LADD"];
94  typeOfLaddRow0 = vsArgs["TYPE_OF_LADD_1"];
95  typeOfLaddRow1 = vsArgs["TYPE_OF_LADD_2"];
96  typeOfLaddRow2 = vsArgs["TYPE_OF_LADD_3"];
97  typeOfLaddRow3 = vsArgs["TYPE_OF_LADD_4"];
98  thickLayers_ = vArgs["Layers"];
99  thickness_ = double(nArgs["PRESH_Z_TOTAL"]);
100  materials_ = vsArgs["LayMat"];
101  layName_ = vsArgs["LayName"];
102  rmaxVec = vArgs["R_MAX"]; // inner radii
103  rminVec = vArgs["R_MIN"]; // outer radii
104  waf_intra_col_sep = double(nArgs["waf_intra_col_sep"]);
105  waf_inter_col_sep = double(nArgs["waf_inter_col_sep"]);
106  waf_active = double(nArgs["waf_active"]);
107  wedge_length = double(nArgs["wedge_length"]);
108  wedge_offset = double(nArgs["wedge_offset"]);
109  zwedge_ceramic_diff = double(nArgs["zwedge_ceramic_diff"]);
110  ywedge_ceramic_diff = double(nArgs["ywedge_ceramic_diff"]);
111  ceramic_length = double(nArgs["ceramic_length"]);
112  wedge_angle = double(nArgs["wedge_angle"]);
113  wedge_back_thick = double(nArgs["wedge_back_thick"]);
114  ladder_thick = double(nArgs["ladder_thick"]);
115  ladder_width = double(nArgs["ladder_width"]);
116  micromodule_length = double(nArgs["micromodule_length"]);
117  box_thick = double(nArgs["box_thick"]);
118  abs1stx = vArgs["1ST_ABSX"];
119  abs1sty = vArgs["1ST_ABSY"];
120  abs2ndx = vArgs["2ND_ABSX"];
121  abs2ndy = vArgs["2ND_ABSY"];
122  ladPfx_ = vsArgs["LadPrefix"];
123  LaddMaterial_ = sArgs["LadderMaterial"];
124  LdrFrnt_Length = double(nArgs["LdrFrnt_Length"]);
125  LdrFrnt_Offset = double(nArgs["LdrFrnt_Offset"]);
126  LdrBck_Length = double(nArgs["LdrBck_Length"]);
127  LdrBck_Offset = double(nArgs["LdrBck_Offset"]);
128  dee_separation = double(nArgs["dee_sep"]);
129  In_rad_Abs_Al = double(nArgs["R_MIN_Abs_Al"]);
130  In_rad_Abs_Pb = double(nArgs["R_MIN_Abs_Pb"]);
131  rMax_Abs_Al_ = double(nArgs["R_MAX_Abs_Al"]);
132  absAlX_X_ = double(nArgs["AbsAlX_X"]);
133  absAlX_Y_ = double(nArgs["AbsAlX_Y"]);
134  absAlX_subtr1_Xshift_ = double(nArgs["AbsAlX_subtr1_Xshift"]);
135  absAlX_subtr1_Yshift_ = double(nArgs["AbsAlX_subtr1_Yshift"]);
136  absAlY_X_ = double(nArgs["AbsAlY_X"]);
137  absAlY_Y_ = double(nArgs["AbsAlY_Y"]);
138  absAlY_subtr1_Xshift_ = double(nArgs["AbsAlY_subtr1_Xshift"]);
139  absAlY_subtr1_Yshift_ = double(nArgs["AbsAlY_subtr1_Yshift"]);
140 }
141 
143 #ifdef EDM_ML_DEBUG
144  edm::LogVerbatim("EcalGeom") << "******** DDEcalPreshowerAlgo execute!";
145 #endif
146  // creates all the tube-like layers of the preshower
147  doLayers(cpv);
148  // creates and places the ladders
149  doLadders(cpv);
150  // places the slicon strips in active silicon wafers
151  doSens(cpv);
152 }
153 
155  double zpos = -thickness_ / 2., sdx(0), sdy(0), bdx(0), bdy(0);
156 
157  for (size_t i = 0; i < thickLayers_.size(); ++i) {
158  int I = int(i) + 1; // FOTRAN I (offset +1)
159 
160  double rIn(0), rOut(0), zHalf(0);
161 
162  // create the name
163  DDName ddname(getLayName(i), "esalgo"); // namespace:name
164 
165  // cone dimensions
166  rIn = rminVec[i];
167  rOut = rmaxVec[i];
168  zHalf = thickLayers_[i] / 2.;
169 
170  // create a logical part representing a single layer in the preshower
171  DDSolid solid = DDSolidFactory::tubs(ddname, zHalf, rIn, rOut, 0., 360. * CLHEP::deg);
172 #ifdef EDM_ML_DEBUG
173  edm::LogVerbatim("SFGeomX") << ddname << " Tubs " << zHalf << ":" << rIn << ":" << rOut << ":0:360";
174 #endif
175  DDLogicalPart layer = DDLogicalPart(ddname, getMaterial(i), solid);
176 
177  // position the logical part w.r.t. the parent volume
178  zpos += zHalf;
179 
180  // create a logical part representing a single layer in the preshower
181  // skip layers with detectors, front and rear window
182  if (I == 2 || I == 28 || I == 13 || I == 23) {
183  zpos += zHalf;
184  continue;
185  }
186 
187  if (I == 12) {
188  zlead1_ = zpos + zHalf;
189  }
190  if (I == 22) {
191  zlead2_ = zpos + zHalf;
192  }
193 
194  if (I == 10 || I == 20) { // New lead shape
195 
196  int absz = 0;
197  double outalbx, outalby, shiftR, outalbx2, outalby2, shiftR2;
198 
199  absz = int(abs1stx.size());
200  if (I == 20)
201  absz = int(abs2ndx.size());
202  int cutabsx = -1, cutabsy = -1;
203 
204  DDName dd_tmp_name_b(getLayName(i) + "Lcut", "esalgo");
205  DDName dd_tmp_name_c(getLayName(i) + "tmpb", "esalgo");
206  DDName dd_tmp_name_d(getLayName(i) + "LinPb", "esalgo");
207  DDName dd_tmp_name_e(getLayName(i) + "LinAl", "esalgo");
208  DDName dd_tmp_name_f(getLayName(i) + "LOutAl", "esalgo");
209 
210  std::ostringstream tmp_Alname_fin;
211  tmp_Alname_fin << getLayName(i) << "LtmpAl" << absz - 1;
212  DDName dd_Alname_fin(tmp_Alname_fin.str(), "esalgo");
213 
214  DDSolid Outer_Al = DDSolid(dd_Alname_fin);
215 
216  DDLogicalPart layerFinOutAl = DDLogicalPart(dd_tmp_name_f, getMaterial(i - 1), Outer_Al);
217 
218  DDName dd_Alname_f(getLayName(i) + "LOutAl", "esalgo");
219  DDName dd_Alname_g(getLayName(i) + "LOutAl2", "esalgo");
220  DDName dd_Alname_h(getLayName(i) + "LOutAltmp", "esalgo");
221  DDName dd_Alname_i(getLayName(i) + "LOutAltmp2", "esalgo");
222  DDName dd_Alname_j(getLayName(i) + "LOutAltmp3", "esalgo");
223  DDName dd_Alname_k(getLayName(i) + "LOutAltmp4", "esalgo");
224  DDName dd_Alname_l(getLayName(i) + "LOutAltmp5", "esalgo");
225  DDName dd_Alname_m(getLayName(i) + "LOutAltmp6", "esalgo");
226 
227  DDSolid Out_Al =
228  DDSolidFactory::tubs(dd_Alname_f, zHalf - 0.1 * mm, rMax_Abs_Al_ - 20 * cm, rMax_Abs_Al_, 0., 90. * deg);
229 #ifdef EDM_ML_DEBUG
230  edm::LogVerbatim("SFGeomX") << dd_Alname_f << " Tubs " << (zHalf - 0.1 * mm) << ":" << (rMax_Abs_Al_ - 20 * cm)
231  << ":" << rMax_Abs_Al_ << ":0:90";
232 #endif
233 
234  outalbx = absAlX_X_ * 0.1;
235  outalby = rMax_Abs_Al_ + 0.1 * mm - absAlX_subtr1_Yshift_;
236  shiftR = absAlX_subtr1_Yshift_;
237  if (I == 20) {
238  outalbx = absAlY_X_ * 0.1;
239  outalby = rMax_Abs_Al_ + 0.1 * mm - absAlY_subtr1_Yshift_;
240  shiftR = absAlY_subtr1_Xshift_;
241  }
242  DDSolid OutAltmp = DDSolidFactory::box(dd_Alname_h, outalbx / 2 + 0.1 * mm, outalby / 2 + 0.1 * mm, zHalf);
244  dd_Alname_j, Out_Al, OutAltmp, DDTranslation(outalbx / 2, outalby / 2 + shiftR, 0), DDRotation());
245 #ifdef EDM_ML_DEBUG
246  edm::LogVerbatim("SFGeomX") << dd_Alname_h << " Box " << (outalbx / 2 + 0.1 * mm) << ":"
247  << (outalby / 2 + 0.1 * mm) << ":" << zHalf;
248  edm::LogVerbatim("SFGeomX") << dd_Alname_j << " Subtraction " << Out_Al.name() << ":" << OutAltmp.name() << " at "
249  << DDTranslation(outalbx / 2, outalby / 2 + shiftR, 0) << " no rotation";
250 #endif
251  outalby2 = absAlX_Y_ * 0.1;
252  outalbx2 = rMax_Abs_Al_ + 0.1 * mm - absAlX_subtr1_Xshift_;
253  shiftR2 = absAlX_subtr1_Xshift_;
254  if (I == 20) {
255  outalby2 = absAlY_Y_ * 0.1;
256  outalbx2 = rMax_Abs_Al_ + 0.1 * mm - absAlY_subtr1_Xshift_;
257  shiftR2 = absAlY_subtr1_Xshift_;
258  }
259  DDSolid OutAltmp2 = DDSolidFactory::box(dd_Alname_i, outalbx2 / 2 + 0.1 * mm, outalby2 / 2 + 0.1 * mm, zHalf);
261  dd_Alname_k, Out_Altmp3, OutAltmp2, DDTranslation(outalbx2 / 2 + shiftR2, outalby2 / 2, 0), DDRotation());
262  DDSolid Out_Altmp5 = DDSolidFactory::unionSolid(
263  dd_Alname_l, Out_Altmp4, Out_Altmp4, DDTranslation(0, 0, 0), DDRotation("esalgo:RABS90"));
264  DDSolid Out_Altmp6 = DDSolidFactory::unionSolid(
265  dd_Alname_m, Out_Altmp5, Out_Altmp4, DDTranslation(0, 0, 0), DDRotation("esalgo:RABS180B"));
267  dd_Alname_g, Out_Altmp6, Out_Altmp4, DDTranslation(0, 0, 0), DDRotation("esalgo:R180"));
268 #ifdef EDM_ML_DEBUG
269  edm::LogVerbatim("SFGeomX") << dd_Alname_i << " Box " << (outalbx2 / 2 + 0.1 * mm) << ":"
270  << (outalby2 / 2 + 0.1 * mm) << ":" << zHalf;
271  edm::LogVerbatim("SFGeomX") << dd_Alname_k << " Subtraction " << Out_Altmp3.name() << ":" << OutAltmp2.name()
272  << " at " << DDTranslation(outalbx2 / 2 + shiftR2, outalby2 / 2, 0) << " no rotation";
273  edm::LogVerbatim("SFGeomX") << dd_Alname_l << " Union " << Out_Altmp4.name() << ":" << Out_Altmp4.name() << " at "
274  << DDTranslation(0, 0, 0) << " rotation esalgo:RABS90";
275  edm::LogVerbatim("SFGeomX") << dd_Alname_m << " Union " << Out_Altmp5.name() << ":" << Out_Altmp4.name() << " at "
276  << DDTranslation(0, 0, 0) << " rotation esalgo:RABS180B";
277  edm::LogVerbatim("SFGeomX") << dd_Alname_g << " Union " << Out_Altmp6.name() << ":" << Out_Altmp4.name() << " at "
278  << DDTranslation(0, 0, 0) << " rotation esalgo:R180";
279  edm::LogVerbatim("SFGeomX") << Outer_Al;
280 #endif
281 
282  for (int L = 0; L < absz; ++L) {
283  int K = L;
284  std::ostringstream tmp_name_b, tmp_name_b2, tmp_FAl_name_c, tmp_FAl_name_d1, tmp_FAl_name_d2, tmp_FAl_name_d3,
285  tmp_FAl_name_d;
286  tmp_name_b << getLayName(i) << "L" << K;
287  tmp_name_b2 << getLayName(i) << "Lb2" << K;
288 
289  if (L == 0)
290  tmp_FAl_name_c << getLayName(i) << "LOutAl2";
291  if (L > 0)
292  tmp_FAl_name_c << getLayName(i) << "LtmpAl" << K - 1;
293 
294  tmp_FAl_name_d1 << getLayName(i) << "LtmpAl" << K << "_1";
295  tmp_FAl_name_d2 << getLayName(i) << "LtmpAl" << K << "_2";
296  tmp_FAl_name_d3 << getLayName(i) << "LtmpAl" << K << "_3";
297  tmp_FAl_name_d << getLayName(i) << "LtmpAl" << K;
298 
299  DDName dd_tmp_name_b(tmp_name_b.str(), "esalgo");
300  DDName dd_tmp_name_b2(tmp_name_b2.str(), "esalgo");
301  DDName dd_FAl_name_c(tmp_FAl_name_c.str(), "esalgo");
302  DDName dd_FAl_name_d1(tmp_FAl_name_d1.str(), "esalgo");
303  DDName dd_FAl_name_d2(tmp_FAl_name_d2.str(), "esalgo");
304  DDName dd_FAl_name_d3(tmp_FAl_name_d3.str(), "esalgo");
305  DDName dd_FAl_name_d(tmp_FAl_name_d.str(), "esalgo");
306 
307  if (L == 0)
308  bdx = std::abs(abs1stx[K]) / 2;
309  if (L > 0)
310  bdx = std::abs(abs1stx[K] - abs1stx[K - 1]) / 2;
311  bdy = abs1sty[K];
312  if (abs1stx[K] < rIn + 30 * cm) {
313  bdy = abs1sty[K] / 2 - 30 * cm;
314  cutabsx = K;
315  }
316 
317  if (I == 20) {
318  if (L == 0)
319  bdx = std::abs(abs2ndx[K]) / 2;
320  if (L > 0)
321  bdx = std::abs(abs2ndx[K] - abs2ndx[K - 1]) / 2;
322  bdy = abs2ndy[K];
323  }
324 
325  if ((abs2ndx[K] < rIn + 30 * cm) && I == 20) {
326  bdy = abs2ndy[K] / 2 - 30 * cm;
327  cutabsy = K;
328  }
329 
330  DDSolid solid_b = DDSolidFactory::box(dd_tmp_name_b, bdx, bdy, zHalf);
331  DDSolid solid_b2 = DDSolidFactory::box(dd_tmp_name_b2, bdx + 0.1 * mm, bdy + 0.1 * mm, zHalf);
332 #ifdef EDM_ML_DEBUG
333  edm::LogVerbatim("SFGeomX") << dd_tmp_name_b << " Box " << bdx << ":" << bdy << ":" << zHalf;
334  edm::LogVerbatim("SFGeomX") << dd_tmp_name_b2 << " Box " << (bdx + 0.1 * mm) << ":" << (bdy + 0.1 * mm) << ":"
335  << zHalf;
336 #endif
337 
338  sdx = abs1stx[K] - bdx;
339  sdy = 0;
340  if (abs1stx[K] < rIn + 30 * cm)
341  sdy = abs1sty[K] - bdy;
342 
343  if (I == 20) {
344  sdx = abs2ndx[K] - bdx;
345  sdy = 0;
346  }
347  if ((abs2ndx[K] < rIn + 30 * cm) && I == 20)
348  sdy = abs2ndy[K] - bdy;
349 
350  DDLogicalPart layer = DDLogicalPart(dd_tmp_name_b, getMaterial(i), solid_b);
351 
352  cpv.position(layer, layerFinOutAl, 1, DDTranslation(sdx, sdy, 0), DDRotation());
353  cpv.position(layer, layerFinOutAl, 2, DDTranslation(-sdx, sdy, 0), DDRotation());
354 #ifdef EDM_ML_DEBUG
355  edm::LogVerbatim("SFGeom") << layer.name() << " copy 1 in " << layerFinOutAl.name() << " at "
356  << DDTranslation(sdx, sdy, 0) << " no rotation";
357  edm::LogVerbatim("SFGeom") << layer.name() << " copy 2 in " << layerFinOutAl.name() << " at "
358  << DDTranslation(-sdx, sdy, 0) << " no rotation";
359 #endif
360  DDSolid solid_c = DDSolid(dd_FAl_name_c);
361  DDSolid solid_d1 =
362  DDSolidFactory::unionSolid(dd_FAl_name_d1, solid_c, solid_b2, DDTranslation(sdx, sdy, 0), DDRotation());
363  DDSolid solid_d2 =
364  DDSolidFactory::unionSolid(dd_FAl_name_d, solid_d1, solid_b2, DDTranslation(-sdx, -sdy, 0), DDRotation());
365 #ifdef EDM_ML_DEBUG
366  edm::LogVerbatim("SFGeomX") << dd_FAl_name_d1 << " Union " << solid_c.name() << ":" << solid_b2.name() << " at "
367  << DDTranslation(sdx, sdy, 0) << " no rotation";
368  edm::LogVerbatim("SFGeomX") << dd_FAl_name_d << " Union " << solid_d1.name() << ":" << solid_b2.name() << " at "
369  << DDTranslation(-sdx, -sdy, 0) << " no rotation";
370 #endif
371  if (((abs1stx[K] < rIn + 30 * cm) && I == 10) || ((abs2ndx[K] < rIn + 30 * cm) && I == 20)) {
372  cpv.position(layer, layerFinOutAl, 3, DDTranslation(sdx, -sdy, 0), DDRotation());
373  cpv.position(layer, layerFinOutAl, 4, DDTranslation(-sdx, -sdy, 0), DDRotation());
374 #ifdef EDM_ML_DEBUG
375  edm::LogVerbatim("SFGeom") << layer.name() << " copy 3 in " << layerFinOutAl.name() << " at "
376  << DDTranslation(sdx, -sdy, 0) << " no rotation";
377  edm::LogVerbatim("SFGeom") << layer.name() << " copy 4 in " << layerFinOutAl.name() << " at "
378  << DDTranslation(-sdx, -sdy, 0) << " no rotation";
379 #endif
380  DDSolid solid_c = DDSolid(dd_FAl_name_c);
381  DDSolid solid_d1 =
382  DDSolidFactory::unionSolid(dd_FAl_name_d1, solid_c, solid_b2, DDTranslation(sdx, sdy, 0), DDRotation());
383  DDSolid solid_d2 =
384  DDSolidFactory::unionSolid(dd_FAl_name_d2, solid_d1, solid_b2, DDTranslation(sdx, -sdy, 0), DDRotation());
385  DDSolid solid_d3 =
386  DDSolidFactory::unionSolid(dd_FAl_name_d3, solid_d2, solid_b2, DDTranslation(-sdx, sdy, 0), DDRotation());
387  DDSolid solid_d4 =
388  DDSolidFactory::unionSolid(dd_FAl_name_d, solid_d3, solid_b2, DDTranslation(-sdx, -sdy, 0), DDRotation());
389 #ifdef EDM_ML_DEBUG
390  edm::LogVerbatim("SFGeomX") << dd_FAl_name_d1 << " Union " << solid_c.name() << ":" << solid_b2.name()
391  << " at " << DDTranslation(sdx, sdy, 0) << " no rotation";
392  edm::LogVerbatim("SFGeomX") << dd_FAl_name_d2 << " Union " << solid_d1.name() << ":" << solid_b2.name()
393  << " at " << DDTranslation(sdx, -sdy, 0) << " no rotation";
394  edm::LogVerbatim("SFGeomX") << dd_FAl_name_d3 << " Union " << solid_d2.name() << ":" << solid_b2.name()
395  << " at " << DDTranslation(-sdx, sdy, 0) << " no rotation";
396  edm::LogVerbatim("SFGeomX") << dd_FAl_name_d << " Union " << solid_d3.name() << ":" << solid_b2.name()
397  << " at " << DDTranslation(-sdx, -sdy, 0) << " no rotation";
398 #endif
399  }
400  }
401 
402  bdx = abs1stx[cutabsx];
403  if (I == 20)
404  bdx = abs2ndx[cutabsy];
405  bdy = 2 * 30 * cm;
406 
407  DDSolid solidcut = DDSolidFactory::box(dd_tmp_name_b, bdx, bdy, zHalf);
408 
409  DDSolid iner = DDSolidFactory::tubs(dd_tmp_name_c, zHalf + 0.1 * mm, 0, In_rad_Abs_Pb, 0., 360. * deg);
410 
411  DDSolid final = DDSolidFactory::subtraction(dd_tmp_name_d, solidcut, iner, DDTranslation(0, 0, 0), DDRotation());
412 #ifdef EDM_ML_DEBUG
413  edm::LogVerbatim("SFGeomX") << dd_tmp_name_b << " Box " << bdx << ":" << bdy << ":" << zHalf;
414  edm::LogVerbatim("SFGeomX") << dd_tmp_name_c << " Tubs " << (zHalf + 0.1 * mm) << ":0:" << In_rad_Abs_Pb
415  << ":0:360";
416  edm::LogVerbatim("SFGeomX") << dd_tmp_name_d << " Subtraction " << solidcut.name() << ":" << iner.name()
417  << " at (0,0,0) no rotation";
418 #endif
419 
420  DDLogicalPart layer = DDLogicalPart(dd_tmp_name_d, getMaterial(i), final);
421  cpv.position(layer, parent(), 1, DDTranslation(0, 0, zpos), DDRotation());
422 #ifdef EDM_ML_DEBUG
423  edm::LogVerbatim("SFGeom") << layer.name() << " copy 1 in " << parent().name() << " at "
424  << DDTranslation(0, 0, zpos) << " no rotation";
425 #endif
426  DDSolid iner_Al =
427  DDSolidFactory::tubs(dd_tmp_name_e, zHalf, In_rad_Abs_Al, In_rad_Abs_Pb - 0.01 * mm, 0., 360. * deg);
428 #ifdef EDM_ML_DEBUG
429  edm::LogVerbatim("SFGeomX") << dd_tmp_name_e << " Tubs " << zHalf << ":" << In_rad_Abs_Al << ":"
430  << (In_rad_Abs_Pb - 0.01 * mm) << ":0:360";
431 #endif
432 
433  DDLogicalPart layerAl = DDLogicalPart(dd_tmp_name_e, getMaterial(i - 1), iner_Al);
434  cpv.position(layerAl, parent(), 1, DDTranslation(0, 0, zpos), DDRotation());
435  cpv.position(layerFinOutAl, parent(), 1, DDTranslation(0, 0, zpos), DDRotation());
436 #ifdef EDM_ML_DEBUG
437  edm::LogVerbatim("SFGeom") << layerAl.name() << " copy 1 in " << parent().name() << " at "
438  << DDTranslation(0, 0, zpos) << " no rotation";
439  edm::LogVerbatim("SFGeom") << layerFinOutAl.name() << " copy 1 in " << parent().name() << " at "
440  << DDTranslation(0, 0, zpos) << " no rotation";
441 #endif
442  } else {
443  cpv.position(layer, parent(), 1, DDTranslation(0., 0., zpos), DDRotation());
444 #ifdef EDM_ML_DEBUG
445  edm::LogVerbatim("SFGeom") << layer.name() << " copy 1 in " << parent().name() << " at "
446  << DDTranslation(0, 0, zpos) << " no rotation";
447 #endif
448  }
449  zpos += zHalf;
450  }
451 }
452 
454  double xpos(0), ypos(0), zpos(0), sdx(0), sdy(0), sdz(0);
455  double prev_length_(0), ladder_new_length_(0), ladd_shift_(0), ladder_length(0);
456  int enb(0), swed_scopy_glob(0);
457  double sdxe[50] = {0}, sdye[50] = {0}, sdze[50] = {0};
458  double sdxe2[50] = {0}, sdye2[50] = {0}, sdze2[50] = {0}, sdxe3[50] = {0}, sdye3[50] = {0}, sdze3[50] = {0};
459 
460  for (int M = 0; M < int(types_l5_.size() + types_l4_.size()); M++) {
461  int scopy(0);
462  double boxax(0), boxay(0), boxaz(0);
463  int ladd_not_plain(0), ladd_subtr_no(0), ladd_upper(0), ladd_side(0);
464 
465  DDSolid solid_lfront = DDSolidFactory::trap(DDName("LDRFRNT", "esalgo"),
466  LdrFrnt_Length / 2, // pDz
467  -wedge_angle, // pTheta
468  0, // pPhi
469  ladder_width / 2, // pDy1
470  (ladder_thick) / 2, // pDx1
471  (ladder_thick) / 2, // pDx2
472  0, // pAlp1
473  ladder_width / 2, // pDy2
474  (ladder_thick - ceramic_length * sin(wedge_angle * 2)) / 2, // pDx3
475  (ladder_thick - ceramic_length * sin(wedge_angle * 2)) / 2, // pDx4
476  0);
477 
478  DDSolid solid_lbck = DDSolidFactory::trap(DDName("LDRBCK", "esalgo"),
479  LdrBck_Length / 2, // pDz
480  -wedge_angle, // pTheta
481  0, // pPhi
482  ladder_width / 2, // pDy1
483  (box_thick / cos(wedge_angle * 2) + 0.02 * mm) / 2, // pDx1
484  (box_thick / cos(wedge_angle * 2) + 0.02 * mm) / 2, // pDx2
485  0, // pAlp1
486  ladder_width / 2, // pDy2
487  (ladder_thick - wedge_back_thick) / 2, // pDx3
488  (ladder_thick - wedge_back_thick) / 2, // pDx4
489  0);
490 
491  DDSolid solid_lfhalf = DDSolidFactory::trap(DDName("LDRFHALF", "esalgo"),
492  LdrFrnt_Length / 2, // pDz
493  -wedge_angle, // pTheta
494  0, // pPhi
495  (ladder_width / 2) / 2, // pDy1
496  (ladder_thick) / 2, // pDx1
497  (ladder_thick) / 2, // pDx2
498  0, // pAlp1
499  (ladder_width / 2) / 2, // pDy2
500  (ladder_thick - ceramic_length * sin(wedge_angle * 2)) / 2, // pDx3
501  (ladder_thick - ceramic_length * sin(wedge_angle * 2)) / 2, // pDx4
502  0);
503 
504  DDSolid solid_lbhalf = DDSolidFactory::trap(DDName("LDRBHALF", "esalgo"),
505  LdrBck_Length / 2, // pDz
506  -wedge_angle, // pTheta
507  0, // pPhi
508  (ladder_width / 2) / 2, // pDy1
509  (box_thick / cos(wedge_angle * 2) + 0.02 * mm) / 2, // pDx1
510  (box_thick / cos(wedge_angle * 2) + 0.02 * mm) / 2, // pDx2
511  0, // pAlp1
512  (ladder_width / 2) / 2, // pDy2
513  (ladder_thick - wedge_back_thick) / 2, // pDx3
514  (ladder_thick - wedge_back_thick) / 2, // pDx4
515  0);
516 
517  DDSolid solid_lfhtrunc =
518  DDSolidFactory::trap(DDName("LDRFHTR", "esalgo"),
519  (LdrFrnt_Length - waf_active) / 2, // pDz
520  -wedge_angle, // pTheta
521  0, // pPhi
522  (ladder_width / 2) / 2, // pDy1
523  (ladder_thick) / 2, // pDx1
524  (ladder_thick) / 2, // pDx2
525  0, // pAlp1
526  (ladder_width / 2) / 2, // pDy2
527  (ladder_thick - (ceramic_length - waf_active) * sin(wedge_angle * 2)) / 2, // pDx3
528  (ladder_thick - (ceramic_length - waf_active) * sin(wedge_angle * 2)) / 2, // pDx4
529  0);
530 #ifdef EDM_ML_DEBUG
531  edm::LogVerbatim("SFGeomX") << DDName("LDRFRNT", "esalgo") << " Trap " << (LdrFrnt_Length / 2) << ":"
532  << -wedge_angle / CLHEP::deg << ":0:" << (ladder_width / 2) << ":" << (ladder_thick / 2)
533  << ":" << (ladder_thick / 2) << ":0:" << (ladder_width / 2) << ":"
534  << ((ladder_thick - ceramic_length * sin(wedge_angle * 2)) / 2) << ":"
535  << ((ladder_thick - ceramic_length * sin(wedge_angle * 2)) / 2) << ":0";
536  edm::LogVerbatim("SFGeomX") << DDName("LDRBCK", "esalgo") << " Trap " << (LdrBck_Length / 2) << ":"
537  << -wedge_angle / CLHEP::deg << ":0:" << (ladder_width / 2) << ":"
538  << ((box_thick / cos(wedge_angle * 2) + 0.02 * mm) / 2) << ":"
539  << ((box_thick / cos(wedge_angle * 2) + 0.02 * mm) / 2) << ":0:" << (ladder_width / 2)
540  << ":" << ((ladder_thick - wedge_back_thick) / 2) << ":"
541  << ((ladder_thick - wedge_back_thick) / 2) << ":0";
542  edm::LogVerbatim("SFGeomX") << DDName("LDRFHALF", "esalgo") << " Trap " << (LdrFrnt_Length / 2) << ":"
543  << -wedge_angle / CLHEP::deg << ":0:" << ((ladder_width / 2) / 2) << ":"
544  << (ladder_thick / 2) << ":" << (ladder_thick / 2) << ":0:" << ((ladder_width / 2) / 2)
545  << ":" << ((ladder_thick - ceramic_length * sin(wedge_angle * 2)) / 2) << ":"
546  << ((ladder_thick - ceramic_length * sin(wedge_angle * 2)) / 2) << ":0";
547  edm::LogVerbatim("SFGeomX") << DDName("LDRBHALF", "esalgo") << " Trap " << (LdrBck_Length / 2) << ":"
548  << -wedge_angle / CLHEP::deg << ":0:" << ((ladder_width / 2) / 2) << ":"
549  << ((box_thick / cos(wedge_angle * 2) + 0.02 * mm) / 2) << ":"
550  << ((box_thick / cos(wedge_angle * 2) + 0.02 * mm) / 2)
551  << ":0:" << ((ladder_width / 2) / 2) << ":" << ((ladder_thick - wedge_back_thick) / 2)
552  << ":" << ((ladder_thick - wedge_back_thick) / 2) << ":0";
553  edm::LogVerbatim("SFGeomX") << DDName("LDRFHTR", "esalgo") << " Trap " << ((LdrFrnt_Length - waf_active) / 2) << ":"
554  << -wedge_angle / CLHEP::deg << ":0:" << ((ladder_width / 2) / 2) << ":"
555  << ((ladder_thick) / 2) << ":" << ((ladder_thick) / 2)
556  << ":0:" << ((ladder_width / 2) / 2) << ":"
557  << ((ladder_thick - (ceramic_length - waf_active) * sin(wedge_angle * 2)) / 2) << ":"
558  << ((ladder_thick - (ceramic_length - waf_active) * sin(wedge_angle * 2)) / 2) << ":0";
559 #endif
560 
561  // Creation of ladders with 5 micromodules length
562 
563  if (M < int(types_l5_.size())) {
564  for (int i = 0; i <= 1; i++) {
565  for (int j = 0; j <= 3; j++) {
566  if (ladd_l5_map_[(i + j * 2 + M * 10)] != 1) {
567  ladd_not_plain = 1;
568  ladd_subtr_no++;
569  if (j > 1)
570  ladd_upper = 1;
571  ladd_side = i;
572  }
573  }
574  }
575 #ifdef EDM_ML_DEBUG
576  edm::LogVerbatim("SFGeomX") << "Side " << ladd_side << ":" << ladd_upper << ":" << ladd_subtr_no << ":"
577  << ladd_not_plain << " Index " << M << ":" << types_l5_.size();
578 #endif
579  DDName ddname(getLadPrefix(0) + types_l5_[M], "esalgo");
580  ladder_length = micromodule_length + 4 * waf_active + 0.1 * mm;
581 
582  if (ladd_not_plain) {
583  // enb++;
584  std::ostringstream tmp_name_5b, tmp_name_5c, tmp_name_5d;
585  if (ladd_upper) {
586  } //upper
587  else {
588  enb++;
589  std::ostringstream tmp_name_5b, tmp_name_5c, tmp_name_5d;
590  DDName dd_tmp_name_5a(getLadPrefix(2), "esalgo");
591  tmp_name_5b << getLadPrefix(3) << enb;
592  DDName dd_tmp_name_5b(tmp_name_5b.str(), "esalgo");
593  tmp_name_5c << getLadPrefix(4) << enb;
594  DDName dd_tmp_name_5c(tmp_name_5c.str(), "esalgo");
595  tmp_name_5d << getLadPrefix(5) << enb;
596  DDName dd_tmp_name_5d(tmp_name_5d.str(), "esalgo");
597 
598  DDName dd_tmp_name_5e(getLadPrefix(6), "esalgo");
599 
601  boxax = ladder_width;
602  boxaz = ladder_thick;
603 
604  DDSolid solid_5a = DDSolidFactory::box(dd_tmp_name_5a, boxax / 2, boxay / 2, boxaz / 2.);
605 #ifdef EDM_ML_DEBUG
606  edm::LogVerbatim("SFGeomX") << dd_tmp_name_5a << " Box " << (boxax / 2) << ":" << (boxay / 2) << ":"
607  << (boxaz / 2);
608 #endif
609  if (ladd_side == 0)
610  sdxe[enb] = ladder_width / 4;
611  sdye[enb] = -boxay / 2 - LdrFrnt_Length / 2;
612  sdze[enb] = -ladder_thick / 2. + LdrFrnt_Offset;
613  if (ladd_side == 1)
614  sdxe[enb] = -ladder_width / 4;
615 
616  DDSolid solid_5b = DDSolidFactory::unionSolid(dd_tmp_name_5b,
617  solid_5a,
618  solid_lfhalf,
619  DDTranslation(sdxe[enb], sdye[enb], sdze[enb]),
620  DDRotation("esalgo:RM1299"));
621 #ifdef EDM_ML_DEBUG
622  edm::LogVerbatim("SFGeomX") << dd_tmp_name_5b << " Union " << solid_5a.name() << ":" << solid_lfhalf.name()
623  << " at " << DDTranslation(sdxe[enb], sdye[enb], sdze[enb])
624  << " rotation esalgo:RM1299";
625 #endif
626 
627  if (ladd_side == 0)
628  sdxe2[enb] = -ladder_width / 4;
629  sdye2[enb] = -boxay / 2 - LdrFrnt_Length / 2 + waf_active / 2;
630  sdze2[enb] = -ladder_thick / 2. + LdrFrnt_Offset + (waf_active * sin(wedge_angle * 2)) / 4;
631  if (ladd_side == 1)
632  sdxe2[enb] = ladder_width / 4;
633 
634  DDSolid solid_5c = DDSolidFactory::unionSolid(dd_tmp_name_5c,
635  solid_5b,
636  solid_lfhtrunc,
637  DDTranslation(sdxe2[enb], sdye2[enb], sdze2[enb]),
638  DDRotation("esalgo:RM1299"));
639 #ifdef EDM_ML_DEBUG
640  edm::LogVerbatim("SFGeomX") << dd_tmp_name_5c << " Union " << solid_5b.name() << ":" << solid_lfhtrunc.name()
641  << " at " << DDTranslation(sdxe2[enb], sdye2[enb], sdze2[enb])
642  << " rotation esalgo:RM1299";
643 #endif
644 
645  sdxe3[enb] = 0;
646  sdye3[enb] = boxay / 2 + LdrBck_Length / 2;
647  sdze3[enb] = -ladder_thick / 2. + LdrBck_Offset;
648  DDSolid solid = DDSolidFactory::unionSolid(ddname,
649  solid_5c,
650  solid_lbck,
651  DDTranslation(sdxe3[enb], sdye3[enb], sdze3[enb]),
652  DDRotation("esalgo:RM1299"));
653 #ifdef EDM_ML_DEBUG
654  edm::LogVerbatim("SFGeomX") << ddname << " Union " << solid_5c.name() << ":" << solid_lbck.name() << " at "
655  << DDTranslation(sdxe3[enb], sdye3[enb], sdze3[enb]) << " rotation esalgo:RM1299";
656 #endif
657 
659  DDName ddname2(getLadPrefix(1) + types_l5_[M], "esalgo");
660  DDLogicalPart ladder2 = DDLogicalPart(ddname2, getLaddMaterial(), solid);
661  }
662 
663  } //end of not plain ladder shape
664  else {
665  DDName dd_tmp_name_5pa(getLadPrefix(2) + "5p", "esalgo");
666  DDName dd_tmp_name_5pb(getLadPrefix(3) + "5p", "esalgo");
667 
669  boxax = ladder_width;
670  boxaz = ladder_thick;
671 
672  DDSolid solid_5pa = DDSolidFactory::box(dd_tmp_name_5pa, boxax / 2, boxay / 2, boxaz / 2.);
673 #ifdef EDM_ML_DEBUG
674  edm::LogVerbatim("SFGeomX") << dd_tmp_name_5pa << " Box " << (boxax / 2) << ":" << (boxay / 2) << ":"
675  << (boxaz / 2);
676 #endif
677  sdx = 0;
678  sdy = -boxay / 2 - LdrFrnt_Length / 2;
679  sdz = -ladder_thick / 2. + LdrFrnt_Offset;
680 
682  dd_tmp_name_5pb, solid_5pa, solid_lfront, DDTranslation(sdx, sdy, sdz), DDRotation("esalgo:RM1299"));
683 #ifdef EDM_ML_DEBUG
684  edm::LogVerbatim("SFGeomX") << dd_tmp_name_5pb << " Union " << solid_5pa.name() << ":" << solid_lfront.name()
685  << " at " << DDTranslation(sdx, sdy, sdz) << " rotation esalgo:RM1299";
686 #endif
687 
688  sdx = 0;
689  sdy = boxay / 2 + LdrBck_Length / 2;
690  sdz = -ladder_thick / 2. + LdrBck_Offset;
691 
693  ddname, solid_5pb, solid_lbck, DDTranslation(sdx, sdy, sdz), DDRotation("esalgo:RM1299"));
694 #ifdef EDM_ML_DEBUG
695  edm::LogVerbatim("SFGeomX") << ddname << " Union " << solid_5pb.name() << ":" << solid_lbck.name() << " at "
696  << DDTranslation(sdx, sdy, sdz) << " rotation esalgo:RM1299";
697 #endif
698 
700  DDName ddname2(getLadPrefix(1) + types_l5_[M], "esalgo");
701  DDLogicalPart ladder2 = DDLogicalPart(ddname2, getLaddMaterial(), solid);
702  }
703  }
704 
705  // Creation of ladders with 4 micromodules length
706 
707  if (M >= int(types_l5_.size())) {
708  int d = M - types_l5_.size();
709 
710  for (int i = 0; i <= 1; i++) {
711  for (int j = 0; j <= 3; j++) {
712  if (ladd_l4_map_[(i + j * 2 + (M - types_l5_.size()) * 8)] != 1) {
713  ladd_not_plain = 1;
714  ladd_subtr_no++;
715  if (j > 1)
716  ladd_upper = 1;
717  ladd_side = i;
718  }
719  }
720  }
721 #ifdef EDM_ML_DEBUG
722  edm::LogVerbatim("SFGeomX") << "Side " << ladd_side << ":" << ladd_upper << ":" << ladd_subtr_no << ":"
723  << ladd_not_plain << " Index " << M << ":" << types_l5_.size();
724 #endif
725  DDName ddname(getLadPrefix(0) + types_l4_[d], "esalgo");
726  ladder_length = micromodule_length + 3 * waf_active + 0.1 * mm;
727 
728  if (ladd_not_plain) {
729  std::ostringstream tmp_name_b, tmp_name_c, tmp_name_d;
730  if (ladd_upper) {
731  enb++;
732 
733  DDName dd_tmp_name_a(getLadPrefix(7), "esalgo");
734  tmp_name_b << getLadPrefix(8) << enb;
735  DDName dd_tmp_name_b(tmp_name_b.str(), "esalgo");
736  tmp_name_c << getLadPrefix(9) << enb;
737  DDName dd_tmp_name_c(tmp_name_c.str(), "esalgo");
738  tmp_name_d << getLadPrefix(10) << enb;
739  DDName dd_tmp_name_d(tmp_name_d.str(), "esalgo");
740  DDName dd_tmp_name_e(getLadPrefix(11), "esalgo");
741 
743  boxax = ladder_width;
744  boxaz = ladder_thick;
745  DDSolid solid_a = DDSolidFactory::box(dd_tmp_name_a, boxax / 2, boxay / 2, boxaz / 2.);
746 #ifdef EDM_ML_DEBUG
747  edm::LogVerbatim("SFGeomX") << dd_tmp_name_a << " Box " << (boxax / 2) << ":" << (boxay / 2) << ":"
748  << (boxaz / 2);
749 #endif
750 
751  sdxe[enb] = 0;
752  sdye[enb] = -boxay / 2 - LdrFrnt_Length / 2;
753  sdze[enb] = -ladder_thick / 2. + LdrFrnt_Offset;
754  DDSolid solid_b = DDSolidFactory::unionSolid(dd_tmp_name_b,
755  solid_a,
756  solid_lfront,
757  DDTranslation(sdxe[enb], sdye[enb], sdze[enb]),
758  DDRotation("esalgo:RM1299"));
759 #ifdef EDM_ML_DEBUG
760  edm::LogVerbatim("SFGeomX") << dd_tmp_name_b << " Union " << solid_a.name() << ":" << solid_lfront.name()
761  << " at " << DDTranslation(sdxe[enb], sdye[enb], sdze[enb])
762  << " rotation esalgo:RM1299";
763 #endif
764 
765  if (ladd_side == 0)
766  sdxe2[enb] = ladder_width / 4;
767  sdye2[enb] = boxay / 2 + LdrBck_Length / 2;
768  sdze2[enb] = -ladder_thick / 2. + LdrBck_Offset;
769  if (ladd_side == 1)
770  sdxe2[enb] = -ladder_width / 4;
771  DDSolid solid = DDSolidFactory::unionSolid(ddname,
772  solid_b,
773  solid_lbhalf,
774  DDTranslation(sdxe2[enb], sdye2[enb], sdze2[enb]),
775  DDRotation("esalgo:RM1299"));
776 #ifdef EDM_ML_DEBUG
777  edm::LogVerbatim("SFGeomX") << ddname << " Union " << solid_b.name() << ":" << solid_lbhalf.name() << " at "
778  << DDTranslation(sdxe2[enb], sdye2[enb], sdze2[enb]) << " rotation esalgo:RM1299";
779 #endif
780 
782  DDName ddname2(getLadPrefix(1) + types_l4_[d], "esalgo");
783  DDLogicalPart ladder2 = DDLogicalPart(ddname2, getLaddMaterial(), solid);
784 
785  } //upper
786  else {
787  if (ladd_subtr_no > 1) {
788  enb++;
789 
790  DDName dd_tmp_name_a(getLadPrefix(7), "esalgo");
791  tmp_name_b << getLadPrefix(8) << enb;
792  DDName dd_tmp_name_b(tmp_name_b.str(), "esalgo");
793  tmp_name_c << getLadPrefix(9) << enb;
794  DDName dd_tmp_name_c(tmp_name_c.str(), "esalgo");
795  tmp_name_d << getLadPrefix(10) << enb;
796  DDName dd_tmp_name_d(tmp_name_d.str(), "esalgo");
797  DDName dd_tmp_name_e(getLadPrefix(11), "esalgo");
798 
800  boxax = ladder_width;
801  boxaz = ladder_thick;
802 
803  DDSolid solid_a = DDSolidFactory::box(dd_tmp_name_a, boxax / 2, boxay / 2, boxaz / 2.);
804 #ifdef EDM_ML_DEBUG
805  edm::LogVerbatim("SFGeomX") << dd_tmp_name_a << " Box " << (boxax / 2) << ":" << (boxay / 2) << ":"
806  << (boxaz / 2);
807 #endif
808  if (ladd_side == 0)
809  sdxe[enb] = ladder_width / 4;
810  sdye[enb] = -boxay / 2 - LdrFrnt_Length / 2;
811  sdze[enb] = -ladder_thick / 2. + LdrFrnt_Offset;
812  if (ladd_side == 1)
813  sdxe[enb] = -ladder_width / 4;
814 
815  DDSolid solid_b = DDSolidFactory::unionSolid(dd_tmp_name_b,
816  solid_a,
817  solid_lfhalf,
818  DDTranslation(sdxe[enb], sdye[enb], sdze[enb]),
819  DDRotation("esalgo:RM1299"));
820 #ifdef EDM_ML_DEBUG
821  edm::LogVerbatim("SFGeomX") << dd_tmp_name_b << " Union " << solid_a.name() << ":" << solid_lfhalf.name()
822  << " at " << DDTranslation(sdxe[enb], sdye[enb], sdze[enb])
823  << " rotation esalgo:RM1299";
824 #endif
825 
826  sdxe2[enb] = 0;
827  sdye2[enb] = boxay / 2 + LdrBck_Length / 2;
828  sdze2[enb] = -ladder_thick / 2. + LdrBck_Offset;
829 
830  DDSolid solid = DDSolidFactory::unionSolid(ddname,
831  solid_b,
832  solid_lbck,
833  DDTranslation(sdxe2[enb], sdye2[enb], sdze2[enb]),
834  DDRotation("esalgo:RM1299"));
835 #ifdef EDM_ML_DEBUG
836  edm::LogVerbatim("SFGeomX") << ddname << " Union " << solid_b.name() << ":" << solid_lbck.name() << " at "
837  << DDTranslation(sdxe2[enb], sdye2[enb], sdze2[enb])
838  << " rotation esalgo:RM1299";
839 #endif
840 
842  DDName ddname2(getLadPrefix(1) + types_l4_[d], "esalgo");
843  DDLogicalPart ladder2 = DDLogicalPart(ddname2, getLaddMaterial(), solid);
844  } else {
845  enb++;
846  DDName dd_tmp_name_a(getLadPrefix(7), "esalgo");
847  tmp_name_b << getLadPrefix(8) << enb;
848  DDName dd_tmp_name_b(tmp_name_b.str(), "esalgo");
849  tmp_name_c << getLadPrefix(9) << enb;
850  DDName dd_tmp_name_c(tmp_name_c.str(), "esalgo");
851  tmp_name_d << getLadPrefix(10) << enb;
852  DDName dd_tmp_name_d(tmp_name_d.str(), "esalgo");
853  DDName dd_tmp_name_e(getLadPrefix(11), "esalgo");
854 
856  boxax = ladder_width;
857  boxaz = ladder_thick;
858  DDSolid solid_a = DDSolidFactory::box(dd_tmp_name_a, boxax / 2, boxay / 2, boxaz / 2.);
859 #ifdef EDM_ML_DEBUG
860  edm::LogVerbatim("SFGeomX") << dd_tmp_name_a << " Box " << (boxax / 2) << ":" << (boxay / 2) << ":"
861  << (boxaz / 2);
862 #endif
863  if (ladd_side == 0)
864  sdxe[enb] = ladder_width / 4;
865  sdye[enb] = -boxay / 2 - LdrFrnt_Length / 2;
866  sdze[enb] = -ladder_thick / 2. + LdrFrnt_Offset;
867  if (ladd_side == 1)
868  sdxe[enb] = -ladder_width / 4;
869 
870  DDSolid solid_b = DDSolidFactory::unionSolid(dd_tmp_name_b,
871  solid_a,
872  solid_lfhalf,
873  DDTranslation(sdxe[enb], sdye[enb], sdze[enb]),
874  DDRotation("esalgo:RM1299"));
875 #ifdef EDM_ML_DEBUG
876  edm::LogVerbatim("SFGeomX") << dd_tmp_name_b << " Union " << solid_a.name() << ":" << solid_lfhalf.name()
877  << " at " << DDTranslation(sdxe[enb], sdye[enb], sdze[enb])
878  << " rotation esalgo:RM1299";
879 #endif
880 
881  if (ladd_side == 0)
882  sdxe2[enb] = -ladder_width / 4;
883  sdye2[enb] = -boxay / 2 - LdrFrnt_Length / 2 + waf_active / 2;
884  sdze2[enb] = -ladder_thick / 2. + LdrFrnt_Offset + (waf_active * sin(wedge_angle * 2)) / 4;
885  if (ladd_side == 1)
886  sdxe2[enb] = ladder_width / 4;
887 
888  DDSolid solid_c = DDSolidFactory::unionSolid(dd_tmp_name_c,
889  solid_b,
890  solid_lfhtrunc,
891  DDTranslation(sdxe2[enb], sdye2[enb], sdze2[enb]),
892  DDRotation("esalgo:RM1299"));
893 #ifdef EDM_ML_DEBUG
894  edm::LogVerbatim("SFGeomX") << dd_tmp_name_c << " Union " << solid_b.name() << ":" << solid_lfhtrunc.name()
895  << " at " << DDTranslation(sdxe2[enb], sdye2[enb], sdze2[enb])
896  << " rotation esalgo:RM1299";
897 #endif
898 
899  sdxe3[enb] = 0;
900  sdye3[enb] = boxay / 2 + LdrBck_Length / 2;
901  sdze3[enb] = -ladder_thick / 2. + LdrBck_Offset;
902  DDSolid solid = DDSolidFactory::unionSolid(ddname,
903  solid_c,
904  solid_lbck,
905  DDTranslation(sdxe3[enb], sdye3[enb], sdze3[enb]),
906  DDRotation("esalgo:RM1299"));
907 #ifdef EDM_ML_DEBUG
908  edm::LogVerbatim("SFGeomX") << ddname << " Union " << solid_c.name() << ":" << solid_lbck.name() << " at "
909  << DDTranslation(sdxe3[enb], sdye3[enb], sdze3[enb])
910  << " rotation esalgo:RM1299";
911 #endif
912 
914  DDName ddname2(getLadPrefix(1) + types_l4_[d], "esalgo");
915  DDLogicalPart ladder2 = DDLogicalPart(ddname2, getLaddMaterial(), solid);
916  }
917  }
918 
919  } //end of not plain ladder shape
920  else {
921  DDName dd_tmp_name_pa(getLadPrefix(2) + "p", "esalgo");
922  DDName dd_tmp_name_pb(getLadPrefix(3) + "p", "esalgo");
923 
925  boxax = ladder_width;
926  boxaz = ladder_thick;
927 
928  DDSolid solid_pa = DDSolidFactory::box(dd_tmp_name_pa, boxax / 2, boxay / 2, boxaz / 2.);
929 #ifdef EDM_ML_DEBUG
930  edm::LogVerbatim("SFGeomX") << dd_tmp_name_pa << " Box " << (boxax / 2) << ":" << (boxay / 2) << ":"
931  << (boxaz / 2);
932 #endif
933  sdx = 0;
934  sdy = -boxay / 2 - LdrFrnt_Length / 2;
935  sdz = -ladder_thick / 2. + LdrFrnt_Offset;
936 
938  dd_tmp_name_pb, solid_pa, solid_lfront, DDTranslation(sdx, sdy, sdz), DDRotation("esalgo:RM1299"));
939 #ifdef EDM_ML_DEBUG
940  edm::LogVerbatim("SFGeomX") << dd_tmp_name_pb << " Union " << solid_pa.name() << ":" << solid_lfront.name()
941  << " at " << DDTranslation(sdx, sdy, sdz) << " rotation esalgo:RM1299";
942 #endif
943 
944  sdx = 0;
945  sdy = boxay / 2 + LdrBck_Length / 2;
946  sdz = -ladder_thick / 2. + LdrBck_Offset;
948  ddname, solid_pb, solid_lbck, DDTranslation(sdx, sdy, sdz), DDRotation("esalgo:RM1299"));
949 #ifdef EDM_ML_DEBUG
950  edm::LogVerbatim("SFGeomX") << ddname << " Union " << solid_pb.name() << ":" << solid_lbck.name() << " at "
951  << DDTranslation(sdx, sdy, sdz) << " rotation esalgo:RM1299";
952 #endif
954  DDName ddname2(getLadPrefix(1) + types_l4_[d], "esalgo");
955  DDLogicalPart ladder2 = DDLogicalPart(ddname2, getLaddMaterial(), solid);
956  }
957  }
958 
959  // insert SWED, SFBX and SFBY into ladders
960  swed_scopy_glob++;
961  if (M < int(types_l5_.size())) {
962  DDName ddname(getLadPrefix(0) + types_l5_[M], "esalgo");
963  DDName ddname2(getLadPrefix(1) + types_l5_[M], "esalgo");
964  for (int i = 0; i <= 1; i++) {
965  for (int j = 0; j <= 4; j++) {
966  xpos = (i * 2 - 1) * waf_intra_col_sep / 2.;
967  ypos = -ladder_length / 2. + 0.05 * mm - (LdrFrnt_Length - LdrBck_Length) / 2 + wedge_length / 2. +
968  j * waf_active;
969  zpos = -ladder_thick / 2. + 0.005 * mm + wedge_offset;
970  if (ladd_l5_map_[(i + j * 2 + M * 10)] == 1) {
971  scopy++;
972  cpv.position(DDLogicalPart("esalgo:SWED"),
973  ddname,
974  scopy + 1000 * swed_scopy_glob,
975  DDTranslation(xpos, ypos, zpos),
976  DDRotation("esalgo:RM1299"));
977  cpv.position(DDLogicalPart("esalgo:SWED"),
978  ddname2,
979  scopy + 1000 * swed_scopy_glob + 100,
980  DDTranslation(xpos, ypos, zpos),
981  DDRotation("esalgo:RM1299"));
982 #ifdef EDM_ML_DEBUG
983  edm::LogVerbatim("SFGeom") << DDLogicalPart("esalgo:SWED").name() << " copy "
984  << (scopy + 1000 * swed_scopy_glob) << " in " << ddname << " at "
985  << DDTranslation(xpos, ypos, zpos) << " rotation esalgo:RM1299";
986  edm::LogVerbatim("SFGeom") << DDLogicalPart("esalgo:SWED").name() << " copy "
987  << (scopy + 1000 * swed_scopy_glob + 100) << " in " << ddname2 << " at "
988  << DDTranslation(xpos, ypos, zpos) << " rotation esalgo:RM1299";
989 #endif
990  ypos = ypos + ywedge_ceramic_diff;
991  zpos = -ladder_thick / 2. + 0.005 * mm + zwedge_ceramic_diff;
992  cpv.position(DDLogicalPart("esalgo:SFBX"),
993  ddname,
994  scopy + 1000 * swed_scopy_glob,
995  DDTranslation(xpos, ypos, zpos),
996  DDRotation("esalgo:RM1298"));
997  cpv.position(DDLogicalPart("esalgo:SFBY"),
998  ddname2,
999  scopy + 1000 * swed_scopy_glob,
1000  DDTranslation(xpos, ypos, zpos),
1001  DDRotation("esalgo:RM1300A"));
1002 #ifdef EDM_ML_DEBUG
1003  edm::LogVerbatim("SFGeom") << DDLogicalPart("esalgo:SFBX").name() << " copy "
1004  << (scopy + 1000 * swed_scopy_glob) << " in " << ddname << " at "
1005  << DDTranslation(xpos, ypos, zpos) << " rotation esalgo:RM1298";
1006  edm::LogVerbatim("SFGeom") << DDLogicalPart("esalgo:SFBY").name() << " copy "
1007  << (scopy + 1000 * swed_scopy_glob) << " in " << ddname2 << " at "
1008  << DDTranslation(xpos, ypos, zpos) << " rotation esalgo:RM1300A";
1009 #endif
1010  }
1011  }
1012  }
1013  } else {
1014  int d = M - types_l5_.size();
1015  DDName ddname(getLadPrefix(0) + types_l4_[d], "esalgo");
1016  DDName ddname2(getLadPrefix(1) + types_l4_[d], "esalgo");
1017  for (int i = 0; i <= 1; i++) {
1018  for (int j = 0; j <= 3; j++) {
1019  xpos = (i * 2 - 1) * waf_intra_col_sep / 2.;
1020  ypos = -ladder_length / 2. + 0.05 * mm - (LdrFrnt_Length - LdrBck_Length) / 2 + wedge_length / 2. +
1021  j * waf_active;
1022  zpos = -ladder_thick / 2. + 0.005 * mm + wedge_offset;
1023  if (ladd_l4_map_[(i + j * 2 + (M - types_l5_.size()) * 8)] == 1) {
1024  scopy++;
1025  cpv.position(DDLogicalPart("esalgo:SWED"),
1026  ddname,
1027  scopy + 1000 * swed_scopy_glob,
1028  DDTranslation(xpos, ypos, zpos),
1029  DDRotation("esalgo:RM1299"));
1030  cpv.position(DDLogicalPart("esalgo:SWED"),
1031  ddname2,
1032  scopy + 1000 * swed_scopy_glob + 100,
1033  DDTranslation(xpos, ypos, zpos),
1034  DDRotation("esalgo:RM1299"));
1035 #ifdef EDM_ML_DEBUG
1036  edm::LogVerbatim("SFGeom") << DDLogicalPart("esalgo:SWED").name() << " copy "
1037  << (scopy + 1000 * swed_scopy_glob) << " in " << ddname << " at "
1038  << DDTranslation(xpos, ypos, zpos) << " rotation esalgo:RM1299";
1039  edm::LogVerbatim("SFGeom") << DDLogicalPart("esalgo:SWED").name() << " copy "
1040  << (scopy + 1000 * swed_scopy_glob + 100) << " in " << ddname2 << " at "
1041  << DDTranslation(xpos, ypos, zpos) << " rotation esalgo:RM1299";
1042 #endif
1043  ypos = ypos + ywedge_ceramic_diff;
1044  zpos = -ladder_thick / 2. + 0.005 * mm + zwedge_ceramic_diff;
1045  cpv.position(DDLogicalPart("esalgo:SFBX"),
1046  ddname,
1047  scopy + 1000 * swed_scopy_glob,
1048  DDTranslation(xpos, ypos, zpos),
1049  DDRotation("esalgo:RM1298"));
1050  cpv.position(DDLogicalPart("esalgo:SFBY"),
1051  ddname2,
1052  scopy + 1000 * swed_scopy_glob,
1053  DDTranslation(xpos, ypos, zpos),
1054  DDRotation("esalgo:RM1300A"));
1055 #ifdef EDM_ML_DEBUG
1056  edm::LogVerbatim("SFGeom") << DDLogicalPart("esalgo:SFBX").name() << " copy "
1057  << (scopy + 1000 * swed_scopy_glob) << " in " << ddname << " at "
1058  << DDTranslation(xpos, ypos, zpos) << " rotation esalgo:RM1298";
1059  edm::LogVerbatim("SFGeom") << DDLogicalPart("esalgo:SFBY").name() << " copy "
1060  << (scopy + 1000 * swed_scopy_glob) << " in " << ddname2 << " at "
1061  << DDTranslation(xpos, ypos, zpos) << " rotation esalgo:RM1300A";
1062 #endif
1063  }
1064  }
1065  }
1066  }
1067  }
1068 
1069  // Positioning of ladders
1070 
1071  std::string type;
1072  int icopy[100] = {0};
1073 
1074  for (int I = -9; I <= 9; ++I) {
1075  prev_length_ = 0;
1076  int J = std::abs(I);
1077  for (int K = 0; K < noLaddInCol_[J]; K++) {
1078  std::string type;
1079 
1080  ladder_new_length_ = micromodule_length + 3 * waf_active;
1081  ladd_shift_ = 4 * waf_active;
1082 
1083  if (K == 0)
1084  type = typeOfLaddRow0[J];
1085  if (K == 1)
1086  type = typeOfLaddRow1[J];
1087  if (K == 2)
1088  type = typeOfLaddRow2[J];
1089  if (K == 3)
1090  type = typeOfLaddRow3[J];
1091 
1092  for (const auto& i : types_l5_)
1093  if (type == i) {
1094  ladder_new_length_ = micromodule_length + 4 * waf_active;
1095  ladd_shift_ = 5 * waf_active;
1096  }
1097 
1098  int j = 0;
1099 
1100  for (int t = 0; t < int(types_l5_.size()); t++)
1101  if (type == types_l5_[t]) {
1102  j = t;
1103  if (I < 0 && asym_ladd_[t] == 1) {
1104  j = j + 1;
1105  type = types_l5_[j];
1106  }
1107  }
1108  for (int t = 0; t < int(types_l4_.size()); t++)
1109  if (type == types_l4_[t]) {
1110  j = t + types_l5_.size();
1111  if (I < 0 && asym_ladd_[(t + types_l5_.size())] == 1) {
1112  j = j + 1;
1113  type = types_l4_[j - types_l5_.size()];
1114  }
1115  }
1116 
1117  xpos = I * (2 * waf_intra_col_sep + waf_inter_col_sep);
1118  if (I > 0)
1119  xpos = xpos + dee_separation;
1120  if (I < 0)
1121  xpos = xpos - dee_separation;
1122 
1123  int sz = 20;
1124  ypos = (sz - int(startOfFirstLadd_[J])) * waf_active - ladder_new_length_ / 2. +
1125  (LdrFrnt_Length - LdrBck_Length) / 2 + micromodule_length + 0.05 * cm - prev_length_;
1126 
1127  prev_length_ += ladd_shift_;
1128 
1129  zpos = zlead1_ + ladder_thick / 2. + 0.01 * mm;
1130  icopy[j] += 1;
1131  DDName ddname(getLadPrefix(0) + type, "esalgo");
1132 
1133  cpv.position(
1134  DDLogicalPart(ddname), DDName("SF", "esalgo"), icopy[j], DDTranslation(xpos, ypos, zpos), DDRotation());
1135 #ifdef EDM_ML_DEBUG
1136  edm::LogVerbatim("SFGeom") << DDLogicalPart(ddname).name() << " copy " << icopy[j] << " in "
1137  << DDName("SF", "esalgo") << " at " << DDTranslation(xpos, ypos, zpos)
1138  << " no rotation";
1139 #endif
1140  DDName ddname2(getLadPrefix(1) + type, "esalgo");
1141 
1142  xpos = I * (2 * waf_intra_col_sep + waf_inter_col_sep);
1143 
1144  cpv.position(DDLogicalPart(ddname2),
1145  DDName("SF", "esalgo"),
1146  icopy[j],
1147  DDTranslation(ypos, -xpos, zpos - zlead1_ + zlead2_),
1148  DDRotation("esalgo:R270"));
1149 #ifdef EDM_ML_DEBUG
1150  edm::LogVerbatim("SFGeom") << DDLogicalPart(ddname2).name() << " copy " << icopy[j] << " in "
1151  << DDName("SF", "esalgo") << " at "
1152  << DDTranslation(ypos, -xpos, zpos - zlead1_ + zlead2_) << " rotation esalgo:R270";
1153 #endif
1154  int changed = 0;
1155  for (int t = 0; t < int(types_l5_.size()); t++)
1156  if (type == types_l5_[t]) {
1157  j = t;
1158  if (asym_ladd_[t] == 2 && !changed) {
1159  j = j - 1;
1160  changed = 1;
1161  }
1162  if (asym_ladd_[t] == 1 && !changed) {
1163  j = j + 1;
1164  changed = 1;
1165  }
1166  type = types_l5_[j];
1167  }
1168  for (int t = 0; t < int(types_l4_.size()); t++)
1169  if (type == types_l4_[t]) {
1170  j = t + types_l5_.size();
1171  if (asym_ladd_[(t + types_l5_.size())] == 2 && !changed) {
1172  j = j - 1;
1173  changed = 1;
1174  }
1175  if (asym_ladd_[(t + types_l5_.size())] == 1 && !changed) {
1176  j = j + 1;
1177  changed = 1;
1178  }
1179  type = types_l4_[j - types_l5_.size()];
1180  }
1181 
1182  icopy[j] += 1;
1183 
1184  if (I > 0)
1185  xpos = xpos + dee_separation;
1186  if (I < 0)
1187  xpos = xpos - dee_separation;
1188 
1189  DDName ddname3(getLadPrefix(0) + type, "esalgo");
1190  cpv.position(DDLogicalPart(ddname3),
1191  DDName("SF", "esalgo"),
1192  icopy[j],
1193  DDTranslation(xpos, -ypos, zpos),
1194  DDRotation("esalgo:R180"));
1195 #ifdef EDM_ML_DEBUG
1196  edm::LogVerbatim("SFGeom") << DDLogicalPart(ddname3).name() << " copy " << icopy[j] << " in "
1197  << DDName("SF", "esalgo") << " at " << DDTranslation(xpos, -ypos, zpos)
1198  << " rotation esalgo:R180";
1199 #endif
1200  DDName ddname4(getLadPrefix(1) + type, "esalgo");
1201 
1202  xpos = I * (2 * waf_intra_col_sep + waf_inter_col_sep);
1203 
1204  cpv.position(DDLogicalPart(ddname4),
1205  DDName("SF", "esalgo"),
1206  icopy[j],
1207  DDTranslation(-ypos, -xpos, zpos - zlead1_ + zlead2_),
1208  DDRotation("esalgo:R090"));
1209 #ifdef EDM_ML_DEBUG
1210  edm::LogVerbatim("SFGeom") << DDLogicalPart(ddname4).name() << " copy " << icopy[j] << " in "
1211  << DDName("SF", "esalgo") << " at "
1212  << DDTranslation(-ypos, -xpos, zpos - zlead1_ + zlead2_) << " rotation esalgo:R090";
1213 #endif
1214  }
1215  }
1216 }
1217 
1219  double xpos(0), ypos(0);
1220  for (size_t i = 0; i < 32; ++i) {
1221  xpos = -waf_active / 2. + i * waf_active / 32. + waf_active / 64.;
1222  cpv.position(
1223  DDLogicalPart("esalgo:SFSX"), DDName("SFWX", "esalgo"), i + 1, DDTranslation(xpos, 0., 0.), DDRotation());
1224 #ifdef EDM_ML_DEBUG
1225  edm::LogVerbatim("SFGeom") << DDLogicalPart("esalgo:SFSX").name() << " copy " << (i + 1) << " in "
1226  << DDName("SFWX", "esalgo") << " at " << DDTranslation(xpos, 0., 0.) << " no rotation";
1227 #endif
1228 
1229  ypos = -waf_active / 2. + i * waf_active / 32. + waf_active / 64.;
1230  cpv.position(
1231  DDLogicalPart("esalgo:SFSY"), DDName("SFWY", "esalgo"), i + 1, DDTranslation(0., ypos, 0.), DDRotation());
1232 #ifdef EDM_ML_DEBUG
1233  edm::LogVerbatim("SFGeom") << DDLogicalPart("esalgo:SFSY").name() << " copy " << (i + 1) << " in "
1234  << DDName("SFWY", "esalgo") << " at " << DDTranslation(0., ypos, 0.) << " no rotation";
1235 #endif
1236  }
1237 }
1238 
1240 
1241 DEFINE_EDM_PLUGIN(DDAlgorithmFactory, DDEcalPreshowerAlgo, "ecal:DDEcalPreshowerAlgo");
std::vector< double > startOfFirstLadd_
Log< level::Info, true > LogVerbatim
std::vector< std::string > types_l4_
std::vector< std::string > typeOfLaddRow2
void initialize(const DDNumericArguments &nArgs, const DDVectorArguments &vArgs, const DDMapArguments &mArgs, const DDStringArguments &sArgs, const DDStringVectorArguments &vsArgs) override
void position(const DDLogicalPart &self, const DDLogicalPart &parent, const std::string &copyno, const DDTranslation &trans, const DDRotation &rot, const DDDivision *div=nullptr)
std::string getLayName(unsigned int i) const
std::vector< double > abs1stx
DDMaterial is used to define and access material information.
Definition: DDMaterial.h:45
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
DDName is used to identify DDD entities uniquely.
Definition: DDName.h:17
std::vector< double > rmaxVec
std::vector< double > ladd_l4_map_
void doLayers(DDCompactView &pos)
Compact representation of the geometrical detector hierarchy.
Definition: DDCompactView.h:81
DDMaterial getLaddMaterial() const
A DDSolid represents the shape of a part.
Definition: DDSolid.h:39
Represents a uniquely identifyable rotation matrix.
Definition: DDTransform.h:57
std::vector< double > asym_ladd_
std::vector< std::string > typeOfLaddRow1
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
A DDLogicalPart aggregates information concerning material, solid and sensitveness ...
Definition: DDLogicalPart.h:93
const std::complex< double > I
Definition: I.h:8
static DDSolid tubs(const DDName &name, double zhalf, double rIn, double rOut, double startPhi, double deltaPhi)
Definition: DDSolid.cc:667
static DDSolid trap(const DDName &name, double pDz, double pTheta, double pPhi, double pDy1, double pDx1, double pDx2, double pAlp1, double pDy2, double pDx3, double pDx4, double pAlp2)
Definition: DDSolid.cc:609
void doLadders(DDCompactView &pos)
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:547
d
Definition: ztail.py:151
void doSens(DDCompactView &pos)
const N & name() const
Definition: DDBase.h:59
std::vector< double > abs1sty
std::vector< std::string > typeOfLaddRow3
static DDSolid subtraction(const DDName &name, const DDSolid &a, const DDSolid &b, const DDTranslation &t, const DDRotation &r)
Definition: DDSolid.cc:599
std::vector< double > thickLayers_
DDMaterial getMaterial(unsigned int i) const
std::string getLadPrefix(unsigned int i) const
std::vector< double > rminVec
void execute(DDCompactView &pos) override
std::vector< std::string > materials_
std::vector< double > ladd_l5_map_
std::vector< std::string > typeOfLaddRow0
#define DEFINE_EDM_PLUGIN(factory, type, name)
static DDSolid unionSolid(const DDName &name, const DDSolid &a, const DDSolid &b, const DDTranslation &t, const DDRotation &r)
Definition: DDSolid.cc:594
std::vector< double > abs2ndx
std::vector< double > noLaddInCol_
std::vector< std::string > ladPfx_
ROOT::Math::DisplacementVector3D< ROOT::Math::Cartesian3D< double > > DDTranslation
Definition: DDTranslation.h:7
std::vector< double > abs2ndy
std::vector< std::string > types_l5_
std::vector< std::string > layName_