Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013 #include "CondFormats/L1TObjects/interface/L1CaloEtScale.h"
00014
00015 #include "FWCore/Utilities/interface/Exception.h"
00016 #include <stdexcept>
00017
00018 using std::vector;
00019 using std::ostream;
00020 using std::endl;
00021
00022
00023 L1CaloEtScale::L1CaloEtScale() :
00024 m_linScaleMax(0x3ff),
00025 m_rankScaleMax(0x3f),
00026 m_linearLsb(1.0)
00027 {
00028 for (unsigned i=0; i<m_rankScaleMax; i++) {
00029 m_thresholds.push_back(m_linearLsb * i);
00030 }
00031 }
00032
00033
00034
00035 L1CaloEtScale::L1CaloEtScale(const double linearLsbInGeV, const vector<double> thresholdsInGeV) :
00036 m_linScaleMax(0x3ff),
00037 m_rankScaleMax(0x3f),
00038 m_linearLsb(linearLsbInGeV),
00039 m_thresholds(thresholdsInGeV) {
00040
00041
00042
00043
00044
00045
00046 }
00047
00048
00049
00050 L1CaloEtScale::L1CaloEtScale(const unsigned linScaleMax, const unsigned rankScaleMax, const double linearLsbInGeV, const vector<double> thresholdsInGeV) :
00051 m_linScaleMax(linScaleMax),
00052 m_rankScaleMax(rankScaleMax),
00053 m_linearLsb(linearLsbInGeV),
00054 m_thresholds(thresholdsInGeV) {
00055
00056 }
00057
00058
00059 L1CaloEtScale::~L1CaloEtScale() {
00060
00061 }
00062
00063
00064 uint16_t L1CaloEtScale::rank(const uint16_t linear) const {
00065
00066 return rank( (linear & m_linScaleMax) * m_linearLsb);
00067
00068 }
00069
00071 uint16_t L1CaloEtScale::rank(const double EtInGeV) const {
00072
00073 uint16_t out = 0;
00074
00075 for (unsigned i=0; i<m_thresholds.size() && i<(unsigned)(m_rankScaleMax+1); i++) {
00076 if ( EtInGeV >= m_thresholds.at(i) ) { out = i; }
00077 }
00078
00079 return out & m_rankScaleMax;
00080 }
00081
00082
00083 double L1CaloEtScale::et(const uint16_t rank) const {
00084
00085
00086
00087
00088
00089
00090
00091
00092
00093
00094 try {
00095 return m_thresholds.at(rank);
00096 }
00097 catch(std::out_of_range) {
00098 throw cms::Exception("OutOfRange") << "Index out of range in L1CaloEtScale::et(rank)" << std::endl;
00099 }
00100
00101 }
00102
00103 void L1CaloEtScale::print(ostream& s) const {
00104 s << "L1CaloEtScale :" << endl;
00105 s << " Input scale max = " << m_linScaleMax << endl;
00106 s << " Input LSB = " << m_linearLsb << " GeV" << endl;
00107 s << " Rank scale max = " << m_rankScaleMax << endl;
00108 for (unsigned i=0; i<m_thresholds.size(); i++) {
00109 s << " Threshold " << i << " = " << m_thresholds[i] << " GeV" << endl;
00110 }
00111 }
00112
00113 std::ostream& operator << (std::ostream& os, const L1CaloEtScale obj) {
00114 os << "L1CaloEtScale :" << endl;
00115 os << " Input scale max = " << obj.linScaleMax() << endl;
00116 os << " Input LSB = " << obj.linearLsb() << " GeV" << endl;
00117 os << " Rank scale max = " << obj.rankScaleMax() << endl;
00118 for (unsigned i=0; i<obj.getThresholds().size(); i++) {
00119 os << " Threshold " << i << " = " << obj.getThresholds().at(i) << " GeV" << endl;
00120 }
00121 return os ;
00122 }
00123
00124
00125