test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
CaloGeometryDBEP.h
Go to the documentation of this file.
1 #ifndef GEOMETRY_CALOGEOMETRY_CALOGEOMETRYDBEP_H
2 #define GEOMETRY_CALOGEOMETRY_CALOGEOMETRYDBEP_H 1
3 
4 // system include files
5 #include <memory>
6 #include "boost/shared_ptr.hpp"
7 
8 // user include files
11 
13 
22 
24 
26 
27 #include <Math/Transform3D.h>
28 #include <Math/EulerAngles.h>
29 
30 //Forward declaration
31 
32 //
33 // class declaration
34 //
35 
36 template <class T, class U>
38 {
39  public:
40 
45 
46  typedef boost::shared_ptr< CaloSubdetectorGeometry > PtrType ;
50 
52  m_applyAlignment ( ps.getParameter<bool>("applyAlignment") ),
53  m_pSet( ps )
54 
55  {
56  setWhatProduced( this,
58  edm::es::Label( T::producerTag() ) ) ;//+std::string("TEST") ) ) ;
59  }
60 
61  virtual ~CaloGeometryDBEP<T,U>() {}
62 
63  PtrType produceAligned( const typename T::AlignedRecord& iRecord )
64  {
65  const Alignments* alignPtr ( 0 ) ;
66  const Alignments* globalPtr ( 0 ) ;
67  if( m_applyAlignment ) // get ptr if necessary
68  {
69  edm::ESHandle< Alignments > alignments ;
70  iRecord.template getRecord< typename T::AlignmentRecord >().get( alignments ) ;
71 
72  assert( alignments.isValid() && // require valid alignments and expected size
73  ( alignments->m_align.size() == T::numberOfAlignments() ) ) ;
74  alignPtr = alignments.product() ;
75 
77  iRecord.template getRecord<GlobalPositionRcd>().get( globals ) ;
78 
79  assert( globals.isValid() ) ;
80  globalPtr = globals.product() ;
81  }
82 
83  TrVec tvec ;
84  DimVec dvec ;
85  IVec ivec ;
86  std::vector<uint32_t> dins;
87 
88  if( U::writeFlag() )
89  {
91  iRecord.get( T::producerTag() + std::string("_master"), pG ) ;
92 
93  const CaloSubdetectorGeometry* pGptr ( pG.product() ) ;
94 
95  pGptr->getSummary( tvec, ivec, dvec, dins ) ;
96 
97  U::write( tvec, dvec, ivec, T::dbString() ) ;
98  }
99  else
100  {
102  iRecord.template getRecord<typename T::PGeometryRecord >().get( pG ) ;
103 
104  tvec = pG->getTranslation() ;
105  dvec = pG->getDimension() ;
106  ivec = pG->getIndexes() ;
107  }
108 //*********************************************************************************************
109 
110  const unsigned int nTrParm ( tvec.size()/T::k_NumberOfCellsForCorners ) ;
111 
112  assert( dvec.size() == T::k_NumberOfShapes * T::k_NumberOfParametersPerShape ) ;
113 
114  PtrType ptr ( new T ) ;
115 
116  ptr->fillDefaultNamedParameters() ;
117 
118  ptr->allocateCorners( T::k_NumberOfCellsForCorners ) ;
119 
120  ptr->allocatePar( dvec.size() ,
121  T::k_NumberOfParametersPerShape ) ;
122 
123  for( unsigned int i ( 0 ) ; i != T::k_NumberOfCellsForCorners ; ++i )
124  {
125  const unsigned int nPerShape ( T::k_NumberOfParametersPerShape ) ;
126  DimVec dims ;
127  dims.reserve( nPerShape ) ;
128 
129  const unsigned int indx ( ivec.size()==1 ? 0 : i ) ;
130 
131  DimVec::const_iterator dsrc ( dvec.begin() + ivec[indx]*nPerShape ) ;
132 
133  for( unsigned int j ( 0 ) ; j != nPerShape ; ++j )
134  {
135  dims.push_back( *dsrc ) ;
136  ++dsrc ;
137  }
138 
139  const CCGFloat* myParm ( CaloCellGeometry::getParmPtr( dims,
140  ptr->parMgr(),
141  ptr->parVecVec() ) ) ;
142 
143 
144  const DetId id ( T::DetIdType::detIdFromDenseIndex( i ) ) ;
145 
146  const unsigned int iGlob ( 0 == globalPtr ? 0 :
147  T::alignmentTransformIndexGlobal( id ) ) ;
148 
149  assert( 0 == globalPtr || iGlob < globalPtr->m_align.size() ) ;
150 
151  const AlignTransform* gt ( 0 == globalPtr ? 0 : &globalPtr->m_align[ iGlob ] ) ;
152 
153  assert( 0 == gt || iGlob == T::alignmentTransformIndexGlobal( DetId( gt->rawId() ) ) ) ;
154 
155  const unsigned int iLoc ( 0 == alignPtr ? 0 :
156  T::alignmentTransformIndexLocal( id ) ) ;
157 
158  assert( 0 == alignPtr || iLoc < alignPtr->m_align.size() ) ;
159 
160  const AlignTransform* at ( 0 == alignPtr ? 0 :
161  &alignPtr->m_align[ iLoc ] ) ;
162 
163  assert( 0 == at || ( T::alignmentTransformIndexLocal( DetId( at->rawId() ) ) == iLoc ) ) ;
164 
165  const CaloGenericDetId gId ( id ) ;
166 
167  Pt3D lRef ;
168  Pt3DVec lc ( 8, Pt3D(0,0,0) ) ;
169  T::localCorners( lc, &dims.front(), i, lRef ) ;
170 
171  const Pt3D lBck ( 0.25*(lc[4]+lc[5]+lc[6]+lc[7] ) ) ; // ctr rear face in local
172  const Pt3D lCor ( lc[0] ) ;
173 
174  //----------------------------------- create transform from 6 numbers ---
175  const unsigned int jj ( i*nTrParm ) ;
176  Tr3D tr ;
177  const ROOT::Math::Translation3D tl ( tvec[jj], tvec[jj+1], tvec[jj+2] ) ;
178  const ROOT::Math::EulerAngles ea (
179  6==nTrParm ?
180  ROOT::Math::EulerAngles( tvec[jj+3], tvec[jj+4], tvec[jj+5] ) :
182  const ROOT::Math::Transform3D rt ( ea, tl ) ;
183  double xx,xy,xz,dx,yx,yy,yz,dy,zx,zy,zz,dz;
184  rt.GetComponents(xx,xy,xz,dx,yx,yy,yz,dy,zx,zy,zz,dz) ;
185  tr = Tr3D( CLHEP::HepRep3x3( xx, xy, xz,
186  yx, yy, yz,
187  zx, zy, zz ),
188  CLHEP::Hep3Vector(dx,dy,dz) );
189 
190  // now prepend alignment(s) for final transform
191  const Tr3D atr ( 0 == at ? tr :
192  ( 0 == gt ? at->transform()*tr :
193  at->transform()*gt->transform()*tr ) ) ;
194  //--------------------------------- done making transform ---------------
195 
196  const Pt3D gRef ( atr*lRef ) ;
197  const GlobalPoint fCtr ( gRef.x(), gRef.y(), gRef.z() ) ;
198  const Pt3D gBck ( atr*lBck ) ;
199  const GlobalPoint fBck ( gBck.x(), gBck.y(), gBck.z() ) ;
200  const Pt3D gCor ( atr*lCor ) ;
201  const GlobalPoint fCor ( gCor.x(), gCor.y(), gCor.z() ) ;
202 
203  ptr->newCell( fCtr, fBck, fCor, myParm, id ) ;
204  }
205 
206  ptr->initializeParms() ; // initializations; must happen after cells filled
207 
208  return ptr ;
209  }
210 
211 private:
212 
215 };
216 
217 #endif
int i
Definition: DBlmapReader.cc:9
CaloCellGeometry::Pt3D Pt3D
std::vector< CCGFloat > DimVec
std::vector< unsigned int > IVec
CaloCellGeometry::Pt3DVec Pt3DVec
std::vector< CCGFloat > TrVec
HepGeom::Transform3D Tr3D
std::vector< Pt3D > Pt3DVec
const edm::ParameterSet m_pSet
std::vector< AlignTransform > m_align
Definition: Alignments.h:19
boost::shared_ptr< CaloSubdetectorGeometry > PtrType
void setWhatProduced(T *iThis, const es::Label &iLabel=es::Label())
Definition: ESProducer.h:115
virtual void getSummary(TrVec &trVector, IVec &iVector, DimVec &dimVector, IVec &dinsVector) const
CaloSubdetectorGeometry::IVec IVec
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)
Definition: DetId.h:18
AlgebraicVector EulerAngles
Definition: Definitions.h:36
T const * product() const
Definition: ESHandle.h:62
HepGeom::Point3D< CCGFloat > Pt3D
CaloCellGeometry::Tr3D Tr3D
DTRecHit1DPair & gt
CaloSubdetectorGeometry::DimVec DimVec
bool isValid() const
Definition: ESHandle.h:37
long double T
CaloCellGeometry::CCGFloat CCGFloat
list at
Definition: asciidump.py:428