metVector = ROOT.TLorentzVector() metVector.SetPtEtaPhiM(theChain.met,0.0,theChain.metphi,0.0) if theChain.gen_match_2 != 5: correctedTauVector = tauVector elif theChain.gen_match_2 == 5: if theChain.l2_decayMode == 0: correctedTauVector = tauVector * (1.0 - 0.011) elif theChain.l2_decayMode == 1: correctedTauVector = tauVector * (1.0 - 0.009) elif theChain.l2_decayMode == 10 or theChain.l2_decayMode == 11: correctedTauVector = tauVector * (1.0 - 0.008) correctedMETVector = GetCorrectedMetVector(tauVector,correctedTauVector,metVector) theBranch.BranchValue[0] = correctedMETVector.Phi() #2016 branches TES_E_UP_2016Branch = Branch.UserBranch() TES_E_UP_2016Branch.Name = "TES_E_UP" TES_E_UP_2016Branch.CalculateValue = CalculateTES_E_UP_2016 TES_E_DOWN_2016Branch = Branch.UserBranch() TES_E_DOWN_2016Branch.Name = "TES_E_DOWN" TES_E_DOWN_2016Branch.CalculateValue = CalculateTES_E_DOWN_2016 TES_PT_UP_2016Branch = Branch.UserBranch() TES_PT_UP_2016Branch.Name = "TES_Pt_UP" TES_PT_UP_2016Branch.CalculateValue = CalculateTES_PT_UP_2016 TES_PT_DOWN_2016Branch = Branch.UserBranch() TES_PT_DOWN_2016Branch.Name = "TES_Pt_DOWN" TES_PT_DOWN_2016Branch.CalculateValue = CalculateTES_PT_DOWN_2016
import ConfigDefinitions.BranchAdditions.BranchDef as Branch import ROOT def CalculateFiducial(theBranch, theChain): theBranch.BranchValue[0] = 0.0 FiducialBranch = Branch.UserBranch() FiducialBranch.Name = "is_Fiducial" FiducialBranch.CalculateValue = CalculateFiducial
import ConfigDefinitions.BranchAdditions.BranchDef as Branch import ROOT def CalculateVisibleMass(theBranch, theChain): muVector = ROOT.TLorentzVector() tauVector = ROOT.TLorentzVector() muVector.SetPtEtaPhiM(theChain.pt_1, theChain.eta_1, theChain.phi_1, theChain.m_1) tauVector.SetPtEtaPhiM(theChain.pt_2, theChain.eta_2, theChain.phi_2, theChain.m_2) theBranch.BranchValue[0] = (muVector + tauVector).M() VisibleMassBranch = Branch.UserBranch() VisibleMassBranch.Name = "m_vis" VisibleMassBranch.CalculateValue = CalculateVisibleMass
import ConfigDefinitions.BranchAdditions.BranchDef as Branch import ROOT def CalculateHiggsPhi(theBranch, theChain): muVector = ROOT.TLorentzVector() tauVector = ROOT.TLorentzVector() metVector = ROOT.TLorentzVector() muVector.SetPtEtaPhiM(theChain.pt_1, theChain.eta_1, theChain.phi_1, theChain.m_1) tauVector.SetPtEtaPhiM(theChain.pt_2, theChain.eta_2, theChain.phi_2, theChain.m_2) metVector.SetPtEtaPhiM(theChain.met, 0.0, theChain.metphi, 0.0) theBranch.BranchValue[0] = (muVector + tauVector + metVector).Phi() HiggsPhiBranch = Branch.UserBranch() HiggsPhiBranch.Name = "HiggsPhi" HiggsPhiBranch.CalculateValue = CalculateHiggsPhi
import ConfigDefinitions.BranchAdditions.BranchDef as Branch import ROOT def CalculateDR(theBranch,theChain): muVector = ROOT.TLorentzVector() tauVector = ROOT.TLorentzVector() muVector.SetPtEtaPhiM(theChain.pt_1,theChain.eta_1,theChain.phi_1,theChain.m_1) tauVector.SetPtEtaPhiM(theChain.pt_2,theChain.eta_2,theChain.phi_2,theChain.m_2) theBranch.BranchValue[0] = muVector.DeltaR(tauVector) DeltaRBranch = Branch.UserBranch() DeltaRBranch.Name = "DeltaR" DeltaRBranch.CalculateValue = CalculateDR
#and TheChain.matchMu27_1 and TheChain.matchEmbFilter_Mu27_1 and TheChain.pt_1 > 25.0): TheBranch.BranchValue[0] = 1.0 else: TheBranch.BranchValue[0] = 0.0 def CalculateTrigger2027(TheBranch, TheChain): if (TheChain.pt_1 > 21 and TheChain.pt_2 > 32 and TheChain.pt_1 < 25 # and abs(TheChain.eta_1) < 2.1 and abs(TheChain.eta_2) < 2.1 #and TheChain.matchEmbFilter_Mu20Tau27_1 #and TheChain.matchEmbFilter_Mu20Tau27_2 ): TheBranch.BranchValue[0] = 1.0 else: TheBranch.BranchValue[0] = 0.0 Trigger24 = Branch.UserBranch() Trigger24.Name = "Trigger24" Trigger24.CalculateValue = CalculateTrigger24 Trigger27 = Branch.UserBranch() Trigger27.Name = "Trigger27" Trigger27.CalculateValue = CalculateTrigger27 Trigger2027 = Branch.UserBranch() Trigger2027.Name = "Trigger2027" Trigger2027.CalculateValue = CalculateTrigger2027
#configuration for creating met UES Up Branches import ConfigDefinitions.BranchAdditions.BranchDef as Branch import ROOT def CalculateMET_UESUp(TheBranch, TheChain): pass Met_UESUp_Branch = Branch.UserBranch() Met_UESUp_Branch.Name = "met_UESUp" Met_UESUp_Branch.CalculateMET_UESUp
theBranch.BranchValue[0] = correctedMETVector.Phi() def CalculateMES_METPhi_DOWN(theBranch,theChain): tauVector = ROOT.TLorentzVector() tauVector.SetPtEtaPhiM(theChain.pt_2,theChain.eta_2,theChain.phi_2,theChain.m_2) metVector = ROOT.TLorentzVector() metVector.SetPtEtaPhiM(theChain.met,0.0,theChain.metphi,0.0) if not(theChain.gen_match_2 == 2 or theChain.gen_match_2 == 4): correctedTauVector = tauVector else: correctedTauVector = tauVector * (1.0 - 0.010) correctedMETVector = GetCorrectedMetVector(tauVector,correctedTauVector,metVector) theBranch.BranchValue[0] = correctedMETVector.Phi() EES_E_UP_Branch = Branch.UserBranch() EES_E_UP_Branch.Name = "EES_E_UP" EES_E_UP_Branch.CalculateValue = CalculateEES_E_UP EES_E_DOWN_Branch = Branch.UserBranch() EES_E_DOWN_Branch.Name = "EES_E_DOWN" EES_E_DOWN_Branch.CalculateValue = CalculateEES_E_DOWN EES_Pt_UP_Branch = Branch.UserBranch() EES_Pt_UP_Branch.Name = "EES_Pt_UP" EES_Pt_UP_Branch.CalculateValue = CalculateEES_Pt_UP EES_Pt_DOWN_Branch = Branch.UserBranch() EES_Pt_DOWN_Branch.Name = "EES_Pt_DOWN" EES_Pt_DOWN_Branch.CalculateValue = CalculateEES_Pt_DOWN
correctedMuVector = muVector * (1.0 - 0.027) elif (muVector.Eta() >= -2.1 and muVector.Eta() < -1.2): correctedMuVector = muVector * (1.0 - 0.009) elif (muVector.Eta() >= -1.2 and muVector.Eta() < 1.2): correctedMuVector = muVector * (1.0 - 0.004) elif (muVector.Eta() >= 1.2 and muVector.Eta() < 2.1): correctedMuVector = muVector * (1.0 - 0.009) elif (muVector.Eta() >= 2.1 and muVector.Eta() < 2.4): correctedMuVector = muVector * (1.0 - 0.017) correctedMETVector = GetCorrectedMetVector(muVector, correctedMuVector, metVector) theBranch.BranchValue[0] = correctedMETVector.Phi() muonES_E_UP_Branch = Branch.UserBranch() muonES_E_UP_Branch.Name = "muonES_E_UP" muonES_E_UP_Branch.CalculateValue = CreateMuonES_E_UP muonES_E_DOWN_Branch = Branch.UserBranch() muonES_E_DOWN_Branch.Name = "muonES_E_DOWN" muonES_E_DOWN_Branch.CalculateValue = CreateMuonES_E_DOWN muonES_Pt_UP_Branch = Branch.UserBranch() muonES_Pt_UP_Branch.Name = "muonES_Pt_UP" muonES_Pt_UP_Branch.CalculateValue = CreateMuonES_Pt_UP muonES_Pt_DOWN_Branch = Branch.UserBranch() muonES_Pt_DOWN_Branch.Name = "muonES_Pt_DOWN" muonES_Pt_DOWN_Branch.CalculateValue = CreateMuonES_Pt_DOWN
import os currentLocation = os.path.dirname(__file__) def CalculateDifferentialHiggsPt(theBranch, theChain): muVector = ROOT.TLorentzVector() tauVector = ROOT.TLorentzVector() metVector = ROOT.TLorentzVector() muVector.SetPtEtaPhiM(theChain.pt_1, theChain.eta_1, theChain.phi_1, theChain.m_1) tauVector.SetPtEtaPhiM(theChain.pt_2, theChain.eta_2, theChain.phi_2, theChain.m_2) metVector.SetPtEtaPhiM(theChain.met, 0.0, theChain.metphi, 0.0) higgsVector = (muVector + tauVector + metVector) correctedPTH = higgsVector.Pt() * theBranch.correctionFunction.Eval( higgsVector.Pt()) if correctedPTH < 0: correctedPTH = 0.5 theBranch.BranchValue[0] = correctedPTH differentialHiggsPtBranch = Branch.UserBranch() differentialHiggsPtBranch.Name = "HiggsPt_Differential" differentialHiggsPtBranch.correctionFile = ROOT.TFile( os.path.join(currentLocation, "RootFiles/pthcorrection_et.root")) differentialHiggsPtBranch.correctionFunction = differentialHiggsPtBranch.correctionFile.Get( "pth_correction") differentialHiggsPtBranch.CalculateValue = CalculateDifferentialHiggsPt
import ConfigDefinitions.BranchAdditions.BranchDef as Branch import ROOT import math def CalculateHiggsPt(theBranch, theChain): muVector = ROOT.TLorentzVector() tauVector = ROOT.TLorentzVector() metVector = ROOT.TLorentzVector() muVector.SetPtEtaPhiM(theChain.pt_1, theChain.eta_1, theChain.phi_1, theChain.m_1) tauVector.SetPtEtaPhiM(theChain.pt_2, theChain.eta_2, theChain.phi_2, theChain.m_2) metVector.SetPtEtaPhiM(theChain.met, 0.0, theChain.metphi, 0.0) theBranch.BranchValue[0] = (muVector + tauVector + metVector).Pt() HiggsPtBranch = Branch.UserBranch() HiggsPtBranch.Name = "HiggsPt" HiggsPtBranch.CalculateValue = CalculateHiggsPt
import ConfigDefinitions.BranchAdditions.BranchDef as Branch import ROOT def CalculateHiggsMass(theBranch,theChain): muVector = ROOT.TLorentzVector() tauVector = ROOT.TLorentzVector() metVector = ROOT.TLorentzVector() muVector.SetPtEtaPhiM(theChain.pt_1,theChain.eta_1,theChain.phi_1,theChain.m_1) tauVector.SetPtEtaPhiM(theChain.pt_2,theChain.eta_2,theChain.phi_2,theChain.m_2) metVector.SetPtEtaPhiM(theChain.met,0.0,theChain.metphi,0.0) theBranch.BranchValue[0] = (muVector+tauVector+metVector).M() HiggsMassBranch = Branch.UserBranch() HiggsMassBranch.Name = "HiggsMass" HiggsMassBranch.CalculateValue = CalculateHiggsMass
import ConfigDefinitions.BranchAdditions.BranchDef as Branch import ROOT def CalculateVisiblePt(theBranch, theChain): muVector = ROOT.TLorentzVector() tauVector = ROOT.TLorentzVector() muVector.SetPtEtaPhiM(theChain.pt_1, theChain.eta_1, theChain.phi_1, theChain.m_1) tauVector.SetPtEtaPhiM(theChain.pt_2, theChain.eta_2, theChain.phi_2, theChain.m_2) theBranch.BranchValue[0] = (muVector + tauVector).Pt() VisiblePtBranch = Branch.UserBranch() VisiblePtBranch.Name = 'VisiblePt' VisiblePtBranch.CalculateValue = CalculateVisiblePt
and TheChain.matchMu19Tau20_1 and TheChain.matchMu19Tau20_2 and TheChain.filterMu19Tau20_1 and TheChain.filterMu19Tau20_2 ) or ( TheChain.passMu19Tau20SingleL1 and TheChain.matchMu19Tau20SingleL1_1 and TheChain.matchMu19Tau20SingleL1_2 and TheChain.filterMu19Tau20SingleL1_1 and TheChain.filterMu19Tau20SingleL1_2 ) ) # no muon filter and TheChain.matchEmbFilter_Mu19Tau20_2 ): TheBranch.BranchValue[0] = 1.0 else: TheBranch.BranchValue[0] = 0.0 Trigger22 = Branch.UserBranch() Trigger22.Name = "Trigger22" Trigger22.CalculateValue = CalculateTrigger22 Trigger1920 = Branch.UserBranch() Trigger1920.Name = "Trigger1920" Trigger1920.CalculateValue = CalculateTrigger1920
#Create and attach a calculation of transverse mass to the chain import ConfigDefinitions.BranchAdditions.BranchDef as Branch import math def CalculateMT(TheBranch,TheChain): TheBranch.BranchValue[0] = math.sqrt(2.0*TheChain.pt_1*TheChain.met*(1.0-math.cos(abs(TheChain.phi_1-TheChain.metphi)))) MTBranch = Branch.UserBranch() MTBranch.Name = "MT" MTBranch.CalculateValue = CalculateMT
import ConfigDefinitions.BranchAdditions.BranchDef as Branch import ROOT def CalculateHiggsEta(theBranch, theChain): muVector = ROOT.TLorentzVector() tauVector = ROOT.TLorentzVector() metVector = ROOT.TLorentzVector() muVector.SetPtEtaPhiM(theChain.pt_1, theChain.eta_1, theChain.phi_1, theChain.m_1) tauVector.SetPtEtaPhiM(theChain.pt_2, theChain.eta_2, theChain.phi_2, theChain.m_2) metVector.SetPtEtaPhiM(theChain.met, 0.0, theChain.metphi, 0.0) theBranch.BranchValue[0] = (muVector + tauVector + metVector).Eta() HiggsEtaBranch = Branch.UserBranch() HiggsEtaBranch.Name = "HiggsEta" HiggsEtaBranch.CalculateValue = CalculateHiggsEta
import ConfigDefinitions.BranchAdditions.BranchDef as Branch import ROOT def CalculateVisiblePhi(theBranch, theChain): muVector = ROOT.TLorentzVector() tauVector = ROOT.TLorentzVector() muVector.SetPtEtaPhiM(theChain.pt_1, theChain.eta_1, theChain.phi_1, theChain.m_1) tauVector.SetPtEtaPhiM(theChain.pt_2, theChain.eta_2, theChain.phi_2, theChain.m_2) theBranch.BranchValue[0] = (muVector + tauVector).Phi() VisiblePhiBranch = Branch.UserBranch() VisiblePhiBranch.Name = 'VisiblePhi' VisiblePhiBranch.CalculateValue = CalculateVisiblePhi
import ConfigDefinitions.BranchAdditions.BranchDef as Branch import ROOT def CalculateVisibleEta(theBranch, theChain): muVector = ROOT.TLorentzVector() tauVector = ROOT.TLorentzVector() muVector.SetPtEtaPhiM(theChain.pt_1, theChain.eta_1, theChain.phi_1, theChain.m_1) tauVector.SetPtEtaPhiM(theChain.pt_2, theChain.eta_2, theChain.phi_2, theChain.m_2) theBranch.BranchValue[0] = (muVector + tauVector).Eta() VisibleEtaBranch = Branch.UserBranch() VisibleEtaBranch.Name = 'VisibleEta' VisibleEtaBranch.CalculateValue = CalculateVisibleEta
import ConfigDefinitions.BranchAdditions.BranchDef as Branch import ROOT def CalculateRivetMjj(theBranch, theChain): Rivet_mjj = -1.0 jetOneVector = ROOT.TLorentzVector() jetTwoVector = ROOT.TLorentzVector() if theChain.Rivet_nJets30 > 1: jetOneVector.SetPtEtaPhiM(theChain.Rivet_j1pt, theChain.Rivet_j1eta, theChain.Rivet_j1phi, theChain.Rivet_j1m) jetTwoVector.SetPtEtaPhiM(theChain.Rivet_j2pt, theChain.Rivet_j2eta, theChain.Rivet_j2phi, theChain.Rivet_j2m) Rivet_mjj = (jetOneVector + jetTwoVector).M() theBranch.BranchValue[0] = Rivet_mjj RivetMjjBranch = Branch.UserBranch() RivetMjjBranch.Name = "Rivet_mjj" RivetMjjBranch.CalculateValue = CalculateRivetMjj