1 #include "DD4hep/DetFactoryHelper.h" 8 #include <CLHEP/Geometry/Transform3D.h> 42 std::vector<double> vecEESCProf;
44 std::vector<double> vecEEShape;
46 std::vector<double> vecEESCCutaway;
48 std::vector<double> vecEESCCtrs;
50 std::vector<double> vecEECRCtrs;
52 std::array<double, 3> cutParms;
69 std::vector<double> vecEESCLims;
82 std::string_view mynamespace(std::string_view
input) {
83 std::string_view
v =
input;
84 auto trim_pos =
v.find(
':');
85 if (trim_pos !=
v.npos)
86 v.remove_suffix(
v.size() - (trim_pos + 1));
109 auto rotAdjusted = crystal.
rotation();
110 rotAdjusted.GetComponents(
xx,
xy,
xz, yx,
yy,
yz, zx, zy,
zz);
111 double xtheta = atan2(zy,
zz);
112 double distyz =
sqrt(zy * zy +
zz *
zz);
113 double ytheta = atan2(-zx, distyz);
114 double ztheta = atan2(yx,
xx);
115 LogDebug(
"EcalGeom") <<
"Original " <<
rname <<
" rotation angles: xtheta = " << std::setprecision(18) << xtheta
116 <<
", distyz = " << distyz <<
", ytheta = " << ytheta <<
", ztheta = " << ztheta;
117 double increase = 1.01;
120 LogDebug(
"EcalGeom") <<
"Adjusted (+1%) " <<
rname <<
" rotation angles: xtheta = " << std::setprecision(18)
121 << xtheta <<
", distyz = " << distyz <<
", ytheta = " << ytheta <<
", ztheta = " << ztheta;
122 double xdiag =
cos(xtheta), xoff =
sin(xtheta);
123 double ydiag =
cos(ytheta), yoff =
sin(ytheta);
126 rotAdjusted = yrot * xrot;
127 eeSCALog.placeVolume(
131 myrot(ns,
rname, rotAdjusted),
146 ee.mat =
args.str(
"EEMat");
147 ee.zOff =
args.dble(
"EEzOff");
149 ee.quaName =
args.str(
"EEQuaName");
150 ee.quaMat =
args.str(
"EEQuaMat");
151 ee.crysMat =
args.str(
"EECrysMat");
152 ee.wallMat =
args.str(
"EEWallMat");
153 ee.crysLength =
args.dble(
"EECrysLength");
154 ee.crysRear =
args.dble(
"EECrysRear");
155 ee.crysFront =
args.dble(
"EECrysFront");
156 ee.sCELength =
args.dble(
"EESCELength");
157 ee.sCERear =
args.dble(
"EESCERear");
158 ee.sCEFront =
args.dble(
"EESCEFront");
159 ee.sCALength =
args.dble(
"EESCALength");
160 ee.sCARear =
args.dble(
"EESCARear");
161 ee.sCAFront =
args.dble(
"EESCAFront");
162 ee.sCAWall =
args.dble(
"EESCAWall");
163 ee.sCHLength =
args.dble(
"EESCHLength");
164 ee.sCHSide =
args.dble(
"EESCHSide");
165 ee.nSCTypes =
args.dble(
"EEnSCTypes");
166 ee.nColumns =
args.dble(
"EEnColumns");
167 ee.nSCCutaway =
args.dble(
"EEnSCCutaway");
168 ee.nSCquad =
args.dble(
"EEnSCquad");
169 ee.nCRSC =
args.dble(
"EEnCRSC");
170 ee.vecEESCProf =
args.vecDble(
"EESCProf");
171 ee.vecEEShape =
args.vecDble(
"EEShape");
172 ee.vecEESCCutaway =
args.vecDble(
"EESCCutaway");
173 ee.vecEESCCtrs =
args.vecDble(
"EESCCtrs");
174 ee.vecEECRCtrs =
args.vecDble(
"EECRCtrs");
176 ee.cutBoxName =
args.str(
"EECutBoxName");
178 ee.envName =
args.str(
"EEEnvName");
179 ee.alvName =
args.str(
"EEAlvName");
180 ee.intName =
args.str(
"EEIntName");
181 ee.cryName =
args.str(
"EECryName");
183 ee.pFHalf =
args.dble(
"EEPFHalf");
184 ee.pFFifth =
args.dble(
"EEPFFifth");
185 ee.pF45 =
args.dble(
"EEPF45");
187 ee.vecEESCLims =
args.vecDble(
"EESCLims");
188 ee.iLength =
args.dble(
"EEiLength");
189 ee.iXYOff =
args.dble(
"EEiXYOff");
190 ee.cryZOff =
args.dble(
"EECryZOff");
191 ee.zFront =
args.dble(
"EEzFront");
196 const double cutWid(ee.sCERear /
sqrt(2.));
197 ee.cutParms[0] = cutWid;
198 ee.cutParms[1] = cutWid;
199 ee.cutParms[2] = ee.sCELength /
sqrt(2.);
200 dd4hep::Solid eeCutBox = dd4hep::Box(ee.cutBoxName, ee.cutParms[0], ee.cutParms[1], ee.cutParms[2]);
203 const double zFix(ee.zFront - 3172 * dd4hep::mm);
206 for (
unsigned int iC(0); iC != (
unsigned int)ee.nSCquad; ++iC) {
207 const unsigned int iOff(8 * iC);
208 const unsigned int ix((
unsigned int)ee.vecEESCCtrs[iOff + 0]);
209 const unsigned int iy((
unsigned int)ee.vecEESCCtrs[iOff + 1]);
211 assert(ix > 0 && ix < 11 && iy > 0 && iy < 11);
213 ee.scrFCtr[ix - 1][iy - 1] =
214 DDTranslation(ee.vecEESCCtrs[iOff + 2], ee.vecEESCCtrs[iOff + 4], ee.vecEESCCtrs[iOff + 6] + zFix);
216 ee.scrRCtr[ix - 1][iy - 1] =
217 DDTranslation(ee.vecEESCCtrs[iOff + 3], ee.vecEESCCtrs[iOff + 5], ee.vecEESCCtrs[iOff + 7] + zFix);
221 for (
unsigned int iC(0); iC != 25; ++iC) {
222 const unsigned int iOff(8 * iC);
223 const unsigned int ix((
unsigned int)ee.vecEECRCtrs[iOff + 0]);
224 const unsigned int iy((
unsigned int)ee.vecEECRCtrs[iOff + 1]);
226 assert(ix > 0 && ix < 6 && iy > 0 && iy < 6);
228 ee.cryFCtr[ix - 1][iy - 1] =
229 DDTranslation(ee.vecEECRCtrs[iOff + 2], ee.vecEECRCtrs[iOff + 4], ee.vecEECRCtrs[iOff + 6]);
231 ee.cryRCtr[ix - 1][iy - 1] =
232 DDTranslation(ee.vecEECRCtrs[iOff + 3], ee.vecEECRCtrs[iOff + 5], ee.vecEECRCtrs[iOff + 7]);
235 dd4hep::Solid eeCRSolid = dd4hep::Trap(ee.cryName,
237 atan((ee.crysRear - ee.crysFront) / (
sqrt(2.) * ee.crysLength)),
249 <<
":" << (atan((ee.crysRear - ee.crysFront) / (
sqrt(2.) * ee.crysLength))) <<
":" 258 for (
unsigned int isc(0); isc < ee.nSCTypes; ++isc) {
259 unsigned int iSCType = isc + 1;
261 const double eFront(0.5 * ee.sCEFront);
262 const double eRear(0.5 * ee.sCERear);
263 const double eAng(atan((ee.sCERear - ee.sCEFront) / (
sqrt(2.) * ee.sCELength)));
264 const double ffived(45_deg);
265 const double zerod(0_deg);
271 eeSCEnvName, 0.5 * ee.sCELength, eAng, ffived, eFront, eFront, eFront, zerod, eRear, eRear, eRear, zerod));
274 <<
":" << eAng <<
":" << ffived <<
":" <<
cms::convert2mm(eFront) <<
":" 280 const double aFront(0.5 * ee.sCAFront);
281 const double aRear(0.5 * ee.sCARear);
282 const double aAng(atan((ee.sCARear - ee.sCAFront) / (
sqrt(2.) * ee.sCALength)));
288 eeSCAlvName, 0.5 * ee.sCALength, aAng, ffived, aFront, aFront, aFront, zerod, aRear, aRear, aRear, zerod));
291 <<
":" << aAng <<
":" << ffived <<
":" <<
cms::convert2mm(aFront) <<
":" 297 const double dwall(ee.sCAWall);
298 const double iFront(aFront - dwall);
299 const double iRear(iFront);
300 const double iLen(ee.iLength);
303 dd4hep::Solid eeSCInt = ns.
addSolidNS(eeSCIntName,
304 dd4hep::Trap(eeSCIntName,
306 atan((ee.sCARear - ee.sCAFront) / (
sqrt(2.) * ee.sCALength)),
318 << (atan((ee.sCARear - ee.sCAFront) / (
sqrt(2.) * ee.sCALength))) <<
":" << ffived
324 const double dz(-0.5 * (ee.sCELength - ee.sCALength));
325 const double dxy(0.5 *
dz * (ee.sCERear - ee.sCEFront) / ee.sCELength);
326 const double zIOff(-(ee.sCALength - iLen) / 2.);
327 const double xyIOff(ee.iXYOff);
339 const double half(ee.cutParms[0] - ee.pFHalf * ee.crysRear);
340 const double fifth(ee.cutParms[0] + ee.pFFifth * ee.crysRear);
341 const double fac(ee.pF45);
343 const double zmm(0 * dd4hep::mm);
349 : (5 == iSCType ?
DDTranslation(-half * fac, -half * fac, zmm)
352 const CLHEP::HepRotationZ cutm(ffived);
367 dd4hep::Solid eeCutEnv = dd4hep::SubtractionSolid(ee.envName +
std::to_string(iSCType),
370 dd4hep::Transform3D(cutRot, cutTra));
378 dd4hep::Solid eeCutAlv = dd4hep::SubtractionSolid(ee.alvName +
std::to_string(iSCType),
381 dd4hep::Transform3D(cutRot, cutTra - extra));
387 const double mySign(iSCType < 4 ? +1. : -1.);
389 const DDTranslation extraI(xyIOff + mySign * 2 * dd4hep::mm, xyIOff + mySign * 2 * dd4hep::mm, zIOff);
391 dd4hep::Solid eeCutInt = dd4hep::SubtractionSolid(ee.intName +
std::to_string(iSCType),
394 dd4hep::Transform3D(cutRot, cutTra - extraI));
406 eeSCALog.placeVolume(eeSCILog, iSCType * 100 + 1,
dd4hep::Position(xyIOff, xyIOff, zIOff));
408 edm::LogVerbatim(
"EEGeom") << eeSCALog.name() <<
" " << (iSCType * 100 + 1) <<
" in " << eeSCELog.name();
409 edm::LogVerbatim(
"EEGeom") << eeSCILog.name() <<
" " << (iSCType * 100 + 1) <<
" in " << eeSCALog.name();
410 edm::LogVerbatim(
"EcalGeom") << eeSCALog.name() <<
" " << (iSCType * 100 + 1) <<
" in " << eeSCELog.name()
413 edm::LogVerbatim(
"EcalGeom") << eeSCILog.name() <<
" " << (iSCType * 100 + 1) <<
" in " << eeSCALog.name()
420 static const unsigned int ncol(5);
422 if (iSCType > 0 && iSCType <= ee.nSCTypes) {
423 const unsigned int icoffset((iSCType - 1) * ncol - 1);
426 for (
unsigned int icol(1); icol <= ncol; ++icol) {
428 const int ncrcol((
int)ee.vecEESCProf[icoffset + icol]);
430 const int imin(0 < ncrcol ? 1 : (0 > ncrcol ? ncol + ncrcol + 1 : 0));
431 const int imax(0 < ncrcol ? ncrcol : (0 > ncrcol ? ncol : 0));
435 for (
int irow(imin); irow <= imax; ++irow) {
440 crystal.
moveto(ee.cryFCtr[icol - 1][irow - 1], ee.cryRCtr[icol - 1][irow - 1]);
444 if (
rname ==
"EECrRoC1R1") {
449 eeSCALog, eeCRLog, 100 * iSCType + 10 * (icol - 1) + (irow - 1), ns,
rname, crystal, ee.cryZOff);
451 eeSCALog.placeVolume(eeCRLog,
452 100 * iSCType + 10 * (icol - 1) + (irow - 1),
458 edm::LogVerbatim(
"EEGeom") << eeCRLog.name() <<
" " << (100 * iSCType + 10 * (icol - 1) + (irow - 1))
459 <<
" in " << eeSCALog.name();
460 edm::LogVerbatim(
"EcalGeom") << eeCRLog.name() <<
" " << (100 * iSCType + 10 * (icol - 1) + (irow - 1))
461 <<
" in " << eeSCALog.name() <<
" at (" 473 for (
int icol = 1; icol <=
int(ee.nColumns); icol++) {
475 for (
int irow =
int(ee.vecEEShape[2 * icol - 2]); irow <=
int(ee.vecEEShape[2 * icol - 1]); ++irow) {
476 if (ee.vecEESCLims[0] <= icol && ee.vecEESCLims[1] >= icol && ee.vecEESCLims[2] <= irow &&
477 ee.vecEESCLims[3] >= irow) {
479 unsigned int isctype = 1;
481 for (
unsigned int ii = 0;
ii < (
unsigned int)(ee.nSCCutaway); ++
ii) {
482 if ((ee.vecEESCCutaway[3 *
ii] == icol) && (ee.vecEESCCutaway[3 *
ii + 1] == irow)) {
483 isctype =
int(ee.vecEESCCutaway[3 *
ii + 2]);
490 scrys.
moveto(ee.scrFCtr[icol - 1][irow - 1], ee.scrRCtr[icol - 1][irow - 1]);
497 quaLog.placeVolume(childEnvLog,
498 100 * isctype + 10 * (icol - 1) + (irow - 1),
501 edm::LogVerbatim(
"EEGeom") << childEnvLog.name() <<
" " << (100 * isctype + 10 * (icol - 1) + (irow - 1))
502 <<
" in " << quaLog.name();
503 edm::LogVerbatim(
"EcalGeom") << childEnvLog.name() <<
" " << (100 * isctype + 10 * (icol - 1) + (irow - 1))
Log< level::Info, true > LogVerbatim
const dd4hep::Rotation3D & rotation(const std::string &name) const
DDTranslation centrePos()
void translate(const DDTranslation &trans)
constexpr NumType convert2mm(NumType length)
Sin< T >::type sin(const T &t)
std::string to_string(const V &value)
dd4hep::Material material(const std::string &name) const
static long algorithm(dd4hep::Detector &, cms::DDParsingContext &ctxt, xml_h e)
static std::string const input
#define DECLARE_DDCMS_DETELEMENT(name, func)
void addRotation(const std::string &name, const dd4hep::Rotation3D &rot) const
ROOT::Math::Rotation3D DDRotationMatrix
A DDRotationMatrix is currently implemented with a ROOT Rotation3D.
Cos< T >::type cos(const T &t)
dd4hep::Solid solid(const std::string &name) const
const G4String rname[NREG]
char data[epos_bytes_allocation]
static std::atomic< unsigned int > counter
DDRotationMatrix rotation()
dd4hep::Volume addVolumeNS(dd4hep::Volume vol) const
ROOT::Math::DisplacementVector3D< ROOT::Math::Cartesian3D< double > > DDTranslation
void moveto(const DDTranslation &frontCentre, const DDTranslation &rearCentre)
dd4hep::Volume volume(const std::string &name, bool exc=true) const
dd4hep::Solid addSolidNS(const std::string &name, dd4hep::Solid solid) const
std::string prepend(const std::string &) const