Definition at line 5 of file EventLoopCPRunScript.py.
◆ __init__()
def python.EventLoopCPRunScript.EventLoopCPRunScript.__init__ |
( |
|
self | ) |
|
◆ addCustomArguments()
def python.EventLoopCPRunScript.EventLoopCPRunScript.addCustomArguments |
( |
|
self | ) |
|
Definition at line 12 of file EventLoopCPRunScript.py.
12 def addCustomArguments(self):
14 derivedGroup = self.parser.add_argument_group(
'EventLoop specific arguments')
15 derivedGroup.add_argument(
'--direct-driver', dest=
'direct_driver',
16 action=
'store_true', help=
'Run the job with the direct driver')
17 derivedGroup.add_argument(
'--work-dir', dest=
'work_dir', nargs=
'?', const=
'workDir', default=
None,
18 help=
'The work directory for the EL job. defaults to "workDir".')
19 derivedGroup.add_argument(
'--merge-output-files', dest=
'merge_output_files', action=
'store_true', help=
'Merge the output histogram and n-tuple files into a single file.')
21 expertGroup = self.parser.add_argument_group(
'Experts arguments')
22 expertGroup.add_argument(
'--run-perf-stat', dest=
'run_perf_stat', action=
'store_true', help=
'Run xAOD::PerfStats to get input branch access data. This is mostly useful for AMG experts wanting to understand branch access patterns.')
23 expertGroup.add_argument(
'--algorithm-timers', dest=
'algorithm_timers', action=
'store_true', help=
'Enable algorithm timers. This is mostly useful for AMG experts wanting to understand tool performance.')
24 expertGroup.add_argument(
'--algorithm-memory-monitoring', dest=
'algorithm_memory_monitoring', action=
'store_true', help=
'Enable algorithm memory monitoring. This is mostly useful for AMG experts wanting to understand tool memory usage. Note that this is imperfect and may in cases assign memory to the wrong algorithm.')
◆ driverSubmit()
def python.EventLoopCPRunScript.EventLoopCPRunScript.driverSubmit |
( |
|
self, |
|
|
|
driver |
|
) |
| |
Important if you want to run code after submitting the job, with external driver e.g., ExecDriver.
Assistant function to call driver submit. Move the submission to a child process to avoid the main process being terminated.
Directly calling external driver submission will not return controls to the main process, the main thread will be terminated.
Definition at line 83 of file EventLoopCPRunScript.py.
83 def driverSubmit(self, driver):
85 Important if you want to run code after submitting the job, with external driver e.g., ExecDriver.
86 Assistant function to call driver submit. Move the submission to a child process to avoid the main process being terminated.
87 Directly calling external driver submission will not return controls to the main process, the main thread will be terminated.
89 if (pid := os.fork()) == 0:
90 name = self.args.work_dir
if self.args.work_dir
else 'workDir'
91 driver.submit(self.job, name)
◆ makeAlgSequence()
def python.EventLoopCPRunScript.EventLoopCPRunScript.makeAlgSequence |
( |
|
self | ) |
|
Definition at line 27 of file EventLoopCPRunScript.py.
27 def makeAlgSequence(self):
28 from AnaAlgorithm.AlgSequence
import AlgSequence
29 from AnalysisAlgorithmsConfig.ConfigAccumulator
import ConfigAccumulator
31 self.logger.
info(
"Configuring algorithms based on YAML file")
33 self.logger.
info(
"Configuring common services")
34 configAccumulator = ConfigAccumulator(flags=self.flags,
36 noSystematics=self.args.no_systematics)
37 self.logger.
info(
"Configuring algorithms")
38 configSeq.fullConfigure(configAccumulator)
◆ moveOutputFiles()
def python.EventLoopCPRunScript.EventLoopCPRunScript.moveOutputFiles |
( |
|
self | ) |
|
Definition at line 50 of file EventLoopCPRunScript.py.
50 def moveOutputFiles(self):
51 from pathlib
import Path
53 self.logger.
info(
"Moving the analysis root file and the hist file to the top level.")
54 workDir = Path(self.args.work_dir)
if self.args.work_dir
else Path(
'workDir')
55 rootfileSymlink = (workDir /
'data-ANALYSIS' / f
'{self.outputName}.root')
56 rootfilePath = rootfileSymlink.resolve()
57 histfileSymlink = (workDir / f
'hist-{self.outputName}.root')
58 histfilePath = histfileSymlink.resolve()
59 currentDir = Path.cwd()
61 if rootfilePath.exists():
62 self.logger.
info(f
"Moving {rootfilePath} to {currentDir / f'{self.outputName}.root'}")
63 if rootfileSymlink.is_symlink():
64 rootfileSymlink.unlink()
65 shutil.move(
str(rootfilePath),
str(currentDir / f
"{self.outputName}.root"))
67 self.logger.warning(f
"Root file {rootfilePath} does not exist or merging is enabled, skipping move.")
69 if histfilePath.exists():
70 self.logger.
info(f
"Moving {histfilePath} to {currentDir / f'hist-{self.outputName}.root'}")
71 if histfileSymlink.is_symlink():
72 histfileSymlink.unlink()
73 shutil.move(
str(histfilePath),
str(currentDir / f
"hist-{self.outputName}.root"))
75 self.logger.warning(f
"Histogram file {histfilePath} does not exist or merging, skipping move.")
77 newHistFile = currentDir / f
"hist-{self.outputName}.root"
79 if self.args.merge_output_files
and newHistFile.exists():
80 self.logger.
info(f
"renmaing the hist-{self.outputName}.root to {self.outputName}.root")
81 newHistFile.rename(currentDir / f
"{self.outputName}.root")
◆ readSamples()
def python.EventLoopCPRunScript.EventLoopCPRunScript.readSamples |
( |
|
self | ) |
|
Definition at line 41 of file EventLoopCPRunScript.py.
41 def readSamples(self):
43 self.sampleHandler = ROOT.SH.SampleHandler()
44 sampleFiles = ROOT.SH.SampleLocal(f
"{self.outputName}")
45 self.logger.
info(
"Adding files to the sample handler")
46 for file
in self.inputList:
48 self.sampleHandler.
add(sampleFiles)
◆ run()
def python.EventLoopCPRunScript.EventLoopCPRunScript.run |
( |
|
self | ) |
|
Definition at line 97 of file EventLoopCPRunScript.py.
106 self.job = ROOT.EL.Job()
107 self.job.sampleHandler(self.sampleHandler)
108 self.job.
options().setDouble(ROOT.EL.Job.optFilesPerWorker, 100)
109 self.job.
options().setDouble(ROOT.EL.Job.optMaxEvents, self.flags.Exec.MaxEvents)
110 self.job.
options().setString(ROOT.EL.Job.optSubmitDirMode,
'unique-link')
111 self.job.
options().setDouble(ROOT.EL.Job.optSkipEvents, self.flags.Exec.SkipEvents)
113 for alg
in self.makeAlgSequence():
114 self.job.algsAdd(alg)
115 if self.args.merge_output_files:
116 self.job.
options().setString(ROOT.EL.Job.optStreamAliases,
"ANALYSIS=" + ROOT.EL.Job.histogramStreamName)
118 self.job.outputAdd(ROOT.EL.OutputStream(
'ANALYSIS'))
120 if self.args.run_perf_stat:
121 self.job.
options().setBool(ROOT.EL.Job.optXAODPerfStats, 1)
122 if self.args.algorithm_timers:
123 self.job.
options().setBool(ROOT.EL.Job.optAlgorithmTimer, 1)
124 if self.args.algorithm_memory_monitoring:
125 self.job.
options().setBool(ROOT.EL.Job.optAlgorithmMemoryMonitor, 1)
127 driver = ROOT.EL.DirectDriver()
if self.args.direct_driver
else ROOT.EL.ExecDriver()
128 self.driverSubmit(driver)
129 if self.args.work_dir
is None:
130 self.moveOutputFiles()
◆ job
python.EventLoopCPRunScript.EventLoopCPRunScript.job |
◆ sampleHandler
python.EventLoopCPRunScript.EventLoopCPRunScript.sampleHandler |
The documentation for this class was generated from the following file:
bool configure(asg::AnaToolHandle< ITrigGlobalEfficiencyCorrectionTool > &tool, ToolHandleArray< IAsgElectronEfficiencyCorrectionTool > &electronEffToolsHandles, ToolHandleArray< IAsgElectronEfficiencyCorrectionTool > &electronSFToolsHandles, ToolHandleArray< CP::IMuonTriggerScaleFactors > &muonToolsHandles, ToolHandleArray< IAsgPhotonEfficiencyCorrectionTool > &photonEffToolsHandles, ToolHandleArray< IAsgPhotonEfficiencyCorrectionTool > &photonSFToolsHandles, const std::string &triggers, const std::map< std::string, std::string > &legsPerTool, unsigned long nToys, bool debug)