File indexing completed on 2024-05-10 02:20:51
0001 #include "Geometry/HcalTestBeamData/plugins/DDEcalPreshowerAlgoTB.h"
0002
0003 #include <cmath>
0004 #include <algorithm>
0005 #include <ostream>
0006
0007 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0008 #include "DetectorDescription/Core/interface/DDTypes.h"
0009 #include "DetectorDescription/Core/interface/DDutils.h"
0010 #include "DetectorDescription/Core/interface/DDLogicalPart.h"
0011 #include "DetectorDescription/Core/interface/DDSolid.h"
0012 #include "DetectorDescription/Core/interface/DDMaterial.h"
0013 #include "DetectorDescription/Core/interface/DDCurrentNamespace.h"
0014 #include "DetectorDescription/Core/interface/DDSplit.h"
0015 #include "DetectorDescription/Core/interface/DDVector.h"
0016 #include <CLHEP/Units/GlobalPhysicalConstants.h>
0017 #include <CLHEP/Units/SystemOfUnits.h>
0018
0019 using namespace CLHEP;
0020
0021 DDEcalPreshowerAlgoTB::DDEcalPreshowerAlgoTB() : DDAlgorithm() {
0022 LogDebug("HCalGeom") << "DDEcalPreshowerAlgoTB info: Creating an instance";
0023 }
0024
0025 void DDEcalPreshowerAlgoTB::initialize(const DDNumericArguments& nArgs,
0026 const DDVectorArguments& vArgs,
0027 const DDMapArguments& mArgs,
0028 const DDStringArguments& sArgs,
0029 const DDStringVectorArguments& vsArgs) {
0030 LogDebug("HCalGeom") << "DDEcalPreshowerAlgoTB info: Initialize";
0031 quadMin_ = vArgs["IQUAD_MIN"];
0032 LogDebug("HCalGeom") << "DDEcalPreshowerAlgoTB IQUAD_MIN";
0033 quadMax_ = vArgs["IQUAD_MAX"];
0034 LogDebug("HCalGeom") << "DDEcalPreshowerAlgoTB IQUAD_MAX";
0035 thickLayers_ = vArgs["Layers"];
0036 LogDebug("HCalGeom") << "DDEcalPreshowerAlgoTB Layers";
0037 thickness_ = double(nArgs["PRESH_Z_TOTAL"]);
0038 LogDebug("HCalGeom") << "DDEcalPreshowerAlgoTB PRESH_Z_TOTAL";
0039 materials_ = vsArgs["LayMat"];
0040 LogDebug("HCalGeom") << "DDEcalPreshowerAlgoTB material";
0041 rmaxVec = vArgs["R_MAX"];
0042 LogDebug("HCalGeom") << "DDEcalPreshowerAlgoTB R_MAX";
0043 rminVec = vArgs["R_MIN"];
0044 LogDebug("HCalGeom") << "DDEcalPreshowerAlgoTB R_MIN";
0045 waf_intra_col_sep = double(nArgs["waf_intra_col_sep"]);
0046 LogDebug("HCalGeom") << "DDEcalPreshowerAlgoTB waf_intra_col_sep";
0047 waf_inter_col_sep = double(nArgs["waf_inter_col_sep"]);
0048 LogDebug("HCalGeom") << "DDEcalPreshowerAlgoTB waf_intra_col_sep = " << waf_inter_col_sep;
0049 waf_active = double(nArgs["waf_active"]);
0050 LogDebug("HCalGeom") << "DDEcalPreshowerAlgoTB waf_active = " << waf_active;
0051 wedge_length = double(nArgs["wedge_length"]);
0052 LogDebug("HCalGeom") << "DDEcalPreshowerAlgoTB wedge_length = " << wedge_length;
0053 wedge_offset = double(nArgs["wedge_offset"]);
0054 zwedge_ceramic_diff = double(nArgs["zwedge_ceramic_diff"]);
0055 ywedge_ceramic_diff = double(nArgs["ywedge_ceramic_diff"]);
0056 micromodulesx = vArgs["MicromodulesX"];
0057 micromodulesy = vArgs["MicromodulesY"];
0058 absorbx = double(nArgs["absorbx"]);
0059 absorby = double(nArgs["absorby"]);
0060 trabsorbx = double(nArgs["trabsorbx"]);
0061 trabsorby = double(nArgs["trabsorby"]);
0062 ScndplaneXshift = double(nArgs["2ndPlaneXshift"]);
0063 ScndplaneYshift = double(nArgs["2ndPlaneYshift"]);
0064 TotSFXshift = double(nArgs["SF07vsSF_Xshift"]);
0065 TotSFYshift = double(nArgs["SF07vsSF_Yshift"]);
0066 dummyMaterial = sArgs["DummyMaterial"];
0067 LogDebug("HCalGeom") << "DDEcalPreshowerAlgoTB Dummy Material = " << dummyMaterial;
0068
0069 idNameSpace = DDCurrentNamespace::ns();
0070
0071 LogDebug("HCalGeom") << "DDEcalPreshowerAlgoTB info: end initialize";
0072 }
0073
0074 void DDEcalPreshowerAlgoTB::execute(DDCompactView& cpv) {
0075 LogDebug("HCalGeom") << "******** DDEcalPreshowerAlgoTB execute!";
0076
0077
0078 doLayers(cpv);
0079
0080 doWedges(cpv);
0081
0082 doSens(cpv);
0083 }
0084
0085 void DDEcalPreshowerAlgoTB::doLayers(DDCompactView& cpv) {
0086
0087 double zpos = -thickness_ / 2.;
0088 for (size_t i = 0; i < rminVec.size(); ++i) {
0089 int I = int(i) + 1;
0090
0091 double zHalf(0);
0092
0093
0094 std::ostringstream name;
0095 name << "SF" << int((50 + I) / 10) << I - int(I / 10) * 10;
0096 DDName ddname(name.str(), idNameSpace);
0097
0098
0099
0100
0101 zHalf = thickLayers_[i] / 2.;
0102
0103
0104 zpos += zHalf;
0105
0106 if (I == 7 || I == 15) {
0107 zpos += zHalf;
0108 continue;
0109 }
0110 if (I == 2) {
0111 zfoam1_ = zpos;
0112 }
0113 if (I == 6) {
0114 zlead1_ = zpos + zHalf;
0115 }
0116 if (I == 14) {
0117 zlead2_ = zpos + zHalf;
0118 }
0119
0120 if (getMaterial(i) != dummyMaterial) {
0121
0122
0123
0124 DDSolid solid = DDSolidFactory::box(ddname, absorbx, absorby, zHalf);
0125
0126 DDName matname(getMaterial(i), "materials");
0127 DDMaterial material(matname);
0128 DDLogicalPart layer = DDLogicalPart(ddname, material, solid);
0129
0130 DDTranslation tran = DDTranslation(trabsorbx + TotSFXshift, trabsorby + TotSFYshift, zpos);
0131 cpv.position(layer, parent(), 1, tran, DDRotation());
0132 LogDebug("HCalGeom") << "DDEcalPreshowerAlgoTB debug : Child " << layer << " Copy 1 in " << parent().name()
0133 << " with translation " << tran << " and rotation " << DDRotation();
0134 }
0135 zpos += zHalf;
0136 }
0137 }
0138
0139 void DDEcalPreshowerAlgoTB::doWedges(DDCompactView& cpv) {
0140 LogDebug("HCalGeom") << "DDEcalPreshowerAlgoTB::debug : doWedges()";
0141 int icopy(0), icopyt(0);
0142 double xpos(0), ypos(0), zpos(0);
0143 int sz = int(quadMax_.size());
0144
0145 DDTranslation tran;
0146 DDName name1("SWED", idNameSpace);
0147 DDName name2("SFBX", idNameSpace);
0148 DDRotation rot1("rotations:RM1299");
0149 DDRotation rot2("rotations:RM1298");
0150
0151 for (int I = 1; I <= sz; ++I) {
0152 for (int J = int(quadMax_[I - 1]); J >= int(quadMin_[I - 1]); --J) {
0153
0154 icopy += 1;
0155 go = 0;
0156 for (double m : micromodulesx)
0157 if (m == icopy) {
0158 go = 1;
0159 icopyt += 1;
0160 }
0161 xpos = -1. * (J * waf_intra_col_sep + (int(J / 2)) * waf_inter_col_sep - waf_intra_col_sep / 2.);
0162 ypos = (sz - int(I)) * waf_active + wedge_length / 2. + 0.05 * cm;
0163 xpos = xpos + TotSFXshift;
0164 ypos = ypos + TotSFYshift;
0165 zpos = zlead1_ + wedge_offset;
0166
0167 if (go == 1) {
0168 tran = DDTranslation(xpos, ypos, zpos);
0169 cpv.position(DDLogicalPart(name1), parent(), icopyt, tran, rot1);
0170 LogDebug("HCalGeom") << "DDEcalPreshowerAlgoTB::debug : Child " << name1 << " copy = " << icopy << " ("
0171 << icopyt << ") in Mother " << parent().name() << " translation " << tran << " rotation "
0172 << rot1;
0173 }
0174 zpos = zlead1_ + zwedge_ceramic_diff;
0175 ypos = ypos + ywedge_ceramic_diff;
0176 if (go == 1) {
0177 tran = DDTranslation(xpos, ypos, zpos);
0178 cpv.position(DDLogicalPart(name2), parent(), icopyt, tran, rot2);
0179 LogDebug("HCalGeom") << "DDEcalPreshowerAlgoTB::debug : Child " << name2 << " copy = " << icopy << " ("
0180 << icopyt << ") in Mother " << parent().name() << " translation " << tran << " rotation "
0181 << rot2;
0182 }
0183 }
0184
0185 for (int J = int(quadMin_[I - 1]); J <= int(quadMax_[I - 1]); ++J) {
0186 icopy += 1;
0187 go = 0;
0188 for (double m : micromodulesx)
0189 if (m == icopy) {
0190 go = 1;
0191 icopyt += 1;
0192 }
0193 xpos = 1. * (J * waf_intra_col_sep + (int(J / 2)) * waf_inter_col_sep - waf_intra_col_sep / 2.);
0194 ypos = (sz - int(I)) * waf_active + wedge_length / 2. + 0.05 * cm;
0195 xpos = xpos + TotSFXshift;
0196 ypos = ypos + TotSFYshift;
0197 zpos = zlead1_ + wedge_offset;
0198 if (go == 1) {
0199 tran = DDTranslation(xpos, ypos, zpos);
0200 cpv.position(DDLogicalPart(name1), parent(), icopyt, tran, rot1);
0201 LogDebug("HCalGeom") << "DDEcalPreshowerAlgoTB::debug : Child " << name1 << " copy = " << icopy << " ("
0202 << icopyt << ") in Mother " << parent().name() << " translation " << tran << " rotation "
0203 << rot1;
0204 }
0205 zpos = zlead1_ + zwedge_ceramic_diff;
0206 ypos = ypos + ywedge_ceramic_diff;
0207 if (go == 1) {
0208 tran = DDTranslation(xpos, ypos, zpos);
0209 cpv.position(DDLogicalPart(name2), parent(), icopyt, tran, rot2);
0210 LogDebug("HCalGeom") << "DDEcalPreshowerAlgoTB::debug : Child " << name2 << " copy = " << icopy << " ("
0211 << icopyt << ") in Mother " << parent().name() << " translation " << tran << " rotation "
0212 << rot2;
0213 }
0214 }
0215 }
0216
0217
0218 rot1 = DDRotation("rotations:RM1303");
0219 rot2 = DDRotation("rotations:RM1302");
0220 for (int I = sz; I >= 1; --I) {
0221 for (int J = int(quadMax_[I - 1]); J >= int(quadMin_[I - 1]); --J) {
0222 icopy += 1;
0223 go = 0;
0224 for (double m : micromodulesx)
0225 if (m == icopy) {
0226 go = 1;
0227 icopyt += 1;
0228 }
0229
0230 xpos = -1. * (J * waf_intra_col_sep + (int(J / 2)) * waf_inter_col_sep - waf_intra_col_sep / 2.);
0231 ypos = -1. * (sz - int(I)) * waf_active - wedge_length / 2. - 0.05 * cm;
0232 xpos = xpos + TotSFXshift;
0233 ypos = ypos + TotSFYshift;
0234 zpos = zlead1_ + wedge_offset;
0235 if (go == 1) {
0236 tran = DDTranslation(xpos, ypos, zpos);
0237 cpv.position(DDLogicalPart(name1), parent(), icopyt, tran, rot1);
0238 LogDebug("HCalGeom") << "DDEcalPreshowerAlgoTB::debug : Child " << name1 << " copy = " << icopy << " ("
0239 << icopyt << ") in Mother " << parent().name() << " translation " << tran << " rotation "
0240 << rot1;
0241 }
0242 zpos = zlead1_ + zwedge_ceramic_diff;
0243 ypos = ypos - ywedge_ceramic_diff;
0244 if (go == 1) {
0245 tran = DDTranslation(xpos, ypos, zpos);
0246 cpv.position(DDLogicalPart(name2), parent(), icopyt, tran, rot2);
0247 LogDebug("HCalGeom") << "DDEcalPreshowerAlgoTB::debug : Child " << name2 << " copy = " << icopy << " ("
0248 << icopyt << ") in Mother " << parent().name() << " translation " << tran << " rotation "
0249 << rot2;
0250 }
0251 }
0252
0253 for (int J = int(quadMin_[I - 1]); J <= int(quadMax_[I - 1]); ++J) {
0254 icopy += 1;
0255 go = 0;
0256 for (double m : micromodulesx)
0257 if (m == icopy) {
0258 go = 1;
0259 icopyt += 1;
0260 }
0261 xpos = 1. * (J * waf_intra_col_sep + (int(J / 2)) * waf_inter_col_sep - waf_intra_col_sep / 2.);
0262 ypos = -1. * (sz - int(I)) * waf_active - wedge_length / 2. - 0.05 * cm;
0263 xpos = xpos + TotSFXshift;
0264 ypos = ypos + TotSFYshift;
0265 zpos = zlead1_ + wedge_offset;
0266 if (go == 1) {
0267 tran = DDTranslation(xpos, ypos, zpos);
0268 cpv.position(DDLogicalPart(name1), parent(), icopyt, tran, rot1);
0269 LogDebug("HCalGeom") << "DDEcalPreshowerAlgoTB::debug : Child " << name1 << " copy = " << icopy << " ("
0270 << icopyt << ") in Mother " << parent().name() << " translation " << tran << " rotation "
0271 << rot1;
0272 }
0273 zpos = zlead1_ + zwedge_ceramic_diff;
0274 ypos = ypos - ywedge_ceramic_diff;
0275 if (go == 1) {
0276 tran = DDTranslation(xpos, ypos, zpos);
0277 cpv.position(DDLogicalPart(name2), parent(), icopyt, tran, rot2);
0278 LogDebug("HCalGeom") << "DDEcalPreshowerAlgoTB::debug : Child " << name2 << " copy = " << icopy << " ("
0279 << icopyt << ") in Mother " << parent().name() << " translation " << tran << " rotation "
0280 << rot2;
0281 }
0282 }
0283 }
0284
0285
0286 icopy = 0;
0287 int nxt = micromodulesy.size();
0288 name1 = DDName("SWED", idNameSpace);
0289 name2 = DDName("SFBY", idNameSpace);
0290 rot1 = DDRotation(DDName("RM1301B", idNameSpace));
0291 rot2 = DDRotation(DDName("RM1300B", idNameSpace));
0292 for (int I = 1; I <= sz; ++I) {
0293 for (int J = int(quadMax_[I - 1]); J >= int(quadMin_[I - 1]); --J) {
0294 icopy += 1;
0295 go = 0;
0296 for (double m : micromodulesy)
0297 if (m == icopy) {
0298 go = 1;
0299 icopyt += 1;
0300 }
0301
0302 ypos = -1. * (J * waf_intra_col_sep + (int(J / 2)) * waf_inter_col_sep - waf_intra_col_sep / 2.);
0303 xpos = (sz - int(I)) * waf_active + wedge_length / 2. + 0.05 * cm + ScndplaneXshift;
0304 xpos = xpos + TotSFXshift;
0305 ypos = ypos + TotSFYshift;
0306 zpos = zlead2_ + wedge_offset;
0307 if (go == 1) {
0308 tran = DDTranslation(xpos, ypos, zpos);
0309 cpv.position(DDLogicalPart(name1), parent(), icopy + nxt, tran, rot1);
0310 LogDebug("HCalGeom") << "DDEcalPreshowerAlgoTB::debug : Child " << name1 << " copy = " << icopy << " ("
0311 << icopyt + nxt << ") in Mother " << parent().name() << " translation " << tran
0312 << " rotation " << rot1;
0313 }
0314 zpos = zlead2_ + zwedge_ceramic_diff;
0315 xpos = xpos - ywedge_ceramic_diff;
0316 if (go == 1) {
0317 tran = DDTranslation(xpos, ypos, zpos);
0318 cpv.position(DDLogicalPart(name2), parent(), icopyt, tran, rot2);
0319 LogDebug("HCalGeom") << "DDEcalPreshowerAlgoTB::debug : Child " << name2 << " copy = " << icopy << " ("
0320 << icopyt << ") in Mother " << parent().name() << " translation " << tran << " rotation "
0321 << rot2;
0322 }
0323 }
0324
0325 for (int J = int(quadMin_[I - 1]); J <= int(quadMax_[I - 1]); ++J) {
0326 icopy += 1;
0327 go = 0;
0328 for (double m : micromodulesy)
0329 if (m == icopy) {
0330 go = 1;
0331 icopyt += 1;
0332 }
0333
0334 ypos = 1. * (J * waf_intra_col_sep + (int(J / 2)) * waf_inter_col_sep - waf_intra_col_sep / 2.);
0335 xpos = (sz - int(I)) * waf_active + wedge_length / 2. + 0.05 * cm + ScndplaneXshift;
0336 xpos = xpos + TotSFXshift;
0337 ypos = ypos + TotSFYshift;
0338 zpos = zlead2_ + wedge_offset;
0339 if (go == 1) {
0340 tran = DDTranslation(xpos, ypos, zpos);
0341 cpv.position(DDLogicalPart(name1), parent(), icopyt + nxt, tran, rot1);
0342 LogDebug("HCalGeom") << "DDEcalPreshowerAlgoTB::debug : Child " << name1 << " copy = " << icopy << " ("
0343 << icopyt + nxt << ") in Mother " << parent().name() << " translation " << tran
0344 << " rotation " << rot1;
0345 }
0346 zpos = zlead2_ + zwedge_ceramic_diff;
0347 xpos = xpos - ywedge_ceramic_diff;
0348 if (go == 1) {
0349 tran = DDTranslation(xpos, ypos, zpos);
0350 cpv.position(DDLogicalPart(name2), parent(), icopyt, tran, rot2);
0351 LogDebug("HCalGeom") << "DDEcalPreshowerAlgoTB::debug : Child " << name2 << " copy = " << icopy << " ("
0352 << icopyt << ") in Mother " << parent().name() << " translation " << tran << " rotation "
0353 << rot2;
0354 }
0355 }
0356 }
0357
0358
0359 rot1 = DDRotation(DDName("RM1305B", idNameSpace));
0360 rot2 = DDRotation(DDName("RM1304B", idNameSpace));
0361 for (int I = sz; I >= 1; --I) {
0362 for (int J = int(quadMax_[I - 1]); J >= int(quadMin_[I - 1]); --J) {
0363 icopy += 1;
0364 go = 0;
0365 for (double m : micromodulesy)
0366 if (m == icopy) {
0367 go = 1;
0368 icopyt += 1;
0369 }
0370
0371 ypos = -1. * (J * waf_intra_col_sep + (int(J / 2)) * waf_inter_col_sep - waf_intra_col_sep / 2.);
0372 xpos = -1. * (sz - int(I)) * waf_active - wedge_length / 2. - 0.05 * cm + ScndplaneXshift;
0373 xpos = xpos + TotSFXshift;
0374 ypos = ypos + TotSFYshift;
0375 zpos = zlead2_ + wedge_offset;
0376 if (go == 1) {
0377 tran = DDTranslation(xpos, ypos, zpos);
0378 cpv.position(DDLogicalPart(name1), parent(), icopyt + nxt, tran, rot1);
0379 LogDebug("HCalGeom") << "DDEcalPreshowerAlgoTB::debug : Child " << name1 << " copy = " << icopy << " ("
0380 << icopyt + nxt << ") in Mother " << parent().name() << " translation " << tran
0381 << " rotation " << rot1;
0382 }
0383 zpos = zlead2_ + zwedge_ceramic_diff;
0384 xpos = xpos + ywedge_ceramic_diff;
0385 if (go == 1) {
0386 tran = DDTranslation(xpos, ypos, zpos);
0387 cpv.position(DDLogicalPart(name2), parent(), icopyt, tran, rot2);
0388 LogDebug("HCalGeom") << "DDEcalPreshowerAlgoTB::debug : Child " << name2 << " copy = " << icopy << " ("
0389 << icopyt << ") in Mother " << parent().name() << " translation " << tran << " rotation "
0390 << rot2;
0391 }
0392 }
0393
0394 for (int J = int(quadMin_[I - 1]); J <= int(quadMax_[I - 1]); ++J) {
0395 icopy += 1;
0396 go = 0;
0397 for (double m : micromodulesy)
0398 if (m == icopy) {
0399 go = 1;
0400 icopyt += 1;
0401 }
0402
0403 ypos = 1. * (J * waf_intra_col_sep + (int(J / 2)) * waf_inter_col_sep - waf_intra_col_sep / 2.);
0404 xpos = -1. * (sz - int(I)) * waf_active - wedge_length / 2. - 0.05 * cm + ScndplaneXshift;
0405 xpos = xpos + TotSFXshift;
0406 ypos = ypos + TotSFYshift;
0407 zpos = zlead2_ + wedge_offset;
0408 if (go == 1) {
0409 tran = DDTranslation(xpos, ypos, zpos);
0410 cpv.position(DDLogicalPart(name1), parent(), icopyt + nxt, tran, rot1);
0411 LogDebug("HCalGeom") << "DDEcalPreshowerAlgoTB::debug : Child " << name1 << " copy = " << icopy << " ("
0412 << icopyt + nxt << ") in Mother " << parent().name() << " translation " << tran
0413 << " rotation " << rot1;
0414 }
0415 zpos = zlead2_ + zwedge_ceramic_diff;
0416 xpos = xpos + ywedge_ceramic_diff;
0417 if (go == 1) {
0418 tran = DDTranslation(xpos, ypos, zpos);
0419 cpv.position(DDLogicalPart(name2), parent(), icopyt, tran, rot2);
0420 LogDebug("HCalGeom") << "DDEcalPreshowerAlgoTB::debug : Child " << name2 << " copy = " << icopy << " ("
0421 << icopyt << ") in Mother " << parent().name() << " translation " << tran << " rotation "
0422 << rot2;
0423 }
0424 }
0425 }
0426 }
0427
0428 void DDEcalPreshowerAlgoTB::doSens(DDCompactView& cpv) {
0429 double xpos(0), ypos(0);
0430 DDTranslation tran;
0431 DDName child1 = DDName("SFSX", idNameSpace);
0432 DDName child2 = DDName("SFSY", idNameSpace);
0433 DDName mother1 = DDName("SFAX", idNameSpace);
0434 DDName mother2 = DDName("SFAY", idNameSpace);
0435 DDRotation rot;
0436 for (size_t i = 0; i < 32; ++i) {
0437 xpos = -waf_active / 2. + i * waf_active / 32. + waf_active / 64.;
0438 tran = DDTranslation(xpos, 0., 0.);
0439 cpv.position(DDLogicalPart(child1), mother1, i + 1, tran, rot);
0440 LogDebug("HCalGeom") << "DDEcalPreshowerAlgoTB::debug : Child " << child1 << "\ncopy number " << i + 1 << " in "
0441 << mother1 << " translation " << tran << " rotation " << rot;
0442
0443 ypos = -waf_active / 2. + i * waf_active / 32. + waf_active / 64.;
0444 tran = DDTranslation(0., ypos, 0.);
0445 cpv.position(DDLogicalPart(child2), mother2, i + 1, tran, rot);
0446 LogDebug("HCalGeom") << "DDEcalPreshowerAlgoTB::debug : Child " << child2 << "\ncopy number " << i + 1 << " in "
0447 << mother2 << " translation " << tran << " rotation " << rot;
0448 }
0449 }