00001 #include "Geometry/EcalCommonData/interface/DDEcalPreshowerAlgo.h"
00002
00003 #include <cmath>
00004 #include <algorithm>
00005
00006 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00007 #include "DetectorDescription/Base/interface/DDTypes.h"
00008 #include "DetectorDescription/Core/interface/DDPosPart.h"
00009 #include "DetectorDescription/Core/interface/DDLogicalPart.h"
00010 #include "DetectorDescription/Core/interface/DDSolid.h"
00011 #include "CLHEP/Units/SystemOfUnits.h"
00012
00013 DDEcalPreshowerAlgo::DDEcalPreshowerAlgo() : DDAlgorithm() {
00014 LogDebug("EcalGeom") << "DDEcalPreshowerAlgo info: Creating an instance" ;
00015
00016 }
00017
00018 void DDEcalPreshowerAlgo::initialize(const DDNumericArguments & nArgs,
00019 const DDVectorArguments & vArgs,
00020 const DDMapArguments & mArgs,
00021 const DDStringArguments & sArgs,
00022 const DDStringVectorArguments & vsArgs)
00023 {
00024
00025 LogDebug("EcalGeom") << "DDEcalPreshowerAlgo info: Initialize" ;
00026
00027 asym_ladd_ = vArgs["ASYMETRIC_LADDER"];
00028 types_l5_ = vsArgs["TYPES_OF_LADD_L5"];
00029 types_l4_ = vsArgs["TYPES_OF_LADD_L4"];
00030 ladd_l5_map_ = vArgs["LADD_L5_MAP"];
00031 ladd_l4_map_ = vArgs["LADD_L4_MAP"];
00032 noLaddInCol_ = vArgs["NUMB_OF_LADD_IN_COL"];
00033 startOfFirstLadd_ = vArgs["START_OF_1ST_LADD"];
00034 typeOfLaddRow0 = vsArgs["TYPE_OF_LADD_1"];
00035 typeOfLaddRow1 = vsArgs["TYPE_OF_LADD_2"];
00036 typeOfLaddRow2 = vsArgs["TYPE_OF_LADD_3"];
00037 typeOfLaddRow3 = vsArgs["TYPE_OF_LADD_4"];
00038 thickLayers_ = vArgs["Layers"];
00039 thickness_ = double(nArgs["PRESH_Z_TOTAL"]);
00040 materials_ = vsArgs["LayMat"];
00041 layName_ = vsArgs["LayName"];
00042 rmaxVec = vArgs["R_MAX"];
00043 rminVec = vArgs["R_MIN"];
00044 waf_intra_col_sep = double(nArgs["waf_intra_col_sep"]);
00045 waf_inter_col_sep = double(nArgs["waf_inter_col_sep"]);
00046 waf_active = double(nArgs["waf_active"]);
00047 wedge_length = double(nArgs["wedge_length"]);
00048 wedge_offset = double(nArgs["wedge_offset"]);
00049 zwedge_ceramic_diff = double(nArgs["zwedge_ceramic_diff"]);
00050 ywedge_ceramic_diff = double(nArgs["ywedge_ceramic_diff"]);
00051 ceramic_length = double(nArgs["ceramic_length"]);
00052 wedge_angle = double(nArgs["wedge_angle"]);
00053 wedge_back_thick = double(nArgs["wedge_back_thick"]);
00054 ladder_thick = double(nArgs["ladder_thick"]);
00055 ladder_width = double(nArgs["ladder_width"]);
00056 micromodule_length = double(nArgs["micromodule_length"]);
00057 box_thick = double(nArgs["box_thick"]);
00058 abs1stx = vArgs["1ST_ABSX"];
00059 abs1sty = vArgs["1ST_ABSY"];
00060 abs2ndx = vArgs["2ND_ABSX"];
00061 abs2ndy = vArgs["2ND_ABSY"];
00062 ladPfx_ = vsArgs["LadPrefix"];
00063 LaddMaterial_ = sArgs["LadderMaterial"];
00064 LdrFrnt_Length = double(nArgs["LdrFrnt_Length"]);
00065 LdrFrnt_Offset = double(nArgs["LdrFrnt_Offset"]);
00066 LdrBck_Length = double(nArgs["LdrBck_Length"]);
00067 LdrBck_Offset = double(nArgs["LdrBck_Offset"]);
00068 dee_separation = double(nArgs["dee_sep"]);
00069 In_rad_Abs_Al = double(nArgs["R_MIN_Abs_Al"]);
00070 In_rad_Abs_Pb = double(nArgs["R_MIN_Abs_Pb"]);
00071 rMax_Abs_Al_ = double(nArgs["R_MAX_Abs_Al"]);
00072 absAlX_X_ = double(nArgs["AbsAlX_X"]);
00073 absAlX_Y_ = double(nArgs["AbsAlX_Y"]);
00074 absAlX_subtr1_Xshift_ = double(nArgs["AbsAlX_subtr1_Xshift"]);
00075 absAlX_subtr1_Yshift_ = double(nArgs["AbsAlX_subtr1_Yshift"]);
00076 absAlY_X_ = double(nArgs["AbsAlY_X"]);
00077 absAlY_Y_ = double(nArgs["AbsAlY_Y"]);
00078 absAlY_subtr1_Xshift_ = double(nArgs["AbsAlY_subtr1_Xshift"]);
00079 absAlY_subtr1_Yshift_ = double(nArgs["AbsAlY_subtr1_Yshift"]);
00080
00081 }
00082
00083 void DDEcalPreshowerAlgo::execute()
00084 {
00085 LogDebug("EcalGeom") << "******** DDEcalPreshowerAlgo execute!";
00086
00087
00088 doLayers();
00089
00090 doLadders();
00091
00092 doSens();
00093
00094 }
00095
00096 void DDEcalPreshowerAlgo::doLayers()
00097 {
00098
00099 double zpos = -thickness_/2., sdx(0), sdy(0), bdx(0),bdy(0);;
00100
00101 for(size_t i = 0; i<thickLayers_.size(); ++i) {
00102
00103 int I = int(i)+1;
00104
00105 double rIn(0), rOut(0), zHalf(0);
00106
00107
00108 DDName ddname(getLayName(i),"esalgo");
00109
00110
00111 rIn = rminVec[i];
00112 rOut = rmaxVec[i];
00113 zHalf = thickLayers_[i]/2.;
00114
00115
00116 DDSolid solid = DDSolidFactory::tubs(ddname, zHalf, rIn, rOut, 0.,360.*deg);
00117
00118 DDLogicalPart layer = DDLogicalPart(ddname,getMaterial(i),solid);
00119
00120
00121 zpos += zHalf;
00122
00123
00124
00125 if (I==2 || I==28 || I==13 || I==23) {
00126 zpos += zHalf;
00127 continue;
00128 }
00129
00130 if ( I==12 ) {
00131 zlead1_ = zpos + zHalf;
00132 }
00133 if ( I==22 ) {
00134 zlead2_ = zpos + zHalf;
00135 }
00136
00137 if (I==10 || I==20) {
00138
00139 int absz=0; double outalbx, outalby, shiftR, outalbx2, outalby2, shiftR2;
00140
00141 absz = int(abs1stx.size());
00142 if ( I==20) absz = int(abs2ndx.size());
00143 int cutabsx=-1, cutabsy=-1;
00144
00145 DDName dd_Alname_f(getLayName(i)+"LOutAl","esalgo");
00146 DDName dd_Alname_g(getLayName(i)+"LOutAl2","esalgo");
00147 DDName dd_Alname_h(getLayName(i)+"LOutAltmp","esalgo");
00148 DDName dd_Alname_i(getLayName(i)+"LOutAltmp2","esalgo");
00149 DDName dd_Alname_j(getLayName(i)+"LOutAltmp3","esalgo");
00150
00151 DDSolid Out_Al = DDSolidFactory::tubs(dd_Alname_f,zHalf-0.1*mm,rMax_Abs_Al_-20*cm,rMax_Abs_Al_,0.,90.*deg);
00152 outalbx = absAlX_X_; outalby = rMax_Abs_Al_+0.1*mm-absAlX_subtr1_Yshift_; shiftR = absAlX_subtr1_Yshift_;
00153 if ( I==20) { outalbx = absAlY_X_; outalby = rMax_Abs_Al_+0.1*mm-absAlY_subtr1_Yshift_; shiftR = absAlY_subtr1_Xshift_; }
00154
00155 DDSolid OutAltmp = DDSolidFactory::box(dd_Alname_h,outalbx/2+0.1*mm,outalby/2+0.1*mm,zHalf);
00156 DDSolid Out_Altmp3 = DDSolidFactory::subtraction(dd_Alname_j,Out_Al,OutAltmp,DDTranslation(outalbx/2,outalby/2+shiftR,0),DDRotation());
00157
00158 outalby2 = absAlX_Y_; outalbx2 = rMax_Abs_Al_+0.1*mm-absAlX_subtr1_Xshift_; shiftR2 = absAlX_subtr1_Xshift_;
00159 if ( I==20) { outalby2 = absAlY_Y_; outalbx2 = rMax_Abs_Al_+0.1*mm-absAlY_subtr1_Xshift_; shiftR2 = absAlY_subtr1_Xshift_; }
00160 DDSolid OutAltmp2 = DDSolidFactory::box(dd_Alname_i,outalbx2/2+0.1*mm,outalby2/2+0.1*mm,zHalf);
00161 DDSolid Out_Al2 = DDSolidFactory::subtraction(dd_Alname_g,Out_Altmp3,OutAltmp2,DDTranslation(outalbx2/2+shiftR2,outalby2/2,0),DDRotation());
00162
00163 for (int L=0; L<absz; ++L) {
00164 int K=L;
00165 std::ostringstream tmp_name_b, tmp_name_b2, tmp_FAl_name_c, tmp_FAl_name_d;
00166 tmp_name_b << getLayName(i) << "L" << K;
00167 tmp_name_b2 << getLayName(i) << "Lb2" << K;
00168
00169 if(L==0) tmp_FAl_name_c << getLayName(i)<<"LOutAl2";
00170 if(L>0) tmp_FAl_name_c << getLayName(i) << "LtmpAl" << K-1;
00171
00172 tmp_FAl_name_d << getLayName(i) << "LtmpAl" << K;
00173
00174 DDName dd_tmp_name_b(tmp_name_b.str(),"esalgo");
00175 DDName dd_tmp_name_b2(tmp_name_b2.str(),"esalgo");
00176 DDName dd_FAl_name_c(tmp_FAl_name_c.str(),"esalgo");
00177 DDName dd_FAl_name_d(tmp_FAl_name_d.str(),"esalgo");
00178
00179 if(L==0) bdx = std::abs(abs1stx[K])/2;
00180 if(L>0) bdx = std::abs(abs1stx[K]-abs1stx[K-1])/2;
00181 bdy=abs1sty[K];
00182 if(abs1stx[K] < rIn+30*cm) { bdy=abs1sty[K]/2 - 30*cm; cutabsx = K;}
00183
00184 if(I==20) { if(L==0) bdx = std::abs(abs2ndx[K])/2;
00185 if(L>0) bdx = std::abs(abs2ndx[K]-abs2ndx[K-1])/2;
00186 bdy=abs2ndy[K];}
00187
00188 if((abs2ndx[K] < rIn+30*cm) && I==20) { bdy=abs2ndy[K]/2 - 30*cm; cutabsy = K;}
00189
00190 DDSolid solid_b = DDSolidFactory::box(dd_tmp_name_b,bdx,bdy,zHalf);
00191 DDSolid solid_b2 = DDSolidFactory::box(dd_tmp_name_b2,bdx+0.1*mm,bdy+0.1*mm,zHalf);
00192
00193 sdx = abs1stx[K]-bdx ; sdy = 0;
00194 if(abs1stx[K] < rIn+30*cm ) sdy = abs1sty[K]-bdy ;
00195
00196 if(I==20) {sdx = abs2ndx[K]-bdx ; sdy = 0;}
00197 if((abs2ndx[K] < rIn+30*cm) && I==20 ) sdy = abs2ndy[K]-bdy ;
00198
00199 DDLogicalPart layer = DDLogicalPart(dd_tmp_name_b,getMaterial(i),solid_b);
00200
00201 DDpos(layer, parent(), 1, DDTranslation(sdx,sdy, zpos), DDRotation());
00202 DDpos(layer, parent(), 2, DDTranslation(-sdx,sdy, zpos), DDRotation());
00203 DDSolid solid_c = DDSolid(dd_FAl_name_c);
00204 DDSolid solid_d = DDSolidFactory::subtraction(dd_FAl_name_d,solid_c,solid_b2,DDTranslation(sdx,sdy,0),DDRotation());
00205 if(((abs1stx[K] < rIn+30*cm) && I==10) || ((abs2ndx[K] < rIn+30*cm) && I==20) ) {
00206 DDpos(layer, parent(), 3, DDTranslation(sdx,-sdy, zpos), DDRotation());
00207 DDpos(layer, parent(), 4, DDTranslation(-sdx,-sdy, zpos), DDRotation());
00208 DDSolid solid_c = DDSolid(dd_FAl_name_c);
00209 DDSolid solid_d = DDSolidFactory::subtraction(dd_FAl_name_d,solid_c,solid_b2,DDTranslation(sdx,sdy,0),DDRotation());
00210 }
00211
00212
00213 }
00214
00215
00216
00217 DDName dd_tmp_name_b(getLayName(i)+"Lcut","esalgo");
00218 DDName dd_tmp_name_c(getLayName(i)+"tmpb","esalgo");
00219 DDName dd_tmp_name_d(getLayName(i)+"LinPb","esalgo");
00220
00221 DDName dd_tmp_name_e(getLayName(i)+"LinAl","esalgo");
00222 DDName dd_tmp_name_f(getLayName(i)+"LOutAl","esalgo");
00223
00224
00225 bdx = abs1stx[cutabsx]; bdy=2*30*cm;
00226 if(I==20) bdx = abs2ndx[cutabsy]; bdy=2*30*cm;
00227
00228 DDSolid solidcut = DDSolidFactory::box(dd_tmp_name_b,bdx,bdy,zHalf);
00229
00230 DDSolid iner = DDSolidFactory::tubs(dd_tmp_name_c,zHalf+0.1*mm,0,In_rad_Abs_Pb,0.,360.*deg);
00231
00232
00233 DDSolid final = DDSolidFactory::subtraction(dd_tmp_name_d,solidcut,iner,DDTranslation(0,0,0),DDRotation());
00234
00235
00236 DDLogicalPart layer = DDLogicalPart(dd_tmp_name_d,getMaterial(i),final);
00237 DDpos(layer, parent(), 1, DDTranslation(0,0, zpos), DDRotation());
00238
00239 DDSolid iner_Al = DDSolidFactory::tubs(dd_tmp_name_e,zHalf,In_rad_Abs_Al,In_rad_Abs_Pb-0.01*mm,0.,360.*deg);
00240 DDLogicalPart layerAl = DDLogicalPart(dd_tmp_name_e,getMaterial(i-1),iner_Al);
00241 DDpos(layerAl, parent(), 1, DDTranslation(0,0, zpos), DDRotation());
00242
00243 std::ostringstream tmp_Alname_fin;
00244 tmp_Alname_fin << getLayName(i) << "LtmpAl" << absz-1;
00245 DDName dd_Alname_fin(tmp_Alname_fin.str(),"esalgo");
00246
00247 DDSolid Outer_Al = DDSolid(dd_Alname_fin);
00248
00249 DDLogicalPart layerFinOutAl = DDLogicalPart(dd_tmp_name_f,getMaterial(i-1),Outer_Al);
00250
00251 DDpos(layerFinOutAl, parent(), 1, DDTranslation(0,0, zpos), DDRotation());
00252 DDpos(layerFinOutAl, parent(), 2, DDTranslation(0,0, zpos), DDRotation("esalgo:RABS90"));
00253 DDpos(layerFinOutAl, parent(), 3, DDTranslation(0,0, zpos), DDRotation("esalgo:RABS180B"));
00254 DDpos(layerFinOutAl, parent(), 4, DDTranslation(0,0, zpos), DDRotation("esalgo:R180"));
00255
00256
00257
00258 } else {
00259
00260 DDpos(layer, parent(), 1, DDTranslation(0.,0., zpos), DDRotation());
00261
00262 LogDebug("SFGeom")<<" debug : tubs, Logical part: "<<DDLogicalPart(ddname,getMaterial(i),solid)<<"\n translation "<<DDTranslation(0.,0.,zpos)<<" rotation "<<DDRotation()<< "\n";
00263 }
00264
00265 zpos += zHalf;
00266 }
00267
00268 }
00269
00270 void DDEcalPreshowerAlgo::doLadders() {
00271
00272 double xpos(0), ypos(0), zpos(0), sdx(0), sdy(0), sdz(0);
00273 double prev_length_(0), ladder_new_length_(0), ladd_shift_(0), ladder_length (0);
00274 int enb(0), swed_scopy_glob(0); double sdxe[50] = {0}, sdye[50] = {0}, sdze[50] = {0};
00275 double sdxe2[50] = {0}, sdye2[50] = {0}, sdze2[50] = {0}, sdxe3[50] = {0}, sdye3[50] = {0}, sdze3[50] = {0};
00276
00277 for (int M=0; M<int(types_l5_.size() + types_l4_.size()); M++) {
00278 int scopy(0); double boxax(0), boxay(0), boxaz(0);
00279 int ladd_not_plain(0), ladd_subtr_no(0), ladd_upper(0), ladd_side(0);
00280
00281 DDSolid solid_lfront = DDSolidFactory::trap(DDName("LDRFRNT","esalgo"),
00282 LdrFrnt_Length/2,
00283 -wedge_angle,
00284 0,
00285 ladder_width/2,
00286 (ladder_thick)/2,
00287 (ladder_thick)/2,
00288 0,
00289 ladder_width/2,
00290 (ladder_thick-ceramic_length*sin(wedge_angle*2))/2,
00291 (ladder_thick-ceramic_length*sin(wedge_angle*2))/2,
00292 0 );
00293
00294
00295 DDSolid solid_lbck = DDSolidFactory::trap(DDName("LDRBCK","esalgo"),
00296 LdrBck_Length/2,
00297 -wedge_angle,
00298 0,
00299 ladder_width/2,
00300 (box_thick/cos(wedge_angle*2)+0.02*mm)/2,
00301 (box_thick/cos(wedge_angle*2)+0.02*mm)/2,
00302 0,
00303 ladder_width/2,
00304 (ladder_thick-wedge_back_thick)/2,
00305 (ladder_thick-wedge_back_thick)/2,
00306 0 );
00307
00308 DDSolid solid_lfhalf = DDSolidFactory::trap(DDName("LDRFHALF","esalgo"),
00309 LdrFrnt_Length/2,
00310 -wedge_angle,
00311 0,
00312 (ladder_width/2)/2,
00313 (ladder_thick)/2,
00314 (ladder_thick)/2,
00315 0,
00316 (ladder_width/2)/2,
00317 (ladder_thick-ceramic_length*sin(wedge_angle*2))/2,
00318 (ladder_thick-ceramic_length*sin(wedge_angle*2))/2,
00319 0 );
00320
00321 DDSolid solid_lbhalf = DDSolidFactory::trap(DDName("LDRBHALF","esalgo"),
00322 LdrBck_Length/2,
00323 -wedge_angle,
00324 0,
00325 (ladder_width/2)/2,
00326 (box_thick/cos(wedge_angle*2)+0.02*mm)/2,
00327 (box_thick/cos(wedge_angle*2)+0.02*mm)/2,
00328 0,
00329 (ladder_width/2)/2,
00330 (ladder_thick-wedge_back_thick)/2,
00331 (ladder_thick-wedge_back_thick)/2,
00332 0 );
00333
00334 DDSolid solid_lfhtrunc = DDSolidFactory::trap(DDName("LDRFHTR","esalgo"),
00335 (LdrFrnt_Length-waf_active)/2,
00336 -wedge_angle,
00337 0,
00338 (ladder_width/2)/2,
00339 (ladder_thick)/2,
00340 (ladder_thick)/2,
00341 0,
00342 (ladder_width/2)/2,
00343 (ladder_thick-(ceramic_length-waf_active)*sin(wedge_angle*2))/2,
00344 (ladder_thick-(ceramic_length-waf_active)*sin(wedge_angle*2))/2,
00345 0 );
00346
00347
00348
00349 if(M<int(types_l5_.size())) {
00350
00351
00352 for (int i=0; i<=1; i++) {
00353 for (int j=0; j<=3; j++) {
00354 if(ladd_l5_map_[(i+j*2+M*10)]!=1){
00355 ladd_not_plain=1; ladd_subtr_no++; if(j>1) ladd_upper=1; ladd_side=i;
00356 }
00357 }
00358 }
00359
00360 DDName ddname(getLadPrefix(0)+types_l5_[M],"esalgo");
00361 ladder_length = micromodule_length + 4*waf_active + 0.1*mm;
00362
00363
00364 if(ladd_not_plain) {
00365
00366 std::ostringstream tmp_name_5b, tmp_name_5c, tmp_name_5d;
00367 if(ladd_upper) {
00368
00369
00370 }
00371 else {
00372 enb++;
00373 std::ostringstream tmp_name_5b, tmp_name_5c, tmp_name_5d;
00374 DDName dd_tmp_name_5a(getLadPrefix(2),"esalgo");
00375 tmp_name_5b <<getLadPrefix(3)<< enb;
00376 DDName dd_tmp_name_5b(tmp_name_5b.str(),"esalgo");
00377 tmp_name_5c <<getLadPrefix(4)<< enb;
00378 DDName dd_tmp_name_5c(tmp_name_5c.str(),"esalgo");
00379 tmp_name_5d << getLadPrefix(5) << enb;
00380 DDName dd_tmp_name_5d(tmp_name_5d.str(),"esalgo");
00381
00382 DDName dd_tmp_name_5e(getLadPrefix(6),"esalgo");
00383
00384 boxay = ladder_length-LdrFrnt_Length-LdrBck_Length; boxax = ladder_width; boxaz = ladder_thick;
00385
00386 DDSolid solid_5a = DDSolidFactory::box(dd_tmp_name_5a,boxax/2,boxay/2,boxaz/2.);
00387 if(ladd_side==0) sdxe[enb] = ladder_width/4; sdye[enb]= -boxay/2 - LdrFrnt_Length/2; sdze[enb] = -ladder_thick/2. + LdrFrnt_Offset;
00388 if(ladd_side==1) sdxe[enb] = -ladder_width/4;
00389
00390 DDSolid solid_5b = DDSolidFactory::unionSolid(dd_tmp_name_5b,solid_5a,solid_lfhalf,DDTranslation(sdxe[enb],sdye[enb],sdze[enb]),DDRotation("esalgo:RM1299"));
00391
00392 if(ladd_side==0) sdxe2[enb] = -ladder_width/4; sdye2[enb]= -boxay/2 - LdrFrnt_Length/2 + waf_active/2;
00393 sdze2[enb] = -ladder_thick/2. + LdrFrnt_Offset + (waf_active*sin(wedge_angle*2))/4;
00394 if(ladd_side==1) sdxe2[enb] = ladder_width/4;
00395
00396 DDSolid solid_5c = DDSolidFactory::unionSolid(dd_tmp_name_5c,solid_5b,solid_lfhtrunc,DDTranslation(sdxe2[enb],sdye2[enb],sdze2[enb]),DDRotation("esalgo:RM1299"));
00397
00398 sdxe3[enb] = 0; sdye3[enb] = boxay/2 + LdrBck_Length/2; sdze3[enb] = -ladder_thick/2. + LdrBck_Offset;
00399 DDSolid solid = DDSolidFactory::unionSolid(ddname,solid_5c,solid_lbck,DDTranslation(sdxe3[enb],sdye3[enb],sdze3[enb]),DDRotation("esalgo:RM1299"));
00400
00401 DDLogicalPart ladder = DDLogicalPart(ddname,getLaddMaterial(),solid);
00402 DDName ddname2(getLadPrefix(1)+types_l5_[M],"esalgo");
00403 DDLogicalPart ladder2 = DDLogicalPart(ddname2,getLaddMaterial(),solid);
00404
00405 }
00406
00407 }
00408 else {
00409
00410
00411
00412 DDName dd_tmp_name_5pa(getLadPrefix(2)+"5p","esalgo");
00413 DDName dd_tmp_name_5pb(getLadPrefix(3)+"5p","esalgo");
00414
00415 boxay = ladder_length-LdrFrnt_Length-LdrBck_Length; boxax = ladder_width; boxaz = ladder_thick;
00416
00417 DDSolid solid_5pa = DDSolidFactory::box(dd_tmp_name_5pa,boxax/2,boxay/2,boxaz/2.);
00418 sdx = 0; sdy= -boxay/2 - LdrFrnt_Length/2; sdz = -ladder_thick/2. + LdrFrnt_Offset;
00419
00420 DDSolid solid_5pb = DDSolidFactory::unionSolid(dd_tmp_name_5pb,solid_5pa,solid_lfront,DDTranslation(sdx,sdy,sdz),DDRotation("esalgo:RM1299"));
00421
00422 sdx = 0; sdy= boxay/2 + LdrBck_Length/2; sdz = -ladder_thick/2. + LdrBck_Offset;
00423
00424 DDSolid solid = DDSolidFactory::unionSolid(ddname,solid_5pb,solid_lbck,DDTranslation(sdx,sdy,sdz),DDRotation("esalgo:RM1299"));
00425
00426 DDLogicalPart ladder = DDLogicalPart(ddname,getLaddMaterial(),solid);
00427 DDName ddname2(getLadPrefix(1)+types_l5_[M],"esalgo");
00428 DDLogicalPart ladder2 = DDLogicalPart(ddname2,getLaddMaterial(),solid);
00429
00430 }
00431 }
00432
00433
00434
00435 if( M >= int(types_l5_.size()) ) {
00436 int d = M - types_l5_.size();
00437
00438 for (int i=0; i<=1; i++) {
00439 for (int j=0; j<=3; j++) {
00440 if(ladd_l4_map_[(i+j*2+(M-types_l5_.size())*8)]!=1 ){
00441 ladd_not_plain=1; ladd_subtr_no++; if(j>1) ladd_upper=1; ladd_side=i;
00442 }
00443 }
00444 }
00445
00446 DDName ddname(getLadPrefix(0)+types_l4_[d],"esalgo");
00447 ladder_length = micromodule_length + 3*waf_active + 0.1*mm;
00448
00449 if(ladd_not_plain) {
00450 std::ostringstream tmp_name_b, tmp_name_c, tmp_name_d;
00451 if(ladd_upper) {
00452 enb++;
00453
00454 DDName dd_tmp_name_a(getLadPrefix(7),"esalgo");
00455 tmp_name_b <<getLadPrefix(8)<< enb;
00456 DDName dd_tmp_name_b(tmp_name_b.str(),"esalgo");
00457 tmp_name_c <<getLadPrefix(9)<< enb;
00458 DDName dd_tmp_name_c(tmp_name_c.str(),"esalgo");
00459 tmp_name_d << getLadPrefix(10) << enb;
00460 DDName dd_tmp_name_d(tmp_name_d.str(),"esalgo");
00461 DDName dd_tmp_name_e(getLadPrefix(11),"esalgo");
00462
00463 boxay = ladder_length-LdrFrnt_Length-LdrBck_Length; boxax = ladder_width; boxaz = ladder_thick;
00464 DDSolid solid_a = DDSolidFactory::box(dd_tmp_name_a,boxax/2,boxay/2,boxaz/2.);
00465
00466 sdxe[enb] = 0; sdye[enb]= -boxay/2 - LdrFrnt_Length/2; sdze[enb] = -ladder_thick/2. + LdrFrnt_Offset;
00467 DDSolid solid_b = DDSolidFactory::unionSolid(dd_tmp_name_b,solid_a,solid_lfront,DDTranslation(sdxe[enb],sdye[enb],sdze[enb]),DDRotation("esalgo:RM1299"));
00468
00469 if(ladd_side==0) sdxe2[enb] = ladder_width/4; sdye2[enb] = boxay/2 + LdrBck_Length/2; sdze2[enb] = -ladder_thick/2. + LdrBck_Offset;
00470 if(ladd_side==1) sdxe2[enb] = -ladder_width/4;
00471 DDSolid solid = DDSolidFactory::unionSolid(ddname,solid_b,solid_lbhalf,DDTranslation(sdxe2[enb],sdye2[enb],sdze2[enb]),DDRotation("esalgo:RM1299"));
00472
00473 DDLogicalPart ladder = DDLogicalPart(ddname,getLaddMaterial(),solid);
00474 DDName ddname2(getLadPrefix(1)+types_l4_[d],"esalgo");
00475 DDLogicalPart ladder2 = DDLogicalPart(ddname2,getLaddMaterial(),solid);
00476
00477 }
00478 else {
00479 if(ladd_subtr_no>1) {
00480 enb++;
00481
00482 DDName dd_tmp_name_a(getLadPrefix(7),"esalgo");
00483 tmp_name_b <<getLadPrefix(8)<< enb;
00484 DDName dd_tmp_name_b(tmp_name_b.str(),"esalgo");
00485 tmp_name_c <<getLadPrefix(9)<< enb;
00486 DDName dd_tmp_name_c(tmp_name_c.str(),"esalgo");
00487 tmp_name_d << getLadPrefix(10) << enb;
00488 DDName dd_tmp_name_d(tmp_name_d.str(),"esalgo");
00489 DDName dd_tmp_name_e(getLadPrefix(11),"esalgo");
00490
00491 boxay = ladder_length-LdrFrnt_Length-LdrBck_Length; boxax = ladder_width; boxaz = ladder_thick;
00492
00493 DDSolid solid_a = DDSolidFactory::box(dd_tmp_name_a,boxax/2,boxay/2,boxaz/2.);
00494 if(ladd_side==0) sdxe[enb] = ladder_width/4; sdye[enb]= -boxay/2 - LdrFrnt_Length/2; sdze[enb] = -ladder_thick/2. + LdrFrnt_Offset;
00495 if(ladd_side==1) sdxe[enb] = -ladder_width/4;
00496
00497 DDSolid solid_b = DDSolidFactory::unionSolid(dd_tmp_name_b,solid_a,solid_lfhalf,DDTranslation(sdxe[enb],sdye[enb],sdze[enb]),DDRotation("esalgo:RM1299"));
00498
00499 sdxe2[enb] = 0; sdye2[enb] = boxay/2 + LdrBck_Length/2; sdze2[enb] = -ladder_thick/2. + LdrBck_Offset;
00500
00501 DDSolid solid = DDSolidFactory::unionSolid(ddname,solid_b,solid_lbck,DDTranslation(sdxe2[enb],sdye2[enb],sdze2[enb]),DDRotation("esalgo:RM1299"));
00502
00503 DDLogicalPart ladder = DDLogicalPart(ddname,getLaddMaterial(),solid);
00504 DDName ddname2(getLadPrefix(1)+types_l4_[d],"esalgo");
00505 DDLogicalPart ladder2 = DDLogicalPart(ddname2,getLaddMaterial(),solid);
00506 } else {
00507 enb++;
00508 DDName dd_tmp_name_a(getLadPrefix(7),"esalgo");
00509 tmp_name_b <<getLadPrefix(8)<< enb;
00510 DDName dd_tmp_name_b(tmp_name_b.str(),"esalgo");
00511 tmp_name_c <<getLadPrefix(9)<< enb;
00512 DDName dd_tmp_name_c(tmp_name_c.str(),"esalgo");
00513 tmp_name_d << getLadPrefix(10) << enb;
00514 DDName dd_tmp_name_d(tmp_name_d.str(),"esalgo");
00515 DDName dd_tmp_name_e(getLadPrefix(11),"esalgo");
00516
00517 boxay = ladder_length-LdrFrnt_Length-LdrBck_Length; boxax = ladder_width; boxaz = ladder_thick;
00518 DDSolid solid_a = DDSolidFactory::box(dd_tmp_name_a,boxax/2,boxay/2,boxaz/2.);
00519 if(ladd_side==0) sdxe[enb] = ladder_width/4; sdye[enb]= -boxay/2 - LdrFrnt_Length/2; sdze[enb] = -ladder_thick/2. + LdrFrnt_Offset;
00520 if(ladd_side==1) sdxe[enb] = -ladder_width/4;
00521
00522 DDSolid solid_b = DDSolidFactory::unionSolid(dd_tmp_name_b,solid_a,solid_lfhalf,DDTranslation(sdxe[enb],sdye[enb],sdze[enb]),DDRotation("esalgo:RM1299"));
00523
00524 if(ladd_side==0) sdxe2[enb] = -ladder_width/4; sdye2[enb]= -boxay/2 - LdrFrnt_Length/2 + waf_active/2;
00525 sdze2[enb] = -ladder_thick/2. + LdrFrnt_Offset + (waf_active*sin(wedge_angle*2))/4;
00526 if(ladd_side==1) sdxe2[enb] = ladder_width/4;
00527
00528 DDSolid solid_c = DDSolidFactory::unionSolid(dd_tmp_name_c,solid_b,solid_lfhtrunc,DDTranslation(sdxe2[enb],sdye2[enb],sdze2[enb]),DDRotation("esalgo:RM1299"));
00529
00530 sdxe3[enb] = 0; sdye3[enb] = boxay/2 + LdrBck_Length/2; sdze3[enb] = -ladder_thick/2. + LdrBck_Offset;
00531 DDSolid solid = DDSolidFactory::unionSolid(ddname,solid_c,solid_lbck,DDTranslation(sdxe3[enb],sdye3[enb],sdze3[enb]),DDRotation("esalgo:RM1299"));
00532
00533 DDLogicalPart ladder = DDLogicalPart(ddname,getLaddMaterial(),solid);
00534 DDName ddname2(getLadPrefix(1)+types_l4_[d],"esalgo");
00535 DDLogicalPart ladder2 = DDLogicalPart(ddname2,getLaddMaterial(),solid);
00536
00537 }
00538 }
00539
00540 }
00541 else {
00542 DDName dd_tmp_name_pa(getLadPrefix(2)+"p","esalgo");
00543 DDName dd_tmp_name_pb(getLadPrefix(3)+"p","esalgo");
00544
00545 boxay = ladder_length-LdrFrnt_Length-LdrBck_Length; boxax = ladder_width; boxaz = ladder_thick;
00546
00547 DDSolid solid_pa = DDSolidFactory::box(dd_tmp_name_pa,boxax/2,boxay/2,boxaz/2.);
00548 sdx = 0; sdy= -boxay/2 - LdrFrnt_Length/2; sdz = -ladder_thick/2. + LdrFrnt_Offset;
00549
00550 DDSolid solid_pb = DDSolidFactory::unionSolid(dd_tmp_name_pb,solid_pa,solid_lfront,DDTranslation(sdx,sdy,sdz),DDRotation("esalgo:RM1299"));
00551
00552 sdx = 0; sdy= boxay/2 + LdrBck_Length/2; sdz = -ladder_thick/2. + LdrBck_Offset;
00553 DDSolid solid = DDSolidFactory::unionSolid(ddname,solid_pb,solid_lbck,DDTranslation(sdx,sdy,sdz),DDRotation("esalgo:RM1299"));
00554 DDLogicalPart ladder = DDLogicalPart(ddname,getLaddMaterial(),solid);
00555 DDName ddname2(getLadPrefix(1)+types_l4_[d],"esalgo");
00556 DDLogicalPart ladder2 = DDLogicalPart(ddname2,getLaddMaterial(),solid);
00557 }
00558 }
00559
00560
00561 swed_scopy_glob++;
00562 if(M<int(types_l5_.size())) {
00563 DDName ddname(getLadPrefix(0)+types_l5_[M],"esalgo");
00564 DDName ddname2(getLadPrefix(1)+types_l5_[M],"esalgo");
00565 for (int i=0; i<=1; i++) {
00566 for (int j=0; j<=4; j++) {
00567 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;
00568 zpos = -ladder_thick/2. + 0.005*mm + wedge_offset;
00569 if(ladd_l5_map_[(i+j*2+M*10)]==1) {
00570 scopy ++;
00571 DDpos(DDLogicalPart("esalgo:SWED"), ddname, scopy+1000*swed_scopy_glob, DDTranslation(xpos,ypos,zpos), DDRotation("esalgo:RM1299"));
00572 DDpos(DDLogicalPart("esalgo:SWED"), ddname2, scopy+1000*swed_scopy_glob+100, DDTranslation(xpos,ypos,zpos), DDRotation("esalgo:RM1299"));
00573
00574 ypos = ypos + ywedge_ceramic_diff; zpos = -ladder_thick/2. + 0.005*mm + zwedge_ceramic_diff;
00575 DDpos(DDLogicalPart("esalgo:SFBX"), ddname, scopy+1000*swed_scopy_glob, DDTranslation(xpos,ypos,zpos), DDRotation("esalgo:RM1298"));
00576 DDpos(DDLogicalPart("esalgo:SFBY"), ddname2, scopy+1000*swed_scopy_glob, DDTranslation(xpos,ypos,zpos), DDRotation("esalgo:RM1300A"));
00577 }
00578 }
00579 }
00580 }
00581 else
00582 {
00583 int d = M - types_l5_.size();
00584 DDName ddname(getLadPrefix(0)+types_l4_[d],"esalgo");
00585 DDName ddname2(getLadPrefix(1)+types_l4_[d],"esalgo");
00586 for (int i=0; i<=1; i++) {
00587 for (int j=0; j<=3; j++) {
00588 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;
00589 zpos = -ladder_thick/2. + 0.005*mm + wedge_offset;
00590 if(ladd_l4_map_[(i+j*2+(M-types_l5_.size())*8)]==1) {
00591 scopy ++;
00592 DDpos(DDLogicalPart("esalgo:SWED"), ddname, scopy+1000*swed_scopy_glob, DDTranslation(xpos,ypos,zpos), DDRotation("esalgo:RM1299"));
00593 DDpos(DDLogicalPart("esalgo:SWED"), ddname2, scopy+1000*swed_scopy_glob+100, DDTranslation(xpos,ypos,zpos), DDRotation("esalgo:RM1299"));
00594
00595 ypos = ypos + ywedge_ceramic_diff; zpos = -ladder_thick/2. + 0.005*mm + zwedge_ceramic_diff;
00596 DDpos(DDLogicalPart("esalgo:SFBX"), ddname, scopy+1000*swed_scopy_glob, DDTranslation(xpos,ypos,zpos), DDRotation("esalgo:RM1298"));
00597 DDpos(DDLogicalPart("esalgo:SFBY"), ddname2, scopy+1000*swed_scopy_glob, DDTranslation(xpos,ypos,zpos), DDRotation("esalgo:RM1300A"));
00598 }
00599 }
00600 }
00601 }
00602 }
00603
00604
00605
00606 std::string type;
00607 int icopy[100] = {0};
00608
00609 for(int I=-9; I<=9;++I) {
00610 prev_length_=0; int J=std::abs(I);
00611 for (int K=0; K<noLaddInCol_[J]; K++) {
00612 std::string type;
00613
00614 ladder_new_length_ = micromodule_length + 3*waf_active;
00615 ladd_shift_ = 4*waf_active;
00616
00617 if(K==0) type = typeOfLaddRow0[J];
00618 if(K==1) type = typeOfLaddRow1[J];
00619 if(K==2) type = typeOfLaddRow2[J];
00620 if(K==3) type = typeOfLaddRow3[J];
00621
00622 for(int i=0;i<int(types_l5_.size());i++) if(type == types_l5_[i]) {
00623 ladder_new_length_ = micromodule_length + 4*waf_active;
00624 ladd_shift_ = 5*waf_active;}
00625
00626 int j = 0;
00627
00628 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];}}
00629 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()];}}
00630
00631 xpos = I*(2*waf_intra_col_sep + waf_inter_col_sep);
00632 if(I>0) xpos = xpos + dee_separation;
00633 if(I<0) xpos = xpos - dee_separation;
00634
00635 int sz = 20;
00636 ypos = (sz-int(startOfFirstLadd_[J]))*waf_active - ladder_new_length_/2. + (LdrFrnt_Length-LdrBck_Length)/2 + micromodule_length + 0.05*cm - prev_length_;
00637
00638 prev_length_ += ladd_shift_;
00639
00640 zpos = zlead1_ + ladder_thick/2. + 0.01*mm;
00641 icopy[j] +=1;
00642 DDName ddname(getLadPrefix(0)+type,"esalgo");
00643
00644 DDpos(DDLogicalPart(ddname), DDName("SF","esalgo"), icopy[j], DDTranslation(xpos,ypos,zpos), DDRotation());
00645
00646 DDName ddname2(getLadPrefix(1)+type,"esalgo");
00647
00648 xpos = I*(2*waf_intra_col_sep + waf_inter_col_sep);
00649
00650 DDpos(DDLogicalPart(ddname2), DDName("SF","esalgo"), icopy[j], DDTranslation(ypos,-xpos,zpos-zlead1_+zlead2_), DDRotation("esalgo:R270"));
00651
00652 int changed = 0;
00653 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];}
00654 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()]; }
00655
00656 icopy[j] +=1;
00657
00658 if(I>0) xpos = xpos + dee_separation;
00659 if(I<0) xpos = xpos - dee_separation;
00660
00661 DDName ddname3(getLadPrefix(0)+type,"esalgo");
00662 DDpos(DDLogicalPart(ddname3), DDName("SF","esalgo"), icopy[j], DDTranslation(xpos,-ypos,zpos), DDRotation("esalgo:R180"));
00663
00664 DDName ddname4(getLadPrefix(1)+type,"esalgo");
00665
00666 xpos = I*(2*waf_intra_col_sep + waf_inter_col_sep);
00667
00668 DDpos(DDLogicalPart(ddname4), DDName("SF","esalgo"), icopy[j], DDTranslation(-ypos,-xpos,zpos-zlead1_+zlead2_), DDRotation("esalgo:R090"));
00669
00670 }
00671 }
00672 }
00673
00674 void DDEcalPreshowerAlgo::doSens() {
00675
00676 double xpos(0), ypos(0);
00677 for(size_t i = 0; i<32; ++i)
00678 {
00679 xpos = -waf_active/2. + i*waf_active/32. + waf_active/64.;
00680 DDpos(DDLogicalPart("esalgo:SFSX"), DDName("SFWX","esalgo"), i+1, DDTranslation(xpos,0., 0.),DDRotation());
00681
00682 LogDebug("SFGeom")<<" debug : SFSX, Logical part: "<<DDLogicalPart("esalgo:SFSX")<<"\n translation "<<DDTranslation(xpos,0.,0.)<<" rotation "<<DDRotation()<<" copy number= " <<i<<"\n";
00683
00684 ypos = -waf_active/2. + i*waf_active/32. + waf_active/64.;
00685 DDpos(DDLogicalPart("esalgo:SFSY"),DDName("SFWY","esalgo"), i+1, DDTranslation(0.,ypos, 0.), DDRotation());
00686
00687 LogDebug("SFGeom")<<" debug : SFSY, Logical part: "<<DDLogicalPart("esalgo:SFSY")<<"\n translation "<<DDTranslation(0.,ypos,0.)<<" rotation "<<DDRotation()<< " copy number= " <<i<< "\n";
00688
00689 }
00690 }