Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
216e67a
Update README.md
Sep 25, 2018
005b53c
introduced MET Cut of 20GeV in BoostedAnalyzer and Synhronizer
Sep 26, 2018
aeff552
Merge branch 'CMSSW_9_4_3' of https://github.com/cms-ttH/BoostedTTH i…
Sep 26, 2018
7746aa2
added isr/fsr up/down weights to synchronizer
Sep 27, 2018
e07f108
diable evaluation of DNNs until new ones are available
Sep 28, 2018
aa5940d
correct mistake in syncparallel
Sep 28, 2018
d40f74e
update globaltag and adjust loose jet pt cut for slimmed ntuples
Oct 17, 2018
25fa01a
added deepcsv variable to slimmed ntuples
Oct 19, 2018
56f5dab
update one MET filter
Oct 22, 2018
233afe5
enable EE noise mitigation for MET
Oct 23, 2018
d3476dc
added num of true interactions to ntuples
Oct 23, 2018
071bb78
change name of number of true interactions
Oct 23, 2018
5137169
use latest globaltag for sync
Oct 29, 2018
9f191ca
Declare member functions which do not access any non-static members a…
Oct 29, 2018
6cb53bf
save configs for slimmed ntuple production
Oct 29, 2018
5476adc
lower case for options of MET EE noise mitigation fix
Oct 29, 2018
7298863
added 'inacceptance' variables to use as AachenDNN-prenet-targets
Nov 5, 2018
7e194d3
maybe use genParton
Nov 6, 2018
27e56cd
Update README.md
michaelwassmer Nov 6, 2018
3f70d3d
genjet matching working version
Nov 6, 2018
49a6653
genjet matching working version
Nov 6, 2018
0926e60
quark matcher updated (just additional bs missing)
Nov 6, 2018
ceb93cd
disabled printouts
Nov 6, 2018
0030553
remove unneccesary printout
Nov 7, 2018
8c8db84
Merge remote-tracking branch 'origin/CMSSW_9_4_3_AachenDNN' into CMSS…
Nov 8, 2018
86394b6
reactivated some Higgs Gen outputs
Nov 9, 2018
22bc312
inacceptance variable update
Nov 15, 2018
75e9f69
Merge remote-tracking branch 'origin/CMSSW_9_4_3_AachenDNN' into CMSS…
Nov 19, 2018
e25d6d9
added MCMatchVar
Nov 19, 2018
5649474
Changed common classifier branch to master
Dec 10, 2018
84a2d26
added a scripts folder where we can collect important scripts which w…
Feb 7, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions BoostedAnalyzer/interface/Synchronizer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#include "BoostedTTH/BoostedAnalyzer/interface/DiLeptonMassSelection.hpp"
#include "BoostedTTH/BoostedAnalyzer/interface/DiLeptonMETSelection.hpp"
#include "BoostedTTH/BoostedAnalyzer/interface/JetTagSelection.hpp"
#include "BoostedTTH/BoostedAnalyzer/interface/METSelection.hpp"
#include "BoostedTTH/BoostedAnalyzer/interface/DiLeptonJetTagSelection.hpp"
#include "BoostedTTH/BoostedAnalyzer/interface/BDT_v3.hpp"
#include "MiniAOD/MiniAODHelper/interface/MiniAODHelper.h"
Expand Down
200 changes: 100 additions & 100 deletions BoostedAnalyzer/plugins/BoostedAnalyzer.cc

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions BoostedAnalyzer/python/Selection_cff.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@
)

METSelection = cms.PSet(
minMET = cms.double(-1),
maxMET = cms.double(800),
minMET = cms.double(20.),
maxMET = cms.double(100000.),
)

