File indexing completed on 2024-04-06 12:14:32
0001 #include "DD4hep/DetFactoryHelper.h"
0002 #include "DetectorDescription/DDCMS/interface/DDPlugins.h"
0003 #include "DetectorDescription/DDCMS/interface/BenchmarkGrd.h"
0004 #include "DetectorDescription/DDCMS/interface/DDutils.h"
0005 #include "DataFormats/Math/interface/angle_units.h"
0006 #include "DD4hep/Shapes.h"
0007
0008 #include <string>
0009 #include <vector>
0010
0011 using namespace std;
0012 using namespace cms;
0013 using namespace dd4hep;
0014 using namespace angle_units::operators;
0015
0016
0017
0018 namespace {
0019
0020 struct EcalPreshower {
0021 vector<string> materials;
0022 vector<string> layName;
0023 vector<string> ladPfx;
0024 vector<string> typesL5;
0025 vector<string> typesL4;
0026 vector<string> typeOfLaddRow0;
0027 vector<string> typeOfLaddRow1;
0028 vector<string> typeOfLaddRow2;
0029 vector<string> typeOfLaddRow3;
0030
0031 vector<double> thickLayers;
0032 vector<double> abs1stx;
0033 vector<double> abs1sty;
0034 vector<double> abs2ndx;
0035 vector<double> abs2ndy;
0036 vector<double> asymLadd;
0037 vector<double> rminVec;
0038 vector<double> rmaxVec;
0039 vector<double> noLaddInCol;
0040 vector<double> startOfFirstLadd;
0041 vector<double> laddL5map;
0042 vector<double> laddL4map;
0043 string laddMaterial;
0044 double thickness;
0045
0046 double zlead1;
0047 double zlead2;
0048 double waf_intra_col_sep;
0049 double waf_inter_col_sep;
0050 double waf_active;
0051 double wedge_length;
0052 double wedge_offset;
0053 double zwedge_ceramic_diff;
0054 double ywedge_ceramic_diff;
0055 double wedge_angle;
0056 double box_thick;
0057 double dee_separation;
0058 double in_rad_Abs_Al;
0059 double in_rad_Abs_Pb;
0060 double ladder_thick;
0061 double ladder_width;
0062 double micromodule_length;
0063 double absAlX_X;
0064 double absAlX_Y;
0065 double absAlX_subtr1_Xshift;
0066 double absAlX_subtr1_Yshift;
0067 double rMax_Abs_Al;
0068 double absAlY_X;
0069 double absAlY_Y;
0070 double absAlY_subtr1_Xshift;
0071 double absAlY_subtr1_Yshift;
0072 double ldrBck_Length;
0073 double ldrFrnt_Length;
0074 double ldrFrnt_Offset;
0075 double ldrBck_Offset;
0076 double ceramic_length;
0077 double wedge_back_thick;
0078 };
0079 }
0080
0081 static long algorithm(dd4hep::Detector& , cms::DDParsingContext& ctxt, xml_h e) {
0082 BenchmarkGrd counter("DDEcalPreshowerAlgo");
0083 cms::DDNamespace ns(ctxt, e, true);
0084 cms::DDAlgoArguments args(ctxt, e);
0085
0086 Volume parentVolume = ns.volume(args.parentName());
0087 Volume swedLog = ns.volume("esalgo:SWED");
0088 Volume sfLog = ns.volume("esalgo:SF");
0089 Volume sfbxLog = ns.volume("esalgo:SFBX");
0090 Volume sfbyLog = ns.volume("esalgo:SFBY");
0091
0092 EcalPreshower es;
0093 es.asymLadd = args.vecDble("ASYMETRIC_LADDER");
0094 es.typesL5 = args.vecStr("TYPES_OF_LADD_L5");
0095 es.typesL4 = args.vecStr("TYPES_OF_LADD_L4");
0096 es.laddL5map = args.vecDble("LADD_L5_MAP");
0097 es.laddL4map = args.vecDble("LADD_L4_MAP");
0098 es.noLaddInCol = args.vecDble("NUMB_OF_LADD_IN_COL");
0099 es.startOfFirstLadd = args.vecDble("START_OF_1ST_LADD");
0100 es.typeOfLaddRow0 = args.vecStr("TYPE_OF_LADD_1");
0101 es.typeOfLaddRow1 = args.vecStr("TYPE_OF_LADD_2");
0102 es.typeOfLaddRow2 = args.vecStr("TYPE_OF_LADD_3");
0103 es.typeOfLaddRow3 = args.vecStr("TYPE_OF_LADD_4");
0104 es.thickLayers = args.vecDble("Layers");
0105 es.thickness = args.dble("PRESH_Z_TOTAL");
0106 es.materials = args.vecStr("LayMat");
0107 es.layName = args.vecStr("LayName");
0108 es.rmaxVec = args.vecDble("R_MAX");
0109 es.rminVec = args.vecDble("R_MIN");
0110 es.waf_intra_col_sep = args.dble("waf_intra_col_sep");
0111 es.waf_inter_col_sep = args.dble("waf_inter_col_sep");
0112 es.waf_active = args.dble("waf_active");
0113 es.wedge_length = args.dble("wedge_length");
0114 es.wedge_offset = args.dble("wedge_offset");
0115 es.zwedge_ceramic_diff = args.dble("zwedge_ceramic_diff");
0116 es.ywedge_ceramic_diff = args.dble("ywedge_ceramic_diff");
0117 es.ceramic_length = args.dble("ceramic_length");
0118 es.wedge_angle = args.dble("wedge_angle");
0119 es.wedge_back_thick = args.dble("wedge_back_thick");
0120 es.ladder_thick = args.dble("ladder_thick");
0121 es.ladder_width = args.dble("ladder_width");
0122 es.micromodule_length = args.dble("micromodule_length");
0123 es.box_thick = args.dble("box_thick");
0124 es.abs1stx = args.vecDble("1ST_ABSX");
0125 es.abs1sty = args.vecDble("1ST_ABSY");
0126 es.abs2ndx = args.vecDble("2ND_ABSX");
0127 es.abs2ndy = args.vecDble("2ND_ABSY");
0128 es.ladPfx = args.vecStr("LadPrefix");
0129 es.laddMaterial = args.str("LadderMaterial");
0130 es.ldrFrnt_Length = args.dble("LdrFrnt_Length");
0131 es.ldrFrnt_Offset = args.dble("LdrFrnt_Offset");
0132 es.ldrBck_Length = args.dble("LdrBck_Length");
0133 es.ldrBck_Offset = args.dble("LdrBck_Offset");
0134 es.dee_separation = args.dble("dee_sep");
0135 es.in_rad_Abs_Al = args.dble("R_MIN_Abs_Al");
0136 es.in_rad_Abs_Pb = args.dble("R_MIN_Abs_Pb");
0137 es.rMax_Abs_Al = args.dble("R_MAX_Abs_Al");
0138 es.absAlX_X = args.dble("AbsAlX_X");
0139 es.absAlX_Y = args.dble("AbsAlX_Y");
0140 es.absAlX_subtr1_Xshift = args.dble("AbsAlX_subtr1_Xshift");
0141 es.absAlX_subtr1_Yshift = args.dble("AbsAlX_subtr1_Yshift");
0142 es.absAlY_X = args.dble("AbsAlY_X");
0143 es.absAlY_Y = args.dble("AbsAlY_Y");
0144 es.absAlY_subtr1_Xshift = args.dble("AbsAlY_subtr1_Xshift");
0145 es.absAlY_subtr1_Yshift = args.dble("AbsAlY_subtr1_Yshift");
0146
0147
0148 {
0149 double zpos = -es.thickness / 2., sdx(0), sdy(0), bdx(0), bdy(0);
0150
0151 for (size_t i = 0; i < es.thickLayers.size(); ++i) {
0152 int I = int(i) + 1;
0153
0154 double rIn(0), rOut(0), zHalf(0);
0155
0156
0157 const string& ddname("esalgo:" + es.layName[i]);
0158
0159
0160 rIn = es.rminVec[i];
0161 rOut = es.rmaxVec[i];
0162 zHalf = es.thickLayers[i] / 2.;
0163
0164
0165 zpos += zHalf;
0166
0167
0168 if (I == 2 || I == 28 || I == 13 || I == 23) {
0169 zpos += zHalf;
0170 continue;
0171 }
0172
0173 Solid solid = ns.addSolid(ddname, Tube(ddname, rIn, rOut, zHalf, 0., 360._deg));
0174 #ifdef EDM_ML_DEBUG
0175 edm::LogVerbatim("SFGeomX") << ddname << " Tubs " << cms::convert2mm(zHalf) << ":" << cms::convert2mm(rIn) << ":"
0176 << cms::convert2mm(rOut) << ":0:360";
0177 #endif
0178 Volume layer = ns.addVolume(Volume(ddname, solid, ns.material(es.materials[i])));
0179
0180 if (I == 12) {
0181 es.zlead1 = zpos + zHalf;
0182 }
0183 if (I == 22) {
0184 es.zlead2 = zpos + zHalf;
0185 }
0186
0187 if (I == 10 || I == 20) {
0188 for (int step = 0; step < 2; ++step) {
0189 int absz = 0;
0190 double outalbx, outalby, shiftR, outalbx2, outalby2, shiftR2;
0191
0192 absz = int(es.abs1stx.size());
0193 if (I == 20)
0194 absz = int(es.abs2ndx.size());
0195 int cutabsx = -1;
0196 int cutabsy = -1;
0197
0198 const string& dd_tmp_name_b("esalgo:" + es.layName[i] + "Lcut");
0199 const string& dd_tmp_name_c("esalgo:" + es.layName[i] + "tmpb");
0200 const string& dd_tmp_name_d("esalgo:" + es.layName[i] + "LinPb");
0201 const string& dd_tmp_name_e("esalgo:" + es.layName[i] + "LinAl");
0202 const string& dd_tmp_name_f("esalgo:" + es.layName[i] + "LOutAlVol");
0203 ostringstream tmp_Alname_fin;
0204 tmp_Alname_fin << es.layName[i] << "LtmpAl" << absz - 1;
0205 string dd_Alname_fin("esalgo:" + tmp_Alname_fin.str());
0206
0207 const string& dd_Alname_f("esalgo:" + es.layName[i] + "LOutAl");
0208 const string& dd_Alname_g("esalgo:" + es.layName[i] + "LOutAl2");
0209 const string& dd_Alname_h("esalgo:" + es.layName[i] + "LOutAltmp");
0210 const string& dd_Alname_i("esalgo:" + es.layName[i] + "LOutAltmp2");
0211 const string& dd_Alname_j("esalgo:" + es.layName[i] + "LOutAltmp3");
0212 const string& dd_Alname_k("esalgo:" + es.layName[i] + "LOutAltmp4");
0213 const string& dd_Alname_l("esalgo:" + es.layName[i] + "LOutAltmp5");
0214 const string& dd_Alname_m("esalgo:" + es.layName[i] + "LOutAltmp6");
0215
0216 if (step == 0) {
0217 Solid outAl = ns.addSolid(dd_Alname_f,
0218 Tube(dd_Alname_f,
0219 es.rMax_Abs_Al - 20 * dd4hep::cm,
0220 es.rMax_Abs_Al,
0221 zHalf - 0.1 * dd4hep::mm,
0222 0.,
0223 90._deg));
0224 #ifdef EDM_ML_DEBUG
0225 edm::LogVerbatim("SFGeomX") << dd_Alname_f << " Tubs " << cms::convert2mm(zHalf - 0.1 * dd4hep::mm) << ":"
0226 << cms::convert2mm(es.rMax_Abs_Al - 20 * dd4hep::cm) << ":"
0227 << cms::convert2mm(es.rMax_Abs_Al) << ":0:90";
0228 #endif
0229
0230 outalbx = es.absAlX_X * 0.1;
0231 outalby = es.rMax_Abs_Al + 0.1 * dd4hep::mm - es.absAlX_subtr1_Yshift;
0232 shiftR = es.absAlX_subtr1_Yshift;
0233 if (I == 20) {
0234 outalbx = es.absAlY_X * 0.1;
0235 outalby = es.rMax_Abs_Al + 0.1 * dd4hep::mm - es.absAlY_subtr1_Yshift;
0236 shiftR = es.absAlY_subtr1_Xshift;
0237 }
0238 Solid outAltmp = ns.addSolid(dd_Alname_h,
0239 Box(dd_Alname_h,
0240 outalbx / 2. + 0.1 * dd4hep::mm,
0241 outalby / 2. + 0.1 * dd4hep::mm,
0242 zHalf + 0.1 * dd4hep::mm));
0243 Solid outAltmp3 = ns.addSolid(
0244 dd_Alname_j,
0245 SubtractionSolid(dd_Alname_j, outAl, outAltmp, Position(outalbx / 2., outalby / 2. + shiftR, 0)));
0246 #ifdef EDM_ML_DEBUG
0247 edm::LogVerbatim("SFGeomX") << dd_Alname_h << " Box " << cms::convert2mm(outalbx / 2. + 0.1 * dd4hep::mm)
0248 << ":" << cms::convert2mm(outalby / 2. + 0.1 * dd4hep::mm) << ":"
0249 << cms::convert2mm(zHalf);
0250 edm::LogVerbatim("SFGeomX") << dd_Alname_j << " Subtraction " << outAl.name() << ":" << outAltmp.name()
0251 << " at (" << cms::convert2mm(outalbx / 2.) << ","
0252 << cms::convert2mm(outalby / 2. + shiftR) << ","
0253 << "0) no rotation";
0254 #endif
0255
0256 outalby2 = es.absAlX_Y * 0.1;
0257 outalbx2 = es.rMax_Abs_Al + 0.1 * dd4hep::mm - es.absAlX_subtr1_Xshift;
0258 shiftR2 = es.absAlX_subtr1_Xshift;
0259 if (I == 20) {
0260 outalby2 = es.absAlY_Y * 0.1;
0261 outalbx2 = es.rMax_Abs_Al + 0.1 * dd4hep::mm - es.absAlY_subtr1_Xshift;
0262 shiftR2 = es.absAlY_subtr1_Xshift;
0263 }
0264 Solid outAltmp2 = ns.addSolid(
0265 dd_Alname_i,
0266 Box(dd_Alname_i, outalbx2 / 2. + 0.1 * dd4hep::mm, outalby2 / 2. + 0.1 * dd4hep::mm, zHalf));
0267 Solid outAltmp4 = ns.addSolid(
0268 dd_Alname_k,
0269 SubtractionSolid(
0270 dd_Alname_k, outAltmp3, outAltmp2, Position(outalbx2 / 2. + shiftR2, outalby2 / 2., 0)));
0271 Solid outAltmp5 =
0272 ns.addSolid(dd_Alname_l, UnionSolid(dd_Alname_l, outAltmp4, outAltmp4, ns.rotation("esalgo:RABS90")));
0273 Solid outAltmp6 =
0274 ns.addSolid(dd_Alname_m, UnionSolid(dd_Alname_m, outAltmp5, outAltmp4, ns.rotation("esalgo:RABS180B")));
0275 ns.addSolid(dd_Alname_g, UnionSolid(dd_Alname_g, outAltmp6, outAltmp4, ns.rotation("esalgo:R180")));
0276
0277 #ifdef EDM_ML_DEBUG
0278 edm::LogVerbatim("SFGeomX") << dd_Alname_i << " Box " << cms::convert2mm(outalbx2 / 2. + 0.1 * dd4hep::mm)
0279 << ":" << cms::convert2mm(outalby2 / 2. + 0.1 * dd4hep::mm) << ":"
0280 << cms::convert2mm(zHalf);
0281 edm::LogVerbatim("SFGeomX") << dd_Alname_k << " Subtraction " << outAltmp3.name() << ":" << outAltmp2.name()
0282 << " at (" << cms::convert2mm(outalbx2 / 2. + shiftR2) << ","
0283 << cms::convert2mm(outalby2 / 2) << ",0) no rotation";
0284 edm::LogVerbatim("SFGeomX") << dd_Alname_l << " Union " << outAltmp4.name() << ":" << outAltmp4.name()
0285 << " at (0,0,0) rotation esalgo:RABS90";
0286 edm::LogVerbatim("SFGeomX") << dd_Alname_m << " Union " << outAltmp5.name() << ":" << outAltmp4.name()
0287 << " at (0,0,0) rotation esalgo:RABS180B";
0288 edm::LogVerbatim("SFGeomX") << dd_Alname_g << " Union " << outAltmp6.name() << ":" << outAltmp4.name()
0289 << " at (0,0,0) rotation esalgo:R180";
0290 #endif
0291 } else {
0292 Solid Outer_Al = ns.solid(dd_Alname_fin);
0293 ns.addVolumeNS(Volume(dd_tmp_name_f, Outer_Al, ns.material(es.materials[i - 1])));
0294 }
0295
0296 for (int L = 0; L < absz; ++L) {
0297 int K = L;
0298 ostringstream tmp_name_b, tmp_name_b2, tmp_FAl_name_c, tmp_FAl_name_d1, tmp_FAl_name_d2, tmp_FAl_name_d3,
0299 tmp_FAl_name_d;
0300 tmp_name_b << es.layName[i] << "L" << K;
0301 tmp_name_b2 << es.layName[i] << "Lb2" << K;
0302
0303 if (L == 0)
0304 tmp_FAl_name_c << es.layName[i] << "LOutAl2";
0305 if (L > 0)
0306 tmp_FAl_name_c << es.layName[i] << "LtmpAl" << K - 1;
0307
0308 tmp_FAl_name_d1 << es.layName[i] << "LtmpAl" << K << "_1";
0309 tmp_FAl_name_d2 << es.layName[i] << "LtmpAl" << K << "_2";
0310 tmp_FAl_name_d3 << es.layName[i] << "LtmpAl" << K << "_3";
0311 tmp_FAl_name_d << es.layName[i] << "LtmpAl" << K;
0312
0313 const string& dd_tmp_name_b("esalgo:" + tmp_name_b.str());
0314 const string& dd_tmp_name_b2("esalgo:" + tmp_name_b2.str());
0315 const string& dd_FAl_name_c("esalgo:" + tmp_FAl_name_c.str());
0316 const string& dd_FAl_name_d1("esalgo:" + tmp_FAl_name_d1.str());
0317 const string& dd_FAl_name_d2("esalgo:" + tmp_FAl_name_d2.str());
0318 const string& dd_FAl_name_d3("esalgo:" + tmp_FAl_name_d3.str());
0319 const string& dd_FAl_name_d("esalgo:" + tmp_FAl_name_d.str());
0320
0321 if (L == 0)
0322 bdx = abs(es.abs1stx[K]) / 2.;
0323 if (L > 0)
0324 bdx = abs(es.abs1stx[K] - es.abs1stx[K - 1]) / 2.;
0325 bdy = es.abs1sty[K];
0326 if (es.abs1stx[K] < rIn + 30 * dd4hep::cm) {
0327 bdy = es.abs1sty[K] / 2. - 30 * dd4hep::cm;
0328 cutabsx = K;
0329 }
0330
0331 if (I == 20) {
0332 if (L == 0)
0333 bdx = abs(es.abs2ndx[K]) / 2.;
0334 if (L > 0)
0335 bdx = abs(es.abs2ndx[K] - es.abs2ndx[K - 1]) / 2.;
0336 bdy = es.abs2ndy[K];
0337 }
0338
0339 if ((es.abs2ndx[K] < rIn + 30 * dd4hep::cm) && I == 20) {
0340 bdy = es.abs2ndy[K] / 2. - 30 * dd4hep::cm;
0341 cutabsy = K;
0342 }
0343 sdx = es.abs1stx[K] - bdx;
0344 sdy = 0;
0345 if (es.abs1stx[K] < rIn + 30 * dd4hep::cm)
0346 sdy = es.abs1sty[K] - bdy;
0347
0348 if (I == 20) {
0349 sdx = es.abs2ndx[K] - bdx;
0350 sdy = 0;
0351 }
0352 if ((es.abs2ndx[K] < rIn + 30 * dd4hep::cm) && I == 20)
0353 sdy = es.abs2ndy[K] - bdy;
0354
0355 if (step == 1) {
0356 Solid solid_b = Box(dd_tmp_name_b, bdx, bdy, zHalf);
0357 Volume layerb = ns.addVolumeNS(Volume(dd_tmp_name_b, solid_b, ns.material(es.materials[i])));
0358
0359 const Volume& layerFinOutAl = ns.volume(dd_tmp_name_f);
0360 layerFinOutAl.placeVolume(layerb, 1, Position(sdx, sdy, 0));
0361 layerFinOutAl.placeVolume(layerb, 2, Position(-sdx, sdy, 0));
0362 #ifdef EDM_ML_DEBUG
0363 edm::LogVerbatim("SFGeomX") << dd_tmp_name_b << " Box " << cms::convert2mm(bdx) << ":"
0364 << cms::convert2mm(bdy) << ":" << cms::convert2mm(zHalf);
0365 edm::LogVerbatim("SFGeom") << layerb.name() << " copy 1 in " << layerFinOutAl.name() << " at ("
0366 << cms::convert2mm(sdx) << "," << cms::convert2mm(sdy) << ",0) no rotation";
0367 edm::LogVerbatim("SFGeom") << layerb.name() << " copy 2 in " << layerFinOutAl.name() << " at ("
0368 << -cms::convert2mm(sdx) << "," << cms::convert2mm(sdy) << ",0) no rotation";
0369 #endif
0370
0371 } else {
0372 Solid solid_b2 = ns.addSolid(dd_tmp_name_b2,
0373 Box(dd_tmp_name_b2, bdx + 0.1 * dd4hep::mm, bdy + 0.1 * dd4hep::mm, zHalf));
0374 Solid solid_c = ns.solid(dd_FAl_name_c);
0375 ns.addSolid(dd_FAl_name_d1, UnionSolid(dd_FAl_name_d1, solid_c, solid_b2, Position(sdx, sdy, 0)));
0376 #ifdef EDM_ML_DEBUG
0377 edm::LogVerbatim("SFGeomX") << dd_tmp_name_b2 << " Box " << cms::convert2mm(bdx + 0.1 * dd4hep::mm) << ":"
0378 << cms::convert2mm(bdy + 0.1 * dd4hep::mm) << ":" << cms::convert2mm(zHalf);
0379 edm::LogVerbatim("SFGeomX")
0380 << dd_FAl_name_d1 << " Union " << solid_c.name() << ":" << solid_b2.name() << " at ("
0381 << cms::convert2mm(sdx) << "," << cms::convert2mm(sdy) << ",0) no rotation";
0382 #endif
0383 }
0384 if (((es.abs1stx[K] < rIn + 30 * dd4hep::cm) && I == 10) ||
0385 ((es.abs2ndx[K] < rIn + 30 * dd4hep::cm) && I == 20)) {
0386 if (step == 1) {
0387 const Volume& layerb = ns.volume(dd_tmp_name_b);
0388 const Volume& layerFinOutAl = ns.volume(dd_tmp_name_f);
0389 layerFinOutAl.placeVolume(layerb, 3, Position(sdx, -sdy, 0));
0390 layerFinOutAl.placeVolume(layerb, 4, Position(-sdx, -sdy, 0));
0391 #ifdef EDM_ML_DEBUG
0392 edm::LogVerbatim("SFGeom") << layerb.name() << " copy 3 in " << layerFinOutAl.name() << " at ("
0393 << cms::convert2mm(sdx) << "," << -cms::convert2mm(sdy) << ",0) no rotation";
0394 edm::LogVerbatim("SFGeom")
0395 << layerb.name() << " copy 4 in " << layerFinOutAl.name() << " at (" << -cms::convert2mm(sdx) << ","
0396 << -cms::convert2mm(sdy) << ",0) no rotation";
0397 #endif
0398
0399 } else {
0400 const Solid& solid_d1 = ns.solid(dd_FAl_name_d1);
0401 const Solid& solid_b2 = ns.solid(dd_tmp_name_b2);
0402 Solid solid_d2 =
0403 ns.addSolid(dd_FAl_name_d2, UnionSolid(dd_FAl_name_d2, solid_d1, solid_b2, Position(sdx, -sdy, 0)));
0404 Solid solid_d3 = UnionSolid(dd_FAl_name_d3, solid_d2, solid_b2, Position(-sdx, sdy, 0));
0405 ns.addSolid(dd_FAl_name_d, UnionSolid(dd_FAl_name_d, solid_d3, solid_b2, Position(-sdx, -sdy, 0)));
0406 #ifdef EDM_ML_DEBUG
0407 edm::LogVerbatim("SFGeomX")
0408 << dd_FAl_name_d2 << " Union " << solid_d1.name() << ":" << solid_b2.name() << " at ("
0409 << cms::convert2mm(sdx) << "," << -cms::convert2mm(sdy) << ",0) no rotation";
0410 edm::LogVerbatim("SFGeomX")
0411 << dd_FAl_name_d3 << " Union " << solid_d2.name() << ":" << solid_b2.name() << " at ("
0412 << -cms::convert2mm(sdx) << "," << cms::convert2mm(sdy) << ",0) no rotation";
0413 edm::LogVerbatim("SFGeomX")
0414 << dd_FAl_name_d << " Union " << solid_d3.name() << ":" << solid_b2.name() << " at ("
0415 << -cms::convert2mm(sdx) << "," << -cms::convert2mm(sdy) << ",0) no rotation";
0416 #endif
0417 }
0418 } else if (step == 0) {
0419 const Solid& solid_d1 = ns.solid(dd_FAl_name_d1);
0420 const Solid& solid_b2 = ns.solid(dd_tmp_name_b2);
0421 ns.addSolid(dd_FAl_name_d, UnionSolid(dd_FAl_name_d, solid_d1, solid_b2, Position(-sdx, -sdy, 0)));
0422 }
0423 }
0424
0425 bdx = es.abs1stx[cutabsx];
0426 if (I == 20)
0427 bdx = es.abs2ndx[cutabsy];
0428 bdy = 2 * 30 * dd4hep::cm;
0429
0430 if (step == 1) {
0431 Solid solidcut = Box(dd_tmp_name_b, bdx, bdy, zHalf);
0432 Solid iner = Tube(dd_tmp_name_c, 0, es.in_rad_Abs_Pb, zHalf + 0.1 * dd4hep::mm, 0., 360._deg);
0433 Solid final = SubtractionSolid(dd_tmp_name_d, solidcut, iner);
0434 #ifdef EDM_ML_DEBUG
0435 edm::LogVerbatim("SFGeomX") << dd_tmp_name_b << " Box " << cms::convert2mm(bdx) << ":"
0436 << cms::convert2mm(bdy) << ":" << cms::convert2mm(zHalf);
0437 edm::LogVerbatim("SFGeomX") << dd_tmp_name_c << " Tubs " << cms::convert2mm(zHalf + 0.1 * dd4hep::mm)
0438 << ":0:" << cms::convert2mm(es.in_rad_Abs_Pb) << ":0:360";
0439 edm::LogVerbatim("SFGeomX") << dd_tmp_name_d << " Subtraction " << solidcut.name() << ":" << iner.name()
0440 << " at (0,0,0) no rotation";
0441 #endif
0442
0443 Volume blayer = Volume(dd_tmp_name_d, final, ns.material(es.materials[i]));
0444 parentVolume.placeVolume(blayer, 1, Position(0, 0, zpos));
0445 #ifdef EDM_ML_DEBUG
0446 edm::LogVerbatim("SFGeom") << blayer.name() << " copy 1 in " << parentVolume.name() << " at (0,0,"
0447 << cms::convert2mm(zpos) << ") no rotation";
0448 #endif
0449
0450 Solid iner_Al =
0451 Tube(dd_tmp_name_e, es.in_rad_Abs_Al, es.in_rad_Abs_Pb - 0.01 * dd4hep::mm, zHalf, 0., 360._deg);
0452 #ifdef EDM_ML_DEBUG
0453 edm::LogVerbatim("SFGeomX") << dd_tmp_name_e << " Tubs " << cms::convert2mm(zHalf) << ":"
0454 << cms::convert2mm(es.in_rad_Abs_Al) << ":"
0455 << cms::convert2mm(es.in_rad_Abs_Pb - 0.01 * dd4hep::mm) << ":0:360";
0456 #endif
0457 Volume layerAl = Volume(dd_tmp_name_e, iner_Al, ns.material(es.materials[i - 1]));
0458 parentVolume.placeVolume(layerAl, 1, Position(0, 0, zpos));
0459 const Volume& layerFinOutAl = ns.volume(dd_tmp_name_f);
0460 parentVolume.placeVolume(layerFinOutAl, 1, Position(0, 0, zpos));
0461 #ifdef EDM_ML_DEBUG
0462 edm::LogVerbatim("SFGeom") << layerAl.name() << " copy 1 in " << parentVolume.name() << " at (0,0,"
0463 << cms::convert2mm(zpos) << ") no rotation";
0464 edm::LogVerbatim("SFGeom") << layerFinOutAl.name() << " copy 1 in " << parentVolume.name() << " at (0,0,"
0465 << cms::convert2mm(zpos) << ") no rotation";
0466 #endif
0467 }
0468 }
0469 } else {
0470 parentVolume.placeVolume(layer, 1, Position(0., 0., zpos));
0471 #ifdef EDM_ML_DEBUG
0472 edm::LogVerbatim("SFGeom") << layer.name() << " copy 1 in " << parentVolume.name() << " at (0,0,"
0473 << cms::convert2mm(zpos) << ") no rotation";
0474 #endif
0475 }
0476 zpos += zHalf;
0477 }
0478 }
0479
0480 {
0481 double xpos(0.), ypos(0.), zpos(0.);
0482 double prev_length(0.), ladder_new_length(0.);
0483 double ladd_shift(0.);
0484 double ladder_length(0.);
0485 int swed_scopy_glob(0);
0486
0487 for (int M = 0; M < int(es.typesL5.size() + es.typesL4.size()); M++) {
0488 int scopy(0);
0489 int ladd_not_plain(0), ladd_subtr_no(0), ladd_upper(0);
0490
0491
0492
0493 if (M < int(es.typesL5.size())) {
0494 for (int i = 0; i <= 1; i++) {
0495 for (int j = 0; j <= 3; j++) {
0496 if (es.laddL5map[(i + j * 2 + M * 10)] != 1) {
0497 ladd_not_plain = 1;
0498 ladd_subtr_no++;
0499 if (j > 1)
0500 ladd_upper = 1;
0501 }
0502 }
0503 }
0504 #ifdef EDM_ML_DEBUG
0505 edm::LogVerbatim("SFGeomX") << "Side "
0506 << ":" << ladd_upper << ":" << ladd_subtr_no << ":" << ladd_not_plain << " Index "
0507 << M << ":" << es.typesL5.size();
0508 #endif
0509 const string& ddname("esalgo:" + es.ladPfx[0] + es.typesL5[M]);
0510 ladder_length = es.micromodule_length + 4 * es.waf_active + 0.1 * dd4hep::mm;
0511
0512 if (ladd_not_plain) {
0513 if (!ladd_upper) {
0514 ns.addAssembly(ddname);
0515 ns.addAssembly("esalgo:" + es.ladPfx[1] + es.typesL5[M]);
0516 }
0517 }
0518 else {
0519 ns.addAssembly(ddname);
0520 ns.addAssembly("esalgo:" + es.ladPfx[1] + es.typesL5[M]);
0521 }
0522 }
0523
0524
0525
0526 if (M >= int(es.typesL5.size())) {
0527 int d = M - es.typesL5.size();
0528
0529 for (int i = 0; i <= 1; i++) {
0530 for (int j = 0; j <= 3; j++) {
0531 if (es.laddL4map[(i + j * 2 + (M - es.typesL5.size()) * 8)] != 1) {
0532 ladd_not_plain = 1;
0533 ladd_subtr_no++;
0534 if (j > 1)
0535 ladd_upper = 1;
0536 }
0537 }
0538 }
0539 #ifdef EDM_ML_DEBUG
0540 edm::LogVerbatim("SFGeomX") << "Side "
0541 << ":" << ladd_upper << ":" << ladd_subtr_no << ":" << ladd_not_plain << " Index "
0542 << M << ":" << es.typesL5.size();
0543 #endif
0544 const string& ddname("esalgo:" + es.ladPfx[0] + es.typesL4[d]);
0545 ladder_length = es.micromodule_length + 3 * es.waf_active + 0.1 * dd4hep::mm;
0546
0547 if (ladd_not_plain) {
0548 if (ladd_upper) {
0549 ns.addAssembly(ddname);
0550 ns.addAssembly("esalgo:" + es.ladPfx[1] + es.typesL4[d]);
0551 }
0552 else {
0553 if (ladd_subtr_no > 1) {
0554 ns.addAssembly(ddname);
0555 ns.addAssembly("esalgo:" + es.ladPfx[1] + es.typesL4[d]);
0556 } else {
0557 ns.addAssembly(ddname);
0558 ns.addAssembly("esalgo:" + es.ladPfx[1] + es.typesL4[d]);
0559 }
0560 }
0561 }
0562 else {
0563 ns.addAssembly(ddname);
0564 ns.addAssembly("esalgo:" + es.ladPfx[1] + es.typesL4[d]);
0565 }
0566 }
0567
0568
0569 swed_scopy_glob++;
0570 if (M < int(es.typesL5.size())) {
0571 const string& ddname("esalgo:" + es.ladPfx[0] + es.typesL5[M]);
0572 const string& ddname2("esalgo:" + es.ladPfx[1] + es.typesL5[M]);
0573 for (int i = 0; i <= 1; i++) {
0574 for (int j = 0; j <= 4; j++) {
0575 xpos = (i * 2 - 1) * es.waf_intra_col_sep / 2.;
0576 ypos = -ladder_length / 2. + 0.05 * dd4hep::mm - (es.ldrFrnt_Length - es.ldrBck_Length) / 2. +
0577 es.wedge_length / 2. + j * es.waf_active;
0578 zpos = -es.ladder_thick / 2. + 0.005 * dd4hep::mm + es.wedge_offset;
0579 if (es.laddL5map[(i + j * 2 + M * 10)] == 1) {
0580 scopy++;
0581 ns.assembly(ddname).placeVolume(swedLog,
0582 scopy + 1000 * swed_scopy_glob,
0583 Transform3D(ns.rotation("esalgo:RM1299"), Position(xpos, ypos, zpos)));
0584 ns.assembly(ddname2).placeVolume(swedLog,
0585 scopy + 1000 * swed_scopy_glob + 100,
0586 Transform3D(ns.rotation("esalgo:RM1299"), Position(xpos, ypos, zpos)));
0587 #ifdef EDM_ML_DEBUG
0588 edm::LogVerbatim("SFGeom") << swedLog.name() << " copy " << (scopy + 1000 * swed_scopy_glob) << " in "
0589 << ddname << " at (" << cms::convert2mm(xpos) << "," << cms::convert2mm(ypos)
0590 << "," << cms::convert2mm(zpos) << ") rotation esalgo:RM1299";
0591 edm::LogVerbatim("SFGeom") << swedLog.name() << " copy " << (scopy + 1000 * swed_scopy_glob + 100)
0592 << " in " << ddname2 << " at (" << cms::convert2mm(xpos) << ","
0593 << cms::convert2mm(ypos) << "," << cms::convert2mm(zpos)
0594 << ") rotation esalgo:RM1299";
0595 #endif
0596
0597 ypos = ypos + es.ywedge_ceramic_diff;
0598 zpos = -es.ladder_thick / 2. + 0.005 * dd4hep::mm + es.zwedge_ceramic_diff;
0599 ns.assembly(ddname).placeVolume(sfbxLog,
0600 scopy + 1000 * swed_scopy_glob,
0601 Transform3D(ns.rotation("esalgo:RM1298"), Position(xpos, ypos, zpos)));
0602 ns.assembly(ddname2).placeVolume(sfbyLog,
0603 scopy + 1000 * swed_scopy_glob,
0604 Transform3D(ns.rotation("esalgo:RM1300A"), Position(xpos, ypos, zpos)));
0605 #ifdef EDM_ML_DEBUG
0606 edm::LogVerbatim("SFGeom") << sfbxLog.name() << " copy " << (scopy + 1000 * swed_scopy_glob) << " in "
0607 << ddname << " at (" << cms::convert2mm(xpos) << "," << cms::convert2mm(ypos)
0608 << "," << cms::convert2mm(zpos) << ") rotation esalgo:RM1298";
0609 edm::LogVerbatim("SFGeom") << sfbyLog.name() << " copy " << (scopy + 1000 * swed_scopy_glob) << " in "
0610 << ddname2 << " at (" << cms::convert2mm(xpos) << "," << cms::convert2mm(ypos)
0611 << "," << cms::convert2mm(zpos) << ") rotation esalgo:RM1300A";
0612 #endif
0613 }
0614 }
0615 }
0616 } else {
0617 int d = M - es.typesL5.size();
0618 const string& ddname("esalgo:" + es.ladPfx[0] + es.typesL4[d]);
0619 const string& ddname2("esalgo:" + es.ladPfx[1] + es.typesL4[d]);
0620 for (int i = 0; i <= 1; i++) {
0621 for (int j = 0; j <= 3; j++) {
0622 xpos = (i * 2 - 1) * es.waf_intra_col_sep / 2.;
0623 ypos = -ladder_length / 2. + 0.05 * dd4hep::mm - (es.ldrFrnt_Length - es.ldrBck_Length) / 2. +
0624 es.wedge_length / 2. + j * es.waf_active;
0625 zpos = -es.ladder_thick / 2. + 0.005 * dd4hep::mm + es.wedge_offset;
0626 if (es.laddL4map[(i + j * 2 + (M - es.typesL5.size()) * 8)] == 1) {
0627 scopy++;
0628 ns.assembly(ddname).placeVolume(swedLog,
0629 scopy + 1000 * swed_scopy_glob,
0630 Transform3D(ns.rotation("esalgo:RM1299"), Position(xpos, ypos, zpos)));
0631 ns.assembly(ddname2).placeVolume(swedLog,
0632 scopy + 1000 * swed_scopy_glob + 100,
0633 Transform3D(ns.rotation("esalgo:RM1299"), Position(xpos, ypos, zpos)));
0634 #ifdef EDM_ML_DEBUG
0635 edm::LogVerbatim("SFGeom") << swedLog.name() << " copy " << (scopy + 1000 * swed_scopy_glob) << " in "
0636 << ddname << " at (" << cms::convert2mm(xpos) << "," << cms::convert2mm(ypos)
0637 << "," << cms::convert2mm(zpos) << ") rotation esalgo:RM1299";
0638 edm::LogVerbatim("SFGeom") << swedLog.name() << " copy " << (scopy + 1000 * swed_scopy_glob + 100)
0639 << " in " << ddname2 << " at (" << cms::convert2mm(xpos) << ","
0640 << cms::convert2mm(ypos) << "," << cms::convert2mm(zpos)
0641 << ") rotation esalgo:RM1299";
0642 #endif
0643
0644 ypos = ypos + es.ywedge_ceramic_diff;
0645 zpos = -es.ladder_thick / 2. + 0.005 * dd4hep::mm + es.zwedge_ceramic_diff;
0646 ns.assembly(ddname).placeVolume(sfbxLog,
0647 scopy + 1000 * swed_scopy_glob,
0648 Transform3D(ns.rotation("esalgo:RM1298"), Position(xpos, ypos, zpos)));
0649 ns.assembly(ddname2).placeVolume(sfbyLog,
0650 scopy + 1000 * swed_scopy_glob,
0651 Transform3D(ns.rotation("esalgo:RM1300A"), Position(xpos, ypos, zpos)));
0652 #ifdef EDM_ML_DEBUG
0653 edm::LogVerbatim("SFGeom") << sfbxLog.name() << " copy " << (scopy + 1000 * swed_scopy_glob) << " in "
0654 << ddname << " at (" << cms::convert2mm(xpos) << "," << cms::convert2mm(ypos)
0655 << "," << cms::convert2mm(zpos) << ") rotation esalgo:RM1298";
0656 edm::LogVerbatim("SFGeom") << sfbyLog.name() << " copy " << (scopy + 1000 * swed_scopy_glob) << " in "
0657 << ddname2 << " at (" << cms::convert2mm(xpos) << "," << cms::convert2mm(ypos)
0658 << "," << cms::convert2mm(zpos) << ") rotation esalgo:RM1300A";
0659 #endif
0660 }
0661 }
0662 }
0663 }
0664 }
0665
0666
0667 int icopy[100] = {0};
0668 constexpr int sz = 20;
0669
0670 for (int I = -9; I <= 9; ++I) {
0671 prev_length = 0;
0672 int J = abs(I);
0673 for (int K = 0; K < es.noLaddInCol[J]; K++) {
0674 string type;
0675
0676 ladder_new_length = es.micromodule_length + 3. * es.waf_active;
0677 ladd_shift = 4. * es.waf_active;
0678
0679 if (K == 0)
0680 type = es.typeOfLaddRow0[J];
0681 if (K == 1)
0682 type = es.typeOfLaddRow1[J];
0683 if (K == 2)
0684 type = es.typeOfLaddRow2[J];
0685 if (K == 3)
0686 type = es.typeOfLaddRow3[J];
0687
0688 for (const auto& i : es.typesL5)
0689 if (type == i) {
0690 ladder_new_length = es.micromodule_length + 4. * es.waf_active;
0691 ladd_shift = 5. * es.waf_active;
0692 }
0693
0694 int j = 0;
0695
0696 for (int t = 0; t < int(es.typesL5.size()); t++)
0697 if (type == es.typesL5[t]) {
0698 j = t;
0699 if (I < 0 && es.asymLadd[t] == 1) {
0700 j = j + 1;
0701 type = es.typesL5[j];
0702 }
0703 }
0704 for (int t = 0; t < int(es.typesL4.size()); t++)
0705 if (type == es.typesL4[t]) {
0706 j = t + es.typesL5.size();
0707 if (I < 0 && es.asymLadd[(t + es.typesL5.size())] == 1) {
0708 j = j + 1;
0709 type = es.typesL4[j - es.typesL5.size()];
0710 }
0711 }
0712
0713 xpos = I * (2 * es.waf_intra_col_sep + es.waf_inter_col_sep);
0714 if (I > 0)
0715 xpos = xpos + es.dee_separation;
0716 if (I < 0)
0717 xpos = xpos - es.dee_separation;
0718
0719 ypos = (sz - int(es.startOfFirstLadd[J])) * es.waf_active - ladder_new_length / 2. +
0720 (es.ldrFrnt_Length - es.ldrBck_Length) / 2. + es.micromodule_length + 0.05 * dd4hep::cm - prev_length;
0721
0722 prev_length += ladd_shift;
0723
0724 zpos = es.zlead1 + es.ladder_thick / 2. + 0.01 * dd4hep::mm;
0725 icopy[j] += 1;
0726
0727 sfLog.placeVolume(ns.assembly("esalgo:" + es.ladPfx[0] + type), icopy[j], Position(xpos, ypos, zpos));
0728 #ifdef EDM_ML_DEBUG
0729 edm::LogVerbatim("SFGeom") << ("esalgo:" + es.ladPfx[0] + type) << " copy " << icopy[j] << " in "
0730 << sfLog.name() << " at (" << cms::convert2mm(xpos) << "," << cms::convert2mm(ypos)
0731 << "," << cms::convert2mm(zpos) << ") no rotation";
0732 #endif
0733
0734 xpos = I * (2 * es.waf_intra_col_sep + es.waf_inter_col_sep);
0735 sfLog.placeVolume(ns.assembly("esalgo:" + es.ladPfx[1] + type),
0736 icopy[j],
0737 Transform3D(ns.rotation("esalgo:R270"), Position(ypos, -xpos, zpos - es.zlead1 + es.zlead2)));
0738 #ifdef EDM_ML_DEBUG
0739 edm::LogVerbatim("SFGeom") << ("esalgo:" + es.ladPfx[1] + type) << " copy " << icopy[j] << " in "
0740 << sfLog.name() << " at (" << cms::convert2mm(ypos) << "," << -cms::convert2mm(xpos)
0741 << "," << cms::convert2mm(zpos - es.zlead1 + es.zlead2) << ") rotation esalgo:R270";
0742 #endif
0743
0744 int changed = 0;
0745 for (int t = 0; t < int(es.typesL5.size()); t++)
0746 if (type == es.typesL5[t]) {
0747 j = t;
0748 if (es.asymLadd[t] == 2 && !changed) {
0749 j = j - 1;
0750 changed = 1;
0751 }
0752 if (es.asymLadd[t] == 1 && !changed) {
0753 j = j + 1;
0754 changed = 1;
0755 }
0756 type = es.typesL5[j];
0757 }
0758 for (int t = 0; t < int(es.typesL4.size()); t++)
0759 if (type == es.typesL4[t]) {
0760 j = t + es.typesL5.size();
0761 if (es.asymLadd[(t + es.typesL5.size())] == 2 && !changed) {
0762 j = j - 1;
0763 changed = 1;
0764 }
0765 if (es.asymLadd[(t + es.typesL5.size())] == 1 && !changed) {
0766 j = j + 1;
0767 changed = 1;
0768 }
0769 type = es.typesL4[j - es.typesL5.size()];
0770 }
0771
0772 icopy[j] += 1;
0773
0774 if (I > 0)
0775 xpos = xpos + es.dee_separation;
0776 if (I < 0)
0777 xpos = xpos - es.dee_separation;
0778
0779 sfLog.placeVolume(ns.assembly("esalgo:" + es.ladPfx[0] + type),
0780 icopy[j],
0781 Transform3D(ns.rotation("esalgo:R180"), Position(xpos, -ypos, zpos)));
0782 #ifdef EDM_ML_DEBUG
0783 edm::LogVerbatim("SFGeom") << ("esalgo:" + es.ladPfx[0] + type) << " copy " << icopy[j] << " in "
0784 << sfLog.name() << " at (" << cms::convert2mm(xpos) << "," << -cms::convert2mm(ypos)
0785 << "," << cms::convert2mm(zpos) << ") rotation esalgo:R180";
0786 #endif
0787
0788 xpos = I * (2 * es.waf_intra_col_sep + es.waf_inter_col_sep);
0789
0790 sfLog.placeVolume(
0791 ns.assembly("esalgo:" + es.ladPfx[1] + type),
0792 icopy[j],
0793 Transform3D(ns.rotation("esalgo:R090"), Position(-ypos, -xpos, zpos - es.zlead1 + es.zlead2)));
0794 #ifdef EDM_ML_DEBUG
0795 edm::LogVerbatim("SFGeom") << ("esalgo:" + es.ladPfx[1] + type) << " copy " << icopy[j] << " in "
0796 << sfLog.name() << " at (" << -cms::convert2mm(ypos) << "," << -cms::convert2mm(xpos)
0797 << "," << cms::convert2mm(zpos - es.zlead1 + es.zlead2) << ") rotation esalgo:R090";
0798 #endif
0799 }
0800 }
0801 }
0802
0803 {
0804 double xpos(0), ypos(0);
0805 Volume sfwxLog = ns.volume("esalgo:SFWX");
0806 Volume sfwyLog = ns.volume("esalgo:SFWY");
0807 Volume sfsxLog = ns.volume("esalgo:SFSX");
0808 Volume sfsyLog = ns.volume("esalgo:SFSY");
0809
0810 for (size_t i = 0; i < 32; ++i) {
0811 xpos = -es.waf_active / 2. + i * es.waf_active / 32. + es.waf_active / 64.;
0812 sfwxLog.placeVolume(sfsxLog, i + 1, Position(xpos, 0., 0.));
0813 #ifdef EDM_ML_DEBUG
0814 edm::LogVerbatim("SFGeom") << sfsxLog.name() << " copy " << (i + 1) << " in " << sfwxLog.name() << " at ("
0815 << cms::convert2mm(xpos) << ",0,0) no rotation";
0816 #endif
0817
0818 ypos = -es.waf_active / 2. + i * es.waf_active / 32. + es.waf_active / 64.;
0819 sfwyLog.placeVolume(sfsyLog, i + 1, Position(0., ypos, 0.));
0820 #ifdef EDM_ML_DEBUG
0821 edm::LogVerbatim("SFGeom") << sfsyLog.name() << " copy " << (i + 1) << " in " << sfwyLog.name() << " at (0,"
0822 << cms::convert2mm(ypos) << ",0) no rotation";
0823 #endif
0824 }
0825 }
0826 return 1;
0827 }
0828
0829 DECLARE_DDCMS_DETELEMENT(DDCMS_ecal_DDEcalPreshowerAlgo, algorithm)