25from .dqExceptions
import CentFilterError, CfgInvalidFormatError, ForgettedArgsError, MandatoryArgNotFoundError, NotInAlienvError, SelsAndCutsNotHaveSameNumberError, TasknameNotFoundInConfigFileError
28def aodFileChecker(aod: str):
29 """This function checks path for AO2D (both for .root and .txt)
32 aod (CLI argument): Provided arg for AO2D File
or text file which includes AO2D list
37 textAodList = argProvidedAod.startswith(
"@")
38 endsWithRoot = argProvidedAod.endswith(
".root")
39 endsWithTxt = argProvidedAod.endswith(
"txt")
or argProvidedAod.endswith(
"text")
40 if textAodList
and endsWithTxt:
41 argProvidedAod = argProvidedAod.replace(
"@",
"")
42 logging.info(
"You provided AO2D list as text file : %s", argProvidedAod)
44 open(argProvidedAod,
"r")
45 logging.info(
"%s has valid File Format and Path, File Found", argProvidedAod)
47 except FileNotFoundError:
48 logging.exception(
"%s AO2D file text list not found in path!!!", argProvidedAod)
52 logging.info(
"You provided single AO2D root file : %s", argProvidedAod)
54 open(argProvidedAod,
"r")
55 logging.info(
"%s has valid File Format and Path, File Found", argProvidedAod)
57 except FileNotFoundError:
58 logging.exception(
"%s AO2D single root file not found in path!!!", argProvidedAod)
62 open(argProvidedAod,
"r")
63 logging.info(
"%s has valid File Format and Path, File Found", argProvidedAod)
65 except FileNotFoundError:
66 logging.exception(
"%s Wrong formatted File, check your file extension!", argProvidedAod)
70def trackPropTransaction(trackProp: bool, deps: list):
71 """This method automatically deletes the o2-analysis-trackextension(for run2) task from your workflow
72 when you add the o2-analysis-track-propagation (for run3)
73 task to your workflow. Two tasks are
not compatible at the same time
76 trackProp (CLI argument): CLI argument to add the o2-analysis-track-propagation task
77 deps (list): Defined dependency list
81 deps.remove(
"o2-analysis-trackextension")
82 logging.info(
"o2-analysis-trackextension is not valid dep for run 3, It will deleted from your workflow.")
85def trackPropChecker(commonDeps: list, barrelDeps: list):
86 """This method automatically deletes the o2-analysis-trackextension(for run2) task from your workflow
87 when you add the o2-analysis-track-propagation (for run3)
88 task to your workflow. Two tasks are
not compatible at the same time
91 commonDeps (list): Common Dependency list
for run to task
92 barrelDeps (list): The dependency list where the trackextension task
is defined
95 if "o2-analysis-track-propagation" in commonDeps:
96 barrelDeps.remove(
"o2-analysis-trackextension")
97 logging.info(
"o2-analysis-trackextension is not valid dep for run 3, It will deleted from your workflow.")
100def mainTaskChecker(config: dict, taskNameInConfig: str):
101 """1. Checks whether the workflow you want to run in your JSON file has a main task.
103 2. Checks If you are running the O2Physics environment
106 taskNameInConfig (string): taskNameInConfig
109 TasknameNotFoundInConfigFileError: if taskname
not found
in json config
110 NotInAlienvError:
if you are
not in O2Physics environment
113 O2PHYSICS_ROOT = os.environ.get("O2PHYSICS_ROOT")
116 if taskNameInConfig
not in config:
119 logging.info(
"%s is in your JSON Config File", taskNameInConfig)
120 except TasknameNotFoundInConfigFileError
as e:
126 if O2PHYSICS_ROOT
is None:
127 raise NotInAlienvError
129 logging.info(
"You are in %s alienv", O2PHYSICS_ROOT)
130 except NotInAlienvError
as e:
135def jsonTypeChecker(cfgFileName: str):
136 """Checks if the JSON config file assigned by the CLI is in the correct format
139 cfgFileName (json): CLI argument as your input json config file
142 CfgInvalidFormatError: If the file format
is not correct
145 isConfigJson = cfgFileName.endswith(".json")
151 logging.info(
"%s is valid json config file", cfgFileName)
153 except CfgInvalidFormatError
as e:
159def forgettedArgsChecker(configuredCommands: dict):
160 """Checks for any arguments forgot to assign a value which you provided to command line
162 E.x. --process --syst PbPb (It will raise)
165 configuredCommands (dict): Dictionary of arguments entered
from the CLI
168 ForgettedArgsError:
if there
is an argument you forgot to configure
171 for key, value
in configuredCommands.items():
172 if value
is not None:
173 if (isinstance(value, str)
or isinstance(value, list))
and len(value) == 0:
174 forgetParams.append(key)
176 if len(forgetParams) > 0:
178 except ForgettedArgsError
as e:
183def centTranscation(config: dict, process, syst, centSearch):
184 """If you assign a centrality-related process function for the pp collision
185 system while trying to skim the data, an error will
return.
188 process (CLI argument): process function
in tableMaker/tableMakerMC
189 centSearch (list): List counting Cent sub strings
in process function
190 syst (CLI argument): collision system
193 CentFilterError: If you assign a centrality-related process function
195 if (process
and len(centSearch) != 0
and (syst ==
"pp" or (syst
is None and config[
"event-selection-task"][
"syst"] ==
"pp"))):
197 "JSON file does not include configs for centrality-table task, It's for DATA. Centrality will removed because you select pp collision system."
199 if process
is not None:
200 processCentralityMatch = [s
for s
in process
if "Cent" in s]
202 if len(processCentralityMatch) > 0:
203 raise CentFilterError
206 except CentFilterError
as e:
211def filterSelsTranscation(argBarrelSels: list, argMuonSels: list, argBarrelTrackCuts: list, argMuonsCuts: list, configuredCommands: dict):
212 """It checks whether the event filter selections and analysis cuts in the
213 Filter PP task are in the same number
and order
216 argBarrelSels (CLI Argument): Event filter argument
for barrel
217 argMuonSels (CLI Argument): Event filter argument
for muons
218 argBarrelTrackCuts (CLI Argument): Analysis cut argument
for barrel
219 argMuonsCuts (CLI Argument): Analysis cuts argument
for muons
220 configuredCommands (dict): Dictionary of all arguments provided by the CLI
223 MandatoryArgNotFoundError: If the required argument
is not found
224 SelsAndCutsNotHaveSameNumberError : If Filter Selections
and analysis cuts
not in same number
and order
227 argMuonSelsClean = []
228 argBarrelSelsClean = []
232 if argMuonsCuts
is None:
237 except MandatoryArgNotFoundError
as e:
239 logging.error(
"For configure to cfgMuonSels (For DQ Filter PP Task), you must also configure cfgMuonsCuts!!!")
243 for i
in argMuonSels:
244 i = i[0 : i.index(
":")]
245 argMuonSelsClean.append(i)
248 if argMuonSelsClean == argMuonsCuts:
251 raise SelsAndCutsNotHaveSameNumberError
253 except SelsAndCutsNotHaveSameNumberError
as e:
256 "[INFO] For fixing this issue, you should have the same number of cuts (and in the same order) provided to the cfgMuonsCuts from dq-selection as those provided to the cfgMuonSels in the DQFilterPPTask."
259 "For example, if cfgMuonCuts is muonLowPt,muonHighPt,muonLowPt then the cfgMuonSels has to be something like: muonLowPt::1,muonHighPt::1,muonLowPt:pairNoCut:1"
263 logging.info(
"Event filter configuration is valid for muons")
268 if argBarrelTrackCuts
is None:
273 except MandatoryArgNotFoundError
as e:
275 logging.error(
"For configure to cfgBarrelSels (For DQ Filter PP Task), you must also configure cfgBarrelTrackCuts!!!")
279 for i
in argBarrelSels:
280 i = i[0 : i.index(
":")]
281 argBarrelSelsClean.append(i)
284 if argBarrelSelsClean == argBarrelTrackCuts:
287 raise SelsAndCutsNotHaveSameNumberError
289 except SelsAndCutsNotHaveSameNumberError
as e:
292 "For fixing this issue, you should have the same number of cuts (and in the same order) provided to the cfgBarrelTrackCuts from dq-selection as those provided to the cfgBarrelSels in the DQFilterPPTask."
295 "For example, if cfgBarrelTrackCuts is jpsiO2MCdebugCuts,jpsiO2MCdebugCuts2,jpsiO2MCdebugCuts then the cfgBarrelSels has to be something like: jpsiO2MCdebugCuts::1,jpsiO2MCdebugCuts2::1,jpsiO2MCdebugCuts:pairNoCut:1"
299 logging.info(
"Event filter configuration is valid for barrel")
303def tableReaderDepsChecker(analysisCfg,processCfg,mixingCfg):
305 sameEventPairingDeps = {
306 [
"JpsiToEE"]: [
"trackSelection"],
307 [
"JpsiToMuMu"]: [
"muonSelection"],
308 [
"JpsiToMuMuVertexing"]: [
"muonSelection"],
309 [
"VnJpsiToEE"]: [
"trackSelection"],
310 [
"JpsiToMuMu"]: [
"muonSelection"],
311 [
"ElectronMuon"] : [
"trackSelection",
"muonSelection"],
312 [
"All"] : [
"trackSelection",
"muonSelection"]
316 "Barrel":
"trackSelection",
317 "Muon":
"muonSelection",
318 "BarrelMuon": [
"trackSelection",
"muonSelection"],
319 "BarrelVn":
"trackSelection",
320 "MuonVn":
"muonSelection"
324 for k,v
in sameEventPairingDeps.items():
325 if (k
in processCfg)
and v
not in analysisCfg:
328 for k,v
in eventMixingDeps.items():
329 if (k
in mixingCfg)
and v
not in analysisCfg: