25from extramodules.converterManager
import converterManager
27from extramodules.debugSettings
import debugSettings
28from extramodules.monitoring
import dispArgs
29from extramodules.descriptor
import inputDescriptors, outputDescriptors
30from extramodules.dqTranscations
import aodFileChecker, centTranscation, forgettedArgsChecker, jsonTypeChecker, mainTaskChecker, trackPropChecker, trackPropTransaction
31from extramodules.configSetter
import multiConfigurableSet
32from extramodules.pycacheRemover
import runPycacheRemover
34from dqtasks.tableMakerMC
import TableMakerMC
40centralityTableParameters = [
41 "estRun2V0M",
"estRun2SPDtks",
"estRun2SPDcls",
"estRun2CL0",
"estRun2CL1",
"estFV0A",
"estFT0M",
"estFDDM",
"estNTPV",
45ft0Parameters = [
"processFT0",
"processNoFT0",
"processOnlyFT0",
"processRun2"]
47pidParameters = [
"pid-el",
"pid-mu",
"pid-pi",
"pid-ka",
"pid-pr",
"pid-de",
"pid-tr",
"pid-he",
"pid-al",]
49booleanSelections = [
"true",
"false"]
60commonDeps = [
"o2-analysis-timestamp",
"o2-analysis-event-selection",
"o2-analysis-multiplicity-table",]
62 "o2-analysis-trackselection",
"o2-analysis-trackextension",
"o2-analysis-pid-tof-base",
"o2-analysis-pid-tof",
63 "o2-analysis-pid-tof-full",
"o2-analysis-pid-tof-beta",
"o2-analysis-pid-tpc-full",
67 "processFullTiny": [],
68 "processFullWithCov": [],
69 "processFullWithCent": [
"o2-analysis-centrality-table"],
70 "processBarrelOnly": [],
71 "processBarrelOnlyWithCov": [],
72 "processBarrelOnlyWithV0Bits": [
"o2-analysis-dq-v0-selector",
"o2-analysis-weak-decay-indices",],
73 "processBarrelOnlyWithEventFilter": [
"o2-analysis-dq-filter-pp"],
74 "processBarrelOnlyWithQvector": [
"o2-analysis-centrality-table",
"o2-analysis-dq-flow",],
75 "processBarrelOnlyWithCent": [
"o2-analysis-centrality-table"],
76 "processMuonOnly": [],
77 "processMuonOnlyWithCov": [],
78 "processMuonOnlyWithCent": [
"o2-analysis-centrality-table"],
79 "processMuonOnlyWithQvector": [
"o2-analysis-centrality-table",
"o2-analysis-dq-flow",],
80 "processMuonOnlyWithFilter": [
"o2-analysis-dq-filter-pp"]
92 "table":
"AOD/REDUCEDEVENT/0",
93 "treename":
"ReducedEvents"
95 "ReducedEventsExtended": {
96 "table":
"AOD/REEXTENDED/0",
97 "treename":
"ReducedEventsExtended",
99 "ReducedEventsVtxCov": {
100 "table":
"AOD/REVTXCOV/0",
101 "treename":
"ReducedEventsVtxCov",
103 "ReducedEventsQvector": {
104 "table":
"AOD/REQVECTOR/0",
105 "treename":
"ReducedEventsQvector",
107 "ReducedMCEventLabels": {
108 "table":
"AOD/REMCCOLLBL/0",
109 "treename":
"ReducedMCEventLabels",
112 "table":
"AOD/REMC/0",
113 "treename":
"ReducedMCEvents"
116 "table":
"AOD/REDUCEDTRACK/0",
117 "treename":
"ReducedTracks"
119 "ReducedTracksBarrel": {
120 "table":
"AOD/RTBARREL/0",
121 "treename":
"ReducedTracksBarrel",
123 "ReducedTracksBarrelCov": {
124 "table":
"AOD/RTBARRELCOV/0",
125 "treename":
"ReducedTracksBarrelCov",
127 "ReducedTracksBarrelPID": {
128 "table":
"AOD/RTBARRELPID/0",
129 "treename":
"ReducedTracksBarrelPID",
131 "ReducedTracksBarrelLabels": {
132 "table":
"AOD/RTBARRELLABELS/0",
133 "treename":
"ReducedTracksBarrelLabels",
136 "table":
"AOD/RTMC/0",
137 "treename":
"ReducedMCTracks"
140 "table":
"AOD/RTMUON/0",
141 "treename":
"ReducedMuons"
143 "ReducedMuonsExtra": {
144 "table":
"AOD/RTMUONEXTRA/0",
145 "treename":
"ReducedMuonsExtra",
148 "table":
"AOD/RTMUONCOV/0",
149 "treename":
"ReducedMuonsCov"
151 "ReducedMuonsLabels": {
152 "table":
"AOD/RTMUONSLABELS/0",
153 "treename":
"ReducedMuonsLabels",
157commonTables = [
"ReducedEvents",
"ReducedEventsExtended",
"ReducedEventsVtxCov"]
158barrelCommonTables = [
"ReducedTracks",
"ReducedTracksBarrel",
"ReducedTracksBarrelPID"]
159muonCommonTables = [
"ReducedMuons",
"ReducedMuonsExtra"]
162 "processFullTiny": [],
163 "processFullWithCov": [
"ReducedTracksBarrelCov",
"ReducedMuonsCov"],
164 "processFullWithCent": [],
165 "processBarrelOnly": [],
166 "processBarrelOnlyWithCov": [
"ReducedTracksBarrelCov"],
167 "processBarrelOnlyWithV0Bits": [],
168 "processBarrelOnlyWithQvector": [
"ReducedEventsQvector"],
169 "processBarrelOnlyWithEventFilter": [],
170 "processBarrelOnlyWithCent": [],
171 "processMuonOnly": [],
172 "processMuonOnlyWithCov": [
"ReducedMuonsCov"],
173 "processMuonOnlyWithCent": [],
174 "processMuonOnlyWithQvector": [
"ReducedEventsQvector"],
175 "processMuonOnlyWithFilter": [],
183initArgs = TableMakerMC()
187args = initArgs.parseArgs()
188configuredCommands = vars(args)
194forgettedArgsChecker(configuredCommands)
201if args.process
is not None:
202 prefix_process =
"process"
203 args.process = [prefix_process + sub
for sub
in args.process]
206if args.pid
is not None:
208 args.pid = [prefix_pid + sub
for sub
in args.pid]
211if args.est
is not None:
213 args.est = [prefix_est + sub
for sub
in args.est]
216if args.FT0
is not None:
217 prefix_process =
"process"
218 args.FT0 = prefix_process + args.FT0
224with open(args.cfgFileName)
as configFile:
225 config = json.load(configFile)
227jsonTypeChecker(args.cfgFileName)
230logging.info(
"runOverMC : %s, Reduced Tables will be produced for MC", runOverMC)
232taskNameInConfig =
"table-maker-m-c"
233taskNameInCommandLine =
"o2-analysis-dq-table-maker-mc"
235mainTaskChecker(config, taskNameInConfig)
241logging.info(
"Only Select Configured as %s", args.onlySelect)
242if args.onlySelect ==
"true":
243 logging.info(
"INTERFACE MODE : JSON Overrider")
244if args.onlySelect ==
"false":
245 logging.info(
"INTERFACE MODE : JSON Additional")
248tableMakerProcessSearch = set()
250for key, value
in config.items():
251 if isinstance(value, dict):
252 for value, value2
in value.items():
255 if value ==
"aod-file" and args.aod:
256 config[key][value] = args.aod
257 logging.debug(
" - [%s] %s : %s", key, value, args.aod)
260 if (value
in specificDeps.keys())
and args.process:
261 if value
in args.process:
264 if "processOnlyBCs" not in args.process:
265 args.process.append(
"processOnlyBCs")
266 logging.warning(
"You forget to add OnlyBCs value in --process parameter! It will automaticaly added.")
268 config[key][value] = value2
269 logging.debug(
" - [%s] %s : %s", key, value, value2)
271 for s
in config[key].keys():
272 if s
in specificDeps.keys():
273 tableMakerProcessSearch.add(s)
275 centSearch = [s
for s
in args.process
if "Cent" in s]
277 elif args.onlySelect ==
"true":
278 if value ==
"processOnlyBCs":
279 config[key][value] =
"true"
280 logging.debug(
" - [%s] %s : true", key, value)
283 config[key][value] = value2
284 logging.debug(
" - [%s] %s : %s", key, value, value2)
287 if (value
in pidParameters)
and args.pid
and key !=
"tof-pid":
288 if value
in args.pid:
290 config[key][value] = value2
291 logging.debug(
" - [%s] %s : %s", key, value, value2)
292 elif args.onlySelect ==
"true":
294 config[key][value] = value2
295 logging.debug(
" - [%s] %s : %s", key, value, value2)
298 if (value
in centralityTableParameters)
and args.est:
299 if value
in args.est:
301 config[key][value] = value2
302 logging.debug(
" - [%s] %s : %s", key, value, value2)
303 elif args.onlySelect ==
"true":
305 config[key][value] = value2
306 logging.debug(
" - [%s] %s : %s", key, value, value2)
309 if value ==
"cfgEventCuts" and args.cfgEventCuts:
310 multiConfigurableSet(config, key, value, args.cfgEventCuts, args.onlySelect)
311 logging.debug(
" - [%s] %s : %s", key, value, args.cfgEventCuts)
312 if value ==
"cfgBarrelTrackCuts" and args.cfgBarrelTrackCuts:
313 multiConfigurableSet(config, key, value, args.cfgBarrelTrackCuts, args.onlySelect)
314 logging.debug(
" - [%s] %s : %s", key, value, args.cfgBarrelTrackCuts)
315 if value ==
"cfgMuonCuts" and args.cfgMuonCuts:
316 multiConfigurableSet(config, key, value, args.cfgMuonCuts, args.onlySelect)
317 logging.debug(
" - [%s] %s : %s", key, value, args.cfgMuonCuts)
318 if value ==
"cfgBarrelLowPt" and args.cfgBarrelLowPt:
319 config[key][value] = args.cfgBarrelLowPt
320 logging.debug(
" - [%s] %s : %s", key, value, args.cfgBarrelLowPt)
321 if value ==
"cfgMuonLowPt" and args.cfgMuonLowPt:
322 config[key][value] = args.cfgMuonLowPt
323 logging.debug(
" - [%s] %s : %s", key, value, args.cfgMuonLowPt)
324 if value ==
"cfgNoQA" and args.cfgNoQA:
325 config[key][value] = args.cfgNoQA
326 logging.debug(
" - [%s] %s : %s", key, value, args.cfgNoQA)
327 if value ==
"cfgDetailedQA" and args.cfgDetailedQA:
328 config[key][value] = args.cfgDetailedQA
329 logging.debug(
" - [%s] %s : %s", key, value, args.cfgDetailedQA)
330 if value ==
"cfgMinTpcSignal" and args.cfgMinTpcSignal:
331 config[key][value] = args.cfgMinTpcSignal
332 logging.debug(
" - [%s] %s : %s", key, value, args.cfgMinTpcSignal)
333 if value ==
"cfgMaxTpcSignal" and args.cfgMaxTpcSignal:
334 config[key][value] = args.cfgMaxTpcSignal
335 logging.debug(
" - [%s] %s : %s", key, value, args.cfgMaxTpcSignal)
336 if value ==
"cfgMCsignals" and args.cfgMCsignals:
337 multiConfigurableSet(config, key, value, args.cfgMCsignals, args.onlySelect)
338 logging.debug(
" - [%s] %s : %s", key, value, args.cfgMCsignals)
341 if value ==
"syst" and args.syst:
342 config[key][value] = args.syst
343 logging.debug(
" - [%s] %s : %s", key, value, args.syst)
344 if value ==
"muonSelection" and args.muonSelection:
345 config[key][value] = args.muonSelection
346 logging.debug(
" - [%s] %s : %s", key, value, args.muonSelection)
347 if value ==
"customDeltaBC" and args.customDeltaBC:
348 config[key][value] = args.customDeltaBC
349 logging.debug(
" - [%s] %s : %s", key, value, args.customDeltaBC)
352 if value ==
"doVertexZeq" and args.isVertexZeq:
353 if args.isVertexZeq ==
"true":
354 config[key][value] =
"1"
355 config[key][
"doDummyZeq"] =
"0"
356 logging.debug(
" - %s %s : 1", key, value)
357 logging.debug(
" - [%s] doDummyZeq : 0", key)
358 if args.isVertexZeq ==
"false":
359 config[key][value] =
"0"
360 config[key][
"doDummyZeq"] =
"1"
361 logging.debug(
" - %s %s : 0", key, value)
362 logging.debug(
" - [%s] doDummyZeq : 1", key)
365 if value ==
"processWSlice" and args.isWSlice:
366 if args.isWSlice ==
"true":
367 config[key][value] =
"true"
368 config[key][
"processWoSlice"] =
"false"
369 logging.debug(
" - %s %s : true", key, value)
370 logging.debug(
" - [%s] processWoSlice : false", key)
371 if args.isWSlice ==
"false":
372 config[key][value] =
"false"
373 config[key][
"processWoSlice"] =
"true"
374 logging.debug(
" - %s %s : false", key, value)
375 logging.debug(
" - [%s] processWoSlice : true", key)
378 if value ==
"tof-expreso" and args.tof_expreso:
379 config[key][value] = args.tof_expreso
380 logging.debug(
" - [%s] %s : %s", key, value, args.tof_expreso)
383 if (value
in ft0Parameters)
and args.FT0
and key ==
"tof-event-time":
384 if value == args.FT0:
386 config[key][value] = value2
387 logging.debug(
" - [%s] %s : %s", key, value, value2)
388 elif value != args.FT0:
390 config[key][value] = value2
391 logging.debug(
" - [%s] %s : %s", key, value, value2)
394 if args.isCovariance:
395 if (value ==
"processStandard" or value ==
"processCovariance")
and args.isCovariance ==
"false":
396 config[key][
"processStandard"] =
"true"
397 config[key][
"processCovariance"] =
"false"
398 logging.debug(
" - [%s] processStandart : true", key)
399 logging.debug(
" - [%s] processCovariance : false", key)
400 if (value ==
"processStandard" or value ==
"processCovariance")
and args.isCovariance ==
"true":
401 config[key][
"processStandard"] =
"false"
402 config[key][
"processCovariance"] =
"true"
403 logging.debug(
" - [%s] processStandart : false", key)
404 logging.debug(
" - [%s] processCovariance : true", key)
408 config[key][value] = args.itsMatching
409 logging.debug(
" - [%s] %s : %s", key, value, args.itsMatching)
412centTranscation(config, args.process, args.syst, centSearch)
413aodFileChecker(args.aod)
417from extramodules.getTTrees
import getTTrees
420if args.aod
is not None:
423 ttreeList = config[
"internal-dpl-aod-reader"][
"aod-file"]
426trackPropChecker(commonDeps, barrelDeps)
433updatedConfigFileName =
"tempConfigTableMakerMC.json"
435with open(updatedConfigFileName,
"w")
as outputFile:
436 json.dump(config, outputFile, indent = 2)
440for dep
in commonDeps:
443for processFunc
in specificDeps.keys():
444 if processFunc
not in config[taskNameInConfig].keys():
446 if config[taskNameInConfig][processFunc] ==
"true":
447 if "processFull" in processFunc
or "processBarrel" in processFunc:
448 for dep
in barrelDeps:
450 for dep
in specificDeps[processFunc]:
455for table
in commonTables:
456 tablesToProduce[table] = 1
459 tablesToProduce[
"ReducedMCEvents"] = 1
460 tablesToProduce[
"ReducedMCEventLabels"] = 1
462for processFunc
in specificDeps.keys():
463 if processFunc
not in config[taskNameInConfig].keys():
465 if config[taskNameInConfig][processFunc] ==
"true":
466 logging.info(
"processFunc ========")
467 logging.info(
"%s", processFunc)
468 if "processFull" in processFunc
or "processBarrel" in processFunc:
469 logging.info(
"common barrel tables==========")
470 for table
in barrelCommonTables:
471 logging.info(
"%s", table)
472 tablesToProduce[table] = 1
474 tablesToProduce[
"ReducedTracksBarrelLabels"] = 1
475 if "processFull" in processFunc
or "processMuon" in processFunc:
476 logging.info(
"common muon tables==========")
477 for table
in muonCommonTables:
478 logging.info(
"%s", table)
479 tablesToProduce[table] = 1
481 tablesToProduce[
"ReducedMuonsLabels"] = 1
483 tablesToProduce[
"ReducedMCTracks"] = 1
484 logging.info(
"specific tables==========")
485 for table
in specificTables[processFunc]:
486 logging.info(
"%s", table)
487 tablesToProduce[table] = 1
489readerConfigFileName =
"aodReaderTempConfig.json"
490writerConfigFileName =
"aodWriterTempConfig.json"
493outputDescriptors(tablesToProduce, tables)
494inputDescriptors(tablesToProduce, tables)
497 taskNameInCommandLine +
" --configuration json://" + updatedConfigFileName +
498 " --severity error --shm-segment-size 12000000000 --aod-writer-json " + writerConfigFileName +
" -b"
500if args.aod_memory_rate_limit:
502 taskNameInCommandLine +
" --configuration json://" + updatedConfigFileName +
503 " --severity error --shm-segment-size 12000000000 --aod-memory-rate-limit " + args.aod_memory_rate_limit +
" --aod-writer-json " +
504 writerConfigFileName +
" -b"
507for dep
in depsToRun.keys():
508 commandToRun +=
" | " + dep +
" --configuration json://" + updatedConfigFileName +
" -b"
509 logging.debug(
"%s added your workflow", dep)
512 logging.debug("o2-analysis-mc-converter added your workflow")
513 commandToRun += (
" | o2-analysis-mc-converter --configuration json://" + updatedConfigFileName +
" -b")
516 commandToRun += (
" | o2-analysis-fdd-converter --configuration json://" + updatedConfigFileName +
" -b")
517 logging.debug(
"o2-analysis-fdd-converter added your workflow")
519if args.add_track_prop:
520 commandToRun += (
" | o2-analysis-track-propagation --configuration json://" + updatedConfigFileName +
" -b")
521 logging.debug(
"o2-analysis-track-propagation added your workflow")
524print("====================================================================================================================")
525logging.info("Command to run:")
526logging.info(commandToRun)
527print("====================================================================================================================")
528logging.info("Tables to produce:")
529logging.info(tablesToProduce.keys())
530print("====================================================================================================================")
533# Listing Added Commands
534dispArgs(configuredCommands)
536os.system(commandToRun)