10def fix_mille_paths_for_algo(algo):
12 Add pre.algorithm to fix mille file paths
14 Attach a pre-algorithm which loops over collector files
15 and fixes the paths to mille binary files (
in case they have
16 been moved since creation - otherwise the effect
is null)
18 If previous pre_algorithm exists, it
is run after the fix
23 algo : caf.framework.Algorithm
24 The algorithm to which to attach pre_algorithm
27 prev_prealgo = algo.pre_algorithm
29 def fixMillePaths(algorithm, iteration):
33 print(
"Now fixing .mille binary paths in CollectorOutput.root files")
35 for path
in algorithm.getInputFileNames():
36 file = ROOT.TFile(path,
"UPDATE")
37 dirname = os.path.dirname(path)
39 runRange = file.Get(
"MillepedeCollector/RunRange")
40 runSet = [(-1, -1)]
if runRange.getGranularity() ==
"all" else [(e, r)
for e, r
in runRange.getExpRunSet()]
42 for exp, run
in runSet:
43 milleData = file.Get(f
"MillepedeCollector/mille/mille_{exp}.{run}/mille_1")
45 fixed_milleFiles = [os.path.join(dirname, os.path.basename(str(milleFile)))
for milleFile
in milleData.getFiles()]
48 for f
in fixed_milleFiles:
54 print(
"Missing file: ", f)
56 file.cd(f
"MillepedeCollector/mille/mille_{exp}.{run}/")
57 milleData.Write(
"", ROOT.TObject.kOverwrite)
62 if prev_prealgo
is not None:
63 prev_prealgo(algorithm, iteration)
65 algo.pre_algorithm = fixMillePaths