diff --git a/TopAnalysis/data/era2016Pbp/electronHLTEfficiencies.root b/TopAnalysis/data/era2016Pbp/electronHLTEfficiencies.root new file mode 100644 index 0000000000000000000000000000000000000000..bf9a6fc4c99d243ff33c0764b677c7f4a14af740 Binary files /dev/null and b/TopAnalysis/data/era2016Pbp/electronHLTEfficiencies.root differ diff --git a/TopAnalysis/data/era2016Pbp/electronIDEfficiencies.root b/TopAnalysis/data/era2016Pbp/electronIDEfficiencies.root new file mode 100644 index 0000000000000000000000000000000000000000..9924c8c29c8e5a568343dc85e5cb567972086735 Binary files /dev/null and b/TopAnalysis/data/era2016Pbp/electronIDEfficiencies.root differ diff --git a/TopAnalysis/data/era2016Pbp/electronIsoHFEffs.root b/TopAnalysis/data/era2016Pbp/electronIsoHFEffs.root new file mode 100644 index 0000000000000000000000000000000000000000..1dae49decdf4806e4ebd0d2311690d956b24f77d Binary files /dev/null and b/TopAnalysis/data/era2016Pbp/electronIsoHFEffs.root differ diff --git a/TopAnalysis/data/era2016Pbp/electronRECOEfficiencies.root b/TopAnalysis/data/era2016Pbp/electronRECOEfficiencies.root new file mode 100644 index 0000000000000000000000000000000000000000..6a3a5b0499dbb8ca7b3403b231c65eb0528dae95 Binary files /dev/null and b/TopAnalysis/data/era2016Pbp/electronRECOEfficiencies.root differ diff --git a/TopAnalysis/data/era2016Pbp/expTageff.root b/TopAnalysis/data/era2016Pbp/expTageff.root new file mode 100644 index 0000000000000000000000000000000000000000..6babe1912dcab086f23b42f4992c01afc0d2de86 Binary files /dev/null and b/TopAnalysis/data/era2016Pbp/expTageff.root differ diff --git a/TopAnalysis/data/era2016Pbp/genweights.root b/TopAnalysis/data/era2016Pbp/genweights.root new file mode 100644 index 0000000000000000000000000000000000000000..5f963faac8a9bad5b2449ad664be2aed44711e7b Binary files /dev/null and b/TopAnalysis/data/era2016Pbp/genweights.root differ diff --git a/TopAnalysis/data/era2016Pbp/muonEfficiencies.root b/TopAnalysis/data/era2016Pbp/muonEfficiencies.root new file mode 100644 index 0000000000000000000000000000000000000000..420d6f819b183698adfec92a3ab0ac7dde10f70e Binary files /dev/null and b/TopAnalysis/data/era2016Pbp/muonEfficiencies.root differ diff --git a/TopAnalysis/data/era2016Pbp/muonIsoHFEffs.root b/TopAnalysis/data/era2016Pbp/muonIsoHFEffs.root new file mode 100644 index 0000000000000000000000000000000000000000..1dae49decdf4806e4ebd0d2311690d956b24f77d Binary files /dev/null and b/TopAnalysis/data/era2016Pbp/muonIsoHFEffs.root differ diff --git a/TopAnalysis/data/era2016pPb/electronHLTEfficiencies.root b/TopAnalysis/data/era2016pPb/electronHLTEfficiencies.root new file mode 100644 index 0000000000000000000000000000000000000000..d319c1ea4b251bcb735e41823d21e510c3993209 Binary files /dev/null and b/TopAnalysis/data/era2016pPb/electronHLTEfficiencies.root differ diff --git a/TopAnalysis/data/era2016pPb/electronIDEfficiencies.root b/TopAnalysis/data/era2016pPb/electronIDEfficiencies.root new file mode 100644 index 0000000000000000000000000000000000000000..6275034bb6318e3be9024ef747b570bb972bebc2 Binary files /dev/null and b/TopAnalysis/data/era2016pPb/electronIDEfficiencies.root differ diff --git a/TopAnalysis/data/era2016pPb/electronIsoHFEffs.root b/TopAnalysis/data/era2016pPb/electronIsoHFEffs.root new file mode 100644 index 0000000000000000000000000000000000000000..1dae49decdf4806e4ebd0d2311690d956b24f77d Binary files /dev/null and b/TopAnalysis/data/era2016pPb/electronIsoHFEffs.root differ diff --git a/TopAnalysis/data/era2016pPb/electronRECOEfficiencies.root b/TopAnalysis/data/era2016pPb/electronRECOEfficiencies.root new file mode 100644 index 0000000000000000000000000000000000000000..c813121d46f5f7eb10b56af0a6f86fe2fde6390e Binary files /dev/null and b/TopAnalysis/data/era2016pPb/electronRECOEfficiencies.root differ diff --git a/TopAnalysis/data/era2016pPb/expTageff.root b/TopAnalysis/data/era2016pPb/expTageff.root new file mode 100644 index 0000000000000000000000000000000000000000..6babe1912dcab086f23b42f4992c01afc0d2de86 Binary files /dev/null and b/TopAnalysis/data/era2016pPb/expTageff.root differ diff --git a/TopAnalysis/data/era2016pPb/genweights.root b/TopAnalysis/data/era2016pPb/genweights.root new file mode 100644 index 0000000000000000000000000000000000000000..5f963faac8a9bad5b2449ad664be2aed44711e7b Binary files /dev/null and b/TopAnalysis/data/era2016pPb/genweights.root differ diff --git a/TopAnalysis/data/era2016pPb/muonEfficiencies.root b/TopAnalysis/data/era2016pPb/muonEfficiencies.root new file mode 100644 index 0000000000000000000000000000000000000000..420d6f819b183698adfec92a3ab0ac7dde10f70e Binary files /dev/null and b/TopAnalysis/data/era2016pPb/muonEfficiencies.root differ diff --git a/TopAnalysis/data/era2016pPb/muonIsoHFEffs.root b/TopAnalysis/data/era2016pPb/muonIsoHFEffs.root new file mode 100644 index 0000000000000000000000000000000000000000..1dae49decdf4806e4ebd0d2311690d956b24f77d Binary files /dev/null and b/TopAnalysis/data/era2016pPb/muonIsoHFEffs.root differ diff --git a/TopAnalysis/interface/LeptonEfficiencyWrapper.h b/TopAnalysis/interface/LeptonEfficiencyWrapper.h index 375aa96423cb394d18278357003a3a039c1f05e3..8dd14bd46d48f202b58073d6ebac8c069c413e51 100644 --- a/TopAnalysis/interface/LeptonEfficiencyWrapper.h +++ b/TopAnalysis/interface/LeptonEfficiencyWrapper.h @@ -21,6 +21,7 @@ class LeptonEfficiencyWrapper EffCorrection_t getTriggerCorrection(std::vector<Particle> &leptons,TString period = ""); EffCorrection_t getOfflineCorrection(int pdgId,float pt,float eta,TString period = ""); EffCorrection_t getOfflineCorrection(Particle lepton,TString period = ""); + EffCorrection_t getOfflineIsoHFCorrection(int pdgId,float hf); ~LeptonEfficiencyWrapper(); private: void init(TString era); diff --git a/TopAnalysis/src/LeptonEfficiencyWrapper.cc b/TopAnalysis/src/LeptonEfficiencyWrapper.cc index a59ae447d48571ee584d19ed1b19d431d3fa08b1..e313aff8601e557da1d87e2c86a8014ff2c8b2b0 100644 --- a/TopAnalysis/src/LeptonEfficiencyWrapper.cc +++ b/TopAnalysis/src/LeptonEfficiencyWrapper.cc @@ -38,7 +38,53 @@ void LeptonEfficiencyWrapper::init(TString era) lepEffH_["e_sel"]->SetDirectory(0); fIn->Close(); } + // 2016 pPb/Pbp dataset + else if(era.Contains("era2016pPb") || era.Contains("era2016Pbp")) + { + era_=2015; + TString lepEffUrl(era+"/muonEfficiencies.root"); + gSystem->ExpandPathName(lepEffUrl); + TFile *fIn=TFile::Open(lepEffUrl); + lepEffH_["m_sel"]=(TH2 *)fIn->Get("m_sel"); + lepEffH_["m_sel"]->SetDirectory(0); + lepEffH_["m_singleleptrig"]=(TH2 *)fIn->Get("m_trig"); + lepEffH_["m_singleleptrig"]->SetDirectory(0); + fIn->Close(); + + lepEffUrl=era+"/muonIsoHFEffs.root"; + gSystem->ExpandPathName(lepEffUrl); + fIn=TFile::Open(lepEffUrl); + lepEffGr_["m_isoHF"]=(TGraphAsymmErrors *)fIn->Get("Graph"); + fIn->Close(); + lepEffUrl=era+"/electronRECOEfficiencies.root"; + gSystem->ExpandPathName(lepEffUrl); + fIn=TFile::Open(lepEffUrl); + lepEffH_["e_reco"]=(TH2 *)fIn->Get("EGamma_SF2D"); + lepEffH_["e_reco"]->SetDirectory(0); + fIn->Close(); + + lepEffUrl=era+"/electronIDEfficiencies.root"; + gSystem->ExpandPathName(lepEffUrl); + fIn=TFile::Open(lepEffUrl); + lepEffH_["e_sel"]=(TH2 *)fIn->Get("EGamma_SF2D"); + lepEffH_["e_sel"]->SetDirectory(0); + fIn->Close(); + + lepEffUrl=era+"/electronHLTEfficiencies.root"; + gSystem->ExpandPathName(lepEffUrl); + fIn=TFile::Open(lepEffUrl); + lepEffH_["e_singleleptrig"]=(TH2 *)fIn->Get("EGamma_SF2D")->Clone(); + lepEffH_["e_singleleptrig"]->SetDirectory(0); + fIn->Close(); + + lepEffUrl=era+"/electronIsoHFEffs.root"; + gSystem->ExpandPathName(lepEffUrl); + fIn=TFile::Open(lepEffUrl); + lepEffGr_["e_isoHF"]=(TGraphAsymmErrors *)fIn->Get("Graph"); + fIn->Close(); + + } //2016 dataset else if(era.Contains("era2016")) { @@ -317,8 +363,26 @@ EffCorrection_t LeptonEfficiencyWrapper::getOfflineCorrection(int pdgId,float pt corr.second = sqrt(pow(tkEffSFUnc*corr.first,2)+pow(tkEffSF*corr.second,2)); corr.first = corr.first*tkEffSF; } + + //reco efficiency (if available) + hname=idstr+"_reco"; + if(lepEffH_.find(hname)!=lepEffH_.end() ) + { + TH2 *h=lepEffH_[hname]; + float minEtaForEff( h->GetXaxis()->GetXmin() ), maxEtaForEff( h->GetXaxis()->GetXmax()-0.01 ); + float etaForEff=TMath::Max(TMath::Min(float(fabs(eta)),maxEtaForEff),minEtaForEff); + Int_t etaBinForEff=h->GetXaxis()->FindBin(etaForEff); + + float minPtForEff( h->GetYaxis()->GetXmin() ), maxPtForEff( h->GetYaxis()->GetXmax()-0.01 ); + float ptForEff=TMath::Max(TMath::Min(pt,maxPtForEff),minPtForEff); + Int_t ptBinForEff=h->GetYaxis()->FindBin(ptForEff); + + corr.second = sqrt(pow(h->GetBinError(etaBinForEff,ptBinForEff)*corr.first,2)+pow(h->GetBinError(etaBinForEff,ptBinForEff)*corr.second,2)); + corr.first = corr.first*h->GetBinContent(etaBinForEff,ptBinForEff); + + } } - + return corr; } @@ -337,6 +401,24 @@ EffCorrection_t LeptonEfficiencyWrapper::getTriggerCorrection(std::vector<int> & return getTriggerCorrection(lepParts, period); } +EffCorrection_t LeptonEfficiencyWrapper::getOfflineIsoHFCorrection(int pdgId,float hf) +{ + EffCorrection_t corr(1.0,0.0); + + //update correction from graph, if found + TString idstr(abs(pdgId)==11 ? "e" : "m"); + TString hname(idstr); + hname+="_isoHF"; + if(lepEffGr_.find(hname)!=lepEffGr_.end()) + { + corr.second = 0; + corr.first = lepEffGr_[hname]->Eval(hf); + } + + + return corr; +} + LeptonEfficiencyWrapper::~LeptonEfficiencyWrapper() { //for(auto& it : lepEffH_) it.second->Delete(); diff --git a/TopAnalysis/src/TOP-pPb.cc b/TopAnalysis/src/TOP-pPb.cc index 142595dcdeceddfdac49cd60d55b25a607c6461e..290ad018d48b5ae539c704c40d22f5361aa935f6 100644 --- a/TopAnalysis/src/TOP-pPb.cc +++ b/TopAnalysis/src/TOP-pPb.cc @@ -98,6 +98,10 @@ void RunToppPb(TString inFileName, std::map<TString,TH1 *> histos; histos["wgtcounter"] = new TH1F("wgtcounter",";Weight;Events;",200,0,200); histos["fidcounter"] = new TH1F("fidcounter",";Weight;Events;",200,0,200); + histos["recocounter"] = new TH1F("recocounter",";Step;Events;",8, 1,9); + TString step[8] = {"Initial", "Trigger", "#req 1Lepton", "#equiv 1Lepton", "#req 4jets","#req 1 b-tags","#equiv 1 b-tag", "#equiv 2btag"}; + for (int i=1; i < histos["recocounter"]->GetNbinsX()+1; i++) + histos["recocounter"]->GetXaxis()->SetBinLabel(i,step[i-1]); histos["trig"] = new TH1F("trig",";Trigger;Events",2,0,2); histos["lpt"] = new TH1F("lpt",";Transverse momentum [GeV];Events",20.,0.,200.); histos["leta"] = new TH1F("leta",";Pseudo-rapidity;Events",20.,0.,2.1); @@ -385,6 +389,7 @@ void RunToppPb(TString inFileName, UInt_t run_, lumi_; ULong64_t evt_; Int_t hiBin_; + Float_t hiHFplus_, hiHFminus_, hiHFplusEta4_, hiHFminusEta4_; Float_t vz_; Float_t weight; std::vector<float> *ttbar_w_p=0; @@ -393,6 +398,10 @@ void RunToppPb(TString inFileName, hiTree_p->SetBranchStatus("evt", 1); hiTree_p->SetBranchStatus("lumi", 1); hiTree_p->SetBranchStatus("hiBin", 1); + hiTree_p->SetBranchAddress("hiHFplus", &hiHFplus_); + hiTree_p->SetBranchAddress("hiHFminus", &hiHFminus_); + hiTree_p->SetBranchAddress("hiHFplusEta4", &hiHFplusEta4_); + hiTree_p->SetBranchAddress("hiHFminusEta4", &hiHFminusEta4_); hiTree_p->SetBranchStatus("vz", 1); hiTree_p->SetBranchStatus("weight", 1); hiTree_p->SetBranchStatus("ttbar_w",1); @@ -448,7 +457,7 @@ void RunToppPb(TString inFileName, printf("\r [%d/%d] done",entry,nEntries); cout << flush; } - + histos["recocounter"]->Fill(1); //reset summary tree ljev.nj=0; ljev.ngj=0; ljev.ngp=0; ljev.nb=0; ljev.l_id=0; ljev.w=0; ljev.npt=0; @@ -567,6 +576,7 @@ void RunToppPb(TString inFileName, histos["trig"]->Fill(trig,evWeight); if(!isMC && trig==0) continue; + histos["recocounter"]->Fill(2); //select good muons //cf. details in https://twiki.cern.ch/twiki/bin/view/CMS/SWGuideMuonIdRun2 @@ -768,13 +778,17 @@ void RunToppPb(TString inFileName, if(channelSelection==1300) { if(tightMuonsNonIso.size()==0) continue; + histos["recocounter"]->Fill(3); if(tightMuons.size()+looseMuons.size()+mediumElectrons.size()+vetoElectrons.size()!=0) continue; + histos["recocounter"]->Fill(4); tightMuons=tightMuonsNonIso; } if(channelSelection==13) { if(tightMuons.size()!=1) continue; //=1 tight muon + histos["recocounter"]->Fill(3); if(looseMuons.size()+mediumElectrons.size()+vetoElectrons.size()!=0) continue; //no extra leptons + histos["recocounter"]->Fill(4); if(chargeSelection!=0) { if(muonCharge[0]!=chargeSelection) continue; @@ -782,11 +796,12 @@ void RunToppPb(TString inFileName, } //electrons EffCorrection_t eselSF(1.0,0.0); - /* if(channelSelection==1100) { if(mediumElectronsFailId.size()==0) continue; + histos["recocounter"]->Fill(3); if(mediumElectrons.size()+vetoElectrons.size()+tightMuons.size()+looseMuons.size()!=0) continue; + histos["recocounter"]->Fill(4); mediumElectrons=mediumElectronsFailId; //from Georgios studies, endcap electron fakes would still benefit from a ~15% extra weight @@ -795,7 +810,9 @@ void RunToppPb(TString inFileName, if(channelSelection==11) { if(mediumElectrons.size()!=1) continue; //=1 medium electron + histos["recocounter"]->Fill(3); if(vetoElectrons.size()+tightMuons.size()+looseMuons.size()!=0) continue; //no extra leptons + histos["recocounter"]->Fill(4); if(chargeSelection!=0) { if(elCharge[0]!=chargeSelection) continue; @@ -806,7 +823,7 @@ void RunToppPb(TString inFileName, eselSF.second=sqrt(pow(0.03,2)+pow(eselSF.second,2)); evWeight*=eselSF.first; } - */ + // combined leptons std::vector<TLorentzVector> goodLeptons; @@ -1001,6 +1018,14 @@ void RunToppPb(TString inFileName, Int_t njets(nljets+nbtags); if(nljets<2) continue; + if (njets>=4) + histos["recocounter"]->Fill(5); + if (njets>=4&&nbtags>=1) + histos["recocounter"]->Fill(6); + if (njets>=4&&nbtags==1) + histos["recocounter"]->Fill(7); + if (njets>=4&&nbtags==2) + histos["recocounter"]->Fill(8); TString pf(Form("%db",TMath::Min(nbtags,2))); //jet-related quantities