Skip to content
Snippets Groups Projects
Commit 0f8308c5 authored by Aman Pavan Salikar's avatar Aman Pavan Salikar
Browse files

add submit_scripts

parent 955aa755
No related branches found
No related tags found
No related merge requests found
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# R. de Sangro 3/3/2020
import os
import sys
import subprocess
genDir={'mixed':'mixed', 'charged':'charged', 'phigamma':'phigamma', 'uu':'uubar', 'dd':'ddbar', 'ss':'ssbar', 'cc':'ccbar', 'bhabha':'bhabha', 'mumu':'mumu', 'tautau':'tautau', 'eeee':'eeee', 'eemm':'eemumu', 'eett':'eetautau', 'mmmm':'mumumumu', 'mmtt':'mumutautau', 'pGun':'pGun'}
def submit_KlId_prod(nJobs, firstJob=1, nEv=100, generator='mixed', sample='training', bkg=''):
if sample!='training' and sample!='test':
print(" Invalid sample! Valid samples are: 'training' or 'test'")
sys.exit()
sidOffset=1000
if sample=='test':
sidOffset=2200
if generator not in list(genDir):
print("Invalid generator...exiting!")
sys.exit()
# outdir="KlId_BBar_rel07/root_files/MC/"+sample+"/"+genDir[generator]
# outLogdir="KlId_BBar_rel07/logs/MC/"+sample+"/"+genDir[generator]
outdir="KlId_BBar_rel08/root_files/MC/"+sample+"/"+genDir[generator]
outLogdir="KlId_BBar_rel08/logs/MC/"+sample+"/"+genDir[generator]
if bkg=='0':
outdir="root_files/MC/"+sample+"/nobkg/"+genDir[generator]
outLogdir="logs/MC/"+sample+"/nobkg/"+genDir[generator]
if os.path.isdir(outdir):
print("directory ",outdir," exists!")
else:
print("directory ",outdir,"does not exist. Creating it...")
os.makedirs(outdir) # makes also intermediate directories
if os.path.isdir(outLogdir):
print("directory ",outLogdir," exists!")
else:
print("directory ",outLogdir,"does not exist. Creating it...")
os.makedirs(outLogdir) # makes also intermediate directories
for i in range(firstJob,firstJob+nJobs):
sid=sidOffset+2*i+6
comando=" bsub -J Kl_{0:s}_{1:s} -q l -o {2:s}/KlId_{3:s}_{4:s}_run{5:05d}".format(sample[:2],generator,outLogdir,generator,sample,i)+".log -e {0:s}/KlId_{1:s}_{2:s}_run{3:05d}".format(outLogdir,generator,sample,i)+".log basf2 ./pitoni/KlId_mc_KLM.py "+outdir+"/mdst_KlId_mc_run"+"{0:05d}".format(i)+".root "+str(nEv)+" "+str(sid)+" "+generator+" "+bkg
print(" ==>",comando)
os.system(comando)
if __name__ == '__main__':
if len(sys.argv)>7:
submit_KlId_prod(int(sys.argv[1]),int(sys.argv[2]),sys.argv[3],sys.argv[4],sys.argv[5],sys.argv[6],sys.argv[7])
elif len(sys.argv)>6:
submit_KlId_prod(int(sys.argv[1]),int(sys.argv[2]),sys.argv[3],sys.argv[4],sys.argv[5],sys.argv[6])
elif len(sys.argv)>5:
submit_KlId_prod(int(sys.argv[1]),int(sys.argv[2]),sys.argv[3],sys.argv[4],sys.argv[5])
elif len(sys.argv)>4:
submit_KlId_prod(int(sys.argv[1]),int(sys.argv[2]),sys.argv[3],sys.argv[4])
elif len(sys.argv)>3:
submit_KlId_prod(int(sys.argv[1]),int(sys.argv[2]),sys.argv[3])
elif len(sys.argv)>2:
submit_KlId_prod(int(sys.argv[1]),int(sys.argv[2]))
elif len(sys.argv)>1:
submit_KlId_prod(int(sys.argv[1]))
else:
print("need at least one argument!\n Usage: submit_KlId_prod <nJobs> <firstJob> <nEvents> <generator> <sample> <bkg>\n where:\n\t <nJobs>=number of jobs\n\t <firstJob>=number of first job (default=1)\n\t <nEvents>= Number of events per job (default=100)",
"\n\t <generator>= one of ",list(genDir),"(default=mixed)\n\t <sample>='training'(default) or 'test'\n\t <bkgScale>=1/0 1=include beam background (default), 0=no beam background" )
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
##########################################################################
# basf2 (Belle II Analysis Software Framework) #
# Author: The Belle II Collaboration #
# #
# See git log for contributors and copyright holders. #
# This file is licensed under LGPL-3.0, see LICENSE.md. #
##########################################################################
import sys
import os
# USE THIS TO TRAIN AND UPLOAD A NEW CLASSIFIER FOR THE KLONG ID
# USE THE OTHER SCRIPT TO GENERATE DATA. THEN TRAIN AND UPLOAD WITH &THIS.
# only thing to set is the path were you have the data to train the classifier on.
try:
data_path = sys.argv[1]
except BaseException:
data_path = "root_files/training/*.root"
try:
identifier = sys.argv[2]
except BaseException:
# the default name used in KLMExpert
identifier = "KLM_fBDT_10xbkg100k.xml"
ex_b = 0 # experiment begin, 0 for all of them
ex_e = -1 # experiment end, -1 for all of them
run_b = 0 # run begin, 0 for all
run_e = -1 # run end, -1 for all of them
training_string = ('basf2_mva_teacher --datafiles {data_path} --treename KLMdata --identifier {identifier} ' +
'--variable "KLMnLayer" "KLMnInnermostlayer" "KLMdistToNextCl" "KLMglobalZ" ' +
'"KLMTrackSepDist" "KLMInitialtrackSepAngle" "KLMTrackRotationAngle" ' +
'"KLMECLenergy" "KLMECLE9oE25" "KLMECLtiming" "KLMECLmintrackDist" "KLMECLZMVA" "KLMECLZ40" '
'"KLMECLZ51" "KLMTrackSepAngle" "KLMhitDepth" "KLMtime" --target_variable isSignal ' +
'--method FastBDT --nTrees 400 --nCutLevels 8 --nLevels 4').format(data_path=data_path, identifier=identifier)
# "EKLMHit2ds" "KLMHit2ds" "KLMenergy"
os.system(training_string)
# "upload" to localdb
os.system(
('basf2_mva_upload --identifier {identifier} --db_identifier {identifier_db} ' +
'--begin_experiment {ex_b} --end_experiment {ex_e} --begin_run {run_b} --end_run {run_e}').format(
identifier=identifier,
identifier_db=identifier.split(".xml")[0],
ex_b=ex_b,
ex_e=ex_e,
run_b=run_b,
run_e=run_e))
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# R. de Sangro 3/3/2020
import os
import sys
import subprocess
genDir={'mixed':'mixed', 'charged':'charged', 'phigamma':'phigamma', 'uu':'uubar', 'dd':'ddbar', 'ss':'ssbar', 'cc':'ccbar', 'bhabha':'bhabha', 'mumu':'mumu', 'tautau':'tautau', 'eeee':'eeee', 'eemm':'eemumu', 'eett':'eetautau', 'mmmm':'mumumumu', 'mmtt':'mumutautau', 'pGun':'pGun'}
def submit_KlId_prod(nJobs, firstJob=1, nEv=100, generator='mixed', sample='training', bkg=''):
if sample!='training' and sample!='test':
print(" Invalid sample! Valid samples are: 'training' or 'test'")
sys.exit()
sidOffset=1000
if sample=='test':
sidOffset=2200
if generator not in list(genDir):
print("Invalid generator...exiting!")
sys.exit()
# outdir="KlId_BBar_rel07/root_files/MC/"+sample+"/"+genDir[generator]
# outLogdir="KlId_BBar_rel07/logs/MC/"+sample+"/"+genDir[generator]
outdir="KlId_BBar_rel08/root_files/MC/"+sample+"/"+genDir[generator]
outLogdir="KlId_BBar_rel08/logs/MC/"+sample+"/"+genDir[generator]
if bkg=='0':
outdir="root_files/MC/"+sample+"/nobkg/"+genDir[generator]
outLogdir="logs/MC/"+sample+"/nobkg/"+genDir[generator]
if os.path.isdir(outdir):
print("directory ",outdir," exists!")
else:
print("directory ",outdir,"does not exist. Creating it...")
os.makedirs(outdir) # makes also intermediate directories
if os.path.isdir(outLogdir):
print("directory ",outLogdir," exists!")
else:
print("directory ",outLogdir,"does not exist. Creating it...")
os.makedirs(outLogdir) # makes also intermediate directories
for i in range(firstJob,firstJob+nJobs):
sid=sidOffset+2*i+6
comando=" bsub -J Kl_{0:s}_{1:s} -q l -o {2:s}/KlId_{3:s}_{4:s}_run{5:05d}".format(sample[:2],generator,outLogdir,generator,sample,i)+".log -e {0:s}/KlId_{1:s}_{2:s}_run{3:05d}".format(outLogdir,generator,sample,i)+".log basf2 ./pitoni/KlId_mc_KLM.py "+outdir+"/mdst_KlId_mc_run"+"{0:05d}".format(i)+".root "+str(nEv)+" "+str(sid)+" "+generator+" "+bkg
print(" ==>",comando)
os.system(comando)
if __name__ == '__main__':
if len(sys.argv)>7:
submit_KlId_prod(int(sys.argv[1]),int(sys.argv[2]),sys.argv[3],sys.argv[4],sys.argv[5],sys.argv[6],sys.argv[7])
elif len(sys.argv)>6:
submit_KlId_prod(int(sys.argv[1]),int(sys.argv[2]),sys.argv[3],sys.argv[4],sys.argv[5],sys.argv[6])
elif len(sys.argv)>5:
submit_KlId_prod(int(sys.argv[1]),int(sys.argv[2]),sys.argv[3],sys.argv[4],sys.argv[5])
elif len(sys.argv)>4:
submit_KlId_prod(int(sys.argv[1]),int(sys.argv[2]),sys.argv[3],sys.argv[4])
elif len(sys.argv)>3:
submit_KlId_prod(int(sys.argv[1]),int(sys.argv[2]),sys.argv[3])
elif len(sys.argv)>2:
submit_KlId_prod(int(sys.argv[1]),int(sys.argv[2]))
elif len(sys.argv)>1:
submit_KlId_prod(int(sys.argv[1]))
else:
print("need at least one argument!\n Usage: submit_KlId_prod <nJobs> <firstJob> <nEvents> <generator> <sample> <bkg>\n where:\n\t <nJobs>=number of jobs\n\t <firstJob>=number of first job (default=1)\n\t <nEvents>= Number of events per job (default=100)",
"\n\t <generator>= one of ",list(genDir),"(default=mixed)\n\t <sample>='training'(default) or 'test'\n\t <bkgScale>=1/0 1=include beam background (default), 0=no beam background" )
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
##########################################################################
# basf2 (Belle II Analysis Software Framework) #
# Author: The Belle II Collaboration #
# #
# See git log for contributors and copyright holders. #
# This file is licensed under LGPL-3.0, see LICENSE.md. #
##########################################################################
import sys
import os
# USE THIS TO TRAIN AND UPLOAD A NEW CLASSIFIER FOR THE KLONG ID
# USE THE OTHER SCRIPT TO GENERATE DATA. THEN TRAIN AND UPLOAD WITH &THIS.
# only thing to set is the path were you have the data to train the classifier on.
try:
data_path = sys.argv[1]
except BaseException:
data_path = "root_files/training/*.root"
try:
identifier = sys.argv[2]
except BaseException:
# the default name used in KLMExpert
identifier = "KLM_fBDT_10xbkg100k.xml"
ex_b = 0 # experiment begin, 0 for all of them
ex_e = -1 # experiment end, -1 for all of them
run_b = 0 # run begin, 0 for all
run_e = -1 # run end, -1 for all of them
training_string = ('basf2_mva_teacher --datafiles {data_path} --treename KLMdata --identifier {identifier} ' +
'--variable "KLMnLayer" "KLMnInnermostlayer" "KLMdistToNextCl" "KLMglobalZ" ' +
'"KLMTrackSepDist" "KLMInitialtrackSepAngle" "KLMTrackRotationAngle" ' +
'"KLMECLenergy" "KLMECLE9oE25" "KLMECLtiming" "KLMECLmintrackDist" "KLMECLZMVA" "KLMECLZ40" '
'"KLMECLZ51" "KLMTrackSepAngle" "KLMhitDepth" "KLMtime" --target_variable isSignal ' +
'--method FastBDT --nTrees 400 --nCutLevels 8 --nLevels 4').format(data_path=data_path, identifier=identifier)
# "EKLMHit2ds" "KLMHit2ds" "KLMenergy"
os.system(training_string)
# "upload" to localdb
os.system(
('basf2_mva_upload --identifier {identifier} --db_identifier {identifier_db} ' +
'--begin_experiment {ex_b} --end_experiment {ex_e} --begin_run {run_b} --end_run {run_e}').format(
identifier=identifier,
identifier_db=identifier.split(".xml")[0],
ex_b=ex_b,
ex_e=ex_e,
run_b=run_b,
run_e=run_e))
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment