Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Heppy 80 x batch #13

Open
wants to merge 3 commits into
base: heppy_80X
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion PhysicsTools/Heppy/python/analyzers/objects/JetAnalyzer.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ def process(self, event):
# self.matchJets(event, allJets)
self.matchJets(event, [ j for j in allJets if j.pt()>self.cfg_ana.jetPt ]) # To match only jets above chosen threshold
if getattr(self.cfg_ana, 'smearJets', False):
self.smearJets(event, allJets)
self.smearJets(event, [ j for j in allJets if j.pt()>self.cfg_ana.jetPt ])



Expand Down
23 changes: 23 additions & 0 deletions PhysicsTools/HeppyCore/python/utils/batchmanager.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,29 @@ def ParseOptions(self):
print "remote directory must start with /pnfs/psi.ch to send to the tier3 at PSI"
print self.remoteOutputDir_, "not valid"
sys.exit(1)
elif "oeaw.ac.at" in self.remoteOutputDir_: # T2 @ VIENNA:
# overwriting protection to be improved
if self.remoteOutputDir_.startswith("/dpm/oeaw.ac.at"):
ld_lib_path = os.environ.get('LD_LIBRARY_PATH')
if ld_lib_path != "None":
os.environ['LD_LIBRARY_PATH'] = "/usr/lib64/:"+ld_lib_path # to solve gfal conflict with CMSSW
print "Creating gfal-mkdir srm://hephyse.oeaw.ac.at/"+self.remoteOutputDir_
os.system("gfal-mkdir srm://hephyse.oeaw.ac.at/"+self.remoteOutputDir_)
outputDir = self.options_.outputDir
if outputDir==None:
today = datetime.today()
outputDir = 'OutCmsBatch_%s' % today.strftime("%d%h%y_%H%M")
else:
outputDir=outputDir.rstrip('/').split('/')[-1]
self.remoteOutputDir_+="/"+outputDir
print "Creating gfal-mkdir srm://hephyse.oeaw.ac.at/"+self.remoteOutputDir_
os.system("gfal-mkdir srm://hephyse.oeaw.ac.at/"+self.remoteOutputDir_)
if ld_lib_path != "None":
os.environ['LD_LIBRARY_PATH'] = ld_lib_path # back to original to avoid conflicts
else:
print "remote directory must start with /dpm/oeaw.ac.at to send to the TIER2 at Vienna"
print self.remoteOutputDir_, "not valid"
sys.exit(1)
else: # assume EOS
if not castortools.isLFN( self.remoteOutputDir_ ):
print 'When providing an output directory, you must give its LFN, starting by /store. You gave:'
Expand Down
86 changes: 83 additions & 3 deletions PhysicsTools/HeppyCore/scripts/heppy_batch.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ def batchScriptPISA( index, remoteDir=''):
"""
return script


def batchScriptCERN( jobDir, remoteDir=''):
'''prepare the LSF version of the batch script, to run on LSF'''

Expand All @@ -88,7 +89,7 @@ def batchScriptCERN( jobDir, remoteDir=''):
if remoteDir=='':
cpCmd=dirCopy
elif remoteDir.startswith("root://eoscms.cern.ch//eos/cms/store/"):
cpCmd="""echo 'sending root files to remote dir'
cpCmd="""echo 'sending root files to remote dir'
export LD_LIBRARY_PATH=/usr/lib64:$LD_LIBRARY_PATH #
for f in Loop/*/tree*.root
do
Expand Down Expand Up @@ -134,7 +135,85 @@ def batchScriptCERN( jobDir, remoteDir=''):
idx = jobDir[jobDir.find("_Chunk")+6:].strip("/") if '_Chunk' in jobDir else 'all',
srm = (""+remoteDir+jobDir[ jobDir.rfind("/") : (jobDir.find("_Chunk") if '_Chunk' in jobDir else len(jobDir)) ]).replace("root://eoscms.cern.ch/","")
)
else:
elif remoteDir.startswith("/dpm/oeaw.ac.at"):
cpCmd="""#!/bin/bash
#BSUB -q 8nm
echo 'environment:'
echo
env
# ulimit -v 3000000 # NO
echo 'copying job dir to worker'
cd $CMSSW_BASE/src
eval `scramv1 ru -sh`
# cd $LS_SUBCWD
# eval `scramv1 ru -sh`
cd -
cp -rf $LS_SUBCWD .
ls
cd `find . -type d | grep /`
echo 'running'
python $CMSSW_BASE/src/PhysicsTools/HeppyCore/python/framework/looper.py pycfg.py config.pck
looperExitStat=$?
echo 'sending root files to remote dir'
copyExitStat=0
if [ $looperExitStatus -ne 0 ]; then
echo "Looper failed. Don't attempt to copy corrupted file remotely"
exit 1
else
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/lib64/dcap/ # Fabio's workaround to fix gfal-tools
#nEvents=`grep 'All Events' Loop/skimAnalyzerCount/SkimReport.txt | sed 's/.* All Events *\([0-9][0-9]*\).*/\\1/'`
echo "Processed ${{nEvents}} according to Loop/log.txt"
for f in Loop/tree*/*.root
do
#ff=`basename $f | cut -d . -f 1`
#ff=`basename $f | cut -d . -f 2`
ff=`echo $f | cut -d/ -f2`
ff="${{ff}}_`basename $f | cut -d . -f 1`"
d=`echo $f | cut -d / -f 2`
echo "-------------------"
echo $f
echo $ff
echo d: $d
echo "-------------------"
#gfal-mkdir {srm}
#echo "Trying 10x: lcg-cp -v file://`pwd`/Loop/$d/$ff.root {srm}/${{ff}}_Chunk_{idx}_nEvents${{nEvents}}.root"
echo "Trying 10x: lcg-cp -v file://`pwd`/Loop/$d/$ff.root {srm}/${{ff}}_Chunk_{idx}.root"
icnt=0
fileCopyExitStatus=1
while [ $icnt -lt 10 ]
do
#lcg-cp -v file://`pwd`/Loop/$d/$ff.root {srm}/${{ff}}_Chunk_{idx}_nEvents${{nEvents}}.root
echo `ls file://`pwd`/Loop/$d`
lcg-cp -v file://`pwd`/Loop/$d/$ff.root {srm}/${{ff}}_Chunk_{idx}.root
if [ $? -eq 0 ]
then
fileCopyExitStatus=0
break
else
let icnt+=1
sleep 300
fi
done
rm Loop/$d/$ff.root
if [ $fileCopyExitStatus -ne 0 ]; then
echo "ERROR: remote copy failed for file $ff"
copyExitStat=$fileCopyExitStatus
else
echo "remote copy succeeded"
fi
done
fi
echo 'sending the job directory back'
cp -r Loop/* $LS_SUBCWD
exit $copyExitStat
""".format(
#idx = jobDir[jobDir.find("_Chunk")+6:].strip("/") if '_Chunk' in jobDir else 'all',
#srm='srm://hephyse.oeaw.ac.at'+remoteDir+jobDir[jobDir.rfind("/"):max(0,jobDir.find("_Chunk"))]
idx = jobDir[jobDir.find("_Chunk_")+6:].strip("/") if '_Chunk_' in jobDir else 'all',
srm='srm://hephyse.oeaw.ac.at'+remoteDir+jobDir[jobDir.rfind("/"):max(0,jobDir.find("_Chunk_"))]
)

else :
print "chosen location not supported yet: ", remoteDir
print 'path must start with /store/'
sys.exit(1)
Expand Down Expand Up @@ -305,14 +384,15 @@ def PrepareJobUser(self, jobDir, value ):
scriptFile = open(scriptFileName,'w')
storeDir = self.remoteOutputDir_.replace('/castor/cern.ch/cms','')
mode = self.RunningMode(options.batch)
print '--------------' , mode, '============'
if mode == 'LXPLUS':
scriptFile.write( batchScriptCERN( jobDir, storeDir ) )
elif mode == 'PSI':
scriptFile.write( batchScriptPSI ( value, jobDir, storeDir ) ) # storeDir not implemented at the moment
elif mode == 'LOCAL':
scriptFile.write( batchScriptLocal( storeDir, value) ) # watch out arguments are swapped (although not used)
elif mode == 'PISA' :
scriptFile.write( batchScriptPISA( storeDir, value) )
scriptFile.write( batchScriptPISA( storeDir, value) )
elif mode == 'PADOVA' :
scriptFile.write( batchScriptPADOVA( value, jobDir) )
elif mode == 'IC':
Expand Down