ATLAS Offline Software
Worker.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 #ifndef EVENT_LOOP_WORKER_HH
6 #define EVENT_LOOP_WORKER_HH
7 
8 #include <EventLoop/Global.h>
9 
11 #include <EventLoop/IWorker.h>
12 #include <map>
13 #include <memory>
14 #include <EventLoop/ModuleData.h>
16 #include <Rtypes.h>
17 #include <unordered_map>
18 
19 class TList;
20 class TStopwatch;
21 
22 namespace EL
23 {
24  class Worker final : public IWorker, private Detail::ModuleData, private Detail::IInputModuleActions
25  {
26  //
27  // public interface
28  //
29 
32  public:
33  void testInvariant () const;
34 
35 
38  public:
39  virtual ~Worker ();
40 
41 
51  public:
52  void addOutput (TObject *output_swallow) final override;
53 
54 
65  public:
66  void addOutputList (const std::string& name, TObject *output_swallow) override;
67 
68 
78  public:
79  TObject *getOutputHist (const std::string& name) const final override;
80 
81 
91  public:
92  TFile *getOutputFile (const std::string& label) const override;
93 
94 
108  public:
109  TFile *getOutputFileNull (const std::string& label) const override;
110 
111 
115  public:
116  ::StatusCode addTree( const TTree& tree,
117  const std::string& stream ) final override;
118 
119 
122  public:
123  TTree* getOutputTree( const std::string& name,
124  const std::string& stream ) const final override;
125 
126 
131  public:
132  const SH::MetaObject *metaData () const override;
133 
134 
137  public:
138  TTree *tree () const override;
139 
140 
143  public:
144  Long64_t treeEntry () const override;
145 
146 
149  public:
150  TFile *inputFile () const override;
151 
152 
157  public:
158  std::string inputFileName () const override;
159 
160 
165  public:
166  TTree *triggerConfig () const override;
167 
168 
174  public:
175  xAOD::TEvent *xaodEvent () const override;
176  xAOD::TStore *xaodStore () const override;
177 
178 
183  public:
184  EL::Algorithm *getAlg (const std::string& name) const override;
185 
186 
194  public:
195  void skipEvent () override;
196 
197 
202  public:
203  virtual bool filterPassed () const noexcept final override;
204 
208  public:
209  virtual void setFilterPassed (bool val_filterPassed) noexcept final override;
210 
211 
212 
213  //
214  // public interface for the drivers
215  //
216 
222  public:
223  Worker ();
224 
225 
226 
227  //
228  // old interface for the drivers
229  //
230 
234  public:
236  const std::string& location, const SH::MetaObject& options);
237 
238 
242  public:
243  ::StatusCode batchExecute (unsigned job_id, const char *confFile);
244 
245  public:
246  ::StatusCode gridExecute (const std::string& sampleName, Long64_t SkipEvents, Long64_t nEventsPerJob);
247 
248  private:
250  EC_FAIL = 220,
251  EC_ABORT = 221,
253  EC_BADINPUT = 223
254  };
255 
256  private:
258 
259 
263  protected:
264  void setMetaData (const SH::MetaObject *val_metaData);
265 
266 
270  protected:
271  void setOutputHist (const std::string& val_outputTarget);
272 
273 
277  protected:
278  void setSegmentName (const std::string& val_segmentName);
279 
280 
296  protected:
298 
299 
305  protected:
306  void addModule (std::unique_ptr<Detail::Module> module);
307 
308 
319  protected:
321 
322 
328  protected:
330 
331 
342  protected:
344 
345 
356  protected:
357  ::StatusCode processEvents (EventRange& eventRange) override;
358 
359 
370  protected:
371  ::StatusCode openInputFile (const std::string& inputFileUrl) override;
372 
373 
378  protected:
379  ::StatusCode addOutputStream (const std::string& label,
381 
382 
387  protected:
388  Long64_t inputFileNumEntries () const override;
389 
390 
394  protected:
395  uint64_t eventsProcessed () const noexcept;
396 
397 
398 
399  //
400  // private interface
401  //
402 
404  private:
405  static bool fileOpenErrorFilter(int level, bool, const char*, const char *);
406 
407 
409  private:
410  typedef std::map<std::string,TH1*>::const_iterator OutputHistMapIter;
411  std::map<std::string,TH1*> m_outputHistMap;
412 
413 
415  private:
416  typedef std::map<std::pair<std::string,std::string>,TTree*>::const_iterator
418  std::map<std::pair<std::string,std::string>,TTree*> m_outputTreeMap;
419 
420 
422  private:
423  std::vector<std::unique_ptr<Detail::Module> > m_modules;
424 
425 
428  private:
429  bool m_newInputFile {false};
430 
431 
433  private:
434  std::string m_outputTarget;
435 
436 
438  private:
439  std::string m_segmentName;
440 
441 
443  private:
445 
446 
448  private:
449  bool m_firstEvent {true};
450  };
451 }
452 
453 #endif
EL::Worker::finalize
::StatusCode finalize()
finalize the worker
Definition: Worker.cxx:452
EL::Worker::m_newInputFile
bool m_newInputFile
whether this is a new input file (i.e.
Definition: Worker.h:429
EL::Worker::addOutput
void addOutput(TObject *output_swallow) final override
effects: add an object to the output.
Definition: Worker.cxx:88
EL::Worker::m_firstEvent
bool m_firstEvent
whether we are still to process the first event
Definition: Worker.h:449
EL::Worker::m_modules
std::vector< std::unique_ptr< Detail::Module > > m_modules
the list of modules we hold
Definition: Worker.h:423
EL::Detail::OutputStreamData
all data needed to manage a given output stream
Definition: OutputStreamData.h:30
EL::Worker::m_outputTarget
std::string m_outputTarget
the target file to which we will write the histogram output
Definition: Worker.h:434
EL::Worker::filterPassed
virtual bool filterPassed() const noexcept final override
whether the current algorithm passed its filter criterion for the current event
Definition: Worker.cxx:306
EL::Worker::getOutputFileNull
TFile * getOutputFileNull(const std::string &label) const override
effects: get the output file that goes into the dataset with the given label.
Definition: Worker.cxx:143
EL::Worker::OutputHistMapIter
std::map< std::string, TH1 * >::const_iterator OutputHistMapIter
the output map
Definition: Worker.h:410
EL::Worker::eventsProcessed
uint64_t eventsProcessed() const noexcept
the number of events that have been processed
Definition: Worker.cxx:712
EL::Worker::directExecute
::StatusCode directExecute(const SH::SamplePtr &sample, const Job &job, const std::string &location, const SH::MetaObject &options)
run the job
Definition: Worker.cxx:731
EL::Detail::ModuleData
the data the EventLoop core classes are sharing with the Module implementation
Definition: ModuleData.h:64
SH::MetaObject
A class that manages meta-data to be associated with an object.
Definition: MetaObject.h:56
EL::Worker::inputFileName
std::string inputFileName() const override
the name of the file we are reading the current tree from, without the path component
Definition: Worker.cxx:236
EL::Worker::m_outputHistMap
std::map< std::string, TH1 * > m_outputHistMap
Definition: Worker.h:411
EL::Worker::inputFile
TFile * inputFile() const override
description: the file we are reading the current tree from guarantee: no-fail
Definition: Worker.cxx:227
PlotCalibFromCool.label
label
Definition: PlotCalibFromCool.py:78
Execution.SkipEvents
SkipEvents
Definition: Execution.py:91
EL::Worker::GridErrorCodes
GridErrorCodes
Definition: Worker.h:249
EL::Worker::addModule
void addModule(std::unique_ptr< Detail::Module > module)
add the given module to this worker
Definition: Worker.cxx:721
EL::Worker::EC_FAIL
@ EC_FAIL
Definition: Worker.h:250
EL::Worker::openInputFile
::StatusCode openInputFile(const std::string &inputFileUrl) override
open the given input file without processing it
Definition: Worker.cxx:599
EL::Worker::EC_NOTFINISHED
@ EC_NOTFINISHED
Definition: Worker.h:252
EL::Worker::m_algorithmsInitialized
bool m_algorithmsInitialized
whether the algorithms are initialized
Definition: Worker.h:444
EL::Worker::EC_ABORT
@ EC_ABORT
Definition: Worker.h:251
const
bool const RAWDATA *ch2 const
Definition: LArRodBlockPhysicsV0.cxx:562
skel.nEventsPerJob
nEventsPerJob
Definition: skel.ABtoEVGEN.py:567
AthenaPoolTestWrite.stream
string stream
Definition: AthenaPoolTestWrite.py:12
EL::Worker::setFilterPassed
virtual void setFilterPassed(bool val_filterPassed) noexcept final override
set the value of filterPassed
Definition: Worker.cxx:315
EL::Worker::processEvents
::StatusCode processEvents(EventRange &eventRange) override
process the given event range
Definition: Worker.cxx:505
python.iconfTool.models.loaders.level
level
Definition: loaders.py:20
EL::Worker::fileOpenErrorFilter
static bool fileOpenErrorFilter(int level, bool, const char *, const char *)
Error handler for file opening.
Definition: Worker.cxx:583
python.PyAthena.module
module
Definition: PyAthena.py:134
EL::Worker::m_outputTreeMap
std::map< std::pair< std::string, std::string >, TTree * > m_outputTreeMap
Definition: Worker.h:418
OutputStreamData.h
EL::Worker
Definition: Worker.h:25
EL::Worker::metaData
const SH::MetaObject * metaData() const override
description: the sample meta-data we are working on guarantee: no-fail invariant: metaData !...
Definition: Worker.cxx:200
EL::Algorithm
Definition: Algorithm.h:22
FullCPAlgorithmsTest_eljob.sample
sample
Definition: FullCPAlgorithmsTest_eljob.py:100
EL::Worker::getAlg
EL::Algorithm * getAlg(const std::string &name) const override
effects: returns the algorithms with the given name or NULL if there is none guarantee: strong failur...
Definition: Worker.cxx:283
EL::Worker::setSegmentName
void setSegmentName(const std::string &val_segmentName)
set the segment name
Definition: Worker.cxx:355
EL::Worker::setOutputHist
void setOutputHist(const std::string &val_outputTarget)
set the histogram output list
Definition: Worker.cxx:345
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
vector
Definition: MultiHisto.h:13
python.sizes.location
string location
Definition: sizes.py:11
EL::Worker::triggerConfig
TTree * triggerConfig() const override
description: the trigger config tree from the input file, or NULL if we did not find it guarantee: st...
Definition: Worker.cxx:250
EL::IWorker
the interface for algorithms to access IWorker
Definition: IWorker.h:40
EL::Worker::~Worker
virtual ~Worker()
effects: standard destructor guarantee: no-fail
Definition: Worker.cxx:80
xAOD::uint64_t
uint64_t
Definition: EventInfo_v1.cxx:123
EL
This module defines the arguments passed from the BATCH driver to the BATCH worker.
Definition: AlgorithmWorkerData.h:24
python.AtlRunQueryLib.options
options
Definition: AtlRunQueryLib.py:379
EL::Worker::getOutputHist
TObject * getOutputHist(const std::string &name) const final override
get the output histogram with the given name
Definition: Worker.cxx:119
EL::Worker::inputFileNumEntries
Long64_t inputFileNumEntries() const override
the number of events in the input file
Definition: Worker.cxx:698
EL::Worker::setJobConfig
void setJobConfig(JobConfig &&jobConfig)
set the JobConfig
Definition: Worker.cxx:365
beamspotman.jobConfig
dictionary jobConfig
Definition: beamspotman.py:1071
merge.output
output
Definition: merge.py:17
EL::Worker::skipEvent
void skipEvent() override
effects: skip the current event, i.e.
Definition: Worker.cxx:297
EL::Worker::EC_BADINPUT
@ EC_BADINPUT
Definition: Worker.h:253
EL::Worker::addOutputStream
::StatusCode addOutputStream(const std::string &label, Detail::OutputStreamData output)
effects: add another output file guarantee: strong failures: low level errors II failures: label alre...
Definition: Worker.cxx:675
private
#define private
Definition: DetDescrConditionsDict_dict_fixes.cxx:13
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:195
xAOD::DiTauJetParameters::Detail
Detail
Definition: DiTauDefs.h:38
EL::Worker::batchExecute
::StatusCode batchExecute(unsigned job_id, const char *confFile)
effects: do what is needed to execute the given job segment guarantee: basic failures: job specific
Definition: Worker.cxx:777
EL::JobConfig
the job configuration that is independent of driver and dataset
Definition: JobConfig.h:39
SH::SamplePtr
A smart pointer class that holds a single Sample object.
Definition: SamplePtr.h:35
EL::Worker::addTree
::StatusCode addTree(const TTree &tree, const std::string &stream) final override
effects: adds a tree to an output file specified by the stream/label failures: Incorrect stream/label...
Definition: Worker.cxx:155
EL::Worker::testInvariant
void testInvariant() const
effects: test the invariant of this object guarantee: no-fail
Definition: Worker.cxx:68
EL::Worker::getOutputTree
TTree * getOutputTree(const std::string &name, const std::string &stream) const final override
effects: get the tree that was added to an output file earlier failures: Tree doesn't exist
Definition: Worker.cxx:177
xAOD::TStore
A relatively simple transient store for objects created in analysis.
Definition: TStore.h:44
EL::Worker::getOutputFile
TFile * getOutputFile(const std::string &label) const override
effects: get the output file that goes into the dataset with the given label.
Definition: Worker.cxx:131
TH1
Definition: rootspy.cxx:268
EL::Detail::IInputModuleActions
the actions that Module::processInputs can perform
Definition: IInputModuleActions.h:42
EL::Worker::setMetaData
void setMetaData(const SH::MetaObject *val_metaData)
set the metaData
Definition: Worker.cxx:334
EL::Worker::xaodEvent
xAOD::TEvent * xaodEvent() const override
description: the xAOD event and store guarantee: strong failures: out of memory I failures: TEventSvc...
Definition: Worker.cxx:259
IInputModuleActions.h
EL::Worker::treeEntry
Long64_t treeEntry() const override
description: the entry in the tree we are reading guarantee: no-fail
Definition: Worker.cxx:218
ModuleData.h
EL::Worker::gridExecute
::StatusCode gridExecute(const std::string &sampleName, Long64_t SkipEvents, Long64_t nEventsPerJob)
Definition: Worker.cxx:853
EL::Worker::initialize
::StatusCode initialize()
initialize the worker
Definition: Worker.cxx:377
EL::Worker::OutputTreeMapIter
std::map< std::pair< std::string, std::string >, TTree * >::const_iterator OutputTreeMapIter
description: the list of output trees
Definition: Worker.h:417
EL::Job
Definition: Job.h:51
test_interactive_athena.job
job
Definition: test_interactive_athena.py:6
IWorker.h
EL::Worker::xaodStore
xAOD::TStore * xaodStore() const override
Definition: Worker.cxx:271
EL::Worker::gridCreateJobSummary
void gridCreateJobSummary(uint64_t eventsProcessed)
EL::EventRange
a range of events in a given file
Definition: EventRange.h:22
Global.h
EL::Worker::tree
TTree * tree() const override
description: the tree we are running on guarantee: no-fail
Definition: Worker.cxx:209
EL::Worker::addOutputList
void addOutputList(const std::string &name, TObject *output_swallow) override
effects: add a given object to the output.
Definition: Worker.cxx:102
xAOD::TEvent
Tool for accessing xAOD files outside of Athena.
Definition: Control/xAODRootAccess/xAODRootAccess/TEvent.h:81
EL::Worker::Worker
Worker()
standard constructor
Definition: Worker.cxx:324
EL::Worker::processInputs
::StatusCode processInputs()
process all the inputs
Definition: Worker.cxx:438
EL::Worker::m_segmentName
std::string m_segmentName
the name of the segment we are processing
Definition: Worker.h:439