CMS 3D CMS Logo

Typedefs | Functions
DDEcalEndcapAlgo.cc File Reference
#include "DD4hep/DetFactoryHelper.h"
#include "DetectorDescription/DDCMS/interface/DDPlugins.h"
#include "DetectorDescription/DDCMS/interface/BenchmarkGrd.h"
#include "DataFormats/Math/interface/CMSUnits.h"
#include "Geometry/EcalCommonData/interface/DDEcalEndcapTrap.h"
#include <CLHEP/Geometry/Transform3D.h>
#include <string>
#include <vector>

Go to the source code of this file.

Typedefs

using DDRotation = ROOT::Math::Rotation3D
 
using DDTranslation = ROOT::Math::DisplacementVector3D< ROOT::Math::Cartesian3D< double > >
 

Functions

static long algorithm (dd4hep::Detector &, cms::DDParsingContext &ctxt, xml_h e, dd4hep::SensitiveDetector &)
 
 DD4HEP_OPEN_PLUGIN (dd4hep, ddcms_det_element_DDCMS_ecal_DDEcalEndcapAlgo)
 

Typedef Documentation

◆ DDRotation

using DDRotation = ROOT::Math::Rotation3D

Definition at line 18 of file DDEcalEndcapAlgo.cc.

◆ DDTranslation

using DDTranslation = ROOT::Math::DisplacementVector3D<ROOT::Math::Cartesian3D<double> >

Definition at line 17 of file DDEcalEndcapAlgo.cc.

Function Documentation

◆ algorithm()

static long algorithm ( dd4hep::Detector &  ,
cms::DDParsingContext ctxt,
xml_h  e,
dd4hep::SensitiveDetector &   
)
static

Definition at line 94 of file DDEcalEndcapAlgo.cc.

