CMS 3D CMS Logo

moduleDB.cc
Go to the documentation of this file.
4 
5 template<>
8 {
9  TrVec tvec;
10  DimVec dvec;
11  IVec ivec;
12  IVec dins;
13 
15 
16  name = "HGCalEESensitive";
17  std::cout << "Reading HGCalGeometry " << name.c_str() << "\n";
19  {
21  iRecord.getRecord<IdealGeometryRecord>().get( name, geomHandle );
22 
23  const HGCalGeometry* geom = geomHandle.product();
24  geom->getSummary( tvec, ivec, dvec, dins ) ;
25 
26  CaloGeometryDBReader::writeIndexed( tvec, dvec, ivec, dins, HGCalGeometry::dbString() ) ;
27  }
28  else
29  {
31  iRecord.getRecord<typename HGCalGeometry::PGeometryRecord >().get( pG ) ;
32 
33  tvec = pG->getTranslation() ;
34  dvec = pG->getDimension() ;
35  ivec = pG->getIndexes() ;
36  dins = pG->getDenseIndices();
37  }
38  //*********************************************************************************************
40  iRecord.getRecord<IdealGeometryRecord>().get( name, topology );
41 
42  assert( dvec.size() <= topology->totalGeomModules() * HGCalGeometry::k_NumberOfParametersPerShape );
43  HGCalGeometry* hcg = new HGCalGeometry( *topology );
44  PtrType ptr ( hcg );
45 
46  ptr->allocateCorners( topology->ncells());
47  ptr->allocatePar( HGCalGeometry::k_NumberOfShapes,
49 
50  const unsigned int nTrParm( ptr->numberOfTransformParms());
51  const unsigned int nPerShape( HGCalGeometry::k_NumberOfParametersPerShape );
52 
53  for( auto it : dins )
54  {
55  DetId id = topology->encode( topology->geomDenseId2decId( it ));
56  // get layer
57  int layer = ivec[ it ];
58 
59  // get transformation
60  const unsigned int jj ( it * nTrParm );
61  Tr3D tr;
62  const ROOT::Math::Translation3D tl( tvec[jj], tvec[jj+1], tvec[jj+2]);
63  const ROOT::Math::EulerAngles ea( 6 == nTrParm ?
64  ROOT::Math::EulerAngles( tvec[jj+3], tvec[jj+4], tvec[jj+5] ) :
66  const ROOT::Math::Transform3D rt( ea, tl );
67  double xx, xy, xz, dx, yx, yy, yz, dy, zx, zy, zz, dz;
68  rt.GetComponents(xx,xy,xz,dx,yx,yy,yz,dy,zx,zy,zz,dz) ;
69  tr = Tr3D( CLHEP::HepRep3x3( xx, xy, xz,
70  yx, yy, yz,
71  zx, zy, zz ),
72  CLHEP::Hep3Vector( dx, dy, dz));
73 
74  // get parameters
75  DimVec dims;
76  dims.reserve( nPerShape );
77 
78  DimVec::const_iterator dsrc( dvec.begin() + layer * nPerShape );
79  for( unsigned int j ( 0 ) ; j != nPerShape ; ++j )
80  {
81  dims.emplace_back( *dsrc ) ;
82  ++dsrc ;
83  }
84 
85  std::vector<GlobalPoint> corners( FlatHexagon::ncorner_ );
86 
87  FlatHexagon::createCorners( dims, tr, corners );
88 
89  const CCGFloat* myParm( CaloCellGeometry::getParmPtr( dims,
90  ptr->parMgr(),
91  ptr->parVecVec()));
92  GlobalPoint front ( FlatHexagon::oneBySix_*( corners[0].x() +
93  corners[1].x() +
94  corners[2].x() +
95  corners[3].x() +
96  corners[4].x() +
97  corners[5].x()),
98  FlatHexagon::oneBySix_*( corners[0].y() +
99  corners[1].y() +
100  corners[2].y() +
101  corners[3].y() +
102  corners[4].y() +
103  corners[5].y()),
104  FlatHexagon::oneBySix_*( corners[0].z() +
105  corners[1].z() +
106  corners[2].z() +
107  corners[3].z() +
108  corners[4].z() +
109  corners[5].z()));
110 
111  GlobalPoint back ( FlatHexagon::oneBySix_*( corners[6].x() +
112  corners[7].x() +
113  corners[8].x() +
114  corners[9].x() +
115  corners[10].x()+
116  corners[11].x()),
117  FlatHexagon::oneBySix_*( corners[6].y() +
118  corners[7].y() +
119  corners[8].y() +
120  corners[9].y() +
121  corners[10].y()+
122  corners[11].y()),
123  FlatHexagon::oneBySix_*( corners[6].z() +
124  corners[7].z() +
125  corners[8].z() +
126  corners[9].z() +
127  corners[10].z()+
128  corners[11].z()));
129 
130  if (front.mag2() > back.mag2()) { // front should always point to the center, so swap front and back
131  std::swap (front, back);
132  std::swap_ranges (corners.begin(),
133  corners.begin()+FlatHexagon::ncornerBy2_,
134  corners.begin()+FlatHexagon::ncornerBy2_);
135  }
136 
137  ptr->newCell( front, back, corners[0], myParm, id );
138  }
139 
140  ptr->initializeParms(); // initializations; must happen after cells filled
141 
142  return ptr ;
143 }
144 
146 
149 
static void createCorners(const std::vector< CCGFloat > &pv, const Tr3D &tr, std::vector< GlobalPoint > &co)
Definition: FlatHexagon.cc:152
T mag2() const
Definition: PV3DBase.h:66
CaloTopology const * topology(0)
std::vector< float > const & getTranslation() const
Definition: PCaloGeometry.h:20
float float float z
static constexpr unsigned int ncorner_
Definition: FlatHexagon.h:82
std::vector< float > const & getDimension() const
Definition: PCaloGeometry.h:21
CaloSubdetectorGeometry::IVec IVec
unsigned int totalGeomModules() const
static unsigned int k_NumberOfShapes
Definition: HGCalGeometry.h:49
void swap(edm::DataFrameContainer &lhs, edm::DataFrameContainer &rhs)
DetId encode(const DecodedDetId &id_) const
static std::string dbString()
Definition: HGCalGeometry.h:52
virtual unsigned int ncells() const
return a count of valid cells (for dense indexing use)
std::unique_ptr< CaloSubdetectorGeometry > PtrType
PtrType produceAligned(const typename T::AlignedRecord &iRecord)
CaloSubdetectorGeometry::TrVec TrVec
static const CCGFloat * getParmPtr(const std::vector< CCGFloat > &vd, ParMgr *mgr, ParVecVec &pvv)
DecodedDetId geomDenseId2decId(const uint32_t &hi) const
Definition: DetId.h:18
static constexpr unsigned int ncornerBy2_
Definition: FlatHexagon.h:83
#define DEFINE_FWK_EVENTSETUP_MODULE(type)
Definition: ModuleFactory.h:60
AlgebraicVector EulerAngles
Definition: Definitions.h:36
void getSummary(CaloSubdetectorGeometry::TrVec &trVector, CaloSubdetectorGeometry::IVec &iVector, CaloSubdetectorGeometry::DimVec &dimVector, CaloSubdetectorGeometry::IVec &dinsVector) const override
static unsigned int k_NumberOfParametersPerShape
Definition: HGCalGeometry.h:48
CaloCellGeometry::Tr3D Tr3D
CaloCellGeometry::Tr3D Tr3D
CaloGeometryDBEP< HGCalGeometry, CaloGeometryDBReader > HGCalGeometryFromDBEP
Definition: moduleDB.cc:148
CaloSubdetectorGeometry::DimVec DimVec
T const * product() const
Definition: ESHandle.h:86
CaloCellGeometry::CCGFloat CCGFloat
std::vector< uint32_t > const & getIndexes() const
Definition: PCaloGeometry.h:22
static constexpr double oneBySix_
Definition: FlatHexagon.h:81
std::vector< uint32_t > const & getDenseIndices() const
Definition: PCaloGeometry.h:23
static void writeIndexed(const TrVec &, const DimVec &, const IVec &, const std::vector< uint32_t > &, const std::string &)