test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
L1CaloEcalScale.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: L1TObjects
4 // Class : L1CaloEcalScale
5 //
6 // Implementation:
7 // <Notes on implementation>
8 //
9 // Author:
10 // Created: Wed Sep 27 17:18:27 CEST 2006
11 // $Id:
12 
14 
15 using std::vector;
16 using std::ostream;
17 using std::endl;
18 
21 {
22  for (unsigned i=0; i<nBinRank; i++) {
23  for (unsigned eta=0; eta<nBinEta; eta++) {
24  m_scale[i][eta] = lsb * i;
25  m_scale[i][eta+nBinEta] = lsb * i;
26  }
27  }
28 }
29 
32 
33 }
34 
36 void L1CaloEcalScale::setBin(unsigned short rank,
37  unsigned short eta,
38  short etaSign,
39  double et) {
40  --eta ; // input eta index starts at 1
41  if (rank < nBinRank && eta < nBinEta) {
42  if( etaSign < 0 ) eta += nBinEta ;
43  m_scale[rank][eta] = et;
44  }
45  else {
46  // throw
47  }
48 }
49 
51 unsigned short L1CaloEcalScale::rank(double et,
52  unsigned short eta,
53  short etaSign) const {
54  --eta ; // input eta index starts at 1
55  if (eta < nBinEta) {
56  unsigned short out = 0;
57  if( etaSign < 0 ) eta += nBinEta ;
58  for (unsigned i=0; i<nBinRank; i++) {
59  if ( et >= m_scale[i][eta] ) { out = i; }
60  }
61  return out & (nBinRank-1);
62  }
63  else {
64  // throw
65  }
66  return nBinRank ;
67 }
68 
69 // convert from rank to Et/GeV
70 double L1CaloEcalScale::et(unsigned short rank,
71  unsigned short eta,
72  short etaSign) const {
73  --eta ; // input eta index starts at 1
74  if (rank < nBinRank && eta < nBinEta) {
75  if( etaSign < 0 ) eta += nBinEta ;
76  return m_scale[rank][eta];
77  }
78  else return -1.;
79 }
80 
81 // pretty print
82 void L1CaloEcalScale::print(ostream& s) const {
83  s << "L1CaloEcalScaleRcd" << endl;
84  s << "Energy for ECAL inputs into the RCT" <<endl;
85  s << "Each new row is for a given value of 8 bit output of ECAL. Each column is for the respective eta value " << endl;
86 
87  for (unsigned rank=0; rank<nBinRank; rank++) {
88  s << "rank = " <<rank << " ";
89  for (unsigned eta=0; eta<2*nBinEta; eta++) {
90  s << m_scale[rank][eta] << " " ;
91  }
92  s << endl;
93  }
94 }
95 
96 
int i
Definition: DBlmapReader.cc:9
L1CaloEcalScale(double lsb=1.0)
constructor (creates a linear scale with an LSB - no LSB gives identity)
void print(std::ostream &s) const
void setBin(unsigned short rank, unsigned short eta, short etaSign, double et)
set scale element; use this to create non-linear scales
double m_scale[nBinRank][2 *nBinEta]
thresholds associated with rank scale in GeV
double et(unsigned short rank, unsigned short eta, short etaSign) const
convert from rank to physically meaningful quantity
uint16_t rank(double et, unsigned short eta, short etaSign) const
convert from physical Et in GeV to rank scale
static const unsigned short nBinRank
static const unsigned short nBinEta
~L1CaloEcalScale()
destructor