diff --git a/BoostedAnalyzer/data/TheoryXS_eej.root b/BoostedAnalyzer/data/TheoryXS_eej.root new file mode 100644 index 00000000..35bae763 Binary files /dev/null and b/BoostedAnalyzer/data/TheoryXS_eej.root differ diff --git a/BoostedAnalyzer/data/TheoryXS_evj.root b/BoostedAnalyzer/data/TheoryXS_evj.root new file mode 100644 index 00000000..9805da52 Binary files /dev/null and b/BoostedAnalyzer/data/TheoryXS_evj.root differ diff --git a/BoostedAnalyzer/data/TheoryXS_vvj.root b/BoostedAnalyzer/data/TheoryXS_vvj.root new file mode 100644 index 00000000..4ff80674 Binary files /dev/null and b/BoostedAnalyzer/data/TheoryXS_vvj.root differ diff --git a/BoostedAnalyzer/interface/BosonWeightProcessor.hpp b/BoostedAnalyzer/interface/BosonWeightProcessor.hpp new file mode 100644 index 00000000..f8a8d2cf --- /dev/null +++ b/BoostedAnalyzer/interface/BosonWeightProcessor.hpp @@ -0,0 +1,114 @@ +#ifndef BOOSTEDTTH_BOOSTEDANALYZER_BosonWeightProcessor_HPP +#define BOOSTEDTTH_BOOSTEDANALYZER_BosonWeightProcessor_HPP + +#include "BoostedTTH/BoostedAnalyzer/interface/TreeProcessor.hpp" +#include "BoostedTTH/BoostedAnalyzer/interface/BoostedUtils.hpp" + + +class BosonWeightProcessor: public TreeProcessor { + +public: + + BosonWeightProcessor(); + ~BosonWeightProcessor(); + + void Init(const InputCollections& input, VariableContainer& var); + void Process(const InputCollections& input, VariableContainer& var); +private: + TFile* fWeightsW = 0; + TFile* fWeightsZvv = 0; + TFile* fWeightsZll = 0; + + TH1D* hWbosonWeight_nominal = 0; + TH1D* hWbosonWeight_QCD1Up = 0; + TH1D* hWbosonWeight_QCD1Down = 0; + TH1D* hWbosonWeight_QCD2Up = 0; + TH1D* hWbosonWeight_QCD2Down = 0; + TH1D* hWbosonWeight_QCD3Up = 0; + TH1D* hWbosonWeight_QCD3Down = 0; + TH1D* hWbosonWeight_EW1Up = 0; + TH1D* hWbosonWeight_EW1Down = 0; + TH1D* hWbosonWeight_EW2Up = 0; + TH1D* hWbosonWeight_EW2Down = 0; + TH1D* hWbosonWeight_EW3Up = 0; + TH1D* hWbosonWeight_EW3Down = 0; + TH1D* hWbosonWeight_MixedUp = 0; + TH1D* hWbosonWeight_MixedDown = 0; + TH1D* hWbosonWeight_AlphaUp = 0; + TH1D* hWbosonWeight_AlphaDown = 0; + TH1D* hWbosonWeight_muRUp = 0; + TH1D* hWbosonWeight_muRDown = 0; + TH1D* hWbosonWeight_muFUp = 0; + TH1D* hWbosonWeight_muFDown = 0; + + + TH1D* hZvvbosonWeight_nominal = 0; + TH1D* hZvvbosonWeight_QCD1Up = 0; + TH1D* hZvvbosonWeight_QCD1Down = 0; + TH1D* hZvvbosonWeight_QCD2Up = 0; + TH1D* hZvvbosonWeight_QCD2Down = 0; + TH1D* hZvvbosonWeight_QCD3Up = 0; + TH1D* hZvvbosonWeight_QCD3Down = 0; + TH1D* hZvvbosonWeight_EW1Up = 0; + TH1D* hZvvbosonWeight_EW1Down = 0; + TH1D* hZvvbosonWeight_EW2Up = 0; + TH1D* hZvvbosonWeight_EW2Down = 0; + TH1D* hZvvbosonWeight_EW3Up = 0; + TH1D* hZvvbosonWeight_EW3Down = 0; + TH1D* hZvvbosonWeight_MixedUp = 0; + TH1D* hZvvbosonWeight_MixedDown = 0; + TH1D* hZvvbosonWeight_AlphaUp = 0; + TH1D* hZvvbosonWeight_AlphaDown = 0; + TH1D* hZvvbosonWeight_muRUp = 0; + TH1D* hZvvbosonWeight_muRDown = 0; + TH1D* hZvvbosonWeight_muFUp = 0; + TH1D* hZvvbosonWeight_muFDown = 0; + + TH1D* hZllbosonWeight_nominal = 0; + TH1D* hZllbosonWeight_QCD1Up = 0; + TH1D* hZllbosonWeight_QCD1Down = 0; + TH1D* hZllbosonWeight_QCD2Up = 0; + TH1D* hZllbosonWeight_QCD2Down = 0; + TH1D* hZllbosonWeight_QCD3Up = 0; + TH1D* hZllbosonWeight_QCD3Down = 0; + TH1D* hZllbosonWeight_EW1Up = 0; + TH1D* hZllbosonWeight_EW1Down = 0; + TH1D* hZllbosonWeight_EW2Up = 0; + TH1D* hZllbosonWeight_EW2Down = 0; + TH1D* hZllbosonWeight_EW3Up = 0; + TH1D* hZllbosonWeight_EW3Down = 0; + TH1D* hZllbosonWeight_MixedUp = 0; + TH1D* hZllbosonWeight_MixedDown = 0; + TH1D* hZllbosonWeight_AlphaUp = 0; + TH1D* hZllbosonWeight_AlphaDown = 0; + TH1D* hZllbosonWeight_muRUp = 0; + TH1D* hZllbosonWeight_muRDown = 0; + TH1D* hZllbosonWeight_muFUp = 0; + TH1D* hZllbosonWeight_muFDown = 0; + + double BosonWeight_nominal = 1; + double BosonWeight_QCD1Up = 1; + double BosonWeight_QCD1Down = 1; + double BosonWeight_QCD2Up = 1; + double BosonWeight_QCD2Down = 1; + double BosonWeight_QCD3Up = 1; + double BosonWeight_QCD3Down = 1; + double BosonWeight_EW1Up = 1; + double BosonWeight_EW1Down = 1; + double BosonWeight_EW2Up = 1; + double BosonWeight_EW2Down = 1; + double BosonWeight_EW3Up = 1; + double BosonWeight_EW3Down = 1; + double BosonWeight_MixedUp = 1; + double BosonWeight_MixedDown = 1; + double BosonWeight_AlphaUp = 1; + double BosonWeight_AlphaDown = 1; + double BosonWeight_muRUp = 1; + double BosonWeight_muRDown = 1; + double BosonWeight_muFUp = 1; + double BosonWeight_muFDown = 1; + + +}; + +#endif diff --git a/BoostedAnalyzer/interface/GenEWevent.hpp b/BoostedAnalyzer/interface/GenEWevent.hpp new file mode 100644 index 00000000..863d4a82 --- /dev/null +++ b/BoostedAnalyzer/interface/GenEWevent.hpp @@ -0,0 +1,50 @@ +#ifndef BOOSTEDTTH_BOOSTEDANALYZER_GenEWevent_HPP +#define BOOSTEDTTH_BOOSTEDANALYZER_GenEWevent_HPP +#include +#include "DataFormats/HepMCCandidate/interface/GenParticle.h" +#include "DataFormats/PatCandidates/interface/PackedGenParticle.h" +#include + +class GenEWevent{ + + public: + // constructor + GenEWevent(); + // destructor + ~GenEWevent(); + void Initialize(std::vector prunedGenParticles_, std::vector packedGenParticles_); + void Fill(); + + std::vector ReturnPrunedGenParticles() const; + std::vector ReturnPackedGenParticles() const; + + + bool IsFilled() const; + + // for MC reweighting of Z/W boson + jets events + void FillBoson(); + bool ZBosonIsFilled() const; + bool WBosonIsFilled() const; + bool IsZnunu() const; + // bool IsZll() const; + math::XYZTLorentzVector ReturnZBoson() const; + math::XYZTLorentzVector ReturnWBoson() const; + + private: + bool isFilled = false; + + std::vector prunedGenParticles; + std::vector packedGenParticles; + + // for MC reweighting of Z/W boson + jets events + bool hasVectorBoson = false; + bool ZBosonisFilled = false; + bool WBosonisFilled = false; + bool isZnunu = false; + // bool isZll = false; + math::XYZTLorentzVector ZBoson; + math::XYZTLorentzVector WBoson; +}; + + +#endif \ No newline at end of file diff --git a/BoostedAnalyzer/interface/InputCollections.hpp b/BoostedAnalyzer/interface/InputCollections.hpp index b62e9d82..41828e18 100644 --- a/BoostedAnalyzer/interface/InputCollections.hpp +++ b/BoostedAnalyzer/interface/InputCollections.hpp @@ -1,160 +1,177 @@ #ifndef BOOSTEDTTH_BOOSTEDANALYZER_INPUTCOLLECTIONS_HPP #define BOOSTEDTTH_BOOSTEDANALYZER_INPUTCOLLECTIONS_HPP -#include +#include #include #include -#include +#include -#include "DataFormats/PatCandidates/interface/Muon.h" +#include "BoostedTTH/BoostedAnalyzer/interface/EventInfo.hpp" +#include "BoostedTTH/BoostedAnalyzer/interface/FilterInfo.hpp" +#include "BoostedTTH/BoostedAnalyzer/interface/GenEWevent.hpp" +#include "BoostedTTH/BoostedAnalyzer/interface/GenTopEvent.hpp" +#include "BoostedTTH/BoostedAnalyzer/interface/TriggerInfo.hpp" #include "DataFormats/PatCandidates/interface/Electron.h" #include "DataFormats/PatCandidates/interface/Jet.h" #include "DataFormats/PatCandidates/interface/MET.h" -#include "MiniAOD/BoostedObjects/interface/BoostedJet.h" +#include "DataFormats/PatCandidates/interface/Muon.h" #include "MiniAOD/BoostedObjects/interface/Ak4Cluster.h" -#include "BoostedTTH/BoostedAnalyzer/interface/GenTopEvent.hpp" -#include "BoostedTTH/BoostedAnalyzer/interface/EventInfo.hpp" -#include "BoostedTTH/BoostedAnalyzer/interface/TriggerInfo.hpp" -#include "BoostedTTH/BoostedAnalyzer/interface/FilterInfo.hpp" +#include "MiniAOD/BoostedObjects/interface/BoostedJet.h" #include "MiniAOD/MiniAODHelper/interface/MiniAODHelper.h" - -enum SampleType{data,tth,ttl,ttbb,ttb,tt2b,ttcc,ttc,nonttbkg,thq}; -namespace HiggsDecay{enum HiggsDecay{NA,bb,nonbb};}; - - +enum SampleType { data, + tth, + ttl, + ttbb, + ttb, + tt2b, + ttcc, + ttc, + nonttbkg, + thq }; +namespace HiggsDecay { +enum HiggsDecay { NA, + bb, + nonbb }; +}; /* References to the selected physics objects as well as some general event information, some generator information, and event weights (nominal and for systematics) are stored in InputCollections. Only from these inputs the variables in the trees are calculated. There are multiple InputCollections for different systematics (e.g. in one the default jets are exchanged with JES shifted jets). */ -struct InputCollections{ -/** +struct InputCollections { + /** Constructor in which all references to the objects that are analyzed are set */ -InputCollections( const EventInfo& eventInfo_, - const TriggerInfo& triggerInfo_, - const FilterInfo& filterInfo_, - const std::vector& selectedPVs_, + InputCollections(const EventInfo& eventInfo_, + const TriggerInfo& triggerInfo_, + const FilterInfo& filterInfo_, + const std::vector& selectedPVs_, + + const std::vector& selectedMuons_, + const std::vector& selectedMuonsDL_, + const std::vector& selectedMuonsLoose_, + const std::vector& selectedElectrons_, + const std::vector& selectedElectronsDL_, + const std::vector& selectedElectronsLoose_, + const std::vector& selectedJets_, + const std::vector& selectedJetsLoose_, + const std::vector& AK8Jets_, + const pat::MET& correctedMET_, + // const boosted::BoostedJetCollection& selectedBoostedJets_, + // const boosted::Ak4ClusterCollection& selectedAk4Cluster_, + const GenTopEvent& genTopEvt_, + const GenEWevent& genEWevt_, + const std::vector& genJets_, + const SampleType sampleType_, + const HiggsDecay::HiggsDecay higgsDecay_, + const std::map& weights_, + const edm::Event& iEvent_, + const edm::EventSetup& iSetup_, + const Systematics::Type& systematic_, + const std::map& selectionTags_, + const std::string& era_ - const std::vector& selectedMuons_, - const std::vector& selectedMuonsDL_, - const std::vector& selectedMuonsLoose_, - const std::vector& selectedElectrons_, - const std::vector& selectedElectronsDL_, - const std::vector& selectedElectronsLoose_, - const std::vector& selectedJets_, - const std::vector& selectedJetsLoose_, - const std::vector& AK8Jets_, - const pat::MET& correctedMET_, -// const boosted::BoostedJetCollection& selectedBoostedJets_, -// const boosted::Ak4ClusterCollection& selectedAk4Cluster_, - const GenTopEvent& genTopEvt_, - const std::vector& genJets_, - const SampleType sampleType_, - const HiggsDecay::HiggsDecay higgsDecay_, - const std::map& weights_, - const edm::Event& iEvent_, - const edm::EventSetup& iSetup_, - const Systematics::Type& systematic_, - const std::map& selectionTags_, - const std::string& era_ - - /**** bjetness code ****/ - ): - eventInfo(eventInfo_), - triggerInfo(triggerInfo_), - filterInfo(filterInfo_), - selectedPVs(selectedPVs_), - selectedMuons(selectedMuons_), - selectedMuonsDL(selectedMuonsDL_), - selectedMuonsLoose(selectedMuonsLoose_), - selectedElectrons(selectedElectrons_), - selectedElectronsDL(selectedElectronsDL_), - selectedElectronsLoose(selectedElectronsLoose_), - selectedJets(selectedJets_), - selectedJetsLoose(selectedJetsLoose_), - AK8Jets(AK8Jets_), - correctedMET(correctedMET_), -// selectedBoostedJets(selectedBoostedJets_), -// selectedAk4Cluster(selectedAk4Cluster_), - genTopEvt(genTopEvt_), - genJets(genJets_), - sampleType(sampleType_), - higgsDecay(higgsDecay_), - weights(weights_), - iEvent(iEvent_), - iSetup(iSetup_), - systematic(systematic_), - selectionTags(selectionTags_), - era(era_) - {} + /**** bjetness code ****/ + ) + : eventInfo(eventInfo_) + , triggerInfo(triggerInfo_) + , filterInfo(filterInfo_) + , selectedPVs(selectedPVs_) + , selectedMuons(selectedMuons_) + , selectedMuonsDL(selectedMuonsDL_) + , selectedMuonsLoose(selectedMuonsLoose_) + , selectedElectrons(selectedElectrons_) + , selectedElectronsDL(selectedElectronsDL_) + , selectedElectronsLoose(selectedElectronsLoose_) + , selectedJets(selectedJets_) + , selectedJetsLoose(selectedJetsLoose_) + , AK8Jets(AK8Jets_) + , correctedMET(correctedMET_) + // selectedBoostedJets(selectedBoostedJets_), + // selectedAk4Cluster(selectedAk4Cluster_), + , genTopEvt(genTopEvt_) + , genEWevt(genEWevt_) + , genJets(genJets_) + , sampleType(sampleType_) + , higgsDecay(higgsDecay_) + , weights(weights_) + , iEvent(iEvent_) + , iSetup(iSetup_) + , systematic(systematic_) + , selectionTags(selectionTags_) + , era(era_) + + { + } -/** + /** Constructor that replaces all variables related to jets and copies the remaining ones from a different input colection */ -InputCollections( const InputCollections& input, - const std::vector& rawJets_, - const std::vector& selectedJets_, - const std::vector& selectedJetsLoose_, - const pat::MET& correctedMET_, - const boosted::BoostedJetCollection& selectedBoostedJets_, - const boosted::Ak4ClusterCollection& selectedAk4Cluster_, - const std::map& weights_ - ): - eventInfo(input.eventInfo), - triggerInfo(input.triggerInfo), - filterInfo(input.filterInfo), - selectedPVs(input.selectedPVs), - selectedMuons(input.selectedMuons), - selectedMuonsDL(input.selectedMuonsDL), - selectedMuonsLoose(input.selectedMuonsLoose), - selectedElectrons(input.selectedElectrons), - selectedElectronsDL(input.selectedElectronsDL), - selectedElectronsLoose(input.selectedElectronsLoose), - selectedJets(selectedJets_), - selectedJetsLoose(selectedJetsLoose_), - AK8Jets(input.AK8Jets), - correctedMET(correctedMET_), -// selectedBoostedJets(selectedBoostedJets_), -// selectedAk4Cluster(selectedAk4Cluster_), - genTopEvt(input.genTopEvt), - genJets(input.genJets), - sampleType(input.sampleType), - higgsDecay(input.higgsDecay), - weights(weights_), - iEvent(input.iEvent), - iSetup(input.iSetup), - systematic(input.systematic), - selectionTags(input.selectionTags), - era(input.era) - {} + InputCollections(const InputCollections& input, + const std::vector& rawJets_, + const std::vector& selectedJets_, + const std::vector& selectedJetsLoose_, + const pat::MET& correctedMET_, + const boosted::BoostedJetCollection& selectedBoostedJets_, + const boosted::Ak4ClusterCollection& selectedAk4Cluster_, + const std::map& weights_) + : eventInfo(input.eventInfo) + , triggerInfo(input.triggerInfo) + , filterInfo(input.filterInfo) + , selectedPVs(input.selectedPVs) + , selectedMuons(input.selectedMuons) + , selectedMuonsDL(input.selectedMuonsDL) + , selectedMuonsLoose(input.selectedMuonsLoose) + , selectedElectrons(input.selectedElectrons) + , selectedElectronsDL(input.selectedElectronsDL) + , selectedElectronsLoose(input.selectedElectronsLoose) + , selectedJets(selectedJets_) + , selectedJetsLoose(selectedJetsLoose_) + , AK8Jets(input.AK8Jets) + , correctedMET(correctedMET_) + // selectedBoostedJets(selectedBoostedJets_), + // selectedAk4Cluster(selectedAk4Cluster_), + , genTopEvt(input.genTopEvt) + , genEWevt(input.genEWevt) + , genJets(input.genJets) + , sampleType(input.sampleType) + , higgsDecay(input.higgsDecay) + , weights(weights_) + , iEvent(input.iEvent) + , iSetup(input.iSetup) + , systematic(input.systematic) + , selectionTags(input.selectionTags) + , era(input.era) + { + } - const EventInfo& eventInfo; - const TriggerInfo& triggerInfo; - const FilterInfo& filterInfo; - const std::vector& selectedPVs; - const std::vector& selectedMuons; - const std::vector& selectedMuonsDL; - const std::vector& selectedMuonsLoose; - const std::vector& selectedElectrons; - const std::vector& selectedElectronsDL; - const std::vector& selectedElectronsLoose; - const std::vector& selectedJets; - const std::vector& selectedJetsLoose; - const std::vector& AK8Jets; - const pat::MET& correctedMET; -// const boosted::BoostedJetCollection& selectedBoostedJets; -// const boosted::Ak4ClusterCollection& selectedAk4Cluster; - const GenTopEvent& genTopEvt; - const std::vector& genJets; - const SampleType sampleType; - const HiggsDecay::HiggsDecay higgsDecay; - const std::map weights; - const edm::Event & iEvent; - const edm::EventSetup & iSetup; - const Systematics::Type& systematic; - const std::map& selectionTags; - const std::string& era; + const EventInfo& eventInfo; + const TriggerInfo& triggerInfo; + const FilterInfo& filterInfo; + const std::vector& selectedPVs; + const std::vector& selectedMuons; + const std::vector& selectedMuonsDL; + const std::vector& selectedMuonsLoose; + const std::vector& selectedElectrons; + const std::vector& selectedElectronsDL; + const std::vector& selectedElectronsLoose; + const std::vector& selectedJets; + const std::vector& selectedJetsLoose; + const std::vector& AK8Jets; + const pat::MET& correctedMET; + // const boosted::BoostedJetCollection& selectedBoostedJets; + // const boosted::Ak4ClusterCollection& selectedAk4Cluster; + const GenTopEvent& genTopEvt; + const GenEWevent& genEWevt; + const std::vector& genJets; + const SampleType sampleType; + const HiggsDecay::HiggsDecay higgsDecay; + const std::map weights; + const edm::Event& iEvent; + const edm::EventSetup& iSetup; + const Systematics::Type& systematic; + const std::map& selectionTags; + const std::string& era; }; #endif diff --git a/BoostedAnalyzer/plugins/BoostedAnalyzer.cc b/BoostedAnalyzer/plugins/BoostedAnalyzer.cc index 1d03613d..a2a81034 100644 --- a/BoostedAnalyzer/plugins/BoostedAnalyzer.cc +++ b/BoostedAnalyzer/plugins/BoostedAnalyzer.cc @@ -101,6 +101,7 @@ #include "BoostedTTH/BoostedAnalyzer/interface/DiJetVarProcessor.hpp" #include "BoostedTTH/BoostedAnalyzer/interface/EventInfo.hpp" #include "BoostedTTH/BoostedAnalyzer/interface/GenTopEvent.hpp" +#include "BoostedTTH/BoostedAnalyzer/interface/GenEWevent.hpp" #include "BoostedTTH/BoostedAnalyzer/interface/Synchronizer.hpp" #include "BoostedTTH/BoostedAnalyzer/interface/DiLeptonVarProcessor.hpp" #include "BoostedTTH/BoostedAnalyzer/interface/TriggerVarProcessor.hpp" @@ -115,6 +116,7 @@ #include "BoostedTTH/BoostedAnalyzer/interface/TTBBStudienProcessor.hpp" #include "BoostedTTH/BoostedAnalyzer/interface/AK8JetProcessor.hpp" #include "BoostedTTH/BoostedAnalyzer/interface/SelectionTagProcessor.hpp" +#include "BoostedTTH/BoostedAnalyzer/interface/BosonWeightProcessor.hpp" // // class declaration @@ -164,6 +166,8 @@ class BoostedAnalyzer : public edm::EDAnalyzer { GenWeights genweights; /** produces MC truth information for ttbar and ttH samples (genTopEvent)*/ GenTopEventProducer genTopEvtProd; + // /** produces MC truth information for ttbar and ttH samples (genTopEvent)*/ + // GenTopEventProducer genEWProd; /** produces trigger information */ TriggerInfoProducer triggerInfoProd; /** produces filter information */ @@ -553,6 +557,9 @@ BoostedAnalyzer::BoostedAnalyzer(const edm::ParameterSet& iConfig): if(std::find(processorNames.begin(),processorNames.end(),"SelectionTagProcessor")!=processorNames.end()) { treewriter->AddTreeProcessor(new SelectionTagProcessor(),"SelectionTagProcessor"); } + if(std::find(processorNames.begin(),processorNames.end(),"BosonWeightProcessor")!=processorNames.end()) { + treewriter->AddTreeProcessor(new BosonWeightProcessor(),"BosonWeightProcessor"); + } } // Genweights: Initialize the weightnames for the generator, that was used for this sample @@ -774,6 +781,17 @@ void BoostedAnalyzer::analyze(const edm::Event& iEvent, const edm::EventSetup& i } else if(((foundT&&!foundTbar)||(!foundT&&foundTbar))&&foundHiggs) sampleType = SampleType::thq; + // create GenEWevent object + GenEWevent genEWevt; + // create empty packedGenParticle dummy since this collection is not yet needed, but maybe later + std::vector packedGenParticles_dummy; + // initialze the GenEWevent object with the collections of genparticles + if(!isData){ + genEWevt.Initialize(*h_genParticles,packedGenParticles_dummy); + // fill the event + genEWevt.FillBoson(); + } + //selectiontags map selectionTags; @@ -802,6 +820,7 @@ void BoostedAnalyzer::analyze(const edm::Event& iEvent, const edm::EventSetup& i //selectedBoostedJets[isys], //selectedAk4Cluster, genTopEvt, + genEWevt, *h_genJets, sampleType, higgsdecay, diff --git a/BoostedAnalyzer/src/BosonWeightProcessor.cpp b/BoostedAnalyzer/src/BosonWeightProcessor.cpp new file mode 100644 index 00000000..f10ce87c --- /dev/null +++ b/BoostedAnalyzer/src/BosonWeightProcessor.cpp @@ -0,0 +1,264 @@ +#include "BoostedTTH/BoostedAnalyzer/interface/BosonWeightProcessor.hpp" + +using namespace std; + +BosonWeightProcessor::BosonWeightProcessor() {} +BosonWeightProcessor::~BosonWeightProcessor() {} + + +void BosonWeightProcessor::Init(const InputCollections& input, VariableContainer& vars) { + + vars.InitVar( "BosonWeight_nominal" ); + + vars.InitVar( "BosonWeight_QCD1Up" ); + vars.InitVar( "BosonWeight_QCD1Down" ); + vars.InitVar( "BosonWeight_QCD2Up" ); + vars.InitVar( "BosonWeight_QCD2Down" ); + vars.InitVar( "BosonWeight_QCD3Up" ); + vars.InitVar( "BosonWeight_QCD3Down" ); + + vars.InitVar( "BosonWeight_EW1Up" ); + vars.InitVar( "BosonWeight_EW1Down" ); + vars.InitVar( "BosonWeight_EW2Up" ); + vars.InitVar( "BosonWeight_EW2Down" ); + vars.InitVar( "BosonWeight_EW3Up" ); + vars.InitVar( "BosonWeight_EW3Down" ); + + vars.InitVar( "BosonWeight_MixedUp" ); + vars.InitVar( "BosonWeight_MixedDown" ); + vars.InitVar( "BosonWeight_AlphaUp" ); + vars.InitVar( "BosonWeight_AlphaDown" ); + + vars.InitVar( "BosonWeight_muRUp" ); + vars.InitVar( "BosonWeight_muRDown" ); + vars.InitVar( "BosonWeight_muFUp" ); + vars.InitVar( "BosonWeight_muFDown" ); + + fWeightsW = new TFile("$CMSSW_BASE/src/BoostedTTH/BoostedAnalyzer/data/TheoryXS_evj.root"); + hWbosonWeight_nominal = (TH1D*)fWeightsW->Get("evj_NNLO_NLO_nnn_nnn_n"); + hWbosonWeight_QCD1Up = (TH1D*)fWeightsW->Get("evj_NNLO_NLO_unn_nnn_n"); + hWbosonWeight_QCD1Down = (TH1D*)fWeightsW->Get("evj_NNLO_NLO_dnn_nnn_n"); + hWbosonWeight_QCD2Up = (TH1D*)fWeightsW->Get("evj_NNLO_NLO_nun_nnn_n"); + hWbosonWeight_QCD2Down = (TH1D*)fWeightsW->Get("evj_NNLO_NLO_ndn_nnn_n"); + hWbosonWeight_QCD3Up = (TH1D*)fWeightsW->Get("evj_NNLO_NLO_nnu_nnn_n"); + hWbosonWeight_QCD3Down = (TH1D*)fWeightsW->Get("evj_NNLO_NLO_nnd_nnn_n"); + hWbosonWeight_EW1Up = (TH1D*)fWeightsW->Get("evj_NNLO_NLO_nnn_unn_n"); + hWbosonWeight_EW1Down = (TH1D*)fWeightsW->Get("evj_NNLO_NLO_nnn_dnn_n"); + hWbosonWeight_EW2Up = (TH1D*)fWeightsW->Get("evj_NNLO_NLO_nnn_nun_n"); + hWbosonWeight_EW2Down = (TH1D*)fWeightsW->Get("evj_NNLO_NLO_nnn_ndn_n"); + hWbosonWeight_EW3Up = (TH1D*)fWeightsW->Get("evj_NNLO_NLO_nnn_nnu_n"); + hWbosonWeight_EW3Down = (TH1D*)fWeightsW->Get("evj_NNLO_NLO_nnn_nnd_n"); + hWbosonWeight_MixedUp = (TH1D*)fWeightsW->Get("evj_NNLO_NLO_nnn_nnn_u"); + hWbosonWeight_MixedDown = (TH1D*)fWeightsW->Get("evj_NNLO_NLO_nnn_nnn_d"); + hWbosonWeight_AlphaUp = (TH1D*)fWeightsW->Get("evj_NNLO_NLO_nnn_nnn_n_alpha_up"); + hWbosonWeight_AlphaDown = (TH1D*)fWeightsW->Get("evj_NNLO_NLO_nnn_nnn_n_alpha_down"); + hWbosonWeight_muRUp = (TH1D*)fWeightsW->Get("evj_NNLO_NLO_nnn_nnn_n_Weight_scale_variation_muR_2p0_muF_1p0"); + hWbosonWeight_muRDown = (TH1D*)fWeightsW->Get("evj_NNLO_NLO_nnn_nnn_n_Weight_scale_variation_muR_0p5_muF_1p0"); + hWbosonWeight_muFUp = (TH1D*)fWeightsW->Get("evj_NNLO_NLO_nnn_nnn_n_Weight_scale_variation_muR_1p0_muF_2p0"); + hWbosonWeight_muFDown = (TH1D*)fWeightsW->Get("evj_NNLO_NLO_nnn_nnn_n_Weight_scale_variation_muR_1p0_muF_0p5"); + + fWeightsZvv = new TFile("$CMSSW_BASE/src/BoostedTTH/BoostedAnalyzer/data/TheoryXS_vvj.root"); + hZvvbosonWeight_nominal = (TH1D*)fWeightsZvv->Get("vvj_NNLO_NLO_nnn_nnn_n"); + hZvvbosonWeight_QCD1Up = (TH1D*)fWeightsZvv->Get("vvj_NNLO_NLO_unn_nnn_n"); + hZvvbosonWeight_QCD1Down = (TH1D*)fWeightsZvv->Get("vvj_NNLO_NLO_dnn_nnn_n"); + hZvvbosonWeight_QCD2Up = (TH1D*)fWeightsZvv->Get("vvj_NNLO_NLO_nun_nnn_n"); + hZvvbosonWeight_QCD2Down = (TH1D*)fWeightsZvv->Get("vvj_NNLO_NLO_ndn_nnn_n"); + hZvvbosonWeight_QCD3Up = (TH1D*)fWeightsZvv->Get("vvj_NNLO_NLO_nnu_nnn_n"); + hZvvbosonWeight_QCD3Down = (TH1D*)fWeightsZvv->Get("vvj_NNLO_NLO_nnd_nnn_n"); + hZvvbosonWeight_EW1Up = (TH1D*)fWeightsZvv->Get("vvj_NNLO_NLO_nnn_unn_n"); + hZvvbosonWeight_EW1Down = (TH1D*)fWeightsZvv->Get("vvj_NNLO_NLO_nnn_dnn_n"); + hZvvbosonWeight_EW2Up = (TH1D*)fWeightsZvv->Get("vvj_NNLO_NLO_nnn_nun_n"); + hZvvbosonWeight_EW2Down = (TH1D*)fWeightsZvv->Get("vvj_NNLO_NLO_nnn_ndn_n"); + hZvvbosonWeight_EW3Up = (TH1D*)fWeightsZvv->Get("vvj_NNLO_NLO_nnn_nnu_n"); + hZvvbosonWeight_EW3Down = (TH1D*)fWeightsZvv->Get("vvj_NNLO_NLO_nnn_nnd_n"); + hZvvbosonWeight_MixedUp = (TH1D*)fWeightsZvv->Get("vvj_NNLO_NLO_nnn_nnn_u"); + hZvvbosonWeight_MixedDown = (TH1D*)fWeightsZvv->Get("vvj_NNLO_NLO_nnn_nnn_d"); + hZvvbosonWeight_AlphaUp = (TH1D*)fWeightsZvv->Get("vvj_NNLO_NLO_nnn_nnn_n_alpha_up"); + hZvvbosonWeight_AlphaDown = (TH1D*)fWeightsZvv->Get("vvj_NNLO_NLO_nnn_nnn_n_alpha_down"); + hZvvbosonWeight_muRUp = (TH1D*)fWeightsZvv->Get("vvj_NNLO_NLO_nnn_nnn_n_Weight_scale_variation_muR_2p0_muF_1p0"); + hZvvbosonWeight_muRDown = (TH1D*)fWeightsZvv->Get("vvj_NNLO_NLO_nnn_nnn_n_Weight_scale_variation_muR_0p5_muF_1p0"); + hZvvbosonWeight_muFUp = (TH1D*)fWeightsZvv->Get("vvj_NNLO_NLO_nnn_nnn_n_Weight_scale_variation_muR_1p0_muF_2p0"); + hZvvbosonWeight_muFDown = (TH1D*)fWeightsZvv->Get("vvj_NNLO_NLO_nnn_nnn_n_Weight_scale_variation_muR_1p0_muF_0p5"); +hZvvbosonWeight_muFDown->Print(); + + fWeightsZll = new TFile("$CMSSW_BASE/src/BoostedTTH/BoostedAnalyzer/data/TheoryXS_eej.root"); + hZllbosonWeight_nominal = (TH1D*)fWeightsZll->Get("eej_NNLO_NLO_nnn_nnn_n"); + hZllbosonWeight_QCD1Up = (TH1D*)fWeightsZll->Get("eej_NNLO_NLO_unn_nnn_n"); + hZllbosonWeight_QCD1Down = (TH1D*)fWeightsZll->Get("eej_NNLO_NLO_dnn_nnn_n"); + hZllbosonWeight_QCD2Up = (TH1D*)fWeightsZll->Get("eej_NNLO_NLO_nun_nnn_n"); + hZllbosonWeight_QCD2Down = (TH1D*)fWeightsZll->Get("eej_NNLO_NLO_ndn_nnn_n"); + hZllbosonWeight_QCD3Up = (TH1D*)fWeightsZll->Get("eej_NNLO_NLO_nnu_nnn_n"); + hZllbosonWeight_QCD3Down = (TH1D*)fWeightsZll->Get("eej_NNLO_NLO_nnd_nnn_n"); + hZllbosonWeight_EW1Up = (TH1D*)fWeightsZll->Get("eej_NNLO_NLO_nnn_unn_n"); + hZllbosonWeight_EW1Down = (TH1D*)fWeightsZll->Get("eej_NNLO_NLO_nnn_dnn_n"); + hZllbosonWeight_EW2Up = (TH1D*)fWeightsZll->Get("eej_NNLO_NLO_nnn_nun_n"); + hZllbosonWeight_EW2Down = (TH1D*)fWeightsZll->Get("eej_NNLO_NLO_nnn_ndn_n"); + hZllbosonWeight_EW3Up = (TH1D*)fWeightsZll->Get("eej_NNLO_NLO_nnn_nnu_n"); + hZllbosonWeight_EW3Down = (TH1D*)fWeightsZll->Get("eej_NNLO_NLO_nnn_nnd_n"); + hZllbosonWeight_MixedUp = (TH1D*)fWeightsZll->Get("eej_NNLO_NLO_nnn_nnn_u"); + hZllbosonWeight_MixedDown = (TH1D*)fWeightsZll->Get("eej_NNLO_NLO_nnn_nnn_d"); + hZllbosonWeight_AlphaUp = (TH1D*)fWeightsZll->Get("eej_NNLO_NLO_nnn_nnn_n_alpha_up"); + hZllbosonWeight_AlphaDown = (TH1D*)fWeightsZll->Get("eej_NNLO_NLO_nnn_nnn_n_alpha_down"); + hZllbosonWeight_muRUp = (TH1D*)fWeightsZll->Get("eej_NNLO_NLO_nnn_nnn_n_Weight_scale_variation_muR_2p0_muF_1p0"); + hZllbosonWeight_muRDown = (TH1D*)fWeightsZll->Get("eej_NNLO_NLO_nnn_nnn_n_Weight_scale_variation_muR_0p5_muF_1p0"); + hZllbosonWeight_muFUp = (TH1D*)fWeightsZll->Get("eej_NNLO_NLO_nnn_nnn_n_Weight_scale_variation_muR_1p0_muF_2p0"); + hZllbosonWeight_muFDown = (TH1D*)fWeightsZll->Get("eej_NNLO_NLO_nnn_nnn_n_Weight_scale_variation_muR_1p0_muF_0p5"); + initialized = true; +} + +void BosonWeightProcessor::Process(const InputCollections& input, VariableContainer& vars) { + if (!initialized) cerr << "tree processor not initialized" << endl; + + if (input.genEWevt.WBosonIsFilled()) { + const GenEWevent& EW_evt = input.genEWevt; + double W_Pt = EW_evt.ReturnWBoson().Pt(); + if (W_Pt > 30) { + BosonWeight_nominal = hWbosonWeight_nominal->GetBinContent(hWbosonWeight_nominal->FindBin(W_Pt)); + BosonWeight_QCD1Up = hWbosonWeight_QCD1Up->GetBinContent(hWbosonWeight_QCD1Up->FindBin(W_Pt)); + BosonWeight_QCD1Down = hWbosonWeight_QCD1Down->GetBinContent(hWbosonWeight_QCD1Down->FindBin(W_Pt)); + BosonWeight_QCD2Up = hWbosonWeight_QCD2Up->GetBinContent(hWbosonWeight_QCD2Up->FindBin(W_Pt)); + BosonWeight_QCD2Down = hWbosonWeight_QCD2Down->GetBinContent(hWbosonWeight_QCD2Down->FindBin(W_Pt)); + BosonWeight_QCD3Up = hWbosonWeight_QCD3Up->GetBinContent(hWbosonWeight_QCD3Up->FindBin(W_Pt)); + BosonWeight_QCD3Down = hWbosonWeight_QCD3Down->GetBinContent(hWbosonWeight_QCD3Down->FindBin(W_Pt)); + BosonWeight_EW1Up = hWbosonWeight_EW1Up->GetBinContent(hWbosonWeight_EW1Up->FindBin(W_Pt)); + BosonWeight_EW1Down = hWbosonWeight_EW1Down->GetBinContent(hWbosonWeight_EW1Down->FindBin(W_Pt)); + BosonWeight_EW2Up = hWbosonWeight_EW2Up->GetBinContent(hWbosonWeight_EW2Up->FindBin(W_Pt)); + BosonWeight_EW2Down = hWbosonWeight_EW2Down->GetBinContent(hWbosonWeight_EW2Down->FindBin(W_Pt)); + BosonWeight_EW3Up = hWbosonWeight_EW3Up->GetBinContent(hWbosonWeight_EW3Up->FindBin(W_Pt)); + BosonWeight_EW3Down = hWbosonWeight_EW3Down->GetBinContent(hWbosonWeight_EW3Down->FindBin(W_Pt)); + BosonWeight_MixedUp = hWbosonWeight_MixedUp->GetBinContent(hWbosonWeight_MixedUp->FindBin(W_Pt)); + BosonWeight_MixedDown = hWbosonWeight_MixedDown->GetBinContent(hWbosonWeight_MixedDown->FindBin(W_Pt)); + BosonWeight_AlphaUp = hWbosonWeight_AlphaUp->GetBinContent(hWbosonWeight_AlphaUp->FindBin(W_Pt)); + BosonWeight_AlphaDown = hWbosonWeight_AlphaDown->GetBinContent(hWbosonWeight_AlphaDown->FindBin(W_Pt)); + BosonWeight_muRUp = hWbosonWeight_muRUp->GetBinContent(hWbosonWeight_muRUp->FindBin(W_Pt)); + BosonWeight_muRDown = hWbosonWeight_muRDown->GetBinContent(hWbosonWeight_muRDown->FindBin(W_Pt)); + BosonWeight_muFUp = hWbosonWeight_muFUp->GetBinContent(hWbosonWeight_muFUp->FindBin(W_Pt)); + BosonWeight_muFDown = hWbosonWeight_muFDown->GetBinContent(hWbosonWeight_muFDown->FindBin(W_Pt)); + } + else { + BosonWeight_nominal = 1; + BosonWeight_QCD1Up = 1; + BosonWeight_QCD1Down = 1; + BosonWeight_QCD2Up = 1; + BosonWeight_QCD2Down = 1; + BosonWeight_QCD3Up = 1; + BosonWeight_QCD3Down = 1; + BosonWeight_EW1Up = 1; + BosonWeight_EW1Down = 1; + BosonWeight_EW2Up = 1; + BosonWeight_EW2Down = 1; + BosonWeight_EW3Up = 1; + BosonWeight_EW3Down = 1; + BosonWeight_MixedUp = 1; + BosonWeight_MixedDown = 1; + BosonWeight_AlphaUp = 1; + BosonWeight_AlphaDown = 1; + BosonWeight_muRUp = 1; + BosonWeight_muRDown = 1; + BosonWeight_muFUp = 1; + BosonWeight_muFDown = 1; + } + } + + if (input.genEWevt.ZBosonIsFilled()) { + const GenEWevent& EW_evt = input.genEWevt; + double Z_Pt = EW_evt.ReturnZBoson().Pt(); + if (Z_Pt > 30) { + if (EW_evt.IsZnunu()){ + BosonWeight_nominal = hZvvbosonWeight_nominal->GetBinContent(hZvvbosonWeight_nominal->FindBin(Z_Pt)); + BosonWeight_QCD1Up = hZvvbosonWeight_QCD1Up->GetBinContent(hZvvbosonWeight_QCD1Up->FindBin(Z_Pt)); + BosonWeight_QCD1Down = hZvvbosonWeight_QCD1Down->GetBinContent(hZvvbosonWeight_QCD1Down->FindBin(Z_Pt)); + BosonWeight_QCD2Up = hZvvbosonWeight_QCD2Up->GetBinContent(hZvvbosonWeight_QCD2Up->FindBin(Z_Pt)); + BosonWeight_QCD2Down = hZvvbosonWeight_QCD2Down->GetBinContent(hZvvbosonWeight_QCD2Down->FindBin(Z_Pt)); + BosonWeight_QCD3Up = hZvvbosonWeight_QCD3Up->GetBinContent(hZvvbosonWeight_QCD3Up->FindBin(Z_Pt)); + BosonWeight_QCD3Down = hZvvbosonWeight_QCD3Down->GetBinContent(hZvvbosonWeight_QCD3Down->FindBin(Z_Pt)); + BosonWeight_EW1Up = hZvvbosonWeight_EW1Up->GetBinContent(hZvvbosonWeight_EW1Up->FindBin(Z_Pt)); + BosonWeight_EW1Down = hZvvbosonWeight_EW1Down->GetBinContent(hZvvbosonWeight_EW1Down->FindBin(Z_Pt)); + BosonWeight_EW2Up = hZvvbosonWeight_EW2Up->GetBinContent(hZvvbosonWeight_EW2Up->FindBin(Z_Pt)); + BosonWeight_EW2Down = hZvvbosonWeight_EW2Down->GetBinContent(hZvvbosonWeight_EW2Down->FindBin(Z_Pt)); + BosonWeight_EW3Up = hZvvbosonWeight_EW3Up->GetBinContent(hZvvbosonWeight_EW3Up->FindBin(Z_Pt)); + BosonWeight_EW3Down = hZvvbosonWeight_EW3Down->GetBinContent(hZvvbosonWeight_EW3Down->FindBin(Z_Pt)); + BosonWeight_MixedUp = hZvvbosonWeight_MixedUp->GetBinContent(hZvvbosonWeight_MixedUp->FindBin(Z_Pt)); + BosonWeight_MixedDown = hZvvbosonWeight_MixedDown->GetBinContent(hZvvbosonWeight_MixedDown->FindBin(Z_Pt)); + BosonWeight_AlphaUp = hZvvbosonWeight_AlphaUp->GetBinContent(hZvvbosonWeight_AlphaUp->FindBin(Z_Pt)); + BosonWeight_AlphaDown = hZvvbosonWeight_AlphaDown->GetBinContent(hZvvbosonWeight_AlphaDown->FindBin(Z_Pt)); + BosonWeight_muRUp = hZvvbosonWeight_muRUp->GetBinContent(hZvvbosonWeight_muRUp->FindBin(Z_Pt)); + BosonWeight_muRDown = hZvvbosonWeight_muRDown->GetBinContent(hZvvbosonWeight_muRDown->FindBin(Z_Pt)); + BosonWeight_muFUp = hZvvbosonWeight_muFUp->GetBinContent(hZvvbosonWeight_muFUp->FindBin(Z_Pt)); + BosonWeight_muFDown = hZvvbosonWeight_muFDown->GetBinContent(hZvvbosonWeight_muFDown->FindBin(Z_Pt)); + } + else{ + BosonWeight_nominal = hZllbosonWeight_nominal->GetBinContent(hZllbosonWeight_nominal->FindBin(Z_Pt)); + BosonWeight_QCD1Up = hZllbosonWeight_QCD1Up->GetBinContent(hZllbosonWeight_QCD1Up->FindBin(Z_Pt)); + BosonWeight_QCD1Down = hZllbosonWeight_QCD1Down->GetBinContent(hZllbosonWeight_QCD1Down->FindBin(Z_Pt)); + BosonWeight_QCD2Up = hZllbosonWeight_QCD2Up->GetBinContent(hZllbosonWeight_QCD2Up->FindBin(Z_Pt)); + BosonWeight_QCD2Down = hZllbosonWeight_QCD2Down->GetBinContent(hZllbosonWeight_QCD2Down->FindBin(Z_Pt)); + BosonWeight_QCD3Up = hZllbosonWeight_QCD3Up->GetBinContent(hZllbosonWeight_QCD3Up->FindBin(Z_Pt)); + BosonWeight_QCD3Down = hZllbosonWeight_QCD3Down->GetBinContent(hZllbosonWeight_QCD3Down->FindBin(Z_Pt)); + BosonWeight_EW1Up = hZllbosonWeight_EW1Up->GetBinContent(hZllbosonWeight_EW1Up->FindBin(Z_Pt)); + BosonWeight_EW1Down = hZllbosonWeight_EW1Down->GetBinContent(hZllbosonWeight_EW1Down->FindBin(Z_Pt)); + BosonWeight_EW2Up = hZllbosonWeight_EW2Up->GetBinContent(hZllbosonWeight_EW2Up->FindBin(Z_Pt)); + BosonWeight_EW2Down = hZllbosonWeight_EW2Down->GetBinContent(hZllbosonWeight_EW2Down->FindBin(Z_Pt)); + BosonWeight_EW3Up = hZllbosonWeight_EW3Up->GetBinContent(hZllbosonWeight_EW3Up->FindBin(Z_Pt)); + BosonWeight_EW3Down = hZllbosonWeight_EW3Down->GetBinContent(hZllbosonWeight_EW3Down->FindBin(Z_Pt)); + BosonWeight_MixedUp = hZllbosonWeight_MixedUp->GetBinContent(hZllbosonWeight_MixedUp->FindBin(Z_Pt)); + BosonWeight_MixedDown = hZllbosonWeight_MixedDown->GetBinContent(hZllbosonWeight_MixedDown->FindBin(Z_Pt)); + BosonWeight_AlphaUp = hZllbosonWeight_AlphaUp->GetBinContent(hZllbosonWeight_AlphaUp->FindBin(Z_Pt)); + BosonWeight_AlphaDown = hZllbosonWeight_AlphaDown->GetBinContent(hZllbosonWeight_AlphaDown->FindBin(Z_Pt)); + BosonWeight_muRUp = hZllbosonWeight_muRUp->GetBinContent(hZllbosonWeight_muRUp->FindBin(Z_Pt)); + BosonWeight_muRDown = hZllbosonWeight_muRDown->GetBinContent(hZllbosonWeight_muRDown->FindBin(Z_Pt)); + BosonWeight_muFUp = hZllbosonWeight_muFUp->GetBinContent(hZllbosonWeight_muFUp->FindBin(Z_Pt)); + BosonWeight_muFDown = hZllbosonWeight_muFDown->GetBinContent(hZllbosonWeight_muFDown->FindBin(Z_Pt)); + } + } + else { + BosonWeight_nominal = 1; + BosonWeight_QCD1Up = 1; + BosonWeight_QCD1Down = 1; + BosonWeight_QCD2Up = 1; + BosonWeight_QCD2Down = 1; + BosonWeight_QCD3Up = 1; + BosonWeight_QCD3Down = 1; + BosonWeight_EW1Up = 1; + BosonWeight_EW1Down = 1; + BosonWeight_EW2Up = 1; + BosonWeight_EW2Down = 1; + BosonWeight_EW3Up = 1; + BosonWeight_EW3Down = 1; + BosonWeight_MixedUp = 1; + BosonWeight_MixedDown = 1; + BosonWeight_AlphaUp = 1; + BosonWeight_AlphaDown = 1; + BosonWeight_muRUp = 1; + BosonWeight_muRDown = 1; + BosonWeight_muFUp = 1; + BosonWeight_muFDown = 1; + } + } + vars.FillVar( "BosonWeight_nominal", BosonWeight_nominal ); + + vars.FillVar( "BosonWeight_QCD1Up", BosonWeight_QCD1Up ); + vars.FillVar( "BosonWeight_QCD1Down", BosonWeight_QCD1Down ); + vars.FillVar( "BosonWeight_QCD2Up", BosonWeight_QCD2Up ); + vars.FillVar( "BosonWeight_QCD2Down", BosonWeight_QCD2Down ); + vars.FillVar( "BosonWeight_QCD3Up", BosonWeight_QCD3Up ); + vars.FillVar( "BosonWeight_QCD3Down", BosonWeight_QCD3Down ); + + vars.FillVar( "BosonWeight_EW1Up", BosonWeight_EW1Up ); + vars.FillVar( "BosonWeight_EW1Down", BosonWeight_EW1Down ); + vars.FillVar( "BosonWeight_EW2Up", BosonWeight_EW2Up ); + vars.FillVar( "BosonWeight_EW2Down", BosonWeight_EW2Down ); + vars.FillVar( "BosonWeight_EW3Up", BosonWeight_EW3Up ); + vars.FillVar( "BosonWeight_EW3Down", BosonWeight_EW3Down ); + + vars.FillVar( "BosonWeight_MixedUp", BosonWeight_MixedUp ); + vars.FillVar( "BosonWeight_MixedDown", BosonWeight_MixedDown ); + vars.FillVar( "BosonWeight_AlphaUp", BosonWeight_AlphaUp ); + vars.FillVar( "BosonWeight_AlphaDown", BosonWeight_AlphaDown ); + + vars.FillVar( "BosonWeight_muRUp", BosonWeight_muRUp ); + vars.FillVar( "BosonWeight_muRDown", BosonWeight_muRDown ); + vars.FillVar( "BosonWeight_muFUp", BosonWeight_muFUp ); + vars.FillVar( "BosonWeight_muFDown", BosonWeight_muFDown ); + +} diff --git a/BoostedAnalyzer/src/GenEWevent.cpp b/BoostedAnalyzer/src/GenEWevent.cpp new file mode 100644 index 00000000..e4f70f66 --- /dev/null +++ b/BoostedAnalyzer/src/GenEWevent.cpp @@ -0,0 +1,156 @@ +#include "BoostedTTH/BoostedAnalyzer/interface/GenEWevent.hpp" +#include "BoostedTTH/BoostedAnalyzer/interface/BoostedUtils.hpp" + +// constructor +GenEWevent::GenEWevent() {} + +// destructor +GenEWevent::~GenEWevent() {} + +// take the given genparticle collections and save a copy of them as member variables +void GenEWevent::Initialize(std::vector prunedGenParticles_, std::vector packedGenParticles_) +{ + prunedGenParticles = prunedGenParticles_; + packedGenParticles = packedGenParticles_; + + isFilled = false; + + hasVectorBoson = false; + WBosonisFilled = false; + ZBosonisFilled = false; + + int n_decay_prods = 0; + + for(size_t i=0;i=2) hasVectorBoson = true; +} + +// return the prunedGenParticles collection +std::vector GenEWevent::ReturnPrunedGenParticles() const +{ + return prunedGenParticles; +} + +// return the packedGenParticles collection +std::vector GenEWevent::ReturnPackedGenParticles() const +{ + return packedGenParticles; +} + +// for MC reweighting of Z/W boson + jets events: save the pt of the generator v boson +void GenEWevent::FillBoson() +{ + if (not hasVectorBoson) { + //std::cout << "The Generator Event does not have a VectorBoson with PDGID 23 or 24 (Z/W)." << std::endl; + //std::cout << "Therefore, the Boson cannot be filled." << std::endl; + return; + } + std::vector decay_prodW; + std::vector decay_prodZ; + std::vector radiated_photons; + //std::cout << "doing Boson stuff" << std::endl; + //std::cout << "looping over " << prunedGenParticles.size() << " genParticles" << std::endl; + for (size_t i = 0; i < prunedGenParticles.size(); i++) { + const reco::GenParticle & genparticle = prunedGenParticles[i]; + + //Z Bosons + if ((abs(genparticle.pdgId()) == 12 or abs(genparticle.pdgId()) == 14 or abs(genparticle.pdgId()) == 16 or abs(genparticle.pdgId()) == 11 or abs(genparticle.pdgId()) == 13) and genparticle.isPromptFinalState()) { + decay_prodZ.push_back(genparticle); + } + + + //W Bosons + if ((abs(genparticle.pdgId()) == 11 or abs(genparticle.pdgId()) == 12 or abs(genparticle.pdgId()) == 13 or abs(genparticle.pdgId()) == 14) and genparticle.isPromptFinalState()) {//or abs(daughter->pdgId()) == 15 or abs(daughter->pdgId()) == 16 + decay_prodW.push_back(genparticle); + } + + if(abs(genparticle.pdgId())==22 and genparticle.status()==1 and !genparticle.statusFlags().isPrompt()) { + radiated_photons.push_back(genparticle); + } + } + + if (decay_prodW.size() == 2){ + // std::cout << "filling W Boson" << std::endl; + if((decay_prodW.at(0).pdgId())*(decay_prodW.at(1).pdgId())<0 and abs(abs(decay_prodW.at(0).pdgId())-abs(decay_prodW.at(1).pdgId()))==1){ + for(size_t k=0;k