CMS 3D CMS Logo

calowriters.cc
Go to the documentation of this file.
17 
18 template <>
21  const typename HcalGeometry::AlignedRecord& iRecord) {
22  const auto [alignPtr, globalPtr] = getAlignGlobal(iRecord);
23 
24  TrVec tvec;
25  DimVec dvec;
26  IVec ivec;
27  IVec dins;
28 
29  const auto& pG = iRecord.get(geometryToken_);
30 
31  pG.getSummary(tvec, ivec, dvec, dins);
32 
34  //*********************************************************************************************
35 
36  const auto& hcalTopology = iRecord.get(additionalTokens_.topology);
37 
38  // We know that the numer of shapes chanes with changing depth
39  // so, this check is temporary disabled. We need to implement
40  // a way either to store or calculate the number of shapes or be able
41  // to deal with only max numer of shapes.
42  assert(dvec.size() <= hcalTopology.getNumberOfShapes() * HcalGeometry::k_NumberOfParametersPerShape);
43  HcalGeometry* hcalGeometry = new HcalGeometry(hcalTopology);
44  PtrType ptr(hcalGeometry);
45 
46  const unsigned int nTrParm(hcalGeometry->numberOfTransformParms());
47 
48  ptr->fillDefaultNamedParameters();
49  ptr->allocateCorners(hcalTopology.ncells() + hcalTopology.getHFSize());
50  ptr->allocatePar(hcalGeometry->numberOfShapes(), HcalGeometry::k_NumberOfParametersPerShape);
51 
52  for (unsigned int i(0); i < dins.size(); ++i) {
53  const unsigned int nPerShape(HcalGeometry::k_NumberOfParametersPerShape);
54  DimVec dims;
55  dims.reserve(nPerShape);
56 
57  const unsigned int indx(ivec.size() == 1 ? 0 : i);
58 
59  DimVec::const_iterator dsrc(dvec.begin() + ivec[indx] * nPerShape);
60 
61  for (unsigned int j(0); j != nPerShape; ++j) {
62  dims.push_back(*dsrc);
63  ++dsrc;
64  }
65 
66  const CCGFloat* myParm(CaloCellGeometry::getParmPtr(dims, ptr->parMgr(), ptr->parVecVec()));
67 
68  const DetId id(hcalTopology.denseId2detId(dins[i]));
69 
70  const unsigned int iGlob(nullptr == globalPtr ? 0 : HcalGeometry::alignmentTransformIndexGlobal(id));
71 
72  assert(nullptr == globalPtr || iGlob < globalPtr->m_align.size());
73 
74  const AlignTransform* gt(nullptr == globalPtr ? nullptr : &globalPtr->m_align[iGlob]);
75 
76  assert(nullptr == gt || iGlob == HcalGeometry::alignmentTransformIndexGlobal(DetId(gt->rawId())));
77 
78  const unsigned int iLoc(nullptr == alignPtr ? 0 : HcalGeometry::alignmentTransformIndexLocal(id));
79 
80  assert(nullptr == alignPtr || iLoc < alignPtr->m_align.size());
81 
82  const AlignTransform* at(nullptr == alignPtr ? nullptr : &alignPtr->m_align[iLoc]);
83 
84  assert(nullptr == at || (HcalGeometry::alignmentTransformIndexLocal(DetId(at->rawId())) == iLoc));
85 
86  Pt3D lRef;
87  Pt3DVec lc(8, Pt3D(0, 0, 0));
88  hcalGeometry->localCorners(lc, &dims.front(), dins[i], lRef);
89 
90  const Pt3D lBck(0.25 * (lc[4] + lc[5] + lc[6] + lc[7])); // ctr rear face in local
91  const Pt3D lCor(lc[0]);
92 
93  //----------------------------------- create transform from 6 numbers ---
94  const unsigned int jj(i * nTrParm);
95 
96  Tr3D tr;
97  const ROOT::Math::Translation3D tl(tvec[jj], tvec[jj + 1], tvec[jj + 2]);
98  const ROOT::Math::EulerAngles ea(6 == nTrParm ? ROOT::Math::EulerAngles(tvec[jj + 3], tvec[jj + 4], tvec[jj + 5])
100  const ROOT::Math::Transform3D rt(ea, tl);
101  double xx, xy, xz, dx;
102  double yx, yy, yz, dy;
103  double zx, zy, zz, dz;
104  rt.GetComponents(xx, xy, xz, dx, yx, yy, yz, dy, zx, zy, zz, dz);
105  tr = Tr3D(CLHEP::HepRep3x3(xx, xy, xz, yx, yy, yz, zx, zy, zz), CLHEP::Hep3Vector(dx, dy, dz));
106 
107  // now prepend alignment(s) for final transform
108  const Tr3D atr(nullptr == at ? tr
109  : (nullptr == gt ? at->transform() * tr : at->transform() * gt->transform() * tr));
110  //--------------------------------- done making transform ---------------
111 
112  const Pt3D gRef(atr * lRef);
113  const GlobalPoint fCtr(gRef.x(), gRef.y(), gRef.z());
114  const Pt3D gBck(atr * lBck);
115  const GlobalPoint fBck(gBck.x(), gBck.y(), gBck.z());
116  const Pt3D gCor(atr * lCor);
117  const GlobalPoint fCor(gCor.x(), gCor.y(), gCor.z());
118 
119  assert(hcalTopology.detId2denseId(id) == dins[i]);
120  ptr->newCell(fCtr, fBck, fCor, myParm, id);
121  }
122 
123  ptr->initializeParms(); // initializations; must happen after cells filled
124 
125  return ptr;
126 }
127 
128 template <>
131  const typename CaloTowerGeometry::AlignedRecord& iRecord) {
132  const auto [alignPtr, globalPtr] = getAlignGlobal(iRecord);
133 
134  TrVec tvec;
135  DimVec dvec;
136  IVec ivec;
137  IVec dins;
138 
139  const auto& pG = iRecord.get(geometryToken_);
140 
141  pG.getSummary(tvec, ivec, dvec, dins);
142 
144  //*********************************************************************************************
145 
146  const auto& caloTopology = iRecord.get(additionalTokens_.topology);
147 
148  CaloTowerGeometry* ctg = new CaloTowerGeometry(&caloTopology);
149 
150  const unsigned int nTrParm(tvec.size() / ctg->numberOfCellsForCorners());
151 
153 
154  PtrType ptr(ctg);
155 
156  ptr->fillDefaultNamedParameters();
157 
158  ptr->allocateCorners(ctg->numberOfCellsForCorners());
159 
160  ptr->allocatePar(dvec.size(), CaloTowerGeometry::k_NumberOfParametersPerShape);
161 
162  for (unsigned int i(0); i < dins.size(); ++i) {
163  const unsigned int nPerShape(ctg->numberOfParametersPerShape());
164  DimVec dims;
165  dims.reserve(nPerShape);
166 
167  const unsigned int indx(ivec.size() == 1 ? 0 : i);
168 
169  DimVec::const_iterator dsrc(dvec.begin() + ivec[indx] * nPerShape);
170 
171  for (unsigned int j(0); j != nPerShape; ++j) {
172  dims.push_back(*dsrc);
173  ++dsrc;
174  }
175 
176  const CCGFloat* myParm(CaloCellGeometry::getParmPtr(dims, ptr->parMgr(), ptr->parVecVec()));
177 
178  const DetId id(caloTopology.detIdFromDenseIndex(dins[i]));
179 
180  const unsigned int iGlob(nullptr == globalPtr ? 0 : ctg->alignmentTransformIndexGlobal(id));
181 
182  assert(nullptr == globalPtr || iGlob < globalPtr->m_align.size());
183 
184  const AlignTransform* gt(nullptr == globalPtr ? nullptr : &globalPtr->m_align[iGlob]);
185 
186  assert(nullptr == gt || iGlob == ctg->alignmentTransformIndexGlobal(DetId(gt->rawId())));
187 
188  const unsigned int iLoc(nullptr == alignPtr ? 0 : ctg->alignmentTransformIndexLocal(id));
189 
190  assert(nullptr == alignPtr || iLoc < alignPtr->m_align.size());
191 
192  const AlignTransform* at(nullptr == alignPtr ? nullptr : &alignPtr->m_align[iLoc]);
193 
194  assert(nullptr == at || (ctg->alignmentTransformIndexLocal(DetId(at->rawId())) == iLoc));
195 
196  const CaloGenericDetId gId(id);
197 
198  Pt3D lRef;
199  Pt3DVec lc(8, Pt3D(0, 0, 0));
200  ctg->localCorners(lc, &dims.front(), dins[i], lRef);
201 
202  const Pt3D lBck(0.25 * (lc[4] + lc[5] + lc[6] + lc[7])); // ctr rear face in local
203  const Pt3D lCor(lc[0]);
204 
205  //----------------------------------- create transform from 6 numbers ---
206  const unsigned int jj(i * nTrParm);
207  Tr3D tr;
208  const ROOT::Math::Translation3D tl(tvec[jj], tvec[jj + 1], tvec[jj + 2]);
209  const ROOT::Math::EulerAngles ea(6 == nTrParm ? ROOT::Math::EulerAngles(tvec[jj + 3], tvec[jj + 4], tvec[jj + 5])
211  const ROOT::Math::Transform3D rt(ea, tl);
212  double xx, xy, xz, dx, yx, yy, yz, dy, zx, zy, zz, dz;
213  rt.GetComponents(xx, xy, xz, dx, yx, yy, yz, dy, zx, zy, zz, dz);
214  tr = Tr3D(CLHEP::HepRep3x3(xx, xy, xz, yx, yy, yz, zx, zy, zz), CLHEP::Hep3Vector(dx, dy, dz));
215 
216  // now prepend alignment(s) for final transform
217  const Tr3D atr(nullptr == at ? tr
218  : (nullptr == gt ? at->transform() * tr : at->transform() * gt->transform() * tr));
219  //--------------------------------- done making transform ---------------
220 
221  const Pt3D gRef(atr * lRef);
222  const GlobalPoint fCtr(gRef.x(), gRef.y(), gRef.z());
223  const Pt3D gBck(atr * lBck);
224  const GlobalPoint fBck(gBck.x(), gBck.y(), gBck.z());
225  const Pt3D gCor(atr * lCor);
226  const GlobalPoint fCor(gCor.x(), gCor.y(), gCor.z());
227 
228  assert(caloTopology.denseIndex(id) == dins[i]);
229 
230  ptr->newCell(fCtr, fBck, fCor, myParm, id);
231  }
232 
233  ptr->initializeParms(); // initializations; must happen after cells filled
234 
235  return ptr;
236 }
237 
238 template <>
241  const typename HGCalGeometry::AlignedRecord& iRecord) {
242  TrVec tvec; // transformation
243  DimVec dvec; // parameters
244  IVec ivec; // layers
245  IVec dins; // valid geom ids
246 
247  const auto& geom = iRecord.get(geometryToken_);
248 
249  geom.getSummary(tvec, ivec, dvec, dins);
250 
252  //*********************************************************************************************
253 
254  const auto& topology = iRecord.get(additionalTokens_.topology);
255 
256  assert(dvec.size() <= topology.totalGeomModules() * HGCalGeometry::k_NumberOfParametersPerShape);
258  PtrType ptr(hcg);
259 
260  ptr->allocateCorners(topology.ncells());
262 
263  const unsigned int nTrParm(ptr->numberOfTransformParms());
264  const unsigned int nPerShape(HGCalGeometry::k_NumberOfParametersPerShape);
265 
266  for (auto it : dins) {
267  DetId id = topology.encode(topology.geomDenseId2decId(it));
268  // get layer
269  int layer = ivec[it];
270 
271  // get transformation
272  const unsigned int jj(it * nTrParm);
273  Tr3D tr;
274  const ROOT::Math::Translation3D tl(tvec[jj], tvec[jj + 1], tvec[jj + 2]);
275  const ROOT::Math::EulerAngles ea(6 == nTrParm ? ROOT::Math::EulerAngles(tvec[jj + 3], tvec[jj + 4], tvec[jj + 5])
277  const ROOT::Math::Transform3D rt(ea, tl);
278  double xx, xy, xz, dx, yx, yy, yz, dy, zx, zy, zz, dz;
279  rt.GetComponents(xx, xy, xz, dx, yx, yy, yz, dy, zx, zy, zz, dz);
280  tr = Tr3D(CLHEP::HepRep3x3(xx, xy, xz, yx, yy, yz, zx, zy, zz), CLHEP::Hep3Vector(dx, dy, dz));
281 
282  // get parameters
283  DimVec dims;
284  dims.reserve(nPerShape);
285 
286  DimVec::const_iterator dsrc(dvec.begin() + layer * nPerShape);
287  for (unsigned int j(0); j != nPerShape; ++j) {
288  dims.push_back(*dsrc);
289  ++dsrc;
290  }
291 
292  std::vector<GlobalPoint> corners(FlatHexagon::ncorner_);
293 
294  FlatHexagon::createCorners(dims, tr, corners);
295 
296  const CCGFloat* myParm(CaloCellGeometry::getParmPtr(dims, ptr->parMgr(), ptr->parVecVec()));
297  GlobalPoint front(
299  (corners[0].x() + corners[1].x() + corners[2].x() + corners[3].x() + corners[4].x() + corners[5].x()),
301  (corners[0].y() + corners[1].y() + corners[2].y() + corners[3].y() + corners[4].y() + corners[5].y()),
303  (corners[0].z() + corners[1].z() + corners[2].z() + corners[3].z() + corners[4].z() + corners[5].z()));
304 
305  GlobalPoint back(
307  (corners[6].x() + corners[7].x() + corners[8].x() + corners[9].x() + corners[10].x() + corners[11].x()),
309  (corners[6].y() + corners[7].y() + corners[8].y() + corners[9].y() + corners[10].y() + corners[11].y()),
311  (corners[6].z() + corners[7].z() + corners[8].z() + corners[9].z() + corners[10].z() + corners[11].z()));
312 
313  if (front.mag2() > back.mag2()) { // front should always point to the center, so swap front and back
314  std::swap(front, back);
315  std::swap_ranges(
316  corners.begin(), corners.begin() + FlatHexagon::ncornerBy2_, corners.begin() + FlatHexagon::ncornerBy2_);
317  }
318 
319  ptr->newCell(front, back, corners[0], myParm, id);
320  }
321 
322  ptr->initializeParms(); // initializations; must happen after cells filled
323 
324  return ptr;
325 }
326 
327 template <>
330  const auto [alignPtr, globalPtr] = getAlignGlobal(iRecord);
331 
332  TrVec tvec;
333  DimVec dvec;
334  IVec ivec;
335  IVec dins;
336 
337  const auto& pG = iRecord.get(geometryToken_);
338 
339  pG.getSummary(tvec, ivec, dvec, dins);
340 
342  //*********************************************************************************************
343 
344  const auto& zdcTopology = iRecord.get(additionalTokens_.topology);
345 
346  // We know that the numer of shapes chanes with changing depth
347  // so, this check is temporary disabled. We need to implement
348  // a way either to store or calculate the number of shapes or be able
349  // to deal with only max numer of shapes.
351  ZdcGeometry* zdcGeometry = new ZdcGeometry(&zdcTopology);
352  PtrType ptr(zdcGeometry);
353 
354  const unsigned int nTrParm(tvec.size() / zdcTopology.kSizeForDenseIndexing());
355 
356  ptr->fillDefaultNamedParameters();
357  ptr->allocateCorners(zdcTopology.kSizeForDenseIndexing());
358  ptr->allocatePar(zdcGeometry->numberOfShapes(), ZdcGeometry::k_NumberOfParametersPerShape);
359 
360  for (unsigned int i(0); i < dins.size(); ++i) {
361  const unsigned int nPerShape(ZdcGeometry::k_NumberOfParametersPerShape);
362  DimVec dims;
363  dims.reserve(nPerShape);
364 
365  const unsigned int indx(ivec.size() == 1 ? 0 : i);
366 
367  DimVec::const_iterator dsrc(dvec.begin() + ivec[indx] * nPerShape);
368 
369  for (unsigned int j(0); j != nPerShape; ++j) {
370  dims.push_back(*dsrc);
371  ++dsrc;
372  }
373 
374  const CCGFloat* myParm(CaloCellGeometry::getParmPtr(dims, ptr->parMgr(), ptr->parVecVec()));
375 
376  const DetId id(zdcTopology.denseId2detId(dins[i]));
377 
378  const unsigned int iGlob(nullptr == globalPtr ? 0 : ZdcGeometry::alignmentTransformIndexGlobal(id));
379 
380  assert(nullptr == globalPtr || iGlob < globalPtr->m_align.size());
381 
382  const AlignTransform* gt(nullptr == globalPtr ? nullptr : &globalPtr->m_align[iGlob]);
383 
384  assert(nullptr == gt || iGlob == ZdcGeometry::alignmentTransformIndexGlobal(DetId(gt->rawId())));
385 
386  const unsigned int iLoc(nullptr == alignPtr ? 0 : ZdcGeometry::alignmentTransformIndexLocal(id));
387 
388  assert(nullptr == alignPtr || iLoc < alignPtr->m_align.size());
389 
390  const AlignTransform* at(nullptr == alignPtr ? nullptr : &alignPtr->m_align[iLoc]);
391 
392  assert(nullptr == at || (ZdcGeometry::alignmentTransformIndexLocal(DetId(at->rawId())) == iLoc));
393 
394  Pt3D lRef;
395  Pt3DVec lc(8, Pt3D(0, 0, 0));
396  zdcGeometry->localCorners(lc, &dims.front(), dins[i], lRef);
397 
398  const Pt3D lBck(0.25 * (lc[4] + lc[5] + lc[6] + lc[7])); // ctr rear face in local
399  const Pt3D lCor(lc[0]);
400 
401  //----------------------------------- create transform from 6 numbers ---
402  const unsigned int jj(i * nTrParm);
403  Tr3D tr;
404  const ROOT::Math::Translation3D tl(tvec[jj], tvec[jj + 1], tvec[jj + 2]);
405  const ROOT::Math::EulerAngles ea(6 == nTrParm ? ROOT::Math::EulerAngles(tvec[jj + 3], tvec[jj + 4], tvec[jj + 5])
407  const ROOT::Math::Transform3D rt(ea, tl);
408  double xx, xy, xz, dx;
409  double yx, yy, yz, dy;
410  double zx, zy, zz, dz;
411  rt.GetComponents(xx, xy, xz, dx, yx, yy, yz, dy, zx, zy, zz, dz);
412  tr = Tr3D(CLHEP::HepRep3x3(xx, xy, xz, yx, yy, yz, zx, zy, zz), CLHEP::Hep3Vector(dx, dy, dz));
413 
414  // now prepend alignment(s) for final transform
415  const Tr3D atr(nullptr == at ? tr
416  : (nullptr == gt ? at->transform() * tr : at->transform() * gt->transform() * tr));
417  //--------------------------------- done making transform ---------------
418 
419  const Pt3D gRef(atr * lRef);
420  const GlobalPoint fCtr(gRef.x(), gRef.y(), gRef.z());
421  const Pt3D gBck(atr * lBck);
422  const GlobalPoint fBck(gBck.x(), gBck.y(), gBck.z());
423  const Pt3D gCor(atr * lCor);
424  const GlobalPoint fCor(gCor.x(), gCor.y(), gCor.z());
425 
426  assert(zdcTopology.detId2denseId(id) == dins[i]);
427  ptr->newCell(fCtr, fBck, fCor, myParm, id);
428  }
429 
430  ptr->initializeParms(); // initializations; must happen after cells filled
431 
432  return ptr;
433 }
434 
438 
443 
445 
447 
449 
451 
453 
455 
457 
459 
461 
463 
465 
467 
469 
471 
473 
static constexpr unsigned int k_NumberOfShapes
Definition: HGCalGeometry.h:46
static void createCorners(const std::vector< CCGFloat > &pv, const Tr3D &tr, std::vector< GlobalPoint > &co)
Definition: FlatHexagon.cc:134
static unsigned int alignmentTransformIndexLocal(const DetId &id)
Definition: ZdcGeometry.cc:63
CaloCellGeometry::Pt3D Pt3D
CaloGeometryDBEP< HcalGeometry, CaloGeometryDBWriter > HcalGeometryToDBEP
Definition: calowriters.cc:456
static unsigned int alignmentTransformIndexLocal(const DetId &id)
virtual unsigned int numberOfCellsForCorners() const
static void writeIndexed(const TrVec &tvec, const DimVec &dvec, const IVec &ivec, const IVec &dins, const std::string &tag)
unsigned int numberOfShapes() const override
CaloGeometryDBEP< CastorGeometry, CaloGeometryDBWriter > CastorGeometryToDBEP
Definition: calowriters.cc:468
std::unique_ptr< CaloSubdetectorGeometry > PtrType
static unsigned int alignmentTransformIndexGlobal(const DetId &id)
Definition: ZdcGeometry.cc:70
static constexpr int k_NumberOfParametersPerShape
Definition: ZdcGeometry.h:31
unsigned int numberOfParametersPerShape() const override
CaloCellGeometry::Pt3DVec Pt3DVec
unsigned int alignmentTransformIndexLocal(const DetId &id)
T mag2() const
Definition: PV3DBase.h:63
assert(be >=bs)
float float float z
void swap(Association< C > &lhs, Association< C > &rhs)
Definition: Association.h:112
static constexpr unsigned int ncorner_
Definition: FlatHexagon.h:81
CaloGeometryDBEP< EcalEndcapGeometry, CaloGeometryDBWriter > EcalEndcapGeometryToDBEP
Definition: calowriters.cc:448
CaloSubdetectorGeometry::IVec IVec
static constexpr unsigned int k_NumberOfParametersPerShape
Definition: HGCalGeometry.h:45
CaloGeometryDBEP< CaloTowerGeometry, CaloGeometryDBWriter > CaloTowerGeometryToDBEP
Definition: calowriters.cc:460
CaloGeometryDBEP< ZdcGeometry, CaloGeometryDBWriter > ZdcGeometryToDBEP
Definition: calowriters.cc:464
static constexpr int k_NumberOfShapes
Definition: ZdcGeometry.h:29
static std::string dbString()
Definition: HGCalGeometry.h:49
static std::string dbString()
static unsigned int alignmentTransformIndexGlobal(const DetId &id)
PtrType produceAligned(const typename T::AlignedRecord &iRecord)
CaloSubdetectorGeometry::TrVec TrVec
static const CCGFloat * getParmPtr(const std::vector< CCGFloat > &vd, ParMgr *mgr, ParVecVec &pvv)
CaloGeometryDBEP< EcalPreshowerGeometry, CaloGeometryDBWriter > EcalPreshowerGeometryToDBEP
Definition: calowriters.cc:452
unsigned int alignmentTransformIndexGlobal(const DetId &id)
#define DEFINE_FWK_EVENTSETUP_MODULE(type)
Definition: ModuleFactory.h:61
CaloCellGeometry::Pt3D Pt3D
static void localCorners(Pt3DVec &lc, const CCGFloat *pv, unsigned int i, Pt3D &ref)
Definition: DetId.h:17
static constexpr unsigned int ncornerBy2_
Definition: FlatHexagon.h:82
AlgebraicVector EulerAngles
Definition: Definitions.h:34
CaloGeometryDBEP< HGCalGeometry, CaloGeometryDBWriter > HGCalGeometryToDBEP
Definition: calowriters.cc:472
static std::string dbString()
Definition: HcalGeometry.h:40
CaloCellGeometry::Tr3D Tr3D
CaloCellGeometry::Tr3D Tr3D
float x
CaloSubdetectorGeometry::DimVec DimVec
CaloGeometryDBEP< EcalBarrelGeometry, CaloGeometryDBWriter > EcalBarrelGeometryToDBEP
Definition: calowriters.cc:444
ProductT const & get(ESGetToken< ProductT, DepRecordT > const &iToken) const
CaloCellGeometry::CCGFloat CCGFloat
static std::string dbString()
Definition: ZdcGeometry.h:33
static constexpr double oneBySix_
Definition: FlatHexagon.h:80