25from extramodules.converterManager
import converterManager
26from extramodules.debugSettings
import debugSettings
28from extramodules.monitoring
import dispArgs
29from extramodules.dqTranscations
import aodFileChecker, forgettedArgsChecker, jsonTypeChecker, filterSelsTranscation, mainTaskChecker, trackPropChecker, trackPropTransaction
30from extramodules.configSetter
import multiConfigurableSet
31from extramodules.pycacheRemover
import runPycacheRemover
33from dqtasks.filterPP
import DQFilterPPTask
39centralityTableParameters = [
40 "estRun2V0M",
"estRun2SPDtks",
"estRun2SPDcls",
"estRun2CL0",
"estRun2CL1",
"estFV0A",
"estFT0M",
"estFDDM",
"estNTPV",
44ft0Parameters = [
"processFT0",
"processNoFT0",
"processOnlyFT0",
"processRun2"]
46pidParameters = [
"pid-el",
"pid-mu",
"pid-pi",
"pid-ka",
"pid-pr",
"pid-de",
"pid-tr",
"pid-he",
"pid-al"]
55 "o2-analysis-timestamp",
"o2-analysis-event-selection",
"o2-analysis-multiplicity-table",
"o2-analysis-trackselection",
56 "o2-analysis-trackextension",
"o2-analysis-pid-tof-base",
"o2-analysis-pid-tof",
"o2-analysis-pid-tof-full",
"o2-analysis-pid-tof-beta",
57 "o2-analysis-pid-tpc-full",
61initArgs = DQFilterPPTask()
65args = initArgs.parseArgs()
66configuredCommands = vars(args)
71forgettedArgsChecker(configuredCommands)
78if args.pid
is not None:
80 args.pid = [prefix_pid + sub
for sub
in args.pid]
83if args.FT0
is not None:
84 prefix_process =
"process"
85 args.FT0 = prefix_process + args.FT0
91with open(args.cfgFileName)
as configFile:
92 config = json.load(configFile)
94jsonTypeChecker(args.cfgFileName)
96taskNameInConfig =
"d-q-filter-p-p-task"
97taskNameInCommandLine =
"o2-analysis-dq-filter-pp"
99mainTaskChecker(config, taskNameInConfig)
105logging.info(
"Only Select Configured as %s", args.onlySelect)
106if args.onlySelect ==
"true":
107 logging.info(
"INTERFACE MODE : JSON Overrider")
108if args.onlySelect ==
"false":
109 logging.info(
"INTERFACE MODE : JSON Additional")
111for key, value
in config.items():
112 if isinstance(value, dict):
113 for value, value2
in value.items():
116 if value ==
"aod-file" and args.aod:
117 config[key][value] = args.aod
118 logging.debug(
" - [%s] %s : %s", key, value, args.aod)
121 if value ==
"processSelection" and args.process:
122 for keyCfg, valueCfg
in configuredCommands.items():
123 if valueCfg
is not None:
124 if keyCfg ==
"process":
126 if key ==
"d-q-barrel-track-selection":
127 if "barrelTrackSelection" in valueCfg:
128 config[key][value] =
"true"
129 logging.debug(
" - [%s] %s : true", key, value)
130 if (
"barrelTrackSelection" not in valueCfg
and args.onlySelect ==
"true"):
131 config[key][value] =
"false"
132 logging.debug(
" - [%s] %s : false", key, value)
134 if key ==
"d-q-muons-selection":
135 if "muonSelection" in valueCfg:
136 config[key][value] =
"true"
137 logging.debug(
" - [%s] %s : true", key, value)
138 if "muonSelection" not in valueCfg
and args.onlySelect ==
"true":
139 config[key][value] =
"false"
140 logging.debug(
" - [%s] %s : false", key, value)
143 if value ==
"processEventSelection" and args.process:
144 for keyCfg, valueCfg
in configuredCommands.items():
145 if valueCfg
is not None:
146 if keyCfg ==
"process":
148 if key ==
"d-q-event-selection-task":
149 if "eventSelection" in valueCfg:
150 config[key][value] =
"true"
151 logging.debug(
" - [%s] %s : true", key, value)
152 if "eventSelection" not in valueCfg:
154 "YOU MUST ALWAYS CONFIGURE eventSelection value in --process parameter!! It is Missing and this issue will fixed by CLI"
156 config[key][value] =
"true"
157 logging.debug(
" - [%s] %s : true", key, value)
160 if value ==
"processSelectionTiny" and args.process:
161 for keyCfg, valueCfg
in configuredCommands.items():
162 if valueCfg
is not None:
163 if keyCfg ==
"process":
165 if key ==
"d-q-barrel-track-selection":
166 if "barrelTrackSelectionTiny" in valueCfg:
167 config[key][value] =
"true"
168 logging.debug(
" - [%s] %s : true", key, value)
169 if (
"barrelTrackSelectionTiny" not in valueCfg
and args.onlySelect ==
"true"):
170 config[key][value] =
"false"
171 logging.debug(
" - [%s] %s : false", key, value)
174 if value ==
"processFilterPPTiny" and args.process:
175 for keyCfg, valueCfg
in configuredCommands.items():
176 if valueCfg
is not None:
177 if keyCfg ==
"process":
179 if key ==
"d-q-filter-p-p-task":
180 if "filterPPSelectionTiny" in valueCfg:
181 config[key][value] =
"true"
182 config[key][
"processFilterPP"] =
"false"
183 logging.debug(
" - [%s] %s : true", key, value)
184 logging.debug(
" - [%s] processFilterPP : false", key)
185 if (
"filterPPSelectionTiny" not in valueCfg
and args.onlySelect ==
"true"):
186 config[key][value] =
"false"
187 config[key][
"processFilterPP"] =
"true"
188 logging.debug(
" - [%s] %s : false", key, value)
189 logging.debug(
" - [%s] processFilterPP : true", key)
192 if value ==
"cfgBarrelSels" and args.cfgBarrelSels:
193 multiConfigurableSet(config, key, value, args.cfgBarrelSels, args.onlySelect)
194 logging.debug(
" - [%s] %s : %s", key, value, args.cfgBarrelSels)
195 if value ==
"cfgMuonSels" and args.cfgMuonSels:
196 multiConfigurableSet(config, key, value, args.cfgMuonSels, args.onlySelect)
197 logging.debug(
" - [%s] %s : %s", key, value, args.cfgMuonSels)
200 if value ==
"cfgEventCuts" and args.cfgEventCuts:
201 multiConfigurableSet(config, key, value, args.cfgEventCuts, args.onlySelect)
202 logging.debug(
" - [%s] %s : %s", key, value, args.cfgEventCuts)
203 if value ==
"cfgBarrelTrackCuts" and args.cfgBarrelTrackCuts:
204 multiConfigurableSet(config, key, value, args.cfgBarrelTrackCuts, args.onlySelect)
205 logging.debug(
" - [%s] %s : %s", key, value, args.cfgBarrelTrackCuts)
206 if value ==
"cfgMuonsCuts" and args.cfgMuonsCuts:
207 multiConfigurableSet(config, key, value, args.cfgMuonsCuts, args.onlySelect)
208 logging.debug(
" - [%s] %s : %s", key, value, args.cfgMuonsCuts)
211 if value ==
"cfgWithQA" and args.cfgWithQA:
212 config[key][value] = args.cfgWithQA
213 logging.debug(
" - [%s] %s : %s", key, value, args.cfgWithQA)
216 if (value
in pidParameters)
and args.pid
and key !=
"tof-pid":
217 if value
in args.pid:
219 config[key][value] = value2
220 logging.debug(
" - [%s] %s : %s", key, value, value2)
221 elif args.onlySelect ==
"true":
223 config[key][value] = value2
224 logging.debug(
" - [%s] %s : %s", key, value, value2)
227 if value ==
"syst" and args.syst:
228 config[key][value] = args.syst
229 logging.debug(
" - [%s] %s : %s", key, value, args.syst)
230 if value ==
"muonSelection" and args.muonSelection:
231 config[key][value] = args.muonSelection
232 logging.debug(
" - [%s] %s : %s", key, value, args.muonSelection)
233 if value ==
"customDeltaBC" and args.customDeltaBC:
234 config[key][value] = args.customDeltaBC
235 logging.debug(
" - [%s] %s : %s", key, value, args.customDeltaBC)
238 if value ==
"doVertexZeq" and args.isVertexZeq:
239 if args.isVertexZeq ==
"true":
240 config[key][value] =
"1"
241 config[key][
"doDummyZeq"] =
"0"
242 logging.debug(
" - %s %s : 1", key, value)
243 logging.debug(
" - [%s] doDummyZeq : 0", key)
244 if args.isVertexZeq ==
"false":
245 config[key][value] =
"0"
246 config[key][
"doDummyZeq"] =
"1"
247 logging.debug(
" - %s %s : 0", key, value)
248 logging.debug(
" - [%s] doDummyZeq : 1", key)
251 if value ==
"processWSlice" and args.isWSlice:
252 if args.isWSlice ==
"true":
253 config[key][value] =
"true"
254 config[key][
"processWoSlice"] =
"false"
255 logging.debug(
" - %s %s : true", key, value)
256 logging.debug(
" - [%s] processWoSlice : false", key)
257 if args.isWSlice ==
"false":
258 config[key][value] =
"false"
259 config[key][
"processWoSlice"] =
"true"
260 logging.debug(
" - %s %s : false", key, value)
261 logging.debug(
" - [%s] processWoSlice : true", key)
264 if value ==
"tof-expreso" and args.tof_expreso:
265 config[key][value] = args.tof_expreso
266 logging.debug(
" - [%s] %s : %s", key, value, args.tof_expreso)
269 if (value
in ft0Parameters)
and args.FT0
and key ==
"tof-event-time":
270 if value == args.FT0:
272 config[key][value] = value2
273 logging.debug(
" - [%s] %s : %s", key, value, value2)
274 elif value != args.FT0:
276 config[key][value] = value2
277 logging.debug(
" - [%s] %s : %s", key, value, value2)
281 config[key][value] = args.itsMatching
282 logging.debug(
" - [%s] %s : %s", key, value, args.itsMatching)
284 if value ==
"processDummy" and args.autoDummy:
285 if config[
"d-q-barrel-track-selection"][
"processSelection"] ==
"true":
286 config[
"d-q-barrel-track-selection"][
"processDummy"] =
"false"
287 if config[
"d-q-barrel-track-selection"][
"processSelection"] ==
"false":
288 config[
"d-q-barrel-track-selection"][
"processDummy"] =
"true"
290 if config[
"d-q-muons-selection"][
"processSelection"] ==
"true":
291 config[
"d-q-muons-selection"][
"processDummy"] =
"false"
292 if config[
"d-q-muons-selection"][
"processSelection"] ==
"false":
293 config[
"d-q-muons-selection"][
"processDummy"] =
"true"
295 if config[
"d-q-event-selection-task"][
"processEventSelection"] ==
"true":
296 config[
"d-q-event-selection-task"][
"processDummy"] =
"false"
297 if config[
"d-q-event-selection-task"][
"processEventSelection"] ==
"false":
298 config[
"d-q-event-selection-task"][
"processDummy"] =
"true"
300 if config[
"d-q-filter-p-p-task"][
"processFilterPP"] ==
"true":
301 config[
"d-q-filter-p-p-task"][
"processDummy"] =
"false"
302 if config[
"d-q-filter-p-p-task"][
"processFilterPP"] ==
"false":
303 config[
"d-q-filter-p-p-task"][
"processDummy"] =
"true"
306filterSelsTranscation(args.cfgBarrelSels, args.cfgMuonSels, args.cfgBarrelTrackCuts, args.cfgMuonsCuts, configuredCommands)
307aodFileChecker(args.aod)
311from extramodules.getTTrees
import getTTrees
314if args.aod
is not None:
317 ttreeList = config[
"internal-dpl-aod-reader"][
"aod-file"]
320trackPropChecker(commonDeps, commonDeps)
327updatedConfigFileName =
"tempConfigFilterPP.json"
329with open(updatedConfigFileName,
"w")
as outputFile:
330 json.dump(config, outputFile, indent = 2)
334for dep
in commonDeps:
338 taskNameInCommandLine +
" --configuration json://" + updatedConfigFileName +
" --severity error --shm-segment-size 12000000000 -b"
340for dep
in depsToRun.keys():
341 commandToRun +=
" | " + dep +
" --configuration json://" + updatedConfigFileName +
" -b"
342 logging.debug(
"%s added your workflow", dep)
345 logging.debug(
"o2-analysis-mc-converter added your workflow")
346 commandToRun += (
" | o2-analysis-mc-converter --configuration json://" + updatedConfigFileName +
" -b")
349 commandToRun += (
" | o2-analysis-fdd-converter --configuration json://" + updatedConfigFileName +
" -b")
350 logging.debug(
"o2-analysis-fdd-converter added your workflow")
352if args.add_track_prop:
353 commandToRun += (
" | o2-analysis-track-propagation --configuration json://" + updatedConfigFileName +
" -b")
354 logging.debug(
"o2-analysis-track-propagation added your workflow")
356print(
"====================================================================================================================")
357logging.info(
"Command to run:")
358logging.info(commandToRun)
359print(
"====================================================================================================================")
362dispArgs(configuredCommands)
364os.system(commandToRun)