CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
CastorHardcodeGeometryLoader.cc
Go to the documentation of this file.
7 #include <algorithm>
8 
10 
12  theTopology ( new CastorTopology ) ,
13  extTopology ( theTopology )
14 {
15  init();
16 }
17 
19  theTopology( 0 ) ,
20  extTopology ( &ht )
21 {
22  init();
23 }
24 
26 {
29  theEMSectiondZ = 101.0;
32  theHADSectiondZ = 1212.;
33 }
34 
35 std::auto_ptr<CaloSubdetectorGeometry>
37  int subdet)
38 {
39  std::auto_ptr<CaloSubdetectorGeometry> hg(new CastorGeometry( extTopology ));
40  if( subdet == HcalCastorDetId::SubdetectorId )
41  {
42  fill( HcalCastorDetId::EM, hg.get() ) ;
43  fill( HcalCastorDetId::HAD, hg.get() ) ;
44  }
45  return hg;
46 }
47 
48 std::auto_ptr<CaloSubdetectorGeometry>
50 {
51  std::auto_ptr<CaloSubdetectorGeometry> hg
52  ( new CastorGeometry( extTopology ) ) ;
53  fill( HcalCastorDetId::EM, hg.get() ) ;
54  fill( HcalCastorDetId::HAD, hg.get() ) ;
55  return hg;
56 }
57 
58 void
61 {
62  if( geom->cornersMgr() == 0 ) geom->allocateCorners(
64  if( geom->parMgr() == 0 ) geom->allocatePar(
67  CastorGeometry::k_NumberOfParametersPerShape ) ;
68 
69  // start by making the new HcalDetIds
70  std::vector<HcalCastorDetId> castorIds ;
71 
72  const int firstCell ( extTopology->firstCell( section ) ) ;
73  const int lastCell ( extTopology->lastCell( section ) );
74 
75  for( int imodule ( firstCell ) ; imodule <= lastCell ; ++imodule )
76  {
77  for( int isector ( 1 ) ;
78  isector <= HcalCastorDetId::kNumberSectorsPerEnd ; ++isector )
79  {
80  const HcalCastorDetId id ( section, false, isector, imodule ) ;
81  if( extTopology->valid( id ) ) castorIds.push_back( id ) ;
82  }
83  }
84 // edm::LogInfo("CastorHardcodeGeometry")
85 // << "Number of Castor DetIds made: " << section
86 // << " " << castorIds.size();
87 
88  // for each new HcalCastorDetId, make a CaloCellGeometry
89 
90  for( std::vector<HcalCastorDetId>::const_iterator
91  castorIdItr ( castorIds.begin() ) ;
92  castorIdItr != castorIds.end() ; ++castorIdItr )
93  {
94  makeCell( *castorIdItr, geom ) ;
95  }
96 }
97 
98 void
100  CaloSubdetectorGeometry* geom ) const
101 {
102  const double zside ( 1.0*detId.zside() ) ;
103  const HcalCastorDetId::Section section ( detId.section() ) ;
104  const int module ( detId.module() ) ;
105  const int isect ( detId.sector() ) ;
106  const double sector ( 1.0*isect ) ;
107 
108 // length units are cm
109 
110 
111  const double sign ( 0 == isect%2 ? -1 : 1 ) ;
112 
113 //********* HERE ARE HARDWIRED GEOMETRY NUMBERS ACTUALLY USED *****
114 
115  static const double an ( atan( 1.)); //angle of cant w.r.t. beam
116  static const double can ( cos( an ));
117  static const double san ( sin( an ));
118  static const double dxlEM ( 1.55/2. ) ; //halflength of side near beam
119  static const double dxhEM ( 5.73/2. ) ; //halflength of side away from beam
120  static const double dhEM ( 14.26/2. ); //halflength of 2nd longest side
121  static const double dR ( 0.1 + 2.*dhEM*san*dxlEM/( dxhEM-dxlEM ) ) ;
122  static const double dhHAD ( 19.88/2. ); //halflength of 2nd longest side
123 
124  static const double dxhHAD ( dxhEM*( 2.*dhHAD*san + dR )/
125  ( 2.*dhEM*san + dR ) ) ; //halflength of side away from beam
126  static const double zm ( 1439.0 ) ; //z of start of EM
127  static const double dzEM ( 5.45/2 ) ; // halflength in z of EM
128  static const double dzHAD ( 10.075/2 ) ; // halflength in z of HAD
129 
130 //*****************************************************************
131 
132  const double dxl ( sign*dxlEM ) ; // same for EM and HAD
133 
134  const double dxh ( sign*( section == HcalCastorDetId::EM ?
135  dxhEM : dxhHAD ) ) ;
136  const double dh ( section == HcalCastorDetId::EM ?
137  dhEM : dhHAD ) ;
138  const double dz ( section == HcalCastorDetId::EM ?
139  dzEM : dzHAD ) ;
140 
141  const double delz ( dh*can ) ;
142  const double dy ( dh*san ) ;
143  const double dx ( ( dxl + dxh )/2. ) ;
144  const double leg ( dR + dy ) ;
145  const double len ( sqrt( leg*leg + dx*dx ) ) ;
146 
147  static const double dphi
149 
150  const double fphi ( atan( dx/( dR + dy ) ) ) ;
151 
152  const double phi ( 0==isect%2 ? (sector-1.)*dphi - fphi :
153  sector*dphi - fphi ) ;
154 
155  const double sphi ( sin( phi ) ) ;
156  const double cphi ( cos( phi ) ) ;
157 
158  const double xc ( len*cphi ) ;
159  const double yc ( len*sphi ) ;
160  const double zc ( zside*( zm + delz +
161  ( module<3 ? ( 1.*module - 1.0 )*2.*dzEM :
162  4.*dzEM + ( 1.*(module-2) - 1 )*2.*dzHAD ) ) ) ;
163 
164  const GlobalPoint fc ( xc, yc, zc ) ;
165 
166  std::vector<CCGFloat> zz ;
168  zz.push_back( dxl ) ;
169  zz.push_back( dxh ) ;
170  zz.push_back( dh ) ;
171  zz.push_back( dz ) ;
172  zz.push_back( an ) ;
173  zz.push_back( dR ) ;
174 
175  geom->newCell( fc, fc, fc,
177  geom->parMgr(),
178  geom->parVecVec() ),
179  detId ) ;
180 }
181 
182 
int sector() const
get the sector (1-16)
virtual void newCell(const GlobalPoint &f1, const GlobalPoint &f2, const GlobalPoint &f3, const CCGFloat *parm, const DetId &detId)=0
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
int module() const
get the module (1-2 for EM, 1-12 for HAD)
void makeCell(const HcalCastorDetId &detId, CaloSubdetectorGeometry *geom) const
Section section() const
get the section
void allocatePar(ParVec::size_type n, unsigned int m)
static const double dYHADPlate
void fill(HcalCastorDetId::Section section, CaloSubdetectorGeometry *cg)
T sqrt(T t)
Definition: SSEVec.h:48
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
int zside() const
get the z-side of the cell (1/-1)
CaloCellGeometry::CCGFloat CCGFloat
static const double dXHADPlate
static const CCGFloat * getParmPtr(const std::vector< CCGFloat > &vd, ParMgr *mgr, ParVecVec &pvv)
static const int SubdetectorId
virtual bool valid(const HcalCastorDetId &id) const
std::auto_ptr< CaloSubdetectorGeometry > load()
#define M_PI
Definition: BFit3D.cc:3
static const double dYEMPlate
CaloCellGeometry::CornersMgr * cornersMgr()
Detector
Definition: DetId.h:26
static const double dXEMPlate
int firstCell(HcalCastorDetId::Section section) const
void allocateCorners(CaloCellGeometry::CornersVec::size_type n)
int lastCell(HcalCastorDetId::Section section) const
Definition: vlib.h:209
tuple dh
Definition: cuy.py:353
Definition: DDAxes.h:10