forked from iarsene/O2DQworkflows
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrunFilterPP.py
executable file
·79 lines (62 loc) · 3.67 KB
/
runFilterPP.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#!/usr/bin/env python3
import argparse
import sys
import json
import os
parser = argparse.ArgumentParser(description='Arguments to pass')
parser.add_argument('cfgFileName', metavar='text', default='config.json', help='config file name')
parser.add_argument('--arg', help='Configuration argument')
parser.add_argument('--add_mc_conv', help="Add the converter from mcparticle to mcparticle+001", action="store_true")
parser.add_argument('--add_fdd_conv', help="Add the fdd converter", action="store_true")
parser.add_argument('--add_track_prop', help="Add track propagation to the innermost layer (TPC or ITS)", action="store_true")
parser.add_argument("--add_col_conv", help = "Add the converter from collision to collision+001", action = "store_true")
extrargs = parser.parse_args()
commonDeps = ["o2-analysis-timestamp", "o2-analysis-event-selection", "o2-analysis-multiplicity-table", "o2-analysis-trackselection", "o2-analysis-track-propagation", "o2-analysis-pid-tof-base", "o2-analysis-pid-tof", "o2-analysis-pid-tof-full", "o2-analysis-pid-tof-beta", "o2-analysis-pid-tpc-full","o2-analysis-pid-tpc-base", "o2-analysis-fwdtrackextension","o2-analysis-bc-converter","o2-analysis-tracks-extra-converter"]
# Make some checks on provided arguments
if len(sys.argv) < 2:
print("ERROR: Invalid syntax! The command line should look like this:")
print(" ./runFilterPP.py <yourConfig.json> [task:param:value] ...")
sys.exit()
# Load the configuration file provided as the first parameter
config = {}
with open(extrargs.cfgFileName) as configFile:
config = json.load(configFile)
if extrargs.arg != "" and extrargs.arg is not None:
args = [line.split(':') for line in extrargs.arg.split(',') if line]
for threeIndex in args:
if len(threeIndex) != 3:
print("ERROR: Wrong parameter syntax for --arg: ", threeIndex, " in ", extrargs.arg)
print("Correct syntax: task:param:value,task:param:value ... ")
print("Example: --arg d-q-barrel-track-selection:cfgWithQA:true")
sys.exit()
for arg in args:
config[arg[0]][arg[1]] = arg[2]
taskNameInConfig = "d-q-filter-p-p-task"
taskNameInCommandLine = "o2-analysis-dq-filter-pp-with-association"
if not taskNameInConfig in config:
print("ERROR: Task to be run not found in the configuration file!")
sys.exit()
# Write the updated configuration file into a temporary file
updatedConfigFileName = "tempConfig.json"
with open(updatedConfigFileName,'w') as outputFile:
json.dump(config, outputFile, indent = 2)
# Check which dependencies need to be run
depsToRun = {}
for dep in commonDeps:
depsToRun[dep] = 1
commandToRun = taskNameInCommandLine + " --configuration json://" + updatedConfigFileName + " --severity error --shm-segment-size 12000000000 -b"
for dep in depsToRun.keys():
commandToRun += " | " + dep + " --configuration json://" + updatedConfigFileName + " -b"
if extrargs.add_mc_conv:
commandToRun += " | o2-analysis-mc-converter --configuration json://" + updatedConfigFileName + " -b"
if extrargs.add_fdd_conv:
commandToRun += " | o2-analysis-fdd-converter --configuration json://" + updatedConfigFileName + " -b"
if extrargs.add_track_prop:
commandToRun += " | o2-analysis-track-propagation --configuration json://" + updatedConfigFileName + " -b"
if extrargs.add_col_conv:
commandToRun += " | o2-analysis-collision-converter --configuration json://" + updatedConfigFileName + " -b"
print("====================================================================================================================")
print("Command to run:")
print(commandToRun)
print("====================================================================================================================")
os.system(commandToRun)