CMS 3D CMS Logo

moduleDB.cc
Go to the documentation of this file.
5 
9 
10 template <>
13  const typename HcalGeometry::AlignedRecord& iRecord) {
14  const auto [alignPtr, globalPtr] = getAlignGlobal(iRecord);
15 
16  TrVec tvec;
17  DimVec dvec;
18  IVec ivec;
19  IVec dins;
20 
21  const auto& pG = iRecord.get(geometryToken_);
22 
23  tvec = pG.getTranslation();
24  dvec = pG.getDimension();
25  ivec = pG.getIndexes();
26  dins = pG.getDenseIndices();
27  //*********************************************************************************************
28 
29  const auto& hcalTopology = iRecord.get(additionalTokens_.topology);
30 
31  // We know that the numer of shapes chanes with changing depth
32  // so, this check is temporary disabled. We need to implement
33  // a way either to store or calculate the number of shapes or be able
34  // to deal with only max numer of shapes.
35  // assert( dvec.size() == hcalTopology.getNumberOfShapes() * HcalGeometry::k_NumberOfParametersPerShape ) ;
36  assert(dvec.size() <= hcalTopology.getNumberOfShapes() * HcalGeometry::k_NumberOfParametersPerShape);
37  HcalGeometry* hcg = new HcalGeometry(hcalTopology);
38 
39  PtrType ptr(hcg);
40 
41  const unsigned int nTrParm(hcg->numberOfTransformParms());
42 
43  ptr->fillDefaultNamedParameters();
44  ptr->allocateCorners(hcalTopology.ncells() + hcalTopology.getHFSize());
45  ptr->allocatePar(dvec.size(), HcalGeometry::k_NumberOfParametersPerShape);
46 
47  for (unsigned int i(0); i < dins.size(); ++i) {
48  const unsigned int nPerShape(HcalGeometry::k_NumberOfParametersPerShape);
49  DimVec dims;
50  dims.reserve(nPerShape);
51 
52  const unsigned int indx(ivec.size() == 1 ? 0 : i);
53 
54  DimVec::const_iterator dsrc(dvec.begin() + ivec[indx] * nPerShape);
55 
56  for (unsigned int j(0); j != nPerShape; ++j) {
57  dims.emplace_back(*dsrc);
58  ++dsrc;
59  }
60 
61  const CCGFloat* myParm(CaloCellGeometry::getParmPtr(dims, ptr->parMgr(), ptr->parVecVec()));
62 
63  const DetId id(hcalTopology.denseId2detId(dins[i]));
64 
65  const unsigned int iGlob(nullptr == globalPtr ? 0 : HcalGeometry::alignmentTransformIndexGlobal(id));
66 
67  assert(nullptr == globalPtr || iGlob < globalPtr->m_align.size());
68 
69  const AlignTransform* gt(nullptr == globalPtr ? nullptr : &globalPtr->m_align[iGlob]);
70 
71  assert(nullptr == gt || iGlob == HcalGeometry::alignmentTransformIndexGlobal(DetId(gt->rawId())));
72 
73  const unsigned int iLoc(nullptr == alignPtr ? 0 : HcalGeometry::alignmentTransformIndexLocal(id));
74 
75  assert(nullptr == alignPtr || iLoc < alignPtr->m_align.size());
76 
77  const AlignTransform* at(nullptr == alignPtr ? nullptr : &alignPtr->m_align[iLoc]);
78 
79  assert(nullptr == at || (HcalGeometry::alignmentTransformIndexLocal(DetId(at->rawId())) == iLoc));
80 
81  Pt3D lRef;
82  Pt3DVec lc(8, Pt3D(0, 0, 0));
83  hcg->localCorners(lc, &dims.front(), dins[i], lRef);
84 
85  const Pt3D lBck(0.25 * (lc[4] + lc[5] + lc[6] + lc[7])); // ctr rear face in local
86  const Pt3D lCor(lc[0]);
87 
88  //----------------------------------- create transform from 6 numbers ---
89  const unsigned int jj(i * nTrParm); // Note: Dence indices are not sorted and
90  // parameters stored according to order of a cell creation
91  Tr3D tr;
92  const ROOT::Math::Translation3D tl(tvec[jj], tvec[jj + 1], tvec[jj + 2]);
93  const ROOT::Math::EulerAngles ea(6 == nTrParm ? ROOT::Math::EulerAngles(tvec[jj + 3], tvec[jj + 4], tvec[jj + 5])
95  const ROOT::Math::Transform3D rt(ea, tl);
96  double xx, xy, xz, dx;
97  double yx, yy, yz, dy;
98  double zx, zy, zz, dz;
99  rt.GetComponents(xx, xy, xz, dx, yx, yy, yz, dy, zx, zy, zz, dz);
100  tr = Tr3D(CLHEP::HepRep3x3(xx, xy, xz, yx, yy, yz, zx, zy, zz), CLHEP::Hep3Vector(dx, dy, dz));
101 
102  // now prepend alignment(s) for final transform
103  const Tr3D atr(nullptr == at ? tr
104  : (nullptr == gt ? at->transform() * tr : at->transform() * gt->transform() * tr));
105  //--------------------------------- done making transform ---------------
106 
107  const Pt3D gRef(atr * lRef);
108  const GlobalPoint fCtr(gRef.x(), gRef.y(), gRef.z());
109  const Pt3D gBck(atr * lBck);
110  const GlobalPoint fBck(gBck.x(), gBck.y(), gBck.z());
111  const Pt3D gCor(atr * lCor);
112  const GlobalPoint fCor(gCor.x(), gCor.y(), gCor.z());
113 
114  assert(hcalTopology.detId2denseId(id) == dins[i]);
115 
116  ptr->newCell(fCtr, fBck, fCor, myParm, id);
117  }
118 
119  ptr->initializeParms(); // initializations; must happen after cells filled
120 
121  return ptr;
122 }
123 
124 template <>
127  const typename CaloTowerGeometry::AlignedRecord& iRecord) {
128  const auto [alignPtr, globalPtr] = getAlignGlobal(iRecord);
129 
130  TrVec tvec;
131  DimVec dvec;
132  IVec ivec;
133  IVec dins;
134 
135  const auto& pG = iRecord.get(geometryToken_);
136 
137  tvec = pG.getTranslation();
138  dvec = pG.getDimension();
139  ivec = pG.getIndexes();
140  dins = pG.getDenseIndices();
141  //*********************************************************************************************
142 
143  const auto& caloTopology = iRecord.get(additionalTokens_.topology);
144 
145  CaloTowerGeometry* ctg = new CaloTowerGeometry(&caloTopology);
146 
147  const unsigned int nTrParm(tvec.size() / ctg->numberOfCellsForCorners());
148 
150 
151  PtrType ptr(ctg);
152 
153  ptr->fillDefaultNamedParameters();
154 
155  ptr->allocateCorners(ctg->numberOfCellsForCorners());
156 
157  ptr->allocatePar(dvec.size(), CaloTowerGeometry::k_NumberOfParametersPerShape);
158 
159  for (unsigned int i(0); i < dins.size(); ++i) {
160  const unsigned int nPerShape(ctg->numberOfParametersPerShape());
161  DimVec dims;
162  dims.reserve(nPerShape);
163 
164  const unsigned int indx(ivec.size() == 1 ? 0 : i);
165 
166  DimVec::const_iterator dsrc(dvec.begin() + ivec[indx] * nPerShape);
167 
168  for (unsigned int j(0); j != nPerShape; ++j) {
169  dims.emplace_back(*dsrc);
170  ++dsrc;
171  }
172 
173  const CCGFloat* myParm(CaloCellGeometry::getParmPtr(dims, ptr->parMgr(), ptr->parVecVec()));
174 
175  const DetId id(caloTopology.detIdFromDenseIndex(dins[i]));
176 
177  const unsigned int iGlob(nullptr == globalPtr ? 0 : ctg->alignmentTransformIndexGlobal(id));
178 
179  assert(nullptr == globalPtr || iGlob < globalPtr->m_align.size());
180 
181  const AlignTransform* gt(nullptr == globalPtr ? nullptr : &globalPtr->m_align[iGlob]);
182 
183  assert(nullptr == gt || iGlob == ctg->alignmentTransformIndexGlobal(DetId(gt->rawId())));
184 
185  const unsigned int iLoc(nullptr == alignPtr ? 0 : ctg->alignmentTransformIndexLocal(id));
186 
187  assert(nullptr == alignPtr || iLoc < alignPtr->m_align.size());
188 
189  const AlignTransform* at(nullptr == alignPtr ? nullptr : &alignPtr->m_align[iLoc]);
190 
191  assert(nullptr == at || (ctg->alignmentTransformIndexLocal(DetId(at->rawId())) == iLoc));
192 
193  const CaloGenericDetId gId(id);
194 
195  Pt3D lRef;
196  Pt3DVec lc(8, Pt3D(0, 0, 0));
197  ctg->localCorners(lc, &dims.front(), dins[i], lRef);
198 
199  const Pt3D lBck(0.25 * (lc[4] + lc[5] + lc[6] + lc[7])); // ctr rear face in local
200  const Pt3D lCor(lc[0]);
201 
202  //----------------------------------- create transform from 6 numbers ---
203  const unsigned int jj(i * nTrParm);
204  Tr3D tr;
205  const ROOT::Math::Translation3D tl(tvec[jj], tvec[jj + 1], tvec[jj + 2]);
206  const ROOT::Math::EulerAngles ea(6 == nTrParm ? ROOT::Math::EulerAngles(tvec[jj + 3], tvec[jj + 4], tvec[jj + 5])
208  const ROOT::Math::Transform3D rt(ea, tl);
209  double xx, xy, xz, dx, yx, yy, yz, dy, zx, zy, zz, dz;
210  rt.GetComponents(xx, xy, xz, dx, yx, yy, yz, dy, zx, zy, zz, dz);
211  tr = Tr3D(CLHEP::HepRep3x3(xx, xy, xz, yx, yy, yz, zx, zy, zz), CLHEP::Hep3Vector(dx, dy, dz));
212 
213  // now prepend alignment(s) for final transform
214  const Tr3D atr(nullptr == at ? tr
215  : (nullptr == gt ? at->transform() * tr : at->transform() * gt->transform() * tr));
216  //--------------------------------- done making transform ---------------
217 
218  const Pt3D gRef(atr * lRef);
219  const GlobalPoint fCtr(gRef.x(), gRef.y(), gRef.z());
220  const Pt3D gBck(atr * lBck);
221  const GlobalPoint fBck(gBck.x(), gBck.y(), gBck.z());
222  const Pt3D gCor(atr * lCor);
223  const GlobalPoint fCor(gCor.x(), gCor.y(), gCor.z());
224 
225  assert(caloTopology.denseIndex(id) == dins[i]);
226 
227  ptr->newCell(fCtr, fBck, fCor, myParm, id);
228  }
229 
230  ptr->initializeParms(); // initializations; must happen after cells filled
231 
232  return ptr;
233 }
234 
236 
238 
240 
242 
244 
CaloCellGeometry::Pt3D Pt3D
static unsigned int alignmentTransformIndexLocal(const DetId &id)
CaloGeometryDBEP< CaloTowerGeometry, CaloGeometryDBReader > CaloTowerGeometryFromDBEP
Definition: moduleDB.cc:243
virtual unsigned int numberOfCellsForCorners() const
unsigned int numberOfShapes() const override
std::unique_ptr< CaloSubdetectorGeometry > PtrType
unsigned int numberOfParametersPerShape() const override
CaloCellGeometry::Pt3DVec Pt3DVec
unsigned int alignmentTransformIndexLocal(const DetId &id)
assert(be >=bs)
CaloSubdetectorGeometry::IVec IVec
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)
unsigned int alignmentTransformIndexGlobal(const DetId &id)
CaloCellGeometry::Pt3D Pt3D
static void localCorners(Pt3DVec &lc, const CCGFloat *pv, unsigned int i, Pt3D &ref)
Definition: DetId.h:17
AlgebraicVector EulerAngles
Definition: Definitions.h:34
#define DEFINE_FWK_EVENTSETUP_MODULE(type)
Definition: ModuleFactory.h:60
CaloCellGeometry::Tr3D Tr3D
CaloCellGeometry::Tr3D Tr3D
CaloSubdetectorGeometry::DimVec DimVec
ProductT const & get(ESGetToken< ProductT, DepRecordT > const &iToken) const
CaloCellGeometry::CCGFloat CCGFloat
CaloGeometryDBEP< HcalGeometry, CaloGeometryDBReader > HcalGeometryFromDBEP
Definition: moduleDB.cc:237