DiLeptonMETSelection = cms.PSet(
Expand Down Expand Up @@ -99,7 +99,7 @@

filtersData= cms.PSet(
filters=cms.vstring("Flag_goodVertices",
"Flag_globalTightHalo2016Filter",
"Flag_globalSuperTightHalo2016Filter",
"Flag_HBHENoiseFilter",
"Flag_HBHENoiseIsoFilter",
"Flag_EcalDeadCellTriggerPrimitiveFilter",
Expand All @@ -112,7 +112,7 @@

filtersMC= cms.PSet(
filters=cms.vstring("Flag_goodVertices",
"Flag_globalTightHalo2016Filter",
"Flag_globalSuperTightHalo2016Filter",
"Flag_HBHENoiseFilter",
"Flag_HBHENoiseIsoFilter",
"Flag_EcalDeadCellTriggerPrimitiveFilter",
Expand Down
247 changes: 247 additions & 0 deletions BoostedAnalyzer/scripts/NAFSubmit.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,247 @@
#!/usr/bin/env python

import sys
import os
import glob
import numpy as np
import subprocess
import stat
import re
import time
import optparse


def submitToBatch(workdir, list_of_shells, memory_, disk_, runtime_, use_proxy, proxy_dir_, name_ ):
''' submit the list of shell script to the NAF batch system '''

if name_!="":
name_ = name_+"_"

# write array script for submission
arrayScript = writeArrayScript(workdir, list_of_shells, name_)

# write submit script for submission
submitScript = writeSubmitScript(workdir, arrayScript, len(list_of_shells), memory_, disk_, runtime_, use_proxy, proxy_dir_, name_)

# submit the whole thing
jobID = condorSubmit( submitScript )
return [jobID]

def writeArrayScript(workdir, files, name_):
path = workdir+"/"+name_+"arraySubmit.sh"

code = """
#!/bin/bash
subtasklist=(
%(tasks)s
)
thescript=${subtasklist[$SGE_TASK_ID]}
echo "${thescript}"
echo "$SGE_TASK_ID"
. $thescript
""" % ({"tasks":"\n".join(files)})

with open(path, "w") as f:
f.write(code)

st = os.stat(path)
os.chmod(path, st.st_mode | stat.S_IEXEC)

print("wrote array script "+str(path))
return path


def writeSubmitScript(workdir, arrayScript, nScripts, memory_, disk_, runtime_, use_proxy, proxy_dir_, name_):
path = workdir+"/"+name_+"submitScript.sub"
logdir = workdir+"/logs"
if not os.path.exists(logdir):
os.makedirs(logdir)

code = """
universe = vanilla
executable = /bin/zsh
arguments = {arg}
error = {dir}/{name}submitScript.$(Cluster)_$(ProcId).err
log = {dir}/{name}submitScript.$(Cluster)_$(ProcId).log
output = {dir}/{name}submitScript.$(Cluster)_$(ProcId).out
run_as_owner = true
RequestMemory = {memory}
RequestDisk = {disk}
+RequestRuntime = {runtime}
""".format(
arg = arrayScript,
dir = logdir,
memory = memory_,
disk = disk_,
runtime = runtime_,
name = name_)
if use_proxy:
code+="""
environment = X509_USER_PROXY={proxy_dir}
getenv = True
use_x509userproxy = True
x509userproxy = {proxy_dir}""".format(proxy_dir = proxy_dir_)
code+="""
Queue Environment From ("""
for taskID in range(nScripts):
code += "\"SGE_TASK_ID="+str(taskID+1)+"\"\n"
code += ")"

with open(path, "w") as f:
f.write(code)

print("wrote submit script "+str(path))
return path

def condorSubmit(submitPath):
submitCommand = "condor_submit -terse -name bird-htc-sched12.desy.de " + submitPath
print("submitting:")
print(submitCommand)
tries = 0
jobID = None
while not jobID:
process = subprocess.Popen(submitCommand.split(), stdout = subprocess.PIPE, stderr = subprocess.STDOUT, stdin = subprocess.PIPE)
process.wait()
output = process.communicate()
try:
jobID = int(output[0].split(".")[0])
except:
print("something went wrong with calling the condir_submit command, submission of jobs was not successful")
print("DEBUG:")
print(output)
tries += 1
jobID = None
time.sleep(60)
if tries>10:
print("job submission was not successful after ten tries - exiting without JOBID")
sys.exit(-1)
return jobID




def monitorJobStatus(jobIDs = None):
allfinished = False
errorcount = 0
print("checking job status in condor_q ...")

command = ["condor_q", "-name", "bird-htc-sched12.desy.de"]
if jobIDs:
command += jobIDs
command = [str(c) for c in command]
command.append("-totals")

while not allfinished:
time.sleep(30)

a = subprocess.Popen(command, stdout=subprocess.PIPE,stderr=subprocess.STDOUT,stdin=subprocess.PIPE)
a.wait()
qstat = a.communicate()[0]

nrunning = -1
queryline = [line for line in qstat.split("\n") if "Total for query" in line]
if len(queryline) == 1:
jobsRunning = int(re.findall(r'\ [0-9]+\ running', queryline[0])[0][1:-8])
jobsIdle = int(re.findall(r'\ [0-9]+\ idle', queryline[0])[0][1:-5])
jobsHeld = int(re.findall(r'\ [0-9]+\ held', queryline[0])[0][1:-5])

nrunning = jobsRunning + jobsIdle + jobsHeld

print("{:4d} running | {:4d} idling | {:4d} held |\t total: {:4d}".format(jobsRunning, jobsIdle, jobsHeld, nrunning))

errorcount = 0
if nrunning == 0:
print("waiting on no more jobs - exiting loop")
allfinished=True
else:
errorcount += 1
# sometimes condor_q is not reachable - if this happens a lot something is probably wrong

print("line does not match query")
if errorcount == 30:
print("something is off - condor_q has not worked for 15 minutes ...")
print("exiting condor_q (jobs are probably still in queue")
sys.exit()


print("all jobs are finished - exiting monitorJobStatus")
return




if __name__ == "__main__":
parser = optparse.OptionParser(usage="%prog [options] files")
parser.add_option("-f","--folder", dest = "folder", default = None, metavar = "FOLDER",
help = "Specify relative path to a folder from which all files are to be submitted.")

parser.add_option("-p","--pattern", dest = "pattern", default = None, metavar = "'PATTERN'",
help = "Specify a pattern to match files in FOLDER, e.g. '_test'.")

parser.add_option("-m","--monitorStatus", action = "store_true", dest = "monitorStatus", default = False, metavar = "MONITORSTATUS",
help = "Monitor the job status after submission with 'condor_q' until all jobs are done.")

parser.add_option("-o","--outputdir", dest = "outputdir", default = os.path.dirname(os.path.realpath(__file__)), metavar = "OUTPUTDIR",
help = "Path to output directory for log files and submit scripts (relative or absolute).")

parser.add_option("-M","--memory",type="string",default="2000",dest="memory",metavar = "MEMORY",
help = "Amount of memory in MB which is requested for the machines")

parser.add_option("-d","--disk",type="string",default="2000",dest="disk",metavar = "DISK",
help = "Amount of disk space in MB which is requested for the machines")

parser.add_option("-r","--runtime",type="string",default="180",dest="runtime",metavar = "RUNTIME",
help = "Amount of runtime in minutes which is requested for the machines")

parser.add_option("-u","--useproxy",action="store_true",default=False,dest="useproxy",metavar = "USEPROXY",
help = "Use voms proxy")

parser.add_option("-v","--vomsproxy",type="string",default="",dest="vomsproxy",metavar = "VOMSPROXY",
help = "Path to the VOMS proxy file")

parser.add_option("-n","--name",type="string",default="",dest="name",metavar = "NAME",
help = "Name for this submit job")

(opts, args) = parser.parse_args()

if opts.useproxy and not opts.vomsproxy:
parser.error('If flag to use proxy is set, a path to the proxy file has to be provided')

# get files to submit
if opts.folder:
filepath = opts.folder+"/*.sh"
submit_files = glob.glob(filepath)
else:
submit_files = [f for f in args if f.endswith(".sh")]


# check for naming pattern
if opts.pattern:
print(opts.pattern)
submit_files = [f for f in submit_files if opts.pattern in f]

# print list of files to submit
print("-"*40)
print("number of files to submit: {}".format(len(submit_files)))
for f in submit_files: print(" {}".format(f))
print("-"*40)


# setup workdir
workdir = opts.outputdir+"/"
if not os.path.exists(workdir):
os.makedirs(workdir)
print("output directory for logfiles, etc: {}".format(workdir))


# submit to batch
jobIDs = submitToBatch(workdir, submit_files, opts.memory, str(int(opts.disk)*1000), str(int(opts.runtime)*60), opts.useproxy, opts.vomsproxy, opts.name)
print("submitted jobs with IDs: {}".format(jobIDs))

# monitor job status
if opts.monitorStatus:
monitorJobStatus(jobIDs)

print("done.")


4 changes: 3 additions & 1 deletion BoostedAnalyzer/src/SlimmedNtuples.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ void SlimmedNtuples::Init(const std::vector<InputCollections>& input,VariableCon
vars.InitVars( "jet_corr_JER" , "njets" );
vars.InitVars( "jet_corr_JES" , "njets" );
vars.InitVars( "jet_csv" , "njets" );
vars.InitVars( "jet_deepcsv" , "njets" );
vars.InitVars( "jet_cmva" , "njets" );

initialized=true;
Expand Down Expand Up @@ -111,7 +112,8 @@ void SlimmedNtuples::Process(const std::vector<InputCollections>& input,Variable
vars.FillVars( "jet_pt" , iJet , jet.pt() );
vars.FillVars( "jet_eta" , iJet , jet.eta() );
vars.FillVars( "jet_phi" , iJet , jet.phi() );
vars.FillVars( "jet_csv" , iJet , MiniAODHelper::GetJetCSV(jet,"DeepCSV") );
vars.FillVars( "jet_csv" , iJet , MiniAODHelper::GetJetCSV(jet,"pfCombinedInclusiveSecondaryVertexV2BJetTags") );
vars.FillVars( "jet_deepcsv" , iJet , MiniAODHelper::GetJetCSV(jet,"DeepCSV") );
// save the product of the nominal jec, meaning JESnominal*JERnominal
vars.FillVars( "jet_corr" , iJet , jes_nom*jer_nom );
vars.FillVars( "jet_corr_JER" , iJet , jer_nom );
Expand Down
Loading