|
| 1 | +#!/usr/bin/env python3 |
| 2 | +# |
| 3 | +# A script producing a consistent full-system-test workflow. |
| 4 | +# Python used for convenient json handling but this is completely up to the workflow writer. |
| 5 | +# |
| 6 | +from os import environ |
| 7 | +import json |
| 8 | + |
| 9 | +workflow={} |
| 10 | +workflow['stages'] = [] |
| 11 | + |
| 12 | +taskcounter=0 |
| 13 | +def Task(name='', needs=[], tf=-1, cmd='a', cwd='./', lab=[]): |
| 14 | + global taskcounter |
| 15 | + taskcounter = taskcounter + 1 |
| 16 | + t = { 'name': name, 'cmd': cmd, 'needs': needs, 'resources': { 'cpu': -1 , 'mem': -1 }, 'timeframe' : tf, 'labels' : lab, 'cwd' : cwd } |
| 17 | + workflow['stages'].append(t) |
| 18 | + return t |
| 19 | + |
| 20 | +# ---- qed transport task ------- |
| 21 | +QED=Task(name='qedsim', lab=["QED", "SIM"], cwd='qed') |
| 22 | +QED['cmd']='o2-sim --seed $O2SIMSEED -j $NJOBS -n$NEventsQED -m PIPE ITS MFT FT0 FV0 FDD -g extgen --configKeyValues \"GeneratorExternal.fileName=$O2_ROOT/share/Generators/external/QEDLoader.C;QEDGenParam.yMin=-7;QEDGenParam.yMax=7;QEDGenParam.ptMin=0.001;QEDGenParam.ptMax=1.;Diamond.width[2]=6.\"' |
| 23 | + |
| 24 | +QED2HAD=Task(name='qed2had', lab=["QED", "SIM"], cwd='qed', needs=["qedsim"]) |
| 25 | +QED2HAD['cmd']='PbPbXSec="8." ; awk "BEGIN {printf \\"%.2f\\",`grep xSectionQED qedgenparam.ini | cut -d\'=\' -f 2`/$PbPbXSec}" > qed2had.log' |
| 26 | +#echo "Obtained ratio of QED to hadronic x-sections = $QED2HAD" >> qedsim.log |
| 27 | + |
| 28 | +# --- signal sim and digitization ---- |
| 29 | +SIM=Task(name="sim", lab=["SIM"]) |
| 30 | +SIM['cmd']='o2-sim --seed $O2SIMSEED -n $NEvents --skipModules ZDC --configKeyValues "Diamond.width[2]=6." -g pythia8hi -j $NJOBS' |
| 31 | + |
| 32 | +DIGI1=Task(name="digi", lab=["DIGI"], needs=["sim", "qed2had"]) |
| 33 | +DIGI1['cmd']='QED2HAD=`cat qed/qed2had.log`; echo ${QED2HAD}; o2-sim-digitizer-workflow -n $NEvents --simPrefixQED qed/o2sim --qed-x-section-ratio ${QED2HAD} ${NOMCLABELS} --firstOrbit 0 --firstBC 0 --skipDet TRD --tpc-lanes $((NJOBS < 36 ? NJOBS : 36)) --shm-segment-size $SHMSIZE ${GLOBALDPLOPT}' |
| 34 | + |
| 35 | +# the dependency on digi is because of collisioncontext |
| 36 | +DIGI2=Task(name='digiTRD', lab=["DIGI"], needs=["sim", "digi"]) |
| 37 | +DIGI2['cmd']='o2-sim-digitizer-workflow -n $NEvents ${NOMCLABELS} --firstOrbit 0 --firstBC 0 --onlyDet TRD --shm-segment-size $SHMSIZE ${GLOBALDPLOPT} --incontext collisioncontext.root --configKeyValues "TRDSimParams.digithreads=${NJOBS}"' |
| 38 | + |
| 39 | +allrawtasknames=[] |
| 40 | +def RAWTask(name, command): |
| 41 | + allrawtasknames.append(name) |
| 42 | + return Task(name=name, cmd=command, lab=["RAW"], needs=["digi"]) |
| 43 | + |
| 44 | +ITSRAW=RAWTask('itsraw', 'o2-its-digi2raw --file-for link --configKeyValues \"HBFUtils.nHBFPerTF=128;HBFUtils.orbitFirst=0\" -o raw/ITS') |
| 45 | +MFTRAW=RAWTask('mftraw', 'o2-mft-digi2raw --file-for link --configKeyValues \"HBFUtils.nHBFPerTF=128;HBFUtils.orbitFirst=0\" -o raw/MFT') |
| 46 | +FT0RAW=RAWTask('ft0raw', 'o2-ft0-digi2raw --file-per-link --configKeyValues \"HBFUtils.nHBFPerTF=128;HBFUtils.orbitFirst=0\" -o raw/FT0') |
| 47 | +FV0RAW=RAWTask('fv0raw', 'o2-fv0-digi2raw --file-per-link --configKeyValues \"HBFUtils.nHBFPerTF=128;HBFUtils.orbitFirst=0\" -o raw/FV0') |
| 48 | +FDDRAW=RAWTask('fddraw', 'o2-fdd-digit2raw --file-per-link --configKeyValues \"HBFUtils.nHBFPerTF=128;HBFUtils.orbitFirst=0\" -o raw/FDD') |
| 49 | +TPCRAW=RAWTask('tpcraw', 'o2-tpc-digits-to-rawzs --file-for link --configKeyValues \"HBFUtils.nHBFPerTF=128;HBFUtils.orbitFirst=0\" -i tpcdigits.root -o raw/TPC') |
| 50 | +TOFRAW=RAWTask('tofraw', 'o2-tof-reco-workflow ${GLOBALDPLOPT} --tof-raw-file-for link --configKeyValues \"HBFUtils.nHBFPerTF=128;HBFUtils.orbitFirst=0\" --output-type raw --tof-raw-outdir raw/TOF') |
| 51 | +TOFRAW=RAWTask('midraw', 'o2-mid-digits-to-raw-workflow ${GLOBALDPLOPT} --mid-raw-outdir raw/MID --mid-raw-perlink --configKeyValues \"HBFUtils.nHBFPerTF=128;HBFUtils.orbitFirst=0\"') |
| 52 | +EMCRAW=RAWTask('emcraw', 'o2-emcal-rawcreator --file-for link --configKeyValues \"HBFUtils.nHBFPerTF=128;HBFUtils.orbitFirst=0\" -o raw/EMC') |
| 53 | +PHSRAW=RAWTask('phsraw', 'o2-phos-digi2raw --file-for link --configKeyValues \"HBFUtils.nHBFPerTF=128;HBFUtils.orbitFirst=0\" -o raw/PHS') |
| 54 | +CPVRAW=RAWTask('cpvraw', 'o2-cpv-digi2raw --file-for link --configKeyValues \"HBFUtils.nHBFPerTF=128;HBFUtils.orbitFirst=0\" -o raw/CPV') |
| 55 | + |
| 56 | +# make configuration -> this depends on all previous raws |
| 57 | +Task('rawAllConfig', cmd='cat raw/*/*.cfg > rawAll.cfg', needs=allrawtasknames, lab=["RAW"]) |
| 58 | + |
| 59 | +# now emit all possible versions of the dpl workflow (WITHGPU, NOGPU, AYNC) |
| 60 | +RECO_ENV={ "WITHGPU": { "CREATECTFDICT":"0", |
| 61 | + "GPUTYPE":"CUDA", |
| 62 | + "GPUMEMSIZE":"6000000000", |
| 63 | + "HOSTMEMSIZE":"1000000000", |
| 64 | + "SYNCMODE":"1", |
| 65 | + "CTFINPUT":"0", |
| 66 | + "SAVECTF":"0" }, |
| 67 | + "ASYNC": { |
| 68 | + "CREATECTFDICT":"0", |
| 69 | + "GPUTYPE":"CPU", |
| 70 | + "SYNCMODE":"0", |
| 71 | + "HOSTMEMSIZE":"$TPCTRACKERSCRATCHMEMORY", |
| 72 | + "CTFINPUT":"1", |
| 73 | + "SAVECTF":"0" |
| 74 | + }, |
| 75 | + "NOGPU": { |
| 76 | + "CREATECTFDICT":"1", |
| 77 | + "GPUTYPE":"CPU", |
| 78 | + "SYNCMODE":"0", |
| 79 | + "HOSTMEMSIZE":"$TPCTRACKERSCRATCHMEMORY", |
| 80 | + "CTFINPUT":"0", |
| 81 | + "SAVECTF":"1" |
| 82 | + } |
| 83 | +} |
| 84 | + |
| 85 | +for stage in [ "NOGPU", "WITHGPU", "ASYNC" ]: |
| 86 | + t=Task(name='reco_' + stage, needs=['rawAllConfig'], lab=["RECO"]) |
| 87 | + t['env']=RECO_ENV[stage] |
| 88 | + precommand="" |
| 89 | + if stage=="NOGPU": |
| 90 | + precommand="rm -f ctf_dictionary.root;" |
| 91 | + t['cmd']=precommand + "$O2_ROOT/prodtests/full-system-test/dpl-workflow.sh" |
| 92 | + |
| 93 | +def trimString(cmd): |
| 94 | + return ' '.join(cmd.split()) |
| 95 | + |
| 96 | +# insert taskwrapper stuff |
| 97 | +for s in workflow['stages']: |
| 98 | + s['cmd']='. ${O2_ROOT}/share/scripts/jobutils.sh; taskwrapper ' + s['name']+'.log \'' + s['cmd'] + '\'' |
| 99 | + |
| 100 | +# remove whitespaces etc |
| 101 | +for s in workflow['stages']: |
| 102 | + s['cmd']=trimString(s['cmd']) |
| 103 | + |
| 104 | +# write workflow to json |
| 105 | +workflowfile='workflow.json' |
| 106 | +with open(workflowfile, 'w') as outfile: |
| 107 | + json.dump(workflow, outfile, indent=2) |
| 108 | + |
| 109 | +exit (0) |
0 commit comments