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  theTopology ( new CastorTopology ) ,
11  extTopology ( theTopology )
12 {
13  init();
14 }
15 
17  theTopology( 0 ) ,
18  extTopology ( &ht )
19 {
20  init();
21 }
22 
24 {
27  theEMSectiondZ = 101.0;
30  theHADSectiondZ = 1212.;
31 }
32 
33 std::auto_ptr<CaloSubdetectorGeometry>
35  int subdet)
36 {
37  std::auto_ptr<CaloSubdetectorGeometry> hg(new CastorGeometry( extTopology ));
38  if( subdet == HcalCastorDetId::SubdetectorId )
39  {
40  fill( HcalCastorDetId::EM, hg.get() ) ;
41  fill( HcalCastorDetId::HAD, hg.get() ) ;
42  }
43  return hg;
44 }
45 
46 std::auto_ptr<CaloSubdetectorGeometry>
48 {
49  std::auto_ptr<CaloSubdetectorGeometry> hg
50  ( new CastorGeometry( extTopology ) ) ;
51  fill( HcalCastorDetId::EM, hg.get() ) ;
52  fill( HcalCastorDetId::HAD, hg.get() ) ;
53  return hg;
54 }
55 
56 void
59 {
60  if( geom->cornersMgr() == 0 ) geom->allocateCorners(
62  if( geom->parMgr() == 0 ) geom->allocatePar(
65  CastorGeometry::k_NumberOfParametersPerShape ) ;
66 
67  // start by making the new HcalDetIds
68  std::vector<HcalCastorDetId> castorIds ;
69 
70  const int firstCell ( extTopology->firstCell( section ) ) ;
71  const int lastCell ( extTopology->lastCell( section ) );
72 
73  for( int imodule ( firstCell ) ; imodule <= lastCell ; ++imodule )
74  {
75  for( int isector ( 1 ) ;
76  isector <= HcalCastorDetId::kNumberSectorsPerEnd ; ++isector )
77  {
78  const HcalCastorDetId id ( section, false, isector, imodule ) ;
79  if( extTopology->valid( id ) ) castorIds.push_back( id ) ;
80  }
81  }
82 // edm::LogInfo("CastorHardcodeGeometry")
83 // << "Number of Castor DetIds made: " << section
84 // << " " << castorIds.size();
85 
86  // for each new HcalCastorDetId, make a CaloCellGeometry
87 
88  for( std::vector<HcalCastorDetId>::const_iterator
89  castorIdItr ( castorIds.begin() ) ;
90  castorIdItr != castorIds.end() ; ++castorIdItr )
91  {
92  geom->addCell( *castorIdItr, makeCell( *castorIdItr, geom ) ) ;
93  }
94 }
95 
99 {
100  const double zside ( 1.0*detId.zside() ) ;
101  const HcalCastorDetId::Section section ( detId.section() ) ;
102  const int module ( detId.module() ) ;
103  const int isect ( detId.sector() ) ;
104  const double sector ( 1.0*isect ) ;
105 
106 // length units are cm
107 
108 
109  const double sign ( 0 == isect%2 ? -1 : 1 ) ;
110 
111 //********* HERE ARE HARDWIRED GEOMETRY NUMBERS ACTUALLY USED *****
112 
113  static const double an ( atan( 1.)); //angle of cant w.r.t. beam
114  static const double can ( cos( an ));
115  static const double san ( sin( an ));
116  static const double dxlEM ( 1.55/2. ) ; //halflength of side near beam
117  static const double dxhEM ( 5.73/2. ) ; //halflength of side away from beam
118  static const double dhEM ( 14.26/2. ); //halflength of 2nd longest side
119  static const double dR ( 0.1 + 2.*dhEM*san*dxlEM/( dxhEM-dxlEM ) ) ;
120  static const double dhHAD ( 19.88/2. ); //halflength of 2nd longest side
121 
122  static const double dxhHAD ( dxhEM*( 2.*dhHAD*san + dR )/
123  ( 2.*dhEM*san + dR ) ) ; //halflength of side away from beam
124  static const double zm ( 1439.0 ) ; //z of start of EM
125  static const double dzEM ( 5.45/2 ) ; // halflength in z of EM
126  static const double dzHAD ( 10.075/2 ) ; // halflength in z of HAD
127 
128 //*****************************************************************
129 
130  const double dxl ( sign*dxlEM ) ; // same for EM and HAD
131 
132  const double dxh ( sign*( section == HcalCastorDetId::EM ?
133  dxhEM : dxhHAD ) ) ;
134  const double dh ( section == HcalCastorDetId::EM ?
135  dhEM : dhHAD ) ;
136  const double dz ( section == HcalCastorDetId::EM ?
137  dzEM : dzHAD ) ;
138 
139  const double delz ( dh*can ) ;
140  const double dy ( dh*san ) ;
141  const double dx ( ( dxl + dxh )/2. ) ;
142  const double leg ( dR + dy ) ;
143  const double len ( sqrt( leg*leg + dx*dx ) ) ;
144 
145  static const double dphi
147 
148  const double fphi ( atan( dx/( dR + dy ) ) ) ;
149 
150  const double phi ( 0==isect%2 ? (sector-1.)*dphi - fphi :
151  sector*dphi - fphi ) ;
152 
153  const double sphi ( sin( phi ) ) ;
154  const double cphi ( cos( phi ) ) ;
155 
156  const double xc ( len*cphi ) ;
157  const double yc ( len*sphi ) ;
158  const double zc ( zside*( zm + delz +
159  ( module<3 ? ( 1.*module - 1.0 )*2.*dzEM :
160  4.*dzEM + ( 1.*(module-2) - 1 )*2.*dzHAD ) ) ) ;
161 
162  const GlobalPoint fc ( xc, yc, zc ) ;
163 
164  std::vector<double> zz ;
166  zz.push_back( dxl ) ;
167  zz.push_back( dxh ) ;
168  zz.push_back( dh ) ;
169  zz.push_back( dz ) ;
170  zz.push_back( an ) ;
171  zz.push_back( dR ) ;
172 
173  return new calogeom::IdealCastorTrapezoid(
174  fc,
175  geom->cornersMgr(),
177  geom->parMgr(),
178  geom->parVecVec() ) );
179 }
180 
181 
CaloCellGeometry * makeCell(const HcalCastorDetId &detId, CaloSubdetectorGeometry *geom) const
int module() const
Definition: HLTadd.h:12
int sector() const
get the sector (1-16)
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)
Section section() const
get the section
void allocatePar(ParVec::size_type n, unsigned int m)
void addCell(const DetId &id, CaloCellGeometry *ccg)
Add a cell to the geometry.
static const double dYHADPlate
void fill(HcalCastorDetId::Section section, CaloSubdetectorGeometry *cg)
T sqrt(T t)
Definition: SSEVec.h:28
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
int zside() const
get the z-side of the cell (1/-1)
static const double dXHADPlate
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 * getParmPtr(const std::vector< double > &vd, ParMgr *mgr, ParVecVec &pvv)
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
Definition: DDAxes.h:10