1 #ifndef GEOMETRY_CALOGEOMETRY_CALOGEOMETRYDBEP_H
2 #define GEOMETRY_CALOGEOMETRY_CALOGEOMETRYDBEP_H 1
6 #include "boost/shared_ptr.hpp"
27 #include <Math/Transform3D.h>
28 #include <Math/EulerAngles.h>
36 template <
class T,
class U>
41 typedef boost::shared_ptr< CaloSubdetectorGeometry >
PtrType ;
62 iRecord.template getRecord< typename T::AlignmentRecord >().
get( alignments ) ;
65 ( alignments->m_align.size() == T::numberOfAlignments() ) ) ;
66 alignPtr = alignments.
product() ;
69 iRecord.template getRecord<GlobalPositionRcd>().
get( globals ) ;
82 iRecord.get( T::producerTag() + std::string(
"_master"), pG ) ;
88 U::write( tvec, dvec, ivec, T::dbString() ) ;
94 iRecord.template getRecord<typename T::PGeometryRecord >().
get( pG ) ;
96 tvec = pG->getTranslation() ;
97 dvec = pG->getDimension() ;
98 ivec = pG->getIndexes() ;
102 const unsigned int nTrParm ( tvec.size()/T::k_NumberOfCellsForCorners ) ;
104 assert( dvec.size() == T::k_NumberOfShapes * T::k_NumberOfParametersPerShape ) ;
108 ptr->fillDefaultNamedParameters() ;
110 ptr->allocateCorners( T::k_NumberOfCellsForCorners ) ;
112 ptr->allocatePar( dvec.size() ,
113 T::k_NumberOfParametersPerShape ) ;
115 for(
unsigned int i ( 0 ) ;
i != T::k_NumberOfCellsForCorners ; ++
i )
117 const unsigned int nPerShape ( T::k_NumberOfParametersPerShape ) ;
119 dims.reserve( nPerShape ) ;
121 const unsigned int indx ( ivec.size()==1 ? 0 :
i ) ;
123 DimVec::const_iterator dsrc ( dvec.begin() + ivec[indx]*nPerShape ) ;
125 for(
unsigned int j ( 0 ) ;
j != nPerShape ; ++
j )
127 dims.push_back( *dsrc ) ;
133 ptr->parVecVec() ) ) ;
136 const DetId id ( T::DetIdType::detIdFromDenseIndex(
i ) ) ;
138 const unsigned int iGlob ( 0 == globalPtr ? 0 :
139 T::alignmentTransformIndexGlobal(
id ) ) ;
141 assert( 0 == globalPtr || iGlob < globalPtr->m_align.size() ) ;
145 assert( 0 == gt || iGlob == T::alignmentTransformIndexGlobal(
DetId( gt->rawId() ) ) ) ;
147 const unsigned int iLoc ( 0 == alignPtr ? 0 :
148 T::alignmentTransformIndexLocal(
id ) ) ;
150 assert( 0 == alignPtr || iLoc < alignPtr->m_align.size() ) ;
155 assert( 0 == at || ( T::alignmentTransformIndexLocal(
DetId( at->rawId() ) ) == iLoc ) ) ;
159 HepGeom::Point3D<double> lRef ;
160 const std::vector<HepGeom::Point3D<double> > lc ( T::localCorners( &dims.front(),
i, lRef ) ) ;
162 const HepGeom::Point3D<double> lBck ( 0.25*(lc[4]+lc[5]+lc[6]+lc[7] ) ) ;
163 const HepGeom::Point3D<double> lCor ( lc[0] ) ;
166 const unsigned int jj (
i*nTrParm ) ;
167 HepGeom::Transform3D tr ;
168 const ROOT::Math::Translation3D tl ( tvec[jj], tvec[jj+1], tvec[jj+2] ) ;
173 const ROOT::Math::Transform3D rt ( ea, tl ) ;
174 double xx,
xy,xz,dx,yx,yy,yz,dy,zx,zy,zz,dz;
175 rt.GetComponents(xx,xy,xz,dx,yx,yy,yz,dy,zx,zy,zz,dz) ;
176 tr = HepGeom::Transform3D( CLHEP::HepRep3x3( xx, xy, xz,
179 CLHEP::Hep3Vector(dx,dy,dz) );
182 const HepGeom::Transform3D atr ( 0 == at ? tr :
183 ( 0 == gt ? at->transform()*tr :
184 at->transform()*gt->transform()*tr ) ) ;
187 const HepGeom::Point3D<double> gRef ( atr*lRef ) ;
188 const GlobalPoint fCtr ( gRef.x(), gRef.y(), gRef.z() ) ;
189 const HepGeom::Point3D<double> gBck ( atr*lBck ) ;
190 const GlobalPoint fBck ( gBck.x(), gBck.y(), gBck.z() ) ;
191 const HepGeom::Point3D<double> gCor ( atr*lCor ) ;
192 const GlobalPoint fCor ( gCor.x(), gCor.y(), gCor.z() ) ;
195 ptr->cornersMgr() , myParm, id ) ) ;
197 ptr->addCell(
id, cell ) ;
200 ptr->initializeParms() ;
std::vector< unsigned int > IVec
std::vector< AlignTransform > m_align
boost::shared_ptr< CaloSubdetectorGeometry > PtrType
void setWhatProduced(T *iThis, const es::Label &iLabel=es::Label())
CaloSubdetectorGeometry::IVec IVec
PtrType produceAligned(const typename T::AlignedRecord &iRecord)
CaloSubdetectorGeometry::TrVec TrVec
std::vector< double > DimVec
Basic2DVector< T > xy() const
void getSummary(TrVec &trVector, IVec &iVector, DimVec &dimVector) const
AlgebraicVector EulerAngles
T const * product() const
static const double * getParmPtr(const std::vector< double > &vd, ParMgr *mgr, ParVecVec &pvv)
CaloSubdetectorGeometry::DimVec DimVec
std::vector< double > TrVec