CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
L1CaloGeometry.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: L1Geometry
4 // Class : L1CaloGeometry
5 //
6 // Implementation:
7 // <Notes on implementation>
8 //
9 // Original Author: Werner Sun
10 // Created: Mon Oct 23 21:52:36 EDT 2006
11 // $Id: L1CaloGeometry.cc,v 1.4 2009/09/28 22:59:14 wsun Exp $
12 //
13 
14 // system include files
15 #include <cmath>
16 
17 // user include files
19 
20 
21 //
22 // constants, enums and typedefs
23 //
24 
25 //
26 // static data member definitions
27 //
28 
29 // double L1CaloGeometry::m_gctEmJetPhiOffset =
30 // -M_PI / L1CaloGeometry::kNumberGctEmJetPhiBins ;
31 // double L1CaloGeometry::m_gctEtSumPhiOffset = 0. ;
32 
33 // double L1CaloGeometry::m_gctEmJetPhiBinWidth =
34 // 2. * M_PI / L1CaloGeometry::kNumberGctEmJetPhiBins ;
35 // double L1CaloGeometry::m_gctEtSumPhiBinWidth =
36 // 2. * M_PI / L1CaloGeometry::kNumberGctEtSumPhiBins ;
37 
38 // double L1CaloGeometry::m_gctEtaBinBoundaries[
39 // kNumberGctCentralEtaBinsPerHalf + kNumberGctForwardEtaBinsPerHalf + 1 ] = {
40 // 0.0000,
41 // 0.3480,
42 // 0.6950,
43 // 1.0440,
44 // 1.3920,
45 // 1.7400,
46 // 2.1720,
47 // 3.0000,
48 // 3.5000,
49 // 4.0000,
50 // 4.5000,
51 // 5.0000 } ;
52 
53 //
54 // constructors and destructor
55 //
57  : m_version( kOrig ), // if version is not in CondDB, set it to kOrig
58  m_numberGctEmJetPhiBins( 0 ),
59  m_numberGctEtSumPhiBins( 0 ),
60  m_numberGctHtSumPhiBins( 0 ),
61  m_numberGctCentralEtaBinsPerHalf( 0 ),
62  m_numberGctForwardEtaBinsPerHalf( 0 ),
63  m_etaSignBitOffset( 0 ),
64  m_gctEtaBinBoundaries(),
65  m_etaBinsPerHalf( 0 ),
66  m_gctEmJetPhiBinWidth( 0. ),
67  m_gctEtSumPhiBinWidth( 0. ),
68  m_gctHtSumPhiBinWidth( 0. ),
69  m_gctEmJetPhiOffset( 0. ),
70  m_gctEtSumPhiOffset( 0. ),
71  m_gctHtSumPhiOffset( 0. )
72 {
73 }
74 
75 L1CaloGeometry::L1CaloGeometry( unsigned int numberGctEmJetPhiBins,
76  double gctEmJetPhiBinOffset,
77  unsigned int numberGctEtSumPhiBins,
78  double gctEtSumPhiBinOffset,
79  unsigned int numberGctHtSumPhiBins,
80  double gctHtSumPhiBinOffset,
81  unsigned int numberGctCentralEtaBinsPerHalf,
82  unsigned int numberGctForwardEtaBinsPerHalf,
83  unsigned int etaSignBitOffset,
84  const std::vector<double>& gctEtaBinBoundaries)
85  : m_version( kAddedMHTPhi ),
86  m_numberGctEmJetPhiBins( numberGctEmJetPhiBins ),
87  m_numberGctEtSumPhiBins( numberGctEtSumPhiBins ),
88  m_numberGctHtSumPhiBins( numberGctHtSumPhiBins ),
89  m_numberGctCentralEtaBinsPerHalf( numberGctCentralEtaBinsPerHalf ),
90  m_numberGctForwardEtaBinsPerHalf( numberGctForwardEtaBinsPerHalf ),
91  m_etaSignBitOffset( etaSignBitOffset ),
92  m_gctEtaBinBoundaries( gctEtaBinBoundaries )
93 {
96 
100 
101  m_gctEmJetPhiOffset = gctEmJetPhiBinOffset * m_gctEmJetPhiBinWidth ;
102  m_gctEtSumPhiOffset = gctEtSumPhiBinOffset * m_gctEtSumPhiBinWidth ;
103  m_gctHtSumPhiOffset = gctHtSumPhiBinOffset * m_gctHtSumPhiBinWidth ;
104 }
105 
106 // L1CaloGeometry::L1CaloGeometry(const L1CaloGeometry& rhs)
107 // {
108 // // do actual copying here;
109 // }
110 
112 {
113 }
114 
115 //
116 // assignment operators
117 //
118 // const L1CaloGeometry& L1CaloGeometry::operator=(const L1CaloGeometry& rhs)
119 // {
120 // //An exception safe implementation is
121 // L1CaloGeometry temp(rhs);
122 // swap(rhs);
123 //
124 // return *this;
125 // }
126 
127 //
128 // member functions
129 //
130 
131 //
132 // const member functions
133 //
134 
135 double
136 L1CaloGeometry::globalEtaBinCenter( unsigned int globalEtaIndex ) const
137 {
138  int etaIndex ;
139  double etaSign = 1. ;
140  if( globalEtaIndex < m_etaBinsPerHalf )
141  {
142  etaIndex = m_etaBinsPerHalf - globalEtaIndex - 1 ;
143  etaSign = -1. ;
144  }
145  else
146  {
147  etaIndex = globalEtaIndex - m_etaBinsPerHalf ;
148  }
149 
150  return 0.5 * etaSign *
152  m_gctEtaBinBoundaries[ etaIndex + 1 ] ) ;
153 }
154 
155 double
156 L1CaloGeometry::globalEtaBinLowEdge( unsigned int globalEtaIndex ) const
157 {
158  int etaIndex ;
159  double etaSign = 1. ;
160  if( globalEtaIndex < m_etaBinsPerHalf )
161  {
162  etaIndex = m_etaBinsPerHalf - globalEtaIndex - 1 ;
163  etaSign = -1. ;
164  }
165  else
166  {
167  etaIndex = globalEtaIndex - m_etaBinsPerHalf ;
168  }
169 
170  return ( etaSign > 0. ?
171  m_gctEtaBinBoundaries[ etaIndex ] :
172  -m_gctEtaBinBoundaries[ etaIndex + 1 ] ) ;
173 }
174 
175 double
176 L1CaloGeometry::globalEtaBinHighEdge( unsigned int globalEtaIndex ) const
177 {
178  int etaIndex ;
179  double etaSign = 1. ;
180  if( globalEtaIndex < m_etaBinsPerHalf )
181  {
182  etaIndex = m_etaBinsPerHalf - globalEtaIndex - 1 ;
183  etaSign = -1. ;
184  }
185  else
186  {
187  etaIndex = globalEtaIndex - m_etaBinsPerHalf ;
188  }
189 
190  return ( etaSign > 0. ?
191  m_gctEtaBinBoundaries[ etaIndex + 1 ] :
192  -m_gctEtaBinBoundaries[ etaIndex ] ) ;
193 }
194 
195 double
196 L1CaloGeometry::etaBinCenter( unsigned int etaIndex,
197  bool central ) const
198 {
199  // Central/tau jets and EM have etaIndex = 0-6 for eta = 0-3.
200  // Forward jets have etaIndex = 0-3 for eta = 3-5.
201  double etaSign = 1. ;
202 
203  // Check sign BEFORE shifting forward jet bin index.
204  if( etaIndex >= m_etaSignBitOffset )
205  {
206  etaSign = -1. ;
207  etaIndex -= m_etaSignBitOffset ;
208  }
209 
210  // Shift forward jet bin index AFTER checking sign bit.
211  if( !central )
212  {
214  }
215 
216  return 0.5 * etaSign *
218  m_gctEtaBinBoundaries[ etaIndex + 1 ] ) ;
219 }
220 
221 double
222 L1CaloGeometry::etaBinLowEdge( unsigned int etaIndex,
223  bool central ) const
224 {
225  // Central/tau jets and EM have etaIndex = 0-6 for eta = 0-3.
226  // Forward jets have etaIndex = 0-3 for eta = 3-5.
227  double etaSign = 1. ;
228 
229  // Check sign BEFORE shifting forward jet bin index.
230  if( etaIndex >= m_etaSignBitOffset )
231  {
232  etaSign = -1. ;
233  etaIndex -= m_etaSignBitOffset ;
234  }
235 
236  // Shift forward jet bin index AFTER checking sign bit.
237  if( !central )
238  {
240  }
241 
242  return ( etaSign > 0. ?
243  m_gctEtaBinBoundaries[ etaIndex ] :
244  -m_gctEtaBinBoundaries[ etaIndex + 1 ] ) ;
245 }
246 
247 double
248 L1CaloGeometry::etaBinHighEdge( unsigned int etaIndex,
249  bool central ) const
250 {
251  // Central/tau jets and EM have etaIndex = 0-6 for eta = 0-3.
252  // Forward jets have etaIndex = 0-3 for eta = 3-5.
253  double etaSign = 1. ;
254 
255  // Check sign BEFORE shifting forward jet bin index.
256  if( etaIndex >= m_etaSignBitOffset )
257  {
258  etaSign = -1. ;
259  etaIndex -= m_etaSignBitOffset ;
260  }
261 
262  // Shift forward jet bin index AFTER checking sign bit.
263  if( !central )
264  {
266  }
267 
268  return ( etaSign > 0. ?
269  m_gctEtaBinBoundaries[ etaIndex + 1 ] :
270  -m_gctEtaBinBoundaries[ etaIndex ] ) ;
271 }
272 
273 double
274 L1CaloGeometry::emJetPhiBinCenter( unsigned int phiIndex ) const
275 {
276  return ( ( double ) phiIndex + 0.5 ) * m_gctEmJetPhiBinWidth +
278 }
279 
280 double
281 L1CaloGeometry::emJetPhiBinLowEdge( unsigned int phiIndex ) const
282 {
283  return ( ( double ) phiIndex ) * m_gctEmJetPhiBinWidth +
285 }
286 
287 double
288 L1CaloGeometry::emJetPhiBinHighEdge( unsigned int phiIndex ) const
289 {
290  return ( ( double ) phiIndex + 1. ) * m_gctEmJetPhiBinWidth +
292 }
293 
294 double
295 L1CaloGeometry::etSumPhiBinCenter( unsigned int phiIndex ) const
296 {
297  return ( ( double ) phiIndex + 0.5 ) * m_gctEtSumPhiBinWidth +
299 }
300 
301 double
302 L1CaloGeometry::etSumPhiBinLowEdge( unsigned int phiIndex ) const
303 {
304  return ( ( double ) phiIndex ) * m_gctEtSumPhiBinWidth +
306 }
307 
308 double
309 L1CaloGeometry::etSumPhiBinHighEdge( unsigned int phiIndex ) const
310 {
311  return ( ( double ) phiIndex + 1. ) * m_gctEtSumPhiBinWidth +
313 }
314 
315 double
316 L1CaloGeometry::htSumPhiBinCenter( unsigned int phiIndex ) const
317 {
318  if( m_version == kOrig )
319  {
320  return ( ( double ) phiIndex + 0.5 ) * m_gctEtSumPhiBinWidth * 4. +
322  }
323  else
324  {
325  return ( ( double ) phiIndex + 0.5 ) * m_gctHtSumPhiBinWidth +
327  }
328 }
329 
330 double
331 L1CaloGeometry::htSumPhiBinLowEdge( unsigned int phiIndex ) const
332 {
333  if( m_version == kOrig )
334  {
335  return ( ( double ) phiIndex ) * m_gctEtSumPhiBinWidth * 4. +
337  }
338  else
339  {
340  return ( ( double ) phiIndex ) * m_gctHtSumPhiBinWidth +
342  }
343 }
344 
345 double
346 L1CaloGeometry::htSumPhiBinHighEdge( unsigned int phiIndex ) const
347 {
348  if( m_version == kOrig )
349  {
350  return ( ( double ) phiIndex + 1. ) * m_gctEtSumPhiBinWidth * 4. +
352  }
353  else
354  {
355  return ( ( double ) phiIndex + 1. ) * m_gctHtSumPhiBinWidth +
357  }
358 }
359 
360 unsigned int
361 L1CaloGeometry::etaIndex( const double& etaValue ) const
362 {
363  unsigned int etaIndex = 0 ;
364 
365  for( unsigned int i = 0 ; i < m_numberGctCentralEtaBinsPerHalf ; ++i )
366  {
367  if( fabs( etaValue ) >= m_gctEtaBinBoundaries[ i ] )
368  {
369  etaIndex = i ;
370  }
371  }
372 
373  for( unsigned int i = 0 ; i < m_numberGctForwardEtaBinsPerHalf ; ++i )
374  {
375  if( fabs( etaValue ) >=
376  m_gctEtaBinBoundaries[ i + m_numberGctCentralEtaBinsPerHalf ] )
377  {
378  etaIndex = i ;
379  }
380  }
381 
382  if( etaValue < 0. )
383  {
384  etaIndex += m_etaSignBitOffset ;
385  }
386 
387  return etaIndex ;
388 }
389 
390 unsigned int
391 L1CaloGeometry::globalEtaIndex( const double& etaValue ) const
392 {
393  unsigned int etaIndex = 0 ;
394 
395  if( etaValue < 0. )
396  {
397  for( unsigned int i = m_etaBinsPerHalf ; i > 0 ; --i )
398  {
399  if( fabs( etaValue ) < m_gctEtaBinBoundaries[ i ] )
400  {
401  etaIndex = m_etaBinsPerHalf - i ;
402  }
403  }
404  }
405  else
406  {
407  for( unsigned int i = 0 ; i < m_etaBinsPerHalf ; ++i )
408  {
409  if( etaValue >= m_gctEtaBinBoundaries[ i ] )
410  {
411  etaIndex = i + m_etaBinsPerHalf ;
412  }
413  }
414  }
415 
416  return etaIndex ;
417 }
418 
419 unsigned int
420 L1CaloGeometry::emJetPhiIndex( const double& phiValue ) const
421 {
422  double phiAdjusted = phiValue - m_gctEmJetPhiOffset ;
423 
424  // Check phiValue is between m_gctEmJetPhiOffset and m_gctEmJetPhiOffset+2pi
425  if( phiAdjusted < 0. )
426  {
427  do
428  {
429  phiAdjusted += 2. * M_PI ;
430  }
431  while( phiAdjusted < 0. ) ;
432  }
433  else if( phiAdjusted > 2. * M_PI )
434  {
435  do
436  {
437  phiAdjusted -= 2. * M_PI ;
438  }
439  while( phiAdjusted > 2. * M_PI ) ;
440  }
441 
442  return ( ( int ) ( phiAdjusted / m_gctEmJetPhiBinWidth ) ) ;
443 }
444 
445 unsigned int
446 L1CaloGeometry::etSumPhiIndex( const double& phiValue ) const
447 {
448  double phiAdjusted = phiValue - m_gctEtSumPhiOffset ;
449 
450  // Check phiValue is between m_gctEtSumPhiOffset and m_gctEtSumPhiOffset+2pi
451  if( phiAdjusted < 0. )
452  {
453  do
454  {
455  phiAdjusted += 2. * M_PI ;
456  }
457  while( phiAdjusted < 0. ) ;
458  }
459  else if( phiAdjusted > 2. * M_PI )
460  {
461  do
462  {
463  phiAdjusted -= 2. * M_PI ;
464  }
465  while( phiAdjusted > 2. * M_PI ) ;
466  }
467 
468  return ( ( int ) ( phiAdjusted / m_gctEtSumPhiBinWidth ) ) ;
469 }
470 
471 unsigned int
472 L1CaloGeometry::htSumPhiIndex( const double& phiValue ) const
473 {
474  double phiAdjusted = phiValue - m_gctEtSumPhiOffset ;
475 
476  // Check phiValue is between m_gctEtSumPhiOffset and m_gctEtSumPhiOffset+2pi
477  if( phiAdjusted < 0. )
478  {
479  do
480  {
481  phiAdjusted += 2. * M_PI ;
482  }
483  while( phiAdjusted < 0. ) ;
484  }
485  else if( phiAdjusted > 2. * M_PI )
486  {
487  do
488  {
489  phiAdjusted -= 2. * M_PI ;
490  }
491  while( phiAdjusted > 2. * M_PI ) ;
492  }
493 
494  if( m_version == kOrig )
495  {
496  return ( ( int ) ( phiAdjusted / ( m_gctEtSumPhiBinWidth * 4. ) ) ) ;
497  }
498  else
499  {
500  return ( ( int ) ( phiAdjusted / m_gctHtSumPhiBinWidth ) ) ;
501  }
502 }
503 
504 unsigned int
506 {
507  if( m_version == kOrig )
508  {
509  return m_numberGctEtSumPhiBins / 4 ;
510  }
511  else
512  {
513  return m_numberGctHtSumPhiBins ;
514  }
515 }
516 
517 std::ostream& operator << ( std::ostream& os, const L1CaloGeometry& obj )
518 {
519  os << "L1CaloGeometry:" << std::endl ;
520 
521  os << "Central/tau eta bins: low / center / high" << std::endl ;
522  for( unsigned int i = 0 ; i < obj.numberGctCentralEtaBinsPerHalf() ; ++i )
523  {
524  os << " bin " << i << ": "
525  << obj.etaBinLowEdge( i ) << " / "
526  << obj.etaBinCenter( i ) << " / "
527  << obj.etaBinHighEdge( i )
528  << std::endl ;
529  }
530 
531  os << "Forward eta bins: low / center / high" << std::endl ;
532  for( unsigned int i = 0 ; i < obj.numberGctForwardEtaBinsPerHalf() ; ++i )
533  {
534  os << " bin " << i << ": "
535  << obj.etaBinLowEdge( i, false ) << " / "
536  << obj.etaBinCenter( i, false ) << " / "
537  << obj.etaBinHighEdge( i, false )
538  << std::endl ;
539  }
540 
541  os << "Global eta bins: low / center / high" << std::endl ;
542  for( unsigned int i = 0 ; i < obj.numberGctCentralEtaBinsPerHalf() +
544  {
545  os << " bin " << i << ": "
546  << obj.globalEtaBinLowEdge( i ) << " / "
547  << obj.globalEtaBinCenter( i ) << " / "
548  << obj.globalEtaBinHighEdge( i )
549  << std::endl ;
550  }
551 
552  os << "EM/jet phi bins: low / center / high" << std::endl ;
553  for( unsigned int i = 0 ; i < obj.numberGctEmJetPhiBins() ; ++i )
554  {
555  os << " bin " << i << ": "
556  << obj.emJetPhiBinLowEdge( i ) << " / "
557  << obj.emJetPhiBinCenter( i ) << " / "
558  << obj.emJetPhiBinHighEdge( i )
559  << std::endl ;
560  }
561 
562  os << "Et sum phi bins: low / center / high" << std::endl ;
563  for( unsigned int i = 0 ; i < obj.numberGctEtSumPhiBins() ; ++i )
564  {
565  os << " bin " << i << ": "
566  << obj.etSumPhiBinLowEdge( i ) << " / "
567  << obj.etSumPhiBinCenter( i ) << " / "
568  << obj.etSumPhiBinHighEdge( i )
569  << std::endl ;
570  }
571 
572  os << "Ht sum phi bins: low / center / high" << std::endl ;
573  for( unsigned int i = 0 ; i < obj.numberGctHtSumPhiBins() ; ++i )
574  {
575  os << " bin " << i << ": "
576  << obj.htSumPhiBinLowEdge( i ) << " / "
577  << obj.htSumPhiBinCenter( i ) << " / "
578  << obj.htSumPhiBinHighEdge( i )
579  << std::endl ;
580  }
581 
582  return os ;
583 }
584 
585 //
586 // static member functions
587 //
double globalEtaBinLowEdge(unsigned int globalEtaIndex) const
unsigned int numberGctForwardEtaBinsPerHalf() const
int i
Definition: DBlmapReader.cc:9
double etaBinHighEdge(unsigned int etaIndex, bool central=true) const
unsigned int numberGctHtSumPhiBins() const
double etaBinLowEdge(unsigned int etaIndex, bool central=true) const
double htSumPhiBinLowEdge(unsigned int phiIndex) const
unsigned int numberGctEtSumPhiBins() const
unsigned int m_numberGctEtSumPhiBins
virtual ~L1CaloGeometry()
double m_gctEmJetPhiBinWidth
unsigned int numberGctEmJetPhiBins() const
double m_gctEtSumPhiOffset
std::ostream & operator<<(std::ostream &out, const ALILine &li)
Definition: ALILine.cc:188
double etaBinCenter(unsigned int etaIndex, bool central=true) const
unsigned int numberGctCentralEtaBinsPerHalf() const
unsigned int htSumPhiIndex(const double &phiValue) const
double m_gctHtSumPhiOffset
unsigned int m_numberGctCentralEtaBinsPerHalf
std::vector< double > m_gctEtaBinBoundaries
unsigned int m_version
unsigned int m_numberGctEmJetPhiBins
double m_gctEmJetPhiOffset
double htSumPhiBinCenter(unsigned int phiIndex) const
unsigned int etSumPhiIndex(const double &phiValue) const
double m_gctHtSumPhiBinWidth
double m_gctEtSumPhiBinWidth
unsigned int emJetPhiIndex(const double &phiValue) const
#define M_PI
double globalEtaBinCenter(unsigned int globalEtaIndex) const
double globalEtaBinHighEdge(unsigned int globalEtaIndex) const
double etSumPhiBinLowEdge(unsigned int phiIndex) const
unsigned int m_etaSignBitOffset
unsigned int m_etaBinsPerHalf
unsigned int m_numberGctHtSumPhiBins
unsigned int m_numberGctForwardEtaBinsPerHalf
double emJetPhiBinCenter(unsigned int phiIndex) const
double emJetPhiBinLowEdge(unsigned int phiIndex) const
double htSumPhiBinHighEdge(unsigned int phiIndex) const
unsigned int globalEtaIndex(const double &etaValue) const
double etSumPhiBinCenter(unsigned int phiIndex) const
double emJetPhiBinHighEdge(unsigned int phiIndex) const
double etSumPhiBinHighEdge(unsigned int phiIndex) const
unsigned int etaIndex(const double &etaValue) const