Loading [MathJax]/extensions/tex2jax.js
ATLAS Offline Software
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
Public Member Functions | Public Attributes | List of all members
python.EventLoopCPRunScript.EventLoopCPRunScript Class Reference
Inheritance diagram for python.EventLoopCPRunScript.EventLoopCPRunScript:
Collaboration diagram for python.EventLoopCPRunScript.EventLoopCPRunScript:

Public Member Functions

def __init__ (self)
 
def addCustomArguments (self)
 
def makeAlgSequence (self)
 
def readSamples (self)
 
def stripPath (self)
 
def driverSubmit (self, driver)
 
def run (self)
 

Public Attributes

 sampleHandler
 
 job
 

Detailed Description

Definition at line 5 of file EventLoopCPRunScript.py.

Constructor & Destructor Documentation

◆ __init__()

def python.EventLoopCPRunScript.EventLoopCPRunScript.__init__ (   self)

Definition at line 6 of file EventLoopCPRunScript.py.

6  def __init__(self):
7  super().__init__()
8  self.logger.info("EventLoopCPRunScript initialized")
9  self.addCustomArguments()
10  # Avoid putting call to parse_args() here! Otherwise it is hard to retrieve the parser infos
11 

Member Function Documentation

◆ addCustomArguments()

def python.EventLoopCPRunScript.EventLoopCPRunScript.addCustomArguments (   self)

Definition at line 12 of file EventLoopCPRunScript.py.

12  def addCustomArguments(self):
13  # add arguments here
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('--strip', dest='strip', action='store_true', help='Move the analysis root file to the top level, and delete the work directory.'
18  ' Mainly useful for standardizing the output with the Athena framework.')
19  derivedGroup.add_argument('--work-dir', dest='work_dir', default='workDir', help='The work directory for the EL job')
20  return
21 

◆ 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 55 of file EventLoopCPRunScript.py.

55  def driverSubmit(self, driver):
56  '''
57  Important if you want to run code after submitting the job, with external driver e.g., ExecDriver.
58  Assistant function to call driver submit. Move the submission to a child process to avoid the main process being terminated.
59  Directly calling external driver submission will not return controls to the main process, the main thread will be terminated.
60  '''
61  import os
62  if (pid := os.fork()) == 0: # child process
63  driver.submit(self.job, self.args.work_dir)
64  exit(0)
65  else:
66  os.waitpid(pid, 0) # parent waits for child process to finish
67  return
68 

◆ makeAlgSequence()

def python.EventLoopCPRunScript.EventLoopCPRunScript.makeAlgSequence (   self)

Definition at line 22 of file EventLoopCPRunScript.py.

22  def makeAlgSequence(self):
23  from AnaAlgorithm.AlgSequence import AlgSequence
24  algSeq = AlgSequence()
25  self.logger.info("Configuring algorithms based on YAML file")
26  configSeq = self.config.configure()
27  self.logger.info("Configuring common services")
28  configAccumulator = ConfigAccumulator(autoconfigFromFlags=self.flags,
29  algSeq=algSeq,
30  noSystematics=self.args.no_systematics)
31  self.logger.info("Configuring algorithms")
32  configSeq.fullConfigure(configAccumulator)
33  return algSeq
34 

◆ readSamples()

def python.EventLoopCPRunScript.EventLoopCPRunScript.readSamples (   self)

Definition at line 35 of file EventLoopCPRunScript.py.

35  def readSamples(self):
36  import ROOT
37  self.sampleHandler = ROOT.SH.SampleHandler()
38  sampleFiles = ROOT.SH.SampleLocal(f"{self.args.output_name}")
39  self.logger.info("Adding files to the sample handler")
40  for file in self.inputList:
41  sampleFiles.add(file)
42  self.sampleHandler.add(sampleFiles)
43 

◆ run()

def python.EventLoopCPRunScript.EventLoopCPRunScript.run (   self)

Definition at line 69 of file EventLoopCPRunScript.py.

69  def run(self):
70  self.setup()
71  # importing ROOT has a long upfront time, so we do it here
72  import ROOT
73  ROOT.xAOD.Init().ignore()
74  self.readSamples()
75  self.flags.lock()
76  self.printFlags()
77 
78  self.job = ROOT.EL.Job()
79  self.job.sampleHandler(self.sampleHandler)
80  self.job.options().setDouble(ROOT.EL.Job.optMaxEvents, self.flags.Exec.MaxEvents)
81  self.job.options().setString(ROOT.EL.Job.optSubmitDirMode, 'unique-link')
82  for alg in self.makeAlgSequence():
83  self.job.algsAdd(alg)
84  self.job.outputAdd(ROOT.EL.OutputStream('ANALYSIS'))
85 
86  driver = ROOT.EL.DirectDriver() if self.args.direct_driver else ROOT.EL.ExecDriver()
87  self.driverSubmit(driver)
88  if self.args.strip: self.stripPath()

◆ stripPath()

def python.EventLoopCPRunScript.EventLoopCPRunScript.stripPath (   self)

Definition at line 44 of file EventLoopCPRunScript.py.

44  def stripPath(self):
45  import os
46  import shutil
47  self.logger.info("Moving the analysis root file to the top level, and deleting the work directory. (--strip option)")
48  workDir = os.path.realpath(self.args.work_dir)
49  rootfilePath = os.path.realpath(os.path.join(workDir, 'data-ANALYSIS', f'{self.args.output_name}.root'))
50  currentDir = os.getcwd()
51  shutil.move(rootfilePath, os.path.join(currentDir, f"{self.args.output_name}.root"))
52  shutil.rmtree(workDir)
53  os.remove(os.path.join(currentDir, self.args.work_dir))
54 

Member Data Documentation

◆ job

python.EventLoopCPRunScript.EventLoopCPRunScript.job

Definition at line 78 of file EventLoopCPRunScript.py.

◆ sampleHandler

python.EventLoopCPRunScript.EventLoopCPRunScript.sampleHandler

Definition at line 37 of file EventLoopCPRunScript.py.


The documentation for this class was generated from the following file:
grepfile.info
info
Definition: grepfile.py:38
configure
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)
Definition: TrigGlobEffCorrValidation.cxx:514
python.AlgSequence.AlgSequence
AlgSequence
Definition: PhysicsAnalysis/D3PDTools/AnaAlgorithm/python/AlgSequence.py:7
run
int run(int argc, char *argv[])
Definition: ttree2hdf5.cxx:28
DiTauMassTools::ignore
void ignore(T &&)
Definition: PhysicsAnalysis/TauID/DiTauMassTools/DiTauMassTools/HelperFunctions.h:58
add
bool add(const std::string &hname, TKey *tobj)
Definition: fastadd.cxx:55
python.AtlRunQueryLib.options
options
Definition: AtlRunQueryLib.py:379
calibdata.exit
exit
Definition: calibdata.py:236
python.processes.powheg.ZZ.ZZ.__init__
def __init__(self, base_directory, **kwargs)
Constructor: all process options are set here.
Definition: ZZ.py:18