CMS 3D CMS Logo

DDEcalPreshowerAlgo.cc
Go to the documentation of this file.
2 
3 #include <cmath>
4 #include <algorithm>
5 
10 #include "CLHEP/Units/GlobalSystemOfUnits.h"
11 
13  LogDebug("EcalGeom") << "DDEcalPreshowerAlgo info: Creating an instance" ;
14 }
15 
17  const DDVectorArguments & vArgs,
18  const DDMapArguments & mArgs,
19  const DDStringArguments & sArgs,
20  const DDStringVectorArguments & vsArgs)
21 {
22  LogDebug("EcalGeom") << "DDEcalPreshowerAlgo info: Initialize" ;
23 
24  asym_ladd_ = vArgs["ASYMETRIC_LADDER"];
25  types_l5_ = vsArgs["TYPES_OF_LADD_L5"];
26  types_l4_ = vsArgs["TYPES_OF_LADD_L4"];
27  ladd_l5_map_ = vArgs["LADD_L5_MAP"];
28  ladd_l4_map_ = vArgs["LADD_L4_MAP"];
29  noLaddInCol_ = vArgs["NUMB_OF_LADD_IN_COL"];
30  startOfFirstLadd_ = vArgs["START_OF_1ST_LADD"];
31  typeOfLaddRow0 = vsArgs["TYPE_OF_LADD_1"];
32  typeOfLaddRow1 = vsArgs["TYPE_OF_LADD_2"];
33  typeOfLaddRow2 = vsArgs["TYPE_OF_LADD_3"];
34  typeOfLaddRow3 = vsArgs["TYPE_OF_LADD_4"];
35  thickLayers_ = vArgs["Layers"];
36  thickness_ = double(nArgs["PRESH_Z_TOTAL"]);
37  materials_ = vsArgs["LayMat"];
38  layName_ = vsArgs["LayName"];
39  rmaxVec = vArgs["R_MAX"]; // inner radii
40  rminVec = vArgs["R_MIN"]; // outer radii
41  waf_intra_col_sep = double(nArgs["waf_intra_col_sep"]);
42  waf_inter_col_sep = double(nArgs["waf_inter_col_sep"]);
43  waf_active = double(nArgs["waf_active"]);
44  wedge_length = double(nArgs["wedge_length"]);
45  wedge_offset = double(nArgs["wedge_offset"]);
46  zwedge_ceramic_diff = double(nArgs["zwedge_ceramic_diff"]);
47  ywedge_ceramic_diff = double(nArgs["ywedge_ceramic_diff"]);
48  ceramic_length = double(nArgs["ceramic_length"]);
49  wedge_angle = double(nArgs["wedge_angle"]);
50  wedge_back_thick = double(nArgs["wedge_back_thick"]);
51  ladder_thick = double(nArgs["ladder_thick"]);
52  ladder_width = double(nArgs["ladder_width"]);
53  micromodule_length = double(nArgs["micromodule_length"]);
54  box_thick = double(nArgs["box_thick"]);
55  abs1stx = vArgs["1ST_ABSX"];
56  abs1sty = vArgs["1ST_ABSY"];
57  abs2ndx = vArgs["2ND_ABSX"];
58  abs2ndy = vArgs["2ND_ABSY"];
59  ladPfx_ = vsArgs["LadPrefix"];
60  LaddMaterial_ = sArgs["LadderMaterial"];
61  LdrFrnt_Length = double(nArgs["LdrFrnt_Length"]);
62  LdrFrnt_Offset = double(nArgs["LdrFrnt_Offset"]);
63  LdrBck_Length = double(nArgs["LdrBck_Length"]);
64  LdrBck_Offset = double(nArgs["LdrBck_Offset"]);
65  dee_separation = double(nArgs["dee_sep"]);
66  In_rad_Abs_Al = double(nArgs["R_MIN_Abs_Al"]);
67  In_rad_Abs_Pb = double(nArgs["R_MIN_Abs_Pb"]);
68  rMax_Abs_Al_ = double(nArgs["R_MAX_Abs_Al"]);
69  absAlX_X_ = double(nArgs["AbsAlX_X"]);
70  absAlX_Y_ = double(nArgs["AbsAlX_Y"]);
71  absAlX_subtr1_Xshift_ = double(nArgs["AbsAlX_subtr1_Xshift"]);
72  absAlX_subtr1_Yshift_ = double(nArgs["AbsAlX_subtr1_Yshift"]);
73  absAlY_X_ = double(nArgs["AbsAlY_X"]);
74  absAlY_Y_ = double(nArgs["AbsAlY_Y"]);
75  absAlY_subtr1_Xshift_ = double(nArgs["AbsAlY_subtr1_Xshift"]);
76  absAlY_subtr1_Yshift_ = double(nArgs["AbsAlY_subtr1_Yshift"]);
77 
78 }
79 
81 {
82  LogDebug("EcalGeom") << "******** DDEcalPreshowerAlgo execute!";
83 
84  // creates all the tube-like layers of the preshower
85  doLayers(cpv);
86  // creates and places the ladders
87  doLadders(cpv);
88  // places the slicon strips in active silicon wafers
89  doSens(cpv);
90 
91 }
92 
94 {
95  double zpos = -thickness_/2., sdx(0), sdy(0), bdx(0),bdy(0);;
96 
97  for(size_t i = 0; i<thickLayers_.size(); ++i) {
98 
99  int I = int(i)+1; // FOTRAN I (offset +1)
100 
101  double rIn(0), rOut(0), zHalf(0);
102 
103  // create the name
104  DDName ddname(getLayName(i),"esalgo"); // namespace:name
105 
106  // cone dimensions
107  rIn = rminVec[i];
108  rOut = rmaxVec[i];
109  zHalf = thickLayers_[i]/2.;
110 
111  // create a logical part representing a single layer in the preshower
112  DDSolid solid = DDSolidFactory::tubs(ddname, zHalf, rIn, rOut, 0.,360.*deg);
113 
114  DDLogicalPart layer = DDLogicalPart(ddname,getMaterial(i),solid);
115 
116  // position the logical part w.r.t. the parent volume
117  zpos += zHalf;
118 
119  // create a logical part representing a single layer in the preshower
120  // skip layers with detectors, front and rear window
121  if (I==2 || I==28 || I==13 || I==23) {
122  zpos += zHalf;
123  continue;
124  }
125 
126  if ( I==12 ) {
127  zlead1_ = zpos + zHalf;
128  }
129  if ( I==22 ) {
130  zlead2_ = zpos + zHalf;
131  }
132 
133  if (I==10 || I==20) { // New lead shape
134 
135  int absz=0;
136  double outalbx, outalby, shiftR, outalbx2, outalby2, shiftR2;
137 
138  absz = int(abs1stx.size());
139  if ( I==20) absz = int(abs2ndx.size());
140  int cutabsx=-1, cutabsy=-1;
141 
142  DDName dd_tmp_name_b(getLayName(i)+"Lcut","esalgo");
143  DDName dd_tmp_name_c(getLayName(i)+"tmpb","esalgo");
144  DDName dd_tmp_name_d(getLayName(i)+"LinPb","esalgo");
145 
146  DDName dd_tmp_name_e(getLayName(i)+"LinAl","esalgo");
147  DDName dd_tmp_name_f(getLayName(i)+"LOutAl","esalgo");
148 
149  std::ostringstream tmp_Alname_fin;
150  tmp_Alname_fin << getLayName(i) << "LtmpAl" << absz-1;
151  DDName dd_Alname_fin(tmp_Alname_fin.str(),"esalgo");
152 
153  DDSolid Outer_Al = DDSolid(dd_Alname_fin);
154 
155  DDLogicalPart layerFinOutAl = DDLogicalPart(dd_tmp_name_f,getMaterial(i-1),Outer_Al);
156 
157  DDName dd_Alname_f(getLayName(i)+"LOutAl","esalgo");
158  DDName dd_Alname_g(getLayName(i)+"LOutAl2","esalgo");
159  DDName dd_Alname_h(getLayName(i)+"LOutAltmp","esalgo");
160  DDName dd_Alname_i(getLayName(i)+"LOutAltmp2","esalgo");
161  DDName dd_Alname_j(getLayName(i)+"LOutAltmp3","esalgo");
162  DDName dd_Alname_k(getLayName(i)+"LOutAltmp4","esalgo");
163  DDName dd_Alname_l(getLayName(i)+"LOutAltmp5","esalgo");
164  DDName dd_Alname_m(getLayName(i)+"LOutAltmp6","esalgo");
165 
166  DDSolid Out_Al = DDSolidFactory::tubs(dd_Alname_f,zHalf-0.1*mm,rMax_Abs_Al_-20*cm,rMax_Abs_Al_,0.,90.*deg);
167 
168  outalbx = absAlX_X_*0.1;
169  outalby = rMax_Abs_Al_+0.1*mm-absAlX_subtr1_Yshift_;
170  shiftR = absAlX_subtr1_Yshift_;
171  if ( I==20) {
172  outalbx = absAlY_X_*0.1;
173  outalby = rMax_Abs_Al_+0.1*mm-absAlY_subtr1_Yshift_;
174  shiftR = absAlY_subtr1_Xshift_;
175  }
176  DDSolid OutAltmp = DDSolidFactory::box(dd_Alname_h,outalbx/2+0.1*mm,outalby/2+0.1*mm,zHalf);
177  DDSolid Out_Altmp3 = DDSolidFactory::subtraction(dd_Alname_j,Out_Al,OutAltmp,DDTranslation(outalbx/2,outalby/2+shiftR,0),DDRotation());
178  outalby2 = absAlX_Y_*0.1;
179  outalbx2 = rMax_Abs_Al_+0.1*mm-absAlX_subtr1_Xshift_;
180  shiftR2 = absAlX_subtr1_Xshift_;
181  if ( I==20) {
182  outalby2 = absAlY_Y_*0.1;
183  outalbx2 = rMax_Abs_Al_+0.1*mm-absAlY_subtr1_Xshift_;
184  shiftR2 = absAlY_subtr1_Xshift_;
185  }
186  DDSolid OutAltmp2 = DDSolidFactory::box(dd_Alname_i,outalbx2/2+0.1*mm,outalby2/2+0.1*mm,zHalf);
187  DDSolid Out_Altmp4 = DDSolidFactory::subtraction(dd_Alname_k,Out_Altmp3,OutAltmp2,DDTranslation(outalbx2/2+shiftR2,outalby2/2,0),DDRotation());
188  DDSolid Out_Altmp5 = DDSolidFactory::unionSolid(dd_Alname_l,Out_Altmp4,Out_Altmp4,DDTranslation(0,0,0),DDRotation("esalgo:RABS90"));
189  DDSolid Out_Altmp6 = DDSolidFactory::unionSolid(dd_Alname_m,Out_Altmp5,Out_Altmp4,DDTranslation(0,0,0),DDRotation("esalgo:RABS180B"));
190  DDSolid Out_Al2 = DDSolidFactory::unionSolid(dd_Alname_g,Out_Altmp6,Out_Altmp4,DDTranslation(0,0,0),DDRotation("esalgo:R180"));
191 
192  for (int L=0; L<absz; ++L) {
193  int K=L;
194  std::ostringstream tmp_name_b, tmp_name_b2, tmp_FAl_name_c, tmp_FAl_name_d1, tmp_FAl_name_d2, tmp_FAl_name_d3, tmp_FAl_name_d;
195  tmp_name_b << getLayName(i) << "L" << K;
196  tmp_name_b2 << getLayName(i) << "Lb2" << K;
197 
198  if(L==0) tmp_FAl_name_c << getLayName(i)<<"LOutAl2";
199  if(L>0) tmp_FAl_name_c << getLayName(i) << "LtmpAl" << K-1;
200 
201  tmp_FAl_name_d1 << getLayName(i) << "LtmpAl" << K << "_1";
202  tmp_FAl_name_d2 << getLayName(i) << "LtmpAl" << K << "_2";
203  tmp_FAl_name_d3 << getLayName(i) << "LtmpAl" << K << "_3";
204  tmp_FAl_name_d << getLayName(i) << "LtmpAl" << K;
205 
206  DDName dd_tmp_name_b(tmp_name_b.str(),"esalgo");
207  DDName dd_tmp_name_b2(tmp_name_b2.str(),"esalgo");
208  DDName dd_FAl_name_c(tmp_FAl_name_c.str(),"esalgo");
209  DDName dd_FAl_name_d1(tmp_FAl_name_d1.str(),"esalgo");
210  DDName dd_FAl_name_d2(tmp_FAl_name_d2.str(),"esalgo");
211  DDName dd_FAl_name_d3(tmp_FAl_name_d3.str(),"esalgo");
212  DDName dd_FAl_name_d(tmp_FAl_name_d.str(),"esalgo");
213 
214  if(L==0) bdx = std::abs(abs1stx[K])/2;
215  if(L>0) bdx = std::abs(abs1stx[K]-abs1stx[K-1])/2;
216  bdy=abs1sty[K];
217  if(abs1stx[K] < rIn+30*cm) { bdy=abs1sty[K]/2 - 30*cm; cutabsx = K;}
218 
219  if(I==20) { if(L==0) bdx = std::abs(abs2ndx[K])/2;
220  if(L>0) bdx = std::abs(abs2ndx[K]-abs2ndx[K-1])/2;
221  bdy=abs2ndy[K];}
222 
223  if((abs2ndx[K] < rIn+30*cm) && I==20) { bdy=abs2ndy[K]/2 - 30*cm; cutabsy = K;}
224 
225  DDSolid solid_b = DDSolidFactory::box(dd_tmp_name_b,bdx,bdy,zHalf);
226  DDSolid solid_b2 = DDSolidFactory::box(dd_tmp_name_b2,bdx+0.1*mm,bdy+0.1*mm,zHalf);
227 
228  sdx = abs1stx[K]-bdx ; sdy = 0;
229  if(abs1stx[K] < rIn+30*cm ) sdy = abs1sty[K]-bdy ;
230 
231  if(I==20) {sdx = abs2ndx[K]-bdx ; sdy = 0;}
232  if((abs2ndx[K] < rIn+30*cm) && I==20 ) sdy = abs2ndy[K]-bdy ;
233 
234  DDLogicalPart layer = DDLogicalPart(dd_tmp_name_b,getMaterial(i),solid_b);
235 
236  cpv.position(layer, layerFinOutAl, 1, DDTranslation(sdx,sdy,0), DDRotation());
237  cpv.position(layer, layerFinOutAl, 2, DDTranslation(-sdx,sdy,0), DDRotation());
238  DDSolid solid_c = DDSolid(dd_FAl_name_c);
239  DDSolid solid_d1 = DDSolidFactory::unionSolid(dd_FAl_name_d1,solid_c,solid_b2,DDTranslation(sdx,sdy,0),DDRotation());
240  DDSolid solid_d2 = DDSolidFactory::unionSolid(dd_FAl_name_d,solid_d1,solid_b2,DDTranslation(-sdx,-sdy,0),DDRotation());
241 
242  if(((abs1stx[K] < rIn+30*cm) && I==10) || ((abs2ndx[K] < rIn+30*cm) && I==20) ) {
243  cpv.position(layer, layerFinOutAl, 3, DDTranslation(sdx,-sdy,0), DDRotation());
244  cpv.position(layer, layerFinOutAl, 4, DDTranslation(-sdx,-sdy,0), DDRotation());
245  DDSolid solid_c = DDSolid(dd_FAl_name_c);
246  DDSolid solid_d1 = DDSolidFactory::unionSolid(dd_FAl_name_d1,solid_c,solid_b2,DDTranslation(sdx,sdy,0),DDRotation());
247  DDSolid solid_d2 = DDSolidFactory::unionSolid(dd_FAl_name_d2,solid_d1,solid_b2,DDTranslation(sdx,-sdy,0),DDRotation());
248  DDSolid solid_d3 = DDSolidFactory::unionSolid(dd_FAl_name_d3,solid_d2,solid_b2,DDTranslation(-sdx,sdy,0),DDRotation());
249  DDSolid solid_d4 = DDSolidFactory::unionSolid(dd_FAl_name_d,solid_d3,solid_b2,DDTranslation(-sdx,-sdy,0),DDRotation());
250  }
251  }
252 
253  bdx = abs1stx[cutabsx];
254  if(I==20) bdx = abs2ndx[cutabsy];
255  bdy=2*30*cm;
256 
257  DDSolid solidcut = DDSolidFactory::box(dd_tmp_name_b,bdx,bdy,zHalf);
258 
259  DDSolid iner = DDSolidFactory::tubs(dd_tmp_name_c,zHalf+0.1*mm,0,In_rad_Abs_Pb,0.,360.*deg);
260 
261  DDSolid final = DDSolidFactory::subtraction(dd_tmp_name_d,solidcut,iner,DDTranslation(0,0,0),DDRotation());
262 
263  DDLogicalPart layer = DDLogicalPart(dd_tmp_name_d,getMaterial(i),final);
264  cpv.position(layer, parent(), 1, DDTranslation(0,0, zpos), DDRotation());
265 
266  DDSolid iner_Al = DDSolidFactory::tubs(dd_tmp_name_e,zHalf,In_rad_Abs_Al,In_rad_Abs_Pb-0.01*mm,0.,360.*deg);
267 
268  DDLogicalPart layerAl = DDLogicalPart(dd_tmp_name_e,getMaterial(i-1),iner_Al);
269  cpv.position(layerAl, parent(), 1, DDTranslation(0,0, zpos), DDRotation());
270  cpv.position(layerFinOutAl, parent(), 1, DDTranslation(0,0, zpos), DDRotation());
271  }
272  else {
273 
274  cpv.position(layer, parent(), 1, DDTranslation(0.,0., zpos), DDRotation());
275 
276  LogDebug("SFGeom")<<" debug : tubs, Logical part: "<<DDLogicalPart(ddname,getMaterial(i),solid)<<"\n translation "<<DDTranslation(0.,0.,zpos)<<" rotation "<<DDRotation()<< "\n";
277  }
278  zpos += zHalf;
279  }
280 }
281 
283 
284  double xpos(0), ypos(0), zpos(0), sdx(0), sdy(0), sdz(0);
285  double prev_length_(0), ladder_new_length_(0), ladd_shift_(0), ladder_length (0);
286  int enb(0), swed_scopy_glob(0); double sdxe[50] = {0}, sdye[50] = {0}, sdze[50] = {0};
287  double sdxe2[50] = {0}, sdye2[50] = {0}, sdze2[50] = {0}, sdxe3[50] = {0}, sdye3[50] = {0}, sdze3[50] = {0};
288 
289  for (int M=0; M<int(types_l5_.size() + types_l4_.size()); M++) {
290  int scopy(0); double boxax(0), boxay(0), boxaz(0);
291  int ladd_not_plain(0), ladd_subtr_no(0), ladd_upper(0), ladd_side(0);
292 
293  DDSolid solid_lfront = DDSolidFactory::trap(DDName("LDRFRNT","esalgo"),
294  LdrFrnt_Length/2, // pDz
295  -wedge_angle, // pTheta
296  0, // pPhi
297  ladder_width/2, // pDy1
298  (ladder_thick)/2, // pDx1
299  (ladder_thick)/2, // pDx2
300  0, //pAlp1
301  ladder_width/2, //pDy2
304  0 );
305 
306 
307  DDSolid solid_lbck = DDSolidFactory::trap(DDName("LDRBCK","esalgo"),
308  LdrBck_Length/2, // pDz
309  -wedge_angle, // pTheta
310  0, // pPhi
311  ladder_width/2, // pDy1
312  (box_thick/cos(wedge_angle*2)+0.02*mm)/2, // pDx1
313  (box_thick/cos(wedge_angle*2)+0.02*mm)/2, // pDx2
314  0, //pAlp1
315  ladder_width/2, //pDy2
316  (ladder_thick-wedge_back_thick)/2, // pDx3
317  (ladder_thick-wedge_back_thick)/2, // pDx4
318  0 );
319 
320  DDSolid solid_lfhalf = DDSolidFactory::trap(DDName("LDRFHALF","esalgo"),
321  LdrFrnt_Length/2, // pDz
322  -wedge_angle, // pTheta
323  0, // pPhi
324  (ladder_width/2)/2, // pDy1
325  (ladder_thick)/2, // pDx1
326  (ladder_thick)/2, // pDx2
327  0, //pAlp1
328  (ladder_width/2)/2, //pDy2
331  0 );
332 
333  DDSolid solid_lbhalf = DDSolidFactory::trap(DDName("LDRBHALF","esalgo"),
334  LdrBck_Length/2, // pDz
335  -wedge_angle, // pTheta
336  0, // pPhi
337  (ladder_width/2)/2, // pDy1
338  (box_thick/cos(wedge_angle*2)+0.02*mm)/2, // pDx1
339  (box_thick/cos(wedge_angle*2)+0.02*mm)/2, // pDx2
340  0, //pAlp1
341  (ladder_width/2)/2, //pDy2
342  (ladder_thick-wedge_back_thick)/2, // pDx3
343  (ladder_thick-wedge_back_thick)/2, // pDx4
344  0 );
345 
346  DDSolid solid_lfhtrunc = DDSolidFactory::trap(DDName("LDRFHTR","esalgo"),
347  (LdrFrnt_Length-waf_active)/2, // pDz
348  -wedge_angle, // pTheta
349  0, // pPhi
350  (ladder_width/2)/2, // pDy1
351  (ladder_thick)/2, // pDx1
352  (ladder_thick)/2, // pDx2
353  0, //pAlp1
354  (ladder_width/2)/2, //pDy2
357  0 );
358 
359  // Creation of ladders with 5 micromodules length
360 
361  if(M<int(types_l5_.size())) {
362  for (int i=0; i<=1; i++) {
363  for (int j=0; j<=3; j++) {
364  if(ladd_l5_map_[(i+j*2+M*10)]!=1){
365  ladd_not_plain=1; ladd_subtr_no++; if(j>1) ladd_upper=1; ladd_side=i;
366  }
367  }
368  }
369 
370  DDName ddname(getLadPrefix(0)+types_l5_[M],"esalgo");
371  ladder_length = micromodule_length + 4*waf_active + 0.1*mm;
372 
373 
374  if(ladd_not_plain) {
375  // enb++;
376  std::ostringstream tmp_name_5b, tmp_name_5c, tmp_name_5d;
377  if(ladd_upper) {
378 
379 
380  }//upper
381  else {
382  enb++;
383  std::ostringstream tmp_name_5b, tmp_name_5c, tmp_name_5d;
384  DDName dd_tmp_name_5a(getLadPrefix(2),"esalgo");
385  tmp_name_5b <<getLadPrefix(3)<< enb;
386  DDName dd_tmp_name_5b(tmp_name_5b.str(),"esalgo");
387  tmp_name_5c <<getLadPrefix(4)<< enb;
388  DDName dd_tmp_name_5c(tmp_name_5c.str(),"esalgo");
389  tmp_name_5d << getLadPrefix(5) << enb;
390  DDName dd_tmp_name_5d(tmp_name_5d.str(),"esalgo");
391 
392  DDName dd_tmp_name_5e(getLadPrefix(6),"esalgo");
393 
394  boxay = ladder_length-LdrFrnt_Length-LdrBck_Length; boxax = ladder_width; boxaz = ladder_thick;
395 
396  DDSolid solid_5a = DDSolidFactory::box(dd_tmp_name_5a,boxax/2,boxay/2,boxaz/2.);
397  if(ladd_side==0) sdxe[enb] = ladder_width/4;
398  sdye[enb]= -boxay/2 - LdrFrnt_Length/2;
399  sdze[enb] = -ladder_thick/2. + LdrFrnt_Offset;
400  if(ladd_side==1) sdxe[enb] = -ladder_width/4;
401 
402  DDSolid solid_5b = DDSolidFactory::unionSolid(dd_tmp_name_5b,solid_5a,solid_lfhalf,DDTranslation(sdxe[enb],sdye[enb],sdze[enb]),DDRotation("esalgo:RM1299"));
403 
404  if(ladd_side==0) sdxe2[enb] = -ladder_width/4;
405  sdye2[enb]= -boxay/2 - LdrFrnt_Length/2 + waf_active/2;
406  sdze2[enb] = -ladder_thick/2. + LdrFrnt_Offset + (waf_active*sin(wedge_angle*2))/4;
407  if(ladd_side==1) sdxe2[enb] = ladder_width/4;
408 
409  DDSolid solid_5c = DDSolidFactory::unionSolid(dd_tmp_name_5c,solid_5b,solid_lfhtrunc,DDTranslation(sdxe2[enb],sdye2[enb],sdze2[enb]),DDRotation("esalgo:RM1299"));
410 
411  sdxe3[enb] = 0; sdye3[enb] = boxay/2 + LdrBck_Length/2; sdze3[enb] = -ladder_thick/2. + LdrBck_Offset;
412  DDSolid solid = DDSolidFactory::unionSolid(ddname,solid_5c,solid_lbck,DDTranslation(sdxe3[enb],sdye3[enb],sdze3[enb]),DDRotation("esalgo:RM1299"));
413 
415  DDName ddname2(getLadPrefix(1)+types_l5_[M],"esalgo");
416  DDLogicalPart ladder2 = DDLogicalPart(ddname2,getLaddMaterial(),solid);
417 
418  }
419 
420  } //end of not plain ladder shape
421  else {
422 
423  DDName dd_tmp_name_5pa(getLadPrefix(2)+"5p","esalgo");
424  DDName dd_tmp_name_5pb(getLadPrefix(3)+"5p","esalgo");
425 
426  boxay = ladder_length-LdrFrnt_Length-LdrBck_Length; boxax = ladder_width; boxaz = ladder_thick;
427 
428  DDSolid solid_5pa = DDSolidFactory::box(dd_tmp_name_5pa,boxax/2,boxay/2,boxaz/2.);
429  sdx = 0; sdy= -boxay/2 - LdrFrnt_Length/2; sdz = -ladder_thick/2. + LdrFrnt_Offset;
430 
431  DDSolid solid_5pb = DDSolidFactory::unionSolid(dd_tmp_name_5pb,solid_5pa,solid_lfront,DDTranslation(sdx,sdy,sdz),DDRotation("esalgo:RM1299"));
432 
433  sdx = 0; sdy= boxay/2 + LdrBck_Length/2; sdz = -ladder_thick/2. + LdrBck_Offset;
434 
435  DDSolid solid = DDSolidFactory::unionSolid(ddname,solid_5pb,solid_lbck,DDTranslation(sdx,sdy,sdz),DDRotation("esalgo:RM1299"));
436 
438  DDName ddname2(getLadPrefix(1)+types_l5_[M],"esalgo");
439  DDLogicalPart ladder2 = DDLogicalPart(ddname2,getLaddMaterial(),solid);
440 
441  }
442  }
443 
444  // Creation of ladders with 4 micromodules length
445 
446  if( M >= int(types_l5_.size()) ) {
447  int d = M - types_l5_.size();
448 
449  for (int i=0; i<=1; i++) {
450  for (int j=0; j<=3; j++) {
451  if(ladd_l4_map_[(i+j*2+(M-types_l5_.size())*8)]!=1 ){
452  ladd_not_plain=1; ladd_subtr_no++; if(j>1) ladd_upper=1; ladd_side=i;
453  }
454  }
455  }
456 
457  DDName ddname(getLadPrefix(0)+types_l4_[d],"esalgo");
458  ladder_length = micromodule_length + 3*waf_active + 0.1*mm;
459 
460  if(ladd_not_plain) {
461  std::ostringstream tmp_name_b, tmp_name_c, tmp_name_d;
462  if(ladd_upper) {
463  enb++;
464 
465  DDName dd_tmp_name_a(getLadPrefix(7),"esalgo");
466  tmp_name_b <<getLadPrefix(8)<< enb;
467  DDName dd_tmp_name_b(tmp_name_b.str(),"esalgo");
468  tmp_name_c <<getLadPrefix(9)<< enb;
469  DDName dd_tmp_name_c(tmp_name_c.str(),"esalgo");
470  tmp_name_d << getLadPrefix(10) << enb;
471  DDName dd_tmp_name_d(tmp_name_d.str(),"esalgo");
472  DDName dd_tmp_name_e(getLadPrefix(11),"esalgo");
473 
474  boxay = ladder_length-LdrFrnt_Length-LdrBck_Length; boxax = ladder_width; boxaz = ladder_thick;
475  DDSolid solid_a = DDSolidFactory::box(dd_tmp_name_a,boxax/2,boxay/2,boxaz/2.);
476 
477  sdxe[enb] = 0; sdye[enb]= -boxay/2 - LdrFrnt_Length/2; sdze[enb] = -ladder_thick/2. + LdrFrnt_Offset;
478  DDSolid solid_b = DDSolidFactory::unionSolid(dd_tmp_name_b,solid_a,solid_lfront,DDTranslation(sdxe[enb],sdye[enb],sdze[enb]),DDRotation("esalgo:RM1299"));
479 
480  if(ladd_side==0) sdxe2[enb] = ladder_width/4;
481  sdye2[enb] = boxay/2 + LdrBck_Length/2;
482  sdze2[enb] = -ladder_thick/2. + LdrBck_Offset;
483  if(ladd_side==1) sdxe2[enb] = -ladder_width/4;
484  DDSolid solid = DDSolidFactory::unionSolid(ddname,solid_b,solid_lbhalf,DDTranslation(sdxe2[enb],sdye2[enb],sdze2[enb]),DDRotation("esalgo:RM1299"));
485 
487  DDName ddname2(getLadPrefix(1)+types_l4_[d],"esalgo");
488  DDLogicalPart ladder2 = DDLogicalPart(ddname2,getLaddMaterial(),solid);
489 
490  }//upper
491  else {
492  if(ladd_subtr_no>1) {
493  enb++;
494 
495  DDName dd_tmp_name_a(getLadPrefix(7),"esalgo");
496  tmp_name_b <<getLadPrefix(8)<< enb;
497  DDName dd_tmp_name_b(tmp_name_b.str(),"esalgo");
498  tmp_name_c <<getLadPrefix(9)<< enb;
499  DDName dd_tmp_name_c(tmp_name_c.str(),"esalgo");
500  tmp_name_d << getLadPrefix(10) << enb;
501  DDName dd_tmp_name_d(tmp_name_d.str(),"esalgo");
502  DDName dd_tmp_name_e(getLadPrefix(11),"esalgo");
503 
504  boxay = ladder_length-LdrFrnt_Length-LdrBck_Length; boxax = ladder_width; boxaz = ladder_thick;
505 
506  DDSolid solid_a = DDSolidFactory::box(dd_tmp_name_a,boxax/2,boxay/2,boxaz/2.);
507  if(ladd_side==0) sdxe[enb] = ladder_width/4;
508  sdye[enb]= -boxay/2 - LdrFrnt_Length/2;
509  sdze[enb] = -ladder_thick/2. + LdrFrnt_Offset;
510  if(ladd_side==1) sdxe[enb] = -ladder_width/4;
511 
512  DDSolid solid_b = DDSolidFactory::unionSolid(dd_tmp_name_b,solid_a,solid_lfhalf,DDTranslation(sdxe[enb],sdye[enb],sdze[enb]),DDRotation("esalgo:RM1299"));
513 
514  sdxe2[enb] = 0; sdye2[enb] = boxay/2 + LdrBck_Length/2; sdze2[enb] = -ladder_thick/2. + LdrBck_Offset;
515 
516  DDSolid solid = DDSolidFactory::unionSolid(ddname,solid_b,solid_lbck,DDTranslation(sdxe2[enb],sdye2[enb],sdze2[enb]),DDRotation("esalgo:RM1299"));
517 
519  DDName ddname2(getLadPrefix(1)+types_l4_[d],"esalgo");
520  DDLogicalPart ladder2 = DDLogicalPart(ddname2,getLaddMaterial(),solid);
521  } else {
522  enb++;
523  DDName dd_tmp_name_a(getLadPrefix(7),"esalgo");
524  tmp_name_b <<getLadPrefix(8)<< enb;
525  DDName dd_tmp_name_b(tmp_name_b.str(),"esalgo");
526  tmp_name_c <<getLadPrefix(9)<< enb;
527  DDName dd_tmp_name_c(tmp_name_c.str(),"esalgo");
528  tmp_name_d << getLadPrefix(10) << enb;
529  DDName dd_tmp_name_d(tmp_name_d.str(),"esalgo");
530  DDName dd_tmp_name_e(getLadPrefix(11),"esalgo");
531 
532  boxay = ladder_length-LdrFrnt_Length-LdrBck_Length; boxax = ladder_width; boxaz = ladder_thick;
533  DDSolid solid_a = DDSolidFactory::box(dd_tmp_name_a,boxax/2,boxay/2,boxaz/2.);
534  if(ladd_side==0) sdxe[enb] = ladder_width/4;
535  sdye[enb]= -boxay/2 - LdrFrnt_Length/2;
536  sdze[enb] = -ladder_thick/2. + LdrFrnt_Offset;
537  if(ladd_side==1) sdxe[enb] = -ladder_width/4;
538 
539  DDSolid solid_b = DDSolidFactory::unionSolid(dd_tmp_name_b,solid_a,solid_lfhalf,DDTranslation(sdxe[enb],sdye[enb],sdze[enb]),DDRotation("esalgo:RM1299"));
540 
541  if(ladd_side==0) sdxe2[enb] = -ladder_width/4;
542  sdye2[enb]= -boxay/2 - LdrFrnt_Length/2 + waf_active/2;
543  sdze2[enb] = -ladder_thick/2. + LdrFrnt_Offset + (waf_active*sin(wedge_angle*2))/4;
544  if(ladd_side==1) sdxe2[enb] = ladder_width/4;
545 
546  DDSolid solid_c = DDSolidFactory::unionSolid(dd_tmp_name_c,solid_b,solid_lfhtrunc,DDTranslation(sdxe2[enb],sdye2[enb],sdze2[enb]),DDRotation("esalgo:RM1299"));
547 
548  sdxe3[enb] = 0; sdye3[enb] = boxay/2 + LdrBck_Length/2; sdze3[enb] = -ladder_thick/2. + LdrBck_Offset;
549  DDSolid solid = DDSolidFactory::unionSolid(ddname,solid_c,solid_lbck,DDTranslation(sdxe3[enb],sdye3[enb],sdze3[enb]),DDRotation("esalgo:RM1299"));
550 
552  DDName ddname2(getLadPrefix(1)+types_l4_[d],"esalgo");
553  DDLogicalPart ladder2 = DDLogicalPart(ddname2,getLaddMaterial(),solid);
554 
555  }
556  }
557 
558  } //end of not plain ladder shape
559  else {
560  DDName dd_tmp_name_pa(getLadPrefix(2)+"p","esalgo");
561  DDName dd_tmp_name_pb(getLadPrefix(3)+"p","esalgo");
562 
563  boxay = ladder_length-LdrFrnt_Length-LdrBck_Length; boxax = ladder_width; boxaz = ladder_thick;
564 
565  DDSolid solid_pa = DDSolidFactory::box(dd_tmp_name_pa,boxax/2,boxay/2,boxaz/2.);
566  sdx = 0; sdy= -boxay/2 - LdrFrnt_Length/2; sdz = -ladder_thick/2. + LdrFrnt_Offset;
567 
568  DDSolid solid_pb = DDSolidFactory::unionSolid(dd_tmp_name_pb,solid_pa,solid_lfront,DDTranslation(sdx,sdy,sdz),DDRotation("esalgo:RM1299"));
569 
570  sdx = 0; sdy= boxay/2 + LdrBck_Length/2; sdz = -ladder_thick/2. + LdrBck_Offset;
571  DDSolid solid = DDSolidFactory::unionSolid(ddname,solid_pb,solid_lbck,DDTranslation(sdx,sdy,sdz),DDRotation("esalgo:RM1299"));
573  DDName ddname2(getLadPrefix(1)+types_l4_[d],"esalgo");
574  DDLogicalPart ladder2 = DDLogicalPart(ddname2,getLaddMaterial(),solid);
575  }
576  }
577 
578  // insert SWED, SFBX and SFBY into ladders
579  swed_scopy_glob++;
580  if(M<int(types_l5_.size())) {
581  DDName ddname(getLadPrefix(0)+types_l5_[M],"esalgo");
582  DDName ddname2(getLadPrefix(1)+types_l5_[M],"esalgo");
583  for (int i=0; i<=1; i++) {
584  for (int j=0; j<=4; j++) {
585  xpos = (i*2-1)*waf_intra_col_sep/2.; ypos = -ladder_length/2. + 0.05*mm -(LdrFrnt_Length-LdrBck_Length)/2 + wedge_length/2. + j*waf_active;
586  zpos = -ladder_thick/2. + 0.005*mm + wedge_offset;
587  if(ladd_l5_map_[(i+j*2+M*10)]==1) {
588  scopy ++;
589  cpv.position(DDLogicalPart("esalgo:SWED"), ddname, scopy+1000*swed_scopy_glob, DDTranslation(xpos,ypos,zpos), DDRotation("esalgo:RM1299"));
590  cpv.position(DDLogicalPart("esalgo:SWED"), ddname2, scopy+1000*swed_scopy_glob+100, DDTranslation(xpos,ypos,zpos), DDRotation("esalgo:RM1299"));
591 
592  ypos = ypos + ywedge_ceramic_diff; zpos = -ladder_thick/2. + 0.005*mm + zwedge_ceramic_diff;
593  cpv.position(DDLogicalPart("esalgo:SFBX"), ddname, scopy+1000*swed_scopy_glob, DDTranslation(xpos,ypos,zpos), DDRotation("esalgo:RM1298"));
594  cpv.position(DDLogicalPart("esalgo:SFBY"), ddname2, scopy+1000*swed_scopy_glob, DDTranslation(xpos,ypos,zpos), DDRotation("esalgo:RM1300A"));
595  }
596  }
597  }
598  }
599  else
600  {
601  int d = M - types_l5_.size();
602  DDName ddname(getLadPrefix(0)+types_l4_[d],"esalgo");
603  DDName ddname2(getLadPrefix(1)+types_l4_[d],"esalgo");
604  for (int i=0; i<=1; i++) {
605  for (int j=0; j<=3; j++) {
606  xpos = (i*2-1)*waf_intra_col_sep/2.; ypos = -ladder_length/2. + 0.05*mm - (LdrFrnt_Length-LdrBck_Length)/2 + wedge_length/2. + j*waf_active;
607  zpos = -ladder_thick/2. + 0.005*mm + wedge_offset;
608  if(ladd_l4_map_[(i+j*2+(M-types_l5_.size())*8)]==1) {
609  scopy ++;
610  cpv.position(DDLogicalPart("esalgo:SWED"), ddname, scopy+1000*swed_scopy_glob, DDTranslation(xpos,ypos,zpos), DDRotation("esalgo:RM1299"));
611  cpv.position(DDLogicalPart("esalgo:SWED"), ddname2, scopy+1000*swed_scopy_glob+100, DDTranslation(xpos,ypos,zpos), DDRotation("esalgo:RM1299"));
612 
613  ypos = ypos + ywedge_ceramic_diff; zpos = -ladder_thick/2. + 0.005*mm + zwedge_ceramic_diff;
614  cpv.position(DDLogicalPart("esalgo:SFBX"), ddname, scopy+1000*swed_scopy_glob, DDTranslation(xpos,ypos,zpos), DDRotation("esalgo:RM1298"));
615  cpv.position(DDLogicalPart("esalgo:SFBY"), ddname2, scopy+1000*swed_scopy_glob, DDTranslation(xpos,ypos,zpos), DDRotation("esalgo:RM1300A"));
616  }
617  }
618  }
619  }
620  }
621 
622  // Positioning of ladders
623 
625  int icopy[100] = {0};
626 
627  for(int I=-9; I<=9;++I) {
628  prev_length_=0; int J=std::abs(I);
629  for (int K=0; K<noLaddInCol_[J]; K++) {
631 
632  ladder_new_length_ = micromodule_length + 3*waf_active;
633  ladd_shift_ = 4*waf_active;
634 
635  if(K==0) type = typeOfLaddRow0[J];
636  if(K==1) type = typeOfLaddRow1[J];
637  if(K==2) type = typeOfLaddRow2[J];
638  if(K==3) type = typeOfLaddRow3[J];
639 
640  for(const auto & i : types_l5_) if(type == i) {
641  ladder_new_length_ = micromodule_length + 4*waf_active;
642  ladd_shift_ = 5*waf_active;}
643 
644  int j = 0;
645 
646  for(int t=0;t<int(types_l5_.size());t++) if(type == types_l5_[t]) {j = t; if(I<0 && asym_ladd_[t] == 1 ) {j = j + 1; type = types_l5_[j];}}
647  for(int t=0;t<int(types_l4_.size());t++) if(type == types_l4_[t]) {j = t+types_l5_.size(); if(I<0 && asym_ladd_[(t+types_l5_.size())] == 1 ) {j = j + 1; type = types_l4_[j-types_l5_.size()];}}
648 
650  if(I>0) xpos = xpos + dee_separation;
651  if(I<0) xpos = xpos - dee_separation;
652 
653  int sz = 20;
654  ypos = (sz-int(startOfFirstLadd_[J]))*waf_active - ladder_new_length_/2. + (LdrFrnt_Length-LdrBck_Length)/2 + micromodule_length + 0.05*cm - prev_length_;
655 
656  prev_length_ += ladd_shift_;
657 
658  zpos = zlead1_ + ladder_thick/2. + 0.01*mm;
659  icopy[j] +=1;
660  DDName ddname(getLadPrefix(0)+type,"esalgo");
661 
662  cpv.position(DDLogicalPart(ddname), DDName("SF","esalgo"), icopy[j], DDTranslation(xpos,ypos,zpos), DDRotation());
663 
664  DDName ddname2(getLadPrefix(1)+type,"esalgo");
665 
667 
668  cpv.position(DDLogicalPart(ddname2), DDName("SF","esalgo"), icopy[j], DDTranslation(ypos,-xpos,zpos-zlead1_+zlead2_), DDRotation("esalgo:R270"));
669 
670  int changed = 0;
671  for(int t=0;t<int(types_l5_.size());t++) if(type == types_l5_[t]) {j = t; if(asym_ladd_[t] == 2 && !changed) { j = j - 1; changed = 1;} if(asym_ladd_[t] == 1 && !changed) { j = j + 1; changed = 1;} type = types_l5_[j];}
672  for(int t=0;t<int(types_l4_.size());t++) if(type == types_l4_[t]) {j = t+types_l5_.size(); if(asym_ladd_[(t+types_l5_.size())] == 2 && !changed) { j = j - 1; changed = 1;} if(asym_ladd_[(t+types_l5_.size())] == 1 && !changed) { j = j + 1; changed = 1;} type = types_l4_[j-types_l5_.size()]; }
673 
674  icopy[j] +=1;
675 
676  if(I>0) xpos = xpos + dee_separation;
677  if(I<0) xpos = xpos - dee_separation;
678 
679  DDName ddname3(getLadPrefix(0)+type,"esalgo");
680  cpv.position(DDLogicalPart(ddname3), DDName("SF","esalgo"), icopy[j], DDTranslation(xpos,-ypos,zpos), DDRotation("esalgo:R180"));
681 
682  DDName ddname4(getLadPrefix(1)+type,"esalgo");
683 
685 
686  cpv.position(DDLogicalPart(ddname4), DDName("SF","esalgo"), icopy[j], DDTranslation(-ypos,-xpos,zpos-zlead1_+zlead2_), DDRotation("esalgo:R090"));
687 
688  }
689  }
690 }
691 
693 
694  double xpos(0), ypos(0);
695  for(size_t i = 0; i<32; ++i)
696  {
697  xpos = -waf_active/2. + i*waf_active/32. + waf_active/64.;
698  cpv.position(DDLogicalPart("esalgo:SFSX"), DDName("SFWX","esalgo"), i+1, DDTranslation(xpos,0., 0.),DDRotation());
699 
700  LogDebug("SFGeom")<<" debug : SFSX, Logical part: "<<DDLogicalPart("esalgo:SFSX")<<"\n translation "<<DDTranslation(xpos,0.,0.)<<" rotation "<<DDRotation()<<" copy number= " <<i<<"\n";
701 
702  ypos = -waf_active/2. + i*waf_active/32. + waf_active/64.;
703  cpv.position(DDLogicalPart("esalgo:SFSY"),DDName("SFWY","esalgo"), i+1, DDTranslation(0.,ypos, 0.), DDRotation());
704 
705  LogDebug("SFGeom")<<" debug : SFSY, Logical part: "<<DDLogicalPart("esalgo:SFSY")<<"\n translation "<<DDTranslation(0.,ypos,0.)<<" rotation "<<DDRotation()<< " copy number= " <<i<< "\n";
706 
707  }
708 }
#define LogDebug(id)
std::vector< double > startOfFirstLadd_
type
Definition: HCALResponse.h:21
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
std::string getLayName(unsigned int i) const
std::vector< double > abs1stx
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
DDName is used to identify DDD entities uniquely.
Definition: DDName.h:15
std::vector< double > rmaxVec
std::vector< double > ladd_l4_map_
void doLayers(DDCompactView &pos)
Compact representation of the geometrical detector hierarchy.
Definition: DDCompactView.h:83
A DDSolid represents the shape of a part.
Definition: DDSolid.h:38
ROOT::Math::DisplacementVector3D< ROOT::Math::Cartesian3D< double > > DDTranslation
Definition: DDTranslation.h:7
Represents a uniquely identifyable rotation matrix.
Definition: DDTransform.h:67
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:92
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:863
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:794
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:705
void doSens(DDCompactView &pos)
DDMaterial getMaterial(unsigned int i) const
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:776
std::vector< double > thickLayers_
void position(const DDLogicalPart &self, const DDLogicalPart &parent, const std::string &copyno, const DDTranslation &trans, const DDRotation &rot, const DDDivision *div=0)
std::vector< double > rminVec
void execute(DDCompactView &pos) override
std::vector< std::string > materials_
std::string getLadPrefix(unsigned int i) const
std::vector< double > ladd_l5_map_
DDMaterial getLaddMaterial() const
std::vector< std::string > typeOfLaddRow0
static DDSolid unionSolid(const DDName &name, const DDSolid &a, const DDSolid &b, const DDTranslation &t, const DDRotation &r)
Definition: DDSolid.cc:767
std::vector< double > abs2ndx
std::vector< double > noLaddInCol_
std::vector< std::string > ladPfx_
std::vector< double > abs2ndy
std::vector< std::string > types_l5_
std::vector< std::string > layName_