CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
moduleDB.cc
Go to the documentation of this file.
3 
6 
7 template<>
10 {
11  const Alignments* alignPtr ( 0 ) ;
12  const Alignments* globalPtr ( 0 ) ;
13  if( m_applyAlignment ) // get ptr if necessary
14  {
15  edm::ESHandle< Alignments > alignments ;
16  iRecord.getRecord< typename HcalGeometry::AlignmentRecord >().get( alignments ) ;
17 
18  assert( alignments.isValid() && // require valid alignments and expected size
19  ( alignments->m_align.size() == HcalGeometry::numberOfAlignments() ) ) ;
20  alignPtr = alignments.product() ;
21 
23  iRecord.getRecord<GlobalPositionRcd>().get( globals ) ;
24 
25  assert( globals.isValid() ) ;
26  globalPtr = globals.product() ;
27  }
28 
29  TrVec tvec ;
30  DimVec dvec ;
31  IVec ivec ;
32  IVec dins ;
33 
35  {
37  iRecord.get( HcalGeometry::producerTag() + std::string("_master"), pG ) ;
38 
39  const CaloSubdetectorGeometry* pGptr ( pG.product() ) ;
40 
41  pGptr->getSummary( tvec, ivec, dvec, dins ) ;
42 
43  CaloGeometryDBReader::writeIndexed( tvec, dvec, ivec, dins, HcalGeometry::dbString() ) ;
44  }
45  else
46  {
48  iRecord.getRecord<typename HcalGeometry::PGeometryRecord >().get( pG ) ;
49 
50  tvec = pG->getTranslation() ;
51  dvec = pG->getDimension() ;
52  ivec = pG->getIndexes() ;
53  dins = pG->getDenseIndices();
54  }
55  //*********************************************************************************************
56 
57 
58  edm::ESHandle<HcalTopology> hcalTopology;
59  iRecord.getRecord<IdealGeometryRecord>().get( hcalTopology );
60 
61  // We know that the numer of shapes chanes with changing depth
62  // so, this check is temporary disabled. We need to implement
63  // a way either to store or calculate the number of shapes or be able
64  // to deal with only max numer of shapes.
65  // assert( dvec.size() == hcalTopology->getNumberOfShapes() * HcalGeometry::k_NumberOfParametersPerShape ) ;
66  assert( dvec.size() <= hcalTopology->getNumberOfShapes() * HcalGeometry::k_NumberOfParametersPerShape ) ;
67  HcalGeometry* hcg=new HcalGeometry( *hcalTopology );
68 
69  PtrType ptr ( hcg );
70 
71  const unsigned int nTrParm ( tvec.size()/hcalTopology->ncells() ) ;
72 
73  ptr->fillDefaultNamedParameters() ;
74 
75  ptr->allocateCorners( hcalTopology->ncells() );
76 
77  ptr->allocatePar( dvec.size() ,
79 
80  for( unsigned int i ( 0 ) ; i < dins.size() ; ++i )
81  {
82  const unsigned int nPerShape ( HcalGeometry::k_NumberOfParametersPerShape ) ;
83  DimVec dims ;
84  dims.reserve( nPerShape ) ;
85 
86  const unsigned int indx ( ivec.size()==1 ? 0 : i ) ;
87 
88  DimVec::const_iterator dsrc ( dvec.begin() + ivec[indx]*nPerShape ) ;
89 
90  for( unsigned int j ( 0 ) ; j != nPerShape ; ++j )
91  {
92  dims.push_back( *dsrc ) ;
93  ++dsrc ;
94  }
95 
96  const CCGFloat* myParm ( CaloCellGeometry::getParmPtr( dims,
97  ptr->parMgr(),
98  ptr->parVecVec() ) ) ;
99 
100 
101  const DetId id ( hcalTopology->denseId2detId(dins[i]) );
102 
103  const unsigned int iGlob ( 0 == globalPtr ? 0 :
105 
106  assert( 0 == globalPtr || iGlob < globalPtr->m_align.size() ) ;
107 
108  const AlignTransform* gt ( 0 == globalPtr ? 0 : &globalPtr->m_align[ iGlob ] ) ;
109 
110  assert( 0 == gt || iGlob == HcalGeometry::alignmentTransformIndexGlobal( DetId( gt->rawId() ) ) ) ;
111 
112  const unsigned int iLoc ( 0 == alignPtr ? 0 :
114 
115  assert( 0 == alignPtr || iLoc < alignPtr->m_align.size() ) ;
116 
117  const AlignTransform* at ( 0 == alignPtr ? 0 :
118  &alignPtr->m_align[ iLoc ] ) ;
119 
120  assert( 0 == at || ( HcalGeometry::alignmentTransformIndexLocal( DetId( at->rawId() ) ) == iLoc ) ) ;
121 
122  Pt3D lRef ;
123  Pt3DVec lc ( 8, Pt3D(0,0,0) ) ;
124  hcg->localCorners( lc, &dims.front(), dins[i], lRef ) ;
125 
126  const Pt3D lBck ( 0.25*(lc[4]+lc[5]+lc[6]+lc[7] ) ) ; // ctr rear face in local
127  const Pt3D lCor ( lc[0] ) ;
128 
129  //----------------------------------- create transform from 6 numbers ---
130  const unsigned int jj ( dins[i]*nTrParm ) ;
131  Tr3D tr ;
132  const ROOT::Math::Translation3D tl ( tvec[jj], tvec[jj+1], tvec[jj+2] ) ;
133  const ROOT::Math::EulerAngles ea (
134  6==nTrParm ?
135  ROOT::Math::EulerAngles( tvec[jj+3], tvec[jj+4], tvec[jj+5] ) :
137  const ROOT::Math::Transform3D rt ( ea, tl ) ;
138  double xx,xy,xz,dx,yx,yy,yz,dy,zx,zy,zz,dz;
139  rt.GetComponents(xx,xy,xz,dx,yx,yy,yz,dy,zx,zy,zz,dz) ;
140  tr = Tr3D( CLHEP::HepRep3x3( xx, xy, xz,
141  yx, yy, yz,
142  zx, zy, zz ),
143  CLHEP::Hep3Vector(dx,dy,dz) );
144 
145  // now prepend alignment(s) for final transform
146  const Tr3D atr ( 0 == at ? tr :
147  ( 0 == gt ? at->transform()*tr :
148  at->transform()*gt->transform()*tr ) ) ;
149  //--------------------------------- done making transform ---------------
150 
151  const Pt3D gRef ( atr*lRef ) ;
152  const GlobalPoint fCtr ( gRef.x(), gRef.y(), gRef.z() ) ;
153  const Pt3D gBck ( atr*lBck ) ;
154  const GlobalPoint fBck ( gBck.x(), gBck.y(), gBck.z() ) ;
155  const Pt3D gCor ( atr*lCor ) ;
156  const GlobalPoint fCor ( gCor.x(), gCor.y(), gCor.z() ) ;
157 
158  assert( hcalTopology->detId2denseId(id) == dins[i] );
159 
160  ptr->newCell( fCtr, fBck, fCor, myParm, id ) ;
161  }
162 
163  ptr->initializeParms() ; // initializations; must happen after cells filled
164 
165  return ptr ;
166 }
167 
169 
172 
174 
176 
179 
int i
Definition: DBlmapReader.cc:9
CaloCellGeometry::Pt3D Pt3D
static unsigned int alignmentTransformIndexLocal(const DetId &id)
static std::string producerTag()
Definition: HcalGeometry.h:54
CaloCellGeometry::Pt3DVec Pt3DVec
std::vector< AlignTransform > m_align
Definition: Alignments.h:19
boost::shared_ptr< CaloSubdetectorGeometry > PtrType
virtual void getSummary(TrVec &trVector, IVec &iVector, DimVec &dimVector, IVec &dinsVector) const
CaloSubdetectorGeometry::IVec IVec
static void writeIndexed(const TrVec &, const DimVec &, const IVec &, const std::vector< uint32_t > &, std::string)
CaloGeometryDBEP< CaloTowerGeometry, CaloGeometryDBReader > CaloTowerGeometryFromDBEP
Definition: moduleDB.cc:178
void get(HolderT &iHolder) const
static unsigned int alignmentTransformIndexGlobal(const DetId &id)
int j
Definition: DBlmapReader.cc:9
PtrType produceAligned(const typename T::AlignedRecord &iRecord)
CaloSubdetectorGeometry::TrVec TrVec
static const CCGFloat * getParmPtr(const std::vector< CCGFloat > &vd, ParMgr *mgr, ParVecVec &pvv)
CaloCellGeometry::Pt3D Pt3D
Definition: DetId.h:18
AlgebraicVector EulerAngles
Definition: Definitions.h:36
static std::string dbString()
Definition: HcalGeometry.h:35
T const * product() const
Definition: ESHandle.h:86
#define DEFINE_FWK_EVENTSETUP_MODULE(type)
Definition: ModuleFactory.h:60
CaloCellGeometry::Tr3D Tr3D
CaloCellGeometry::Tr3D Tr3D
DTRecHit1DPair & gt
CaloSubdetectorGeometry::DimVec DimVec
CaloGeometryDBEP< HcalGeometry, CaloGeometryDBReader > HcalGeometryFromDBEP
Definition: moduleDB.cc:171
bool isValid() const
Definition: ESHandle.h:47
CaloCellGeometry::CCGFloat CCGFloat
static unsigned int numberOfAlignments()
Definition: HcalGeometry.h:66
list at
Definition: asciidump.py:428