Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-03-08 05:28:57

0001 #include <cmath>
0002 #include <algorithm>
0003 
0004 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0005 #include "DetectorDescription/Core/interface/DDTypes.h"
0006 #include "DetectorDescription/Core/interface/DDLogicalPart.h"
0007 #include "DetectorDescription/Core/interface/DDSolid.h"
0008 #include "CLHEP/Units/GlobalSystemOfUnits.h"
0009 #include <vector>
0010 #include <string>
0011 
0012 #include "DetectorDescription/Core/interface/DDAlgorithm.h"
0013 #include "DetectorDescription/Core/interface/DDMaterial.h"
0014 
0015 //#define EDM_ML_DEBUG
0016 
0017 class DDEcalPreshowerAlgo : public DDAlgorithm {
0018 public:
0019   DDMaterial getMaterial(unsigned int i) const { return DDMaterial(materials_[i]); }
0020   DDMaterial getLaddMaterial() const { return DDMaterial(LaddMaterial_); }
0021   std::string getLayName(unsigned int i) const { return layName_[i]; }
0022   std::string getLadPrefix(unsigned int i) const { return ladPfx_[i]; }
0023 
0024   DDEcalPreshowerAlgo();
0025   void initialize(const DDNumericArguments& nArgs,
0026                   const DDVectorArguments& vArgs,
0027                   const DDMapArguments& mArgs,
0028                   const DDStringArguments& sArgs,
0029                   const DDStringVectorArguments& vsArgs) override;
0030   void execute(DDCompactView& pos) override;
0031 
0032 private:
0033   void doLayers(DDCompactView& pos);
0034   void doLadders(DDCompactView& pos);
0035   void doSens(DDCompactView& pos);
0036 
0037   int nmat_;                            // number of preshower layers
0038   double thickness_;                    // overall thickness of the preshower envelope
0039   std::vector<std::string> materials_;  // materials of the presh-layers
0040   std::vector<std::string> layName_;    // names of the presh-layers
0041   std::vector<std::string> ladPfx_;     // name prefix for ladders
0042   std::string LaddMaterial_;            // ladd material - air
0043   std::vector<double> thickLayers_;
0044   std::vector<double> abs1stx;
0045   std::vector<double> abs1sty;
0046   std::vector<double> abs2ndx;
0047   std::vector<double> abs2ndy;
0048   std::vector<double> asym_ladd_;
0049   std::vector<double> rminVec;
0050   std::vector<double> rmaxVec;
0051   std::vector<double> noLaddInCol_;
0052   std::vector<double> startOfFirstLadd_;
0053   std::vector<std::string> types_l5_;
0054   std::vector<std::string> types_l4_;
0055   std::vector<double> ladd_l5_map_;
0056   std::vector<double> ladd_l4_map_;
0057   std::vector<std::string> typeOfLaddRow0;
0058   std::vector<std::string> typeOfLaddRow1;
0059   std::vector<std::string> typeOfLaddRow2;
0060   std::vector<std::string> typeOfLaddRow3;
0061 
0062   double zlead1_, zlead2_, zfoam1_, zfoam2_;
0063   double waf_intra_col_sep, waf_inter_col_sep, waf_active, wedge_length, wedge_offset, zwedge_ceramic_diff,
0064       ywedge_ceramic_diff, wedge_angle, box_thick, dee_separation, In_rad_Abs_Al, In_rad_Abs_Pb;
0065   double ladder_thick, yladder_1stwedge_diff, ladder_width, ladder_length, micromodule_length;
0066   double absAlX_X_, absAlX_Y_, absAlX_subtr1_Xshift_, absAlX_subtr1_Yshift_, rMax_Abs_Al_;
0067   double absAlY_X_, absAlY_Y_, absAlY_subtr1_Xshift_, absAlY_subtr1_Yshift_;
0068   double LdrBck_Length, LdrFrnt_Length, LdrFrnt_Offset, LdrBck_Offset, ceramic_length, wedge_back_thick;
0069 };
0070 
0071 DDEcalPreshowerAlgo::DDEcalPreshowerAlgo() : DDAlgorithm() {
0072 #ifdef EDM_ML_DEBUG
0073   edm::LogVerbatim("EcalGeom") << "DDEcalPreshowerAlgo info: Creating an instance";
0074 #endif
0075 }
0076 
0077 void DDEcalPreshowerAlgo::initialize(const DDNumericArguments& nArgs,
0078                                      const DDVectorArguments& vArgs,
0079                                      const DDMapArguments& mArgs,
0080                                      const DDStringArguments& sArgs,
0081                                      const DDStringVectorArguments& vsArgs) {
0082   edm::LogVerbatim("EcalGeom") << "DDEcalPreshowerAlgo info: Initialize";
0083 
0084   asym_ladd_ = vArgs["ASYMETRIC_LADDER"];
0085   types_l5_ = vsArgs["TYPES_OF_LADD_L5"];
0086   types_l4_ = vsArgs["TYPES_OF_LADD_L4"];
0087   ladd_l5_map_ = vArgs["LADD_L5_MAP"];
0088   ladd_l4_map_ = vArgs["LADD_L4_MAP"];
0089   noLaddInCol_ = vArgs["NUMB_OF_LADD_IN_COL"];
0090   startOfFirstLadd_ = vArgs["START_OF_1ST_LADD"];
0091   typeOfLaddRow0 = vsArgs["TYPE_OF_LADD_1"];
0092   typeOfLaddRow1 = vsArgs["TYPE_OF_LADD_2"];
0093   typeOfLaddRow2 = vsArgs["TYPE_OF_LADD_3"];
0094   typeOfLaddRow3 = vsArgs["TYPE_OF_LADD_4"];
0095   thickLayers_ = vArgs["Layers"];
0096   thickness_ = double(nArgs["PRESH_Z_TOTAL"]);
0097   materials_ = vsArgs["LayMat"];
0098   layName_ = vsArgs["LayName"];
0099   rmaxVec = vArgs["R_MAX"];  // inner radii
0100   rminVec = vArgs["R_MIN"];  // outer radii
0101   waf_intra_col_sep = double(nArgs["waf_intra_col_sep"]);
0102   waf_inter_col_sep = double(nArgs["waf_inter_col_sep"]);
0103   waf_active = double(nArgs["waf_active"]);
0104   wedge_length = double(nArgs["wedge_length"]);
0105   wedge_offset = double(nArgs["wedge_offset"]);
0106   zwedge_ceramic_diff = double(nArgs["zwedge_ceramic_diff"]);
0107   ywedge_ceramic_diff = double(nArgs["ywedge_ceramic_diff"]);
0108   ceramic_length = double(nArgs["ceramic_length"]);
0109   wedge_angle = double(nArgs["wedge_angle"]);
0110   wedge_back_thick = double(nArgs["wedge_back_thick"]);
0111   ladder_thick = double(nArgs["ladder_thick"]);
0112   ladder_width = double(nArgs["ladder_width"]);
0113   micromodule_length = double(nArgs["micromodule_length"]);
0114   box_thick = double(nArgs["box_thick"]);
0115   abs1stx = vArgs["1ST_ABSX"];
0116   abs1sty = vArgs["1ST_ABSY"];
0117   abs2ndx = vArgs["2ND_ABSX"];
0118   abs2ndy = vArgs["2ND_ABSY"];
0119   ladPfx_ = vsArgs["LadPrefix"];
0120   LaddMaterial_ = sArgs["LadderMaterial"];
0121   LdrFrnt_Length = double(nArgs["LdrFrnt_Length"]);
0122   LdrFrnt_Offset = double(nArgs["LdrFrnt_Offset"]);
0123   LdrBck_Length = double(nArgs["LdrBck_Length"]);
0124   LdrBck_Offset = double(nArgs["LdrBck_Offset"]);
0125   dee_separation = double(nArgs["dee_sep"]);
0126   In_rad_Abs_Al = double(nArgs["R_MIN_Abs_Al"]);
0127   In_rad_Abs_Pb = double(nArgs["R_MIN_Abs_Pb"]);
0128   rMax_Abs_Al_ = double(nArgs["R_MAX_Abs_Al"]);
0129   absAlX_X_ = double(nArgs["AbsAlX_X"]);
0130   absAlX_Y_ = double(nArgs["AbsAlX_Y"]);
0131   absAlX_subtr1_Xshift_ = double(nArgs["AbsAlX_subtr1_Xshift"]);
0132   absAlX_subtr1_Yshift_ = double(nArgs["AbsAlX_subtr1_Yshift"]);
0133   absAlY_X_ = double(nArgs["AbsAlY_X"]);
0134   absAlY_Y_ = double(nArgs["AbsAlY_Y"]);
0135   absAlY_subtr1_Xshift_ = double(nArgs["AbsAlY_subtr1_Xshift"]);
0136   absAlY_subtr1_Yshift_ = double(nArgs["AbsAlY_subtr1_Yshift"]);
0137 }
0138 
0139 void DDEcalPreshowerAlgo::execute(DDCompactView& cpv) {
0140 #ifdef EDM_ML_DEBUG
0141   edm::LogVerbatim("EcalGeom") << "******** DDEcalPreshowerAlgo execute!";
0142 #endif
0143   // creates all the tube-like layers of the preshower
0144   doLayers(cpv);
0145   // creates and places the ladders
0146   doLadders(cpv);
0147   // places the slicon strips in active silicon wafers
0148   doSens(cpv);
0149 }
0150 
0151 void DDEcalPreshowerAlgo::doLayers(DDCompactView& cpv) {
0152   double zpos = -thickness_ / 2., sdx(0), sdy(0), bdx(0), bdy(0);
0153 
0154   for (size_t i = 0; i < thickLayers_.size(); ++i) {
0155     int I = int(i) + 1;  // FOTRAN I (offset +1)
0156 
0157     double rIn(0), rOut(0), zHalf(0);
0158 
0159     // create the name
0160     DDName ddname(getLayName(i), "esalgo");  // namespace:name
0161 
0162     // cone dimensions
0163     rIn = rminVec[i];
0164     rOut = rmaxVec[i];
0165     zHalf = thickLayers_[i] / 2.;
0166 
0167     // create a logical part representing a single layer in the preshower
0168     DDSolid solid = DDSolidFactory::tubs(ddname, zHalf, rIn, rOut, 0., 360. * deg);
0169 #ifdef EDM_ML_DEBUG
0170     edm::LogVerbatim("SFGeomX") << ddname << " Tubs " << zHalf << ":" << rIn << ":" << rOut << ":0:360";
0171 #endif
0172     DDLogicalPart layer = DDLogicalPart(ddname, getMaterial(i), solid);
0173 
0174     // position the logical part w.r.t. the parent volume
0175     zpos += zHalf;
0176 
0177     // create a logical part representing a single layer in the preshower
0178     // skip layers with detectors, front and rear window
0179     if (I == 2 || I == 28 || I == 13 || I == 23) {
0180       zpos += zHalf;
0181       continue;
0182     }
0183 
0184     if (I == 12) {
0185       zlead1_ = zpos + zHalf;
0186     }
0187     if (I == 22) {
0188       zlead2_ = zpos + zHalf;
0189     }
0190 
0191     if (I == 10 || I == 20) {  // New lead shape
0192 
0193       int absz = 0;
0194       double outalbx, outalby, shiftR, outalbx2, outalby2, shiftR2;
0195 
0196       absz = int(abs1stx.size());
0197       if (I == 20)
0198         absz = int(abs2ndx.size());
0199       int cutabsx = -1, cutabsy = -1;
0200 
0201       DDName dd_tmp_name_b(getLayName(i) + "Lcut", "esalgo");
0202       DDName dd_tmp_name_c(getLayName(i) + "tmpb", "esalgo");
0203       DDName dd_tmp_name_d(getLayName(i) + "LinPb", "esalgo");
0204       DDName dd_tmp_name_e(getLayName(i) + "LinAl", "esalgo");
0205       DDName dd_tmp_name_f(getLayName(i) + "LOutAl", "esalgo");
0206 
0207       std::ostringstream tmp_Alname_fin;
0208       tmp_Alname_fin << getLayName(i) << "LtmpAl" << absz - 1;
0209       DDName dd_Alname_fin(tmp_Alname_fin.str(), "esalgo");
0210 
0211       DDSolid Outer_Al = DDSolid(dd_Alname_fin);
0212 
0213       DDLogicalPart layerFinOutAl = DDLogicalPart(dd_tmp_name_f, getMaterial(i - 1), Outer_Al);
0214 
0215       DDName dd_Alname_f(getLayName(i) + "LOutAl", "esalgo");
0216       DDName dd_Alname_g(getLayName(i) + "LOutAl2", "esalgo");
0217       DDName dd_Alname_h(getLayName(i) + "LOutAltmp", "esalgo");
0218       DDName dd_Alname_i(getLayName(i) + "LOutAltmp2", "esalgo");
0219       DDName dd_Alname_j(getLayName(i) + "LOutAltmp3", "esalgo");
0220       DDName dd_Alname_k(getLayName(i) + "LOutAltmp4", "esalgo");
0221       DDName dd_Alname_l(getLayName(i) + "LOutAltmp5", "esalgo");
0222       DDName dd_Alname_m(getLayName(i) + "LOutAltmp6", "esalgo");
0223 
0224       DDSolid Out_Al =
0225           DDSolidFactory::tubs(dd_Alname_f, zHalf - 0.1 * mm, rMax_Abs_Al_ - 20 * cm, rMax_Abs_Al_, 0., 90. * deg);
0226 #ifdef EDM_ML_DEBUG
0227       edm::LogVerbatim("SFGeomX") << dd_Alname_f << " Tubs " << (zHalf - 0.1 * mm) << ":" << (rMax_Abs_Al_ - 20 * cm)
0228                                   << ":" << rMax_Abs_Al_ << ":0:90";
0229 #endif
0230 
0231       outalbx = absAlX_X_ * 0.1;
0232       outalby = rMax_Abs_Al_ + 0.1 * mm - absAlX_subtr1_Yshift_;
0233       shiftR = absAlX_subtr1_Yshift_;
0234       if (I == 20) {
0235         outalbx = absAlY_X_ * 0.1;
0236         outalby = rMax_Abs_Al_ + 0.1 * mm - absAlY_subtr1_Yshift_;
0237         shiftR = absAlY_subtr1_Xshift_;
0238       }
0239       DDSolid OutAltmp = DDSolidFactory::box(dd_Alname_h, outalbx / 2 + 0.1 * mm, outalby / 2 + 0.1 * mm, zHalf);
0240       DDSolid Out_Altmp3 = DDSolidFactory::subtraction(
0241           dd_Alname_j, Out_Al, OutAltmp, DDTranslation(outalbx / 2, outalby / 2 + shiftR, 0), DDRotation());
0242 #ifdef EDM_ML_DEBUG
0243       edm::LogVerbatim("SFGeomX") << dd_Alname_h << " Box " << (outalbx / 2 + 0.1 * mm) << ":"
0244                                   << (outalby / 2 + 0.1 * mm) << ":" << zHalf;
0245       edm::LogVerbatim("SFGeomX") << dd_Alname_j << " Subtraction " << Out_Al.name() << ":" << OutAltmp.name() << " at "
0246                                   << DDTranslation(outalbx / 2, outalby / 2 + shiftR, 0) << " no rotation";
0247 #endif
0248       outalby2 = absAlX_Y_ * 0.1;
0249       outalbx2 = rMax_Abs_Al_ + 0.1 * mm - absAlX_subtr1_Xshift_;
0250       shiftR2 = absAlX_subtr1_Xshift_;
0251       if (I == 20) {
0252         outalby2 = absAlY_Y_ * 0.1;
0253         outalbx2 = rMax_Abs_Al_ + 0.1 * mm - absAlY_subtr1_Xshift_;
0254         shiftR2 = absAlY_subtr1_Xshift_;
0255       }
0256       DDSolid OutAltmp2 = DDSolidFactory::box(dd_Alname_i, outalbx2 / 2 + 0.1 * mm, outalby2 / 2 + 0.1 * mm, zHalf);
0257       DDSolid Out_Altmp4 = DDSolidFactory::subtraction(
0258           dd_Alname_k, Out_Altmp3, OutAltmp2, DDTranslation(outalbx2 / 2 + shiftR2, outalby2 / 2, 0), DDRotation());
0259       DDSolid Out_Altmp5 = DDSolidFactory::unionSolid(
0260           dd_Alname_l, Out_Altmp4, Out_Altmp4, DDTranslation(0, 0, 0), DDRotation("esalgo:RABS90"));
0261       DDSolid Out_Altmp6 = DDSolidFactory::unionSolid(
0262           dd_Alname_m, Out_Altmp5, Out_Altmp4, DDTranslation(0, 0, 0), DDRotation("esalgo:RABS180B"));
0263       DDSolid Out_Al2 = DDSolidFactory::unionSolid(
0264           dd_Alname_g, Out_Altmp6, Out_Altmp4, DDTranslation(0, 0, 0), DDRotation("esalgo:R180"));
0265 #ifdef EDM_ML_DEBUG
0266       edm::LogVerbatim("SFGeomX") << dd_Alname_i << " Box " << (outalbx2 / 2 + 0.1 * mm) << ":"
0267                                   << (outalby2 / 2 + 0.1 * mm) << ":" << zHalf;
0268       edm::LogVerbatim("SFGeomX") << dd_Alname_k << " Subtraction " << Out_Altmp3.name() << ":" << OutAltmp2.name()
0269                                   << " at " << DDTranslation(outalbx2 / 2 + shiftR2, outalby2 / 2, 0) << " no rotation";
0270       edm::LogVerbatim("SFGeomX") << dd_Alname_l << " Union " << Out_Altmp4.name() << ":" << Out_Altmp4.name() << " at "
0271                                   << DDTranslation(0, 0, 0) << " rotation esalgo:RABS90";
0272       edm::LogVerbatim("SFGeomX") << dd_Alname_m << " Union " << Out_Altmp5.name() << ":" << Out_Altmp4.name() << " at "
0273                                   << DDTranslation(0, 0, 0) << " rotation esalgo:RABS180B";
0274       edm::LogVerbatim("SFGeomX") << dd_Alname_g << " Union " << Out_Altmp6.name() << ":" << Out_Altmp4.name() << " at "
0275                                   << DDTranslation(0, 0, 0) << " rotation esalgo:R180";
0276       edm::LogVerbatim("SFGeomX") << Outer_Al;
0277 #endif
0278 
0279       for (int L = 0; L < absz; ++L) {
0280         int K = L;
0281         std::ostringstream tmp_name_b, tmp_name_b2, tmp_FAl_name_c, tmp_FAl_name_d1, tmp_FAl_name_d2, tmp_FAl_name_d3,
0282             tmp_FAl_name_d;
0283         tmp_name_b << getLayName(i) << "L" << K;
0284         tmp_name_b2 << getLayName(i) << "Lb2" << K;
0285 
0286         if (L == 0)
0287           tmp_FAl_name_c << getLayName(i) << "LOutAl2";
0288         if (L > 0)
0289           tmp_FAl_name_c << getLayName(i) << "LtmpAl" << K - 1;
0290 
0291         tmp_FAl_name_d1 << getLayName(i) << "LtmpAl" << K << "_1";
0292         tmp_FAl_name_d2 << getLayName(i) << "LtmpAl" << K << "_2";
0293         tmp_FAl_name_d3 << getLayName(i) << "LtmpAl" << K << "_3";
0294         tmp_FAl_name_d << getLayName(i) << "LtmpAl" << K;
0295 
0296         DDName dd_tmp_name_b(tmp_name_b.str(), "esalgo");
0297         DDName dd_tmp_name_b2(tmp_name_b2.str(), "esalgo");
0298         DDName dd_FAl_name_c(tmp_FAl_name_c.str(), "esalgo");
0299         DDName dd_FAl_name_d1(tmp_FAl_name_d1.str(), "esalgo");
0300         DDName dd_FAl_name_d2(tmp_FAl_name_d2.str(), "esalgo");
0301         DDName dd_FAl_name_d3(tmp_FAl_name_d3.str(), "esalgo");
0302         DDName dd_FAl_name_d(tmp_FAl_name_d.str(), "esalgo");
0303 
0304         if (L == 0)
0305           bdx = std::abs(abs1stx[K]) / 2;
0306         if (L > 0)
0307           bdx = std::abs(abs1stx[K] - abs1stx[K - 1]) / 2;
0308         bdy = abs1sty[K];
0309         if (abs1stx[K] < rIn + 30 * cm) {
0310           bdy = abs1sty[K] / 2 - 30 * cm;
0311           cutabsx = K;
0312         }
0313 
0314         if (I == 20) {
0315           if (L == 0)
0316             bdx = std::abs(abs2ndx[K]) / 2;
0317           if (L > 0)
0318             bdx = std::abs(abs2ndx[K] - abs2ndx[K - 1]) / 2;
0319           bdy = abs2ndy[K];
0320         }
0321 
0322         if ((abs2ndx[K] < rIn + 30 * cm) && I == 20) {
0323           bdy = abs2ndy[K] / 2 - 30 * cm;
0324           cutabsy = K;
0325         }
0326 
0327         DDSolid solid_b = DDSolidFactory::box(dd_tmp_name_b, bdx, bdy, zHalf);
0328         DDSolid solid_b2 = DDSolidFactory::box(dd_tmp_name_b2, bdx + 0.1 * mm, bdy + 0.1 * mm, zHalf);
0329 #ifdef EDM_ML_DEBUG
0330         edm::LogVerbatim("SFGeomX") << dd_tmp_name_b << " Box " << bdx << ":" << bdy << ":" << zHalf;
0331         edm::LogVerbatim("SFGeomX") << dd_tmp_name_b2 << " Box " << (bdx + 0.1 * mm) << ":" << (bdy + 0.1 * mm) << ":"
0332                                     << zHalf;
0333 #endif
0334 
0335         sdx = abs1stx[K] - bdx;
0336         sdy = 0;
0337         if (abs1stx[K] < rIn + 30 * cm)
0338           sdy = abs1sty[K] - bdy;
0339 
0340         if (I == 20) {
0341           sdx = abs2ndx[K] - bdx;
0342           sdy = 0;
0343         }
0344         if ((abs2ndx[K] < rIn + 30 * cm) && I == 20)
0345           sdy = abs2ndy[K] - bdy;
0346 
0347         DDLogicalPart layer = DDLogicalPart(dd_tmp_name_b, getMaterial(i), solid_b);
0348 
0349         cpv.position(layer, layerFinOutAl, 1, DDTranslation(sdx, sdy, 0), DDRotation());
0350         cpv.position(layer, layerFinOutAl, 2, DDTranslation(-sdx, sdy, 0), DDRotation());
0351 #ifdef EDM_ML_DEBUG
0352         edm::LogVerbatim("SFGeom") << layer.name() << " copy 1 in " << layerFinOutAl.name() << " at "
0353                                    << DDTranslation(sdx, sdy, 0) << " no rotation";
0354         edm::LogVerbatim("SFGeom") << layer.name() << " copy 2 in " << layerFinOutAl.name() << " at "
0355                                    << DDTranslation(-sdx, sdy, 0) << " no rotation";
0356 #endif
0357         DDSolid solid_c = DDSolid(dd_FAl_name_c);
0358         DDSolid solid_d1 =
0359             DDSolidFactory::unionSolid(dd_FAl_name_d1, solid_c, solid_b2, DDTranslation(sdx, sdy, 0), DDRotation());
0360         DDSolid solid_d2 =
0361             DDSolidFactory::unionSolid(dd_FAl_name_d, solid_d1, solid_b2, DDTranslation(-sdx, -sdy, 0), DDRotation());
0362 #ifdef EDM_ML_DEBUG
0363         edm::LogVerbatim("SFGeomX") << dd_FAl_name_d1 << " Union " << solid_c.name() << ":" << solid_b2.name() << " at "
0364                                     << DDTranslation(sdx, sdy, 0) << " no rotation";
0365         edm::LogVerbatim("SFGeomX") << dd_FAl_name_d << " Union " << solid_d1.name() << ":" << solid_b2.name() << " at "
0366                                     << DDTranslation(-sdx, -sdy, 0) << " no rotation";
0367 #endif
0368         if (((abs1stx[K] < rIn + 30 * cm) && I == 10) || ((abs2ndx[K] < rIn + 30 * cm) && I == 20)) {
0369           cpv.position(layer, layerFinOutAl, 3, DDTranslation(sdx, -sdy, 0), DDRotation());
0370           cpv.position(layer, layerFinOutAl, 4, DDTranslation(-sdx, -sdy, 0), DDRotation());
0371 #ifdef EDM_ML_DEBUG
0372           edm::LogVerbatim("SFGeom") << layer.name() << " copy 3 in " << layerFinOutAl.name() << " at "
0373                                      << DDTranslation(sdx, -sdy, 0) << " no rotation";
0374           edm::LogVerbatim("SFGeom") << layer.name() << " copy 4 in " << layerFinOutAl.name() << " at "
0375                                      << DDTranslation(-sdx, -sdy, 0) << " no rotation";
0376 #endif
0377           DDSolid solid_c = DDSolid(dd_FAl_name_c);
0378           DDSolid solid_d1 =
0379               DDSolidFactory::unionSolid(dd_FAl_name_d1, solid_c, solid_b2, DDTranslation(sdx, sdy, 0), DDRotation());
0380           DDSolid solid_d2 =
0381               DDSolidFactory::unionSolid(dd_FAl_name_d2, solid_d1, solid_b2, DDTranslation(sdx, -sdy, 0), DDRotation());
0382           DDSolid solid_d3 =
0383               DDSolidFactory::unionSolid(dd_FAl_name_d3, solid_d2, solid_b2, DDTranslation(-sdx, sdy, 0), DDRotation());
0384           DDSolid solid_d4 =
0385               DDSolidFactory::unionSolid(dd_FAl_name_d, solid_d3, solid_b2, DDTranslation(-sdx, -sdy, 0), DDRotation());
0386 #ifdef EDM_ML_DEBUG
0387           edm::LogVerbatim("SFGeomX") << dd_FAl_name_d1 << " Union " << solid_c.name() << ":" << solid_b2.name()
0388                                       << " at " << DDTranslation(sdx, sdy, 0) << " no rotation";
0389           edm::LogVerbatim("SFGeomX") << dd_FAl_name_d2 << " Union " << solid_d1.name() << ":" << solid_b2.name()
0390                                       << " at " << DDTranslation(sdx, -sdy, 0) << " no rotation";
0391           edm::LogVerbatim("SFGeomX") << dd_FAl_name_d3 << " Union " << solid_d2.name() << ":" << solid_b2.name()
0392                                       << " at " << DDTranslation(-sdx, sdy, 0) << " no rotation";
0393           edm::LogVerbatim("SFGeomX") << dd_FAl_name_d << " Union " << solid_d3.name() << ":" << solid_b2.name()
0394                                       << " at " << DDTranslation(-sdx, -sdy, 0) << " no rotation";
0395 #endif
0396         }
0397       }
0398 
0399       bdx = abs1stx[cutabsx];
0400       if (I == 20)
0401         bdx = abs2ndx[cutabsy];
0402       bdy = 2 * 30 * cm;
0403 
0404       DDSolid solidcut = DDSolidFactory::box(dd_tmp_name_b, bdx, bdy, zHalf);
0405 
0406       DDSolid iner = DDSolidFactory::tubs(dd_tmp_name_c, zHalf + 0.1 * mm, 0, In_rad_Abs_Pb, 0., 360. * deg);
0407 
0408       DDSolid final = DDSolidFactory::subtraction(dd_tmp_name_d, solidcut, iner, DDTranslation(0, 0, 0), DDRotation());
0409 #ifdef EDM_ML_DEBUG
0410       edm::LogVerbatim("SFGeomX") << dd_tmp_name_b << " Box " << bdx << ":" << bdy << ":" << zHalf;
0411       edm::LogVerbatim("SFGeomX") << dd_tmp_name_c << " Tubs " << (zHalf + 0.1 * mm) << ":0:" << In_rad_Abs_Pb
0412                                   << ":0:360";
0413       edm::LogVerbatim("SFGeomX") << dd_tmp_name_d << " Subtraction " << solidcut.name() << ":" << iner.name()
0414                                   << " at (0,0,0) no rotation";
0415 #endif
0416 
0417       DDLogicalPart layer = DDLogicalPart(dd_tmp_name_d, getMaterial(i), final);
0418       cpv.position(layer, parent(), 1, DDTranslation(0, 0, zpos), DDRotation());
0419 #ifdef EDM_ML_DEBUG
0420       edm::LogVerbatim("SFGeom") << layer.name() << " copy 1 in " << parent().name() << " at "
0421                                  << DDTranslation(0, 0, zpos) << " no rotation";
0422 #endif
0423       DDSolid iner_Al =
0424           DDSolidFactory::tubs(dd_tmp_name_e, zHalf, In_rad_Abs_Al, In_rad_Abs_Pb - 0.01 * mm, 0., 360. * deg);
0425 #ifdef EDM_ML_DEBUG
0426       edm::LogVerbatim("SFGeomX") << dd_tmp_name_e << " Tubs " << zHalf << ":" << In_rad_Abs_Al << ":"
0427                                   << (In_rad_Abs_Pb - 0.01 * mm) << ":0:360";
0428 #endif
0429 
0430       DDLogicalPart layerAl = DDLogicalPart(dd_tmp_name_e, getMaterial(i - 1), iner_Al);
0431       cpv.position(layerAl, parent(), 1, DDTranslation(0, 0, zpos), DDRotation());
0432       cpv.position(layerFinOutAl, parent(), 1, DDTranslation(0, 0, zpos), DDRotation());
0433 #ifdef EDM_ML_DEBUG
0434       edm::LogVerbatim("SFGeom") << layerAl.name() << " copy 1 in " << parent().name() << " at "
0435                                  << DDTranslation(0, 0, zpos) << " no rotation";
0436       edm::LogVerbatim("SFGeom") << layerFinOutAl.name() << " copy 1 in " << parent().name() << " at "
0437                                  << DDTranslation(0, 0, zpos) << " no rotation";
0438 #endif
0439     } else {
0440       cpv.position(layer, parent(), 1, DDTranslation(0., 0., zpos), DDRotation());
0441 #ifdef EDM_ML_DEBUG
0442       edm::LogVerbatim("SFGeom") << layer.name() << " copy 1 in " << parent().name() << " at "
0443                                  << DDTranslation(0, 0, zpos) << " no rotation";
0444 #endif
0445     }
0446     zpos += zHalf;
0447   }
0448 }
0449 
0450 void DDEcalPreshowerAlgo::doLadders(DDCompactView& cpv) {
0451   double xpos(0), ypos(0), zpos(0), sdx(0), sdy(0), sdz(0);
0452   double prev_length_(0), ladder_new_length_(0), ladd_shift_(0), ladder_length(0);
0453   int enb(0), swed_scopy_glob(0);
0454   double sdxe[50] = {0}, sdye[50] = {0}, sdze[50] = {0};
0455   double sdxe2[50] = {0}, sdye2[50] = {0}, sdze2[50] = {0}, sdxe3[50] = {0}, sdye3[50] = {0}, sdze3[50] = {0};
0456 
0457   for (int M = 0; M < int(types_l5_.size() + types_l4_.size()); M++) {
0458     int scopy(0);
0459     double boxax(0), boxay(0), boxaz(0);
0460     int ladd_not_plain(0), ladd_subtr_no(0), ladd_upper(0), ladd_side(0);
0461 
0462     DDSolid solid_lfront = DDSolidFactory::trap(DDName("LDRFRNT", "esalgo"),
0463                                                 LdrFrnt_Length / 2,                                          // pDz
0464                                                 -wedge_angle,                                                // pTheta
0465                                                 0,                                                           // pPhi
0466                                                 ladder_width / 2,                                            // pDy1
0467                                                 (ladder_thick) / 2,                                          // pDx1
0468                                                 (ladder_thick) / 2,                                          // pDx2
0469                                                 0,                                                           // pAlp1
0470                                                 ladder_width / 2,                                            // pDy2
0471                                                 (ladder_thick - ceramic_length * sin(wedge_angle * 2)) / 2,  // pDx3
0472                                                 (ladder_thick - ceramic_length * sin(wedge_angle * 2)) / 2,  // pDx4
0473                                                 0);
0474 
0475     DDSolid solid_lbck = DDSolidFactory::trap(DDName("LDRBCK", "esalgo"),
0476                                               LdrBck_Length / 2,                                   // pDz
0477                                               -wedge_angle,                                        // pTheta
0478                                               0,                                                   // pPhi
0479                                               ladder_width / 2,                                    // pDy1
0480                                               (box_thick / cos(wedge_angle * 2) + 0.02 * mm) / 2,  // pDx1
0481                                               (box_thick / cos(wedge_angle * 2) + 0.02 * mm) / 2,  // pDx2
0482                                               0,                                                   // pAlp1
0483                                               ladder_width / 2,                                    // pDy2
0484                                               (ladder_thick - wedge_back_thick) / 2,               // pDx3
0485                                               (ladder_thick - wedge_back_thick) / 2,               // pDx4
0486                                               0);
0487 
0488     DDSolid solid_lfhalf = DDSolidFactory::trap(DDName("LDRFHALF", "esalgo"),
0489                                                 LdrFrnt_Length / 2,                                          // pDz
0490                                                 -wedge_angle,                                                // pTheta
0491                                                 0,                                                           // pPhi
0492                                                 (ladder_width / 2) / 2,                                      // pDy1
0493                                                 (ladder_thick) / 2,                                          // pDx1
0494                                                 (ladder_thick) / 2,                                          // pDx2
0495                                                 0,                                                           // pAlp1
0496                                                 (ladder_width / 2) / 2,                                      // pDy2
0497                                                 (ladder_thick - ceramic_length * sin(wedge_angle * 2)) / 2,  // pDx3
0498                                                 (ladder_thick - ceramic_length * sin(wedge_angle * 2)) / 2,  // pDx4
0499                                                 0);
0500 
0501     DDSolid solid_lbhalf = DDSolidFactory::trap(DDName("LDRBHALF", "esalgo"),
0502                                                 LdrBck_Length / 2,                                   // pDz
0503                                                 -wedge_angle,                                        // pTheta
0504                                                 0,                                                   // pPhi
0505                                                 (ladder_width / 2) / 2,                              // pDy1
0506                                                 (box_thick / cos(wedge_angle * 2) + 0.02 * mm) / 2,  // pDx1
0507                                                 (box_thick / cos(wedge_angle * 2) + 0.02 * mm) / 2,  // pDx2
0508                                                 0,                                                   // pAlp1
0509                                                 (ladder_width / 2) / 2,                              // pDy2
0510                                                 (ladder_thick - wedge_back_thick) / 2,               // pDx3
0511                                                 (ladder_thick - wedge_back_thick) / 2,               // pDx4
0512                                                 0);
0513 
0514     DDSolid solid_lfhtrunc =
0515         DDSolidFactory::trap(DDName("LDRFHTR", "esalgo"),
0516                              (LdrFrnt_Length - waf_active) / 2,                                          // pDz
0517                              -wedge_angle,                                                               // pTheta
0518                              0,                                                                          // pPhi
0519                              (ladder_width / 2) / 2,                                                     // pDy1
0520                              (ladder_thick) / 2,                                                         // pDx1
0521                              (ladder_thick) / 2,                                                         // pDx2
0522                              0,                                                                          // pAlp1
0523                              (ladder_width / 2) / 2,                                                     // pDy2
0524                              (ladder_thick - (ceramic_length - waf_active) * sin(wedge_angle * 2)) / 2,  // pDx3
0525                              (ladder_thick - (ceramic_length - waf_active) * sin(wedge_angle * 2)) / 2,  // pDx4
0526                              0);
0527 #ifdef EDM_ML_DEBUG
0528     edm::LogVerbatim("SFGeomX") << DDName("LDRFRNT", "esalgo") << " Trap " << (LdrFrnt_Length / 2) << ":"
0529                                 << -wedge_angle / CLHEP::deg << ":0:" << (ladder_width / 2) << ":" << (ladder_thick / 2)
0530                                 << ":" << (ladder_thick / 2) << ":0:" << (ladder_width / 2) << ":"
0531                                 << ((ladder_thick - ceramic_length * sin(wedge_angle * 2)) / 2) << ":"
0532                                 << ((ladder_thick - ceramic_length * sin(wedge_angle * 2)) / 2) << ":0";
0533     edm::LogVerbatim("SFGeomX") << DDName("LDRBCK", "esalgo") << " Trap " << (LdrBck_Length / 2) << ":"
0534                                 << -wedge_angle / CLHEP::deg << ":0:" << (ladder_width / 2) << ":"
0535                                 << ((box_thick / cos(wedge_angle * 2) + 0.02 * mm) / 2) << ":"
0536                                 << ((box_thick / cos(wedge_angle * 2) + 0.02 * mm) / 2) << ":0:" << (ladder_width / 2)
0537                                 << ":" << ((ladder_thick - wedge_back_thick) / 2) << ":"
0538                                 << ((ladder_thick - wedge_back_thick) / 2) << ":0";
0539     edm::LogVerbatim("SFGeomX") << DDName("LDRFHALF", "esalgo") << " Trap " << (LdrFrnt_Length / 2) << ":"
0540                                 << -wedge_angle / CLHEP::deg << ":0:" << ((ladder_width / 2) / 2) << ":"
0541                                 << (ladder_thick / 2) << ":" << (ladder_thick / 2) << ":0:" << ((ladder_width / 2) / 2)
0542                                 << ":" << ((ladder_thick - ceramic_length * sin(wedge_angle * 2)) / 2) << ":"
0543                                 << ((ladder_thick - ceramic_length * sin(wedge_angle * 2)) / 2) << ":0";
0544     edm::LogVerbatim("SFGeomX") << DDName("LDRBHALF", "esalgo") << " Trap " << (LdrBck_Length / 2) << ":"
0545                                 << -wedge_angle / CLHEP::deg << ":0:" << ((ladder_width / 2) / 2) << ":"
0546                                 << ((box_thick / cos(wedge_angle * 2) + 0.02 * mm) / 2) << ":"
0547                                 << ((box_thick / cos(wedge_angle * 2) + 0.02 * mm) / 2)
0548                                 << ":0:" << ((ladder_width / 2) / 2) << ":" << ((ladder_thick - wedge_back_thick) / 2)
0549                                 << ":" << ((ladder_thick - wedge_back_thick) / 2) << ":0";
0550     edm::LogVerbatim("SFGeomX") << DDName("LDRFHTR", "esalgo") << " Trap " << ((LdrFrnt_Length - waf_active) / 2) << ":"
0551                                 << -wedge_angle / CLHEP::deg << ":0:" << ((ladder_width / 2) / 2) << ":"
0552                                 << ((ladder_thick) / 2) << ":" << ((ladder_thick) / 2)
0553                                 << ":0:" << ((ladder_width / 2) / 2) << ":"
0554                                 << ((ladder_thick - (ceramic_length - waf_active) * sin(wedge_angle * 2)) / 2) << ":"
0555                                 << ((ladder_thick - (ceramic_length - waf_active) * sin(wedge_angle * 2)) / 2) << ":0";
0556 #endif
0557 
0558     // Creation of ladders with 5 micromodules length
0559 
0560     if (M < int(types_l5_.size())) {
0561       for (int i = 0; i <= 1; i++) {
0562         for (int j = 0; j <= 3; j++) {
0563           if (ladd_l5_map_[(i + j * 2 + M * 10)] != 1) {
0564             ladd_not_plain = 1;
0565             ladd_subtr_no++;
0566             if (j > 1)
0567               ladd_upper = 1;
0568             ladd_side = i;
0569           }
0570         }
0571       }
0572 #ifdef EDM_ML_DEBUG
0573       edm::LogVerbatim("SFGeomX") << "Side " << ladd_side << ":" << ladd_upper << ":" << ladd_subtr_no << ":"
0574                                   << ladd_not_plain << " Index " << M << ":" << types_l5_.size();
0575 #endif
0576       DDName ddname(getLadPrefix(0) + types_l5_[M], "esalgo");
0577       ladder_length = micromodule_length + 4 * waf_active + 0.1 * mm;
0578 
0579       if (ladd_not_plain) {
0580         //          enb++;
0581         std::ostringstream tmp_name_5b, tmp_name_5c, tmp_name_5d;
0582         if (ladd_upper) {
0583         }  //upper
0584         else {
0585           enb++;
0586           std::ostringstream tmp_name_5b, tmp_name_5c, tmp_name_5d;
0587           DDName dd_tmp_name_5a(getLadPrefix(2), "esalgo");
0588           tmp_name_5b << getLadPrefix(3) << enb;
0589           DDName dd_tmp_name_5b(tmp_name_5b.str(), "esalgo");
0590           tmp_name_5c << getLadPrefix(4) << enb;
0591           DDName dd_tmp_name_5c(tmp_name_5c.str(), "esalgo");
0592           tmp_name_5d << getLadPrefix(5) << enb;
0593           DDName dd_tmp_name_5d(tmp_name_5d.str(), "esalgo");
0594 
0595           DDName dd_tmp_name_5e(getLadPrefix(6), "esalgo");
0596 
0597           boxay = ladder_length - LdrFrnt_Length - LdrBck_Length;
0598           boxax = ladder_width;
0599           boxaz = ladder_thick;
0600 
0601           DDSolid solid_5a = DDSolidFactory::box(dd_tmp_name_5a, boxax / 2, boxay / 2, boxaz / 2.);
0602 #ifdef EDM_ML_DEBUG
0603           edm::LogVerbatim("SFGeomX") << dd_tmp_name_5a << " Box " << (boxax / 2) << ":" << (boxay / 2) << ":"
0604                                       << (boxaz / 2);
0605 #endif
0606           if (ladd_side == 0)
0607             sdxe[enb] = ladder_width / 4;
0608           sdye[enb] = -boxay / 2 - LdrFrnt_Length / 2;
0609           sdze[enb] = -ladder_thick / 2. + LdrFrnt_Offset;
0610           if (ladd_side == 1)
0611             sdxe[enb] = -ladder_width / 4;
0612 
0613           DDSolid solid_5b = DDSolidFactory::unionSolid(dd_tmp_name_5b,
0614                                                         solid_5a,
0615                                                         solid_lfhalf,
0616                                                         DDTranslation(sdxe[enb], sdye[enb], sdze[enb]),
0617                                                         DDRotation("esalgo:RM1299"));
0618 #ifdef EDM_ML_DEBUG
0619           edm::LogVerbatim("SFGeomX") << dd_tmp_name_5b << " Union " << solid_5a.name() << ":" << solid_lfhalf.name()
0620                                       << " at " << DDTranslation(sdxe[enb], sdye[enb], sdze[enb])
0621                                       << " rotation esalgo:RM1299";
0622 #endif
0623 
0624           if (ladd_side == 0)
0625             sdxe2[enb] = -ladder_width / 4;
0626           sdye2[enb] = -boxay / 2 - LdrFrnt_Length / 2 + waf_active / 2;
0627           sdze2[enb] = -ladder_thick / 2. + LdrFrnt_Offset + (waf_active * sin(wedge_angle * 2)) / 4;
0628           if (ladd_side == 1)
0629             sdxe2[enb] = ladder_width / 4;
0630 
0631           DDSolid solid_5c = DDSolidFactory::unionSolid(dd_tmp_name_5c,
0632                                                         solid_5b,
0633                                                         solid_lfhtrunc,
0634                                                         DDTranslation(sdxe2[enb], sdye2[enb], sdze2[enb]),
0635                                                         DDRotation("esalgo:RM1299"));
0636 #ifdef EDM_ML_DEBUG
0637           edm::LogVerbatim("SFGeomX") << dd_tmp_name_5c << " Union " << solid_5b.name() << ":" << solid_lfhtrunc.name()
0638                                       << " at " << DDTranslation(sdxe2[enb], sdye2[enb], sdze2[enb])
0639                                       << " rotation esalgo:RM1299";
0640 #endif
0641 
0642           sdxe3[enb] = 0;
0643           sdye3[enb] = boxay / 2 + LdrBck_Length / 2;
0644           sdze3[enb] = -ladder_thick / 2. + LdrBck_Offset;
0645           DDSolid solid = DDSolidFactory::unionSolid(ddname,
0646                                                      solid_5c,
0647                                                      solid_lbck,
0648                                                      DDTranslation(sdxe3[enb], sdye3[enb], sdze3[enb]),
0649                                                      DDRotation("esalgo:RM1299"));
0650 #ifdef EDM_ML_DEBUG
0651           edm::LogVerbatim("SFGeomX") << ddname << " Union " << solid_5c.name() << ":" << solid_lbck.name() << " at "
0652                                       << DDTranslation(sdxe3[enb], sdye3[enb], sdze3[enb]) << " rotation esalgo:RM1299";
0653 #endif
0654 
0655           DDLogicalPart ladder = DDLogicalPart(ddname, getLaddMaterial(), solid);
0656           DDName ddname2(getLadPrefix(1) + types_l5_[M], "esalgo");
0657           DDLogicalPart ladder2 = DDLogicalPart(ddname2, getLaddMaterial(), solid);
0658         }
0659 
0660       }  //end of not plain ladder shape
0661       else {
0662         DDName dd_tmp_name_5pa(getLadPrefix(2) + "5p", "esalgo");
0663         DDName dd_tmp_name_5pb(getLadPrefix(3) + "5p", "esalgo");
0664 
0665         boxay = ladder_length - LdrFrnt_Length - LdrBck_Length;
0666         boxax = ladder_width;
0667         boxaz = ladder_thick;
0668 
0669         DDSolid solid_5pa = DDSolidFactory::box(dd_tmp_name_5pa, boxax / 2, boxay / 2, boxaz / 2.);
0670 #ifdef EDM_ML_DEBUG
0671         edm::LogVerbatim("SFGeomX") << dd_tmp_name_5pa << " Box " << (boxax / 2) << ":" << (boxay / 2) << ":"
0672                                     << (boxaz / 2);
0673 #endif
0674         sdx = 0;
0675         sdy = -boxay / 2 - LdrFrnt_Length / 2;
0676         sdz = -ladder_thick / 2. + LdrFrnt_Offset;
0677 
0678         DDSolid solid_5pb = DDSolidFactory::unionSolid(
0679             dd_tmp_name_5pb, solid_5pa, solid_lfront, DDTranslation(sdx, sdy, sdz), DDRotation("esalgo:RM1299"));
0680 #ifdef EDM_ML_DEBUG
0681         edm::LogVerbatim("SFGeomX") << dd_tmp_name_5pb << " Union " << solid_5pa.name() << ":" << solid_lfront.name()
0682                                     << " at " << DDTranslation(sdx, sdy, sdz) << " rotation esalgo:RM1299";
0683 #endif
0684 
0685         sdx = 0;
0686         sdy = boxay / 2 + LdrBck_Length / 2;
0687         sdz = -ladder_thick / 2. + LdrBck_Offset;
0688 
0689         DDSolid solid = DDSolidFactory::unionSolid(
0690             ddname, solid_5pb, solid_lbck, DDTranslation(sdx, sdy, sdz), DDRotation("esalgo:RM1299"));
0691 #ifdef EDM_ML_DEBUG
0692         edm::LogVerbatim("SFGeomX") << ddname << " Union " << solid_5pb.name() << ":" << solid_lbck.name() << " at "
0693                                     << DDTranslation(sdx, sdy, sdz) << " rotation esalgo:RM1299";
0694 #endif
0695 
0696         DDLogicalPart ladder = DDLogicalPart(ddname, getLaddMaterial(), solid);
0697         DDName ddname2(getLadPrefix(1) + types_l5_[M], "esalgo");
0698         DDLogicalPart ladder2 = DDLogicalPart(ddname2, getLaddMaterial(), solid);
0699       }
0700     }
0701 
0702     // Creation of ladders with 4 micromodules length
0703 
0704     if (M >= int(types_l5_.size())) {
0705       int d = M - types_l5_.size();
0706 
0707       for (int i = 0; i <= 1; i++) {
0708         for (int j = 0; j <= 3; j++) {
0709           if (ladd_l4_map_[(i + j * 2 + (M - types_l5_.size()) * 8)] != 1) {
0710             ladd_not_plain = 1;
0711             ladd_subtr_no++;
0712             if (j > 1)
0713               ladd_upper = 1;
0714             ladd_side = i;
0715           }
0716         }
0717       }
0718 #ifdef EDM_ML_DEBUG
0719       edm::LogVerbatim("SFGeomX") << "Side " << ladd_side << ":" << ladd_upper << ":" << ladd_subtr_no << ":"
0720                                   << ladd_not_plain << " Index " << M << ":" << types_l5_.size();
0721 #endif
0722       DDName ddname(getLadPrefix(0) + types_l4_[d], "esalgo");
0723       ladder_length = micromodule_length + 3 * waf_active + 0.1 * mm;
0724 
0725       if (ladd_not_plain) {
0726         std::ostringstream tmp_name_b, tmp_name_c, tmp_name_d;
0727         if (ladd_upper) {
0728           enb++;
0729 
0730           DDName dd_tmp_name_a(getLadPrefix(7), "esalgo");
0731           tmp_name_b << getLadPrefix(8) << enb;
0732           DDName dd_tmp_name_b(tmp_name_b.str(), "esalgo");
0733           tmp_name_c << getLadPrefix(9) << enb;
0734           DDName dd_tmp_name_c(tmp_name_c.str(), "esalgo");
0735           tmp_name_d << getLadPrefix(10) << enb;
0736           DDName dd_tmp_name_d(tmp_name_d.str(), "esalgo");
0737           DDName dd_tmp_name_e(getLadPrefix(11), "esalgo");
0738 
0739           boxay = ladder_length - LdrFrnt_Length - LdrBck_Length;
0740           boxax = ladder_width;
0741           boxaz = ladder_thick;
0742           DDSolid solid_a = DDSolidFactory::box(dd_tmp_name_a, boxax / 2, boxay / 2, boxaz / 2.);
0743 #ifdef EDM_ML_DEBUG
0744           edm::LogVerbatim("SFGeomX") << dd_tmp_name_a << " Box " << (boxax / 2) << ":" << (boxay / 2) << ":"
0745                                       << (boxaz / 2);
0746 #endif
0747 
0748           sdxe[enb] = 0;
0749           sdye[enb] = -boxay / 2 - LdrFrnt_Length / 2;
0750           sdze[enb] = -ladder_thick / 2. + LdrFrnt_Offset;
0751           DDSolid solid_b = DDSolidFactory::unionSolid(dd_tmp_name_b,
0752                                                        solid_a,
0753                                                        solid_lfront,
0754                                                        DDTranslation(sdxe[enb], sdye[enb], sdze[enb]),
0755                                                        DDRotation("esalgo:RM1299"));
0756 #ifdef EDM_ML_DEBUG
0757           edm::LogVerbatim("SFGeomX") << dd_tmp_name_b << " Union " << solid_a.name() << ":" << solid_lfront.name()
0758                                       << " at " << DDTranslation(sdxe[enb], sdye[enb], sdze[enb])
0759                                       << " rotation esalgo:RM1299";
0760 #endif
0761 
0762           if (ladd_side == 0)
0763             sdxe2[enb] = ladder_width / 4;
0764           sdye2[enb] = boxay / 2 + LdrBck_Length / 2;
0765           sdze2[enb] = -ladder_thick / 2. + LdrBck_Offset;
0766           if (ladd_side == 1)
0767             sdxe2[enb] = -ladder_width / 4;
0768           DDSolid solid = DDSolidFactory::unionSolid(ddname,
0769                                                      solid_b,
0770                                                      solid_lbhalf,
0771                                                      DDTranslation(sdxe2[enb], sdye2[enb], sdze2[enb]),
0772                                                      DDRotation("esalgo:RM1299"));
0773 #ifdef EDM_ML_DEBUG
0774           edm::LogVerbatim("SFGeomX") << ddname << " Union " << solid_b.name() << ":" << solid_lbhalf.name() << " at "
0775                                       << DDTranslation(sdxe2[enb], sdye2[enb], sdze2[enb]) << " rotation esalgo:RM1299";
0776 #endif
0777 
0778           DDLogicalPart ladder = DDLogicalPart(ddname, getLaddMaterial(), solid);
0779           DDName ddname2(getLadPrefix(1) + types_l4_[d], "esalgo");
0780           DDLogicalPart ladder2 = DDLogicalPart(ddname2, getLaddMaterial(), solid);
0781 
0782         }  //upper
0783         else {
0784           if (ladd_subtr_no > 1) {
0785             enb++;
0786 
0787             DDName dd_tmp_name_a(getLadPrefix(7), "esalgo");
0788             tmp_name_b << getLadPrefix(8) << enb;
0789             DDName dd_tmp_name_b(tmp_name_b.str(), "esalgo");
0790             tmp_name_c << getLadPrefix(9) << enb;
0791             DDName dd_tmp_name_c(tmp_name_c.str(), "esalgo");
0792             tmp_name_d << getLadPrefix(10) << enb;
0793             DDName dd_tmp_name_d(tmp_name_d.str(), "esalgo");
0794             DDName dd_tmp_name_e(getLadPrefix(11), "esalgo");
0795 
0796             boxay = ladder_length - LdrFrnt_Length - LdrBck_Length;
0797             boxax = ladder_width;
0798             boxaz = ladder_thick;
0799 
0800             DDSolid solid_a = DDSolidFactory::box(dd_tmp_name_a, boxax / 2, boxay / 2, boxaz / 2.);
0801 #ifdef EDM_ML_DEBUG
0802             edm::LogVerbatim("SFGeomX") << dd_tmp_name_a << " Box " << (boxax / 2) << ":" << (boxay / 2) << ":"
0803                                         << (boxaz / 2);
0804 #endif
0805             if (ladd_side == 0)
0806               sdxe[enb] = ladder_width / 4;
0807             sdye[enb] = -boxay / 2 - LdrFrnt_Length / 2;
0808             sdze[enb] = -ladder_thick / 2. + LdrFrnt_Offset;
0809             if (ladd_side == 1)
0810               sdxe[enb] = -ladder_width / 4;
0811 
0812             DDSolid solid_b = DDSolidFactory::unionSolid(dd_tmp_name_b,
0813                                                          solid_a,
0814                                                          solid_lfhalf,
0815                                                          DDTranslation(sdxe[enb], sdye[enb], sdze[enb]),
0816                                                          DDRotation("esalgo:RM1299"));
0817 #ifdef EDM_ML_DEBUG
0818             edm::LogVerbatim("SFGeomX") << dd_tmp_name_b << " Union " << solid_a.name() << ":" << solid_lfhalf.name()
0819                                         << " at " << DDTranslation(sdxe[enb], sdye[enb], sdze[enb])
0820                                         << " rotation esalgo:RM1299";
0821 #endif
0822 
0823             sdxe2[enb] = 0;
0824             sdye2[enb] = boxay / 2 + LdrBck_Length / 2;
0825             sdze2[enb] = -ladder_thick / 2. + LdrBck_Offset;
0826 
0827             DDSolid solid = DDSolidFactory::unionSolid(ddname,
0828                                                        solid_b,
0829                                                        solid_lbck,
0830                                                        DDTranslation(sdxe2[enb], sdye2[enb], sdze2[enb]),
0831                                                        DDRotation("esalgo:RM1299"));
0832 #ifdef EDM_ML_DEBUG
0833             edm::LogVerbatim("SFGeomX") << ddname << " Union " << solid_b.name() << ":" << solid_lbck.name() << " at "
0834                                         << DDTranslation(sdxe2[enb], sdye2[enb], sdze2[enb])
0835                                         << " rotation esalgo:RM1299";
0836 #endif
0837 
0838             DDLogicalPart ladder = DDLogicalPart(ddname, getLaddMaterial(), solid);
0839             DDName ddname2(getLadPrefix(1) + types_l4_[d], "esalgo");
0840             DDLogicalPart ladder2 = DDLogicalPart(ddname2, getLaddMaterial(), solid);
0841           } else {
0842             enb++;
0843             DDName dd_tmp_name_a(getLadPrefix(7), "esalgo");
0844             tmp_name_b << getLadPrefix(8) << enb;
0845             DDName dd_tmp_name_b(tmp_name_b.str(), "esalgo");
0846             tmp_name_c << getLadPrefix(9) << enb;
0847             DDName dd_tmp_name_c(tmp_name_c.str(), "esalgo");
0848             tmp_name_d << getLadPrefix(10) << enb;
0849             DDName dd_tmp_name_d(tmp_name_d.str(), "esalgo");
0850             DDName dd_tmp_name_e(getLadPrefix(11), "esalgo");
0851 
0852             boxay = ladder_length - LdrFrnt_Length - LdrBck_Length;
0853             boxax = ladder_width;
0854             boxaz = ladder_thick;
0855             DDSolid solid_a = DDSolidFactory::box(dd_tmp_name_a, boxax / 2, boxay / 2, boxaz / 2.);
0856 #ifdef EDM_ML_DEBUG
0857             edm::LogVerbatim("SFGeomX") << dd_tmp_name_a << " Box " << (boxax / 2) << ":" << (boxay / 2) << ":"
0858                                         << (boxaz / 2);
0859 #endif
0860             if (ladd_side == 0)
0861               sdxe[enb] = ladder_width / 4;
0862             sdye[enb] = -boxay / 2 - LdrFrnt_Length / 2;
0863             sdze[enb] = -ladder_thick / 2. + LdrFrnt_Offset;
0864             if (ladd_side == 1)
0865               sdxe[enb] = -ladder_width / 4;
0866 
0867             DDSolid solid_b = DDSolidFactory::unionSolid(dd_tmp_name_b,
0868                                                          solid_a,
0869                                                          solid_lfhalf,
0870                                                          DDTranslation(sdxe[enb], sdye[enb], sdze[enb]),
0871                                                          DDRotation("esalgo:RM1299"));
0872 #ifdef EDM_ML_DEBUG
0873             edm::LogVerbatim("SFGeomX") << dd_tmp_name_b << " Union " << solid_a.name() << ":" << solid_lfhalf.name()
0874                                         << " at " << DDTranslation(sdxe[enb], sdye[enb], sdze[enb])
0875                                         << " rotation esalgo:RM1299";
0876 #endif
0877 
0878             if (ladd_side == 0)
0879               sdxe2[enb] = -ladder_width / 4;
0880             sdye2[enb] = -boxay / 2 - LdrFrnt_Length / 2 + waf_active / 2;
0881             sdze2[enb] = -ladder_thick / 2. + LdrFrnt_Offset + (waf_active * sin(wedge_angle * 2)) / 4;
0882             if (ladd_side == 1)
0883               sdxe2[enb] = ladder_width / 4;
0884 
0885             DDSolid solid_c = DDSolidFactory::unionSolid(dd_tmp_name_c,
0886                                                          solid_b,
0887                                                          solid_lfhtrunc,
0888                                                          DDTranslation(sdxe2[enb], sdye2[enb], sdze2[enb]),
0889                                                          DDRotation("esalgo:RM1299"));
0890 #ifdef EDM_ML_DEBUG
0891             edm::LogVerbatim("SFGeomX") << dd_tmp_name_c << " Union " << solid_b.name() << ":" << solid_lfhtrunc.name()
0892                                         << " at " << DDTranslation(sdxe2[enb], sdye2[enb], sdze2[enb])
0893                                         << " rotation esalgo:RM1299";
0894 #endif
0895 
0896             sdxe3[enb] = 0;
0897             sdye3[enb] = boxay / 2 + LdrBck_Length / 2;
0898             sdze3[enb] = -ladder_thick / 2. + LdrBck_Offset;
0899             DDSolid solid = DDSolidFactory::unionSolid(ddname,
0900                                                        solid_c,
0901                                                        solid_lbck,
0902                                                        DDTranslation(sdxe3[enb], sdye3[enb], sdze3[enb]),
0903                                                        DDRotation("esalgo:RM1299"));
0904 #ifdef EDM_ML_DEBUG
0905             edm::LogVerbatim("SFGeomX") << ddname << " Union " << solid_c.name() << ":" << solid_lbck.name() << " at "
0906                                         << DDTranslation(sdxe3[enb], sdye3[enb], sdze3[enb])
0907                                         << " rotation esalgo:RM1299";
0908 #endif
0909 
0910             DDLogicalPart ladder = DDLogicalPart(ddname, getLaddMaterial(), solid);
0911             DDName ddname2(getLadPrefix(1) + types_l4_[d], "esalgo");
0912             DDLogicalPart ladder2 = DDLogicalPart(ddname2, getLaddMaterial(), solid);
0913           }
0914         }
0915 
0916       }  //end of not plain ladder shape
0917       else {
0918         DDName dd_tmp_name_pa(getLadPrefix(2) + "p", "esalgo");
0919         DDName dd_tmp_name_pb(getLadPrefix(3) + "p", "esalgo");
0920 
0921         boxay = ladder_length - LdrFrnt_Length - LdrBck_Length;
0922         boxax = ladder_width;
0923         boxaz = ladder_thick;
0924 
0925         DDSolid solid_pa = DDSolidFactory::box(dd_tmp_name_pa, boxax / 2, boxay / 2, boxaz / 2.);
0926 #ifdef EDM_ML_DEBUG
0927         edm::LogVerbatim("SFGeomX") << dd_tmp_name_pa << " Box " << (boxax / 2) << ":" << (boxay / 2) << ":"
0928                                     << (boxaz / 2);
0929 #endif
0930         sdx = 0;
0931         sdy = -boxay / 2 - LdrFrnt_Length / 2;
0932         sdz = -ladder_thick / 2. + LdrFrnt_Offset;
0933 
0934         DDSolid solid_pb = DDSolidFactory::unionSolid(
0935             dd_tmp_name_pb, solid_pa, solid_lfront, DDTranslation(sdx, sdy, sdz), DDRotation("esalgo:RM1299"));
0936 #ifdef EDM_ML_DEBUG
0937         edm::LogVerbatim("SFGeomX") << dd_tmp_name_pb << " Union " << solid_pa.name() << ":" << solid_lfront.name()
0938                                     << " at " << DDTranslation(sdx, sdy, sdz) << " rotation esalgo:RM1299";
0939 #endif
0940 
0941         sdx = 0;
0942         sdy = boxay / 2 + LdrBck_Length / 2;
0943         sdz = -ladder_thick / 2. + LdrBck_Offset;
0944         DDSolid solid = DDSolidFactory::unionSolid(
0945             ddname, solid_pb, solid_lbck, DDTranslation(sdx, sdy, sdz), DDRotation("esalgo:RM1299"));
0946 #ifdef EDM_ML_DEBUG
0947         edm::LogVerbatim("SFGeomX") << ddname << " Union " << solid_pb.name() << ":" << solid_lbck.name() << " at "
0948                                     << DDTranslation(sdx, sdy, sdz) << " rotation esalgo:RM1299";
0949 #endif
0950         DDLogicalPart ladder = DDLogicalPart(ddname, getLaddMaterial(), solid);
0951         DDName ddname2(getLadPrefix(1) + types_l4_[d], "esalgo");
0952         DDLogicalPart ladder2 = DDLogicalPart(ddname2, getLaddMaterial(), solid);
0953       }
0954     }
0955 
0956     // insert SWED, SFBX and SFBY into ladders
0957     swed_scopy_glob++;
0958     if (M < int(types_l5_.size())) {
0959       DDName ddname(getLadPrefix(0) + types_l5_[M], "esalgo");
0960       DDName ddname2(getLadPrefix(1) + types_l5_[M], "esalgo");
0961       for (int i = 0; i <= 1; i++) {
0962         for (int j = 0; j <= 4; j++) {
0963           xpos = (i * 2 - 1) * waf_intra_col_sep / 2.;
0964           ypos = -ladder_length / 2. + 0.05 * mm - (LdrFrnt_Length - LdrBck_Length) / 2 + wedge_length / 2. +
0965                  j * waf_active;
0966           zpos = -ladder_thick / 2. + 0.005 * mm + wedge_offset;
0967           if (ladd_l5_map_[(i + j * 2 + M * 10)] == 1) {
0968             scopy++;
0969             cpv.position(DDLogicalPart("esalgo:SWED"),
0970                          ddname,
0971                          scopy + 1000 * swed_scopy_glob,
0972                          DDTranslation(xpos, ypos, zpos),
0973                          DDRotation("esalgo:RM1299"));
0974             cpv.position(DDLogicalPart("esalgo:SWED"),
0975                          ddname2,
0976                          scopy + 1000 * swed_scopy_glob + 100,
0977                          DDTranslation(xpos, ypos, zpos),
0978                          DDRotation("esalgo:RM1299"));
0979 #ifdef EDM_ML_DEBUG
0980             edm::LogVerbatim("SFGeom") << DDLogicalPart("esalgo:SWED").name() << " copy "
0981                                        << (scopy + 1000 * swed_scopy_glob) << " in " << ddname << " at "
0982                                        << DDTranslation(xpos, ypos, zpos) << " rotation esalgo:RM1299";
0983             edm::LogVerbatim("SFGeom") << DDLogicalPart("esalgo:SWED").name() << " copy "
0984                                        << (scopy + 1000 * swed_scopy_glob + 100) << " in " << ddname2 << " at "
0985                                        << DDTranslation(xpos, ypos, zpos) << " rotation esalgo:RM1299";
0986 #endif
0987             ypos = ypos + ywedge_ceramic_diff;
0988             zpos = -ladder_thick / 2. + 0.005 * mm + zwedge_ceramic_diff;
0989             cpv.position(DDLogicalPart("esalgo:SFBX"),
0990                          ddname,
0991                          scopy + 1000 * swed_scopy_glob,
0992                          DDTranslation(xpos, ypos, zpos),
0993                          DDRotation("esalgo:RM1298"));
0994             cpv.position(DDLogicalPart("esalgo:SFBY"),
0995                          ddname2,
0996                          scopy + 1000 * swed_scopy_glob,
0997                          DDTranslation(xpos, ypos, zpos),
0998                          DDRotation("esalgo:RM1300A"));
0999 #ifdef EDM_ML_DEBUG
1000             edm::LogVerbatim("SFGeom") << DDLogicalPart("esalgo:SFBX").name() << " copy "
1001                                        << (scopy + 1000 * swed_scopy_glob) << " in " << ddname << " at "
1002                                        << DDTranslation(xpos, ypos, zpos) << " rotation esalgo:RM1298";
1003             edm::LogVerbatim("SFGeom") << DDLogicalPart("esalgo:SFBY").name() << " copy "
1004                                        << (scopy + 1000 * swed_scopy_glob) << " in " << ddname2 << " at "
1005                                        << DDTranslation(xpos, ypos, zpos) << " rotation esalgo:RM1300A";
1006 #endif
1007           }
1008         }
1009       }
1010     } else {
1011       int d = M - types_l5_.size();
1012       DDName ddname(getLadPrefix(0) + types_l4_[d], "esalgo");
1013       DDName ddname2(getLadPrefix(1) + types_l4_[d], "esalgo");
1014       for (int i = 0; i <= 1; i++) {
1015         for (int j = 0; j <= 3; j++) {
1016           xpos = (i * 2 - 1) * waf_intra_col_sep / 2.;
1017           ypos = -ladder_length / 2. + 0.05 * mm - (LdrFrnt_Length - LdrBck_Length) / 2 + wedge_length / 2. +
1018                  j * waf_active;
1019           zpos = -ladder_thick / 2. + 0.005 * mm + wedge_offset;
1020           if (ladd_l4_map_[(i + j * 2 + (M - types_l5_.size()) * 8)] == 1) {
1021             scopy++;
1022             cpv.position(DDLogicalPart("esalgo:SWED"),
1023                          ddname,
1024                          scopy + 1000 * swed_scopy_glob,
1025                          DDTranslation(xpos, ypos, zpos),
1026                          DDRotation("esalgo:RM1299"));
1027             cpv.position(DDLogicalPart("esalgo:SWED"),
1028                          ddname2,
1029                          scopy + 1000 * swed_scopy_glob + 100,
1030                          DDTranslation(xpos, ypos, zpos),
1031                          DDRotation("esalgo:RM1299"));
1032 #ifdef EDM_ML_DEBUG
1033             edm::LogVerbatim("SFGeom") << DDLogicalPart("esalgo:SWED").name() << " copy "
1034                                        << (scopy + 1000 * swed_scopy_glob) << " in " << ddname << " at "
1035                                        << DDTranslation(xpos, ypos, zpos) << " rotation esalgo:RM1299";
1036             edm::LogVerbatim("SFGeom") << DDLogicalPart("esalgo:SWED").name() << " copy "
1037                                        << (scopy + 1000 * swed_scopy_glob + 100) << " in " << ddname2 << " at "
1038                                        << DDTranslation(xpos, ypos, zpos) << " rotation esalgo:RM1299";
1039 #endif
1040             ypos = ypos + ywedge_ceramic_diff;
1041             zpos = -ladder_thick / 2. + 0.005 * mm + zwedge_ceramic_diff;
1042             cpv.position(DDLogicalPart("esalgo:SFBX"),
1043                          ddname,
1044                          scopy + 1000 * swed_scopy_glob,
1045                          DDTranslation(xpos, ypos, zpos),
1046                          DDRotation("esalgo:RM1298"));
1047             cpv.position(DDLogicalPart("esalgo:SFBY"),
1048                          ddname2,
1049                          scopy + 1000 * swed_scopy_glob,
1050                          DDTranslation(xpos, ypos, zpos),
1051                          DDRotation("esalgo:RM1300A"));
1052 #ifdef EDM_ML_DEBUG
1053             edm::LogVerbatim("SFGeom") << DDLogicalPart("esalgo:SFBX").name() << " copy "
1054                                        << (scopy + 1000 * swed_scopy_glob) << " in " << ddname << " at "
1055                                        << DDTranslation(xpos, ypos, zpos) << " rotation esalgo:RM1298";
1056             edm::LogVerbatim("SFGeom") << DDLogicalPart("esalgo:SFBY").name() << " copy "
1057                                        << (scopy + 1000 * swed_scopy_glob) << " in " << ddname2 << " at "
1058                                        << DDTranslation(xpos, ypos, zpos) << " rotation esalgo:RM1300A";
1059 #endif
1060           }
1061         }
1062       }
1063     }
1064   }
1065 
1066   // Positioning of ladders
1067 
1068   std::string type;
1069   int icopy[100] = {0};
1070 
1071   for (int I = -9; I <= 9; ++I) {
1072     prev_length_ = 0;
1073     int J = std::abs(I);
1074     for (int K = 0; K < noLaddInCol_[J]; K++) {
1075       std::string type;
1076 
1077       ladder_new_length_ = micromodule_length + 3 * waf_active;
1078       ladd_shift_ = 4 * waf_active;
1079 
1080       if (K == 0)
1081         type = typeOfLaddRow0[J];
1082       if (K == 1)
1083         type = typeOfLaddRow1[J];
1084       if (K == 2)
1085         type = typeOfLaddRow2[J];
1086       if (K == 3)
1087         type = typeOfLaddRow3[J];
1088 
1089       for (const auto& i : types_l5_)
1090         if (type == i) {
1091           ladder_new_length_ = micromodule_length + 4 * waf_active;
1092           ladd_shift_ = 5 * waf_active;
1093         }
1094 
1095       int j = 0;
1096 
1097       for (int t = 0; t < int(types_l5_.size()); t++)
1098         if (type == types_l5_[t]) {
1099           j = t;
1100           if (I < 0 && asym_ladd_[t] == 1) {
1101             j = j + 1;
1102             type = types_l5_[j];
1103           }
1104         }
1105       for (int t = 0; t < int(types_l4_.size()); t++)
1106         if (type == types_l4_[t]) {
1107           j = t + types_l5_.size();
1108           if (I < 0 && asym_ladd_[(t + types_l5_.size())] == 1) {
1109             j = j + 1;
1110             type = types_l4_[j - types_l5_.size()];
1111           }
1112         }
1113 
1114       xpos = I * (2 * waf_intra_col_sep + waf_inter_col_sep);
1115       if (I > 0)
1116         xpos = xpos + dee_separation;
1117       if (I < 0)
1118         xpos = xpos - dee_separation;
1119 
1120       int sz = 20;
1121       ypos = (sz - int(startOfFirstLadd_[J])) * waf_active - ladder_new_length_ / 2. +
1122              (LdrFrnt_Length - LdrBck_Length) / 2 + micromodule_length + 0.05 * cm - prev_length_;
1123 
1124       prev_length_ += ladd_shift_;
1125 
1126       zpos = zlead1_ + ladder_thick / 2. + 0.01 * mm;
1127       icopy[j] += 1;
1128       DDName ddname(getLadPrefix(0) + type, "esalgo");
1129 
1130       cpv.position(
1131           DDLogicalPart(ddname), DDName("SF", "esalgo"), icopy[j], DDTranslation(xpos, ypos, zpos), DDRotation());
1132 #ifdef EDM_ML_DEBUG
1133       edm::LogVerbatim("SFGeom") << DDLogicalPart(ddname).name() << " copy " << icopy[j] << " in "
1134                                  << DDName("SF", "esalgo") << " at " << DDTranslation(xpos, ypos, zpos)
1135                                  << " no rotation";
1136 #endif
1137       DDName ddname2(getLadPrefix(1) + type, "esalgo");
1138 
1139       xpos = I * (2 * waf_intra_col_sep + waf_inter_col_sep);
1140 
1141       cpv.position(DDLogicalPart(ddname2),
1142                    DDName("SF", "esalgo"),
1143                    icopy[j],
1144                    DDTranslation(ypos, -xpos, zpos - zlead1_ + zlead2_),
1145                    DDRotation("esalgo:R270"));
1146 #ifdef EDM_ML_DEBUG
1147       edm::LogVerbatim("SFGeom") << DDLogicalPart(ddname2).name() << " copy " << icopy[j] << " in "
1148                                  << DDName("SF", "esalgo") << " at "
1149                                  << DDTranslation(ypos, -xpos, zpos - zlead1_ + zlead2_) << " rotation esalgo:R270";
1150 #endif
1151       int changed = 0;
1152       for (int t = 0; t < int(types_l5_.size()); t++)
1153         if (type == types_l5_[t]) {
1154           j = t;
1155           if (asym_ladd_[t] == 2 && !changed) {
1156             j = j - 1;
1157             changed = 1;
1158           }
1159           if (asym_ladd_[t] == 1 && !changed) {
1160             j = j + 1;
1161             changed = 1;
1162           }
1163           type = types_l5_[j];
1164         }
1165       for (int t = 0; t < int(types_l4_.size()); t++)
1166         if (type == types_l4_[t]) {
1167           j = t + types_l5_.size();
1168           if (asym_ladd_[(t + types_l5_.size())] == 2 && !changed) {
1169             j = j - 1;
1170             changed = 1;
1171           }
1172           if (asym_ladd_[(t + types_l5_.size())] == 1 && !changed) {
1173             j = j + 1;
1174             changed = 1;
1175           }
1176           type = types_l4_[j - types_l5_.size()];
1177         }
1178 
1179       icopy[j] += 1;
1180 
1181       if (I > 0)
1182         xpos = xpos + dee_separation;
1183       if (I < 0)
1184         xpos = xpos - dee_separation;
1185 
1186       DDName ddname3(getLadPrefix(0) + type, "esalgo");
1187       cpv.position(DDLogicalPart(ddname3),
1188                    DDName("SF", "esalgo"),
1189                    icopy[j],
1190                    DDTranslation(xpos, -ypos, zpos),
1191                    DDRotation("esalgo:R180"));
1192 #ifdef EDM_ML_DEBUG
1193       edm::LogVerbatim("SFGeom") << DDLogicalPart(ddname3).name() << " copy " << icopy[j] << " in "
1194                                  << DDName("SF", "esalgo") << " at " << DDTranslation(xpos, -ypos, zpos)
1195                                  << " rotation esalgo:R180";
1196 #endif
1197       DDName ddname4(getLadPrefix(1) + type, "esalgo");
1198 
1199       xpos = I * (2 * waf_intra_col_sep + waf_inter_col_sep);
1200 
1201       cpv.position(DDLogicalPart(ddname4),
1202                    DDName("SF", "esalgo"),
1203                    icopy[j],
1204                    DDTranslation(-ypos, -xpos, zpos - zlead1_ + zlead2_),
1205                    DDRotation("esalgo:R090"));
1206 #ifdef EDM_ML_DEBUG
1207       edm::LogVerbatim("SFGeom") << DDLogicalPart(ddname4).name() << " copy " << icopy[j] << " in "
1208                                  << DDName("SF", "esalgo") << " at "
1209                                  << DDTranslation(-ypos, -xpos, zpos - zlead1_ + zlead2_) << " rotation esalgo:R090";
1210 #endif
1211     }
1212   }
1213 }
1214 
1215 void DDEcalPreshowerAlgo::doSens(DDCompactView& cpv) {
1216   double xpos(0), ypos(0);
1217   for (size_t i = 0; i < 32; ++i) {
1218     xpos = -waf_active / 2. + i * waf_active / 32. + waf_active / 64.;
1219     cpv.position(
1220         DDLogicalPart("esalgo:SFSX"), DDName("SFWX", "esalgo"), i + 1, DDTranslation(xpos, 0., 0.), DDRotation());
1221 #ifdef EDM_ML_DEBUG
1222     edm::LogVerbatim("SFGeom") << DDLogicalPart("esalgo:SFSX").name() << " copy " << (i + 1) << " in "
1223                                << DDName("SFWX", "esalgo") << " at " << DDTranslation(xpos, 0., 0.) << " no rotation";
1224 #endif
1225 
1226     ypos = -waf_active / 2. + i * waf_active / 32. + waf_active / 64.;
1227     cpv.position(
1228         DDLogicalPart("esalgo:SFSY"), DDName("SFWY", "esalgo"), i + 1, DDTranslation(0., ypos, 0.), DDRotation());
1229 #ifdef EDM_ML_DEBUG
1230     edm::LogVerbatim("SFGeom") << DDLogicalPart("esalgo:SFSY").name() << " copy " << (i + 1) << " in "
1231                                << DDName("SFWY", "esalgo") << " at " << DDTranslation(0., ypos, 0.) << " no rotation";
1232 #endif
1233   }
1234 }
1235 
1236 #include "DetectorDescription/Core/interface/DDAlgorithmFactory.h"
1237 
1238 DEFINE_EDM_PLUGIN(DDAlgorithmFactory, DDEcalPreshowerAlgo, "ecal:DDEcalPreshowerAlgo");