ATLAS Offline Software
Loading...
Searching...
No Matches
Worker.h
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2026 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>
17#include <Rtypes.h>
18#include <unordered_map>
19
20class TList;
21class TStopwatch;
22
23namespace EL
24{
25 class Worker final : public IWorker, private Detail::ModuleData, private Detail::IInputModuleActions
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
156 public:
157 bool hasInputEvents () const override;
158
159
164 public:
165 std::string inputFileName () const override;
166
167
172 public:
173 TTree *triggerConfig () const override;
174
175
181 public:
182 xAOD::Event *xaodEvent () const override;
183 xAOD::TStore *xaodStore () const override;
184
185
190 public:
191 EL::Algorithm *getAlg (const std::string& name) const override;
192
193
201 public:
202 void skipEvent () override;
203
204
209 public:
210 virtual bool filterPassed () const noexcept final override;
211
215 public:
216 virtual void setFilterPassed (bool val_filterPassed) noexcept final override;
217
218
219
220 //
221 // public interface for the drivers
222 //
223
229 public:
230 Worker ();
231
232
233
234 //
235 // old interface for the drivers
236 //
237
241 public:
242 ::StatusCode directExecute (const SH::Sample& sample, const Job& job,
243 const std::string& location, const SH::MetaObject& options);
244
245
249 public:
250 ::StatusCode batchExecute (unsigned job_id, const char *confFile);
251
252 public:
253 ::StatusCode gridExecute (const std::string& sampleName, Long64_t SkipEvents, Long64_t nEventsPerJob);
254
255 private:
262
263 private:
265
266
270 protected:
271 void setMetaData (const SH::MetaObject *val_metaData);
272
273
277 protected:
278 void setOutputHist (const std::string& val_outputTarget);
279
280
284 protected:
285 void setSegmentName (const std::string& val_segmentName);
286
287
303 protected:
304 void setJobConfig (JobConfig&& jobConfig);
305
306
317 protected:
319
320
326 protected:
328
329
340 protected:
342
343
354 protected:
355 ::StatusCode processEvents (EventRange& eventRange) override;
356
357
368 protected:
369 ::StatusCode openInputFile (const std::string& inputFileUrl) override;
370
371
376 protected:
377 ::StatusCode addOutputStream (const std::string& label,
379
380
385 protected:
386 Long64_t inputFileNumEntries () const override;
387
388
392 protected:
393 uint64_t eventsProcessed () const noexcept;
394
395
396
397 //
398 // private interface
399 //
400
402 private:
403 static bool fileOpenErrorFilter(int level, bool, const char*, const char *);
404
405
407 private:
408 typedef std::map<std::string,TH1*>::const_iterator OutputHistMapIter;
409 std::map<std::string,TH1*> m_outputHistMap;
410
411
413 private:
414 typedef std::map<std::pair<std::string,std::string>,TTree*>::const_iterator
416 std::map<std::pair<std::string,std::string>,TTree*> m_outputTreeMap;
417
418
420 private:
422
423
425 private:
426 bool m_firstInputFile {true};
427
428
431 private:
432 bool m_newInputFile {false};
433
434
436 private:
437 std::string m_outputTarget;
438
439
441 private:
442 std::string m_segmentName;
443
444
446 private:
448
449
451 private:
452 bool m_firstEvent {true};
453
454
456 private:
457 std::vector<asg::AsgComponentConfig> m_moduleConfig;
458 };
459}
460
461#endif
the actions that Module::processInputs can perform
all data needed to manage a given output stream
the interface for algorithms to access IWorker
Definition IWorker.h:40
the job configuration that is independent of driver and dataset
Definition JobConfig.h:45
Definition Job.h:51
Long64_t treeEntry() const override
description: the entry in the tree we are reading guarantee: no-fail
Definition Worker.cxx:219
std::string inputFileName() const override
the name of the file we are reading the current tree from, without the path component
Definition Worker.cxx:244
std::map< std::string, TH1 * > m_outputHistMap
Definition Worker.h:409
@ EC_NOTFINISHED
Definition Worker.h:259
@ EC_BADINPUT
Definition Worker.h:260
void testInvariant() const
effects: test the invariant of this object guarantee: no-fail
Definition Worker.cxx:69
::StatusCode gridExecute(const std::string &sampleName, Long64_t SkipEvents, Long64_t nEventsPerJob)
Definition Worker.cxx:939
void addOutputList(const std::string &name, TObject *output_swallow) override
effects: add a given object to the output.
Definition Worker.cxx:103
::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
TFile * inputFile() const override
description: the file we are reading the current tree from guarantee: no-fail
Definition Worker.cxx:228
void skipEvent() override
effects: skip the current event, i.e.
Definition Worker.cxx:305
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
::StatusCode processEvents(EventRange &eventRange) override
process the given event range
Definition Worker.cxx:567
static bool fileOpenErrorFilter(int level, bool, const char *, const char *)
Error handler for file opening.
Definition Worker.cxx:645
void setOutputHist(const std::string &val_outputTarget)
set the histogram output list
Definition Worker.cxx:353
std::vector< asg::AsgComponentConfig > m_moduleConfig
the module configurations we use
Definition Worker.h:457
::StatusCode directExecute(const SH::Sample &sample, const Job &job, const std::string &location, const SH::MetaObject &options)
run the job
Definition Worker.cxx:819
::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:768
const SH::MetaObject * metaData() const override
description: the sample meta-data we are working on guarantee: no-fail invariant: metaData !...
Definition Worker.cxx:201
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
TObject * getOutputHist(const std::string &name) const final override
get the output histogram with the given name
Definition Worker.cxx:120
virtual void setFilterPassed(bool val_filterPassed) noexcept final override
set the value of filterPassed
Definition Worker.cxx:323
std::string m_segmentName
the name of the segment we are processing
Definition Worker.h:442
::StatusCode finalize()
finalize the worker
Definition Worker.cxx:514
std::map< std::pair< std::string, std::string >, TTree * > m_outputTreeMap
Definition Worker.h:416
Worker()
standard constructor
Definition Worker.cxx:332
virtual bool filterPassed() const noexcept final override
whether the current algorithm passed its filter criterion for the current event
Definition Worker.cxx:314
bool m_firstInputFile
whether this is the first input file
Definition Worker.h:426
void setJobConfig(JobConfig &&jobConfig)
set the JobConfig
Definition Worker.cxx:373
::StatusCode openInputFile(const std::string &inputFileUrl) override
open the given input file without processing it
Definition Worker.cxx:670
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:291
uint64_t eventsProcessed() const noexcept
the number of events that have been processed
Definition Worker.cxx:810
bool m_newInputFile
whether this is a new input file (i.e.
Definition Worker.h:432
TTree * tree() const override
description: the tree we are running on guarantee: no-fail
Definition Worker.cxx:210
void setMetaData(const SH::MetaObject *val_metaData)
set the metaData
Definition Worker.cxx:342
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:258
bool m_algorithmsInitialized
whether the algorithms are initialized
Definition Worker.h:447
std::vector< std::unique_ptr< Detail::Module > > m_modules
the list of modules we hold
Definition Worker.h:421
std::map< std::string, TH1 * >::const_iterator OutputHistMapIter
the output map
Definition Worker.h:408
std::map< std::pair< std::string, std::string >, TTree * >::const_iterator OutputTreeMapIter
description: the list of output trees
Definition Worker.h:415
void addOutput(TObject *output_swallow) final override
effects: add an object to the output.
Definition Worker.cxx:89
virtual ~Worker()
effects: standard destructor guarantee: no-fail
Definition Worker.cxx:81
::StatusCode initialize()
initialize the worker
Definition Worker.cxx:385
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
void setSegmentName(const std::string &val_segmentName)
set the segment name
Definition Worker.cxx:363
void gridCreateJobSummary(uint64_t eventsProcessed)
Long64_t inputFileNumEntries() const override
the number of events in the input file
Definition Worker.cxx:793
xAOD::TStore * xaodStore() const override
Definition Worker.cxx:279
::StatusCode processInputs()
process all the inputs
Definition Worker.cxx:499
::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:864
bool m_firstEvent
whether we are still to process the first event
Definition Worker.h:452
xAOD::Event * xaodEvent() const override
description: the xAOD event and store guarantee: strong failures: out of memory I failures: EventSvc ...
Definition Worker.cxx:267
bool hasInputEvents() const override
flag whether the most recently opened input file has events or not
Definition Worker.cxx:236
std::string m_outputTarget
the target file to which we will write the histogram output
Definition Worker.h:437
A class that manages meta-data to be associated with an object.
Definition MetaObject.h:56
a base class that manages a set of files belonging to a particular data set and the associated meta-d...
Definition Sample.h:57
STL class.
STL class.
STL class.
Base class for the event (xAOD::TEvent and xAOD::REvent) classes.
Definition Event.h:60
A relatively simple transient store for objects created in analysis.
Definition TStore.h:45
std::string label(const std::string &format, int i)
Definition label.h:19
This module defines the arguments passed from the BATCH driver to the BATCH worker.
::StatusCode StatusCode
StatusCode definition for legacy code.
STL namespace.
the data the EventLoop core classes are sharing with the Module implementation
Definition ModuleData.h:65
a range of events in a given file
Definition EventRange.h:22
#define private