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_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 
)
static

Definition at line 94 of file DDEcalEndcapAlgo.cc.

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

References cms::DDNamespace::addSolidNS(), cms::DDNamespace::addVolumeNS(), writedatasetfile::args, cms::cuda::assert(), DDEcalEndcapTrap::centrePos(), counter, data, PVValHelper::dxy, PVValHelper::dz, MillePedeFileConverter_cfg::e, cuy::ii, createfilelist::int, cms::DDNamespace::material(), DDEcalEndcapTrap::moveto(), PixelTestBeamValidation_cfi::Position, rname, DDEcalEndcapTrap::rotation(), findQualityFiles::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 393 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:75
cms::Volume
dd4hep::Volume Volume
Definition: DDFilteredView.h:47
rname
const G4String rname[NREG]
Definition: ParametrisedEMPhysics.cc:48
createfilelist.int
int
Definition: createfilelist.py:10
cms::DDAlgoArguments
Definition: DDAlgoArguments.h:28
counter
static std::atomic< unsigned int > counter
Definition: SharedResourceNames.cc:17
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