00001 // -*- C++ -*- 00002 // 00003 // Package: L1TObjects 00004 // Class : L1CaloEtScale 00005 // 00006 // Implementation: 00007 // <Notes on implementation> 00008 // 00009 // Author: 00010 // Created: Wed Sep 27 17:18:27 CEST 2006 00011 // $Id: 00012 00013 #include "CondFormats/L1TObjects/interface/L1CaloEtScale.h" 00014 00015 using std::vector; 00016 using std::ostream; 00017 using std::endl; 00018 00019 uint16_t L1CaloEtScale::linScaleMax = 0x3ff; 00020 uint16_t L1CaloEtScale::rankScaleMax = 0x3f; 00021 00022 // default constructor (testing only!) 00023 L1CaloEtScale::L1CaloEtScale() : 00024 m_linearLsb(1.0), 00025 m_thresholds(rankScaleMax) 00026 { 00027 00028 for (unsigned i=0; i<rankScaleMax; i++) { 00029 m_thresholds[i] = m_linearLsb * i; 00030 } 00031 00032 } 00033 00034 // real constructor 00035 L1CaloEtScale::L1CaloEtScale(const double linearLsbInGeV, const vector<double> thresholdsInGeV) : 00036 m_linearLsb(linearLsbInGeV), 00037 m_thresholds(thresholdsInGeV) { 00038 00039 // protect against too many thresholds! 00040 // while ( m_threshold.size() > (L1GctJetScale::maxRank+1) ) { 00041 // m_thresholds.pop_back(); 00042 // } 00043 00044 } 00045 00046 00047 L1CaloEtScale::~L1CaloEtScale() { 00048 00049 } 00050 00051 // convert from linear Et to rank 00052 uint16_t L1CaloEtScale::rank(const uint16_t linear) const { 00053 00054 return rank( (linear & linScaleMax) * m_linearLsb); 00055 00056 } 00057 00059 uint16_t L1CaloEtScale::rank(const double EtInGeV) const { 00060 00061 uint16_t out = 0; 00062 00063 for (unsigned i=0; i<m_thresholds.size() && i<(unsigned)(rankScaleMax+1); i++) { 00064 if ( EtInGeV >= m_thresholds[i] ) { out = i; } 00065 } 00066 00067 return out & rankScaleMax; 00068 } 00069 00070 // convert from rank to Et/GeV 00071 double L1CaloEtScale::et(const uint16_t rank) const { 00072 00073 // return bin centre, except for highest bin 00074 // if (rank < m_thresholds.size()-1) { 00075 // return (m_thresholds[rank+1]+m_thresholds[rank]) / 2; 00076 // } 00077 // else { 00078 // return m_thresholds.back(); 00079 // } 00080 00081 // return bin lower edge 00082 return m_thresholds[rank]; 00083 00084 } 00085 00086 void L1CaloEtScale::print(ostream& s) const { 00087 s << "L1CaloEtScale" << endl; 00088 s << "L1CaloEtScale : linear LSB = " << m_linearLsb << " GeV" << endl; 00089 for (unsigned i=0; i<m_thresholds.size(); i++) { 00090 s << "L1CaloEtScale : threshold " << i << " = " << m_thresholds[i] << " GeV" << endl; 00091 } 00092 } 00093 00094