CMS 3D CMS Logo

moduleDB.cc
Go to the documentation of this file.
5 
6 template <>
9  const typename HGCalGeometry::AlignedRecord& iRecord) {
10  TrVec tvec;
11  DimVec dvec;
12  IVec ivec;
13  IVec dins;
14 
15  std::cout << "Reading HGCalGeometry " << calogeometryDBEPimpl::nameHGCal << "\n";
16  const auto& pG = iRecord.get(geometryToken_);
17 
18  tvec = pG.getTranslation();
19  dvec = pG.getDimension();
20  ivec = pG.getIndexes();
21  dins = pG.getDenseIndices();
22  //*********************************************************************************************
23  const auto& topology = iRecord.get(additionalTokens_.topology);
24 
25  assert(dvec.size() <= topology.totalGeomModules() * HGCalGeometry::k_NumberOfParametersPerShape);
26  HGCalGeometry* hcg = new HGCalGeometry(topology);
27  PtrType ptr(hcg);
28 
29  ptr->allocateCorners(topology.ncells());
31 
32  const unsigned int nTrParm(ptr->numberOfTransformParms());
33  const unsigned int nPerShape(HGCalGeometry::k_NumberOfParametersPerShape);
34 
35  for (auto it : dins) {
36  DetId id = topology.encode(topology.geomDenseId2decId(it));
37  // get layer
38  int layer = ivec[it];
39 
40  // get transformation
41  const unsigned int jj(it * nTrParm);
42  Tr3D tr;
43  const ROOT::Math::Translation3D tl(tvec[jj], tvec[jj + 1], tvec[jj + 2]);
44  const ROOT::Math::EulerAngles ea(6 == nTrParm ? ROOT::Math::EulerAngles(tvec[jj + 3], tvec[jj + 4], tvec[jj + 5])
46  const ROOT::Math::Transform3D rt(ea, tl);
47  double xx, xy, xz, dx, yx, yy, yz, dy, zx, zy, zz, dz;
48  rt.GetComponents(xx, xy, xz, dx, yx, yy, yz, dy, zx, zy, zz, dz);
49  tr = Tr3D(CLHEP::HepRep3x3(xx, xy, xz, yx, yy, yz, zx, zy, zz), CLHEP::Hep3Vector(dx, dy, dz));
50 
51  // get parameters
52  DimVec dims;
53  dims.reserve(nPerShape);
54 
55  DimVec::const_iterator dsrc(dvec.begin() + layer * nPerShape);
56  for (unsigned int j(0); j != nPerShape; ++j) {
57  dims.emplace_back(*dsrc);
58  ++dsrc;
59  }
60 
61  std::vector<GlobalPoint> corners(FlatHexagon::ncorner_);
62 
63  FlatHexagon::createCorners(dims, tr, corners);
64 
65  const CCGFloat* myParm(CaloCellGeometry::getParmPtr(dims, ptr->parMgr(), ptr->parVecVec()));
66  GlobalPoint front(
68  (corners[0].x() + corners[1].x() + corners[2].x() + corners[3].x() + corners[4].x() + corners[5].x()),
70  (corners[0].y() + corners[1].y() + corners[2].y() + corners[3].y() + corners[4].y() + corners[5].y()),
72  (corners[0].z() + corners[1].z() + corners[2].z() + corners[3].z() + corners[4].z() + corners[5].z()));
73 
74  GlobalPoint back(
76  (corners[6].x() + corners[7].x() + corners[8].x() + corners[9].x() + corners[10].x() + corners[11].x()),
78  (corners[6].y() + corners[7].y() + corners[8].y() + corners[9].y() + corners[10].y() + corners[11].y()),
80  (corners[6].z() + corners[7].z() + corners[8].z() + corners[9].z() + corners[10].z() + corners[11].z()));
81 
82  if (front.mag2() > back.mag2()) { // front should always point to the center, so swap front and back
83  std::swap(front, back);
84  std::swap_ranges(
85  corners.begin(), corners.begin() + FlatHexagon::ncornerBy2_, corners.begin() + FlatHexagon::ncornerBy2_);
86  }
87 
88  ptr->newCell(front, back, corners[0], myParm, id);
89  }
90 
91  ptr->initializeParms(); // initializations; must happen after cells filled
92 
93  return ptr;
94 }
95 
97 
99 
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
CaloGeometryDBEP< HGCalGeometry, CaloGeometryDBReader > HGCalGeometryFromDBEP
Definition: moduleDB.cc:98
std::unique_ptr< CaloSubdetectorGeometry > PtrType
T mag2() const
Definition: PV3DBase.h:63
assert(be >=bs)
float float float z
static constexpr unsigned int ncorner_
Definition: FlatHexagon.h:81
constexpr std::array< uint8_t, layerIndexSize > layer
CaloSubdetectorGeometry::IVec IVec
static constexpr unsigned int k_NumberOfParametersPerShape
Definition: HGCalGeometry.h:45
void swap(edm::DataFrameContainer &lhs, edm::DataFrameContainer &rhs)
PtrType produceAligned(const typename T::AlignedRecord &iRecord)
CaloSubdetectorGeometry::TrVec TrVec
static const CCGFloat * getParmPtr(const std::vector< CCGFloat > &vd, ParMgr *mgr, ParVecVec &pvv)
Definition: DetId.h:17
static constexpr unsigned int ncornerBy2_
Definition: FlatHexagon.h:82
AlgebraicVector EulerAngles
Definition: Definitions.h:34
#define DEFINE_FWK_EVENTSETUP_MODULE(type)
Definition: ModuleFactory.h:60
static constexpr auto nameHGCal
CaloCellGeometry::Tr3D Tr3D
CaloCellGeometry::Tr3D Tr3D
float x
CaloSubdetectorGeometry::DimVec DimVec
ProductT const & get(ESGetToken< ProductT, DepRecordT > const &iToken) const
CaloCellGeometry::CCGFloat CCGFloat
static constexpr double oneBySix_
Definition: FlatHexagon.h:80