1 def fix_mille_paths_for_algo(algo):
3 Add pre.algorithm to fix mille file paths
5 Attach a pre-algorithm which loops over collector files
6 and fixes the paths to mille binary files (in case they have
7 been moved since creation - otherwise the effect is null)
9 If previous pre_algorithm exists, it is run after the fix
14 algo : caf.framework.Algorithm
15 The algorithm to which to attach pre_algorithm
18 prev_prealgo = algo.pre_algorithm
20 def fixMillePaths(algorithm, iteration):
24 print(
"Now fixing .mille binary paths in CollectorOutput.root files")
26 for path
in algorithm.getInputFileNames():
27 file = ROOT.TFile(path,
"UPDATE")
28 dirname = os.path.dirname(path)
30 runRange = file.Get(
"MillepedeCollector/RunRange")
31 runSet = [(-1, -1)]
if runRange.getGranularity() ==
"all" else [(e, r)
for e, r
in runRange.getExpRunSet()]
33 for exp, run
in runSet:
34 milleData = file.Get(f
"MillepedeCollector/mille/mille_{exp}.{run}/mille_1")
36 fixed_milleFiles = [os.path.join(dirname, os.path.basename(milleFile))
for milleFile
in milleData.getFiles()]
39 for f
in fixed_milleFiles:
42 file.cd(f
"MillepedeCollector/mille/mille_{exp}.{run}/")
43 milleData.Write(
"", ROOT.TObject.kOverwrite)
48 if prev_prealgo
is not None:
49 prev_prealgo(algorithm, iteration)
51 algo.pre_algorithm = fixMillePaths