ATLAS Offline Software
Loading...
Searching...
No Matches
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>
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
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:
236 ::StatusCode directExecute (const SH::SamplePtr& sample, const Job& job,
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:
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:
298 void setJobConfig (JobConfig&& jobConfig);
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,
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:
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
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:39
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:237
std::map< std::string, TH1 * > m_outputHistMap
Definition Worker.h:403
::StatusCode directExecute(const SH::SamplePtr &sample, const Job &job, const std::string &location, const SH::MetaObject &options)
run the job
Definition Worker.cxx:788
@ EC_NOTFINISHED
Definition Worker.h:253
@ EC_BADINPUT
Definition Worker.h:254
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:908
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:298
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:561
static bool fileOpenErrorFilter(int level, bool, const char *, const char *)
Error handler for file opening.
Definition Worker.cxx:639
void setOutputHist(const std::string &val_outputTarget)
set the histogram output list
Definition Worker.cxx:346
std::vector< asg::AsgComponentConfig > m_moduleConfig
the module configurations we use
Definition Worker.h:446
::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:740
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:316
std::string m_segmentName
the name of the segment we are processing
Definition Worker.h:431
::StatusCode finalize()
finalize the worker
Definition Worker.cxx:508
std::map< std::pair< std::string, std::string >, TTree * > m_outputTreeMap
Definition Worker.h:410
Worker()
standard constructor
Definition Worker.cxx:325
virtual bool filterPassed() const noexcept final override
whether the current algorithm passed its filter criterion for the current event
Definition Worker.cxx:307
void setJobConfig(JobConfig &&jobConfig)
set the JobConfig
Definition Worker.cxx:366
::StatusCode openInputFile(const std::string &inputFileUrl) override
open the given input file without processing it
Definition Worker.cxx:664
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
uint64_t eventsProcessed() const noexcept
the number of events that have been processed
Definition Worker.cxx:779
bool m_newInputFile
whether this is a new input file (i.e.
Definition Worker.h:421
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:335
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
bool m_algorithmsInitialized
whether the algorithms are initialized
Definition Worker.h:436
std::vector< std::unique_ptr< Detail::Module > > m_modules
the list of modules we hold
Definition Worker.h:415
std::map< std::string, TH1 * >::const_iterator OutputHistMapIter
the output map
Definition Worker.h:402
std::map< std::pair< std::string, std::string >, TTree * >::const_iterator OutputTreeMapIter
description: the list of output trees
Definition Worker.h:409
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:378
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:356
xAOD::TEvent * xaodEvent() const override
description: the xAOD event and store guarantee: strong failures: out of memory I failures: TEventSvc...
Definition Worker.cxx:260
void gridCreateJobSummary(uint64_t eventsProcessed)
Long64_t inputFileNumEntries() const override
the number of events in the input file
Definition Worker.cxx:765
xAOD::TStore * xaodStore() const override
Definition Worker.cxx:272
::StatusCode processInputs()
process all the inputs
Definition Worker.cxx:494
::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:833
bool m_firstEvent
whether we are still to process the first event
Definition Worker.h:441
std::string m_outputTarget
the target file to which we will write the histogram output
Definition Worker.h:426
A class that manages meta-data to be associated with an object.
Definition MetaObject.h:56
A smart pointer class that holds a single Sample object.
Definition SamplePtr.h:35
STL class.
STL class.
STL class.
Tool for accessing xAOD files outside of Athena.
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:64
a range of events in a given file
Definition EventRange.h:22
#define private