7373workflow ['stages' ] = []
7474
7575taskcounter = 0
76- def createTask (name = '' , needs = [], tf = - 1 , cwd = './' ):
76+ def createTask (name = '' , needs = [], tf = - 1 , cwd = './' , lab = [], cpu = 0 , mem = 0 ):
7777 global taskcounter
7878 taskcounter = taskcounter + 1
79- return { 'name' : name , 'cmd' :'' , 'needs' : needs , 'resources' : { 'cpu' : - 1 , 'mem' : - 1 }, 'timeframe' : tf , 'labels' : [] , 'cwd' : cwd }
79+ return { 'name' : name , 'cmd' :'' , 'needs' : needs , 'resources' : { 'cpu' : cpu , 'mem' : mem }, 'timeframe' : tf , 'labels' : lab , 'cwd' : cwd }
8080
81- def getDPL_global_options ():
81+ def getDPL_global_options (bigshm = False ):
8282 if args .noIPC != None :
83- return "-b --run --no-IPC"
84- return "-b --run --shm-segment-size ${SHMSIZE:-50000000000} --session " + str (taskcounter )
83+ return "-b --run --rate 1 --no-IPC"
84+ if bigshm :
85+ return "-b --run --rate 1 --shm-segment-size ${SHMSIZE:-50000000000} --session " + str (taskcounter ) + ' --driver-client-backend ws://'
86+ else :
87+ return "-b --run --rate 1 --session " + str (taskcounter ) + ' --driver-client-backend ws://'
8588
8689
8790doembedding = True if args .embedding == 'True' or args .embedding == True else False
@@ -91,7 +94,7 @@ def getDPL_global_options():
9194 NBKGEVENTS = args .nb
9295 GENBKG = args .genBkg
9396 INIBKG = args .iniBkg
94- BKGtask = createTask (name = 'bkgsim' )
97+ BKGtask = createTask (name = 'bkgsim' , lab = [ "GEANT" ], cpu = '8' )
9598 BKGtask ['cmd' ]= 'o2-sim -e ' + SIMENGINE + ' -j ' + str (NWORKERS ) + ' -n ' + str (NBKGEVENTS ) + ' -g ' + str (GENBKG ) + str (MODULES ) + ' -o bkg --configFile ' + str (INIBKG )
9699 workflow ['stages' ].append (BKGtask )
97100
@@ -197,7 +200,7 @@ def getDPL_global_options():
197200 if doembedding :
198201 # link background files to current working dir for this timeframe
199202 LinkBKGtask = createTask (name = 'linkbkg_' + str (tf ), needs = [BKGtask ['name' ]], tf = tf , cwd = timeframeworkdir )
200- LinkBKGtask ['cmd' ]= 'ln -s ../bkg*.root .'
203+ LinkBKGtask ['cmd' ]= 'ln -nsf ../bkg*.root .'
201204 workflow ['stages' ].append (LinkBKGtask )
202205
203206 # transport signals
@@ -206,73 +209,96 @@ def getDPL_global_options():
206209 embeddinto = "--embedIntoFile bkg_Kine.root" if doembedding else ""
207210 if doembedding :
208211 signalneeds = signalneeds + [ BKGtask ['name' ], LinkBKGtask ['name' ] ]
209- SGNtask = createTask (name = 'sgnsim_' + str (tf ), needs = signalneeds , tf = tf , cwd = 'tf' + str (tf ))
210- #SGNtask['cmd']='o2-sim -e '+str(SIMENGINE) + ' ' + str(MODULES) + ' -n ' + str(NSIGEVENTS) + ' -j ' + str(NWORKERS) + ' -g extgen \
211- # --configFile ${O2DPG_ROOT}/MC/config/PWGHF/ini/GeneratorHF.ini \
212- # --configKeyValues \"GeneratorPythia8.config=pythia8_'+ str(tf) +'.cfg\"' \
213- # + ' -o ' + signalprefix + ' ' + embeddinto
212+ SGNtask = createTask (name = 'sgnsim_' + str (tf ), needs = signalneeds , tf = tf , cwd = 'tf' + str (tf ), lab = ["GEANT" ], cpu = '5.' )
214213 SGNtask ['cmd' ]= 'o2-sim -e ' + str (SIMENGINE ) + ' ' + str (MODULES ) + ' -n ' + str (NSIGEVENTS ) + ' -j ' + str (NWORKERS ) + ' -g ' + str (GENERATOR ) + ' ' + str (TRIGGER )+ ' ' + str (CONFKEY ) + ' ' + str (INIFILE ) + ' -o ' + signalprefix + ' ' + embeddinto
215214 workflow ['stages' ].append (SGNtask )
216215
217216 # some tasks further below still want geometry + grp in fixed names, so we provide it here
218217 # Alternatively, since we have timeframe isolation, we could just work with standard o2sim_ files
219- LinkGRPFileTask = createTask (name = 'linkGRP_' + str (tf ), needs = [SGNtask ['name' ]], tf = tf , cwd = timeframeworkdir )
220- LinkGRPFileTask ['cmd' ]= 'ln -s ' + signalprefix + '_grp.root o2sim_grp.root ; ln -s ' + signalprefix + '_geometry.root o2sim_geometry.root'
218+ # We need to be careful here and distinguish between embedding and non-embedding cases
219+ # (otherwise it can confuse itstpcmatching, see O2-2026). This is because only one of the GRPs is updated during digitization.
220+ if doembedding :
221+ LinkGRPFileTask = createTask (name = 'linkGRP_' + str (tf ), needs = [BKGtask ['name' ]], tf = tf , cwd = timeframeworkdir )
222+ LinkGRPFileTask ['cmd' ]= 'ln -nsf bkg_grp.root o2sim_grp.root ; ln -nsf bkg_geometry.root o2sim_geometry.root'
223+ else :
224+ LinkGRPFileTask = createTask (name = 'linkGRP_' + str (tf ), needs = [SGNtask ['name' ]], tf = tf , cwd = timeframeworkdir )
225+ LinkGRPFileTask ['cmd' ]= 'ln -nsf ' + signalprefix + '_grp.root o2sim_grp.root ; ln -nsf ' + signalprefix + '_geometry.root o2sim_geometry.root'
221226 workflow ['stages' ].append (LinkGRPFileTask )
222227
223228
224229 CONTEXTFILE = 'collisioncontext.root'
225230
226231 simsoption = ' --sims ' + ('bkg,' + signalprefix if doembedding else signalprefix )
227- TPCDigitask = createTask (name = 'tpcdigi_' + str (tf ), needs = [SGNtask ['name' ], LinkGRPFileTask ['name' ]], tf = tf , cwd = timeframeworkdir )
228- TPCDigitask ['cmd' ] = 'o2-sim-digitizer-workflow ' + getDPL_global_options () + ' -n ' + str (args .ns ) + simsoption + ' --onlyDet TPC --interactionRate 50000 --tpc-lanes ' + str (NWORKERS ) + ' --outcontext ' + str (CONTEXTFILE )
232+
233+ ContextTask = createTask (name = 'digicontext_' + str (tf ), needs = [SGNtask ['name' ], LinkGRPFileTask ['name' ]], tf = tf , cwd = timeframeworkdir , lab = ["DIGI" ], cpu = '8' )
234+
235+ ContextTask ['cmd' ] = 'o2-sim-digitizer-workflow --only-context --interactionRate 50000 ' + getDPL_global_options () + ' -n ' + str (args .ns ) + simsoption
236+ workflow ['stages' ].append (ContextTask )
237+
238+ TPCDigitask = createTask (name = 'tpcdigi_' + str (tf ), needs = [ContextTask ['name' ], LinkGRPFileTask ['name' ]],
239+ tf = tf , cwd = timeframeworkdir , lab = ["DIGI" ], cpu = '8' , mem = '16000' )
240+ TPCDigitask ['cmd' ] = 'o2-sim-digitizer-workflow ' + getDPL_global_options (bigshm = True ) + ' -n ' + str (args .ns ) + simsoption + ' --onlyDet TPC --interactionRate 50000 --tpc-lanes ' + str (NWORKERS ) + ' --incontext ' + str (CONTEXTFILE )
229241 workflow ['stages' ].append (TPCDigitask )
230242
231- # The TRD digi task has a dependency on TPC only because of the digitization context (and because they both use CPU efficiently)
232- # TODO: activate only if TRD present
233- TRDDigitask = createTask (name = 'trddigi_' + str (tf ), needs = [TPCDigitask ['name' ]], tf = tf , cwd = timeframeworkdir )
243+ TRDDigitask = createTask (name = 'trddigi_' + str (tf ), needs = [ContextTask ['name' ]], tf = tf , cwd = timeframeworkdir , lab = ["DIGI" ], cpu = '8' , mem = '8000' )
234244 TRDDigitask ['cmd' ] = 'o2-sim-digitizer-workflow ' + getDPL_global_options () + ' -n ' + str (args .ns ) + simsoption + ' --onlyDet TRD --interactionRate 50000 --configKeyValues \" TRDSimParams.digithreads=' + str (NWORKERS ) + '\" --incontext ' + str (CONTEXTFILE )
235245 workflow ['stages' ].append (TRDDigitask )
236246
237- RESTDigitask = createTask (name = 'restdigi_' + str (tf ), needs = [TPCDigitask ['name' ], LinkGRPFileTask ['name' ]], tf = tf , cwd = timeframeworkdir )
238- RESTDigitask ['cmd' ] = 'o2-sim-digitizer-workflow ' + getDPL_global_options () + ' -n ' + str (args .ns ) + simsoption + ' --skipDet TRD,TPC --interactionRate 50000 --incontext ' + str (CONTEXTFILE )
239- workflow ['stages' ].append (RESTDigitask )
247+ # RESTDigitask=createTask(name='restdigi_'+str(tf), needs=[ContextTask['name'], LinkGRPFileTask['name']], tf=tf, cwd=timeframeworkdir, lab=["DIGI"], cpu='medium', mem='8000')
248+ # RESTDigitask['cmd'] = 'o2-sim-digitizer-workflow ' + getDPL_global_options() + ' -n ' + str(args.ns) + simsoption + ' --skipDet TRD,TPC --interactionRate 50000 --incontext ' + str(CONTEXTFILE)
249+ # workflow['stages'].append(RESTDigitask)
250+
251+ # we split the digitizers for improved load balancing --> the precise list needs to be made consistent with geometry and active sensors
252+ sensorlist = [ "ITS" , "TOF" , "FT0" , "FV0" , "FDD" , "MCH" , "MID" , "MFT" , "HMP" , "EMC" , "PHS" , "CPV" ]
253+ # these are digitizers which are single threaded
254+ def createRestDigiTask (name ):
255+ t = createTask (name = name , needs = [ContextTask ['name' ]], tf = tf , cwd = timeframeworkdir , lab = ["DIGI" ,"SMALLDIGI" ], cpu = '1' )
256+ t ['cmd' ] = 'o2-sim-digitizer-workflow ' + getDPL_global_options () + ' -n ' + str (args .ns ) + simsoption + ' --onlyDet ' + str (det ) + ' --interactionRate 50000 --incontext ' + str (CONTEXTFILE )
257+ workflow ['stages' ].append (t )
258+ return t
259+
260+ det_to_digitask = {}
261+
262+ for det in sensorlist :
263+ name = str (det ).lower () + "digi_" + str (tf )
264+ t = createRestDigiTask (name )
265+ det_to_digitask [det ]= t
240266
241267 # -----------
242268 # reco
243269 # -----------
244270
245271 # TODO: check value for MaxTimeBin; A large value had to be set tmp in order to avoid crashes bases on "exceeding timeframe limit"
246- TPCRECOtask = createTask (name = 'tpcreco_' + str (tf ), needs = [TPCDigitask ['name' ]], tf = tf , cwd = timeframeworkdir )
247- TPCRECOtask ['cmd' ] = 'o2-tpc-reco-workflow ' + getDPL_global_options () + ' --tpc-digit-reader "--infile tpcdigits.root" --input-type digits --output-type clusters,tracks,send-clusters-per-sector --configKeyValues "GPU_global.continuousMaxTimeBin=100000;GPU_proc.ompThreads=' + str (NWORKERS )+ '"'
272+ TPCRECOtask = createTask (name = 'tpcreco_' + str (tf ), needs = [TPCDigitask ['name' ]], tf = tf , cwd = timeframeworkdir , lab = [ "RECO" ], cpu = '3' , mem = '16000' )
273+ TPCRECOtask ['cmd' ] = 'o2-tpc-reco-workflow ' + getDPL_global_options (bigshm = True ) + ' --tpc-digit-reader "--infile tpcdigits.root" --input-type digits --output-type clusters,tracks,send-clusters-per-sector --configKeyValues "GPU_global.continuousMaxTimeBin=100000;GPU_proc.ompThreads=' + str (NWORKERS )+ '"'
248274 workflow ['stages' ].append (TPCRECOtask )
249275
250- ITSRECOtask = createTask (name = 'itsreco_' + str (tf ), needs = [RESTDigitask [ 'name' ]], tf = tf , cwd = timeframeworkdir )
276+ ITSRECOtask = createTask (name = 'itsreco_' + str (tf ), needs = [det_to_digitask [ "ITS" ][ 'name' ]], tf = tf , cwd = timeframeworkdir , lab = [ "RECO" ], cpu = '1' , mem = '2000' )
251277 ITSRECOtask ['cmd' ] = 'o2-its-reco-workflow --trackerCA --tracking-mode async ' + getDPL_global_options ()
252278 workflow ['stages' ].append (ITSRECOtask )
253279
254- FT0RECOtask = createTask (name = 'ft0reco_' + str (tf ), needs = [RESTDigitask [ 'name' ]], tf = tf , cwd = timeframeworkdir )
280+ FT0RECOtask = createTask (name = 'ft0reco_' + str (tf ), needs = [det_to_digitask [ "FT0" ][ 'name' ]], tf = tf , cwd = timeframeworkdir , lab = [ "RECO" ] )
255281 FT0RECOtask ['cmd' ] = 'o2-ft0-reco-workflow ' + getDPL_global_options ()
256282 workflow ['stages' ].append (FT0RECOtask )
257283
258- ITSTPCMATCHtask = createTask (name = 'itstpcMatch_' + str (tf ), needs = [TPCRECOtask ['name' ], ITSRECOtask ['name' ]], tf = tf , cwd = timeframeworkdir )
259- ITSTPCMATCHtask ['cmd' ]= 'o2-tpcits-match-workflow ' + getDPL_global_options () + ' --tpc-track-reader \" tpctracks.root\" --tpc-native-cluster-reader \" --infile tpc-native-clusters.root\" '
284+ ITSTPCMATCHtask = createTask (name = 'itstpcMatch_' + str (tf ), needs = [TPCRECOtask ['name' ], ITSRECOtask ['name' ]], tf = tf , cwd = timeframeworkdir , lab = [ "RECO" ], mem = '8000' , cpu = '3' )
285+ ITSTPCMATCHtask ['cmd' ]= 'o2-tpcits-match-workflow ' + getDPL_global_options (bigshm = True ) + ' --tpc-track-reader \" tpctracks.root\" --tpc-native-cluster-reader \" --infile tpc-native-clusters.root\" '
260286 workflow ['stages' ].append (ITSTPCMATCHtask )
261287
262288 # this can be combined with TRD digitization if benefical
263- TRDTRAPtask = createTask (name = 'trdtrap_' + str (tf ), needs = [TRDDigitask ['name' ]], tf = tf , cwd = timeframeworkdir )
289+ TRDTRAPtask = createTask (name = 'trdtrap_' + str (tf ), needs = [TRDDigitask ['name' ]], tf = tf , cwd = timeframeworkdir , lab = [ "DIGI" ] )
264290 TRDTRAPtask ['cmd' ] = 'o2-trd-trap-sim'
265291 workflow ['stages' ].append (TRDTRAPtask )
266292
267- TRDTRACKINGtask = createTask (name = 'trdreco_' + str (tf ), needs = [TRDTRAPtask ['name' ], ITSTPCMATCHtask ['name' ], TPCRECOtask ['name' ], ITSRECOtask ['name' ]], tf = tf , cwd = timeframeworkdir )
268- TRDTRACKINGtask ['cmd' ] = 'o2-trd-global-tracking'
293+ TRDTRACKINGtask = createTask (name = 'trdreco_' + str (tf ), needs = [TRDTRAPtask ['name' ], ITSTPCMATCHtask ['name' ], TPCRECOtask ['name' ], ITSRECOtask ['name' ]], tf = tf , cwd = timeframeworkdir , lab = [ "RECO" ] )
294+ TRDTRACKINGtask ['cmd' ] = 'echo "would do TRD tracking"' # ' o2-trd-global-tracking'
269295 workflow ['stages' ].append (TRDTRACKINGtask )
270296
271- TOFRECOtask = createTask (name = 'tofmatch_' + str (tf ), needs = [ITSTPCMATCHtask ['name' ], RESTDigitask [ 'name' ]], tf = tf , cwd = timeframeworkdir )
297+ TOFRECOtask = createTask (name = 'tofmatch_' + str (tf ), needs = [ITSTPCMATCHtask ['name' ], det_to_digitask [ "TOF" ][ 'name' ]], tf = tf , cwd = timeframeworkdir , lab = [ "RECO" ] )
272298 TOFRECOtask ['cmd' ] = 'o2-tof-reco-workflow ' + getDPL_global_options ()
273299 workflow ['stages' ].append (TOFRECOtask )
274300
275- PVFINDERtask = createTask (name = 'pvfinder_' + str (tf ), needs = [ITSTPCMATCHtask ['name' ], FT0RECOtask ['name' ]], tf = tf , cwd = timeframeworkdir )
301+ PVFINDERtask = createTask (name = 'pvfinder_' + str (tf ), needs = [ITSTPCMATCHtask ['name' ], FT0RECOtask ['name' ]], tf = tf , cwd = timeframeworkdir , lab = [ "RECO" ], cpu = '4' )
276302 PVFINDERtask ['cmd' ] = 'o2-primary-vertexing-workflow ' + getDPL_global_options ()
277303 workflow ['stages' ].append (PVFINDERtask )
278304
@@ -282,7 +308,7 @@ def getDPL_global_options():
282308
283309 # enable later. It still has memory access problems
284310 # taskwrapper aod_${tf}.log o2-aod-producer-workflow --aod-writer-keep dangling --aod-writer-resfile "AO2D" --aod-writer-resmode UPDATE --aod-timeframe-id ${tf} $gloOpt
285- AODtask = createTask (name = 'aod_' + str (tf ), needs = [PVFINDERtask ['name' ], TOFRECOtask ['name' ], TRDTRACKINGtask ['name' ]], tf = tf , cwd = timeframeworkdir )
311+ AODtask = createTask (name = 'aod_' + str (tf ), needs = [PVFINDERtask ['name' ], TOFRECOtask ['name' ], TRDTRACKINGtask ['name' ]], tf = tf , cwd = timeframeworkdir , lab = [ "AOD" ] )
286312 AODtask ['cmd' ] = ' echo "Would do AOD (enable later)" '
287313 workflow ['stages' ].append (AODtask )
288314
0 commit comments