1 #include "DD4hep/DetFactoryHelper.h"
8 #include <CLHEP/Geometry/Transform3D.h>
15 using DDTranslation = ROOT::Math::DisplacementVector3D<ROOT::Math::Cartesian3D<double> >;
45 std::vector<double> vecEESCProf;
47 std::vector<double> vecEEShape;
49 std::vector<double> vecEESCCutaway;
51 std::vector<double> vecEESCCtrs;
53 std::vector<double> vecEECRCtrs;
55 std::array<double, 3> cutParms;
72 std::vector<double> vecEESCLims;
85 std::string_view mynamespace(std::string_view
input) {
86 std::string_view
v =
input;
87 auto trim_pos =
v.find(
':');
88 if (trim_pos !=
v.npos)
89 v.remove_suffix(
v.size() - (trim_pos + 1));
103 ee.mat =
args.str(
"EEMat");
104 ee.zOff =
args.dble(
"EEzOff");
106 ee.quaName =
args.str(
"EEQuaName");
107 ee.quaMat =
args.str(
"EEQuaMat");
108 ee.crysMat =
args.str(
"EECrysMat");
109 ee.wallMat =
args.str(
"EEWallMat");
110 ee.crysLength =
args.dble(
"EECrysLength");
111 ee.crysRear =
args.dble(
"EECrysRear");
112 ee.crysFront =
args.dble(
"EECrysFront");
113 ee.sCELength =
args.dble(
"EESCELength");
114 ee.sCERear =
args.dble(
"EESCERear");
115 ee.sCEFront =
args.dble(
"EESCEFront");
116 ee.sCALength =
args.dble(
"EESCALength");
117 ee.sCARear =
args.dble(
"EESCARear");
118 ee.sCAFront =
args.dble(
"EESCAFront");
119 ee.sCAWall =
args.dble(
"EESCAWall");
120 ee.sCHLength =
args.dble(
"EESCHLength");
121 ee.sCHSide =
args.dble(
"EESCHSide");
122 ee.nSCTypes =
args.dble(
"EEnSCTypes");
123 ee.nColumns =
args.dble(
"EEnColumns");
124 ee.nSCCutaway =
args.dble(
"EEnSCCutaway");
125 ee.nSCquad =
args.dble(
"EEnSCquad");
126 ee.nCRSC =
args.dble(
"EEnCRSC");
127 ee.vecEESCProf =
args.vecDble(
"EESCProf");
128 ee.vecEEShape =
args.vecDble(
"EEShape");
129 ee.vecEESCCutaway =
args.vecDble(
"EESCCutaway");
130 ee.vecEESCCtrs =
args.vecDble(
"EESCCtrs");
131 ee.vecEECRCtrs =
args.vecDble(
"EECRCtrs");
133 ee.cutBoxName =
args.str(
"EECutBoxName");
135 ee.envName =
args.str(
"EEEnvName");
136 ee.alvName =
args.str(
"EEAlvName");
137 ee.intName =
args.str(
"EEIntName");
138 ee.cryName =
args.str(
"EECryName");
140 ee.pFHalf =
args.dble(
"EEPFHalf");
141 ee.pFFifth =
args.dble(
"EEPFFifth");
142 ee.pF45 =
args.dble(
"EEPF45");
144 ee.vecEESCLims =
args.vecDble(
"EESCLims");
145 ee.iLength =
args.dble(
"EEiLength");
146 ee.iXYOff =
args.dble(
"EEiXYOff");
147 ee.cryZOff =
args.dble(
"EECryZOff");
148 ee.zFront =
args.dble(
"EEzFront");
153 const double cutWid(ee.sCERear /
sqrt(2.));
154 ee.cutParms[0] = cutWid;
155 ee.cutParms[1] = cutWid;
156 ee.cutParms[2] = ee.sCELength /
sqrt(2.);
157 dd4hep::Solid eeCutBox = dd4hep::Box(ee.cutBoxName, ee.cutParms[0], ee.cutParms[1], ee.cutParms[2]);
160 const double zFix(ee.zFront - 3172 * dd4hep::mm);
163 for (
unsigned int iC(0); iC != (
unsigned int)ee.nSCquad; ++iC) {
164 const unsigned int iOff(8 * iC);
165 const unsigned int ix((
unsigned int)ee.vecEESCCtrs[iOff + 0]);
166 const unsigned int iy((
unsigned int)ee.vecEESCCtrs[iOff + 1]);
168 assert(ix > 0 && ix < 11 && iy > 0 && iy < 11);
170 ee.scrFCtr[ix - 1][iy - 1] =
171 DDTranslation(ee.vecEESCCtrs[iOff + 2], ee.vecEESCCtrs[iOff + 4], ee.vecEESCCtrs[iOff + 6] + zFix);
173 ee.scrRCtr[ix - 1][iy - 1] =
174 DDTranslation(ee.vecEESCCtrs[iOff + 3], ee.vecEESCCtrs[iOff + 5], ee.vecEESCCtrs[iOff + 7] + zFix);
178 for (
unsigned int iC(0); iC != 25; ++iC) {
179 const unsigned int iOff(8 * iC);
180 const unsigned int ix((
unsigned int)ee.vecEECRCtrs[iOff + 0]);
181 const unsigned int iy((
unsigned int)ee.vecEECRCtrs[iOff + 1]);
183 assert(ix > 0 && ix < 6 && iy > 0 && iy < 6);
185 ee.cryFCtr[ix - 1][iy - 1] =
186 DDTranslation(ee.vecEECRCtrs[iOff + 2], ee.vecEECRCtrs[iOff + 4], ee.vecEECRCtrs[iOff + 6]);
188 ee.cryRCtr[ix - 1][iy - 1] =
189 DDTranslation(ee.vecEECRCtrs[iOff + 3], ee.vecEECRCtrs[iOff + 5], ee.vecEECRCtrs[iOff + 7]);
192 dd4hep::Solid eeCRSolid = dd4hep::Trap(ee.cryName,
194 atan((ee.crysRear - ee.crysFront) / (
sqrt(2.) * ee.crysLength)),
206 <<
":" << (atan((ee.crysRear - ee.crysFront) / (
sqrt(2.) * ee.crysLength))) <<
":"
215 for (
unsigned int isc(0); isc < ee.nSCTypes; ++isc) {
216 unsigned int iSCType = isc + 1;
218 const double eFront(0.5 * ee.sCEFront);
219 const double eRear(0.5 * ee.sCERear);
220 const double eAng(atan((ee.sCERear - ee.sCEFront) / (
sqrt(2.) * ee.sCELength)));
221 const double ffived(45_deg);
222 const double zerod(0_deg);
223 std::string eeSCEnvName(1 == iSCType ? ee.envName + std::to_string(iSCType)
224 : (ee.envName + std::to_string(iSCType) +
"Tmp"));
228 eeSCEnvName, 0.5 * ee.sCELength, eAng, ffived, eFront, eFront, eFront, zerod, eRear, eRear, eRear, zerod));
231 <<
":" << eAng <<
":" << ffived <<
":" <<
cms::convert2mm(eFront) <<
":"
237 const double aFront(0.5 * ee.sCAFront);
238 const double aRear(0.5 * ee.sCARear);
239 const double aAng(atan((ee.sCARear - ee.sCAFront) / (
sqrt(2.) * ee.sCALength)));
241 (1 == iSCType ? ee.alvName + std::to_string(iSCType) : (ee.alvName + std::to_string(iSCType) +
"Tmp")));
245 eeSCAlvName, 0.5 * ee.sCALength, aAng, ffived, aFront, aFront, aFront, zerod, aRear, aRear, aRear, zerod));
248 <<
":" << aAng <<
":" << ffived <<
":" <<
cms::convert2mm(aFront) <<
":"
254 const double dwall(ee.sCAWall);
255 const double iFront(aFront - dwall);
256 const double iRear(iFront);
257 const double iLen(ee.iLength);
258 std::string eeSCIntName(1 == iSCType ? ee.intName + std::to_string(iSCType)
259 : (ee.intName + std::to_string(iSCType) +
"Tmp"));
260 dd4hep::Solid eeSCInt = ns.
addSolidNS(eeSCIntName,
261 dd4hep::Trap(eeSCIntName,
263 atan((ee.sCARear - ee.sCAFront) / (
sqrt(2.) * ee.sCALength)),
275 << (atan((ee.sCARear - ee.sCAFront) / (
sqrt(2.) * ee.sCALength))) <<
":" << ffived
281 const double dz(-0.5 * (ee.sCELength - ee.sCALength));
282 const double dxy(0.5 *
dz * (ee.sCERear - ee.sCEFront) / ee.sCELength);
283 const double zIOff(-(ee.sCALength - iLen) / 2.);
284 const double xyIOff(ee.iXYOff);
296 const double half(ee.cutParms[0] - ee.pFHalf * ee.crysRear);
297 const double fifth(ee.cutParms[0] + ee.pFFifth * ee.crysRear);
298 const double fac(ee.pF45);
300 const double zmm(0 * dd4hep::mm);
306 : (5 == iSCType ?
DDTranslation(-half * fac, -half * fac, zmm)
309 const CLHEP::HepRotationZ cutm(ffived);
324 dd4hep::Solid eeCutEnv = dd4hep::SubtractionSolid(ee.envName + std::to_string(iSCType),
325 ns.
solid(ee.envName + std::to_string(iSCType) +
"Tmp"),
327 dd4hep::Transform3D(cutRot, cutTra));
335 dd4hep::Solid eeCutAlv = dd4hep::SubtractionSolid(ee.alvName + std::to_string(iSCType),
336 ns.
solid(ee.alvName + std::to_string(iSCType) +
"Tmp"),
338 dd4hep::Transform3D(cutRot, cutTra - extra));
344 const double mySign(iSCType < 4 ? +1. : -1.);
346 const DDTranslation extraI(xyIOff + mySign * 2 * dd4hep::mm, xyIOff + mySign * 2 * dd4hep::mm, zIOff);
348 dd4hep::Solid eeCutInt = dd4hep::SubtractionSolid(ee.intName + std::to_string(iSCType),
349 ns.
solid(ee.intName + std::to_string(iSCType) +
"Tmp"),
351 dd4hep::Transform3D(cutRot, cutTra - extraI));
359 eeSCALog =
dd4hep::Volume(myns + ee.alvName + std::to_string(iSCType), eeCutAlv, ns.
material(ee.wallMat));
363 eeSCALog.placeVolume(eeSCILog, iSCType * 100 + 1,
dd4hep::Position(xyIOff, xyIOff, zIOff));
365 edm::LogVerbatim(
"EEGeom") << eeSCALog.name() <<
" " << (iSCType * 100 + 1) <<
" in " << eeSCELog.name();
366 edm::LogVerbatim(
"EEGeom") << eeSCILog.name() <<
" " << (iSCType * 100 + 1) <<
" in " << eeSCALog.name();
367 edm::LogVerbatim(
"EcalGeom") << eeSCALog.name() <<
" " << (iSCType * 100 + 1) <<
" in " << eeSCELog.name()
370 edm::LogVerbatim(
"EcalGeom") << eeSCILog.name() <<
" " << (iSCType * 100 + 1) <<
" in " << eeSCALog.name()
377 static const unsigned int ncol(5);
379 if (iSCType > 0 && iSCType <= ee.nSCTypes) {
380 const unsigned int icoffset((iSCType - 1) * ncol - 1);
383 for (
unsigned int icol(1); icol <= ncol; ++icol) {
385 const int ncrcol((
int)ee.vecEESCProf[icoffset + icol]);
387 const int imin(0 < ncrcol ? 1 : (0 > ncrcol ? ncol + ncrcol + 1 : 0));
388 const int imax(0 < ncrcol ? ncrcol : (0 > ncrcol ? ncol : 0));
392 for (
int irow(imin); irow <= imax; ++irow) {
397 crystal.
moveto(ee.cryFCtr[icol - 1][irow - 1], ee.cryRCtr[icol - 1][irow - 1]);
399 std::string rname(
"EECrRoC" + std::to_string(icol) +
"R" + std::to_string(irow));
401 eeSCALog.placeVolume(eeCRLog,
402 100 * iSCType + 10 * (icol - 1) + (irow - 1),
408 edm::LogVerbatim(
"EEGeom") << eeCRLog.name() <<
" " << (100 * iSCType + 10 * (icol - 1) + (irow - 1))
409 <<
" in " << eeSCALog.name();
410 edm::LogVerbatim(
"EcalGeom") << eeCRLog.name() <<
" " << (100 * iSCType + 10 * (icol - 1) + (irow - 1))
411 <<
" in " << eeSCALog.name() <<
" at ("
423 for (
int icol = 1; icol <=
int(ee.nColumns); icol++) {
425 for (
int irow =
int(ee.vecEEShape[2 * icol - 2]); irow <=
int(ee.vecEEShape[2 * icol - 1]); ++irow) {
426 if (ee.vecEESCLims[0] <= icol && ee.vecEESCLims[1] >= icol && ee.vecEESCLims[2] <= irow &&
427 ee.vecEESCLims[3] >= irow) {
429 unsigned int isctype = 1;
431 for (
unsigned int ii = 0;
ii < (
unsigned int)(ee.nSCCutaway); ++
ii) {
432 if ((ee.vecEESCCutaway[3 *
ii] == icol) && (ee.vecEESCCutaway[3 *
ii + 1] == irow)) {
433 isctype =
int(ee.vecEESCCutaway[3 *
ii + 2]);
440 scrys.
moveto(ee.scrFCtr[icol - 1][irow - 1], ee.scrRCtr[icol - 1][irow - 1]);
443 std::string rname(ee.envName + std::to_string(isctype) + std::to_string(icol) +
"R" + std::to_string(irow));
447 quaLog.placeVolume(childEnvLog,
448 100 * isctype + 10 * (icol - 1) + (irow - 1),
451 edm::LogVerbatim(
"EEGeom") << childEnvLog.name() <<
" " << (100 * isctype + 10 * (icol - 1) + (irow - 1))
452 <<
" in " << quaLog.name();
453 edm::LogVerbatim(
"EcalGeom") << childEnvLog.name() <<
" " << (100 * isctype + 10 * (icol - 1) + (irow - 1))