11#!/usr/bin/env python3
22
33#
4- # A script producing a consistent MC->RECO->AOD workflow
5- # It aims to handle the different MC possible configurations
4+ # A script producing a consistent MC->RECO->AOD workflow
5+ # It aims to handle the different MC possible configurations
66# It just creates a workflow.json txt file, to execute the workflow one must execute right after
7- # ${O2DPG_ROOT}/MC/bin/o2_dpg_workflow_runner.py -f workflow.json
7+ # ${O2DPG_ROOT}/MC/bin/o2_dpg_workflow_runner.py -f workflow.json
88#
99# Execution examples:
1010# - pp PYTHIA jets, 2 events, triggered on high pT decay photons on all barrel calorimeters acceptance, eCMS 13 TeV
1515# - pp PYTHIA ccbar events embedded into heavy-ion environment, 2 PYTHIA events into 1 bkg event, beams energy 2.510
1616# ./o2dpg_sim_workflow.py -e TGeant3 -nb 1 -ns 2 -j 8 -tf 1 -mod "--skipModules ZDC" \
1717# -col pp -eA 2.510 -proc "ccbar" --embedding
18- #
18+ #
1919
2020import sys
2121import importlib .util
125125QUALITYCONTROL_ROOT = environ .get ('QUALITYCONTROL_ROOT' )
126126O2PHYSICS_ROOT = environ .get ('O2PHYSICS_ROOT' )
127127
128- if O2DPG_ROOT == None :
128+ if O2DPG_ROOT == None :
129129 print ('Error: This needs O2DPG loaded' )
130130# exit(1)
131131
132- if O2_ROOT == None :
132+ if O2_ROOT == None :
133133 print ('Error: This needs O2 loaded' )
134134# exit(1)
135135
@@ -184,7 +184,7 @@ def addWhenActive(detID, needslist, appendstring):
184184 if isActive (detID ):
185185 needslist .append (appendstring )
186186
187- # ----------- START WORKFLOW CONSTRUCTION -----------------------------
187+ # ----------- START WORKFLOW CONSTRUCTION -----------------------------
188188
189189# set the time
190190if args .timestamp == - 1 :
@@ -395,7 +395,7 @@ def getDPL_global_options(bigshm=False):
395395 WEIGHTPOW = float (args .weightPow )
396396 PTHATMIN = float (args .ptHatMin )
397397 PTHATMAX = float (args .ptHatMax )
398-
398+
399399 # translate here collision type to PDG
400400 COLTYPE = args .col
401401
@@ -439,7 +439,7 @@ def getDPL_global_options(bigshm=False):
439439 if GENERATOR == 'pythia8' and PROCESS != '' :
440440 SGN_CONFIG_task ['cmd' ] = '${O2DPG_ROOT}/MC/config/common/pythia8/utils/mkpy8cfg.py \
441441 --output=pythia8.cfg \
442- --seed='+ str (RNDSEED + tf )+ ' \
442+ --seed='+ str (RNDSEED )+ ' \
443443 --idA='+ str (PDGA )+ ' \
444444 --idB='+ str (PDGB )+ ' \
445445 --eCM='+ str (ECMS )+ ' \
@@ -469,7 +469,7 @@ def getDPL_global_options(bigshm=False):
469469 # -----------------
470470 signalprefix = 'sgn_' + str (tf )
471471 signalneeds = [ SGN_CONFIG_task ['name' ] ]
472-
472+
473473 # add embedIntoFile only if embeddPattern does contain a '@'
474474 embeddinto = "--embedIntoFile ../bkg_MCHeader.root" if (doembedding & ("@" in args .embeddPattern )) else ""
475475 #embeddinto= "--embedIntoFile ../bkg_MCHeader.root" if doembedding else ""
@@ -511,7 +511,7 @@ def getDPL_global_options(bigshm=False):
511511 # digitization steps
512512 # ------------------
513513 CONTEXTFILE = 'collisioncontext.root'
514-
514+
515515 # Determine interation rate
516516 # it should be taken from CDB, meanwhile some default values
517517 INTRATE = int (args .interactionRate )
@@ -742,7 +742,7 @@ def getDigiTaskName(det):
742742 TRDTRACKINGtask = createTask (name = 'trdreco_' + str (tf ), needs = [TRDDigitask ['name' ], ITSTPCMATCHtask ['name' ], TPCRECOtask ['name' ], ITSRECOtask ['name' ]], tf = tf , cwd = timeframeworkdir , lab = ["RECO" ], cpu = '1' , mem = '2000' )
743743 TRDTRACKINGtask ['cmd' ] = '${O2_ROOT}/bin/o2-trd-tracklet-transformer ' + getDPL_global_options () + putConfigValues ()
744744 workflow ['stages' ].append (TRDTRACKINGtask )
745-
745+
746746 # FIXME This is so far a workaround to avoud a race condition for trdcalibratedtracklets.root
747747 TRDTRACKINGtask2 = createTask (name = 'trdreco2_' + str (tf ), needs = [TRDTRACKINGtask ['name' ],MATBUD_DOWNLOADER_TASK ['name' ]], tf = tf , cwd = timeframeworkdir , lab = ["RECO" ], cpu = '1' , mem = '2000' )
748748 TRDTRACKINGtask2 ['cmd' ] = '${O2_ROOT}/bin/o2-trd-global-tracking ' + getDPL_global_options (bigshm = True ) \
@@ -806,7 +806,7 @@ def getDigiTaskName(det):
806806 PHSRECOtask = createTask (name = 'phsreco_' + str (tf ), needs = [getDigiTaskName ("PHS" )], tf = tf , cwd = timeframeworkdir , lab = ["RECO" ], mem = '1500' )
807807 PHSRECOtask ['cmd' ] = '${O2_ROOT}/bin/o2-phos-reco-workflow ' + getDPL_global_options () + putConfigValues ()
808808 workflow ['stages' ].append (PHSRECOtask )
809-
809+
810810 CPVRECOtask = createTask (name = 'cpvreco_' + str (tf ), needs = [getDigiTaskName ("CPV" )], tf = tf , cwd = timeframeworkdir , lab = ["RECO" ], mem = '1500' )
811811 CPVRECOtask ['cmd' ] = '${O2_ROOT}/bin/o2-cpv-reco-workflow ' + getDPL_global_options () + putConfigValues ()
812812 workflow ['stages' ].append (CPVRECOtask )
@@ -816,7 +816,7 @@ def getDigiTaskName(det):
816816 ZDCRECOtask ['cmd' ] = '${O2_ROOT}/bin/o2-zdc-digits-reco ' + getDPL_global_options () + putConfigValues ()
817817 workflow ['stages' ].append (ZDCRECOtask )
818818
819- ## forward matching
819+ ## forward matching
820820 MCHMIDMATCHtask = createTask (name = 'mchmidMatch_' + str (tf ), needs = [MCHRECOtask ['name' ], MIDRECOtask ['name' ]], tf = tf , cwd = timeframeworkdir , lab = ["RECO" ], mem = '1500' )
821821 MCHMIDMATCHtask ['cmd' ] = '${O2_ROOT}/bin/o2-mch-tracks-reader-workflow | ${O2_ROOT}/bin/o2-mid-tracks-reader-workflow | ${O2_ROOT}/bin/o2-muon-tracks-matcher-workflow | ${O2_ROOT}/bin/o2-muon-tracks-writer-workflow ' + getDPL_global_options ()
822822 workflow ['stages' ].append (MCHMIDMATCHtask )
@@ -860,7 +860,7 @@ def getDigiTaskName(det):
860860
861861 def addQCPerTF (taskName , needs , readerCommand , configFilePath , objectsFile = '' ):
862862 task = createTask (name = taskName + '_local' + str (tf ), needs = needs , tf = tf , cwd = timeframeworkdir , lab = ["QC" ], cpu = 1 , mem = '2000' )
863- objectsFile = objectsFile if len (objectsFile ) > 0 else taskName + '.root'
863+ objectsFile = objectsFile if len (objectsFile ) > 0 else taskName + '.root'
864864 # the --local-batch argument will make QC Tasks store their results in a file and merge with any existing objects
865865 task ['cmd' ] = f'{ readerCommand } | o2-qc --config { configFilePath } ' + \
866866 f' --local-batch ../{ qcdir } /{ objectsFile } ' + \
@@ -869,9 +869,9 @@ def addQCPerTF(taskName, needs, readerCommand, configFilePath, objectsFile=''):
869869 # Prevents this task from being run for multiple TimeFrames at the same time, thus trying to modify the same file.
870870 task ['semaphore' ] = objectsFile
871871 workflow ['stages' ].append (task )
872-
872+
873873 ### MFT
874-
874+
875875 # to be enabled once MFT Digits should run 5 times with different configurations
876876 for flp in range (5 ):
877877 addQCPerTF (taskName = 'mftDigitsQC' + str (flp ),
@@ -957,7 +957,7 @@ def addQCPerTF(taskName, needs, readerCommand, configFilePath, objectsFile=''):
957957 needs = [ITSRECOtask ['name' ]],
958958 readerCommand = 'o2-global-track-cluster-reader --track-types "ITS" --cluster-types "ITS"' ,
959959 configFilePath = 'json://${O2DPG_ROOT}/MC/config/QC/json/its-mc-tracks-qc.json' )
960-
960+
961961 #secondary vertexer
962962 svfinder_threads = ' --threads 1 '
963963 svfinder_cpu = 1
@@ -973,7 +973,7 @@ def addQCPerTF(taskName, needs, readerCommand, configFilePath, objectsFile=''):
973973 # -----------
974974 # produce AOD
975975 # -----------
976- aodneeds = [PVFINDERtask ['name' ], SVFINDERtask ['name' ], TOFRECOtask ['name' ],
976+ aodneeds = [PVFINDERtask ['name' ], SVFINDERtask ['name' ], TOFRECOtask ['name' ],
977977 FV0RECOtask ['name' ]]
978978 if isActive ('FV0' ):
979979 aodneeds += [ FV0RECOtask ['name' ] ]
@@ -1008,7 +1008,7 @@ def addQCPerTF(taskName, needs, readerCommand, configFilePath, objectsFile=''):
10081008 if args .run_anchored == False :
10091009 AODtask ['cmd' ] += ' --aod-timeframe-id ${ALIEN_PROC_ID}' + aod_df_id
10101010 AODtask ['cmd' ] += ' ' + getDPL_global_options (bigshm = True )
1011- AODtask ['cmd' ] += ' --info-sources ' + anchorConfig .get ("o2-aod-producer-workflow-options" ,{}).get ("info-sources" ,str (aodinfosources ))
1011+ AODtask ['cmd' ] += ' --info-sources ' + anchorConfig .get ("o2-aod-producer-workflow-options" ,{}).get ("info-sources" ,str (aodinfosources ))
10121012 AODtask ['cmd' ] += ' --lpmp-prod-tag ${ALIEN_JDL_LPMPRODUCTIONTAG:-unknown}'
10131013 AODtask ['cmd' ] += ' --anchor-pass ${ALIEN_JDL_LPMANCHORPASSNAME:-unknown}'
10141014 AODtask ['cmd' ] += ' --anchor-prod ${ALIEN_JDL_MCANCHOR:-unknown}'
0 commit comments