@@ -186,6 +186,47 @@ def add_analysis_post_processing_tasks(workflow):
186186 task ["cmd" ] = f"root -l -b -q { post_processing_macro } { cmd } "
187187 workflow .append (task )
188188
189+ def get_additional_workflows (input_aod ):
190+ additional_workflows = []
191+
192+ # Treat case we have a text file as input. Use the first line in this case
193+ if input_aod .endswith (".txt" ):
194+ if input_aod .startswith ("@" ):
195+ input_aod = input_aod [1 :]
196+ with open (input_aod ) as f :
197+ input_aod = f .readline ().strip ('\n ' )
198+
199+ if input_aod .endswith (".root" ):
200+ from ROOT import TFile
201+ if input_aod .startswith ("alien://" ):
202+ from ROOT import TGrid
203+ TGrid .Connect ("alien" )
204+ froot = TFile .Open (input_aod , "READ" )
205+ found_O2collision_001 = False
206+ found_O2zdc_001 = False
207+ found_O2bc_001 = False
208+ for i in froot .GetListOfKeys ():
209+ if "DF_" not in i .GetName ():
210+ continue
211+ df_dir = froot .Get (i .GetName ())
212+ # print(i)
213+ for j in df_dir .GetListOfKeys ():
214+ # print(j)
215+ if "O2collision_001" in j .GetName ():
216+ found_O2collision_001 = True
217+ if "O2zdc_001" in j .GetName ():
218+ found_O2zdc_001 = True
219+ if "O2bc_001" in j .GetName ():
220+ found_O2bc_001 = True
221+ if not found_O2collision_001 :
222+ additional_workflows .append ("o2-analysis-collision-converter --doNotSwap" )
223+ if not found_O2zdc_001 :
224+ additional_workflows .append ("o2-analysis-zdc-converter" )
225+ if not found_O2bc_001 :
226+ additional_workflows .append ("o2-analysis-bc-converter" )
227+ break
228+ return additional_workflows
229+
189230
190231def add_analysis_tasks (workflow , input_aod = "./AO2D.root" , output_dir = "./Analysis" , * , analyses_only = None , is_mc = True , needs = None , autoset_converters = False , include_disabled_analyses = False , timeout = None ):
191232 """Add default analyses to user workflow
@@ -206,39 +247,15 @@ def add_analysis_tasks(workflow, input_aod="./AO2D.root", output_dir="./Analysis
206247 if specified, list of other tasks which need to be run before
207248 """
208249
209- additional_workflows = []
210250 if not input_aod .startswith ("alien://" ):
211251 input_aod = abspath (input_aod )
212- if autoset_converters : # This is needed to run with the latest TAG of the O2Physics with the older data
213- if input_aod .endswith (".root" ):
214- from ROOT import TFile
215- froot = TFile .Open (input_aod , "READ" )
216- found_O2collision_001 = False
217- found_O2zdc_001 = False
218- found_O2bc_001 = False
219- for i in froot .GetListOfKeys ():
220- if "DF_" not in i .GetName ():
221- continue
222- df_dir = froot .Get (i .GetName ())
223- # print(i)
224- for j in df_dir .GetListOfKeys ():
225- # print(j)
226- if "O2collision_001" in j .GetName ():
227- found_O2collision_001 = True
228- if "O2zdc_001" in j .GetName ():
229- found_O2zdc_001 = True
230- if "O2bc_001" in j .GetName ():
231- found_O2bc_001 = True
232- if not found_O2collision_001 :
233- additional_workflows .append ("o2-analysis-collision-converter --doNotSwap" )
234- if not found_O2zdc_001 :
235- additional_workflows .append ("o2-analysis-zdc-converter" )
236- if not found_O2bc_001 :
237- additional_workflows .append ("o2-analysis-bc-converter" )
238- break
239252 if input_aod .endswith (".txt" ) and not input_aod .startswith ("@" ):
240253 input_aod = f"@{ input_aod } "
241254
255+ additional_workflows = []
256+ if autoset_converters : # This is needed to run with the latest TAG of the O2Physics with the older data
257+ additional_workflows = get_additional_workflows (input_aod )
258+
242259 data_or_mc = ANALYSIS_VALID_MC if is_mc else ANALYSIS_VALID_DATA
243260
244261 for ana in load_analyses (analyses_only , include_disabled_analyses = include_disabled_analyses ):
0 commit comments