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 
12 #include <EventLoop/IWorker.h>
13 #include <map>
14 #include <memory>
15 #include <EventLoop/ModuleData.h>
17 #include <Rtypes.h>
18 #include <unordered_map>
19 
20 class TList;
21 class TStopwatch;
22 
23 namespace EL
24 {
26  {
27  //
28  // public interface
29  //
30 
33  public:
34  void testInvariant () const;
35 
36 
39  public:
40  virtual ~Worker ();
41 
42 
52  public:
53  void addOutput (TObject *output_swallow) final override;
54 
55 
66  public:
67  void addOutputList (const std::string& name, TObject *output_swallow) override;
68 
69 
79  public:
80  TObject *getOutputHist (const std::string& name) const final override;
81 
82 
92  public:
93  TFile *getOutputFile (const std::string& label) const override;
94 
95 
109  public:
110  TFile *getOutputFileNull (const std::string& label) const override;
111 
112 
116  public:
117  ::StatusCode addTree( const TTree& tree,
118  const std::string& stream ) final override;
119 
120 
123  public:
124  TTree* getOutputTree( const std::string& name,
125  const std::string& stream ) const final override;
126 
127 
132  public:
133  const SH::MetaObject *metaData () const override;
134 
135 
138  public:
139  TTree *tree () const override;
140 
141 
144  public:
145  Long64_t treeEntry () const override;
146 
147 
150  public:
151  TFile *inputFile () const override;
152 
153 
158  public:
159  std::string inputFileName () const override;
160 
161 
166  public:
167  TTree *triggerConfig () const override;
168 
169 
175  public:
176  xAOD::TEvent *xaodEvent () const override;
177  xAOD::TStore *xaodStore () const override;
178 
179 
184  public:
185  EL::Algorithm *getAlg (const std::string& name) const override;
186 
187 
195  public:
196  void skipEvent () override;
197 
198 
203  public:
204  virtual bool filterPassed () const noexcept final override;
205 
209  public:
210  virtual void setFilterPassed (bool val_filterPassed) noexcept final override;
211 
212 
213 
214  //
215  // public interface for the drivers
216  //
217 
223  public:
224  Worker ();
225 
226 
227 
228  //
229  // old interface for the drivers
230  //
231 
235  public:
237  const std::string& location, const SH::MetaObject& options);
238 
239 
243  public:
244  ::StatusCode batchExecute (unsigned job_id, const char *confFile);
245 
246  public:
247  ::StatusCode gridExecute (const std::string& sampleName, Long64_t SkipEvents, Long64_t nEventsPerJob);
248 
249  private:
251  EC_FAIL = 220,
252  EC_ABORT = 221,
254  EC_BADINPUT = 223
255  };
256 
257  private:
259 
260 
264  protected:
265  void setMetaData (const SH::MetaObject *val_metaData);
266 
267 
271  protected:
272  void setOutputHist (const std::string& val_outputTarget);
273 
274 
278  protected:
279  void setSegmentName (const std::string& val_segmentName);
280 
281 
297  protected:
299 
300 
311  protected:
313 
314 
320  protected:
322 
323 
334  protected:
336 
337 
348  protected:
349  ::StatusCode processEvents (EventRange& eventRange) override;
350 
351 
362  protected:
363  ::StatusCode openInputFile (const std::string& inputFileUrl) override;
364 
365 
370  protected:
371  ::StatusCode addOutputStream (const std::string& label,
372  Detail::OutputStreamData output);
373 
374 
379  protected:
380  Long64_t inputFileNumEntries () const override;
381 
382 
386  protected:
387  uint64_t eventsProcessed () const noexcept;
388 
389 
390 
391  //
392  // private interface
393  //
394 
396  private:
397  static bool fileOpenErrorFilter(int level, bool, const char*, const char *);
398 
399 
401  private:
402  typedef std::map<std::string,TH1*>::const_iterator OutputHistMapIter;
403  std::map<std::string,TH1*> m_outputHistMap;
404 
405 
407  private:
408  typedef std::map<std::pair<std::string,std::string>,TTree*>::const_iterator
410  std::map<std::pair<std::string,std::string>,TTree*> m_outputTreeMap;
411 
412 
414  private:
415  std::vector<std::unique_ptr<Detail::Module> > m_modules;
416 
417 
420  private:
421  bool m_newInputFile {false};
422 
423 
425  private:
426  std::string m_outputTarget;
427 
428 
430  private:
431  std::string m_segmentName;
432 
433 
435  private:
437 
438 
440  private:
441  bool m_firstEvent {true};
442 
443 
445  private:
446  std::vector<asg::AsgComponentConfig> m_moduleConfig;
447  };
448 }
449 
450 #endif
EL::Worker::finalize
::StatusCode finalize()
finalize the worker
Definition: Worker.cxx:507
EL::Worker::m_newInputFile
bool m_newInputFile
whether this is a new input file (i.e.
Definition: Worker.h:421
EL::Worker::addOutput
void addOutput(TObject *output_swallow) final override
effects: add an object to the output.
Definition: Worker.cxx:89
EL::Worker::m_firstEvent
bool m_firstEvent
whether we are still to process the first event
Definition: Worker.h:441
EL::Worker::m_modules
std::vector< std::unique_ptr< Detail::Module > > m_modules
the list of modules we hold
Definition: Worker.h:415
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:426
HelloWorldOptions.job
job
Definition: HelloWorldOptions.py:18
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:307
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:144
EL::Worker::OutputHistMapIter
std::map< std::string, TH1 * >::const_iterator OutputHistMapIter
the output map
Definition: Worker.h:402
EL::Worker::eventsProcessed
uint64_t eventsProcessed() const noexcept
the number of events that have been processed
Definition: Worker.cxx:778
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:787
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
AsgComponentConfig.h
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:237
EL::Worker::m_outputHistMap
std::map< std::string, TH1 * > m_outputHistMap
Definition: Worker.h:403
EL::Worker::inputFile
TFile * inputFile() const override
description: the file we are reading the current tree from guarantee: no-fail
Definition: Worker.cxx:228
Execution.SkipEvents
SkipEvents
Definition: Execution.py:91
EL::Worker::GridErrorCodes
GridErrorCodes
Definition: Worker.h:250
EL::Worker::EC_FAIL
@ EC_FAIL
Definition: Worker.h:251
EL::Worker::openInputFile
::StatusCode openInputFile(const std::string &inputFileUrl) override
open the given input file without processing it
Definition: Worker.cxx:663
EL::Worker::EC_NOTFINISHED
@ EC_NOTFINISHED
Definition: Worker.h:253
EL::Worker::m_algorithmsInitialized
bool m_algorithmsInitialized
whether the algorithms are initialized
Definition: Worker.h:436
EL::Worker::EC_ABORT
@ EC_ABORT
Definition: Worker.h:252
const
bool const RAWDATA *ch2 const
Definition: LArRodBlockPhysicsV0.cxx:560
skel.nEventsPerJob
nEventsPerJob
Definition: skel.ABtoEVGEN.py:552
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:316
EL::Worker::processEvents
::StatusCode processEvents(EventRange &eventRange) override
process the given event range
Definition: Worker.cxx:560
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:638
EL::Worker::m_outputTreeMap
std::map< std::pair< std::string, std::string >, TTree * > m_outputTreeMap
Definition: Worker.h:410
OutputStreamData.h
EL::Worker
Definition: Worker.h:26
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:201
EL::Algorithm
Definition: Algorithm.h:22
FullCPAlgorithmsTest_eljob.sample
sample
Definition: FullCPAlgorithmsTest_eljob.py:116
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:284
EL::Worker::setSegmentName
void setSegmentName(const std::string &val_segmentName)
set the segment name
Definition: Worker.cxx:356
EL::Worker::setOutputHist
void setOutputHist(const std::string &val_outputTarget)
set the histogram output list
Definition: Worker.cxx:346
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
vector
Definition: MultiHisto.h:13
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:251
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:81
add-xsec-uncert-quadrature-N.label
label
Definition: add-xsec-uncert-quadrature-N.py:104
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: AsgComponentFactories.h:16
EL::Worker::m_moduleConfig
std::vector< asg::AsgComponentConfig > m_moduleConfig
the module configurations we use
Definition: Worker.h:446
python.AtlRunQueryLib.options
options
Definition: AtlRunQueryLib.py:378
EL::Worker::getOutputHist
TObject * getOutputHist(const std::string &name) const final override
get the output histogram with the given name
Definition: Worker.cxx:120
EL::Worker::inputFileNumEntries
Long64_t inputFileNumEntries() const override
the number of events in the input file
Definition: Worker.cxx:764
EL::Worker::setJobConfig
void setJobConfig(JobConfig &&jobConfig)
set the JobConfig
Definition: Worker.cxx:366
beamspotman.jobConfig
dictionary jobConfig
Definition: beamspotman.py:1067
columnar::final
CM final
Definition: ColumnAccessor.h:106
EL::Worker::skipEvent
void skipEvent() override
effects: skip the current event, i.e.
Definition: Worker.cxx:298
EL::Worker::EC_BADINPUT
@ EC_BADINPUT
Definition: Worker.h:254
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:739
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:240
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:832
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:156
EL::Worker::testInvariant
void testInvariant() const
effects: test the invariant of this object guarantee: no-fail
Definition: Worker.cxx:69
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:178
xAOD::TStore
A relatively simple transient store for objects created in analysis.
Definition: TStore.h:47
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:132
private
#define private
Definition: xAODTruthCnvAlg.h:20
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:335
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:260
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:219
ModuleData.h
EL::Worker::gridExecute
::StatusCode gridExecute(const std::string &sampleName, Long64_t SkipEvents, Long64_t nEventsPerJob)
Definition: Worker.cxx:907
EL::Worker::initialize
::StatusCode initialize()
initialize the worker
Definition: Worker.cxx:378
EL::Worker::OutputTreeMapIter
std::map< std::pair< std::string, std::string >, TTree * >::const_iterator OutputTreeMapIter
description: the list of output trees
Definition: Worker.h:409
EL::Job
Definition: Job.h:51
IWorker.h
EL::Worker::xaodStore
xAOD::TStore * xaodStore() const override
Definition: Worker.cxx:272
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:210
getEFTrackSample.sampleName
sampleName
Definition: getEFTrackSample.py:13
EL::Worker::addOutputList
void addOutputList(const std::string &name, TObject *output_swallow) override
effects: add a given object to the output.
Definition: Worker.cxx:103
xAOD::TEvent
Tool for accessing xAOD files outside of Athena.
Definition: Control/xAODRootAccess/xAODRootAccess/TEvent.h:85
EL::Worker::Worker
Worker()
standard constructor
Definition: Worker.cxx:325
EL::Worker::processInputs
::StatusCode processInputs()
process all the inputs
Definition: Worker.cxx:493
EL::Worker::m_segmentName
std::string m_segmentName
the name of the segment we are processing
Definition: Worker.h:431