CMS 3D CMS Logo

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