97  {
98  BenchmarkGrd counter("DDEcalEndcapAlgo");
99  cms::DDNamespace ns(ctxt, e, true);
100  cms::DDAlgoArguments args(ctxt, e);
101 
102  // TRICK!
103  string myns{mynamespace(args.parentName()).data(), mynamespace(args.parentName()).size()};
104 
105  Endcap ee;
106  ee.mat = args.str("EEMat");
107  ee.zOff = args.dble("EEzOff");
108 
109  ee.quaName = args.str("EEQuaName");
110  ee.quaMat = args.str("EEQuaMat");
111  ee.crysMat = args.str("EECrysMat");
112  ee.wallMat = args.str("EEWallMat");
113  ee.crysLength = args.dble("EECrysLength");
114  ee.crysRear = args.dble("EECrysRear");
115  ee.crysFront = args.dble("EECrysFront");
116  ee.sCELength = args.dble("EESCELength");
117  ee.sCERear = args.dble("EESCERear");
118  ee.sCEFront = args.dble("EESCEFront");
119  ee.sCALength = args.dble("EESCALength");
120  ee.sCARear = args.dble("EESCARear");
121  ee.sCAFront = args.dble("EESCAFront");
122  ee.sCAWall = args.dble("EESCAWall");
123  ee.sCHLength = args.dble("EESCHLength");
124  ee.sCHSide = args.dble("EESCHSide");
125  ee.nSCTypes = args.dble("EEnSCTypes");
126  ee.nColumns = args.dble("EEnColumns");
127  ee.nSCCutaway = args.dble("EEnSCCutaway");
128  ee.nSCquad = args.dble("EEnSCquad");
129  ee.nCRSC = args.dble("EEnCRSC");
130  ee.vecEESCProf = args.vecDble("EESCProf");
131  ee.vecEEShape = args.vecDble("EEShape");
132  ee.vecEESCCutaway = args.vecDble("EESCCutaway");
133  ee.vecEESCCtrs = args.vecDble("EESCCtrs");
134  ee.vecEECRCtrs = args.vecDble("EECRCtrs");
135 
136  ee.cutBoxName = args.str("EECutBoxName");
137 
138  ee.envName = args.str("EEEnvName");
139  ee.alvName = args.str("EEAlvName");
140  ee.intName = args.str("EEIntName");
141  ee.cryName = args.str("EECryName");
142 
143  ee.pFHalf = args.dble("EEPFHalf");
144  ee.pFFifth = args.dble("EEPFFifth");
145  ee.pF45 = args.dble("EEPF45");
146 
147  ee.vecEESCLims = args.vecDble("EESCLims");
148  ee.iLength = args.dble("EEiLength");
149  ee.iXYOff = args.dble("EEiXYOff");
150  ee.cryZOff = args.dble("EECryZOff");
151  ee.zFront = args.dble("EEzFront");
152 
153  // Position supercrystals in EE Quadrant
154 
155  //********************************* cutbox for trimming edge SCs
156  const double cutWid(ee.sCERear / sqrt(2.));
157  ee.cutParms[0] = cutWid;
158  ee.cutParms[1] = cutWid;
159  ee.cutParms[2] = ee.sCELength / sqrt(2.);
160  Solid eeCutBox = Box(ee.cutBoxName, ee.cutParms[0], ee.cutParms[1], ee.cutParms[2]);
161  //**************************************************************
162 
163  const double zFix(ee.zFront - 3172_mm); // fix for changing z offset
164 
165  //** fill supercrystal front and rear center positions from xml input
166  for (unsigned int iC(0); iC != (unsigned int)ee.nSCquad; ++iC) {
167  const unsigned int iOff(8 * iC);
168  const unsigned int ix((unsigned int)ee.vecEESCCtrs[iOff + 0]);
169  const unsigned int iy((unsigned int)ee.vecEESCCtrs[iOff + 1]);
170 
171  assert(ix > 0 && ix < 11 && iy > 0 && iy < 11);
172 
173  ee.scrFCtr[ix - 1][iy - 1] =
174  DDTranslation(ee.vecEESCCtrs[iOff + 2], ee.vecEESCCtrs[iOff + 4], ee.vecEESCCtrs[iOff + 6] + zFix);
175 
176  ee.scrRCtr[ix - 1][iy - 1] =
177  DDTranslation(ee.vecEESCCtrs[iOff + 3], ee.vecEESCCtrs[iOff + 5], ee.vecEESCCtrs[iOff + 7] + zFix);
178  }
179 
180  //** fill crystal front and rear center positions from xml input
181  for (unsigned int iC(0); iC != 25; ++iC) {
182  const unsigned int iOff(8 * iC);
183  const unsigned int ix((unsigned int)ee.vecEECRCtrs[iOff + 0]);
184  const unsigned int iy((unsigned int)ee.vecEECRCtrs[iOff + 1]);
185 
186  assert(ix > 0 && ix < 6 && iy > 0 && iy < 6);
187 
188  ee.cryFCtr[ix - 1][iy - 1] =
189  DDTranslation(ee.vecEECRCtrs[iOff + 2], ee.vecEECRCtrs[iOff + 4], ee.vecEECRCtrs[iOff + 6]);
190 
191  ee.cryRCtr[ix - 1][iy - 1] =
192  DDTranslation(ee.vecEECRCtrs[iOff + 3], ee.vecEECRCtrs[iOff + 5], ee.vecEECRCtrs[iOff + 7]);
193  }
194 
195  Solid eeCRSolid = Trap(ee.cryName,
196  0.5 * ee.crysLength,
197  atan((ee.crysRear - ee.crysFront) / (sqrt(2.) * ee.crysLength)),
198  45._deg,
199  0.5 * ee.crysFront,
200  0.5 * ee.crysFront,
201  0.5 * ee.crysFront,
202  0._deg,
203  0.5 * ee.crysRear,
204  0.5 * ee.crysRear,
205  0.5 * ee.crysRear,
206  0._deg);
207  Volume eeCRLog = Volume(ee.cryName, eeCRSolid, ns.material(ee.crysMat));
208 
209  for (unsigned int isc(0); isc < ee.nSCTypes; ++isc) {
210  unsigned int iSCType = isc + 1;
211  const string anum(std::to_string(iSCType));
212  const double eFront(0.5 * ee.sCEFront);
213  const double eRear(0.5 * ee.sCERear);
214  const double eAng(atan((ee.sCERear - ee.sCEFront) / (sqrt(2.) * ee.sCELength)));
215  const double ffived(45_deg);
216  const double zerod(0_deg);
217  string eeSCEnvName(1 == iSCType ? ee.envName + std::to_string(iSCType)
218  : (ee.envName + std::to_string(iSCType) + "Tmp"));
219  Solid eeSCEnv = ns.addSolidNS(
220  eeSCEnvName,
221  Trap(eeSCEnvName, 0.5 * ee.sCELength, eAng, ffived, eFront, eFront, eFront, zerod, eRear, eRear, eRear, zerod));
222 
223  const double aFront(0.5 * ee.sCAFront);
224  const double aRear(0.5 * ee.sCARear);
225  const double aAng(atan((ee.sCARear - ee.sCAFront) / (sqrt(2.) * ee.sCALength)));
226  string eeSCAlvName(
227  (1 == iSCType ? ee.alvName + std::to_string(iSCType) : (ee.alvName + std::to_string(iSCType) + "Tmp")));
228  Solid eeSCAlv = ns.addSolidNS(
229  eeSCAlvName,
230  Trap(eeSCAlvName, 0.5 * ee.sCALength, aAng, ffived, aFront, aFront, aFront, zerod, aRear, aRear, aRear, zerod));
231 
232  const double dwall(ee.sCAWall);
233  const double iFront(aFront - dwall);
234  const double iRear(iFront);
235  const double iLen(ee.iLength);
236  string eeSCIntName(1 == iSCType ? ee.intName + std::to_string(iSCType)
237  : (ee.intName + std::to_string(iSCType) + "Tmp"));
238  Solid eeSCInt = ns.addSolidNS(eeSCIntName,
239  Trap(eeSCIntName,
240  iLen / 2.,
241  atan((ee.sCARear - ee.sCAFront) / (sqrt(2.) * ee.sCALength)),
242  ffived,
243  iFront,
244  iFront,
245  iFront,
246  zerod,
247  iRear,
248  iRear,
249  iRear,
250  zerod));
251 
252  const double dz(-0.5 * (ee.sCELength - ee.sCALength));
253  const double dxy(0.5 * dz * (ee.sCERear - ee.sCEFront) / ee.sCELength);
254  const double zIOff(-(ee.sCALength - iLen) / 2.);
255  const double xyIOff(ee.iXYOff);
256 
257  Volume eeSCELog;
258  Volume eeSCALog;
259  Volume eeSCILog;
260 
261  if (1 == iSCType) { // standard SC in this block
262  eeSCELog = ns.addVolumeNS(Volume(myns + ee.envName + std::to_string(iSCType), eeSCEnv, ns.material(ee.mat)));
263  eeSCALog = Volume(ee.alvName + std::to_string(iSCType), eeSCAlv, ns.material(ee.wallMat));
264  eeSCILog = Volume(ee.intName + std::to_string(iSCType), eeSCInt, ns.material(ee.mat));
265  } else { // partial SCs this block: create subtraction volumes as appropriate
266  const double half(ee.cutParms[0] - ee.pFHalf * ee.crysRear);
267  const double fifth(ee.cutParms[0] + ee.pFFifth * ee.crysRear);
268  const double fac(ee.pF45);
269 
270  const double zmm(0_mm);
271 
272  DDTranslation cutTra(
273  2 == iSCType ? DDTranslation(zmm, half, zmm)
274  : (3 == iSCType ? DDTranslation(half, zmm, zmm)
275  : (4 == iSCType ? DDTranslation(zmm, -fifth, zmm)
276  : (5 == iSCType ? DDTranslation(-half * fac, -half * fac, zmm)
277  : DDTranslation(-fifth, zmm, zmm)))));
278 
279  const CLHEP::HepRotationZ cutm(ffived);
280 
281  Rotation3D cutRot(5 != iSCType ? Rotation3D()
282  : myrot(ns,
283  "EECry5Rot",
284  Rotation3D(cutm.xx(),
285  cutm.xy(),
286  cutm.xz(),
287  cutm.yx(),
288  cutm.yy(),
289  cutm.yz(),
290  cutm.zx(),
291  cutm.zy(),
292  cutm.zz())));
293 
294  Solid eeCutEnv = SubtractionSolid(ee.envName + std::to_string(iSCType),
295  ns.solid(ee.envName + std::to_string(iSCType) + "Tmp"),
296  eeCutBox,
297  Transform3D(cutRot, cutTra));
298 
299  const DDTranslation extra(dxy, dxy, dz);
300 
301  Solid eeCutAlv = SubtractionSolid(ee.alvName + std::to_string(iSCType),
302  ns.solid(ee.alvName + std::to_string(iSCType) + "Tmp"),
303  eeCutBox,
304  Transform3D(cutRot, cutTra - extra));
305 
306  const double mySign(iSCType < 4 ? +1. : -1.);
307 
308  const DDTranslation extraI(xyIOff + mySign * 2_mm, xyIOff + mySign * 2_mm, zIOff);
309 
310  Solid eeCutInt = SubtractionSolid(ee.intName + std::to_string(iSCType),
311  ns.solid(ee.intName + std::to_string(iSCType) + "Tmp"),
312  eeCutBox,
313  Transform3D(cutRot, cutTra - extraI));
314 
315  eeSCELog = ns.addVolumeNS(Volume(myns + ee.envName + std::to_string(iSCType), eeCutEnv, ns.material(ee.mat)));
316  eeSCALog = Volume(ee.alvName + std::to_string(iSCType), eeCutAlv, ns.material(ee.wallMat));
317  eeSCILog = Volume(ee.intName + std::to_string(iSCType), eeCutInt, ns.material(ee.mat));
318  }
319  eeSCELog.placeVolume(eeSCALog, iSCType * 100 + 1, Position(dxy, dxy, dz));
320  eeSCALog.placeVolume(eeSCILog, iSCType * 100 + 1, Position(xyIOff, xyIOff, zIOff));
321 
322  DDTranslation croffset(0., 0., 0.);
323 
324  // Position crystals within parent supercrystal interior volume
325  static const unsigned int ncol(5);
326 
327  if (iSCType > 0 && iSCType <= ee.nSCTypes) {
328  const unsigned int icoffset((iSCType - 1) * ncol - 1);
329 
330  // Loop over columns of SC
331  for (unsigned int icol(1); icol <= ncol; ++icol) {
332  // Get column limits for this SC type from xml input
333  const int ncrcol((int)ee.vecEESCProf[icoffset + icol]);
334 
335  const int imin(0 < ncrcol ? 1 : (0 > ncrcol ? ncol + ncrcol + 1 : 0));
336  const int imax(0 < ncrcol ? ncrcol : (0 > ncrcol ? ncol : 0));
337 
338  if (imax > 0) {
339  // Loop over crystals in this row
340  for (int irow(imin); irow <= imax; ++irow) {
341  // Create crystal as a DDEcalEndcapTrap object and calculate rotation and
342  // translation required to position it in the SC.
343  DDEcalEndcapTrap crystal(1, ee.crysFront, ee.crysRear, ee.crysLength);
344 
345  crystal.moveto(ee.cryFCtr[icol - 1][irow - 1], ee.cryRCtr[icol - 1][irow - 1]);
346 
347  string rname("EECrRoC" + std::to_string(icol) + "R" + std::to_string(irow));
348 
349  eeSCALog.placeVolume(
350  eeCRLog,
351  100 * iSCType + 10 * (icol - 1) + (irow - 1),
352  Transform3D(
353  myrot(ns, rname, crystal.rotation()),
354  Position(crystal.centrePos().x(), crystal.centrePos().y(), crystal.centrePos().z() - ee.cryZOff)));
355  }
356  }
357  }
358  }
359  }
360 
361  //** Loop over endcap columns
362  for (int icol = 1; icol <= int(ee.nColumns); icol++) {
363  //** Loop over SCs in column, using limits from xml input
364  for (int irow = int(ee.vecEEShape[2 * icol - 2]); irow <= int(ee.vecEEShape[2 * icol - 1]); ++irow) {
365  if (ee.vecEESCLims[0] <= icol && ee.vecEESCLims[1] >= icol && ee.vecEESCLims[2] <= irow &&
366  ee.vecEESCLims[3] >= irow) {
367  // Find SC type (complete or partial) for this location
368  unsigned int isctype = 1;
369 
370  for (unsigned int ii = 0; ii < (unsigned int)(ee.nSCCutaway); ++ii) {
371  if ((ee.vecEESCCutaway[3 * ii] == icol) && (ee.vecEESCCutaway[3 * ii + 1] == irow)) {
372  isctype = int(ee.vecEESCCutaway[3 * ii + 2]);
373  }
374  }
375 
376  // Create SC as a DDEcalEndcapTrap object and calculate rotation and
377  // translation required to position it in the endcap.
378  DDEcalEndcapTrap scrys(1, ee.sCEFront, ee.sCERear, ee.sCELength);
379  scrys.moveto(ee.scrFCtr[icol - 1][irow - 1], ee.scrRCtr[icol - 1][irow - 1]);
380  scrys.translate(DDTranslation(0., 0., -ee.zOff));
381 
382  string rname(ee.envName + std::to_string(isctype) + std::to_string(icol) + "R" + std::to_string(irow));
383  // Position SC in endcap
384  Volume quaLog = ns.volume(ee.quaName);
385  Volume childEnvLog = ns.volume(myns + ee.envName + std::to_string(isctype));
386  quaLog.placeVolume(childEnvLog,
387  100 * isctype + 10 * (icol - 1) + (irow - 1),
388  Transform3D(scrys.rotation(), scrys.centrePos()));
389  }
390  }
391  }
392 
393  return 1;
394 }

