From 1d2c3c103ca953fcf8cb04845d34a1e09f27f2d3 Mon Sep 17 00:00:00 2001 From: Emyr Clement Date: Wed, 3 Dec 2014 20:18:11 +0000 Subject: [PATCH 1/4] WIP Add hadron leg efficiency in electron channel. --- interface/GlobalVariables.h | 2 ++ interface/Python/ConfigFile.h | 5 +++++ interface/RecoObjects/Jet.h | 6 +++++ python/master_2011_53X_cfg.py | 3 +++ python/master_2012_cfg.py | 3 +++ src/Analysers/TTbar_plus_X_analyser.cpp | 4 ++++ src/GlobalsVariables.cpp | 1 + src/Python/ConfigFile.cpp | 30 +++++++++++++++++++++++++ src/RecoObjects/Jet.cpp | 29 ++++++++++++++++++++++-- 9 files changed, 81 insertions(+), 2 deletions(-) diff --git a/interface/GlobalVariables.h b/interface/GlobalVariables.h index b3b982a5..9eb03e62 100644 --- a/interface/GlobalVariables.h +++ b/interface/GlobalVariables.h @@ -16,6 +16,7 @@ #include "TH1D.h" #include "TH2F.h" #include "TH3F.h" +#include "TEfficiency.h" #include @@ -51,6 +52,7 @@ struct Globals { //jets static JetAlgorithm::value jetAlgorithm; + static boost::shared_ptr hadronTriggerLegEfficiencyHistogram; static boost::array, 12> bL7Corrections; static boost::array, 12> lightL7Corrections; static int JESsystematic; diff --git a/interface/Python/ConfigFile.h b/interface/Python/ConfigFile.h index 4c704d1a..8ea01fd4 100644 --- a/interface/Python/ConfigFile.h +++ b/interface/Python/ConfigFile.h @@ -16,6 +16,7 @@ #include "TH1D.h" #include "TH2F.h" #include "TH3F.h" +#include "TEfficiency.h" #include #include @@ -33,6 +34,7 @@ class ConfigFile { std::string MuonScaleFactorsFile() const; std::string bJetResoFile() const; std::string lightJetResoFile() const; + std::string hadronTriggerFile() const; bool useHitFit() const; bool fitterOutputFlag() const; const std::vector& inputFiles() const; @@ -71,6 +73,8 @@ class ConfigFile { std::string muonScaleFactorsFile_; std::string bJetResoFile_; std::string lightJetResoFile_; + bool getHadronTriggerFromFile_; + std::string hadronTriggerFile_; bool useHitFit_; bool fitterOutputFlag_; std::vector inputFiles_; @@ -100,6 +104,7 @@ class ConfigFile { boost::shared_ptr getMuonIdIsoScaleFactorsHistogram(std::string muonScaleFactorsFile); boost::shared_ptr getMuonTriggerScaleFactorsHistogram(std::string muonScaleFactorsFile); boost::array, 12> getL7Correction(std::string correctionFile); + boost::shared_ptr getHadronTriggerLegHistogram(std::string hadronTriggerFile); }; } /* namespace BAT */ diff --git a/interface/RecoObjects/Jet.h b/interface/RecoObjects/Jet.h index bb812395..dffaee5f 100644 --- a/interface/RecoObjects/Jet.h +++ b/interface/RecoObjects/Jet.h @@ -9,6 +9,7 @@ #define JET_H_ #include "Particle.h" #include "TF1.h" +#include "TEfficiency.h" #include #include #include @@ -135,6 +136,9 @@ class Jet: public Particle { bool FirstDataLoosePFJetID() const; bool FirstDataLooseCaloJetID() const; + + double getEfficiencyCorrection( int muon_scale_factor_systematic, int run_number) const; + private: JetAlgorithm::value usedAlgorithm; double electromagneticFraction; @@ -169,6 +173,8 @@ class Jet: public Particle { ParticlePointer unsmearedJet; ParticlePointer smearedJet; + boost::shared_ptr hadronTriggerLegEfficiencyHistogram; + }; typedef boost::shared_ptr JetPointer; diff --git a/python/master_2011_53X_cfg.py b/python/master_2011_53X_cfg.py index f2dc9041..daf1b7fc 100644 --- a/python/master_2011_53X_cfg.py +++ b/python/master_2011_53X_cfg.py @@ -85,6 +85,7 @@ 'JetSmearingSystematic':0, 'PUFile':'Data_PUDist_2011Full_central_68000mb_June2014.root', 'MuonScaleFactors':'MuonEfficiencies_SF_2011_53X_DataMC.root', + 'hadronTriggerFile':'hadronLegEfficiencies_electron_.root', 'BTagSystematic':0, 'LightTagSystematic':0, 'custom_file_suffix':'', @@ -160,6 +161,8 @@ def getAnalysisSettings(analysisMode): PUFile = toolsFolder + "data/" + settings['PUFile'] getMuonScaleFactorsFromFile = True MuonScaleFactorsFile = toolsFolder + "data/" + settings['MuonScaleFactors'] +getHadronTriggerFromFile = True +hadronTriggerFile = toolsFolder + "data/" + settings['hadronTriggerFile'] ElectronScaleFactorSystematic = settings['ElectronScaleFactorSystematic'] MuonScaleFactorSystematic = settings['MuonScaleFactorSystematic'] #JES Systematic, the +/- number of uncertainties to vary the jets with diff --git a/python/master_2012_cfg.py b/python/master_2012_cfg.py index 8d8c731f..87a48801 100644 --- a/python/master_2012_cfg.py +++ b/python/master_2012_cfg.py @@ -93,6 +93,7 @@ 'JetSmearingSystematic':0, 'PUFile':'PileUp_2012_69300_truth_finebin.root', 'MuonScaleFactors':'nofile.root', + 'PUFile':'noFile.root', 'BTagSystematic':0, 'LightTagSystematic':0, 'custom_file_suffix':'', @@ -168,6 +169,8 @@ def getAnalysisSettings(analysisMode): PUFile = toolsFolder + "data/" + settings['PUFile'] getMuonScaleFactorsFromFile = False MuonScaleFactorsFile = toolsFolder + "data/" + settings['MuonScaleFactors'] +getHadronTriggerFromFile = True +hadronTriggerFile = toolsFolder + "data/" + settings['hadronTriggerFile'] ElectronScaleFactorSystematic = settings['ElectronScaleFactorSystematic'] MuonScaleFactorSystematic = settings['MuonScaleFactorSystematic'] #JES Systematic, the +/- number of uncertainties to vary the jets with diff --git a/src/Analysers/TTbar_plus_X_analyser.cpp b/src/Analysers/TTbar_plus_X_analyser.cpp index 7870552d..bcb4f141 100644 --- a/src/Analysers/TTbar_plus_X_analyser.cpp +++ b/src/Analysers/TTbar_plus_X_analyser.cpp @@ -33,6 +33,7 @@ void TTbar_plus_X_analyser::ePlusJetsSignalAnalysis(const EventPtr event) { if (topEplusJetsRefSelection_->passesFullSelectionExceptLastTwoSteps(event)) { const JetCollection jets(topEplusJetsRefSelection_->cleanedJets(event)); const JetCollection bJets(topEplusJetsRefSelection_->cleanedBJets(event)); + const JetPointer fourthJet = jets[3]; unsigned int numberOfBjets(bJets.size()); vector bjetWeights; if (event->isRealData()) { @@ -51,6 +52,9 @@ void TTbar_plus_X_analyser::ePlusJetsSignalAnalysis(const EventPtr event) { const LeptonPointer signalLepton = topEplusJetsRefSelection_->signalLepton(event); const ElectronPointer signalElectron(boost::static_pointer_cast(signalLepton)); + + double hadronTriggerLegCorrection = event->isRealData() ? 1. : fourthJet->getEfficiencyCorrection( Globals::ElectronScaleFactorSystematic, event->runnumber() ); + double efficiencyCorrection = event->isRealData() ? 1. : signalElectron->getEfficiencyCorrection(false, Globals::ElectronScaleFactorSystematic, event->runnumber()); for (unsigned int weightIndex = 0; weightIndex < bjetWeights.size(); ++weightIndex) { diff --git a/src/GlobalsVariables.cpp b/src/GlobalsVariables.cpp index 43be7170..49f98cca 100644 --- a/src/GlobalsVariables.cpp +++ b/src/GlobalsVariables.cpp @@ -40,6 +40,7 @@ boost::shared_ptr Globals::muonTriggerScaleFactorsHistogram = boost::share //jets JetAlgorithm::value Globals::jetAlgorithm = JetAlgorithm::PF2PAT; +boost::shared_ptr Globals::hadronTriggerLegEfficiencyHistogram = boost::shared_ptr(new TEfficiency()); int Globals::JESsystematic = 0; int Globals::BJetSystematic = 0; int Globals::LightJetSystematic = 0; diff --git a/src/Python/ConfigFile.cpp b/src/Python/ConfigFile.cpp index 7e728b5b..64c74c8b 100644 --- a/src/Python/ConfigFile.cpp +++ b/src/Python/ConfigFile.cpp @@ -33,6 +33,8 @@ ConfigFile::ConfigFile(int argc, char **argv) : muonScaleFactorsFile_(PythonParser::getAttributeFromPyObject(config, "MuonScaleFactorsFile")), // bJetResoFile_(PythonParser::getAttributeFromPyObject(config, "bJetResoFile")), // lightJetResoFile_(PythonParser::getAttributeFromPyObject(config, "lightJetResoFile")), // + getHadronTriggerFromFile_(PythonParser::getAttributeFromPyObject(config, "getHadronTriggerFromFile")), // + hadronTriggerFile_(PythonParser::getAttributeFromPyObject(config, "hadronTriggerFile")), // useHitFit_(PythonParser::getAttributeFromPyObject(config, "useHitFit")), // fitterOutputFlag_(PythonParser::getAttributeFromPyObject(config, "produceFitterASCIIoutput")), // inputFiles_(PythonParser::getVectorFromPythonObject(config, "inputFiles")), // @@ -100,6 +102,7 @@ boost::program_options::variables_map ConfigFile::getParameters(int argc, char** desc.add_options()("MuonScaleFactorsFile", value(), "set input file for muon scale factors"); desc.add_options()("bJetResoFile", value(), "set input root file for b-jet L7 resolutions"); desc.add_options()("lightJetResoFile", value(), "set input root file for light jet L7 resolutions"); + desc.add_options()("getHadronTriggerFromFile", value(), "state whether we are getting the electron trigger hadron leg efficiencies from a file or not"); desc.add_options()("fitter", value(), "turn on the fitter (HitFit)"); desc.add_options()("fitterASCIIoutput", value(), "produce full kinematic fit output in ASCII format"); desc.add_options()("TQAFPath", value(), @@ -205,6 +208,13 @@ string ConfigFile::MuonScaleFactorsFile() const { return muonScaleFactorsFile_; } +string ConfigFile::hadronTriggerFile() const { + if (programOptions.count("hadronTriggerFile")) + return programOptions["hadronTriggerFile"].as(); + else + return hadronTriggerFile_; +} + string ConfigFile::datasetInfoFile() const { if (programOptions.count("datasetInfoFile")) return programOptions["datasetInfoFile"].as(); @@ -417,6 +427,11 @@ void ConfigFile::loadIntoMemory() { std::cout << "ConfigFile.cpp: Globals::ElectronScaleFactorSystematic = " << Globals::ElectronScaleFactorSystematic << std::endl; std::cout << "ConfigFile.cpp: Globals::MuonScaleFactorSystematic = " << Globals::MuonScaleFactorSystematic << std::endl; + if ( Globals::energyInTeV == 7 && getHadronTriggerFromFile_ ) { + std::cout << "Getting electron trigger hadron leg efficiencies from file " << hadronTriggerFile() << "." << std::endl; + Globals::hadronTriggerLegEfficiencyHistogram = getHadronTriggerLegHistogram(hadronTriggerFile()); + } + //JES systematic Globals::JESsystematic = jesSystematic(); @@ -491,6 +506,21 @@ boost::shared_ptr ConfigFile::getMuonTriggerScaleFactorsHistogram(std::str return triggerHistogram; } +boost::shared_ptr ConfigFile::getHadronTriggerLegHistogram(std::string hadronTriggerFile) { + using namespace std; + + if (!boost::filesystem::exists(hadronTriggerFile)) { + cerr << "ConfigFile::getHadronTriggerLegHistogram(" << hadronTriggerFile << "): could not find file" << endl; + throw "Could not find hadron leg efficiency histogram file in " + hadronTriggerFile; + } + + boost::scoped_ptr file(TFile::Open(hadronTriggerFile.c_str())); + boost::shared_ptr hadronHistogram((TEfficiency*) file->Get("data")->Clone()); + file->Close(); + + return hadronHistogram; +} + unsigned int ConfigFile::nTupleVersion() const { return nTupleVersion_; } diff --git a/src/RecoObjects/Jet.cpp b/src/RecoObjects/Jet.cpp index 0989b9cb..0da198de 100644 --- a/src/RecoObjects/Jet.cpp +++ b/src/RecoObjects/Jet.cpp @@ -52,7 +52,9 @@ Jet::Jet() : // matchedGeneratedJet(), // unsmearedJet(), // - smearedJet() // + smearedJet(), // + + hadronTriggerLegEfficiencyHistogram( Globals::hadronTriggerLegEfficiencyHistogram ) // { for (unsigned int btag = 0; btag < btag_discriminators.size(); ++btag) { btag_discriminators[btag] = -9999; @@ -100,7 +102,9 @@ Jet::Jet(double energy, double px, double py, double pz) : // matchedGeneratedJet(), // unsmearedJet(), // - smearedJet() // + smearedJet(), // + + hadronTriggerLegEfficiencyHistogram( Globals::hadronTriggerLegEfficiencyHistogram ) // { for (unsigned int btag = 0; btag < btag_discriminators.size(); ++btag) { btag_discriminators[btag] = -9999; @@ -525,5 +529,26 @@ double Jet::getBTagDiscriminator(BtagAlgorithm::value type) const { return btag_discriminators.at((unsigned int) type); } +double Jet::getEfficiencyCorrection( int muon_scale_factor_systematic, int run_number) const { + + if (Globals::energyInTeV == 7) { + double correction(1.); + double jetPt = pt(); + + if ( jetPt >= 100 ) return 1.0; + + unsigned int binNumber = hadronTriggerLegEfficiencyHistogram->FindFixBin( jetPt ); + correction = hadronTriggerLegEfficiencyHistogram->GetEfficiency( binNumber ); + + std::cout << "Correction for pt : " << jetPt << " " << correction << std::endl; + + return correction; + } + else { + return 1.; + } +} + } + From 41f283eb255c3fc4be44d3204d1684a37eaf6b21 Mon Sep 17 00:00:00 2001 From: Emyr Clement Date: Thu, 4 Dec 2014 11:55:33 +0000 Subject: [PATCH 2/4] Take account of different efficiencies in different run ranges. --- interface/GlobalVariables.h | 4 +++- interface/Python/ConfigFile.h | 2 +- interface/RecoObjects/Jet.h | 5 +++-- python/master_2011_53X_cfg.py | 2 +- src/Analysers/TTbar_plus_X_analyser.cpp | 14 ++++++++++---- src/GlobalsVariables.cpp | 4 +++- src/Python/ConfigFile.cpp | 10 +++++----- src/RecoObjects/Jet.cpp | 21 ++++++++++++++++----- 8 files changed, 42 insertions(+), 20 deletions(-) diff --git a/interface/GlobalVariables.h b/interface/GlobalVariables.h index 9eb03e62..a838f608 100644 --- a/interface/GlobalVariables.h +++ b/interface/GlobalVariables.h @@ -52,7 +52,9 @@ struct Globals { //jets static JetAlgorithm::value jetAlgorithm; - static boost::shared_ptr hadronTriggerLegEfficiencyHistogram; + static boost::shared_ptr hadronTriggerLegEfficiencyHistogram_nonIsoJets; + static boost::shared_ptr hadronTriggerLegEfficiencyHistogram_isoJets; + static boost::shared_ptr hadronTriggerLegEfficiencyHistogram_isoPFJets; static boost::array, 12> bL7Corrections; static boost::array, 12> lightL7Corrections; static int JESsystematic; diff --git a/interface/Python/ConfigFile.h b/interface/Python/ConfigFile.h index 8ea01fd4..06dd0864 100644 --- a/interface/Python/ConfigFile.h +++ b/interface/Python/ConfigFile.h @@ -104,7 +104,7 @@ class ConfigFile { boost::shared_ptr getMuonIdIsoScaleFactorsHistogram(std::string muonScaleFactorsFile); boost::shared_ptr getMuonTriggerScaleFactorsHistogram(std::string muonScaleFactorsFile); boost::array, 12> getL7Correction(std::string correctionFile); - boost::shared_ptr getHadronTriggerLegHistogram(std::string hadronTriggerFile); + void getHadronTriggerLegHistogram(std::string hadronTriggerFile); }; } /* namespace BAT */ diff --git a/interface/RecoObjects/Jet.h b/interface/RecoObjects/Jet.h index dffaee5f..767d7e6a 100644 --- a/interface/RecoObjects/Jet.h +++ b/interface/RecoObjects/Jet.h @@ -173,8 +173,9 @@ class Jet: public Particle { ParticlePointer unsmearedJet; ParticlePointer smearedJet; - boost::shared_ptr hadronTriggerLegEfficiencyHistogram; - + boost::shared_ptr hadronTriggerLegEfficiencyHistogram_nonIsoJets; + boost::shared_ptr hadronTriggerLegEfficiencyHistogram_isoJets; + boost::shared_ptr hadronTriggerLegEfficiencyHistogram_isoPFJets; }; typedef boost::shared_ptr JetPointer; diff --git a/python/master_2011_53X_cfg.py b/python/master_2011_53X_cfg.py index daf1b7fc..ec99a780 100644 --- a/python/master_2011_53X_cfg.py +++ b/python/master_2011_53X_cfg.py @@ -85,7 +85,7 @@ 'JetSmearingSystematic':0, 'PUFile':'Data_PUDist_2011Full_central_68000mb_June2014.root', 'MuonScaleFactors':'MuonEfficiencies_SF_2011_53X_DataMC.root', - 'hadronTriggerFile':'hadronLegEfficiencies_electron_.root', + 'hadronTriggerFile':'hadronLegEfficiencies_electron.root', 'BTagSystematic':0, 'LightTagSystematic':0, 'custom_file_suffix':'', diff --git a/src/Analysers/TTbar_plus_X_analyser.cpp b/src/Analysers/TTbar_plus_X_analyser.cpp index bcb4f141..143e6da3 100644 --- a/src/Analysers/TTbar_plus_X_analyser.cpp +++ b/src/Analysers/TTbar_plus_X_analyser.cpp @@ -55,7 +55,7 @@ void TTbar_plus_X_analyser::ePlusJetsSignalAnalysis(const EventPtr event) { double hadronTriggerLegCorrection = event->isRealData() ? 1. : fourthJet->getEfficiencyCorrection( Globals::ElectronScaleFactorSystematic, event->runnumber() ); - double efficiencyCorrection = event->isRealData() ? 1. : signalElectron->getEfficiencyCorrection(false, Globals::ElectronScaleFactorSystematic, event->runnumber()); + double efficiencyCorrection = event->isRealData() ? 1. : signalElectron->getEfficiencyCorrection(false, Globals::ElectronScaleFactorSystematic, event->runnumber()) * hadronTriggerLegCorrection; for (unsigned int weightIndex = 0; weightIndex < bjetWeights.size(); ++weightIndex) { double bjetWeight = bjetWeights.at(weightIndex); @@ -150,6 +150,7 @@ void TTbar_plus_X_analyser::ePlusJetsQcdAnalysis(const EventPtr event) { TTbarEPlusJetsReferenceSelection::AtLeastFourGoodJets)) { const JetCollection jets(qcdNonIsoElectronSelection_->cleanedJets(event)); const JetCollection bJets(qcdNonIsoElectronSelection_->cleanedBJets(event)); + const JetPointer fourthJet = jets[3]; unsigned int numberOfBjets(bJets.size()); vector bjetWeights; if (event->isRealData()) { @@ -167,7 +168,8 @@ void TTbar_plus_X_analyser::ePlusJetsQcdAnalysis(const EventPtr event) { unsigned int prescale(qcdNonIsoElectronSelection_->prescale(event)); const LeptonPointer signalLepton = qcdNonIsoElectronSelection_->signalLepton(event); const ElectronPointer signalElectron(boost::static_pointer_cast(signalLepton)); - double efficiencyCorrection = event->isRealData() ? 1. : signalElectron->getEfficiencyCorrection(false, Globals::ElectronScaleFactorSystematic, event->runnumber()); // should really be qcd=true, not false, and should have a loop in Electron.cpp to get scale factors for QCD selection, but it doesn't exist (yet) + double hadronTriggerLegCorrection = event->isRealData() ? 1. : fourthJet->getEfficiencyCorrection( Globals::ElectronScaleFactorSystematic, event->runnumber() ); + double efficiencyCorrection = event->isRealData() ? 1. : signalElectron->getEfficiencyCorrection(false, Globals::ElectronScaleFactorSystematic, event->runnumber()) * hadronTriggerLegCorrection; qcdNonIsoElectronAnalyser_->setPrescale(prescale); metAnalyserqcdNonIsoElectronSelection_->setPrescale(prescale); @@ -241,6 +243,7 @@ void TTbar_plus_X_analyser::ePlusJetsQcdAnalysis(const EventPtr event) { TTbarEPlusJetsReferenceSelection::AtLeastFourGoodJets)) { const JetCollection jets(qcdConversionSelection_->cleanedJets(event)); const JetCollection bJets(qcdConversionSelection_->cleanedBJets(event)); + const JetPointer fourthJet = jets[3]; unsigned int numberOfBjets(bJets.size()); vector bjetWeights; if (event->isRealData()) { @@ -257,7 +260,8 @@ void TTbar_plus_X_analyser::ePlusJetsQcdAnalysis(const EventPtr event) { unsigned int prescale(qcdConversionSelection_->prescale(event)); const LeptonPointer signalLepton = qcdConversionSelection_->signalLepton(event); const ElectronPointer signalElectron(boost::static_pointer_cast(signalLepton)); - double efficiencyCorrection = event->isRealData() ? 1. : signalElectron->getEfficiencyCorrection(false, Globals::ElectronScaleFactorSystematic, event->runnumber()); + double hadronTriggerLegCorrection = event->isRealData() ? 1. : fourthJet->getEfficiencyCorrection( Globals::ElectronScaleFactorSystematic, event->runnumber() ); + double efficiencyCorrection = event->isRealData() ? 1. : signalElectron->getEfficiencyCorrection(false, Globals::ElectronScaleFactorSystematic, event->runnumber()) * hadronTriggerLegCorrection; qcdConversionsElectronAnalyser_->setPrescale(prescale); metAnalyserqcdConversionSelection_->setPrescale(prescale); @@ -347,7 +351,9 @@ void TTbar_plus_X_analyser::ePlusJetsQcdAnalysis(const EventPtr event) { unsigned int prescale(qcdPFRelIsoEPlusJetsSelection_->prescale(event)); const LeptonPointer signalLepton = qcdPFRelIsoEPlusJetsSelection_->signalLepton(event); const ElectronPointer signalElectron(boost::static_pointer_cast(signalLepton)); - double efficiencyCorrection = event->isRealData() ? 1. : signalElectron->getEfficiencyCorrection(false, Globals::ElectronScaleFactorSystematic, event->runnumber()); + const JetPointer fourthJet = jets[3]; + double hadronTriggerLegCorrection = event->isRealData() ? 1. : fourthJet->getEfficiencyCorrection( Globals::ElectronScaleFactorSystematic, event->runnumber() ); + double efficiencyCorrection = event->isRealData() ? 1. : signalElectron->getEfficiencyCorrection(false, Globals::ElectronScaleFactorSystematic, event->runnumber()) * hadronTriggerLegCorrection; qcdEPlusjetsPFRelIsoElectronAnalyser_->setPrescale(prescale); for (unsigned int weightIndex = 0; weightIndex < bjetWeights.size(); ++weightIndex) { diff --git a/src/GlobalsVariables.cpp b/src/GlobalsVariables.cpp index 49f98cca..31b3f75b 100644 --- a/src/GlobalsVariables.cpp +++ b/src/GlobalsVariables.cpp @@ -40,7 +40,9 @@ boost::shared_ptr Globals::muonTriggerScaleFactorsHistogram = boost::share //jets JetAlgorithm::value Globals::jetAlgorithm = JetAlgorithm::PF2PAT; -boost::shared_ptr Globals::hadronTriggerLegEfficiencyHistogram = boost::shared_ptr(new TEfficiency()); +boost::shared_ptr Globals::hadronTriggerLegEfficiencyHistogram_nonIsoJets = boost::shared_ptr(new TEfficiency()); +boost::shared_ptr Globals::hadronTriggerLegEfficiencyHistogram_isoJets = boost::shared_ptr(new TEfficiency()); +boost::shared_ptr Globals::hadronTriggerLegEfficiencyHistogram_isoPFJets = boost::shared_ptr(new TEfficiency()); int Globals::JESsystematic = 0; int Globals::BJetSystematic = 0; int Globals::LightJetSystematic = 0; diff --git a/src/Python/ConfigFile.cpp b/src/Python/ConfigFile.cpp index 64c74c8b..8fbb9d03 100644 --- a/src/Python/ConfigFile.cpp +++ b/src/Python/ConfigFile.cpp @@ -429,7 +429,7 @@ void ConfigFile::loadIntoMemory() { if ( Globals::energyInTeV == 7 && getHadronTriggerFromFile_ ) { std::cout << "Getting electron trigger hadron leg efficiencies from file " << hadronTriggerFile() << "." << std::endl; - Globals::hadronTriggerLegEfficiencyHistogram = getHadronTriggerLegHistogram(hadronTriggerFile()); + getHadronTriggerLegHistogram(hadronTriggerFile()); } //JES systematic @@ -506,7 +506,7 @@ boost::shared_ptr ConfigFile::getMuonTriggerScaleFactorsHistogram(std::str return triggerHistogram; } -boost::shared_ptr ConfigFile::getHadronTriggerLegHistogram(std::string hadronTriggerFile) { +void ConfigFile::getHadronTriggerLegHistogram(std::string hadronTriggerFile) { using namespace std; if (!boost::filesystem::exists(hadronTriggerFile)) { @@ -515,10 +515,10 @@ boost::shared_ptr ConfigFile::getHadronTriggerLegHistogram(std::str } boost::scoped_ptr file(TFile::Open(hadronTriggerFile.c_str())); - boost::shared_ptr hadronHistogram((TEfficiency*) file->Get("data")->Clone()); + Globals::hadronTriggerLegEfficiencyHistogram_nonIsoJets = (boost::shared_ptr) ((TEfficiency*) file->Get("data_1")->Clone("data_1")); + Globals::hadronTriggerLegEfficiencyHistogram_isoJets = (boost::shared_ptr) ((TEfficiency*) file->Get("data_2")->Clone("data_2")); + Globals::hadronTriggerLegEfficiencyHistogram_isoPFJets = (boost::shared_ptr) ((TEfficiency*) file->Get("data_3")->Clone("data_3")); file->Close(); - - return hadronHistogram; } unsigned int ConfigFile::nTupleVersion() const { diff --git a/src/RecoObjects/Jet.cpp b/src/RecoObjects/Jet.cpp index 0da198de..f2e828b3 100644 --- a/src/RecoObjects/Jet.cpp +++ b/src/RecoObjects/Jet.cpp @@ -54,7 +54,10 @@ Jet::Jet() : unsmearedJet(), // smearedJet(), // - hadronTriggerLegEfficiencyHistogram( Globals::hadronTriggerLegEfficiencyHistogram ) // + hadronTriggerLegEfficiencyHistogram_nonIsoJets( Globals::hadronTriggerLegEfficiencyHistogram_nonIsoJets ), // + hadronTriggerLegEfficiencyHistogram_isoJets( Globals::hadronTriggerLegEfficiencyHistogram_isoJets ), // + hadronTriggerLegEfficiencyHistogram_isoPFJets( Globals::hadronTriggerLegEfficiencyHistogram_isoPFJets ) // + { for (unsigned int btag = 0; btag < btag_discriminators.size(); ++btag) { btag_discriminators[btag] = -9999; @@ -104,7 +107,9 @@ Jet::Jet(double energy, double px, double py, double pz) : unsmearedJet(), // smearedJet(), // - hadronTriggerLegEfficiencyHistogram( Globals::hadronTriggerLegEfficiencyHistogram ) // + hadronTriggerLegEfficiencyHistogram_nonIsoJets( Globals::hadronTriggerLegEfficiencyHistogram_nonIsoJets ), // + hadronTriggerLegEfficiencyHistogram_isoJets( Globals::hadronTriggerLegEfficiencyHistogram_isoJets ), // + hadronTriggerLegEfficiencyHistogram_isoPFJets( Globals::hadronTriggerLegEfficiencyHistogram_isoPFJets ) // { for (unsigned int btag = 0; btag < btag_discriminators.size(); ++btag) { btag_discriminators[btag] = -9999; @@ -537,10 +542,16 @@ double Jet::getEfficiencyCorrection( int muon_scale_factor_systematic, int run_n if ( jetPt >= 100 ) return 1.0; - unsigned int binNumber = hadronTriggerLegEfficiencyHistogram->FindFixBin( jetPt ); - correction = hadronTriggerLegEfficiencyHistogram->GetEfficiency( binNumber ); + unsigned int binNumber = hadronTriggerLegEfficiencyHistogram_nonIsoJets->FindFixBin( jetPt ); + + double correction_nonIsoJets = hadronTriggerLegEfficiencyHistogram_nonIsoJets->GetEfficiency( binNumber ); + double lumi_nonIsoJets = Globals::luminosity * 0.076; + double correction_isoJets = hadronTriggerLegEfficiencyHistogram_isoJets->GetEfficiency( binNumber ); + double lumi_isoJets = Globals::luminosity * 0.764; + double correction_isoPFJets = hadronTriggerLegEfficiencyHistogram_isoPFJets->GetEfficiency( binNumber ); + double lumi_isoPFJets = Globals::luminosity * 0.16; - std::cout << "Correction for pt : " << jetPt << " " << correction << std::endl; + correction = ((correction_nonIsoJets * lumi_nonIsoJets) + (correction_isoJets * lumi_isoJets) + (correction_isoPFJets * lumi_isoPFJets)) / (Globals::luminosity); return correction; } From fbfd1de3a4ce5ba8c68f53410cb39d56f1720e94 Mon Sep 17 00:00:00 2001 From: Emyr Clement Date: Thu, 4 Dec 2014 12:24:13 +0000 Subject: [PATCH 3/4] Include systematic variation of hadron leg efficiency. --- interface/RecoObjects/Jet.h | 2 +- src/Analysers/TTbar_plus_X_analyser.cpp | 8 ++++---- src/RecoObjects/Jet.cpp | 26 +++++++++++++++++++++---- 3 files changed, 27 insertions(+), 9 deletions(-) diff --git a/interface/RecoObjects/Jet.h b/interface/RecoObjects/Jet.h index 767d7e6a..15a49620 100644 --- a/interface/RecoObjects/Jet.h +++ b/interface/RecoObjects/Jet.h @@ -137,7 +137,7 @@ class Jet: public Particle { bool FirstDataLoosePFJetID() const; bool FirstDataLooseCaloJetID() const; - double getEfficiencyCorrection( int muon_scale_factor_systematic, int run_number) const; + double getEfficiencyCorrection( int scale_factor_systematic ) const; private: JetAlgorithm::value usedAlgorithm; diff --git a/src/Analysers/TTbar_plus_X_analyser.cpp b/src/Analysers/TTbar_plus_X_analyser.cpp index 143e6da3..65d392ce 100644 --- a/src/Analysers/TTbar_plus_X_analyser.cpp +++ b/src/Analysers/TTbar_plus_X_analyser.cpp @@ -53,7 +53,7 @@ void TTbar_plus_X_analyser::ePlusJetsSignalAnalysis(const EventPtr event) { const LeptonPointer signalLepton = topEplusJetsRefSelection_->signalLepton(event); const ElectronPointer signalElectron(boost::static_pointer_cast(signalLepton)); - double hadronTriggerLegCorrection = event->isRealData() ? 1. : fourthJet->getEfficiencyCorrection( Globals::ElectronScaleFactorSystematic, event->runnumber() ); + double hadronTriggerLegCorrection = event->isRealData() ? 1. : fourthJet->getEfficiencyCorrection( Globals::ElectronScaleFactorSystematic ); double efficiencyCorrection = event->isRealData() ? 1. : signalElectron->getEfficiencyCorrection(false, Globals::ElectronScaleFactorSystematic, event->runnumber()) * hadronTriggerLegCorrection; @@ -168,7 +168,7 @@ void TTbar_plus_X_analyser::ePlusJetsQcdAnalysis(const EventPtr event) { unsigned int prescale(qcdNonIsoElectronSelection_->prescale(event)); const LeptonPointer signalLepton = qcdNonIsoElectronSelection_->signalLepton(event); const ElectronPointer signalElectron(boost::static_pointer_cast(signalLepton)); - double hadronTriggerLegCorrection = event->isRealData() ? 1. : fourthJet->getEfficiencyCorrection( Globals::ElectronScaleFactorSystematic, event->runnumber() ); + double hadronTriggerLegCorrection = event->isRealData() ? 1. : fourthJet->getEfficiencyCorrection( Globals::ElectronScaleFactorSystematic ); double efficiencyCorrection = event->isRealData() ? 1. : signalElectron->getEfficiencyCorrection(false, Globals::ElectronScaleFactorSystematic, event->runnumber()) * hadronTriggerLegCorrection; qcdNonIsoElectronAnalyser_->setPrescale(prescale); @@ -260,7 +260,7 @@ void TTbar_plus_X_analyser::ePlusJetsQcdAnalysis(const EventPtr event) { unsigned int prescale(qcdConversionSelection_->prescale(event)); const LeptonPointer signalLepton = qcdConversionSelection_->signalLepton(event); const ElectronPointer signalElectron(boost::static_pointer_cast(signalLepton)); - double hadronTriggerLegCorrection = event->isRealData() ? 1. : fourthJet->getEfficiencyCorrection( Globals::ElectronScaleFactorSystematic, event->runnumber() ); + double hadronTriggerLegCorrection = event->isRealData() ? 1. : fourthJet->getEfficiencyCorrection( Globals::ElectronScaleFactorSystematic ); double efficiencyCorrection = event->isRealData() ? 1. : signalElectron->getEfficiencyCorrection(false, Globals::ElectronScaleFactorSystematic, event->runnumber()) * hadronTriggerLegCorrection; qcdConversionsElectronAnalyser_->setPrescale(prescale); @@ -352,7 +352,7 @@ void TTbar_plus_X_analyser::ePlusJetsQcdAnalysis(const EventPtr event) { const LeptonPointer signalLepton = qcdPFRelIsoEPlusJetsSelection_->signalLepton(event); const ElectronPointer signalElectron(boost::static_pointer_cast(signalLepton)); const JetPointer fourthJet = jets[3]; - double hadronTriggerLegCorrection = event->isRealData() ? 1. : fourthJet->getEfficiencyCorrection( Globals::ElectronScaleFactorSystematic, event->runnumber() ); + double hadronTriggerLegCorrection = event->isRealData() ? 1. : fourthJet->getEfficiencyCorrection( Globals::ElectronScaleFactorSystematic ); double efficiencyCorrection = event->isRealData() ? 1. : signalElectron->getEfficiencyCorrection(false, Globals::ElectronScaleFactorSystematic, event->runnumber()) * hadronTriggerLegCorrection; qcdEPlusjetsPFRelIsoElectronAnalyser_->setPrescale(prescale); diff --git a/src/RecoObjects/Jet.cpp b/src/RecoObjects/Jet.cpp index f2e828b3..f8c842cf 100644 --- a/src/RecoObjects/Jet.cpp +++ b/src/RecoObjects/Jet.cpp @@ -534,7 +534,7 @@ double Jet::getBTagDiscriminator(BtagAlgorithm::value type) const { return btag_discriminators.at((unsigned int) type); } -double Jet::getEfficiencyCorrection( int muon_scale_factor_systematic, int run_number) const { +double Jet::getEfficiencyCorrection( int scale_factor_systematic ) const { if (Globals::energyInTeV == 7) { double correction(1.); @@ -544,13 +544,31 @@ double Jet::getEfficiencyCorrection( int muon_scale_factor_systematic, int run_n unsigned int binNumber = hadronTriggerLegEfficiencyHistogram_nonIsoJets->FindFixBin( jetPt ); - double correction_nonIsoJets = hadronTriggerLegEfficiencyHistogram_nonIsoJets->GetEfficiency( binNumber ); + double correction_nonIsoJets = 1.; double lumi_nonIsoJets = Globals::luminosity * 0.076; - double correction_isoJets = hadronTriggerLegEfficiencyHistogram_isoJets->GetEfficiency( binNumber ); + double correction_isoJets = 1.; double lumi_isoJets = Globals::luminosity * 0.764; - double correction_isoPFJets = hadronTriggerLegEfficiencyHistogram_isoPFJets->GetEfficiency( binNumber ); + double correction_isoPFJets = 1.; double lumi_isoPFJets = Globals::luminosity * 0.16; + + switch (scale_factor_systematic) { + case -1: + correction_nonIsoJets = hadronTriggerLegEfficiencyHistogram_nonIsoJets->GetEfficiency( binNumber ) - hadronTriggerLegEfficiencyHistogram_nonIsoJets->GetEfficiencyErrorLow( binNumber ); + correction_isoJets = hadronTriggerLegEfficiencyHistogram_isoJets->GetEfficiency( binNumber ) - hadronTriggerLegEfficiencyHistogram_isoJets->GetEfficiencyErrorLow( binNumber ); + correction_isoPFJets = hadronTriggerLegEfficiencyHistogram_isoPFJets->GetEfficiency( binNumber ) - hadronTriggerLegEfficiencyHistogram_isoPFJets->GetEfficiencyErrorLow( binNumber ); + break; + case 1: + correction_nonIsoJets = hadronTriggerLegEfficiencyHistogram_nonIsoJets->GetEfficiency( binNumber ) + hadronTriggerLegEfficiencyHistogram_nonIsoJets->GetEfficiencyErrorUp( binNumber ); + correction_isoJets = hadronTriggerLegEfficiencyHistogram_isoJets->GetEfficiency( binNumber ) + hadronTriggerLegEfficiencyHistogram_isoJets->GetEfficiencyErrorUp( binNumber ); + correction_isoPFJets = hadronTriggerLegEfficiencyHistogram_isoPFJets->GetEfficiency( binNumber ) + hadronTriggerLegEfficiencyHistogram_isoPFJets->GetEfficiencyErrorUp( binNumber ); + break; + default: + correction_nonIsoJets = hadronTriggerLegEfficiencyHistogram_nonIsoJets->GetEfficiency( binNumber ); + correction_isoJets = hadronTriggerLegEfficiencyHistogram_isoJets->GetEfficiency( binNumber ); + correction_isoPFJets = hadronTriggerLegEfficiencyHistogram_isoPFJets->GetEfficiency( binNumber ); + } + correction = ((correction_nonIsoJets * lumi_nonIsoJets) + (correction_isoJets * lumi_isoJets) + (correction_isoPFJets * lumi_isoPFJets)) / (Globals::luminosity); return correction; From 4b83a74e63298c28ebcca3c0f7a71fab9c3934f6 Mon Sep 17 00:00:00 2001 From: Emyr Clement Date: Thu, 4 Dec 2014 16:12:18 +0000 Subject: [PATCH 4/4] Store histograms as global only, rather than per jet. --- interface/RecoObjects/Jet.h | 4 ---- src/RecoObjects/Jet.cpp | 33 ++++++++++++--------------------- 2 files changed, 12 insertions(+), 25 deletions(-) diff --git a/interface/RecoObjects/Jet.h b/interface/RecoObjects/Jet.h index 15a49620..86ccd13e 100644 --- a/interface/RecoObjects/Jet.h +++ b/interface/RecoObjects/Jet.h @@ -172,10 +172,6 @@ class Jet: public Particle { ParticlePointer matchedGeneratedJet; ParticlePointer unsmearedJet; ParticlePointer smearedJet; - - boost::shared_ptr hadronTriggerLegEfficiencyHistogram_nonIsoJets; - boost::shared_ptr hadronTriggerLegEfficiencyHistogram_isoJets; - boost::shared_ptr hadronTriggerLegEfficiencyHistogram_isoPFJets; }; typedef boost::shared_ptr JetPointer; diff --git a/src/RecoObjects/Jet.cpp b/src/RecoObjects/Jet.cpp index f8c842cf..4095ba96 100644 --- a/src/RecoObjects/Jet.cpp +++ b/src/RecoObjects/Jet.cpp @@ -52,12 +52,7 @@ Jet::Jet() : // matchedGeneratedJet(), // unsmearedJet(), // - smearedJet(), // - - hadronTriggerLegEfficiencyHistogram_nonIsoJets( Globals::hadronTriggerLegEfficiencyHistogram_nonIsoJets ), // - hadronTriggerLegEfficiencyHistogram_isoJets( Globals::hadronTriggerLegEfficiencyHistogram_isoJets ), // - hadronTriggerLegEfficiencyHistogram_isoPFJets( Globals::hadronTriggerLegEfficiencyHistogram_isoPFJets ) // - + smearedJet() // { for (unsigned int btag = 0; btag < btag_discriminators.size(); ++btag) { btag_discriminators[btag] = -9999; @@ -105,11 +100,7 @@ Jet::Jet(double energy, double px, double py, double pz) : // matchedGeneratedJet(), // unsmearedJet(), // - smearedJet(), // - - hadronTriggerLegEfficiencyHistogram_nonIsoJets( Globals::hadronTriggerLegEfficiencyHistogram_nonIsoJets ), // - hadronTriggerLegEfficiencyHistogram_isoJets( Globals::hadronTriggerLegEfficiencyHistogram_isoJets ), // - hadronTriggerLegEfficiencyHistogram_isoPFJets( Globals::hadronTriggerLegEfficiencyHistogram_isoPFJets ) // + smearedJet() // { for (unsigned int btag = 0; btag < btag_discriminators.size(); ++btag) { btag_discriminators[btag] = -9999; @@ -542,7 +533,7 @@ double Jet::getEfficiencyCorrection( int scale_factor_systematic ) const { if ( jetPt >= 100 ) return 1.0; - unsigned int binNumber = hadronTriggerLegEfficiencyHistogram_nonIsoJets->FindFixBin( jetPt ); + unsigned int binNumber = Globals::hadronTriggerLegEfficiencyHistogram_nonIsoJets->FindFixBin( jetPt ); double correction_nonIsoJets = 1.; double lumi_nonIsoJets = Globals::luminosity * 0.076; @@ -554,19 +545,19 @@ double Jet::getEfficiencyCorrection( int scale_factor_systematic ) const { switch (scale_factor_systematic) { case -1: - correction_nonIsoJets = hadronTriggerLegEfficiencyHistogram_nonIsoJets->GetEfficiency( binNumber ) - hadronTriggerLegEfficiencyHistogram_nonIsoJets->GetEfficiencyErrorLow( binNumber ); - correction_isoJets = hadronTriggerLegEfficiencyHistogram_isoJets->GetEfficiency( binNumber ) - hadronTriggerLegEfficiencyHistogram_isoJets->GetEfficiencyErrorLow( binNumber ); - correction_isoPFJets = hadronTriggerLegEfficiencyHistogram_isoPFJets->GetEfficiency( binNumber ) - hadronTriggerLegEfficiencyHistogram_isoPFJets->GetEfficiencyErrorLow( binNumber ); + correction_nonIsoJets = Globals::hadronTriggerLegEfficiencyHistogram_nonIsoJets->GetEfficiency( binNumber ) - Globals::hadronTriggerLegEfficiencyHistogram_nonIsoJets->GetEfficiencyErrorLow( binNumber ); + correction_isoJets = Globals::hadronTriggerLegEfficiencyHistogram_isoJets->GetEfficiency( binNumber ) - Globals::hadronTriggerLegEfficiencyHistogram_isoJets->GetEfficiencyErrorLow( binNumber ); + correction_isoPFJets = Globals::hadronTriggerLegEfficiencyHistogram_isoPFJets->GetEfficiency( binNumber ) - Globals::hadronTriggerLegEfficiencyHistogram_isoPFJets->GetEfficiencyErrorLow( binNumber ); break; case 1: - correction_nonIsoJets = hadronTriggerLegEfficiencyHistogram_nonIsoJets->GetEfficiency( binNumber ) + hadronTriggerLegEfficiencyHistogram_nonIsoJets->GetEfficiencyErrorUp( binNumber ); - correction_isoJets = hadronTriggerLegEfficiencyHistogram_isoJets->GetEfficiency( binNumber ) + hadronTriggerLegEfficiencyHistogram_isoJets->GetEfficiencyErrorUp( binNumber ); - correction_isoPFJets = hadronTriggerLegEfficiencyHistogram_isoPFJets->GetEfficiency( binNumber ) + hadronTriggerLegEfficiencyHistogram_isoPFJets->GetEfficiencyErrorUp( binNumber ); + correction_nonIsoJets = Globals::hadronTriggerLegEfficiencyHistogram_nonIsoJets->GetEfficiency( binNumber ) + Globals::hadronTriggerLegEfficiencyHistogram_nonIsoJets->GetEfficiencyErrorUp( binNumber ); + correction_isoJets = Globals::hadronTriggerLegEfficiencyHistogram_isoJets->GetEfficiency( binNumber ) + Globals::hadronTriggerLegEfficiencyHistogram_isoJets->GetEfficiencyErrorUp( binNumber ); + correction_isoPFJets = Globals::hadronTriggerLegEfficiencyHistogram_isoPFJets->GetEfficiency( binNumber ) + Globals::hadronTriggerLegEfficiencyHistogram_isoPFJets->GetEfficiencyErrorUp( binNumber ); break; default: - correction_nonIsoJets = hadronTriggerLegEfficiencyHistogram_nonIsoJets->GetEfficiency( binNumber ); - correction_isoJets = hadronTriggerLegEfficiencyHistogram_isoJets->GetEfficiency( binNumber ); - correction_isoPFJets = hadronTriggerLegEfficiencyHistogram_isoPFJets->GetEfficiency( binNumber ); + correction_nonIsoJets = Globals::hadronTriggerLegEfficiencyHistogram_nonIsoJets->GetEfficiency( binNumber ); + correction_isoJets = Globals::hadronTriggerLegEfficiencyHistogram_isoJets->GetEfficiency( binNumber ); + correction_isoPFJets = Globals::hadronTriggerLegEfficiencyHistogram_isoPFJets->GetEfficiency( binNumber ); } correction = ((correction_nonIsoJets * lumi_nonIsoJets) + (correction_isoJets * lumi_isoJets) + (correction_isoPFJets * lumi_isoPFJets)) / (Globals::luminosity);