CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
HcalHardcodeGeometryLoader.cc
Go to the documentation of this file.
8 #include <algorithm>
9 
11 
13  theTopology ( new HcalTopology ),
14  extTopology ( theTopology )
15 {
16  init();
17 }
18 
20  theTopology ( 0 ) ,
21  extTopology ( &ht )
22 {
23  init();
24 }
25 
26 void
28 {
29  theBarrelRadius = 190.;
30  theHBThickness = 93.6; // just from drawings. All thicknesses needs to be done right
31 
32  theHB15aThickness = theHBThickness * 12.0/17.0; // relative weight from layer count!
33  theHB15bThickness = theHBThickness * 4.0/17.0; // relative weight from layer count!
34  theHB16aThickness = theHBThickness * 1.0/17.0; // relative weight from layer count!
35  theHB16bThickness = theHBThickness * 7.0/17.0; // relative weight from layer count!
36 
37  theOuterRadius = 406;
38  theHOThickness = 1.;
39 
40  theHEZPos[0] = 388.0;
41  theHEZPos[1] = 397.0;
42  theHEZPos[2] = 450.0;
43  theHEZPos[3] = 568.0;
44 
45  theHFZPos[0] = 1100.0;
46  theHFZPos[1] = 1120.0;
47  theHFThickness = 165;
48 
49 }
50 
51 
54  int subdet )
55 {
56  HcalSubdetector hsub=static_cast<HcalSubdetector>( subdet );
58 
60  if( hg->parMgr() == 0 ) hg->allocatePar(
63 
64  switch (hsub)
65  {
66  case (HcalBarrel) : fill(hsub, extTopology->firstHBRing(), extTopology->lastHBRing(), hg ); break;
67  case (HcalEndcap) : fill(hsub, extTopology->firstHERing(), extTopology->lastHERing(), hg ); break;
68  case (HcalForward) : fill(hsub, extTopology->firstHFRing(), extTopology->lastHFRing(), hg ); break;
69  case (HcalOuter) : fill(hsub, extTopology->firstHORing(), extTopology->lastHORing(), hg ); break;
70  default: break;
71  }
72  return hg;
73 }
74 
77 {
78  ReturnType hg( new HcalGeometry( extTopology ) ) ;
79 
81  if( hg->parMgr() == 0 ) hg->allocatePar( 500, 5 ) ;
82 
87  return hg;
88 }
89 
90 void
92  int firstEtaRing,
93  int lastEtaRing,
94  ReturnType geom )
95 {
96  // start by making the new HcalDetIds
97  std::vector<HcalDetId> hcalIds;
98  int nDepthSegments, startingDepthSegment;
99  for(int etaRing = firstEtaRing; etaRing <= lastEtaRing; ++etaRing) {
100  extTopology->depthBinInformation(subdet, etaRing, nDepthSegments, startingDepthSegment);
101  unsigned int nPhiBins = extTopology->nPhiBins(etaRing);
102  unsigned int phiInc=72/std::max(36u,nPhiBins);
103  for(int idepth = 0; idepth < nDepthSegments; ++idepth) {
104  int depthBin = startingDepthSegment + idepth;
105 
106  for(unsigned iphi = 1; iphi <= 72; iphi+=phiInc) {
107  for(int zsign = -1; zsign <= 1; zsign += 2) {
108  HcalDetId id( subdet, zsign * etaRing, iphi, depthBin);
109  if (extTopology->valid(id)) hcalIds.push_back(id);
110  }
111  }
112  }
113  }
114 
115  edm::LogInfo("HcalHardcodeGeometry") << "Number of HCAL DetIds made: "
116  << subdet
117  << " " << hcalIds.size();
118  // for each new HcalDetId, make a CaloCellGeometry
119  for(std::vector<HcalDetId>::const_iterator hcalIdItr = hcalIds.begin();
120  hcalIdItr != hcalIds.end(); ++hcalIdItr)
121  {
122  makeCell(*hcalIdItr,geom) ;
123  }
124 }
125 
126 
127 inline double theta_from_eta(double eta){return (2.0*atan(exp(-eta)));}
128 
129 void
131  ReturnType geom ) const
132 {
133  // the two eta boundaries of the cell
134  double eta1, eta2;
135  HcalSubdetector subdet = detId.subdet();
136  int etaRing = detId.ietaAbs();
137  if(subdet == HcalForward)
138  {
139  eta1 = theHFEtaBounds[etaRing-extTopology->firstHFRing()];
140  eta2 = theHFEtaBounds[etaRing-extTopology->firstHFRing()+1];
141  }
142  else if (etaRing==28 && detId.depth()==3)
143  {
144  // double-width in eta at depth 3 in ieta=28
145  eta1 = theHBHEEtaBounds[etaRing-1];
146  eta2 = theHBHEEtaBounds[etaRing+1];
147  }
148  else
149  {
150  eta1 = theHBHEEtaBounds[etaRing-1];
151  eta2 = theHBHEEtaBounds[etaRing];
152  }
153  double eta = 0.5*(eta1+eta2) * detId.zside();
154  double deta = 0.5*(eta2-eta1);
155  double theta = theta_from_eta(eta);
156 
157  int nDepthBins, startingBin;
158  extTopology->depthBinInformation(subdet,etaRing,nDepthBins,startingBin);
159 
160  // in radians
161  double dphi_nominal = 2.0*M_PI / extTopology->nPhiBins(1); // always the same
162  double dphi_half = M_PI / extTopology->nPhiBins(etaRing); // half-width
163 
164  double phi_low = dphi_nominal*(detId.iphi()-1); // low-edge boundaries are constant...
165  double phi = phi_low+dphi_half;
166 
167  bool isBarrel = (subdet == HcalBarrel || subdet == HcalOuter);
168 
169  double x,y,z,r;
170  double thickness;
171 
172  if(isBarrel)
173  {
174  if(subdet == HcalBarrel)
175  {
176  if (detId.ietaAbs()==15)
177  {
178  if (detId.depth()==1)
179  {
180  r = theBarrelRadius;
181  thickness = theHB15aThickness;
182  }
183  else
184  {
186  thickness = theHB15bThickness;
187  }
188  }
189  else if (detId.ietaAbs()==16)
190  {
191  if (detId.depth()==1)
192  {
193  r = theBarrelRadius;
194  thickness = theHB16aThickness;
195  }
196  else
197  {
199  thickness = theHB16bThickness;
200  }
201  }
202  else
203  {
204  r = theBarrelRadius;
205  thickness = theHBThickness;
206  }
207  }
208  else
209  { // HO
210  r = theOuterRadius;
211  thickness = theHOThickness;
212  }
213  z = r * sinh(eta); // sinh(eta) == 1/tan(theta)
214  thickness *= cosh(eta); // cosh(eta) == 1/sin(theta)
215  }
216  else
217  {
218  int depth = detId.depth();
219  if(subdet == HcalEndcap)
220  { // Sadly, Z must be made a function of ieta.
221  if (nDepthBins==1)
222  {
223  z = theHEZPos[depth - 1];
224  thickness = theHEZPos[3] - z;
225  }
226  else if (nDepthBins==2 && depth==2)
227  {
228  z = theHEZPos[depth - 1];
229  if (etaRing==29) // special case for tower 29
230  thickness = theHEZPos[depth] - z;
231  else
232  thickness = theHEZPos[3] - z;
233  }
234  else
235  {
236  z = theHEZPos[depth - 1];
237  thickness = theHEZPos[depth] - z;
238  }
239  thickness /= fabs(tanh(eta));
240  }
241  else
242  {
243  z = theHFZPos[depth - 1];
244  thickness = theHFThickness-(theHFZPos[depth-1]-theHFZPos[0]);
245  }
246  z*=detId.zside(); // get the sign right.
247  r = z * tan(theta);
248  assert(r>0.);
249  }
250 
251  x = r * cos(phi);
252  y = r * sin(phi);
253  GlobalPoint point(x,y,z);
254 
255  std::vector<CCGFloat> hp ;
256  hp.reserve(5) ;
257 
258  if (subdet==HcalForward)
259  {
260  hp.push_back( deta ) ;
261  hp.push_back( dphi_half ) ;
262  hp.push_back( thickness/2 ) ;
263  hp.push_back( fabs( point.eta() ) ) ;
264  hp.push_back( fabs( point.z() ) ) ;
265  }
266  else
267  {
268  const double mysign ( isBarrel ? 1 : -1 ) ;
269  hp.push_back( deta ) ;
270  hp.push_back( dphi_half ) ;
271  hp.push_back( mysign*thickness/2. ) ;
272  hp.push_back( fabs( point.eta() ) ) ;
273  hp.push_back( fabs( point.z() ) ) ;
274  }
275  geom->newCell( point, point, point,
277  geom->parMgr(),
278  geom->parVecVec() ),
279  detId );
280 }
281 
282 
int firstHFRing() const
Definition: HcalTopology.h:65
HcalSubdetector subdet() const
get the subdetector
Definition: HcalDetId.h:32
virtual bool valid(const HcalDetId &id) const
Definition: HcalTopology.cc:32
int zside() const
get the z-side of the cell (1/-1)
Definition: HcalDetId.h:34
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
Geom::Theta< T > theta() const
double theta_from_eta(double eta)
int nPhiBins(int etaRing) const
how many phi segments in this ring
int firstHBRing() const
Definition: HcalTopology.h:61
int lastHBRing() const
Definition: HcalTopology.h:62
T eta() const
void allocatePar(ParVec::size_type n, unsigned int m)
double double double z
int depth() const
get the tower depth
Definition: HcalDetId.h:42
const T & max(const T &a, const T &b)
T z() const
Definition: PV3DBase.h:63
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
int lastHFRing() const
Definition: HcalTopology.h:66
Tan< T >::type tan(const T &t)
Definition: Tan.h:22
HcalSubdetector
Definition: HcalAssistant.h:32
CaloCellGeometry::CCGFloat CCGFloat
void depthBinInformation(HcalSubdetector subdet, int etaRing, int &nDepthBins, int &startingBin) const
finds the number of depth bins and which is the number to start with
int firstHORing() const
Definition: HcalTopology.h:67
static const CCGFloat * getParmPtr(const std::vector< CCGFloat > &vd, ParMgr *mgr, ParVecVec &pvv)
int ietaAbs() const
get the absolute value of the cell ieta
Definition: HcalDetId.h:36
int iphi() const
get the cell iphi
Definition: HcalDetId.h:40
#define M_PI
Definition: BFit3D.cc:3
void fill(HcalSubdetector subdet, int firstEtaRing, int lastEtaRing, ReturnType cg)
static const double theHFEtaBounds[]
CaloCellGeometry::CornersMgr * cornersMgr()
Detector
Definition: DetId.h:26
int firstHERing() const
Definition: HcalTopology.h:63
void makeCell(const HcalDetId &detId, ReturnType geom) const
T eta() const
Definition: PV3DBase.h:75
ReturnType load()
Load all of HCAL.
void allocateCorners(CaloCellGeometry::CornersVec::size_type n)
Definition: DDAxes.h:10
static const double theHBHEEtaBounds[]
int lastHORing() const
Definition: HcalTopology.h:68
*vegas h *****************************************************used in the default bin number in original ***version of VEGAS is ***a higher bin number might help to derive a more precise ***grade subtle point
Definition: invegas.h:5
int lastHERing() const
Definition: HcalTopology.h:64
Definition: DDAxes.h:10