-
Notifications
You must be signed in to change notification settings - Fork 4.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[RecoEgamma/EgammaTools] Updates to EnergyScaleCorrection class for scales and smearings in UL #29526
[RecoEgamma/EgammaTools] Updates to EnergyScaleCorrection class for scales and smearings in UL #29526
Changes from 3 commits
7cf2cbb
755d702
3cb9589
430793d
7b5e5c3
c42e614
5f6a5e0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,17 +2,23 @@ | |
|
||
_correctionFile2016Legacy = "EgammaAnalysis/ElectronTools/data/ScalesSmearings/Legacy2016_07Aug2017_FineEtaR9_v3_ele_unc" | ||
_correctionFile2017Nov17 = "EgammaAnalysis/ElectronTools/data/ScalesSmearings/Run2017_17Nov2017_v1_ele_unc" | ||
_correctionFile2017UL = "EgammaAnalysis/ElectronTools/data/ScalesSmearings/Run2017_24Feb2020_runEtaR9Gain_v2" | ||
|
||
|
||
calibratedEgammaSettings = cms.PSet(minEtToCalibrate = cms.double(5.0), | ||
semiDeterministic = cms.bool(True), | ||
correctionFile = cms.string(_correctionFile2017Nov17), | ||
correctionFile = cms.string(_correctionFile2017UL), | ||
recHitCollectionEB = cms.InputTag('reducedEcalRecHitsEB'), | ||
recHitCollectionEE = cms.InputTag('reducedEcalRecHitsEE'), | ||
produceCalibratedObjs = cms.bool(True) | ||
) | ||
) | ||
from Configuration.Eras.Modifier_run2_miniAOD_80XLegacy_cff import run2_miniAOD_80XLegacy | ||
run2_miniAOD_80XLegacy.toModify(calibratedEgammaSettings,correctionFile = _correctionFile2016Legacy) | ||
|
||
from Configuration.Eras.Modifier_run2_miniAOD_94XFall17_cff import run2_miniAOD_94XFall17 | ||
run2_miniAOD_94XFall17.toModify(calibratedEgammaSettings,correctionFile = _correctionFile2017Nov17) | ||
|
||
|
||
calibratedEgammaPatSettings = calibratedEgammaSettings.clone( | ||
recHitCollectionEB = cms.InputTag('reducedEgamma','reducedEBRecHits'), | ||
recHitCollectionEE = cms.InputTag('reducedEgamma','reducedEERecHits') | ||
|
@@ -60,7 +66,8 @@ | |
calibratedEgammaPatSettings, | ||
epCombConfig = ecalTrkCombinationRegression, | ||
src = cms.InputTag('slimmedElectrons'), | ||
) | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. here and on L6 and L20 the extra empty lines are not clearly needed |
||
) | ||
|
||
calibratedPhotons = cms.EDProducer("CalibratedPhotonProducer", | ||
calibratedEgammaSettings, | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,6 +7,8 @@ | |
#include <cmath> | ||
#include <iomanip> | ||
#include <algorithm> | ||
#include <sstream> | ||
#include <iterator> | ||
|
||
EnergyScaleCorrection::EnergyScaleCorrection(const std::string& correctionFileName, unsigned int genSeed) | ||
: smearingType_(ECALELF) { | ||
|
@@ -148,6 +150,32 @@ void EnergyScaleCorrection::addScale(const std::string& category, | |
std::sort(scales_.begin(), scales_.end(), Sorter<CorrectionCategory, ScaleCorrection>()); | ||
} | ||
|
||
void EnergyScaleCorrection::addScale(int runMin, | ||
int runMax, | ||
double etaMin, | ||
double etaMax, | ||
double r9Min, | ||
double r9Max, | ||
double etMin, | ||
double etMax, | ||
unsigned int gain, | ||
double energyScale, | ||
double energyScaleErrStat, | ||
double energyScaleErrSyst, | ||
double energyScaleErrGain) { | ||
CorrectionCategory cat( | ||
runMin, runMax, etaMin, etaMax, r9Min, r9Max, etMin, etMax, gain); // build the category from the string | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. the comment appears to be not matching the reality: which string ? |
||
|
||
auto result = std::equal_range(scales_.begin(), scales_.end(), cat, Sorter<CorrectionCategory, ScaleCorrection>()); | ||
if (result.first != result.second) { | ||
throw cms::Exception("ConfigError") << "Category already defined! " << cat; | ||
} | ||
|
||
ScaleCorrection corr(energyScale, energyScaleErrStat, energyScaleErrSyst, energyScaleErrGain); | ||
scales_.push_back({cat, corr}); | ||
std::sort(scales_.begin(), scales_.end(), Sorter<CorrectionCategory, ScaleCorrection>()); | ||
} | ||
|
||
void EnergyScaleCorrection::addSmearing(const std::string& category, | ||
int runMin, | ||
int runMax, | ||
|
@@ -189,10 +217,56 @@ void EnergyScaleCorrection::readScalesFromFile(const std::string& filename) { | |
std::string category, region2; | ||
double energyScale, energyScaleErr, energyScaleErrStat, energyScaleErrSyst, energyScaleErrGain; | ||
|
||
for (file >> category; file.good(); file >> category) { | ||
file >> region2 >> runMin >> runMax >> energyScale >> energyScaleErr >> energyScaleErrStat >> energyScaleErrSyst >> | ||
energyScaleErrGain; | ||
addScale(category, runMin, runMax, energyScale, energyScaleErrStat, energyScaleErrSyst, energyScaleErrGain); | ||
double etaMin; ///< Min eta value for the bin | ||
double etaMax; ///< Max eta value for the bin | ||
double r9Min; ///< Min R9 vaule for the bin | ||
double r9Max; ///< Max R9 value for the bin | ||
double etMin; ///< Min Et value for the bin | ||
double etMax; ///< Max Et value for the bin unsigned int gain; ///< 12, 6, 1, 61 (double gain switch) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. it looks like |
||
unsigned int gain; ///< 12, 6, 1, 61 (double gain switch) | ||
|
||
// TO count the #columns in that txt file and decide based on that the version to read | ||
std::string line; | ||
std::stringstream stream; | ||
getline(file, line); | ||
stream.clear(); | ||
stream << line; | ||
|
||
int ncols = std::distance(std::istream_iterator<std::string>(stream), std::istream_iterator<std::string>()); | ||
|
||
file.seekg(0, std::ios::beg); | ||
|
||
if (ncols == 9) { | ||
for (file >> category; file.good(); file >> category) { | ||
file >> region2 >> runMin >> runMax >> energyScale >> energyScaleErr >> energyScaleErrStat >> | ||
energyScaleErrSyst >> energyScaleErrGain; | ||
addScale(category, runMin, runMax, energyScale, energyScaleErrStat, energyScaleErrSyst, energyScaleErrGain); | ||
} | ||
} else { | ||
if (file.peek() == 'r') | ||
file.ignore(1000, 10); | ||
|
||
for (file >> runMin; file.good(); file >> runMin) { | ||
file >> runMax >> etaMin >> etaMax >> r9Min >> r9Max >> etMin >> etMax >> gain >> energyScale >> energyScaleErr; | ||
file.ignore(1000, 10); | ||
energyScaleErrStat = energyScaleErr; | ||
energyScaleErrSyst = 0; | ||
energyScaleErrGain = 0; | ||
|
||
addScale(runMin, | ||
runMax, | ||
etaMin, | ||
etaMax, | ||
r9Min, | ||
r9Max, | ||
etMin, | ||
etMax, | ||
gain, | ||
energyScale, | ||
energyScaleErrStat, | ||
energyScaleErrSyst, | ||
energyScaleErrGain); | ||
} | ||
} | ||
|
||
file.close(); | ||
|
@@ -394,7 +468,7 @@ EnergyScaleCorrection::CorrectionCategory::CorrectionCategory(const std::string& | |
r9Max_ = std::nextafterf(r9Max_, std::numeric_limits<float>::min()); | ||
} | ||
bool EnergyScaleCorrection::CorrectionCategory::inCategory( | ||
const unsigned int runnr, const float et, const float eta, const float r9, const unsigned int gainSeed) const { | ||
const unsigned int runnr, const double et, const double eta, const double r9, const unsigned int gainSeed) const { | ||
return runnr >= runMin_ && runnr <= runMax_ && et >= etMin_ && et <= etMax_ && eta >= etaMin_ && eta <= etaMax_ && | ||
r9 >= r9Min_ && r9 <= r9Max_ && (gain_ == 0 || gainSeed == gain_); | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A general question, why all the changes from floats to doubles?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I saw problems at boundaries of the corrections (e.g. eta=2.5000001 which was at a precision of 10^-7). So I had to update from float to double.