References cms::DDNamespace::addSolidNS(), cms::DDNamespace::addVolumeNS(), writedatasetfile::args, cms::cuda::assert(), DDEcalEndcapTrap::centrePos(), counter, std::data(), PVValHelper::dxy, PVValHelper::dz, MillePedeFileConverter_cfg::e, cuy::ii, createfilelist::int, cms::DDNamespace::material(), DDEcalEndcapTrap::moveto(), PixelTestBeamValidation_cfi::Position, rname, DDEcalEndcapTrap::rotation(), std::size(), cms::DDNamespace::solid(), mathSSE::sqrt(), DDEcalEndcapTrap::translate(), and cms::DDNamespace::volume().

◆ DD4HEP_OPEN_PLUGIN()

DD4HEP_OPEN_PLUGIN ( dd4hep  ,
ddcms_det_element_DDCMS_ecal_DDEcalEndcapAlgo   
)

Definition at line 396 of file DDEcalEndcapAlgo.cc.

writedatasetfile.args
args
Definition: writedatasetfile.py:18
reco::HaloData::Endcap
Endcap
Definition: HaloData.h:14
cms::DDNamespace
Definition: DDNamespace.h:16
cms::cuda::assert
assert(be >=bs)
DDEcalEndcapTrap
Definition: DDEcalEndcapTrap.h:11
DDTranslation
ROOT::Math::DisplacementVector3D< ROOT::Math::Cartesian3D< double > > DDTranslation
Definition: DDTranslation.h:7
mathSSE::sqrt
T sqrt(T t)
Definition: SSEVec.h:19
PixelTestBeamValidation_cfi.Position
Position
Definition: PixelTestBeamValidation_cfi.py:62
cms::Volume
dd4hep::Volume Volume
Definition: DDFilteredView.h:45
rname
const G4String rname[NREG]
Definition: ParametrisedEMPhysics.cc:46
createfilelist.int
int
Definition: createfilelist.py:10
cms::DDAlgoArguments
Definition: DDAlgoArguments.h:28
counter
static std::atomic< unsigned int > counter
Definition: SharedResourceNames.cc:15
PVValHelper::dxy
Definition: PVValidationHelpers.h:47
PVValHelper::dz
Definition: PVValidationHelpers.h:50
BenchmarkGrd
Definition: BenchmarkGrd.h:9
data
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:79
cuy.ii
ii
Definition: cuy.py:590
findQualityFiles.size
size
Write out results.
Definition: findQualityFiles.py:443
MillePedeFileConverter_cfg.e
e
Definition: MillePedeFileConverter_cfg.py:37
DDTranslation
ROOT::Math::DisplacementVector3D< ROOT::Math::Cartesian3D< double > > DDTranslation
Definition: DDEcalEndcapAlgo.cc:17