From 5003277df2ee7203e245ff02ddca89fd5bc018e9 Mon Sep 17 00:00:00 2001 From: Ramkrishna Sharma Date: Thu, 8 Feb 2024 09:59:16 +0100 Subject: [PATCH] Update for 2l2nu and Bug fix for 2l2q channel (#9) * RoccoR with official nano-tools (#27) * RoccoRUpdate * Delete KalmanMuonCalibrationsProducer/data/roccor.Run2.v5 directory --------- Co-authored-by: yuji * # For 2l2nu channel - Added b-tagged jet info - Added VBF jets and VBF di-jet kinematics. Along with the VBF jet index # For 2l2q channel BUGFIX-1: Updated "jetidx.size()+1" with "jetidx.size()" to select di-jet BUBFIX-2: Jet index was wrong while accessing jets info when selecting based on mass BUGFIX-3: Also, fixed jet index that was saved in output branch * Added deltaPhi var for 2l2nu channel --------- Co-authored-by: YujiLee301 <99654114+YujiLee301@users.noreply.github.com> Co-authored-by: yuji --- H4LCppModule.py | 203 ++++++++++--- interface/H4LTools.h | 649 +++++++++++++++++++++-------------------- keep_and_drop.txt | 8 +- keep_and_drop_data.txt | 8 +- src/H4LTools.cc | 146 +++++++-- 5 files changed, 615 insertions(+), 399 deletions(-) diff --git a/H4LCppModule.py b/H4LCppModule.py index 3a8e041..fa10405 100644 --- a/H4LCppModule.py +++ b/H4LCppModule.py @@ -125,7 +125,15 @@ def beginFile(self, inputFile, outputFile, inputTree, wrappedOutputTree): self.out.branch("passZZ4lSelection", "O") self.out.branch("passZZ2l2qSelection", "O") self.out.branch("passZZ2l2nuSelection", "O") + self.out.branch("isBoosted2l2q", "O") + self.out.branch("boostedJet_PNScore", "F") + self.out.branch("boostedJet_Index", "I") + self.out.branch("resolvedJet1_Index", "I") + self.out.branch("resolvedJet2_Index", "I") + self.out.branch("nTightBtaggedJets", "I") + self.out.branch("nMediumBtaggedJets", "I") + self.out.branch("nLooseBtaggedJets", "I") # common branches for 4l, 2l2q, 2l2nu channels self.out.branch("massZ1", "F") @@ -178,6 +186,30 @@ def beginFile(self, inputFile, outputFile, inputTree, wrappedOutputTree): self.out.branch("pTZ2_met", "F") self.out.branch("EneZ2_met", "F") + # Branches for 2l2nu channel: VBF jets and dijet kinematics + self.out.branch("VBF_jet1_index", "I") + self.out.branch("VBF_jet2_index", "I") + self.out.branch("minDeltaPhi_METAK4jet", "F") + + # Branches for 2l2nu channel: VBF jets and dijet kinematics + self.out.branch("VBF_2l2nu_jet1_pT", "F") + self.out.branch("VBF_2l2nu_jet1_eta", "F") + self.out.branch("VBF_2l2nu_jet1_phi", "F") + self.out.branch("VBF_2l2nu_jet1_mass", "F") + + self.out.branch("VBF_2l2nu_jet2_pT", "F") + self.out.branch("VBF_2l2nu_jet2_eta", "F") + self.out.branch("VBF_2l2nu_jet2_phi", "F") + self.out.branch("VBF_2l2nu_jet2_mass", "F") + + self.out.branch("VBF_2l2nu_dijet_mass", "F") + self.out.branch("VBF_2l2nu_dijet_pT", "F") + self.out.branch("VBF_2l2nu_dijet_E", "F") + self.out.branch("VBF_2l2nu_dEta_jj", "F") + self.out.branch("VBF_2l2nu_dPhi_jj", "F") + self.out.branch("VBF_2l2nu_dR_jj", "F") + + self.out.branch("mj1", "F") self.out.branch("pTj1", "F") self.out.branch("etaj1", "F") @@ -248,6 +280,27 @@ def analyze(self, event): phiZ2_met = -999. pTZ2_met = -999. EneZ2_met = -999. + minDeltaPhi_METAK4jet = 999.0 + + VBF_jet1_index = -999 + VBF_jet2_index = -999 + + VBF_2l2nu_jet1_pT = -999. + VBF_2l2nu_jet1_eta = -999. + VBF_2l2nu_jet1_phi = -999. + VBF_2l2nu_jet1_mass = -999. + + VBF_2l2nu_jet2_pT = -999. + VBF_2l2nu_jet2_eta = -999. + VBF_2l2nu_jet2_phi = -999. + VBF_2l2nu_jet2_mass = -999. + + VBF_2l2nu_dijet_mass = -999. + VBF_2l2nu_dijet_pT = -999. + VBF_2l2nu_dijet_E = -999. + VBF_2l2nu_dEta_jj = -999. + VBF_2l2nu_dPhi_jj = -999. + VBF_2l2nu_dR_jj = -999. pTL1 = -999. etaL1 = -999. @@ -334,7 +387,7 @@ def analyze(self, event): for xf in fsrPhotons: self.worker.SetFsrPhotons(xf.dROverEt2,xf.eta,xf.phi,xf.pt,xf.relIso03) for xj in jets: - self.worker.SetJets(xj.pt,xj.eta,xj.phi,xj.mass,xj.jetId, xj.btagCSVV2, xj.puId) + self.worker.SetJets(xj.pt,xj.eta,xj.phi,xj.mass,xj.jetId, xj.btagDeepFlavB, xj.puId) for xj in FatJets: self.worker.SetFatJets(xj.pt, xj.eta, xj.phi, xj.msoftdrop, xj.jetId, xj.btagDeepB, xj.particleNet_ZvsQCD) @@ -351,55 +404,21 @@ def analyze(self, event): foundZZCandidate_2l2q = self.worker.ZZSelection_2l2q() foundZZCandidate_2l2nu = self.worker.ZZSelection_2l2nu() foundZZCandidate_4l = self.worker.ZZSelection_4l() + isBoosted2l2q = self.worker.isBoosted2l2q - #if ((self.worker.nTightEle + self.worker.nTightMu == 2) and (not self.worker.nTightMu == 1)): - # # This event should belong to either 2l2q or 2l2nu \ - # # nTightEle + nTightMu == 2 => 2l2q or 2l2nu => (2,0), (0,2), (1,1) - # # => Reject (1,1) combination: ( (nTightEle + nTightMu == 2) and (not nTightEle == 1)) - # # 2nd part is to avoid the situation where we get 1 electron and 1 muon - # print("====> met pt: {}, {}, {}".format(met.pt, met.phi, met.sumEt)) - # foundZZCandidate_2l2q = self.worker.ZZSelection_2l2q() - # foundZZCandidate_2l2nu = self.worker.ZZSelection_2l2nu() - # print("(2l2q, 2l2nu) = ({}, {})".format(foundZZCandidate_2l2q, foundZZCandidate_2l2nu)) - # #print("Inside the 2l2q loop: END") - - #elif (self.worker.nTightEle + self.worker.nTightMu >= 4): - ##if (self.worker.nTightEle + self.worker.nTightMu >= 4): - # # This event should belong to 4l; nTightEle + nTightMu >= 4 - # foundZZCandidate_4l = self.worker.ZZSelection_4l() - ##if (foundZZCandidate_2l2q and foundZZCandidate_2l2nu ): - # #print("both 2l2q and 2l2nu passed the MET selection") - # #exit() + boostedJet_PNScore = self.worker.boostedJet_PNScore + boostedJet_Index = self.worker.boostedJet_Index + resolvedJet1_Index = self.worker.resolvedJet1_Index + resolvedJet2_Index = self.worker.resolvedJet2_Index + VBF_jet1_index = self.worker.VBF_jet1_index + VBF_jet2_index = self.worker.VBF_jet2_index + minDeltaPhi_METAK4jet = self.worker.minDeltaPhi + nTightBtaggedJets = self.worker.nTightBtaggedJets + nMediumBtaggedJets = self.worker.nMediumBtaggedJets + nLooseBtaggedJets = self.worker.nLooseBtaggedJets - if (foundZZCandidate_2l2q): - keepIt = True - #print("Hello found 2l2q candidate") - passZZ2l2qSelection = True - #print(passZZ2l2qSelection) - passZZ4lSelection = False - self.passZZ2l2qEvts += 1 - # FatJet_PNZvsQCD = self.worker.FatJet_PNZvsQCD - # self.out.fillBranch("FatJet_PNZvsQCD",FatJet_PNZvsQCD) - massZ2_2j = self.worker.Z2_2j.M() #Anusree - phiZ2_2j = self.worker.Z2_2j.Phi() - etaZ2_2j = self.worker.Z2_2j.Eta() - pTZ2_2j = self.worker.Z2_2j.Pt() - EneZ2_2j = self.worker.Z2_2j.E() - - if (foundZZCandidate_2l2nu): - keepIt = True - passZZ2l2nuSelection = True - self.passZZ2l2nuEvts += 1 - # FatJet_PNZvsQCD = self.worker.FatJet_PNZvsQCD - # self.out.fillBranch("FatJet_PNZvsQCD",FatJet_PNZvsQCD) - phiZ2_met = self.worker.Z2_met.Phi() - pTZ2_met = self.worker.Z2_met.Pt() - EneZ2_met = self.worker.Z2_met.E() - #print("inside 2l2nu loop") - #self.out.fillBranch("phiZ2_met",phiZ2_met) - #self.out.fillBranch("pTZ2_met",pTZ2_met) - #self.out.fillBranch("EneZ2_met",EneZ2_met) + if self.DEBUG: print("isBoosted2l2q: ", isBoosted2l2q) if (foundZZCandidate_4l or foundZZCandidate_2l2q or foundZZCandidate_2l2nu): #print("inside loop 4l or 2l2q") @@ -419,15 +438,73 @@ def analyze(self, event): phiL1, phiL2 = phiL2, phiL1 massL1,massL2 = massL2, massL1 + # Kinematics of Z1: Obtained from pair of leptons with mass closest to Z mass pTZ1 = self.worker.Z1.Pt() etaZ1 = self.worker.Z1.Eta() phiZ1 = self.worker.Z1.Phi() massZ1 = self.worker.Z1.M() + + # Kinematics of Z2: Only for 4l and 2l2q channels + # For 2l2nu channel, Z2 kinematics are obtained from MET + # For 2l2q channel, Z2 represents the kinamatics of the boosted Z topology pTZ2 = self.worker.Z2.Pt() etaZ2 = self.worker.Z2.Eta() phiZ2 = self.worker.Z2.Phi() massZ2 = self.worker.Z2.M() + if (foundZZCandidate_2l2q): + keepIt = True + passZZ2l2qSelection = True + self.passZZ2l2qEvts += 1 + + massZ2_2j = self.worker.Z2_2j.M() + phiZ2_2j = self.worker.Z2_2j.Phi() + etaZ2_2j = self.worker.Z2_2j.Eta() + pTZ2_2j = self.worker.Z2_2j.Pt() + EneZ2_2j = self.worker.Z2_2j.E() + + if (foundZZCandidate_2l2nu): + keepIt = True + passZZ2l2nuSelection = True + self.passZZ2l2nuEvts += 1 + # FatJet_PNZvsQCD = self.worker.FatJet_PNZvsQCD + # self.out.fillBranch("FatJet_PNZvsQCD",FatJet_PNZvsQCD) + phiZ2_met = self.worker.Z2_met.Phi() + pTZ2_met = self.worker.Z2_met.Pt() + EneZ2_met = self.worker.Z2_met.E() + + # Define TLorentzVector for VBF jets and get dijet mass + if VBF_jet1_index>=0 and VBF_jet2_index>=0: + VBF_jet1 = ROOT.TLorentzVector() + VBF_jet2 = ROOT.TLorentzVector() + VBF_jet1.SetPtEtaPhiM(jets[VBF_jet1_index].pt, jets[VBF_jet1_index].eta, jets[VBF_jet1_index].phi, jets[VBF_jet1_index].mass) + VBF_jet2.SetPtEtaPhiM(jets[VBF_jet2_index].pt, jets[VBF_jet2_index].eta, jets[VBF_jet2_index].phi, jets[VBF_jet2_index].mass) + VBF_dijet = VBF_jet1 + VBF_jet2 + if self.DEBUG: print("in .py file: VBF_dijet_mass: ", VBF_dijet.M()) + + VBF_2l2nu_jet1_pT = jets[VBF_jet1_index].pt + VBF_2l2nu_jet1_eta = jets[VBF_jet1_index].eta + VBF_2l2nu_jet1_phi = jets[VBF_jet1_index].phi + VBF_2l2nu_jet1_mass = jets[VBF_jet1_index].mass + + VBF_2l2nu_jet2_pT = jets[VBF_jet2_index].pt + VBF_2l2nu_jet2_eta = jets[VBF_jet2_index].eta + VBF_2l2nu_jet2_phi = jets[VBF_jet2_index].phi + VBF_2l2nu_jet2_mass = jets[VBF_jet2_index].mass + + VBF_2l2nu_dijet_mass = VBF_dijet.M() + VBF_2l2nu_dijet_pT = VBF_dijet.Pt() + VBF_2l2nu_dijet_E = VBF_dijet.E() + + VBF_2l2nu_dEta_jj = abs(VBF_jet1.Eta() - VBF_jet2.Eta()) + VBF_2l2nu_dPhi_jj = abs(VBF_jet1.DeltaPhi(VBF_jet2)) + VBF_2l2nu_dR_jj = VBF_jet1.DeltaR(VBF_jet2) + + #print("inside 2l2nu loop") + #self.out.fillBranch("phiZ2_met",phiZ2_met) + #self.out.fillBranch("pTZ2_met",pTZ2_met) + #self.out.fillBranch("EneZ2_met",EneZ2_met) + if (foundZZCandidate_4l): keepIt = True self.passZZ4lEvts += 1 @@ -487,6 +564,27 @@ def analyze(self, event): self.out.fillBranch("phiZ2_met",phiZ2_met) self.out.fillBranch("pTZ2_met",pTZ2_met) self.out.fillBranch("EneZ2_met",EneZ2_met) + self.out.fillBranch("minDeltaPhi_METAK4jet", minDeltaPhi_METAK4jet) + + self.out.fillBranch("VBF_jet1_index", VBF_jet1_index) + self.out.fillBranch("VBF_jet2_index", VBF_jet2_index) + + self.out.fillBranch("VBF_2l2nu_jet1_pT", VBF_2l2nu_jet1_pT) + self.out.fillBranch("VBF_2l2nu_jet1_eta", VBF_2l2nu_jet1_eta) + self.out.fillBranch("VBF_2l2nu_jet1_phi", VBF_2l2nu_jet1_phi) + self.out.fillBranch("VBF_2l2nu_jet1_mass", VBF_2l2nu_jet1_mass) + + self.out.fillBranch("VBF_2l2nu_jet2_pT", VBF_2l2nu_jet2_pT) + self.out.fillBranch("VBF_2l2nu_jet2_eta", VBF_2l2nu_jet2_eta) + self.out.fillBranch("VBF_2l2nu_jet2_phi", VBF_2l2nu_jet2_phi) + self.out.fillBranch("VBF_2l2nu_jet2_mass", VBF_2l2nu_jet2_mass) + + self.out.fillBranch("VBF_2l2nu_dijet_mass", VBF_2l2nu_dijet_mass) + self.out.fillBranch("VBF_2l2nu_dijet_pT", VBF_2l2nu_dijet_pT) + self.out.fillBranch("VBF_2l2nu_dijet_E", VBF_2l2nu_dijet_E) + self.out.fillBranch("VBF_2l2nu_dEta_jj", VBF_2l2nu_dEta_jj) + self.out.fillBranch("VBF_2l2nu_dPhi_jj", VBF_2l2nu_dPhi_jj) + self.out.fillBranch("VBF_2l2nu_dR_jj", VBF_2l2nu_dR_jj) self.out.fillBranch("massZ2_2j",massZ2_2j) self.out.fillBranch("phiZ2_2j",phiZ2_2j) @@ -544,6 +642,17 @@ def analyze(self, event): self.out.fillBranch("passZZ4lSelection",passZZ4lSelection) self.out.fillBranch("passZZ2l2qSelection",passZZ2l2qSelection) self.out.fillBranch("passZZ2l2nuSelection",passZZ2l2nuSelection) + self.out.fillBranch("isBoosted2l2q",isBoosted2l2q) + + self.out.fillBranch("boostedJet_PNScore", boostedJet_PNScore) + self.out.fillBranch("boostedJet_Index", boostedJet_Index) + + self.out.fillBranch("resolvedJet1_Index",resolvedJet1_Index) + self.out.fillBranch("resolvedJet2_Index",resolvedJet2_Index) + + self.out.fillBranch("nTightBtaggedJets",nTightBtaggedJets) + self.out.fillBranch("nMediumBtaggedJets",nMediumBtaggedJets) + self.out.fillBranch("nLooseBtaggedJets",nLooseBtaggedJets) return keepIt diff --git a/interface/H4LTools.h b/interface/H4LTools.h index e81d890..798791a 100644 --- a/interface/H4LTools.h +++ b/interface/H4LTools.h @@ -10,18 +10,19 @@ #include "yaml-cpp/yaml.h" #include "../JHUGenMELA/MELA/interface/Mela.h" -class H4LTools { - public: - H4LTools(int year, bool DEBUG_Main); - float elePtcut, MuPtcut, eleEtacut, MuEtacut, elesip3dCut, Musip3dCut,Zmass,MZ1cut,MZcutup,MZcutdown,MZZcut,HiggscutUp,HiggscutDown; - float eleLoosedxycut,eleLoosedzcut,MuLoosedxycut,MuLoosedzcut,MuTightdxycut,MuTightdzcut,MuTightTrackerLayercut,MuTightpTErrorcut,MuHighPtBound,eleIsocut,MuIsocut; - float fsrphotonPtcut,fsrphotonEtacut,fsrphotonIsocut,fsrphotondRlcut,fsrphotondRlOverPtcut, JetPtcut,JetEtacut; - float eleBDTWPLELP,eleBDTWPMELP,eleBDTWPHELP,eleBDTWPLEHP,eleBDTWPMEHP,eleBDTWPHEHP; - float HZZ2l2q_Leading_Lep_pT, HZZ2l2q_SubLeading_Lep_pT, HZZ2l2q_Lep_eta, HZZ2l2q_MZLepcutdown, HZZ2l2q_MZLepcutup; - bool DEBUG; - - - void InitializeElecut(float elePtcut_,float eleEtacut_,float elesip3dCut_,float eleLoosedxycut_,float eleLoosedzcut_,float eleIsocut_,float eleBDTWPLELP_,float eleBDTWPMELP_, float eleBDTWPHELP_,float eleBDTWPLEHP_,float eleBDTWPMEHP_,float eleBDTWPHEHP_){ +class H4LTools +{ +public: + H4LTools(int year, bool DEBUG_Main); + float elePtcut, MuPtcut, eleEtacut, MuEtacut, elesip3dCut, Musip3dCut, Zmass, MZ1cut, MZcutup, MZcutdown, MZZcut, HiggscutUp, HiggscutDown; + float eleLoosedxycut, eleLoosedzcut, MuLoosedxycut, MuLoosedzcut, MuTightdxycut, MuTightdzcut, MuTightTrackerLayercut, MuTightpTErrorcut, MuHighPtBound, eleIsocut, MuIsocut; + float fsrphotonPtcut, fsrphotonEtacut, fsrphotonIsocut, fsrphotondRlcut, fsrphotondRlOverPtcut, JetPtcut, JetEtacut; + float eleBDTWPLELP, eleBDTWPMELP, eleBDTWPHELP, eleBDTWPLEHP, eleBDTWPMEHP, eleBDTWPHEHP; + float HZZ2l2q_Leading_Lep_pT, HZZ2l2q_SubLeading_Lep_pT, HZZ2l2q_Lep_eta, HZZ2l2q_MZLepcutdown, HZZ2l2q_MZLepcutup; + bool DEBUG; + + void InitializeElecut(float elePtcut_, float eleEtacut_, float elesip3dCut_, float eleLoosedxycut_, float eleLoosedzcut_, float eleIsocut_, float eleBDTWPLELP_, float eleBDTWPMELP_, float eleBDTWPHELP_, float eleBDTWPLEHP_, float eleBDTWPMEHP_, float eleBDTWPHEHP_) + { elePtcut = elePtcut_; eleEtacut = eleEtacut_; elesip3dCut = elesip3dCut_; @@ -34,18 +35,19 @@ class H4LTools { eleBDTWPLEHP = eleBDTWPLEHP_; eleBDTWPMEHP = eleBDTWPMEHP_; eleBDTWPHEHP = eleBDTWPHEHP_; - } + } - void Initialize2l2qEvtCut(float HZZ2l2q_Leading_Lep_pT_, float HZZ2l2q_SubLeading_Lep_pT_, float HZZ2l2q_Lep_eta_, float HZZ2l2q_MZLepcutdown_, float HZZ2l2q_MZLepcutup_) { + void Initialize2l2qEvtCut(float HZZ2l2q_Leading_Lep_pT_, float HZZ2l2q_SubLeading_Lep_pT_, float HZZ2l2q_Lep_eta_, float HZZ2l2q_MZLepcutdown_, float HZZ2l2q_MZLepcutup_) + { HZZ2l2q_Leading_Lep_pT = HZZ2l2q_Leading_Lep_pT_; HZZ2l2q_SubLeading_Lep_pT = HZZ2l2q_SubLeading_Lep_pT_; HZZ2l2q_Lep_eta = HZZ2l2q_Lep_eta_; HZZ2l2q_MZLepcutdown = HZZ2l2q_MZLepcutdown_; HZZ2l2q_MZLepcutup = HZZ2l2q_MZLepcutup_; - } + } - void InitializeMucut(float MuPtcut_, float MuEtacut_, float Musip3dCut_, float MuLoosedxycut_, float MuLoosedzcut_, float MuIsocut_, float MuTightdxycut_, float MuTightdzcut_, float MuTightTrackerLayercut_, float MuTightpTErrorcut_, float MuHighPtBound_) - { + void InitializeMucut(float MuPtcut_, float MuEtacut_, float Musip3dCut_, float MuLoosedxycut_, float MuLoosedzcut_, float MuIsocut_, float MuTightdxycut_, float MuTightdzcut_, float MuTightTrackerLayercut_, float MuTightpTErrorcut_, float MuHighPtBound_) + { MuPtcut = MuPtcut_; MuEtacut = MuEtacut_; Musip3dCut = Musip3dCut_; @@ -57,19 +59,22 @@ class H4LTools { MuTightTrackerLayercut = MuTightTrackerLayercut_; MuTightpTErrorcut = MuTightpTErrorcut_; MuHighPtBound = MuHighPtBound_; - } - void InitializeFsrPhotonCut(float fsrphotonPtcut_, float fsrphotonEtacut_, float fsrphotonIsocut_, float fsrphotondRlcut_, float fsrphotondRlOverPtcut_){ + } + void InitializeFsrPhotonCut(float fsrphotonPtcut_, float fsrphotonEtacut_, float fsrphotonIsocut_, float fsrphotondRlcut_, float fsrphotondRlOverPtcut_) + { fsrphotonPtcut = fsrphotonPtcut_; fsrphotonEtacut = fsrphotonEtacut_; fsrphotonIsocut = fsrphotonIsocut_; fsrphotondRlcut = fsrphotondRlcut_; fsrphotondRlOverPtcut = fsrphotondRlOverPtcut_; - } - void InitializeJetcut(float JetPtcut_, float JetEtacut_){ + } + void InitializeJetcut(float JetPtcut_, float JetEtacut_) + { JetPtcut = JetPtcut_; JetEtacut = JetEtacut_; - } - void InitializeEvtCut(float MZ1cut_,float MZZcut_,float HiggscutDown_,float HiggscutUp_,float Zmass_,float MZcutdown_, float MZcutup_){ + } + void InitializeEvtCut(float MZ1cut_, float MZZcut_, float HiggscutDown_, float HiggscutUp_, float Zmass_, float MZcutdown_, float MZcutup_) + { MZ1cut = MZ1cut_; MZZcut = MZZcut_; HiggscutDown = HiggscutDown_; @@ -77,10 +82,11 @@ class H4LTools { Zmass = Zmass_; MZcutdown = MZcutdown_; MZcutup = MZcutup_; - } + } - void SetElectrons(float Electron_pt_, float Electron_eta_, float Electron_phi_, float Electron_mass_, float Electron_dxy_,float Electron_dz_, - float Electron_sip3d_, float Electron_mvaFall17V2Iso_, int Electron_pdgId_, float Electron_pfRelIso03_all_){ + void SetElectrons(float Electron_pt_, float Electron_eta_, float Electron_phi_, float Electron_mass_, float Electron_dxy_, float Electron_dz_, + float Electron_sip3d_, float Electron_mvaFall17V2Iso_, int Electron_pdgId_, float Electron_pfRelIso03_all_) + { Electron_pt.push_back(Electron_pt_); Electron_phi.push_back(Electron_phi_); Electron_eta.push_back(Electron_eta_); @@ -91,22 +97,23 @@ class H4LTools { Electron_mvaFall17V2Iso.push_back(Electron_mvaFall17V2Iso_); Electron_pdgId.push_back(Electron_pdgId_); Electron_pfRelIso03_all.push_back(Electron_pfRelIso03_all_); - } + } - void SetJets(float Jet_pt_, float Jet_eta_, float Jet_phi_, float Jet_mass_, int Jet_jetId_, float Jet_btagDeepC_, - int Jet_puId_){ + void SetJets(float Jet_pt_, float Jet_eta_, float Jet_phi_, float Jet_mass_, int Jet_jetId_, float Jet_btagDeepFlavB_, + int Jet_puId_) + { Jet_pt.push_back(Jet_pt_); Jet_phi.push_back(Jet_phi_); Jet_eta.push_back(Jet_eta_); Jet_mass.push_back(Jet_mass_); - Jet_btagDeepC.push_back(Jet_btagDeepC_); + Jet_btagDeepFlavB.push_back(Jet_btagDeepFlavB_); Jet_jetId.push_back(Jet_jetId_); - Jet_puId.push_back(Jet_puId_); //1 or 0? - } + Jet_puId.push_back(Jet_puId_); // 1 or 0? + } - void SetFatJets(float Jet_pt_, float Jet_eta_, float Jet_phi_, float Jet_mass_, int Jet_jetId_, float Jet_btagDeepB_, - float Jet_PNZvsQCD_) - { + void SetFatJets(float Jet_pt_, float Jet_eta_, float Jet_phi_, float Jet_mass_, int Jet_jetId_, float Jet_btagDeepB_, + float Jet_PNZvsQCD_) + { FatJet_pt.push_back(Jet_pt_); FatJet_eta.push_back(Jet_eta_); FatJet_phi.push_back(Jet_phi_); @@ -114,21 +121,20 @@ class H4LTools { FatJet_jetId.push_back(Jet_jetId_); FatJet_btagDeepB.push_back(Jet_btagDeepB_); FatJet_PNZvsQCD.push_back(Jet_PNZvsQCD_); // 1 or 0? - } + } - void SetMET(float MET_pt_, float MET_phi_, float MET_sumEt_) - { + void SetMET(float MET_pt_, float MET_phi_, float MET_sumEt_) + { MET_pt = MET_pt_; MET_phi = MET_phi_; MET_sumEt = MET_sumEt_; -// std::cout<<"Inside header file: MET_sumEt = " << MET_sumEt_ << "\t" << MET_sumEt << std::endl; - } + // std::cout<<"Inside header file: MET_sumEt = " << MET_sumEt_ << "\t" << MET_sumEt << std::endl; + } - - void SetMuons(float Muon_pt_, float Muon_eta_, float Muon_phi_, float Muon_mass_, bool Muon_isGlobal_, bool Muon_isTracker_, - float Muon_dxy_, float Muon_dz_,float Muon_sip3d_, float Muon_ptErr_, - int Muon_nTrackerLayers_, bool Muon_isPFcand_, int Muon_pdgId_,int Muon_charge_, float Muon_pfRelIso03_all_ - ){ + void SetMuons(float Muon_pt_, float Muon_eta_, float Muon_phi_, float Muon_mass_, bool Muon_isGlobal_, bool Muon_isTracker_, + float Muon_dxy_, float Muon_dz_, float Muon_sip3d_, float Muon_ptErr_, + int Muon_nTrackerLayers_, bool Muon_isPFcand_, int Muon_pdgId_, int Muon_charge_, float Muon_pfRelIso03_all_) + { Muon_pt.push_back(Muon_pt_); Muon_phi.push_back(Muon_phi_); Muon_eta.push_back(Muon_eta_); @@ -144,161 +150,150 @@ class H4LTools { Muon_pdgId.push_back(Muon_pdgId_); Muon_charge.push_back(Muon_charge_); Muon_pfRelIso03_all.push_back(Muon_pfRelIso03_all_); + } - } - void SetMuonsGen(int Muon_genPartIdx_){ + void SetMuonsGen(int Muon_genPartIdx_) + { Muon_genPartIdx.push_back(Muon_genPartIdx_); - } - /*void SetMuons(TTreeReaderArray *Muon_pt_, TTreeReaderArray *Muon_eta_, - TTreeReaderArray *Muon_phi_, TTreeReaderArray *Muon_mass_, TTreeReaderArray *Muon_isGlobal_, TTreeReaderArray *Muon_isTracker_, - TTreeReaderArray *Muon_dxy_, TTreeReaderArray *Muon_dz_,TTreeReaderArray *Muon_sip3d_, TTreeReaderArray *Muon_ptErr_, - TTreeReaderArray *Muon_nTrackerLayers_, TTreeReaderArray *Muon_isPFcand_, TTreeReaderArray *Muon_pdgId_,TTreeReaderArray *Muon_charge_, TTreeReaderArray *Muon_pfRelIso03_all_, - TTreeReaderArray *Muon_genPartIdx_){ - Muon_pt = Muon_pt_; - Muon_phi = Muon_phi_; - Muon_eta = Muon_eta_; - Muon_mass = Muon_mass_; - Muon_isGlobal = Muon_isGlobal_; - Muon_isTracker = Muon_isTracker_; - Muon_dxy = Muon_dxy_; - Muon_dz = Muon_dz_; - Muon_sip3d = Muon_sip3d_; - Muon_ptErr = Muon_ptErr_; - Muon_nTrackerLayers = Muon_nTrackerLayers_; - Muon_isPFcand = Muon_isPFcand_; - Muon_pdgId = Muon_pdgId_; - Muon_charge = Muon_charge_; - Muon_pfRelIso03_all = Muon_pfRelIso03_all_; - Muon_genPartIdx = Muon_genPartIdx_; - }*/ - void SetFsrPhotons(float FsrPhoton_dROverEt2_, float FsrPhoton_eta_, - float FsrPhoton_phi_, float FsrPhoton_pt_, float FsrPhoton_relIso03_){ + } + + void SetFsrPhotons(float FsrPhoton_dROverEt2_, float FsrPhoton_eta_, + float FsrPhoton_phi_, float FsrPhoton_pt_, float FsrPhoton_relIso03_) + { FsrPhoton_dROverEt2.push_back(FsrPhoton_dROverEt2_); FsrPhoton_phi.push_back(FsrPhoton_phi_); FsrPhoton_eta.push_back(FsrPhoton_eta_); FsrPhoton_pt.push_back(FsrPhoton_pt_); FsrPhoton_relIso03.push_back(FsrPhoton_relIso03_); - } - /*void SetFsrPhotons(TTreeReaderArray *FsrPhoton_dROverEt2_, TTreeReaderArray *FsrPhoton_eta_, - TTreeReaderArray *FsrPhoton_phi_, TTreeReaderArray *FsrPhoton_pt_, - TTreeReaderArray *FsrPhoton_relIso03_){ - FsrPhoton_dROverEt2 = FsrPhoton_dROverEt2_; - FsrPhoton_phi = FsrPhoton_phi_; - FsrPhoton_eta = FsrPhoton_eta_; - FsrPhoton_pt = FsrPhoton_pt_; - FsrPhoton_relIso03 = FsrPhoton_relIso03_; - }*/ - void SetGenParts(float GenPart_pt_){ + } + + void SetGenParts(float GenPart_pt_) + { GenPart_pt.push_back(GenPart_pt_); - } - /*void SetGenParts(TTreeReaderArray *GenPart_pt_){ - GenPart_pt = GenPart_pt_; - }*/ - void SetObjectNum(unsigned nElectron_,unsigned nMuon_,unsigned nJet_,unsigned nFsrPhoton_){ + } + + void SetObjectNum(unsigned nElectron_, unsigned nMuon_, unsigned nJet_, unsigned nFsrPhoton_) + { nElectron = nElectron_; nMuon = nMuon_; nJet = nJet_; nFsrPhoton = nFsrPhoton_; - } - void SetObjectNumGen(unsigned nGenPart_){ + } + void SetObjectNumGen(unsigned nGenPart_) + { nGenPart = nGenPart_; - } - - std::vector goodLooseElectrons2012(); - std::vector goodLooseMuons2012(); - std::vector goodMuons2015_noIso_noPf(std::vector Muonindex); - std::vector goodElectrons2015_noIso_noBdt(std::vector Electronindex); - std::vector passTight_BDT_Id(); - std::vector passTight_Id(); - std::vector goodFsrPhotons(); - unsigned doFsrRecovery(TLorentzVector Lep); - std::vector BatchFsrRecovery(std::vector LepList); - std::vector ElectronFsr(); - std::vector MuonFsr(); - std::vector ElectronFsrPt(); - std::vector ElectronFsrEta(); - std::vector ElectronFsrPhi(); - std::vector MuonFsrPt(); - std::vector MuonFsrEta(); - std::vector MuonFsrPhi(); - std::vector SelectedJets(std::vector ele, std::vector mu); - std::vector SelectedFatJets(std::vector ele, std::vector mu); - - std::vector Zlist; - std::vector Zlistnofsr; - std::vector Zflavor; //mu->13, e->11 - std::vector Zlep1index; - std::vector Zlep2index; - std::vector Zlep1pt; // leading lepton from each Z boson - std::vector Zlep1eta; - std::vector Zlep1phi; - std::vector Zlep1mass; - std::vector Zlep1chg; - std::vector Zlep2pt; // subleading lepton from each Z boson - std::vector Zlep2eta; - std::vector Zlep2phi; - std::vector Zlep2mass; - std::vector Zlep2chg; - std::vector Zlep1ptNoFsr; - std::vector Zlep1etaNoFsr; - std::vector Zlep1phiNoFsr; - std::vector Zlep1massNoFsr; - std::vector Zlep2ptNoFsr; - std::vector Zlep2etaNoFsr; - std::vector Zlep2phiNoFsr; - std::vector Zlep2massNoFsr; - std::vector jetidx; - std::vector FatJetidx; - - int nTightEle; - int nTightMu; - int nTightEleChgSum; - int nTightMuChgSum; - bool flag4e; - bool flag4mu; - bool flag2e2mu; - - bool flag2e; - bool flag2mu; - bool flag2l; - bool flag2e_met; - bool flag2mu_met; - bool flag2l_met; - - void LeptonSelection(); - std::vector looseEle,looseMu,bestEle,bestMu, tighteleforjetidx, tightmuforjetidx; - std::vector Electronindex; - std::vector Muonindex; - std::vector AllEid; - std::vector AllMuid; - std::vector Elelist; - std::vector Mulist; - std::vector ElelistFsr; - std::vector MulistFsr; - std::vector Elechg; - std::vector Muchg; - std::vector Muiso,Eiso; - std::vector Eid; - std::vector muid; - - std::vector TightEleindex; - std::vector TightMuindex; - void Initialize() - { - looseEle.clear(); - looseMu.clear(); - bestEle.clear(); - bestMu.clear(); - tighteleforjetidx.clear(); - tightmuforjetidx.clear(); - Electronindex.clear(); - Muonindex.clear(); - AllEid.clear(); - AllMuid.clear(); - Elelist.clear(); - Mulist.clear(); - ElelistFsr.clear(); - MulistFsr.clear(); + } + + std::vector goodLooseElectrons2012(); + std::vector goodLooseMuons2012(); + std::vector goodMuons2015_noIso_noPf(std::vector Muonindex); + std::vector goodElectrons2015_noIso_noBdt(std::vector Electronindex); + std::vector passTight_BDT_Id(); + std::vector passTight_Id(); + std::vector goodFsrPhotons(); + unsigned doFsrRecovery(TLorentzVector Lep); + std::vector BatchFsrRecovery(std::vector LepList); + std::vector ElectronFsr(); + std::vector MuonFsr(); + std::vector ElectronFsrPt(); + std::vector ElectronFsrEta(); + std::vector ElectronFsrPhi(); + std::vector MuonFsrPt(); + std::vector MuonFsrEta(); + std::vector MuonFsrPhi(); + std::vector SelectedJets(std::vector ele, std::vector mu); + std::vector SelectedFatJets(std::vector ele, std::vector mu); + + std::vector Zlist; + std::vector Zlistnofsr; + std::vector Zflavor; // mu->13, e->11 + std::vector Zlep1index; + std::vector Zlep2index; + std::vector Zlep1pt; // leading lepton from each Z boson + std::vector Zlep1eta; + std::vector Zlep1phi; + std::vector Zlep1mass; + std::vector Zlep1chg; + std::vector Zlep2pt; // subleading lepton from each Z boson + std::vector Zlep2eta; + std::vector Zlep2phi; + std::vector Zlep2mass; + std::vector Zlep2chg; + std::vector Zlep1ptNoFsr; + std::vector Zlep1etaNoFsr; + std::vector Zlep1phiNoFsr; + std::vector Zlep1massNoFsr; + std::vector Zlep2ptNoFsr; + std::vector Zlep2etaNoFsr; + std::vector Zlep2phiNoFsr; + std::vector Zlep2massNoFsr; + std::vector jetidx; + std::vector FatJetidx; + + int nTightEle; + int nTightMu; + int nTightEleChgSum; + int nTightMuChgSum; + bool flag4e; + bool flag4mu; + bool flag2e2mu; + + bool isBoosted2l2q; + bool flag2e; + bool flag2mu; + bool flag2l; + bool flag2e_met; + bool flag2mu_met; + bool flag2l_met; + + // count number of tight, medium and loose b-tagged jets + // FIXME: For now these b-tag numbers are only for 2l2nu case + int nTightBtaggedJets; + int nMediumBtaggedJets; + int nLooseBtaggedJets; + float minDeltaPhi; + + float boostedJet_PNScore; + int boostedJet_Index; // Contains the inded of 2l2q case; the boosted jet index that satisfies the P/N score and pT cut>200 GeV; No mass cut + int resolvedJet1_Index; // Contains the index of 2l2q case; when paired using mass close to Z-boson mass + int resolvedJet2_Index; // Contains the index of 2l2q case; when paired using mass close to Z-boson mass + int VBF_jet1_index; // Contains the index of 2l2nu case + int VBF_jet2_index; + + void LeptonSelection(); + std::vector looseEle, looseMu, bestEle, bestMu, tighteleforjetidx, tightmuforjetidx; + std::vector Electronindex; + std::vector Muonindex; + std::vector AllEid; + std::vector AllMuid; + std::vector Elelist; + std::vector Mulist; + std::vector ElelistFsr; + std::vector MulistFsr; + std::vector Elechg; + std::vector Muchg; + std::vector Muiso, Eiso; + std::vector Eid; + std::vector muid; + + std::vector TightEleindex; + std::vector TightMuindex; + void Initialize() + { + looseEle.clear(); + looseMu.clear(); + bestEle.clear(); + bestMu.clear(); + tighteleforjetidx.clear(); + tightmuforjetidx.clear(); + Electronindex.clear(); + Muonindex.clear(); + AllEid.clear(); + AllMuid.clear(); + Elelist.clear(); + Mulist.clear(); + ElelistFsr.clear(); + MulistFsr.clear(); // Electron related variables nElectron = 0; @@ -350,7 +345,7 @@ class H4LTools { Jet_phi.clear(); Jet_eta.clear(); Jet_mass.clear(); - Jet_btagDeepC.clear(); + Jet_btagDeepFlavB.clear(); Jet_jetId.clear(); Jet_puId.clear(); FatJet_pt.clear(); @@ -431,7 +426,20 @@ class H4LTools { phij2 = -99; mj2 = -99; + nTightBtaggedJets = -999; + nMediumBtaggedJets = -999; + nLooseBtaggedJets = -999; + minDeltaPhi = 999.0; + + boostedJet_PNScore = -999.0; + boostedJet_Index = -999; + resolvedJet1_Index = -999; + resolvedJet2_Index = -999; + VBF_jet1_index = -999; + VBF_jet2_index = -999; + // Flags for various final states + isBoosted2l2q = false; flag4e = false; flag4mu = false; flag2e2mu = false; @@ -453,142 +461,137 @@ class H4LTools { ZZ_metsystem.SetPtEtaPhiM(0.0, 0.0, 0.0, 0.0); ZZ_2jsystemnofsr.SetPtEtaPhiM(0.0, 0.0, 0.0, 0.0); ZZ_metsystemnofsr.SetPtEtaPhiM(0.0, 0.0, 0.0, 0.0); - } - - bool isFSR=true; - unsigned int Zsize=0; - TSpline *spline_g4; - TSpline *spline_g2; - TSpline *spline_L1; - TSpline *spline_L1Zgs; - bool findZCandidate(); - bool ZZSelection_4l(); - bool ZZSelection_2l2q(); - bool ZZSelection_2l2nu(); - TLorentzVector Z1; - TLorentzVector Z1nofsr; - TLorentzVector Z2; - TLorentzVector Z2_2j; - TLorentzVector Z2_met; - TLorentzVector Z2nofsr; - TLorentzVector ZZsystem; - TLorentzVector ZZsystemnofsr; - TLorentzVector ZZ_2jsystem; - TLorentzVector ZZ_metsystem; - TLorentzVector ZZ_2jsystemnofsr; - TLorentzVector ZZ_metsystemnofsr; - - Mela* mela; - float me_0plus_JHU, me_qqZZ_MCFM, p0plus_m4l, bkg_m4l; - float D_bkg_kin, D_bkg, D_g4, D_g1g4, D_0m, D_CP, D_0hp, D_int, D_L1, D_L1_int, D_L1Zg, D_L1Zgint; - float D_bkg_kin_vtx_BS; - float p0minus_VAJHU, Dgg10_VAMCFM, pg1g4_VAJHU; - float p0plus_VAJHU, p_GG_SIG_ghg2_1_ghz1prime2_1E4_JHUGen, p_GG_SIG_ghg2_1_ghza1prime2_1E4_JHUGen, p_GG_SIG_ghg2_1_ghz1_1_ghza1prime2_1E4_JHUGen, p_GG_SIG_ghg2_1_ghz1_1_ghz1prime2_1E4_JHUGen, p_GG_SIG_ghg2_1_ghz1_1_ghz2_1_JHUGen, pDL1_VAJHU, pD_L1Zgint; //, p0plus_VAJHU; - float getDg4Constant(float ZZMass); - float getDg2Constant(float ZZMass); - float getDL1Constant(float ZZMass); - float getDL1ZgsConstant(float ZZMass); - - int cut2e_m40_180, cut2mu_m40_180, cut2l_m40_180; - int cutMETlt150; - int cutMETgt150; - int cut2l_met_m40_180, cut2e_met_m40_180, cut2mu_met_m40_180; - int cut2e, cut2mu, cut2l, cut2l1J, cut2l2j, cut2l1Jor2j, cut2l1met; - int cut2e_met, cut2mu_met, cut2l_met; - int cut4e, cut4mu, cut2e2mu, cutZZ4e, cutZZ4mu, cutZZ2e2mu, cutm4l4e, cutm4l4mu, cutm4l2e2mu, cutghost2e2mu, cutQCD2e2mu, cutLepPt2e2mu, cutghost4e, cutQCD4e, cutLepPt4e, cutghost4mu, cutQCD4mu, cutLepPt4mu; - float pTL1, etaL1, phiL1, massL1, pTL2, etaL2, phiL2, massL2, pTL3, etaL3, phiL3, massL3, pTL4, etaL4, phiL4, massL4; - float pTj1, etaj1, phij1, mj1, pTj2, etaj2, phij2, mj2; - - - - private: - std::vector Electron_pt,Electron_phi,Electron_eta,Electron_mass,Electron_dxy,Electron_dz,Electron_sip3d; - std::vector Electron_mvaFall17V2Iso,Electron_pfRelIso03_all; - std::vector Electron_pdgId; - - std::vector Jet_pt,Jet_phi,Jet_eta,Jet_mass,Jet_btagDeepC; - std::vector Jet_jetId,Jet_puId; - float MET_pt, MET_phi; - float MET_sumEt; - - std::vector FatJet_pt, FatJet_phi, FatJet_eta, FatJet_SDmass, FatJet_btagDeepB, FatJet_PNZvsQCD; - std::vector FatJet_jetId; - - std::vector Muon_pt,Muon_phi,Muon_eta,Muon_mass,Muon_dxy,Muon_dz,Muon_sip3d,Muon_ptErr,Muon_pfRelIso03_all; - std::vector Muon_nTrackerLayers,Muon_genPartIdx,Muon_pdgId,Muon_charge; - std::vector Muon_isTracker,Muon_isGlobal,Muon_isPFcand; - - std::vector FsrPhoton_dROverEt2,FsrPhoton_phi,FsrPhoton_pt,FsrPhoton_relIso03,FsrPhoton_eta; - - std::vector GenPart_pt; - - - unsigned nElectron,nMuon,nJet,nGenPart,nFsrPhoton; - - - + } + + bool isFSR = true; + unsigned int Zsize = 0; + TSpline *spline_g4; + TSpline *spline_g2; + TSpline *spline_L1; + TSpline *spline_L1Zgs; + bool findZCandidate(); + bool ZZSelection_4l(); + bool ZZSelection_2l2q(); + bool ZZSelection_2l2nu(); + TLorentzVector Z1; + TLorentzVector Z1nofsr; + TLorentzVector Z2; + TLorentzVector Z2_2j; + TLorentzVector Z2_met; + TLorentzVector Z2nofsr; + TLorentzVector ZZsystem; + TLorentzVector ZZsystemnofsr; + TLorentzVector ZZ_2jsystem; + TLorentzVector ZZ_metsystem; + TLorentzVector ZZ_2jsystemnofsr; + TLorentzVector ZZ_metsystemnofsr; + + Mela *mela; + float me_0plus_JHU, me_qqZZ_MCFM, p0plus_m4l, bkg_m4l; + float D_bkg_kin, D_bkg, D_g4, D_g1g4, D_0m, D_CP, D_0hp, D_int, D_L1, D_L1_int, D_L1Zg, D_L1Zgint; + float D_bkg_kin_vtx_BS; + float p0minus_VAJHU, Dgg10_VAMCFM, pg1g4_VAJHU; + float p0plus_VAJHU, p_GG_SIG_ghg2_1_ghz1prime2_1E4_JHUGen, p_GG_SIG_ghg2_1_ghza1prime2_1E4_JHUGen, p_GG_SIG_ghg2_1_ghz1_1_ghza1prime2_1E4_JHUGen, p_GG_SIG_ghg2_1_ghz1_1_ghz1prime2_1E4_JHUGen, p_GG_SIG_ghg2_1_ghz1_1_ghz2_1_JHUGen, pDL1_VAJHU, pD_L1Zgint; //, p0plus_VAJHU; + float getDg4Constant(float ZZMass); + float getDg2Constant(float ZZMass); + float getDL1Constant(float ZZMass); + float getDL1ZgsConstant(float ZZMass); + + int cut2e_m40_180, cut2mu_m40_180, cut2l_m40_180; + int cutMETlt150; + int cutMETgt150; + int cut2l_met_m40_180, cut2e_met_m40_180, cut2mu_met_m40_180; + int cut2e, cut2mu, cut2l, cut2l1J, cut2l2j, cut2l1Jor2j, cut2l1met; + int cut2e_met, cut2mu_met, cut2l_met; + int cut4e, cut4mu, cut2e2mu, cutZZ4e, cutZZ4mu, cutZZ2e2mu, cutm4l4e, cutm4l4mu, cutm4l2e2mu, cutghost2e2mu, cutQCD2e2mu, cutLepPt2e2mu, cutghost4e, cutQCD4e, cutLepPt4e, cutghost4mu, cutQCD4mu, cutLepPt4mu; + float pTL1, etaL1, phiL1, massL1, pTL2, etaL2, phiL2, massL2, pTL3, etaL3, phiL3, massL3, pTL4, etaL4, phiL4, massL4; + float pTj1, etaj1, phij1, mj1, pTj2, etaj2, phij2, mj2; + +private: + std::vector Electron_pt, Electron_phi, Electron_eta, Electron_mass, Electron_dxy, Electron_dz, Electron_sip3d; + std::vector Electron_mvaFall17V2Iso, Electron_pfRelIso03_all; + std::vector Electron_pdgId; + + std::vector Jet_pt, Jet_phi, Jet_eta, Jet_mass, Jet_btagDeepFlavB; + std::vector Jet_jetId, Jet_puId; + float MET_pt, MET_phi; + float MET_sumEt; + + std::vector FatJet_pt, FatJet_phi, FatJet_eta, FatJet_SDmass, FatJet_btagDeepB, FatJet_PNZvsQCD; + std::vector FatJet_jetId; + + std::vector Muon_pt, Muon_phi, Muon_eta, Muon_mass, Muon_dxy, Muon_dz, Muon_sip3d, Muon_ptErr, Muon_pfRelIso03_all; + std::vector Muon_nTrackerLayers, Muon_genPartIdx, Muon_pdgId, Muon_charge; + std::vector Muon_isTracker, Muon_isGlobal, Muon_isPFcand; + + std::vector FsrPhoton_dROverEt2, FsrPhoton_phi, FsrPhoton_pt, FsrPhoton_relIso03, FsrPhoton_eta; + + std::vector GenPart_pt; + + unsigned nElectron, nMuon, nJet, nGenPart, nFsrPhoton; }; -H4LTools::H4LTools(int year, bool DEBUG_Main){ - DEBUG = DEBUG_Main; - std::cout<<"year"<<" "<setCandidateDecayMode(TVar::CandidateDecay_ZZ); - TFile *gConstant_g4 = TFile::Open("CoupleConstantsForMELA/gConstant_HZZ2e2mu_g4.root"); - spline_g4 = (TSpline*) gConstant_g4->Get("sp_tgfinal_HZZ2e2mu_SM_over_tgfinal_HZZ2e2mu_g4"); - gConstant_g4->Close(); - delete gConstant_g4; - TFile *gConstant_g2 = TFile::Open("CoupleConstantsForMELA/gConstant_HZZ2e2mu_g2.root"); - spline_g2 = (TSpline*) gConstant_g2->Get("sp_tgfinal_HZZ2e2mu_SM_over_tgfinal_HZZ2e2mu_g2"); - gConstant_g2->Close(); - delete gConstant_g2; - TFile *gConstant_L1 = TFile::Open("CoupleConstantsForMELA/gConstant_HZZ2e2mu_L1.root"); - spline_L1 = (TSpline*) gConstant_L1->Get("sp_tgfinal_HZZ2e2mu_SM_over_tgfinal_HZZ2e2mu_L1"); - gConstant_L1->Close(); - delete gConstant_L1; - TFile *gConstant_L1Zgs = TFile::Open("CoupleConstantsForMELA/gConstant_HZZ2e2mu_L1Zgs.root"); - spline_L1Zgs = (TSpline*) gConstant_L1Zgs->Get("sp_tgfinal_HZZ2e2mu_SM_photoncut_over_tgfinal_HZZ2e2mu_L1Zgs"); - gConstant_L1Zgs->Close(); - delete gConstant_L1Zgs; - - cut2e2mu = 0; - cut4e = 0; - cut4mu = 0; - cutghost2e2mu = 0; - cutghost4e = 0; - cutghost4mu = 0; - cutLepPt2e2mu = 0; - cutLepPt4e = 0; - cutLepPt4mu = 0; - cutQCD2e2mu = 0; - cutQCD4e = 0; - cutQCD4mu = 0; - cutZZ2e2mu = 0; - cutZZ4e = 0; - cutZZ4mu = 0; - cutm4l2e2mu = 0; - cutm4l4e = 0; - cutm4l4mu = 0; - cutMETlt150 = 0; - cutMETgt150 = 0; - - cut2e = 0; - cut2mu = 0; - cut2l = 0; - cut2l1J = 0; - cut2l2j = 0; - cut2l1Jor2j = 0; - cut2e_m40_180 = 0; - cut2mu_m40_180 = 0; - cut2l_m40_180 = 0; - - cut2e_met = 0; - cut2mu_met = 0; - cut2l_met = 0; - cut2l_met_m40_180 = 0; - cut2e_met_m40_180 = 0; - cut2mu_met_m40_180 = 0; - cut2l1met = 0; +H4LTools::H4LTools(int year, bool DEBUG_Main) +{ + DEBUG = DEBUG_Main; + std::cout << "year" + << " " << year << std::endl; + mela = new Mela(13.0, 125.0, TVar::SILENT); + mela->setCandidateDecayMode(TVar::CandidateDecay_ZZ); + TFile *gConstant_g4 = TFile::Open("CoupleConstantsForMELA/gConstant_HZZ2e2mu_g4.root"); + spline_g4 = (TSpline *)gConstant_g4->Get("sp_tgfinal_HZZ2e2mu_SM_over_tgfinal_HZZ2e2mu_g4"); + gConstant_g4->Close(); + delete gConstant_g4; + TFile *gConstant_g2 = TFile::Open("CoupleConstantsForMELA/gConstant_HZZ2e2mu_g2.root"); + spline_g2 = (TSpline *)gConstant_g2->Get("sp_tgfinal_HZZ2e2mu_SM_over_tgfinal_HZZ2e2mu_g2"); + gConstant_g2->Close(); + delete gConstant_g2; + TFile *gConstant_L1 = TFile::Open("CoupleConstantsForMELA/gConstant_HZZ2e2mu_L1.root"); + spline_L1 = (TSpline *)gConstant_L1->Get("sp_tgfinal_HZZ2e2mu_SM_over_tgfinal_HZZ2e2mu_L1"); + gConstant_L1->Close(); + delete gConstant_L1; + TFile *gConstant_L1Zgs = TFile::Open("CoupleConstantsForMELA/gConstant_HZZ2e2mu_L1Zgs.root"); + spline_L1Zgs = (TSpline *)gConstant_L1Zgs->Get("sp_tgfinal_HZZ2e2mu_SM_photoncut_over_tgfinal_HZZ2e2mu_L1Zgs"); + gConstant_L1Zgs->Close(); + delete gConstant_L1Zgs; + + cut2e2mu = 0; + cut4e = 0; + cut4mu = 0; + cutghost2e2mu = 0; + cutghost4e = 0; + cutghost4mu = 0; + cutLepPt2e2mu = 0; + cutLepPt4e = 0; + cutLepPt4mu = 0; + cutQCD2e2mu = 0; + cutQCD4e = 0; + cutQCD4mu = 0; + cutZZ2e2mu = 0; + cutZZ4e = 0; + cutZZ4mu = 0; + cutm4l2e2mu = 0; + cutm4l4e = 0; + cutm4l4mu = 0; + cutMETlt150 = 0; + cutMETgt150 = 0; + + cut2e = 0; + cut2mu = 0; + cut2l = 0; + cut2l1J = 0; + cut2l2j = 0; + cut2l1Jor2j = 0; + cut2e_m40_180 = 0; + cut2mu_m40_180 = 0; + cut2l_m40_180 = 0; + + cut2e_met = 0; + cut2mu_met = 0; + cut2l_met = 0; + cut2l_met_m40_180 = 0; + cut2e_met_m40_180 = 0; + cut2mu_met_m40_180 = 0; + cut2l1met = 0; } #endif - diff --git a/keep_and_drop.txt b/keep_and_drop.txt index d4c1db1..807bcb5 100644 --- a/keep_and_drop.txt +++ b/keep_and_drop.txt @@ -21,11 +21,15 @@ keep HLT* keep Flag* # # +keep VBF* +keep is* +keep *Index +keep boosted* keep *4l keep *Z1 keep *Z2 -keep *Z2_2j -keep *Z2_met +keep *2j +keep *met keep *L1 keep *L2 keep *L3 diff --git a/keep_and_drop_data.txt b/keep_and_drop_data.txt index 4a2788b..457ee6a 100644 --- a/keep_and_drop_data.txt +++ b/keep_and_drop_data.txt @@ -21,11 +21,15 @@ keep HLT* keep Flag* # # +keep VBF* +keep is* +keep *Index +keep boosted* keep *4l keep *Z1 keep *Z2 -keep *Z2_2j -keep *Z2_met +keep *2j +keep *met keep *L1 keep *L2 keep *L3 diff --git a/src/H4LTools.cc b/src/H4LTools.cc index 0517a38..63456e1 100644 --- a/src/H4LTools.cc +++ b/src/H4LTools.cc @@ -1027,43 +1027,67 @@ bool H4LTools::ZZSelection_2l2q(){ if (FatJetidx.size() > 0 || jetidx.size()>=2) { - foundZZCandidate = true; - - - // std::cout << "Zlist size: " << Zlist.size() << std::endl; - // std::cout << "jetidx size: " << jetidx.size() << std::endl; - // std::cout << "FatJetidx size: " << FatJetidx.size() << std::endl; - if (FatJetidx.size() > 0) { + for (unsigned int i = 0; i < FatJetidx.size(); i++) + { + if (FatJet_PNZvsQCD[FatJetidx[i]] < 0.9) continue; + if (FatJet_pt[FatJetidx[i]] < 200.0) continue; + // if (FatJet_msoftdrop[FatJetidx[i]] < 40.0) continue; + // if (FatJet_msoftdrop[FatJetidx[i]] > 180.0) continue; - Z2.SetPtEtaPhiM(FatJet_pt[0], FatJet_eta[0], FatJet_phi[0], FatJet_SDmass[0]); + foundZZCandidate = true; + isBoosted2l2q = true; + cut2l1J++; + cut2l1Jor2j++; - TLorentzVector Z2_1;//AV - TLorentzVector Z2_2;//AV - if (jetidx.size() >= 1) - { - Z2_1.SetPtEtaPhiM(Jet_pt[0], Jet_eta[0], Jet_phi[0], Jet_mass[0]); - Z2_2.SetPtEtaPhiM(0.0, 0.0, 0.0, 0.0); + boostedJet_PNScore = FatJet_PNZvsQCD[FatJetidx[i]]; + boostedJet_Index = FatJetidx[i]; + + Z2.SetPtEtaPhiM(FatJet_pt[FatJetidx[i]], FatJet_eta[FatJetidx[i]], FatJet_phi[FatJetidx[i]], FatJet_SDmass[FatJetidx[i]]); } - if (jetidx.size() >= 2) + } + + // if (jetidx.size() >= 2 && isBoosted2l2q == false) // FIXME: Only for testing purposes; comment this line and uncomment the next line for real analysis + if (jetidx.size() >= 2) + { + foundZZCandidate = true; + if (Z2.M() < 40.0 || Z2.M() > 180) { - Z2_2.SetPtEtaPhiM(Jet_pt[1], Jet_eta[1], Jet_phi[1], Jet_mass[1]); + cut2l2j++; } - Z2_2j = Z2_1 + Z2_2; - - cut2l1J++; cut2l1Jor2j++; - } - else - { + TLorentzVector Z2_1; TLorentzVector Z2_2; Z2_1.SetPtEtaPhiM(Jet_pt[0], Jet_eta[0], Jet_phi[0], Jet_mass[0]); Z2_2.SetPtEtaPhiM(Jet_pt[1], Jet_eta[1], Jet_phi[1], Jet_mass[1]); Z2_2j = Z2_1 + Z2_2; - cut2l2j++; - cut2l1Jor2j++; + + // Select the two jets with mass closest to Z-boson mass + float mass_diff = 999.0; + for (unsigned int i = 0; i < jetidx.size(); i++) + { + for (unsigned int j = i+1; j < jetidx.size(); j++) // FIXME: Check if there should be +1 or not + { + TLorentzVector Z2_1; + TLorentzVector Z2_2; + Z2_1.SetPtEtaPhiM(Jet_pt[jetidx[i]], Jet_eta[jetidx[i]], Jet_phi[jetidx[i]], Jet_mass[jetidx[i]]); + Z2_2.SetPtEtaPhiM(Jet_pt[jetidx[j]], Jet_eta[jetidx[j]], Jet_phi[jetidx[j]], Jet_mass[jetidx[j]]); + TLorentzVector Z2_2j_temp = Z2_1 + Z2_2; + + if (fabs(Z2_2j_temp.M() - Zmass) < mass_diff) + { + mass_diff = fabs(Z2_2j_temp.M() - Zmass); + Z2 = Z2_2j_temp; + resolvedJet1_Index = jetidx[i]; + resolvedJet2_Index = jetidx[j]; + } + } + } + + if (DEBUG) + std::cout << "Z2: Mass based, pT based: " << Z2.Pt() << ", " << Z2_2j.Pt() << std::endl; } ZZsystem = Z1 + Z2; @@ -1173,7 +1197,7 @@ bool H4LTools::ZZSelection_2l2nu(){ cutMETgt150++; foundZZCandidate = true; - //jetidx = SelectedJets(tighteleforjetidx, tightmuforjetidx); + jetidx = SelectedJets(tighteleforjetidx, tightmuforjetidx); //FatJetidx = SelectedFatJets(tighteleforjetidx, tightmuforjetidx); Z2_met.SetPtEtaPhiE(MET_pt, 0, MET_phi, MET_pt); @@ -1185,6 +1209,78 @@ bool H4LTools::ZZSelection_2l2nu(){ float METZZ_met; METZZ_met = ZZ_metsystem.E(); + // count the number of tight, medium and loose b-tagged jets + for (unsigned int i = 0; i < jetidx.size(); i++) + { + if (Jet_btagDeepFlavB[jetidx[i]] > 0.7100) nTightBtaggedJets++; + if (Jet_btagDeepFlavB[jetidx[i]] > 0.2783) nMediumBtaggedJets++; + if (Jet_btagDeepFlavB[jetidx[i]] > 0.0490) nLooseBtaggedJets++; + } + + // Get Angle between MET and nearest good jet + for (unsigned int i = 0; i < jetidx.size(); i++) + { + float dPhi = fabs(TVector2::Phi_mpi_pi(Jet_phi[jetidx[i]] - MET_phi)); + if (dPhi < minDeltaPhi) + { + minDeltaPhi = dPhi; + } + } + + // Get VBF jets having dEta>4.0 and mjj>500 + // If there are more than one pair of VBF jets, select the pair with highest mjj + float VBF_jj_mjj = 0.0; + if (DEBUG) + std::cout << "Size of jets: " << jetidx.size() << std::endl; + for (unsigned int i = 0; i < jetidx.size(); i++) + { + for (unsigned int j = i+1; j < jetidx.size(); j++) + { + // std::cout << "Inside: i: " << i << ", j: " << j << std::endl; + TLorentzVector VBF_jet1; + TLorentzVector VBF_jet2; + VBF_jet1.SetPtEtaPhiM(Jet_pt[jetidx[i]], Jet_eta[jetidx[i]], Jet_phi[jetidx[i]], Jet_mass[jetidx[i]]); + VBF_jet2.SetPtEtaPhiM(Jet_pt[jetidx[j]], Jet_eta[jetidx[j]], Jet_phi[jetidx[j]], Jet_mass[jetidx[j]]); + TLorentzVector VBF_jj = VBF_jet1 + VBF_jet2; + + if (fabs(VBF_jet1.Eta() - VBF_jet2.Eta()) > 4.0 && VBF_jj.M() > 500.0) + { + if (VBF_jj.M() > VBF_jj_mjj) + { + VBF_jj_mjj = VBF_jj.M(); + VBF_jet1_index = jetidx[i]; + VBF_jet2_index = jetidx[j]; + if (DEBUG) + std::cout << "Inside: VBF_jj_mjj: " << VBF_jj_mjj << "\tVBF_jet1_index: " << VBF_jet1_index << "\tVBF_jet2_index: " << VBF_jet2_index << std::endl; + } + } + } + } + + if (jetidx.size() >= 2 && VBF_jet1_index >= 0 && VBF_jet2_index >= 0) + { + + TLorentzVector VBF_jet1; + TLorentzVector VBF_jet2; + VBF_jet1.SetPtEtaPhiM(Jet_pt[VBF_jet1_index], Jet_eta[VBF_jet1_index], Jet_phi[VBF_jet1_index], Jet_mass[VBF_jet1_index]); + VBF_jet2.SetPtEtaPhiM(Jet_pt[VBF_jet2_index], Jet_eta[VBF_jet2_index], Jet_phi[VBF_jet2_index], Jet_mass[VBF_jet2_index]); + TLorentzVector VBF_jj = VBF_jet1 + VBF_jet2; + if (DEBUG) + std::cout << "Outside: VBF_jj_mjj: " << VBF_jj.M() << "\tVBF_jet1_index: " << VBF_jet1_index << "\tVBF_jet2_index: " << VBF_jet2_index << std::endl; + } + + // // If there are VBF jets, set the kinematics of VBF jets + // if (VBF_jj_mjj > 0.0) + // { + // TLorentzVector VBF_jet1; + // TLorentzVector VBF_jet2; + // VBF_jet1.SetPtEtaPhiM(Jet_pt[VBF_jet1_index], Jet_eta[VBF_jet1_index], Jet_phi[VBF_jet1_index], Jet_mass[VBF_jet1_index]); + // VBF_jet2.SetPtEtaPhiM(Jet_pt[VBF_jet2_index], Jet_eta[VBF_jet2_index], Jet_phi[VBF_jet2_index], Jet_mass[VBF_jet2_index]); + // VBF_jj = VBF_jet1 + VBF_jet2; + + // cut2lMETVBF++; + // } + return foundZZCandidate; }