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