CMS 3D CMS Logo

L1CaloHcalScale.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: L1TObjects
4 // Class : L1CaloHcalScale
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::endl;
16 using std::ostream;
17 using std::vector;
18 
21  for (unsigned i = 0; i < nBinRank; i++) {
22  for (unsigned eta = 0; eta < nBinEta; eta++) {
23  m_scale[i][eta] = lsb * i;
24  m_scale[i][eta + nBinEta] = lsb * i;
25  }
26  }
27 }
28 
31 
33 void L1CaloHcalScale::setBin(unsigned short rank, unsigned short eta, short etaSign, double et) {
34  --eta; // input eta index starts at 1
35  if (rank < nBinRank && eta < nBinEta) {
36  if (etaSign < 0)
37  eta += nBinEta;
38  m_scale[rank][eta] = et;
39  } else {
40  // throw
41  }
42 }
43 
45 unsigned short L1CaloHcalScale::rank(double et, unsigned short eta, short etaSign) const {
46  --eta; // input eta index starts at 1
47  if (eta < nBinEta) {
48  unsigned short out = 0;
49  if (etaSign < 0)
50  eta += nBinEta;
51  for (unsigned i = 0; i < nBinRank; i++) {
52  if (et >= m_scale[i][eta]) {
53  out = i;
54  }
55  }
56  return out & (nBinRank - 1);
57  } else {
58  // throw
59  }
60  return nBinRank;
61 }
62 
63 // convert from rank to Et/GeV
64 double L1CaloHcalScale::et(unsigned short rank, unsigned short eta, short etaSign) const {
65  --eta; // input eta index starts at 1
66  if (rank < nBinRank && eta < nBinEta) {
67  if (etaSign < 0)
68  eta += nBinEta;
69  return m_scale[rank][eta];
70  } else
71  return -1.;
72 }
73 
74 // pretty print
75 void L1CaloHcalScale::print(ostream& s) const {
76  s << "L1CaloHcalScaleRcd" << endl;
77  s << "Energy for HCAL inputs into the RCT" << endl;
78  s << "Each new row is for a given value of 8 bit output of HCAL. Each column is for the respective eta value "
79  << endl;
80  for (unsigned rank = 0; rank < nBinRank; rank++) {
81  s << "rank " << rank << " ";
82  for (unsigned eta = 0; eta < 2 * nBinEta; eta++) {
83  s << m_scale[rank][eta] << " ";
84  }
85  s << endl;
86  }
87 }
void setBin(unsigned short rank, unsigned short eta, short etaSign, double et)
set scale element; use this to create non-linear scales
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
double m_scale[nBinRank][2 *nBinEta]
thresholds associated with rank scale in GeV
void print(std::ostream &s) const
L1CaloHcalScale(double lsb=1.0)
constructor (creates a linear scale with an LSB - no LSB gives identity)
static const unsigned short nBinEta
double et(unsigned short rank, unsigned short eta, short etaSign) const
convert from rank to physically meaningful quantity
~L1CaloHcalScale()
destructor