Skip to content

Commit

Permalink
Bug fix and condor improvement (#13)
Browse files Browse the repository at this point in the history
* Removed transfer file from condor as now we don't have any files to transfer

* Now condor job will take arguments from txt file instead of many jdl files ram1123#51

* Update .write method to file instead of multi-string now just using one string using """

* As yaml-cpp is not available on el7 container so now cloe the yaml-cpp package and build it to remove the official dependencies. This solves Issue ram1123#54

* - Fix the ele eta cut for barrel and endcap transition
- Added the print statement under debug condition
- Added all high mass 2l2nu signal sample

* Changing the setup to work with EL9 ram1123#56

* Added variables to yml file for studying Di and single lepton triggers. (ram1123#57)

* Added variables to yml file for studying Di and single lepton triggers.

* Added leptons high pT triggers

---------

Co-authored-by: skeshri <[email protected]>

* Update condor script

* Fixed the library issue and nanohadd script fix for python2 to 3 shift

* Update condor job script

* Added output Dir option when running locally

* BugFix: Condor resubmit script is adapted as per the changes made for improving condor script ram1123#51 ram1123#56

---------

Co-authored-by: skeshri <[email protected]>
Co-authored-by: skeshri <[email protected]>
  • Loading branch information
3 people authored Aug 26, 2024
1 parent e1b6bb2 commit 81fee6c
Show file tree
Hide file tree
Showing 22 changed files with 974 additions and 249 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# Ignore root files
*.tgz
*.xml
*.1
*.png
Expand Down Expand Up @@ -168,3 +169,6 @@ br.sm2
*maincc
*linkdef.h
JHUGenMELA/
cutFlow.json
yaml-cpp/
nanoAOD_skim.wiki/
83 changes: 43 additions & 40 deletions GenVarsProducer.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

class GenVarsProducer(Module):
def __init__(self):
DEBUG = False
pass
def beginJob(self):
pass
Expand Down Expand Up @@ -47,7 +48,7 @@ def beginFile(self, inputFile, outputFile, inputTree, wrappedOutputTree):
def endFile(self, inputFile, outputFile, inputTree, wrappedOutputTree):
pass
def getParentID(self,particle,genParticles):
if particle.genPartIdxMother is -1: #No parent in record, return ID of original particle
if particle.genPartIdxMother == -1: #No parent in record, return ID of original particle
return particle.pdgId
elif genParticles[particle.genPartIdxMother].pdgId is particle.pdgId: #'Parent' is self, keep iterating
return self.getParentID(genParticles[particle.genPartIdxMother],genParticles)
Expand All @@ -60,7 +61,7 @@ def analyze(self, event):
genmet = Object(event, "GenMET", None)
GenMET_pt = None
GenMET_pt = genmet.pt
#print("GenMET_pt: {}".format(GenMET_pt))
self.DEBUG: print("GenMET_pt: {}".format(GenMET_pt))
# Loop over gen particles to find Higgs and its each respective decay products. Then keep all kinematics information of Higgs and its respective decay products along with its PDG ID and status flag.

higgs = None
Expand All @@ -82,43 +83,43 @@ def analyze(self, event):
neutrino2_pz = 0.0
delta_pz_neutrino = 0.0
pz1 = 0.0
print("length of genParticles: {}".format(len(genParticles)))

self.DEBUG: print("length of genParticles: {}".format(len(genParticles)))
for idx, particle in enumerate(genParticles):
print("DEBUG - line 70: Index: {}, Particle pdgID: {}, Parent ID: {}, MotherIdx: {}, Status: {}".format(idx, particle.pdgId, self.getParentID(particle, genParticles), particle.genPartIdxMother, particle.statusFlags >> 13 & 1))
self.DEBUG: print("DEBUG - line 70: Index: {}, Particle pdgID: {}, Parent ID: {}, MotherIdx: {}, Status: {}".format(idx, particle.pdgId, self.getParentID(particle, genParticles), particle.genPartIdxMother, particle.statusFlags >> 13 & 1))

if particle.pdgId == 25 and (particle.statusFlags >> 13 & 1):
higgs = particle
print("DEBUG - line 74 (found higgs): Index: {}, Particle ID: {}, MotherIdx: {}, Parent ID: {}, Status: {}".format(idx, particle.pdgId, self.getParentID(particle, genParticles), particle.genPartIdxMother, particle.statusFlags >> 13 & 1))
self.DEBUG: print("DEBUG - line 74 (found higgs): Index: {}, Particle ID: {}, MotherIdx: {}, Parent ID: {}, Status: {}".format(idx, particle.pdgId, self.getParentID(particle, genParticles), particle.genPartIdxMother, particle.statusFlags >> 13 & 1))

elif (abs(particle.pdgId) == 23) and (particle.statusFlags >> 13 & 1) and self.getParentID(particle, genParticles) == 25:
print("DEBUG - line 76 (found Z boson, daughter of higgs): Index: {}, Particle ID: {}, Parent ID: {}, MotherIdx: {}, Status: {}".format(idx, particle.pdgId, self.getParentID(particle, genParticles), particle.genPartIdxMother, particle.statusFlags >> 13 & 1))
self.DEBUG: print("DEBUG - line 76 (found Z boson, daughter of higgs): Index: {}, Particle ID: {}, Parent ID: {}, MotherIdx: {}, Status: {}".format(idx, particle.pdgId, self.getParentID(particle, genParticles), particle.genPartIdxMother, particle.statusFlags >> 13 & 1))

if v1 is None or v2 is None:
v1_daughters = []
v2_daughters = []
for daughter1 in genParticles:
if abs(daughter1.pdgId) in [11, 13, 15] and daughter1.genPartIdxMother == idx and self.getParentID(daughter1, genParticles) == 23 and daughter1.statusFlags >> 13 & 1:
v1 = particle
found_Z1 = True
print("DEBUG - line 81 (found Z1 boson, daughter of higgs): Index: {}, Particle ID: {}, Parent ID: {}, MotherIdx: {}, Status: {}".format(idx, v1.pdgId, self.getParentID(v1, genParticles), v1.genPartIdxMother, v1.statusFlags >> 13 & 1))
self.DEBUG: print("DEBUG - line 81 (found Z1 boson, daughter of higgs): Index: {}, Particle ID: {}, Parent ID: {}, MotherIdx: {}, Status: {}".format(idx, v1.pdgId, self.getParentID(v1, genParticles), v1.genPartIdxMother, v1.statusFlags >> 13 & 1))
v1_daughters.append(daughter1)
#elif temp_boson is None:
#temp_boson = particle
#if v2 is None:
#v2 = temp_boson
#v2_daughters.append(daughter1)
n = len(v1_daughters)
n = len(v1_daughters)
if len(v1_daughters) == 2:
for i in range(n):
v1_decay_products = v1_daughters
print("DEBUG - line 92 ( 2 daughters of Z1 boson): Index: {}, Particle ID: {}, Parent ID: {}, MotherIdx: {}, Status: {}".format(idx, v1_decay_products[i].pdgId, self.getParentID(v1_decay_products[i], genParticles), v1_decay_products[i].genPartIdxMother, v1_decay_products[i].statusFlags >> 13 & 1))
self.DEBUG: print("DEBUG - line 92 ( 2 daughters of Z1 boson): Index: {}, Particle ID: {}, Parent ID: {}, MotherIdx: {}, Status: {}".format(idx, v1_decay_products[i].pdgId, self.getParentID(v1_decay_products[i], genParticles), v1_decay_products[i].genPartIdxMother, v1_decay_products[i].statusFlags >> 13 & 1))

#m = len(v2_daughters)
#if len(v2_daughters) == 2:
#for i in range(m):
#v1_decay_products = v1_daughters
#print("DEBUG - line 108 ( 2 daughters of Z2 boson): Index: {}, Particle ID: {}, Parent ID: {}, MotherIdx: {}, Status: {}".format(idx, v2_decay_products[i].pdgId, self.getParentID(v2_decay_products[i], genParticles), v2_decay_products[i].genPartIdxMother, v2_decay_products[i].statusFlags >> 13 & 1))
#self.DEBUG: print("DEBUG - line 108 ( 2 daughters of Z2 boson): Index: {}, Particle ID: {}, Parent ID: {}, MotherIdx: {}, Status: {}".format(idx, v2_decay_products[i].pdgId, self.getParentID(v2_decay_products[i], genParticles), v2_decay_products[i].genPartIdxMother, v2_decay_products[i].statusFlags >> 13 & 1))
#elif abs(v1_daughters[0].pdgId) in [1, 2, 3, 4, 5] and abs(v1_daughters[1].pdgId) in [1, 2, 3, 4, 5]:
#v1_decay_products = v1_daughters
#if v2 is None:
Expand All @@ -129,7 +130,7 @@ def analyze(self, event):
if abs(daughter2.pdgId) in [12, 14, 16] and daughter2.genPartIdxMother == idx and self.getParentID(daughter2, genParticles) == 23 and daughter2.statusFlags >> 13 & 1:
v2 = particle
found_Z2 = True
print("DEBUG - line 115 (found Z2 boson, daughter of higgs): Index: {}, Particle ID: {}, Parent ID: {}, MotherIdx: {}, Status: {}".format(idx, v2.pdgId, self.getParentID(v2, genParticles), v2.genPartIdxMother, v2.statusFlags >> 13 & 1))
self.DEBUG: print("DEBUG - line 115 (found Z2 boson, daughter of higgs): Index: {}, Particle ID: {}, Parent ID: {}, MotherIdx: {}, Status: {}".format(idx, v2.pdgId, self.getParentID(v2, genParticles), v2.genPartIdxMother, v2.statusFlags >> 13 & 1))
v2_daughters.append(daughter2)
#elif temp_boson1 is None:
#temp_boson1 = particle
Expand All @@ -140,8 +141,8 @@ def analyze(self, event):
if len(v2_daughters) == 2:
for i in range(m):
v2_decay_products = v2_daughters
print("DEBUG - line 126 ( 2 daughters of Z2 boson): Index: {}, Particle ID: {}, Parent ID: {}, MotherIdx: {}, Status: {}".format(idx, v2_decay_products[i].pdgId, self.getParentID(v2_decay_products[i], genParticles), v2_decay_products[i].genPartIdxMother, v2_decay_products[i].statusFlags >> 13 & 1))
self.DEBUG: print("DEBUG - line 126 ( 2 daughters of Z2 boson): Index: {}, Particle ID: {}, Parent ID: {}, MotherIdx: {}, Status: {}".format(idx, v2_decay_products[i].pdgId, self.getParentID(v2_decay_products[i], genParticles), v2_decay_products[i].genPartIdxMother, v2_decay_products[i].statusFlags >> 13 & 1))

if higgs is not None:
higgs_pt = higgs.pt
higgs_eta = higgs.eta
Expand All @@ -158,12 +159,12 @@ def analyze(self, event):
v1_eta = v1.eta
v1_phi = v1.phi
v1_mass = v1.mass

#Z1 = ROOT.TLorentzVector()
#Z1.SetPtEtaPhiM(v1_pt, v1_eta, v1_phi, v1_mass)
#boost_Z1 = Z1.BoostVector()
#boost_Z1_mag = boost_Z1.Mag()

else:
v1_pt = -1.
v1_eta = 0.
Expand All @@ -177,15 +178,15 @@ def analyze(self, event):
v1_decay_products_eta = [daughter.eta for daughter in v1_decay_products]
v1_decay_products_phi = [daughter.phi for daughter in v1_decay_products]
v1_decay_products_mass = [daughter.mass for daughter in v1_decay_products]
print("v1_decay_products_pt:", v1_decay_products_pt, type(v1_decay_products_pt))
self.DEBUG: print("v1_decay_products_pt:", v1_decay_products_pt, type(v1_decay_products_pt))
#pz = v1_decay_products_pt[0] * math.sinh(v1_decay_products_eta[0])
#print("pz of neutrino1:", pz, type(pz))
#self.DEBUG: print("pz of neutrino1:", pz, type(pz))
#for i in range(2):
#v1_decay_products[i] = ROOT.TLorentzVector()
#v1_decay_products[i].SetPxPyPzE(0.0, 0.0, 0.0, 0.0)
#neutrino1_pz = v1_decay_products[0].Pz()
#neutrino2_pz = v1_decay_products[1].Pz()
#print("neutrino1_pz:", neutrino1_pz, type(neutrino1_pz))
#self.DEBUG: print("neutrino1_pz:", neutrino1_pz, type(neutrino1_pz))
else:
v1_decay_products_pt = [-1.]
v1_decay_products_eta = [0.]
Expand All @@ -198,13 +199,13 @@ def analyze(self, event):
v2_eta = v2.eta
v2_phi = v2.phi
v2_mass = v2.mass
print("v2_mass:", v2_mass, type(v2_mass))
self.DEBUG: print("v2_mass:", v2_mass, type(v2_mass))

#Z2 = ROOT.TLorentzVector()
#Z2.SetPtEtaPhiM(v2_pt, v2_eta, v2_phi, v2_mass)
#boost_Z2 = Z2.BoostVector()
#boost_Z2_mag = boost_Z2.Mag()

else:
v2_pt = -1.
v2_eta = 0.
Expand All @@ -217,25 +218,25 @@ def analyze(self, event):
v2_decay_products_eta = [daughter.eta for daughter in v2_decay_products]
v2_decay_products_phi = [daughter.phi for daughter in v2_decay_products]
v2_decay_products_mass = [daughter.mass for daughter in v2_decay_products]
print("v2_decay_products_pt:", v2_decay_products_pt, type(v2_decay_products_pt))
self.DEBUG: print("v2_decay_products_pt:", v2_decay_products_pt, type(v2_decay_products_pt))
pz1 = v2_decay_products_pt[0] * math.sinh(v2_decay_products_eta[0])
neutrino1_pz = abs(pz1)
print("pz of neutrino1:", neutrino1_pz, type(neutrino1_pz))
neutrino1_pz = abs(pz1)
self.DEBUG: print("pz of neutrino1:", neutrino1_pz, type(neutrino1_pz))
pz2 = v2_decay_products_pt[1] * math.sinh(v2_decay_products_eta[1])
neutrino2_pz = abs(pz2)
print("pz of neutrino2:", neutrino2_pz, type(neutrino2_pz))
self.DEBUG: print("pz of neutrino2:", neutrino2_pz, type(neutrino2_pz))
delta_pz_neutrino = neutrino1_pz - neutrino2_pz
print("delta_pz_neutrino:", delta_pz_neutrino, type(delta_pz_neutrino))
self.DEBUG: print("delta_pz_neutrino:", delta_pz_neutrino, type(delta_pz_neutrino))

###defining Pz of neutrino as a lorentz vector
v2_decay_products[0] = ROOT.TLorentzVector()
v2_decay_products[0].SetPtEtaPhiM(v2_decay_products_pt[0], v2_decay_products_eta[0], v2_decay_products_phi[0], v2_decay_products_mass[0])
v2_decay_products[1] = ROOT.TLorentzVector()
v2_decay_products[1].SetPtEtaPhiM(v2_decay_products_pt[1], v2_decay_products_eta[1], v2_decay_products_phi[1], v2_decay_products_mass[1])
pz1 = v2_decay_products[0].Pz()
print("pz of neutrino1_new:", pz1, type(pz1))
self.DEBUG: print("pz of neutrino1_new:", pz1, type(pz1))
pz2 = v2_decay_products[1].Pz()
print("pz of neutrino2_new:", pz2, type(pz2))
self.DEBUG: print("pz of neutrino2_new:", pz2, type(pz2))
else:
v2_decay_products_pt = [-1.]
v2_decay_products_eta = [0.]
Expand All @@ -245,8 +246,8 @@ def analyze(self, event):
#Pz_list = []
#Pz = ROOT.TMath.Sqrt((v2_mass ** 2) / 4 - GenMET_pt)
#Pz_list.append(Pz)
#print("Pz:", Pz_list)
#self.DEBUG: print("Pz:", Pz_list)


## Calculating Boost
if found_Z1 == True and found_Z2 == True:
Expand All @@ -255,14 +256,16 @@ def analyze(self, event):
boost_Z1_mag = boost_Z1.Mag()
Z2.SetPtEtaPhiM(v2_pt, v2_eta, v2_phi, v2_mass)
boost_Z2 = Z2.BoostVector()
boost_Z2_mag = boost_Z2.Mag()
boost_Z2_mag = boost_Z2.Mag()
boost_diff_mag = boost_Z1_mag - boost_Z2_mag
print("delta boost: {}".format(boost_diff_mag))
self.DEBUG: print("delta boost: {}".format(boost_diff_mag))
#self.out.fillBranch("Boostdiff", boost_diff_mag)

#self.out.fillBranch("Pz_neutrino", Pz)
self.out.fillBranch("Pz_neutrino1", pz1)
self.out.fillBranch("delta_pz_neutrino", delta_pz_neutrino)

# self.out.fillBranch("Pz_neutrino", Pz)
self.out.fillBranch("BoostZ1", boost_Z1_mag)
self.out.fillBranch("BoostZ2", boost_Z2_mag)
self.out.fillBranch("Boostdiff", boost_diff_mag)
Expand All @@ -286,6 +289,6 @@ def analyze(self, event):
self.out.fillBranch("genV2DaughterEta", v2_decay_products_eta)
self.out.fillBranch("genV2DaughterPhi", v2_decay_products_phi)
self.out.fillBranch("genV2DaughterMass", v2_decay_products_mass)
print("#######################Event end ################################")

self.DEBUG: print("#######################Event end ################################")
return True
12 changes: 10 additions & 2 deletions H4LCppModule.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,24 @@ def __init__(self, year, cfgFile, isMC, isFSR, cutFlowJSONFile, DEBUG=False):

def loadLibraries(self):
base_path = os.getenv('CMSSW_BASE') + '/src/PhysicsTools/NanoAODTools/python/postprocessing/analysis/nanoAOD_skim'
yaml_cpp_path = os.path.join(base_path, "external/yaml-cpp")

# Adding yaml-cpp headers to the include path
ROOT.gSystem.AddIncludePath("-I%s/include" % yaml_cpp_path)
libraries = [
'libmcfm_710.so',
'libJHUGenMELAMELA.so',
'libjhugenmela.so',
'libmcfm_707.so',
'libcollier.so',
]
for lib in libraries:
fullPath = os.path.join(base_path, 'JHUGenMELA/MELA/data/slc7_amd64_gcc700', lib)
fullPath = os.path.join(base_path, 'JHUGenMELA/MELA/data/el9_amd64_gcc12', lib)
ROOT.gSystem.Load(fullPath)

# Load the yaml-cpp library
yaml_cpp_lib_path = os.path.join(yaml_cpp_path, "build")
ROOT.gSystem.Load(os.path.join(yaml_cpp_lib_path, "libyaml-cpp.so"))

# Load the C++ module
if "/H4LTools_cc.so" not in ROOT.gSystem.GetLibraries():
print("Load C++ module")
Expand Down
41 changes: 41 additions & 0 deletions Input_2018.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ TriggerChannels:
- Triggers_HZZ4l
- Triggers_HZZ2l2q
- Triggers_HZZ2l2nu
- Triggers_HZZ2l2nu_SingleLep
- Triggers_HZZ2l2nu_DiLep
- Triggers_HZZ2l2nu_HighPt

Triggers_HZZ4l:
- event.HLT_Ele32_WPTight_Gsf
Expand Down Expand Up @@ -53,6 +56,44 @@ Triggers_HZZ2l2nu:
- event.HLT_Photon165_R9Id90_HE10_IsoM
- event.HLT_Photon300_NoHE


Triggers_HZZ2l2nu_SingleLep:
# Single Mu
- event.HLT_IsoMu20
- event.HLT_IsoMu24
- event.HLT_IsoMu27
# Single Electron
- event.HLT_Ele32_WPTight_Gsf

Triggers_HZZ2l2nu_DiLep:
# DoubleMu
- event.HLT_Mu17_TrkIsoVVL_Mu8_TrkIsoVVL_DZ_Mass3p8
# Double Electron
- event.HLT_Ele23_Ele12_CaloIdL_TrackIdL_IsoVL
- event.HLT_DoubleEle25_CaloIdL_MW

Triggers_HZZ2l2nu_HighPt:
# Double Electron
- event.HLT_Ele27_Ele37_CaloIdL_MW
# Single Electron
- event.HLT_Ele35_WPTight_Gsf
- event.HLT_Ele35_WPTight_Gsf_L1EGMT
- event.HLT_Ele38_WPTight_Gsf
- event.HLT_Ele40_WPTight_Gsf
- event.HLT_Ele50_IsoVVVL_PFHT450
- event.HLT_Ele115_CaloIdVT_GsfTrkIdT
- event.HLT_Ele135_CaloIdVT_GsfTrkIdT
- event.HLT_Ele145_CaloIdVT_GsfTrkIdT
- event.HLT_Ele200_CaloIdVT_GsfTrkIdT
- event.HLT_Ele250_CaloIdVT_GsfTrkIdT
- event.HLT_Ele300_CaloIdVT_GsfTrkIdT
# DoubleMu
- event.HLT_Mu37_TkMu27
# SingleMu
- event.HLT_Mu50
- event.HLT_Mu55


Zmass: 91.1876
MZ1cut: 40
MZcut:
Expand Down
16 changes: 14 additions & 2 deletions JetSFMaker.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,20 @@ class JetSFMaker(Module):

def __init__(self, cmssw, puid_sf_config='PhysicsTools/NanoAODTools/python/postprocessing/analysis/nanoAOD_skim/data/JetPUID_cfg.py'):
cmssw_base = os.getenv('CMSSW_BASE')
with open(cmssw_base + '/src/' + puid_sf_config) as src:
exec(src)

# Dictionary to hold the local variables from the exec
# Reference: https://stackoverflow.com/a/65647108
local_vars = {}

with open(cmssw_base + '/src/' + puid_sf_config) as src_file:
src_code = src_file.read()
exec(src_code, {}, local_vars)

# Extract jet_puid_sf from local_vars
if 'jet_puid_sf' in local_vars:
jet_puid_sf = local_vars['jet_puid_sf']
else:
raise NameError("jet_puid_sf is not defined in the provided configuration file.")

puid_sf_cfg = jet_puid_sf[cmssw]

Expand Down
Loading

0 comments on commit 81fee6c

Please sign in to comment.