Skip to content

Commit

Permalink
adapted for use with ecal and hcal compressed scales
Browse files Browse the repository at this point in the history
---
yaml
---
svn_rev: 43346
current_ref: refs/heads/CMSSW_7_2_X
current_commit: f2d7f01
head_branch: refs/heads/CMSSW_7_2_X
migrated_from: v3
  • Loading branch information
Jim Brooke committed May 12, 2008
1 parent 693461e commit 3484261
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 27 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/CMSSW_7_2_X: 5466623b4c10bd8050f8ef5bf7b8114da633a13c
refs/heads/CMSSW_7_2_X: f2d7f0197fa6e1c6e9a8a335c6d708a88aa326fe
15 changes: 9 additions & 6 deletions trunk/CondFormats/L1TObjects/interface/L1CaloEtScale.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,18 +27,15 @@ class L1CaloEtScale {

public:

/// linear scale maximum
static uint16_t linScaleMax;

/// rank scale maximum
static uint16_t rankScaleMax;

/// default constructor (out = in)
L1CaloEtScale();

/// constructor takes physically meaningful quantities
L1CaloEtScale(const double linearLsbInGeV, const std::vector<double> thresholdsInGeV);

/// constructor for non-default number of bits
L1CaloEtScale(unsigned linScaleMax, unsigned rankScaleMax, const double linearLsbInGeV, const std::vector<double> thresholdsInGeV);

// destructor
~L1CaloEtScale();

Expand All @@ -58,6 +55,12 @@ class L1CaloEtScale {

private:

/// linear scale maximum
uint16_t m_linScaleMax;

/// rank scale maximum
uint16_t m_rankScaleMax;

/// LSB of linear scale in GeV
double m_linearLsb;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ class L1GctJetEtCalibrationFunction

static const unsigned NUMBER_ETA_VALUES; ///< Number of eta bins used in correction
static const unsigned N_CENTRAL_ETA_VALUES; ///< Number of eta bins for separate tau correction
static const unsigned LIN_SCALE_MAX; ///< Max value of linear scale

L1GctJetEtCalibrationFunction();
~L1GctJetEtCalibrationFunction();
Expand Down
39 changes: 23 additions & 16 deletions trunk/CondFormats/L1TObjects/src/L1CaloEtScale.cc
Original file line number Diff line number Diff line change
Expand Up @@ -16,23 +16,25 @@ using std::vector;
using std::ostream;
using std::endl;

uint16_t L1CaloEtScale::linScaleMax = 0x3ff;
uint16_t L1CaloEtScale::rankScaleMax = 0x3f;

// default constructor (testing only!)
L1CaloEtScale::L1CaloEtScale() :
m_linScaleMax(0x3ff),
m_rankScaleMax(0x3f),
m_linearLsb(1.0),
m_thresholds(rankScaleMax)
m_thresholds(0x3f)
{

for (unsigned i=0; i<rankScaleMax; i++) {
for (unsigned i=0; i<m_rankScaleMax; i++) {
m_thresholds[i] = m_linearLsb * i;
}

}

// real constructor
L1CaloEtScale::L1CaloEtScale(const double linearLsbInGeV, const vector<double> thresholdsInGeV) :
m_linScaleMax(0x3ff),
m_rankScaleMax(0x3f),
m_linearLsb(linearLsbInGeV),
m_thresholds(thresholdsInGeV) {

Expand All @@ -43,6 +45,19 @@ L1CaloEtScale::L1CaloEtScale(const double linearLsbInGeV, const vector<double> t

}

// real constructor
L1CaloEtScale::L1CaloEtScale(unsigned linScaleMax, unsigned rankScaleMax, const double linearLsbInGeV, const vector<double> thresholdsInGeV) :
m_linScaleMax(linScaleMax),
m_rankScaleMax(rankScaleMax),
m_linearLsb(linearLsbInGeV),
m_thresholds(thresholdsInGeV) {

// protect against too many thresholds!
// while ( m_threshold.size() > (L1GctJetScale::maxRank+1) ) {
// m_thresholds.pop_back();
// }

}

L1CaloEtScale::~L1CaloEtScale() {

Expand All @@ -51,7 +66,7 @@ L1CaloEtScale::~L1CaloEtScale() {
// convert from linear Et to rank
uint16_t L1CaloEtScale::rank(const uint16_t linear) const {

return rank( (linear & linScaleMax) * m_linearLsb);
return rank( (linear & m_linScaleMax) * m_linearLsb);

}

Expand All @@ -60,25 +75,17 @@ uint16_t L1CaloEtScale::rank(const double EtInGeV) const {

uint16_t out = 0;

for (unsigned i=0; i<m_thresholds.size() && i<(unsigned)(rankScaleMax+1); i++) {
for (unsigned i=0; i<m_thresholds.size() && i<(unsigned)(m_rankScaleMax+1); i++) {
if ( EtInGeV >= m_thresholds[i] ) { out = i; }
}

return out & rankScaleMax;
return out & m_rankScaleMax;
}

// convert from rank to Et/GeV
double L1CaloEtScale::et(const uint16_t rank) const {

// return bin centre, except for highest bin
// if (rank < m_thresholds.size()-1) {
// return (m_thresholds[rank+1]+m_thresholds[rank]) / 2;
// }
// else {
// return m_thresholds.back();
// }

// return bin lower edge
// return bin lower edge
return m_thresholds[rank];

}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@

#include "CondFormats/L1TObjects/interface/L1GctJetEtCalibrationFunction.h"

#include "CondFormats/L1TObjects/interface/L1CaloEtScale.h"

#include <iostream>
#include <iomanip>
#include <assert.h>
Expand All @@ -11,6 +9,7 @@
//DEFINE STATICS
const unsigned L1GctJetEtCalibrationFunction::NUMBER_ETA_VALUES = 11;
const unsigned L1GctJetEtCalibrationFunction::N_CENTRAL_ETA_VALUES = 7;
const unsigned L1GctJetEtCalibrationFunction::LIN_SCALE_MAX = 0x3ff;

L1GctJetEtCalibrationFunction::L1GctJetEtCalibrationFunction()
: m_corrFunType(POWER_SERIES_CORRECTION),
Expand Down Expand Up @@ -208,8 +207,8 @@ uint16_t L1GctJetEtCalibrationFunction::calibratedEt(const double correctedEt) c

uint16_t jetEtOut = static_cast<uint16_t>(scaledEt);

if(jetEtOut > L1CaloEtScale::linScaleMax) {
return L1CaloEtScale::linScaleMax;
if(jetEtOut > L1GctJetEtCalibrationFunction::LIN_SCALE_MAX) {
return L1GctJetEtCalibrationFunction::LIN_SCALE_MAX;
} else {
return jetEtOut;
}
Expand Down

0 comments on commit 3484261

Please sign in to comment.