diff --git a/GenVarsProducer.py b/GenVarsProducer.py index d107c3e..da0d041 100644 --- a/GenVarsProducer.py +++ b/GenVarsProducer.py @@ -9,6 +9,7 @@ class GenVarsProducer(Module): def __init__(self): + DEBUG = False pass def beginJob(self): pass @@ -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 @@ -82,16 +83,16 @@ def analyze(self, event): neutrino2_pz = 0.0 delta_pz_neutrino = 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 = [] @@ -100,7 +101,7 @@ def analyze(self, event): 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 @@ -111,13 +112,13 @@ def analyze(self, event): 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: @@ -128,7 +129,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 @@ -139,7 +140,7 @@ 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 @@ -176,15 +177,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.] @@ -197,7 +198,7 @@ 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) @@ -216,15 +217,15 @@ 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)) + 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() @@ -232,9 +233,9 @@ def analyze(self, event): 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.] @@ -244,7 +245,7 @@ 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 @@ -256,7 +257,7 @@ def analyze(self, event): boost_Z2 = Z2.BoostVector() 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) @@ -288,5 +289,5 @@ def analyze(self, event): 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 diff --git a/env.sh b/env.sh new file mode 100755 index 0000000..99c024c --- /dev/null +++ b/env.sh @@ -0,0 +1,28 @@ +#!/bin/bash + +# Update LD_LIBRARY_PATH for JHUGenMELA +export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$CMSSW_BASE/src/PhysicsTools/NanoAODTools/python/postprocessing/analysis/nanoAOD_skim/JHUGenMELA/MELA/data/el9_amd64_gcc12 + +# Initialize a new proxy with the desired validity +voms-proxy-init --voms cms --valid 168:00 + +if [ $? -eq 0 ]; then + echo "Proxy successfully created." + + # Check if the proxy is created in /tmp + PROXY_PATH=$(voms-proxy-info --path) + + if [[ $PROXY_PATH == /tmp/* ]]; then + echo "Proxy is located in /tmp, moving it to home directory..." + echo "cp $PROXY_PATH ~/" + cp $PROXY_PATH ~/ + echo "export X509_USER_PROXY=~/$(basename $PROXY_PATH)" + export X509_USER_PROXY=~/$(basename $PROXY_PATH) + echo "Proxy moved to home directory and X509_USER_PROXY set to $X509_USER_PROXY" + else + echo "Proxy is not in /tmp, no need to move it." + fi +else + echo "Failed to create the proxy." + exit 1 +fi diff --git a/input_data_Files/sample_list_v9_2018.dat b/input_data_Files/sample_list_v9_2018.dat index 92d9ce8..eaf44f8 100644 --- a/input_data_Files/sample_list_v9_2018.dat +++ b/input_data_Files/sample_list_v9_2018.dat @@ -22,7 +22,11 @@ ## #/GluGluHToZZTo4L_M125_TuneCP5_13TeV_powheg2_JHUGenV7011_pythia8/RunIISummer20UL18NanoAODv9-106X_upgrade2018_realistic_v16_L1v1-v1/NANOAODSIM #/GluGluHToZZTo2L2Q_M1000_TuneCP5_13TeV_powheg2_JHUGenV7011_pythia8/RunIISummer20UL18NanoAODv9-106X_upgrade2018_realistic_v16_L1v1-v1/NANOAODSIM +/GluGluHToZZTo2L2Nu_M125_TuneCP5_13TeV_powheg2_JHUGenV735_pythia8/RunIISummer20UL18NanoAODv9-106X_upgrade2018_realistic_v16_L1v1-v1/NANOAODSIM +/GluGluHToZZTo2L2Nu_M160_TuneCP5_13TeV_powheg2_JHUGenV735_pythia8/RunIISummer20UL18NanoAODv9-106X_upgrade2018_realistic_v16_L1v1-v1/NANOAODSIM +/GluGluHToZZTo2L2Nu_M180_TuneCP5_13TeV_powheg2_JHUGenV735_pythia8/RunIISummer20UL18NanoAODv9-106X_upgrade2018_realistic_v16_L1v1-v2/NANOAODSIM /GluGluHToZZTo2L2Nu_M200_TuneCP5_13TeV_powheg2_JHUGenV7011_pythia8/RunIISummer20UL18NanoAODv9-106X_upgrade2018_realistic_v16_L1v1-v1/NANOAODSIM +/GluGluHToZZTo2L2Nu_M250_TuneCP5_13TeV_powheg2_JHUGenV735_pythia8/RunIISummer20UL18NanoAODv9-106X_upgrade2018_realistic_v16_L1v1-v2/NANOAODSIM /GluGluHToZZTo2L2Nu_M300_TuneCP5_13TeV_powheg2_JHUGenV7011_pythia8/RunIISummer20UL18NanoAODv9-106X_upgrade2018_realistic_v16_L1v1-v1/NANOAODSIM /GluGluHToZZTo2L2Nu_M400_TuneCP5_13TeV_powheg2_JHUGenV7011_pythia8/RunIISummer20UL18NanoAODv9-106X_upgrade2018_realistic_v16_L1v1-v2/NANOAODSIM /GluGluHToZZTo2L2Nu_M500_TuneCP5_13TeV_powheg2_JHUGenV7011_pythia8/RunIISummer20UL18NanoAODv9-106X_upgrade2018_realistic_v16_L1v1-v1/NANOAODSIM diff --git a/scripts/nanoAOD_condor_resubmit.py b/scripts/nanoAOD_condor_resubmit.py index 74efa66..b31c2e3 100644 --- a/scripts/nanoAOD_condor_resubmit.py +++ b/scripts/nanoAOD_condor_resubmit.py @@ -135,18 +135,13 @@ def prepare_runJobs_missing(FailedJobRootFile,InputJdlFile,CondorLogDir,EOSDir,R if DEBUG: print("copy command: {}".format(bashCommand)) os.system(bashCommand) - outjdl_fileName = InputJdlFile.replace(".jdl", "_resubmit_"+str(Resubmit_no)+".jdl") + outjdl_fileName = InputJdlFile.replace(".txt", "_resubmit_"+str(Resubmit_no)+".txt") outjdl_file = open(outjdl_fileName,"w") - with open(InputJdlFile, 'r') as myfile: - """Copy the main part of original jdl file to new jdl file. - All the lines before "Output = " should be copied to new jdl file. - """ - for line in myfile: - # Check if line starts with "Output = " - if line.startswith("Output = "): - break - outjdl_file.write(line) + # Update the new txt file name in the JDL file + bashCommand = "sed -i 's/{0}/{1}/g' {2}".format(InputJdlFile, outjdl_fileName, InputJdlFile.replace(".txt",".jdl")) + if DEBUG: print("sed command: {}".format(bashCommand)) + os.system(bashCommand) for RootFiles in FailedJobRootFile: if DEBUG: print("Root file to look for in stdout files: {}".format(RootFiles)) @@ -175,7 +170,7 @@ def prepare_runJobs_missing(FailedJobRootFile,InputJdlFile,CondorLogDir,EOSDir,R OldRefFile = "" if DEBUG: print("OldRefFile: {}".format(OldRefFile)) - grepCommand_GetJdlInfo = 'grep -A1 -B3 "{}" {}'.format(RootFiles, InputJdlFile) + grepCommand_GetJdlInfo = 'grep "{}" {}'.format(RootFiles, InputJdlFile) if DEBUG: print(grepCommand_GetJdlInfo) grep_condor_jdl_part = os.popen(grepCommand_GetJdlInfo).read() if DEBUG: print("=="*51) @@ -244,7 +239,7 @@ def main(): jdlfile = prepare_runJobs_missing(not_finished,options.input,options.dir,stageDir,str(options.resubmit_no)) print(jdlfile) print('Submitting missing jobs : ') - submit_missing(jdlfile,options.resubmit) + submit_missing(options.input.replace(".txt",".jdl"),options.resubmit) if __name__ == "__main__": main()