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]; bdy=2*30*cm;
225  if(I==20) bdx = abs2ndx[cutabsy]; bdy=2*30*cm;
226 
227  DDSolid solidcut = DDSolidFactory::box(dd_tmp_name_b,bdx,bdy,zHalf);
228 
229  DDSolid iner = DDSolidFactory::tubs(dd_tmp_name_c,zHalf+0.1*mm,0,In_rad_Abs_Pb,0.,360.*deg);
230 
231 
232  DDSolid final = DDSolidFactory::subtraction(dd_tmp_name_d,solidcut,iner,DDTranslation(0,0,0),DDRotation());
233 
234 
235  DDLogicalPart layer = DDLogicalPart(dd_tmp_name_d,getMaterial(i),final);
236  cpv.position(layer, parent(), 1, DDTranslation(0,0, zpos), DDRotation());
237 
238  DDSolid iner_Al = DDSolidFactory::tubs(dd_tmp_name_e,zHalf,In_rad_Abs_Al,In_rad_Abs_Pb-0.01*mm,0.,360.*deg);
239  DDLogicalPart layerAl = DDLogicalPart(dd_tmp_name_e,getMaterial(i-1),iner_Al);
240  cpv.position(layerAl, parent(), 1, DDTranslation(0,0, zpos), DDRotation());
241 
242  std::ostringstream tmp_Alname_fin;
243  tmp_Alname_fin << getLayName(i) << "LtmpAl" << absz-1;
244  DDName dd_Alname_fin(tmp_Alname_fin.str(),"esalgo");
245 
246  DDSolid Outer_Al = DDSolid(dd_Alname_fin);
247 
248  DDLogicalPart layerFinOutAl = DDLogicalPart(dd_tmp_name_f,getMaterial(i-1),Outer_Al);
249 
250  cpv.position(layerFinOutAl, parent(), 1, DDTranslation(0,0, zpos), DDRotation());
251  cpv.position(layerFinOutAl, parent(), 2, DDTranslation(0,0, zpos), DDRotation("esalgo:RABS90"));
252  cpv.position(layerFinOutAl, parent(), 3, DDTranslation(0,0, zpos), DDRotation("esalgo:RABS180B"));
253  cpv.position(layerFinOutAl, parent(), 4, DDTranslation(0,0, zpos), DDRotation("esalgo:R180"));
254 
255 
256 
257  } else {
258 
259  cpv.position(layer, parent(), 1, DDTranslation(0.,0., zpos), DDRotation());
260 
261  LogDebug("SFGeom")<<" debug : tubs, Logical part: "<<DDLogicalPart(ddname,getMaterial(i),solid)<<"\n translation "<<DDTranslation(0.,0.,zpos)<<" rotation "<<DDRotation()<< "\n";
262  }
263 
264  zpos += zHalf;
265  }
266 
267 }
268 
270 
271  double xpos(0), ypos(0), zpos(0), sdx(0), sdy(0), sdz(0);
272  double prev_length_(0), ladder_new_length_(0), ladd_shift_(0), ladder_length (0);
273  int enb(0), swed_scopy_glob(0); double sdxe[50] = {0}, sdye[50] = {0}, sdze[50] = {0};
274  double sdxe2[50] = {0}, sdye2[50] = {0}, sdze2[50] = {0}, sdxe3[50] = {0}, sdye3[50] = {0}, sdze3[50] = {0};
275 
276  for (int M=0; M<int(types_l5_.size() + types_l4_.size()); M++) {
277  int scopy(0); double boxax(0), boxay(0), boxaz(0);
278  int ladd_not_plain(0), ladd_subtr_no(0), ladd_upper(0), ladd_side(0);
279 
280  DDSolid solid_lfront = DDSolidFactory::trap(DDName("LDRFRNT","esalgo"),
281  LdrFrnt_Length/2, // pDz
282  -wedge_angle, // pTheta
283  0, // pPhi
284  ladder_width/2, // pDy1
285  (ladder_thick)/2, // pDx1
286  (ladder_thick)/2, // pDx2
287  0, //pAlp1
288  ladder_width/2, //pDy2
291  0 );
292 
293 
294  DDSolid solid_lbck = DDSolidFactory::trap(DDName("LDRBCK","esalgo"),
295  LdrBck_Length/2, // pDz
296  -wedge_angle, // pTheta
297  0, // pPhi
298  ladder_width/2, // pDy1
299  (box_thick/cos(wedge_angle*2)+0.02*mm)/2, // pDx1
300  (box_thick/cos(wedge_angle*2)+0.02*mm)/2, // pDx2
301  0, //pAlp1
302  ladder_width/2, //pDy2
303  (ladder_thick-wedge_back_thick)/2, // pDx3
304  (ladder_thick-wedge_back_thick)/2, // pDx4
305  0 );
306 
307  DDSolid solid_lfhalf = DDSolidFactory::trap(DDName("LDRFHALF","esalgo"),
308  LdrFrnt_Length/2, // pDz
309  -wedge_angle, // pTheta
310  0, // pPhi
311  (ladder_width/2)/2, // pDy1
312  (ladder_thick)/2, // pDx1
313  (ladder_thick)/2, // pDx2
314  0, //pAlp1
315  (ladder_width/2)/2, //pDy2
318  0 );
319 
320  DDSolid solid_lbhalf = DDSolidFactory::trap(DDName("LDRBHALF","esalgo"),
321  LdrBck_Length/2, // pDz
322  -wedge_angle, // pTheta
323  0, // pPhi
324  (ladder_width/2)/2, // pDy1
325  (box_thick/cos(wedge_angle*2)+0.02*mm)/2, // pDx1
326  (box_thick/cos(wedge_angle*2)+0.02*mm)/2, // pDx2
327  0, //pAlp1
328  (ladder_width/2)/2, //pDy2
329  (ladder_thick-wedge_back_thick)/2, // pDx3
330  (ladder_thick-wedge_back_thick)/2, // pDx4
331  0 );
332 
333  DDSolid solid_lfhtrunc = DDSolidFactory::trap(DDName("LDRFHTR","esalgo"),
334  (LdrFrnt_Length-waf_active)/2, // pDz
335  -wedge_angle, // pTheta
336  0, // pPhi
337  (ladder_width/2)/2, // pDy1
338  (ladder_thick)/2, // pDx1
339  (ladder_thick)/2, // pDx2
340  0, //pAlp1
341  (ladder_width/2)/2, //pDy2
344  0 );
345 
346 // Creation of ladders with 5 micromodules length
347 
348  if(M<int(types_l5_.size())) {
349 
350 
351  for (int i=0; i<=1; i++) {
352  for (int j=0; j<=3; j++) {
353  if(ladd_l5_map_[(i+j*2+M*10)]!=1){
354  ladd_not_plain=1; ladd_subtr_no++; if(j>1) ladd_upper=1; ladd_side=i;
355  }
356  }
357  }
358 
359  DDName ddname(getLadPrefix(0)+types_l5_[M],"esalgo");
360  ladder_length = micromodule_length + 4*waf_active + 0.1*mm;
361 
362 
363  if(ladd_not_plain) {
364  // enb++;
365  std::ostringstream tmp_name_5b, tmp_name_5c, tmp_name_5d;
366  if(ladd_upper) {
367 
368 
369  }//upper
370  else {
371  enb++;
372  std::ostringstream tmp_name_5b, tmp_name_5c, tmp_name_5d;
373  DDName dd_tmp_name_5a(getLadPrefix(2),"esalgo");
374  tmp_name_5b <<getLadPrefix(3)<< enb;
375  DDName dd_tmp_name_5b(tmp_name_5b.str(),"esalgo");
376  tmp_name_5c <<getLadPrefix(4)<< enb;
377  DDName dd_tmp_name_5c(tmp_name_5c.str(),"esalgo");
378  tmp_name_5d << getLadPrefix(5) << enb;
379  DDName dd_tmp_name_5d(tmp_name_5d.str(),"esalgo");
380 
381  DDName dd_tmp_name_5e(getLadPrefix(6),"esalgo");
382 
383  boxay = ladder_length-LdrFrnt_Length-LdrBck_Length; boxax = ladder_width; boxaz = ladder_thick;
384 
385  DDSolid solid_5a = DDSolidFactory::box(dd_tmp_name_5a,boxax/2,boxay/2,boxaz/2.);
386  if(ladd_side==0) sdxe[enb] = ladder_width/4; sdye[enb]= -boxay/2 - LdrFrnt_Length/2; sdze[enb] = -ladder_thick/2. + LdrFrnt_Offset;
387  if(ladd_side==1) sdxe[enb] = -ladder_width/4;
388 
389  DDSolid solid_5b = DDSolidFactory::unionSolid(dd_tmp_name_5b,solid_5a,solid_lfhalf,DDTranslation(sdxe[enb],sdye[enb],sdze[enb]),DDRotation("esalgo:RM1299"));
390 
391  if(ladd_side==0) sdxe2[enb] = -ladder_width/4; sdye2[enb]= -boxay/2 - LdrFrnt_Length/2 + waf_active/2;
392  sdze2[enb] = -ladder_thick/2. + LdrFrnt_Offset + (waf_active*sin(wedge_angle*2))/4;
393  if(ladd_side==1) sdxe2[enb] = ladder_width/4;
394 
395  DDSolid solid_5c = DDSolidFactory::unionSolid(dd_tmp_name_5c,solid_5b,solid_lfhtrunc,DDTranslation(sdxe2[enb],sdye2[enb],sdze2[enb]),DDRotation("esalgo:RM1299"));
396 
397  sdxe3[enb] = 0; sdye3[enb] = boxay/2 + LdrBck_Length/2; sdze3[enb] = -ladder_thick/2. + LdrBck_Offset;
398  DDSolid solid = DDSolidFactory::unionSolid(ddname,solid_5c,solid_lbck,DDTranslation(sdxe3[enb],sdye3[enb],sdze3[enb]),DDRotation("esalgo:RM1299"));
399 
400  DDLogicalPart ladder = DDLogicalPart(ddname,getLaddMaterial(),solid);
401  DDName ddname2(getLadPrefix(1)+types_l5_[M],"esalgo");
402  DDLogicalPart ladder2 = DDLogicalPart(ddname2,getLaddMaterial(),solid);
403 
404  }
405 
406  } //end of not plain ladder shape
407  else {
408 
409 
410 
411  DDName dd_tmp_name_5pa(getLadPrefix(2)+"5p","esalgo");
412  DDName dd_tmp_name_5pb(getLadPrefix(3)+"5p","esalgo");
413 
414  boxay = ladder_length-LdrFrnt_Length-LdrBck_Length; boxax = ladder_width; boxaz = ladder_thick;
415 
416  DDSolid solid_5pa = DDSolidFactory::box(dd_tmp_name_5pa,boxax/2,boxay/2,boxaz/2.);
417  sdx = 0; sdy= -boxay/2 - LdrFrnt_Length/2; sdz = -ladder_thick/2. + LdrFrnt_Offset;
418 
419  DDSolid solid_5pb = DDSolidFactory::unionSolid(dd_tmp_name_5pb,solid_5pa,solid_lfront,DDTranslation(sdx,sdy,sdz),DDRotation("esalgo:RM1299"));
420 
421  sdx = 0; sdy= boxay/2 + LdrBck_Length/2; sdz = -ladder_thick/2. + LdrBck_Offset;
422 
423  DDSolid solid = DDSolidFactory::unionSolid(ddname,solid_5pb,solid_lbck,DDTranslation(sdx,sdy,sdz),DDRotation("esalgo:RM1299"));
424 
425  DDLogicalPart ladder = DDLogicalPart(ddname,getLaddMaterial(),solid);
426  DDName ddname2(getLadPrefix(1)+types_l5_[M],"esalgo");
427  DDLogicalPart ladder2 = DDLogicalPart(ddname2,getLaddMaterial(),solid);
428 
429  }
430  }
431 
432 // Creation of ladders with 4 micromodules length
433 
434  if( M >= int(types_l5_.size()) ) {
435  int d = M - types_l5_.size();
436 
437  for (int i=0; i<=1; i++) {
438  for (int j=0; j<=3; j++) {
439  if(ladd_l4_map_[(i+j*2+(M-types_l5_.size())*8)]!=1 ){
440  ladd_not_plain=1; ladd_subtr_no++; if(j>1) ladd_upper=1; ladd_side=i;
441  }
442  }
443  }
444 
445  DDName ddname(getLadPrefix(0)+types_l4_[d],"esalgo");
446  ladder_length = micromodule_length + 3*waf_active + 0.1*mm;
447 
448  if(ladd_not_plain) {
449  std::ostringstream tmp_name_b, tmp_name_c, tmp_name_d;
450  if(ladd_upper) {
451  enb++;
452 
453  DDName dd_tmp_name_a(getLadPrefix(7),"esalgo");
454  tmp_name_b <<getLadPrefix(8)<< enb;
455  DDName dd_tmp_name_b(tmp_name_b.str(),"esalgo");
456  tmp_name_c <<getLadPrefix(9)<< enb;
457  DDName dd_tmp_name_c(tmp_name_c.str(),"esalgo");
458  tmp_name_d << getLadPrefix(10) << enb;
459  DDName dd_tmp_name_d(tmp_name_d.str(),"esalgo");
460  DDName dd_tmp_name_e(getLadPrefix(11),"esalgo");
461 
462  boxay = ladder_length-LdrFrnt_Length-LdrBck_Length; boxax = ladder_width; boxaz = ladder_thick;
463  DDSolid solid_a = DDSolidFactory::box(dd_tmp_name_a,boxax/2,boxay/2,boxaz/2.);
464 
465  sdxe[enb] = 0; sdye[enb]= -boxay/2 - LdrFrnt_Length/2; sdze[enb] = -ladder_thick/2. + LdrFrnt_Offset;
466  DDSolid solid_b = DDSolidFactory::unionSolid(dd_tmp_name_b,solid_a,solid_lfront,DDTranslation(sdxe[enb],sdye[enb],sdze[enb]),DDRotation("esalgo:RM1299"));
467 
468  if(ladd_side==0) sdxe2[enb] = ladder_width/4; sdye2[enb] = boxay/2 + LdrBck_Length/2; sdze2[enb] = -ladder_thick/2. + LdrBck_Offset;
469  if(ladd_side==1) sdxe2[enb] = -ladder_width/4;
470  DDSolid solid = DDSolidFactory::unionSolid(ddname,solid_b,solid_lbhalf,DDTranslation(sdxe2[enb],sdye2[enb],sdze2[enb]),DDRotation("esalgo:RM1299"));
471 
472  DDLogicalPart ladder = DDLogicalPart(ddname,getLaddMaterial(),solid);
473  DDName ddname2(getLadPrefix(1)+types_l4_[d],"esalgo");
474  DDLogicalPart ladder2 = DDLogicalPart(ddname2,getLaddMaterial(),solid);
475 
476  }//upper
477  else {
478  if(ladd_subtr_no>1) {
479  enb++;
480 
481  DDName dd_tmp_name_a(getLadPrefix(7),"esalgo");
482  tmp_name_b <<getLadPrefix(8)<< enb;
483  DDName dd_tmp_name_b(tmp_name_b.str(),"esalgo");
484  tmp_name_c <<getLadPrefix(9)<< enb;
485  DDName dd_tmp_name_c(tmp_name_c.str(),"esalgo");
486  tmp_name_d << getLadPrefix(10) << enb;
487  DDName dd_tmp_name_d(tmp_name_d.str(),"esalgo");
488  DDName dd_tmp_name_e(getLadPrefix(11),"esalgo");
489 
490  boxay = ladder_length-LdrFrnt_Length-LdrBck_Length; boxax = ladder_width; boxaz = ladder_thick;
491 
492  DDSolid solid_a = DDSolidFactory::box(dd_tmp_name_a,boxax/2,boxay/2,boxaz/2.);
493  if(ladd_side==0) sdxe[enb] = ladder_width/4; sdye[enb]= -boxay/2 - LdrFrnt_Length/2; sdze[enb] = -ladder_thick/2. + LdrFrnt_Offset;
494  if(ladd_side==1) sdxe[enb] = -ladder_width/4;
495 
496  DDSolid solid_b = DDSolidFactory::unionSolid(dd_tmp_name_b,solid_a,solid_lfhalf,DDTranslation(sdxe[enb],sdye[enb],sdze[enb]),DDRotation("esalgo:RM1299"));
497 
498  sdxe2[enb] = 0; sdye2[enb] = boxay/2 + LdrBck_Length/2; sdze2[enb] = -ladder_thick/2. + LdrBck_Offset;
499 
500  DDSolid solid = DDSolidFactory::unionSolid(ddname,solid_b,solid_lbck,DDTranslation(sdxe2[enb],sdye2[enb],sdze2[enb]),DDRotation("esalgo:RM1299"));
501 
502  DDLogicalPart ladder = DDLogicalPart(ddname,getLaddMaterial(),solid);
503  DDName ddname2(getLadPrefix(1)+types_l4_[d],"esalgo");
504  DDLogicalPart ladder2 = DDLogicalPart(ddname2,getLaddMaterial(),solid);
505  } else {
506  enb++;
507  DDName dd_tmp_name_a(getLadPrefix(7),"esalgo");
508  tmp_name_b <<getLadPrefix(8)<< enb;
509  DDName dd_tmp_name_b(tmp_name_b.str(),"esalgo");
510  tmp_name_c <<getLadPrefix(9)<< enb;
511  DDName dd_tmp_name_c(tmp_name_c.str(),"esalgo");
512  tmp_name_d << getLadPrefix(10) << enb;
513  DDName dd_tmp_name_d(tmp_name_d.str(),"esalgo");
514  DDName dd_tmp_name_e(getLadPrefix(11),"esalgo");
515 
516  boxay = ladder_length-LdrFrnt_Length-LdrBck_Length; boxax = ladder_width; boxaz = ladder_thick;
517  DDSolid solid_a = DDSolidFactory::box(dd_tmp_name_a,boxax/2,boxay/2,boxaz/2.);
518  if(ladd_side==0) sdxe[enb] = ladder_width/4; sdye[enb]= -boxay/2 - LdrFrnt_Length/2; sdze[enb] = -ladder_thick/2. + LdrFrnt_Offset;
519  if(ladd_side==1) sdxe[enb] = -ladder_width/4;
520 
521  DDSolid solid_b = DDSolidFactory::unionSolid(dd_tmp_name_b,solid_a,solid_lfhalf,DDTranslation(sdxe[enb],sdye[enb],sdze[enb]),DDRotation("esalgo:RM1299"));
522 
523  if(ladd_side==0) sdxe2[enb] = -ladder_width/4; sdye2[enb]= -boxay/2 - LdrFrnt_Length/2 + waf_active/2;
524  sdze2[enb] = -ladder_thick/2. + LdrFrnt_Offset + (waf_active*sin(wedge_angle*2))/4;
525  if(ladd_side==1) sdxe2[enb] = ladder_width/4;
526 
527  DDSolid solid_c = DDSolidFactory::unionSolid(dd_tmp_name_c,solid_b,solid_lfhtrunc,DDTranslation(sdxe2[enb],sdye2[enb],sdze2[enb]),DDRotation("esalgo:RM1299"));
528 
529  sdxe3[enb] = 0; sdye3[enb] = boxay/2 + LdrBck_Length/2; sdze3[enb] = -ladder_thick/2. + LdrBck_Offset;
530  DDSolid solid = DDSolidFactory::unionSolid(ddname,solid_c,solid_lbck,DDTranslation(sdxe3[enb],sdye3[enb],sdze3[enb]),DDRotation("esalgo:RM1299"));
531 
532  DDLogicalPart ladder = DDLogicalPart(ddname,getLaddMaterial(),solid);
533  DDName ddname2(getLadPrefix(1)+types_l4_[d],"esalgo");
534  DDLogicalPart ladder2 = DDLogicalPart(ddname2,getLaddMaterial(),solid);
535 
536  }
537  }
538 
539  } //end of not plain ladder shape
540  else {
541  DDName dd_tmp_name_pa(getLadPrefix(2)+"p","esalgo");
542  DDName dd_tmp_name_pb(getLadPrefix(3)+"p","esalgo");
543 
544  boxay = ladder_length-LdrFrnt_Length-LdrBck_Length; boxax = ladder_width; boxaz = ladder_thick;
545 
546  DDSolid solid_pa = DDSolidFactory::box(dd_tmp_name_pa,boxax/2,boxay/2,boxaz/2.);
547  sdx = 0; sdy= -boxay/2 - LdrFrnt_Length/2; sdz = -ladder_thick/2. + LdrFrnt_Offset;
548 
549  DDSolid solid_pb = DDSolidFactory::unionSolid(dd_tmp_name_pb,solid_pa,solid_lfront,DDTranslation(sdx,sdy,sdz),DDRotation("esalgo:RM1299"));
550 
551  sdx = 0; sdy= boxay/2 + LdrBck_Length/2; sdz = -ladder_thick/2. + LdrBck_Offset;
552  DDSolid solid = DDSolidFactory::unionSolid(ddname,solid_pb,solid_lbck,DDTranslation(sdx,sdy,sdz),DDRotation("esalgo:RM1299"));
553  DDLogicalPart ladder = DDLogicalPart(ddname,getLaddMaterial(),solid);
554  DDName ddname2(getLadPrefix(1)+types_l4_[d],"esalgo");
555  DDLogicalPart ladder2 = DDLogicalPart(ddname2,getLaddMaterial(),solid);
556  }
557  }
558 
559 // insert SWED, SFBX and SFBY into ladders
560  swed_scopy_glob++;
561  if(M<int(types_l5_.size())) {
562  DDName ddname(getLadPrefix(0)+types_l5_[M],"esalgo");
563  DDName ddname2(getLadPrefix(1)+types_l5_[M],"esalgo");
564  for (int i=0; i<=1; i++) {
565  for (int j=0; j<=4; j++) {
566  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;
567  zpos = -ladder_thick/2. + 0.005*mm + wedge_offset;
568  if(ladd_l5_map_[(i+j*2+M*10)]==1) {
569  scopy ++;
570  cpv.position(DDLogicalPart("esalgo:SWED"), ddname, scopy+1000*swed_scopy_glob, DDTranslation(xpos,ypos,zpos), DDRotation("esalgo:RM1299"));
571  cpv.position(DDLogicalPart("esalgo:SWED"), ddname2, scopy+1000*swed_scopy_glob+100, DDTranslation(xpos,ypos,zpos), DDRotation("esalgo:RM1299"));
572 
573  ypos = ypos + ywedge_ceramic_diff; zpos = -ladder_thick/2. + 0.005*mm + zwedge_ceramic_diff;
574  cpv.position(DDLogicalPart("esalgo:SFBX"), ddname, scopy+1000*swed_scopy_glob, DDTranslation(xpos,ypos,zpos), DDRotation("esalgo:RM1298"));
575  cpv.position(DDLogicalPart("esalgo:SFBY"), ddname2, scopy+1000*swed_scopy_glob, DDTranslation(xpos,ypos,zpos), DDRotation("esalgo:RM1300A"));
576  }
577  }
578  }
579  }
580  else
581  {
582  int d = M - types_l5_.size();
583  DDName ddname(getLadPrefix(0)+types_l4_[d],"esalgo");
584  DDName ddname2(getLadPrefix(1)+types_l4_[d],"esalgo");
585  for (int i=0; i<=1; i++) {
586  for (int j=0; j<=3; j++) {
587  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;
588  zpos = -ladder_thick/2. + 0.005*mm + wedge_offset;
589  if(ladd_l4_map_[(i+j*2+(M-types_l5_.size())*8)]==1) {
590  scopy ++;
591  cpv.position(DDLogicalPart("esalgo:SWED"), ddname, scopy+1000*swed_scopy_glob, DDTranslation(xpos,ypos,zpos), DDRotation("esalgo:RM1299"));
592  cpv.position(DDLogicalPart("esalgo:SWED"), ddname2, scopy+1000*swed_scopy_glob+100, DDTranslation(xpos,ypos,zpos), DDRotation("esalgo:RM1299"));
593 
594  ypos = ypos + ywedge_ceramic_diff; zpos = -ladder_thick/2. + 0.005*mm + zwedge_ceramic_diff;
595  cpv.position(DDLogicalPart("esalgo:SFBX"), ddname, scopy+1000*swed_scopy_glob, DDTranslation(xpos,ypos,zpos), DDRotation("esalgo:RM1298"));
596  cpv.position(DDLogicalPart("esalgo:SFBY"), ddname2, scopy+1000*swed_scopy_glob, DDTranslation(xpos,ypos,zpos), DDRotation("esalgo:RM1300A"));
597  }
598  }
599  }
600  }
601  }
602 
603 // Positioning of ladders
604 
606  int icopy[100] = {0};
607 
608  for(int I=-9; I<=9;++I) {
609  prev_length_=0; int J=std::abs(I);
610  for (int K=0; K<noLaddInCol_[J]; K++) {
612 
613  ladder_new_length_ = micromodule_length + 3*waf_active;
614  ladd_shift_ = 4*waf_active;
615 
616  if(K==0) type = typeOfLaddRow0[J];
617  if(K==1) type = typeOfLaddRow1[J];
618  if(K==2) type = typeOfLaddRow2[J];
619  if(K==3) type = typeOfLaddRow3[J];
620 
621  for(int i=0;i<int(types_l5_.size());i++) if(type == types_l5_[i]) {
622  ladder_new_length_ = micromodule_length + 4*waf_active;
623  ladd_shift_ = 5*waf_active;}
624 
625  int j = 0;
626 
627  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];}}
628  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()];}}
629 
631  if(I>0) xpos = xpos + dee_separation;
632  if(I<0) xpos = xpos - dee_separation;
633 
634  int sz = 20;
635  ypos = (sz-int(startOfFirstLadd_[J]))*waf_active - ladder_new_length_/2. + (LdrFrnt_Length-LdrBck_Length)/2 + micromodule_length + 0.05*cm - prev_length_;
636 
637  prev_length_ += ladd_shift_;
638 
639  zpos = zlead1_ + ladder_thick/2. + 0.01*mm;
640  icopy[j] +=1;
641  DDName ddname(getLadPrefix(0)+type,"esalgo");
642 
643  cpv.position(DDLogicalPart(ddname), DDName("SF","esalgo"), icopy[j], DDTranslation(xpos,ypos,zpos), DDRotation());
644 
645  DDName ddname2(getLadPrefix(1)+type,"esalgo");
646 
648 
649  cpv.position(DDLogicalPart(ddname2), DDName("SF","esalgo"), icopy[j], DDTranslation(ypos,-xpos,zpos-zlead1_+zlead2_), DDRotation("esalgo:R270"));
650 
651  int changed = 0;
652  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];}
653  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()]; }
654 
655  icopy[j] +=1;
656 
657  if(I>0) xpos = xpos + dee_separation;
658  if(I<0) xpos = xpos - dee_separation;
659 
660  DDName ddname3(getLadPrefix(0)+type,"esalgo");
661  cpv.position(DDLogicalPart(ddname3), DDName("SF","esalgo"), icopy[j], DDTranslation(xpos,-ypos,zpos), DDRotation("esalgo:R180"));
662 
663  DDName ddname4(getLadPrefix(1)+type,"esalgo");
664 
666 
667  cpv.position(DDLogicalPart(ddname4), DDName("SF","esalgo"), icopy[j], DDTranslation(-ypos,-xpos,zpos-zlead1_+zlead2_), DDRotation("esalgo:R090"));
668 
669  }
670  }
671 }
672 
674 
675  double xpos(0), ypos(0);
676  for(size_t i = 0; i<32; ++i)
677  {
678  xpos = -waf_active/2. + i*waf_active/32. + waf_active/64.;
679  cpv.position(DDLogicalPart("esalgo:SFSX"), DDName("SFWX","esalgo"), i+1, DDTranslation(xpos,0., 0.),DDRotation());
680 
681  LogDebug("SFGeom")<<" debug : SFSX, Logical part: "<<DDLogicalPart("esalgo:SFSX")<<"\n translation "<<DDTranslation(xpos,0.,0.)<<" rotation "<<DDRotation()<<" copy number= " <<i<<"\n";
682 
683  ypos = -waf_active/2. + i*waf_active/32. + waf_active/64.;
684  cpv.position(DDLogicalPart("esalgo:SFSY"),DDName("SFWY","esalgo"), i+1, DDTranslation(0.,ypos, 0.), DDRotation());
685 
686  LogDebug("SFGeom")<<" debug : SFSY, Logical part: "<<DDLogicalPart("esalgo:SFSY")<<"\n translation "<<DDTranslation(0.,ypos,0.)<<" rotation "<<DDRotation()<< " copy number= " <<i<< "\n";
687 
688  }
689 }
#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
list parent
Definition: dbtoconf.py:74
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:18
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
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_