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, filterSelsTranscation, mainTaskChecker, trackPropChecker, trackPropTransaction
31from extramodules.configSetter
import multiConfigurableSet
32from extramodules.pycacheRemover
import runPycacheRemover
34from dqtasks.tableMaker
import TableMaker
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"]
65commonDeps = [
"o2-analysis-timestamp",
"o2-analysis-event-selection",
"o2-analysis-multiplicity-table"]
67 "o2-analysis-trackselection",
"o2-analysis-trackextension",
"o2-analysis-pid-tof-base",
"o2-analysis-pid-tof",
68 "o2-analysis-pid-tof-full",
"o2-analysis-pid-tof-beta",
"o2-analysis-pid-tpc-full"
72 "processFullTiny": [],
73 "processFullWithCov": [],
74 "processFullWithCent": [
"o2-analysis-centrality-table"],
75 "processBarrelOnly": [],
76 "processBarrelOnlyWithCov": [],
77 "processBarrelOnlyWithV0Bits": [
"o2-analysis-dq-v0-selector"],
78 "processBarrelOnlyWithEventFilter": [
"o2-analysis-dq-filter-pp"],
79 "processBarrelOnlyWithQvector": [
"o2-analysis-centrality-table",
"o2-analysis-dq-flow"],
80 "processBarrelOnlyWithCent": [
"o2-analysis-centrality-table"],
81 "processMuonOnly": [],
82 "processMuonOnlyWithCov": [],
83 "processMuonOnlyWithCent": [
"o2-analysis-centrality-table"],
84 "processMuonOnlyWithQvector": [
"o2-analysis-centrality-table",
"o2-analysis-dq-flow"],
85 "processMuonOnlyWithFilter": [
"o2-analysis-dq-filter-pp"]
97 "table":
"AOD/REDUCEDEVENT/0",
98 "treename":
"ReducedEvents"
100 "ReducedEventsExtended": {
101 "table":
"AOD/REEXTENDED/0",
102 "treename":
"ReducedEventsExtended",
104 "ReducedEventsVtxCov": {
105 "table":
"AOD/REVTXCOV/0",
106 "treename":
"ReducedEventsVtxCov",
108 "ReducedEventsQvector": {
109 "table":
"AOD/REQVECTOR/0",
110 "treename":
"ReducedEventsQvector",
112 "ReducedMCEventLabels": {
113 "table":
"AOD/REMCCOLLBL/0",
114 "treename":
"ReducedMCEventLabels",
117 "table":
"AOD/REMC/0",
118 "treename":
"ReducedMCEvents"
121 "table":
"AOD/REDUCEDTRACK/0",
122 "treename":
"ReducedTracks"
124 "ReducedTracksBarrel": {
125 "table":
"AOD/RTBARREL/0",
126 "treename":
"ReducedTracksBarrel",
128 "ReducedTracksBarrelCov": {
129 "table":
"AOD/RTBARRELCOV/0",
130 "treename":
"ReducedTracksBarrelCov",
132 "ReducedTracksBarrelPID": {
133 "table":
"AOD/RTBARRELPID/0",
134 "treename":
"ReducedTracksBarrelPID",
136 "ReducedTracksBarrelLabels": {
137 "table":
"AOD/RTBARRELLABELS/0",
138 "treename":
"ReducedTracksBarrelLabels",
141 "table":
"AOD/RTMC/0",
142 "treename":
"ReducedMCTracks"
145 "table":
"AOD/RTMUON/0",
146 "treename":
"ReducedMuons"
148 "ReducedMuonsExtra": {
149 "table":
"AOD/RTMUONEXTRA/0",
150 "treename":
"ReducedMuonsExtra",
153 "table":
"AOD/RTMUONCOV/0",
154 "treename":
"ReducedMuonsCov"
156 "ReducedMuonsLabels": {
157 "table":
"AOD/RTMUONSLABELS/0",
158 "treename":
"ReducedMuonsLabels",
162commonTables = [
"ReducedEvents",
"ReducedEventsExtended",
"ReducedEventsVtxCov"]
163barrelCommonTables = [
"ReducedTracks",
"ReducedTracksBarrel",
"ReducedTracksBarrelPID"]
164muonCommonTables = [
"ReducedMuons",
"ReducedMuonsExtra"]
167 "processFullTiny": [],
168 "processFullWithCov": [
"ReducedTracksBarrelCov",
"ReducedMuonsCov"],
169 "processFullWithCent": [],
170 "processBarrelOnly": [],
171 "processBarrelOnlyWithCov": [
"ReducedTracksBarrelCov"],
172 "processBarrelOnlyWithV0Bits": [],
173 "processBarrelOnlyWithQvector": [
"ReducedEventsQvector"],
174 "processBarrelOnlyWithEventFilter": [],
175 "processBarrelOnlyWithCent": [],
176 "processMuonOnly": [],
177 "processMuonOnlyWithCov": [
"ReducedMuonsCov"],
178 "processMuonOnlyWithCent": [],
179 "processMuonOnlyWithQvector": [
"ReducedEventsQvector"],
180 "processMuonOnlyWithFilter": [],
184initArgs = TableMaker()
189args = initArgs.parseArgs()
190configuredCommands = vars(args)
196forgettedArgsChecker(configuredCommands)
203if args.process
is not None:
204 prefix_process =
"process"
205 args.process = [prefix_process + sub
for sub
in args.process]
208if args.pid
is not None:
210 args.pid = [prefix_pid + sub
for sub
in args.pid]
213if args.est
is not None:
215 args.est = [prefix_est + sub
for sub
in args.est]
218if args.FT0
is not None:
219 prefix_process =
"process"
220 args.FT0 = prefix_process + args.FT0
226with open(args.cfgFileName)
as configFile:
227 config = json.load(configFile)
229jsonTypeChecker(args.cfgFileName)
232logging.info(
"runOverMC : %s, Reduced Tables will be produced for Data", runOverMC)
234taskNameInConfig =
"table-maker"
235taskNameInCommandLine =
"o2-analysis-dq-table-maker"
237mainTaskChecker(config, taskNameInConfig)
243logging.info(
"Only Select Configured as %s", args.onlySelect)
244if args.onlySelect ==
"true":
245 logging.info(
"INTERFACE MODE : JSON Overrider")
246if args.onlySelect ==
"false":
247 logging.info(
"INTERFACE MODE : JSON Additional")
250tableMakerProcessSearch = set()
252for key, value
in config.items():
253 if isinstance(value, dict):
254 for value, value2
in value.items():
257 if value ==
"aod-file" and args.aod:
258 config[key][value] = args.aod
259 logging.debug(
" - [%s] %s : %s", key, value, args.aod)
263 if (value
in specificDeps.keys())
and args.process:
264 if value
in args.process:
267 if "processOnlyBCs" not in args.process:
268 args.process.append(
"processOnlyBCs")
269 logging.warning(
"You forget to add OnlyBCs value in --process parameter! It will automaticaly added.")
271 config[key][value] = value2
272 logging.debug(
" - [%s] %s : %s", key, value, value2)
274 for s
in config[key].keys():
275 if s
in specificDeps.keys():
276 tableMakerProcessSearch.add(s)
278 fullSearch = [s
for s
in args.process
if "Full" in s]
279 barrelSearch = [s
for s
in args.process
if "Barrel" in s]
280 muonSearch = [s
for s
in args.process
if "Muon" in s]
281 filterSearch = [s
for s
in args.process
if "Filter" in s]
282 centSearch = [s
for s
in args.process
if "Cent" in s]
284 if len(barrelSearch) > 0
or len(fullSearch) > 0:
285 if args.isBarrelSelectionTiny ==
"true":
286 config[
"d-q-barrel-track-selection-task"][
"processSelection"] =
"false"
287 config[
"d-q-barrel-track-selection-task"][
"processSelectionTiny"] = args.isBarrelSelectionTiny
289 if (len(barrelSearch) == 0
and len(fullSearch) == 0
and args.runData
and args.onlySelect ==
"true"):
290 config[
"d-q-barrel-track-selection-task"][
"processSelection"] =
"false"
291 config[
"d-q-barrel-track-selection-task"][
"processSelectionTiny"] =
"false"
292 config[
"d-q-barrel-track-selection-task"][
"processDummy"] =
"true"
294 if (len(muonSearch) == 0
and len(fullSearch) == 0
and args.runData
and args.onlySelect ==
"true"):
295 config[
"d-q-muons-selection"][
"processSelection"] =
"false"
296 config[
"d-q-muons-selection"][
"processDummy"] =
"true"
298 if len(filterSearch) > 0
and args.runData:
299 config[
"d-q-filter-p-p-task"][
"processFilterPP"] =
"true"
300 config[
"d-q-filter-p-p-task"][
"processFilterPPTiny"] =
"false"
302 if args.isFilterPPTiny ==
"true":
303 config[
"d-q-filter-p-p-task"][
"processFilterPP"] =
"false"
304 config[
"d-q-filter-p-p-task"][
"processFilterPPTiny"] =
"true"
306 if len(filterSearch) == 0
and args.runData
and args.onlySelect ==
"true":
307 config[
"d-q-filter-p-p-task"][
"processFilterPP"] =
"false"
308 config[
"d-q-filter-p-p-task"][
"processFilterPPTiny"] =
"false"
309 config[
"d-q-filter-p-p-task"][
"processDummy"] =
"false"
311 elif args.onlySelect ==
"true":
312 if value ==
"processOnlyBCs":
313 config[key][value] =
"true"
314 logging.debug(
" - [%s] %s : true", key, value)
317 config[key][value] = value2
318 logging.debug(
" - [%s] %s : %s", key, value, value2)
321 if value ==
"cfgBarrelSels" and args.cfgBarrelSels:
322 multiConfigurableSet(config, key, value, args.cfgBarrelSels, args.onlySelect)
323 logging.debug(
" - [%s] %s : %s", key, value, args.cfgBarrelSels)
324 if value ==
"cfgMuonSels" and args.cfgMuonSels:
325 multiConfigurableSet(config, key, value, args.cfgMuonSels, args.onlySelect)
326 logging.debug(
" - [%s] %s : %s", key, value, args.cfgMuonSels)
329 if (value
in pidParameters)
and args.pid
and key !=
"tof-pid":
330 if value
in args.pid:
332 config[key][value] = value2
333 logging.debug(
" - [%s] %s : %s", key, value, value2)
334 elif args.onlySelect ==
"true":
336 config[key][value] = value2
337 logging.debug(
" - [%s] %s : %s", key, value, value2)
340 if value ==
"cfgCutPtMin" and args.cfgCutPtMin:
341 config[key][value] = args.cfgCutPtMin
342 logging.debug(
" - [%s] %s : %s", key, value, args.cfgCutPtMin)
343 if value ==
"cfgCutPtMax" and args.cfgCutPtMax:
344 config[key][value] = args.cfgCutPtMax
345 logging.debug(
" - [%s] %s : %s", key, value, args.cfgCutPtMax)
346 if value ==
"cfgCutEta" and args.cfgCutEta:
347 config[key][value] = args.cfgCutEta
348 logging.debug(
" - [%s] %s : %s", key, value, args.cfgCutEta)
349 if value ==
"cfgEtaLimit" and args.cfgEtaLimit:
350 config[key][value] = args.cfgEtaLimit
351 logging.debug(
" - [%s] %s : %s", key, value, args.cfgEtaLimit)
352 if value ==
"cfgNPow" and args.cfgNPow:
353 config[key][value] = args.cfgNPow
354 logging.debug(
" - [%s] %s : %s", key, value, args.cfgNPow)
355 if value ==
"cfgEfficiency" and args.cfgEfficiency:
356 config[key][value] = args.cfgEfficiency
357 logging.debug(
" - [%s] %s : %s", key, value, args.cfgEfficiency)
358 if value ==
"cfgAcceptance" and args.cfgAcceptance:
359 config[key][value] = args.cfgAcceptance
360 logging.debug(
" - [%s] %s : %s", key, value, args.cfgAcceptance)
363 if value ==
"d_bz_input" and args.d_bz_input:
364 config[key][value] = args.d_bz_input
365 logging.debug(
" - [%s] %s : %s", key, value, args.d_bz_input)
366 if value ==
"v0cospa" and args.v0cospa:
367 config[key][value] = args.v0cospa
368 logging.debug(
" - [%s] %s : %s", key, value, args.v0cospa)
369 if value ==
"dcav0dau" and args.dcav0dau:
370 config[key][value] = args.dcav0dau
371 logging.debug(
" - [%s] %s : %s", key, value, args.dcav0dau)
372 if value ==
"v0Rmin" and args.v0Rmin:
373 config[key][value] = args.v0Rmin
374 logging.debug(
" - [%s] %s : %s", key, value, args.v0Rmin)
375 if value ==
"v0Rmax" and args.v0Rmax:
376 config[key][value] = args.v0Rmax
377 logging.debug(
" - [%s] %s : %s", key, value, args.v0Rmax)
378 if value ==
"dcamin" and args.dcamin:
379 config[key][value] = args.dcamin
380 logging.debug(
" - [%s] %s : %s", key, value, args.dcamin)
381 if value ==
"dcamax" and args.dcamax:
382 config[key][value] = args.dcamax
383 logging.debug(
" - [%s] %s : %s", key, value, args.dcamax)
384 if value ==
"mincrossedrows" and args.mincrossedrows:
385 config[key][value] = args.mincrossedrows
386 logging.debug(
" - [%s] %s : %s", key, value, args.mincrossedrows)
387 if value ==
"maxchi2tpc" and args.maxchi2tpc:
388 config[key][value] = args.maxchi2tpc
389 logging.debug(
" - [%s] %s : %s", key, value, args.maxchi2tpc)
392 if (value
in centralityTableParameters)
and args.est:
393 if value
in args.est:
395 config[key][value] = value2
396 logging.debug(
" - [%s] %s : %s", key, value, value2)
397 elif args.onlySelect ==
"true":
399 config[key][value] = value2
400 logging.debug(
" - [%s] %s : %s", key, value, value2)
403 if value ==
"cfgEventCuts" and args.cfgEventCuts:
404 multiConfigurableSet(config, key, value, args.cfgEventCuts, args.onlySelect)
405 logging.debug(
" - [%s] %s : %s", key, value, args.cfgEventCuts)
406 if value ==
"cfgBarrelTrackCuts" and args.cfgBarrelTrackCuts:
407 multiConfigurableSet(config, key, value, args.cfgBarrelTrackCuts, args.onlySelect)
408 logging.debug(
" - [%s] %s : %s", key, value, args.cfgBarrelTrackCuts)
409 if value ==
"cfgMuonCuts" and args.cfgMuonCuts:
410 multiConfigurableSet(config, key, value, args.cfgMuonCuts, args.onlySelect)
411 logging.debug(
" - [%s] %s : %s", key, value, args.cfgMuonCuts)
412 if value ==
"cfgBarrelLowPt" and args.cfgBarrelLowPt:
413 config[key][value] = args.cfgBarrelLowPt
414 logging.debug(
" - [%s] %s : %s", key, value, args.cfgBarrelLowPt)
415 if value ==
"cfgMuonLowPt" and args.cfgMuonLowPt:
416 config[key][value] = args.cfgMuonLowPt
417 logging.debug(
" - [%s] %s : %s", key, value, args.cfgMuonLowPt)
418 if value ==
"cfgNoQA" and args.cfgNoQA:
419 config[key][value] = args.cfgNoQA
420 logging.debug(
" - [%s] %s : %s", key, value, args.cfgNoQA)
421 if value ==
"cfgDetailedQA" and args.cfgDetailedQA:
422 config[key][value] = args.cfgDetailedQA
423 logging.debug(
" - [%s] %s : %s", key, value, args.cfgDetailedQA)
424 if value ==
"cfgMinTpcSignal" and args.cfgMinTpcSignal:
425 config[key][value] = args.cfgMinTpcSignal
426 logging.debug(
" - [%s] %s : %s", key, value, args.cfgMinTpcSignal)
427 if value ==
"cfgMaxTpcSignal" and args.cfgMaxTpcSignal:
428 config[key][value] = args.cfgMaxTpcSignal
429 logging.debug(
" - [%s] %s : %s", key, value, args.cfgMaxTpcSignal)
432 if value ==
"cfgMuonsCuts" and args.cfgMuonsCuts:
433 multiConfigurableSet(config, key, value, args.cfgMuonsCuts, args.onlySelect)
434 logging.debug(
" - [%s] %s : %s", key, value, args.cfgMuonsCuts)
437 if value ==
"syst" and args.syst:
438 config[key][value] = args.syst
439 logging.debug(
" - [%s] %s : %s", key, value, args.syst)
440 if value ==
"muonSelection" and args.muonSelection:
441 config[key][value] = args.muonSelection
442 logging.debug(
" - [%s] %s : %s", key, value, args.muonSelection)
443 if value ==
"customDeltaBC" and args.customDeltaBC:
444 config[key][value] = args.customDeltaBC
445 logging.debug(
" - [%s] %s : %s", key, value, args.customDeltaBC)
448 if value ==
"doVertexZeq" and args.isVertexZeq:
449 if args.isVertexZeq ==
"true":
450 config[key][value] =
"1"
451 config[key][
"doDummyZeq"] =
"0"
452 logging.debug(
" - %s %s : 1", key, value)
453 logging.debug(
" - [%s] doDummyZeq : 0", key)
454 if args.isVertexZeq ==
"false":
455 config[key][value] =
"0"
456 config[key][
"doDummyZeq"] =
"1"
457 logging.debug(
" - %s %s : 0", key, value)
458 logging.debug(
" - [%s] doDummyZeq : 1", key)
461 if value ==
"processWSlice" and args.isWSlice:
462 if args.isWSlice ==
"true":
463 config[key][value] =
"true"
464 config[key][
"processWoSlice"] =
"false"
465 logging.debug(
" - %s %s : true", key, value)
466 logging.debug(
" - [%s] processWoSlice : false", key)
467 if args.isWSlice ==
"false":
468 config[key][value] =
"false"
469 config[key][
"processWoSlice"] =
"true"
470 logging.debug(
" - %s %s : false", key, value)
471 logging.debug(
" - [%s] processWoSlice : true", key)
474 if value ==
"tof-expreso" and args.tof_expreso:
475 config[key][value] = args.tof_expreso
476 logging.debug(
" - [%s] %s : %s", key, value, args.tof_expreso)
479 if (value
in ft0Parameters)
and args.FT0
and key ==
"tof-event-time":
480 if value == args.FT0:
482 config[key][value] = value2
483 logging.debug(
" - [%s] %s : %s", key, value, value2)
484 elif value != args.FT0:
486 config[key][value] = value2
487 logging.debug(
" - [%s] %s : %s", key, value, value2)
490 if (value ==
"cfgWithQA" or value ==
"cfgQA")
and args.cfgWithQA:
491 config[key][value] = args.cfgWithQA
492 logging.debug(
" - [%s] %s : %s", key, value, args.cfgWithQA)
495 if args.isCovariance:
496 if (value ==
"processStandard" or value ==
"processCovariance")
and args.isCovariance ==
"false":
497 config[key][
"processStandard"] =
"true"
498 config[key][
"processCovariance"] =
"false"
499 logging.debug(
" - [%s] processStandart : true", key)
500 logging.debug(
" - [%s] processCovariance : false", key)
501 if (value ==
"processStandard" or value ==
"processCovariance")
and args.isCovariance ==
"true":
502 config[key][
"processStandard"] =
"false"
503 config[key][
"processCovariance"] =
"true"
504 logging.debug(
" - [%s] processStandart : false", key)
505 logging.debug(
" - [%s] processCovariance : true", key)
509 config[key][value] = args.itsMatching
510 logging.debug(
" - [%s] %s : %s", key, value, args.itsMatching)
513centTranscation(config, args.process, args.syst, centSearch)
514filterSelsTranscation(args.cfgBarrelSels, args.cfgMuonSels, args.cfgBarrelTrackCuts, args.cfgMuonsCuts, configuredCommands)
515aodFileChecker(args.aod)
519from extramodules.getTTrees
import getTTrees
522if args.aod
is not None:
525 ttreeList = config[
"internal-dpl-aod-reader"][
"aod-file"]
528trackPropChecker(commonDeps, barrelDeps)
535updatedConfigFileName =
"tempConfigTableMaker.json"
537with open(updatedConfigFileName,
"w")
as outputFile:
538 json.dump(config, outputFile, indent = 2)
542for dep
in commonDeps:
545for processFunc
in specificDeps.keys():
546 if processFunc
not in config[taskNameInConfig].keys():
548 if config[taskNameInConfig][processFunc] ==
"true":
549 if "processFull" in processFunc
or "processBarrel" in processFunc:
550 for dep
in barrelDeps:
552 for dep
in specificDeps[processFunc]:
557for table
in commonTables:
558 tablesToProduce[table] = 1
561 tablesToProduce[
"ReducedMCEvents"] = 1
562 tablesToProduce[
"ReducedMCEventLabels"] = 1
564for processFunc
in specificDeps.keys():
565 if processFunc
not in config[taskNameInConfig].keys():
567 if config[taskNameInConfig][processFunc] ==
"true":
568 logging.info(
"processFunc ========")
569 logging.info(
"%s", processFunc)
570 if "processFull" in processFunc
or "processBarrel" in processFunc:
571 logging.info(
"common barrel tables==========")
572 for table
in barrelCommonTables:
573 logging.info(
"%s", table)
574 tablesToProduce[table] = 1
576 tablesToProduce[
"ReducedTracksBarrelLabels"] = 1
577 if "processFull" in processFunc
or "processMuon" in processFunc:
578 logging.info(
"common muon tables==========")
579 for table
in muonCommonTables:
580 logging.info(
"%s", table)
581 tablesToProduce[table] = 1
583 tablesToProduce[
"ReducedMuonsLabels"] = 1
585 tablesToProduce[
"ReducedMCTracks"] = 1
586 logging.info(
"specific tables==========")
587 for table
in specificTables[processFunc]:
588 logging.info(
"%s", table)
589 tablesToProduce[table] = 1
591readerConfigFileName =
"aodReaderTempConfig.json"
592writerConfigFileName =
"aodWriterTempConfig.json"
595outputDescriptors(tablesToProduce, tables)
596inputDescriptors(tablesToProduce, tables)
599 taskNameInCommandLine +
" --configuration json://" + updatedConfigFileName +
600 " --severity error --shm-segment-size 12000000000 --aod-writer-json " + writerConfigFileName +
" -b"
602if args.aod_memory_rate_limit:
604 taskNameInCommandLine +
" --configuration json://" + updatedConfigFileName +
605 " --severity error --shm-segment-size 12000000000 --aod-memory-rate-limit " + args.aod_memory_rate_limit +
" --aod-writer-json " +
606 writerConfigFileName +
" -b"
609for dep
in depsToRun.keys():
610 commandToRun +=
" | " + dep +
" --configuration json://" + updatedConfigFileName +
" -b"
611 logging.debug(
"%s added your workflow", dep)
614 logging.debug("o2-analysis-mc-converter added your workflow")
615 commandToRun += (
" | o2-analysis-mc-converter --configuration json://" + updatedConfigFileName +
" -b")
618 commandToRun += (
" | o2-analysis-fdd-converter --configuration json://" + updatedConfigFileName +
" -b")
619 logging.debug(
"o2-analysis-fdd-converter added your workflow")
621if args.add_track_prop:
622 commandToRun += (
" | o2-analysis-track-propagation --configuration json://" + updatedConfigFileName +
" -b")
623 logging.debug(
"o2-analysis-track-propagation added your workflow")
626print("====================================================================================================================")
627logging.info("Command to run:")
628logging.info(commandToRun)
629print("====================================================================================================================")
630logging.info("Tables to produce:")
631logging.info(tablesToProduce.keys())
632print("====================================================================================================================")
634# Listing Added Commands
635dispArgs(configuredCommands)
637os.system(commandToRun)