test
CMS 3D CMS Logo

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