CMS 3D CMS Logo

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