test
CMS 3D CMS Logo

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