CMS 3D CMS Logo

CaloTowerGeometry.cc
Go to the documentation of this file.
3 
4 #include <Math/Transform3D.h>
5 #include <Math/EulerAngles.h>
6 
11 
13  cttopo(cttopo_),
14  k_NumberOfCellsForCorners(cttopo->sizeForDenseIndexing()),
15  k_NumberOfShapes(cttopo->lastHFRing()),
16  m_cellVec ( k_NumberOfCellsForCorners )
17 {
18 }
19 
20 
22 
23 
24 unsigned int
26 
27  const CaloGenericDetId gid ( id ) ;
28  assert( gid.isCaloTower() ) ;
29 
30  const CaloTowerDetId cid ( id ) ;
31  const int iea ( cid.ietaAbs() ) ;
32  const unsigned int ip ( ( cid.iphi() - 1 )/4 ) ;
33  const int izoff ( ( cid.zside() + 1 )/2 ) ;
34  const unsigned int offset ( izoff*3*18) ;
35 
36  return ( offset + ip +
37  ( cttopo->firstHFQuadPhiRing() <= iea ? 36 :
38  ( cttopo->firstHEDoublePhiRing() <= iea ? 18 : 0 ) ) ) ;
39 }
40 
41 unsigned int
43  return (unsigned int) DetId::Calo - 1 ;
44 }
45 
46 void
48  const CCGFloat* pv ,
49  unsigned int i ,
50  Pt3D& ref ) {
51  IdealObliquePrism::localCorners( lc, pv, ref ) ;
52 }
53 
54 void
56  const GlobalPoint& f2 ,
57  const GlobalPoint& f3 ,
58  const CCGFloat* parm ,
59  const DetId& detId ) {
60  const CaloGenericDetId cgid ( detId ) ;
61 
62  assert( cgid.isCaloTower() ) ;
63 
64  const CaloTowerDetId cid ( detId ) ;
65 
66  const unsigned int di ( cttopo->denseIndex(cid) ) ;
67 
68  m_cellVec[ di ] = IdealObliquePrism( f1, cornersMgr(), parm ) ;
69  addValidID( detId ) ;
70  m_dins.emplace_back( di );
71 }
72 
73 const CaloCellGeometry*
75  const CaloCellGeometry* cell ( &m_cellVec[ index ] ) ;
76  return ( m_cellVec.size() < index ||
77  nullptr == cell->param() ? nullptr : cell ) ;
78 }
79 
80 void
84  CaloSubdetectorGeometry::IVec& dinsVec ) const {
86  iVec.reserve( numberOfShapes()==1 ? 1 : numberOfCellsForCorners() ) ;
87  dVec.reserve( numberOfShapes()*numberOfParametersPerShape() ) ;
88  dinsVec.reserve(numberOfCellsForCorners());
89 
90  for (const auto & pv : parVecVec()) {
91  for (float iv : pv) {
92  dVec.emplace_back( iv ) ;
93  }
94  }
95 
96  for (unsigned int i ( 0 ) ; i < numberOfCellsForCorners() ; ++i) {
97  Tr3D tr ;
98  const CaloCellGeometry* ptr ( cellGeomPtr( i ) ) ;
99 
100  if (nullptr != ptr) {
101  dinsVec.emplace_back( i );
102 
103  ptr->getTransform( tr, ( Pt3DVec* ) nullptr ) ;
104 
105  if( Tr3D() == tr ) { // for preshower there is no rotation
106  const GlobalPoint& gp ( ptr->getPosition() ) ;
107  tr = HepGeom::Translate3D( gp.x(), gp.y(), gp.z() ) ;
108  }
109 
110  const CLHEP::Hep3Vector tt ( tr.getTranslation() ) ;
111  tVec.emplace_back( tt.x() ) ;
112  tVec.emplace_back( tt.y() ) ;
113  tVec.emplace_back( tt.z() ) ;
114  if (6 == numberOfTransformParms()) {
115  const CLHEP::HepRotation rr ( tr.getRotation() ) ;
116  const ROOT::Math::Transform3D rtr (rr.xx(), rr.xy(), rr.xz(), tt.x(),
117  rr.yx(), rr.yy(), rr.yz(), tt.y(),
118  rr.zx(), rr.zy(), rr.zz(), tt.z());
120  rtr.GetRotation( ea ) ;
121  tVec.emplace_back( ea.Phi() ) ;
122  tVec.emplace_back( ea.Theta() ) ;
123  tVec.emplace_back( ea.Psi() ) ;
124  }
125 
126  const CCGFloat* par ( ptr->param() ) ;
127 
128  unsigned int ishape ( 9999 ) ;
129  for( unsigned int ivv ( 0 ) ; ivv != parVecVec().size() ; ++ivv ) {
130  bool ok ( true ) ;
131  const CCGFloat* pv ( &(*parVecVec()[ivv].begin() ) ) ;
132  for( unsigned int k ( 0 ) ; k != numberOfParametersPerShape() ; ++k ) {
133  ok = ok && ( fabs( par[k] - pv[k] ) < 1.e-6 ) ;
134  }
135  if( ok ) {
136  ishape = ivv ;
137  break ;
138  }
139  }
140  assert( 9999 != ishape ) ;
141 
142  const unsigned int nn (( numberOfShapes()==1) ? (unsigned int)1 : m_dins.size() ) ;
143  if( iVec.size() < nn ) iVec.emplace_back( ishape ) ;
144  }
145  }
146 }
CaloCellGeometry::Tr3D Tr3D
std::vector< CCGFloat > DimVec
CaloTowerGeometry(const CaloTowerTopology *cttopo_)
virtual unsigned int numberOfCellsForCorners() const
virtual const GlobalPoint & getPosition() const
Returns the position of reference for this cell.
bool isCaloTower() const
std::vector< unsigned int > IVec
unsigned int numberOfShapes() const override
std::vector< CCGFloat > TrVec
HepGeom::Transform3D Tr3D
std::vector< Pt3D > Pt3DVec
unsigned int alignmentTransformIndexLocal(const DetId &id)
const CaloCellGeometry * cellGeomPtr(uint32_t index) const override
CaloCellGeometry::CCGFloat CCGFloat
~CaloTowerGeometry() override
unsigned int numberOfParametersPerShape() const override
const CCGFloat * param() const
void newCell(const GlobalPoint &f1, const GlobalPoint &f2, const GlobalPoint &f3, const CCGFloat *parm, const DetId &detId) override
static void localCorners(Pt3DVec &vec, const CCGFloat *pv, Pt3D &ref)
void getSummary(CaloSubdetectorGeometry::TrVec &trVector, CaloSubdetectorGeometry::IVec &iVector, CaloSubdetectorGeometry::DimVec &dimVector, CaloSubdetectorGeometry::IVec &dinsVector) const override
virtual void getTransform(Tr3D &tr, Pt3DVec *lptr) const
--------— only needed by specific utility; overloaded when needed -—
CaloCellGeometry::Pt3D Pt3D
def pv(vc)
Definition: MetAnalyzer.py:6
const CaloTowerTopology * cttopo
CaloSubdetectorGeometry::IVec m_dins
unsigned int alignmentTransformIndexGlobal(const DetId &id)
int k[5][pyjets_maxn]
uint32_t denseIndex(const DetId &id) const
static void localCorners(Pt3DVec &lc, const CCGFloat *pv, unsigned int i, Pt3D &ref)
Definition: DetId.h:18
AlgebraicVector EulerAngles
Definition: Definitions.h:36
void addValidID(const DetId &id)
CaloCellGeometry::CornersMgr * cornersMgr()
int firstHEDoublePhiRing() const
HepGeom::Point3D< CCGFloat > Pt3D
CaloCellGeometry::Tr3D Tr3D
CaloCellGeometry::Pt3D Pt3D
#define begin
Definition: vmac.h:30
CaloCellGeometry::Pt3DVec Pt3DVec
virtual unsigned int numberOfTransformParms() const
int firstHFQuadPhiRing() const
CaloCellGeometry::Pt3DVec Pt3DVec
CaloCellGeometry::CCGFloat CCGFloat