ATLAS Offline Software
Loading...
Searching...
No Matches
EL::Worker Class Referencefinal

#include <Worker.h>

Inheritance diagram for EL::Worker:
Collaboration diagram for EL::Worker:

Public Member Functions

void testInvariant () const
 effects: test the invariant of this object guarantee: no-fail
virtual ~Worker ()
 effects: standard destructor guarantee: no-fail
void addOutput (TObject *output_swallow) final override
 effects: add an object to the output.
void addOutputList (const std::string &name, TObject *output_swallow) override
 effects: add a given object to the output.
TObject * getOutputHist (const std::string &name) const final override
 get the output histogram with the given name
TFile * getOutputFile (const std::string &label) const override
 effects: get the output file that goes into the dataset with the given label.
TFile * getOutputFileNull (const std::string &label) const override
 effects: get the output file that goes into the dataset with the given label.
::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 specified, called at the wrong time note: See getOutputFile for failure types...
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
const SH::MetaObjectmetaData () const override
 description: the sample meta-data we are working on guarantee: no-fail invariant: metaData != 0 rationale: this can be used for accessing sample meta-data
TTree * tree () const override
 description: the tree we are running on guarantee: no-fail
Long64_t treeEntry () const override
 description: the entry in the tree we are reading guarantee: no-fail
TFile * inputFile () const override
 description: the file we are reading the current tree from guarantee: no-fail
std::string inputFileName () const override
 the name of the file we are reading the current tree from, without the path component
TTree * triggerConfig () const override
 description: the trigger config tree from the input file, or NULL if we did not find it guarantee: strong failures: i/o errors
xAOD::TEventxaodEvent () const override
 description: the xAOD event and store guarantee: strong failures: out of memory I failures: TEventSvc not configured postcondition: result != 0
xAOD::TStorexaodStore () const override
EL::AlgorithmgetAlg (const std::string &name) const override
 effects: returns the algorithms with the given name or NULL if there is none guarantee: strong failures: out of memory II
void skipEvent () override
 effects: skip the current event, i.e.
virtual bool filterPassed () const noexcept final override
 whether the current algorithm passed its filter criterion for the current event
virtual void setFilterPassed (bool val_filterPassed) noexcept final override
 set the value of filterPassed
 Worker ()
 standard constructor
::StatusCode directExecute (const SH::SamplePtr &sample, const Job &job, const std::string &location, const SH::MetaObject &options)
 run the job
::StatusCode batchExecute (unsigned job_id, const char *confFile)
 effects: do what is needed to execute the given job segment guarantee: basic failures: job specific
::StatusCode gridExecute (const std::string &sampleName, Long64_t SkipEvents, Long64_t nEventsPerJob)

Protected Member Functions

void setMetaData (const SH::MetaObject *val_metaData)
 set the metaData
void setOutputHist (const std::string &val_outputTarget)
 set the histogram output list
void setSegmentName (const std::string &val_segmentName)
 set the segment name
void setJobConfig (JobConfig &&jobConfig)
 set the JobConfig
::StatusCode initialize ()
 initialize the worker
::StatusCode processInputs ()
 process all the inputs
::StatusCode finalize ()
 finalize the worker
::StatusCode processEvents (EventRange &eventRange) override
 process the given event range
::StatusCode openInputFile (const std::string &inputFileUrl) override
 open the given input file without processing it
::StatusCode addOutputStream (const std::string &label, Detail::OutputStreamData output)
 effects: add another output file guarantee: strong failures: low level errors II failures: label already used
Long64_t inputFileNumEntries () const override
 the number of events in the input file
uint64_t eventsProcessed () const noexcept
 the number of events that have been processed

Private Types

enum  GridErrorCodes { EC_FAIL = 220 , EC_ABORT = 221 , EC_NOTFINISHED = 222 , EC_BADINPUT = 223 }
typedef std::map< std::string, TH1 * >::const_iterator OutputHistMapIter
 the output map
typedef std::map< std::pair< std::string, std::string >, TTree * >::const_iterator OutputTreeMapIter
 description: the list of output trees

Private Member Functions

void gridCreateJobSummary (uint64_t eventsProcessed)
void addOutput (std::unique_ptr< TObject > output)
 add the given output object to the histogram output stream

Static Private Member Functions

static bool fileOpenErrorFilter (int level, bool, const char *, const char *)
 Error handler for file opening.

Private Attributes

std::map< std::string, TH1 * > m_outputHistMap
std::map< std::pair< std::string, std::string >, TTree * > m_outputTreeMap
std::vector< std::unique_ptr< Detail::Module > > m_modules
 the list of modules we hold
bool m_newInputFile {false}
 whether this is a new input file (i.e.
std::string m_outputTarget
 the target file to which we will write the histogram output
std::string m_segmentName
 the name of the segment we are processing
bool m_algorithmsInitialized {false}
 whether the algorithms are initialized
bool m_firstEvent {true}
 whether we are still to process the first event
std::vector< asg::AsgComponentConfigm_moduleConfig
 the module configurations we use
std::vector< Detail::AlgorithmDatam_algs
 the list of algorithms
std::string m_inputFileUrl
 the input file url of the currently opened file
std::unique_ptr< TFile > m_inputFile
 the input file pointer of the currently opened filed
TTree * m_inputTree {nullptr}
 the (main) tree in the input file
uint64_t m_inputTreeEntry {0}
 the entry in the input tree we are currently looking at
bool m_skipEvent = false
 whether we are skipping the current event
const SH::MetaObjectm_metaData {nullptr}
 the meta-data we use
uint64_t m_eventsProcessed {0}
 the number of events that have been processed
OutputStreamData * m_histOutput {nullptr}
 the histogram output stream
std::unique_ptr< TTree > m_jobStats
 Tree saving per-job statistics information.
xAOD::TEventm_tevent {nullptr}
 the TEvent structure, if we use one
xAOD::TStorem_tstore {nullptr}
 the TStore structure, if we use one
asg::SgTEventm_evtStore {nullptr}
 the SgTEvent structure, if we use one
Workerm_worker {nullptr}
 the worker (to pass on to the algorithms)
std::map< std::string, std::shared_ptr< Detail::OutputStreamData > > m_outputs
 the list of output files
BatchJobm_batchJob = nullptr
 the BatchJob configuration (if used)

Detailed Description

Definition at line 25 of file Worker.h.

Member Typedef Documentation

◆ OutputHistMapIter

typedef std::map<std::string,TH1*>::const_iterator EL::Worker::OutputHistMapIter
private

the output map

Definition at line 402 of file Worker.h.

◆ OutputTreeMapIter

typedef std::map<std::pair<std::string,std::string>,TTree*>::const_iterator EL::Worker::OutputTreeMapIter
private

description: the list of output trees

Definition at line 409 of file Worker.h.

Member Enumeration Documentation

◆ GridErrorCodes

Enumerator
EC_FAIL 
EC_ABORT 
EC_NOTFINISHED 
EC_BADINPUT 

Definition at line 250 of file Worker.h.

250 {
251 EC_FAIL = 220,
252 EC_ABORT = 221,
253 EC_NOTFINISHED = 222,
254 EC_BADINPUT = 223
255 };
@ EC_NOTFINISHED
Definition Worker.h:253
@ EC_BADINPUT
Definition Worker.h:254

Constructor & Destructor Documentation

◆ ~Worker()

EL::Worker::~Worker ( )
virtual

effects: standard destructor guarantee: no-fail

Definition at line 80 of file Worker.cxx.

82 {
84 }
#define RCU_DESTROY_INVARIANT(x)
Definition Assert.h:235

◆ Worker()

EL::Worker::Worker ( )

standard constructor

Guarantee
strong
Failures
out of memory I

Definition at line 324 of file Worker.cxx.

326 {
327 m_worker = this;
328
329 RCU_NEW_INVARIANT (this);
330 }
#define RCU_NEW_INVARIANT(x)
Definition Assert.h:233
Worker * m_worker
the worker (to pass on to the algorithms)
Definition ModuleData.h:106

Member Function Documentation

◆ addOutput() [1/2]

void EL::Detail::ModuleData::addOutput ( std::unique_ptr< TObject > output)
inherited

add the given output object to the histogram output stream

Guarantee
basic
Failures
out of memory II

Definition at line 33 of file ModuleData.cxx.

35 {
36 RCU_ASSERT (m_histOutput != nullptr);
37 m_histOutput->addOutput (std::move (output));
38 }
#define RCU_ASSERT(x)
Definition Assert.h:222
OutputStreamData * m_histOutput
the histogram output stream
Definition ModuleData.h:91

◆ addOutput() [2/2]

void EL::Worker::addOutput ( TObject * output_swallow)
finaloverridevirtual

effects: add an object to the output.

the worker takes over ownership of the object, but the caller may maintain a reference to it guarantee: basic, argument is always swallowed failures: out of memory I requires: output_swallow != 0 warning: so far I placed no requirements on the output objects. I may do that at a later stage though, possibly breaking existing code.

Implements EL::IHistogramWorker.

Definition at line 88 of file Worker.cxx.

90 {
91 std::unique_ptr<TObject> output (output_swallow);
92
94 RCU_REQUIRE_SOFT (output_swallow != 0);
95
96 RCU::SetDirectory (output_swallow, 0);
97 ModuleData::addOutput (std::move (output));
98 }
#define RCU_CHANGE_INVARIANT(x)
Definition Assert.h:231
#define RCU_REQUIRE_SOFT(x)
Definition Assert.h:153
bool SetDirectory(TObject *object, TDirectory *directory)
effects: set the directory this object is associated with returns: whether the object type actively k...
Definition RootUtils.cxx:28
output
Definition merge.py:16

◆ addOutputList()

void EL::Worker::addOutputList ( const std::string & name,
TObject * output_swallow )
overridevirtual

effects: add a given object to the output.

instead of trying to merge the outputs from multiple jobs the output file will contain a TList of the given name with the objects from all the output. guarantee: basic, argument is always swallowed failures: out of memory II requires: output_swallow != 0 rationale: This was primarily build to allow the GRL output to be collected from EventLoop jobs, but it can be used for any kind of output that can not or should not be merged.

Implements EL::IWorker.

Definition at line 102 of file Worker.cxx.

104 {
105 std::unique_ptr<TObject> output (output_swallow);
106
108 RCU_REQUIRE_SOFT (output_swallow != 0);
109
110 RCU::SetDirectory (output_swallow, 0);
111 std::unique_ptr<TList> list (new TList);
112 list->SetName (name.c_str());
113 list->Add (output.release());
114 addOutput (list.release());
115 }
void addOutput(TObject *output_swallow) final override
effects: add an object to the output.
Definition Worker.cxx:89
list(name, path='/')
Definition histSizes.py:38

◆ addOutputStream()

StatusCode EL::Worker::addOutputStream ( const std::string & label,
Detail::OutputStreamData output )
protected

effects: add another output file guarantee: strong failures: low level errors II failures: label already used

Definition at line 739 of file Worker.cxx.

742 {
743 using namespace msgEventLoop;
745
746 if (m_outputs.find (label) != m_outputs.end())
747 {
748 ANA_MSG_ERROR ("output file already defined for label: " + label);
749 return ::StatusCode::FAILURE;
750 }
751 if (data.file() == nullptr)
752 {
753 ANA_MSG_ERROR ("output stream does not have a file attached");
754 return ::StatusCode::FAILURE;
755 }
756 if (data.mainStreamName().empty())
757 data.setMainStreamName (label);
758 m_outputs.insert (std::make_pair (label, std::make_shared<Detail::OutputStreamData>(std::move (data))));
759 return ::StatusCode::SUCCESS;
760 }
#define ANA_MSG_ERROR(xmsg)
Macro printing error messages.
char data[hepevt_bytes_allocation_ATLAS]
Definition HepEvt.cxx:11
std::string label(const std::string &format, int i)
Definition label.h:19
std::map< std::string, std::shared_ptr< Detail::OutputStreamData > > m_outputs
the list of output files
Definition ModuleData.h:109

◆ addTree()

StatusCode EL::Worker::addTree ( const TTree & tree,
const std::string & stream )
finaloverridevirtual

effects: adds a tree to an output file specified by the stream/label failures: Incorrect stream/label specified, called at the wrong time note: See getOutputFile for failure types...

Implements EL::ITreeWorker.

Definition at line 155 of file Worker.cxx.

157 {
158 using namespace msgEventLoop;
159 RCU_READ_INVARIANT( this );
160
161 auto outputIter = m_outputs.find (stream);
162 if (outputIter == m_outputs.end())
163 {
164 ANA_MSG_ERROR ( "No output file with stream name \"" + stream +
165 "\" found" );
166 return ::StatusCode::FAILURE;
167 }
168
169 outputIter->second->addClone (tree);
170
171 // Return gracefully:
172 return ::StatusCode::SUCCESS;
173 }
#define RCU_READ_INVARIANT(x)
Definition Assert.h:229
TTree * tree() const override
description: the tree we are running on guarantee: no-fail
Definition Worker.cxx:210

◆ batchExecute()

StatusCode EL::Worker::batchExecute ( unsigned job_id,
const char * confFile )

effects: do what is needed to execute the given job segment guarantee: basic failures: job specific

Definition at line 832 of file Worker.cxx.

834 {
835 using namespace msgEventLoop;
837
838 try
839 {
840 std::unique_ptr<TFile> file (TFile::Open (confFile, "READ"));
841 if (file.get() == nullptr || file->IsZombie())
842 {
843 ANA_MSG_ERROR ("failed to open file: " << confFile);
844 return ::StatusCode::FAILURE;
845 }
846
847 std::unique_ptr<BatchJob> job (dynamic_cast<BatchJob*>(file->Get ("job")));
848 m_batchJob = job.get();
849 if (job.get() == nullptr)
850 {
851 ANA_MSG_ERROR ("failed to retrieve BatchJob object");
852 return ::StatusCode::FAILURE;
853 }
854
855 if (job_id >= job->segments.size())
856 {
857 ANA_MSG_ERROR ("invalid job-id " << job_id << ", max is " << job->segments.size());
858 return ::StatusCode::FAILURE;
859 }
860 BatchSegment *segment = &job->segments[job_id];
861 RCU_ASSERT (segment->job_id == job_id);
862 RCU_ASSERT (segment->sample < job->samples.size());
863 BatchSample *sample = &job->samples[segment->sample];
864
865 gSystem->Exec ("pwd");
866 gSystem->MakeDirectory ("output");
867
868 setMetaData (&sample->meta);
869 setOutputHist (job->location + "/fetch");
870 setSegmentName (segment->fullName);
871
872 setJobConfig (JobConfig (job->job.jobConfig()));
873
874 for (Job::outputIter out = job->job.outputBegin(),
875 end = job->job.outputEnd(); out != end; ++ out)
876 {
877 Detail::OutputStreamData data {
878 out->output()->makeWriter (segment->sampleName, segment->segmentName, ".root")};
879 ANA_CHECK (addOutputStream (out->label(), std::move (data)));
880 }
881
882 {
883 m_moduleConfig.emplace_back ("EL::Detail::BatchInputModule/BatchInputModule");
884 ANA_CHECK (m_moduleConfig.back().setProperty ("jobId", job_id));
886 if (maxEvents != -1)
887 ANA_CHECK (m_moduleConfig.back().setProperty ("maxEvents", maxEvents));
888 }
889
892 ANA_CHECK (finalize ());
893
894 std::ostringstream job_name;
895 job_name << job_id;
896 std::ofstream completed ((job->location + "/status/completed-" + job_name.str()).c_str());
897 return ::StatusCode::SUCCESS;
898 } catch (...)
899 {
900 Detail::report_exception (std::current_exception());
901 return ::StatusCode::FAILURE;
902 }
903 }
#define ANA_CHECK(EXP)
check whether the given expression was successful
static const std::string optMaxEvents
description: the name of the option used for setting the maximum number of events to process per samp...
Definition Job.h:225
const OutputStream * outputIter
Definition Job.h:143
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
::StatusCode finalize()
finalize the worker
Definition Worker.cxx:508
void setJobConfig(JobConfig &&jobConfig)
set the JobConfig
Definition Worker.cxx:366
void setMetaData(const SH::MetaObject *val_metaData)
set the metaData
Definition Worker.cxx:335
::StatusCode initialize()
initialize the worker
Definition Worker.cxx:378
void setSegmentName(const std::string &val_segmentName)
set the segment name
Definition Worker.cxx:356
::StatusCode processInputs()
process all the inputs
Definition Worker.cxx:494
double castDouble(const std::string &name, double def_val=0, CastMode mode=CAST_ERROR_THROW) const
the meta-data double with the given name
void report_exception(std::exception_ptr eptr)
print out the currently evaluated exception
BatchJob * m_batchJob
the BatchJob configuration (if used)
Definition ModuleData.h:112
TFile * file

◆ directExecute()

StatusCode EL::Worker::directExecute ( const SH::SamplePtr & sample,
const Job & job,
const std::string & location,
const SH::MetaObject & options )

run the job

Guarantee
basic

Definition at line 787 of file Worker.cxx.

790 {
791 using namespace msgEventLoop;
793
794 SH::MetaObject meta (*sample->meta());
795 meta.fetchDefaults (options);
796
797 setMetaData (&meta);
798 setOutputHist (location);
799 setSegmentName (sample->name());
800
801 ANA_MSG_INFO ("Running sample: " << sample->name());
802
803 setJobConfig (JobConfig (job.jobConfig()));
804
805 for (Job::outputIter out = job.outputBegin(),
806 end = job.outputEnd(); out != end; ++ out)
807 {
808 Detail::OutputStreamData data {
809 out->output()->makeWriter (sample->name(), "", ".root")};
810 ANA_CHECK (addOutputStream (out->label(), std::move (data)));
811 }
812
813 {
814 m_moduleConfig.emplace_back ("EL::Detail::DirectInputModule/DirectInputModule");
815 ANA_CHECK (m_moduleConfig.back().setProperty ("fileList", sample->makeFileList()));
817 if (maxEvents != -1)
818 ANA_CHECK (m_moduleConfig.back().setProperty ("maxEvents", maxEvents));
820 if (skipEvents != 0)
821 ANA_CHECK (m_moduleConfig.back().setProperty ("skipEvents", skipEvents));
822 }
823
826 ANA_CHECK (finalize ());
827 return ::StatusCode::SUCCESS;
828 }
#define ANA_MSG_INFO(xmsg)
Macro printing info messages.
static const std::string optSkipEvents
description: the name of the option used for skipping a certain number of events in the beginning rat...
Definition Job.h:233

◆ eventsProcessed()

uint64_t EL::Worker::eventsProcessed ( ) const
protectednoexcept

the number of events that have been processed

Guarantee
no-fail

Definition at line 778 of file Worker.cxx.

780 {
781 RCU_READ_INVARIANT (this);
782 return m_eventsProcessed;
783 }
uint64_t m_eventsProcessed
the number of events that have been processed
Definition ModuleData.h:88

◆ fileOpenErrorFilter()

bool EL::Worker::fileOpenErrorFilter ( int level,
bool ,
const char * s1,
const char * s2 )
staticprivate

Error handler for file opening.

Definition at line 638 of file Worker.cxx.

640 {
641 // Don't fail on missing dictionary messages.
642 if (strstr (s2, "no streamer or dictionary") != nullptr) {
643 return true;
644 }
645
646 // For messages above warning level (SysError, Error, Fatal)
647 if( level > kWarning ) {
648 // We won't output further; ROOT should have already put something in the log file
649 std::string msg = "ROOT error detected in Worker.cxx: ";
650 msg += s1;
651 msg += " ";
652 msg += s2;
653 throw std::runtime_error(msg);
654
655 // No need for further error handling
656 return false;
657 }
658
659 // Pass to the default error handlers
660 return true;
661 }
MsgStream & msg
Definition testRead.cxx:32

◆ filterPassed()

bool EL::Worker::filterPassed ( ) const
finaloverridevirtualnoexcept

whether the current algorithm passed its filter criterion for the current event

Guarantee
no-fail

Implements EL::IFilterWorker.

Definition at line 306 of file Worker.cxx.

308 {
309 RCU_READ_INVARIANT (this);
310 return !m_skipEvent;
311 }
bool m_skipEvent
whether we are skipping the current event
Definition ModuleData.h:82

◆ finalize()

StatusCode EL::Worker::finalize ( )
protected

finalize the worker

This method ought to be called after all events have been processed. It is meant to ensure that the job is ended properly and all outputs are written out and files are closed.

Guarantee
basic
Failures
finalization failures

Definition at line 507 of file Worker.cxx.

509 {
510 using namespace msgEventLoop;
511
513
514 if (m_algorithmsInitialized == false)
515 {
516 ANA_MSG_ERROR ("algorithms never got initialized");
517 return StatusCode::FAILURE;
518 }
519
521 for (auto& module : m_modules)
522 ANA_CHECK (module->onFinalize (*this));
523 for (auto& output : m_outputs)
524 {
525 if (output.first != Job::histogramStreamName && output.second->mainStreamName() == output.first)
526 {
527 output.second->saveOutput ();
528 output.second->close ();
529 std::string path = output.second->finalFileName ();
530 if (!path.empty())
531 addOutputList ("EventLoop_OutputStream_" + output.first, new TObjString (path.c_str()));
532 }
533 }
534 for (auto& module : m_modules)
535 ANA_CHECK (module->postFinalize (*this));
536 if (m_jobStats->GetListOfBranches()->GetEntries() > 0)
537 {
538 if (m_jobStats->Fill() <= 0)
539 {
540 ANA_MSG_ERROR ("failed to fill the job statistics tree");
541 return ::StatusCode::FAILURE;
542 }
543 ModuleData::addOutput (std::move (m_jobStats));
544 }
545 m_histOutput->saveOutput ();
546 for (auto& module : m_modules)
547 ANA_CHECK (module->onWorkerEnd (*this));
548 m_histOutput->saveOutput ();
549 m_histOutput->close ();
550
551 for (auto& module : m_modules){
552 ANA_CHECK (module->postFileClose(*this));
553 }
554 ANA_MSG_INFO ("worker finished successfully");
555 return ::StatusCode::SUCCESS;
556 }
static const std::string histogramStreamName
the name of the histogram output stream
Definition Job.h:618
void addOutputList(const std::string &name, TObject *output_swallow) override
effects: add a given object to the output.
Definition Worker.cxx:103
::StatusCode openInputFile(const std::string &inputFileUrl) override
open the given input file without processing it
Definition Worker.cxx:664
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
path
python interpreter configuration --------------------------------------—
Definition athena.py:128
std::unique_ptr< TTree > m_jobStats
Tree saving per-job statistics information.
Definition ModuleData.h:94

◆ getAlg()

Algorithm * EL::Worker::getAlg ( const std::string & name) const
overridevirtual

effects: returns the algorithms with the given name or NULL if there is none guarantee: strong failures: out of memory II

Implements EL::IWorker.

Definition at line 283 of file Worker.cxx.

285 {
286 RCU_READ_INVARIANT (this);
287 for (auto& alg : m_algs)
288 {
289 if (alg->hasName (name))
290 return alg.m_algorithm->getLegacyAlg();
291 }
292 return 0;
293 }
std::vector< Detail::AlgorithmData > m_algs
the list of algorithms
Definition ModuleData.h:66

◆ getOutputFile()

TFile * EL::Worker::getOutputFile ( const std::string & label) const
overridevirtual

effects: get the output file that goes into the dataset with the given label.

this dataset has to be registered before the job is submitted. typically that happens in the doSetupJob method. guarantee: strong failures: no dataset with the given label postcondition: result != 0 note: the default value for the argument corresponds to the default label value in the OutputInfo class.

Implements EL::IWorker.

Definition at line 131 of file Worker.cxx.

133 {
134 RCU_READ_INVARIANT (this);
135 TFile *result = getOutputFileNull (label);
136 if (result == 0)
137 RCU_THROW_MSG ("no output dataset defined with label: " + label);
138 return result;
139 }
#define RCU_THROW_MSG(message)
Definition PrintMsg.h:58
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

◆ getOutputFileNull()

TFile * EL::Worker::getOutputFileNull ( const std::string & label) const
overridevirtual

effects: get the output file that goes into the dataset with the given label.

this dataset has to be registered before the job is submitted. typically that happens in the doSetupJob method. guarantee: strong failures: internal errors note: the default value for the argument corresponds to the default label value in the OutputInfo class. rationale: this method was added to support optional output files, i.e.: the algorithm leaves it to the user whether or not the output file gets configured. then the algorithm just checks whether the output file is there. if so it fills it, otherwise it ignores it.

Implements EL::IWorker.

Definition at line 143 of file Worker.cxx.

145 {
146 RCU_READ_INVARIANT (this);
147 auto iter = m_outputs.find (label);
148 if (iter == m_outputs.end())
149 return 0;
150 return iter->second->file();
151 }

◆ getOutputHist()

TObject * EL::Worker::getOutputHist ( const std::string & name) const
finaloverridevirtual

get the output histogram with the given name

This is mostly meant, so that I can emulate the Athena histogram mechanism.

Guarantee
strong
Failures
object not found
Postcondition
result != 0

Implements EL::IHistogramWorker.

Definition at line 119 of file Worker.cxx.

121 {
122 RCU_READ_INVARIANT (this);
123
124 TObject *result = m_histOutput->getOutputHist (name);
125 if (result == nullptr) RCU_THROW_MSG ("unknown output histogram: " + name);
126 return result;
127 }

◆ getOutputTree()

TTree * EL::Worker::getOutputTree ( const std::string & name,
const std::string & stream ) const
finaloverridevirtual

effects: get the tree that was added to an output file earlier failures: Tree doesn't exist

Implements EL::ITreeWorker.

Definition at line 177 of file Worker.cxx.

179 {
180 using namespace msgEventLoop;
181 RCU_READ_INVARIANT( this );
182
183 auto outputIter = m_outputs.find (stream);
184 if (outputIter == m_outputs.end())
185 {
186 RCU_THROW_MSG ( "No output file with stream name \"" + stream
187 + "\" found" );
188 }
189
190 TTree *result = outputIter->second->getOutputTree( name );
191 if( result == nullptr ) {
192 RCU_THROW_MSG ( "No tree with name \"" + name + "\" in stream \"" +
193 stream + "\"" );
194 }
195 return result;
196 }

◆ gridCreateJobSummary()

void EL::Worker::gridCreateJobSummary ( uint64_t eventsProcessed)
private

◆ gridExecute()

StatusCode EL::Worker::gridExecute ( const std::string & sampleName,
Long64_t SkipEvents,
Long64_t nEventsPerJob )

Definition at line 907 of file Worker.cxx.

909 {
910 using namespace msgEventLoop;
912
913 ANA_MSG_INFO ("Running with ROOT version " << gROOT->GetVersion()
914 << " (" << gROOT->GetVersionDate() << ")");
915
916 ANA_MSG_INFO ("Loading EventLoop grid job");
917
918
919 TList bigOutputs;
920 std::unique_ptr<JobConfig> jobConfig;
921 SH::MetaObject *mo = 0;
922
923 std::unique_ptr<TFile> f (TFile::Open("jobdef.root"));
924 if (f == nullptr || f->IsZombie()) {
925 ANA_MSG_ERROR ("Could not read jobdef");
926 return ::StatusCode::FAILURE;
927 }
928
929 mo = dynamic_cast<SH::MetaObject*>(f->Get(sampleName.c_str()));
930 if (!mo)
931 mo = dynamic_cast<SH::MetaObject*>(f->Get("defaultMetaObject"));
932 if (!mo) {
933 ANA_MSG_ERROR ("Could not read in sample meta object");
934 return ::StatusCode::FAILURE;
935 }
936
937 jobConfig.reset (dynamic_cast<JobConfig*>(f->Get("jobConfig")));
938 if (jobConfig == nullptr)
939 {
940 ANA_MSG_ERROR ("failed to read jobConfig object");
941 return ::StatusCode::FAILURE;
942 }
943
944 {
945 std::unique_ptr<TList> outs ((TList*)f->Get("outputs"));
946 if (outs == nullptr)
947 {
948 ANA_MSG_ERROR ("Could not read list of outputs");
949 return ::StatusCode::FAILURE;
950 }
951
952 TIter itr(outs.get());
953 TObject *obj = 0;
954 while ((obj = itr())) {
955 EL::OutputStream * out = dynamic_cast<EL::OutputStream*>(obj);
956 if (out) {
957 bigOutputs.Add(out);
958 }
959 else {
960 ANA_MSG_ERROR ("Encountered unexpected entry in list of outputs");
961 return ::StatusCode::FAILURE;
962 }
963 }
964 }
965
966 f->Close();
967 f.reset ();
968
969 const std::string location = ".";
970
971 mo->setBool (Job::optGridReporting, true);
972 setMetaData (mo);
973 setOutputHist (location);
974 setSegmentName ("output");
975
976 ANA_MSG_INFO ("Starting EventLoop Grid worker");
977
978 {//Create and register the "big" output files with base class
979 TIter itr(&bigOutputs);
980 TObject *obj = 0;
981 while ((obj = itr())) {
982 EL::OutputStream *os = dynamic_cast<EL::OutputStream*>(obj);
983 if (os == nullptr)
984 {
985 ANA_MSG_ERROR ("Bad input");
986 return ::StatusCode::FAILURE;
987 }
988 {
989 Detail::OutputStreamData data {
990 location + "/" + os->label() + ".root", "RECREATE"};
991 ANA_CHECK (addOutputStream (os->label(), std::move (data)));
992 }
993 }
994 }
995
996 setJobConfig (std::move (*jobConfig));
997
998 {
999 std::vector<std::string> fileList;
1000 std::ifstream infile("input.txt");
1001 while (infile) {
1002 std::string sLine;
1003 if (!getline(infile, sLine)) break;
1004 std::istringstream ssLine(sLine);
1005 while (ssLine) {
1006 std::string sFile;
1007 if (!getline(ssLine, sFile, ',')) break;
1008 fileList.push_back(sFile);
1009 }
1010 }
1011 if (fileList.size() == 0) {
1012 ANA_MSG_ERROR ("no input files provided");
1013 //User was expecting input after all.
1014 gSystem->Exit(EC_BADINPUT);
1015 }
1016 m_moduleConfig.emplace_back ("EL::Detail::DirectInputModule/DirectInputModule");
1017 ANA_CHECK (m_moduleConfig.back().setProperty ("fileList", fileList));
1018
1019 if (nEventsPerJob != -1)
1020 ANA_CHECK (m_moduleConfig.back().setProperty ("maxEvents", nEventsPerJob));
1021 if (SkipEvents != 0)
1022 ANA_CHECK (m_moduleConfig.back().setProperty ("skipEvents", SkipEvents));
1023 }
1024
1027 ANA_CHECK (finalize ());
1028
1029 int nEvents = eventsProcessed();
1030 ANA_MSG_INFO ("Loop finished.");
1031 ANA_MSG_INFO ("Read/processed " << nEvents << " events.");
1032
1033 ANA_MSG_INFO ("EventLoop Grid worker finished");
1034 ANA_MSG_INFO ("Saving output");
1035 return ::StatusCode::SUCCESS;
1036 }
static const std::string optGridReporting
whether to use grid reporting even when not running on the grid
Definition Job.h:510
uint64_t eventsProcessed() const noexcept
the number of events that have been processed
Definition Worker.cxx:779
void setBool(const std::string &name, bool value)
set the meta-data boolean with the given name
const int nEvents
str infile
Definition run.py:13

◆ initialize()

StatusCode EL::Worker::initialize ( )
protected

initialize the worker

This method ought to be called after the options on the worker are set and before any events are processed. It is meant to make sure everything is ready and set up for event processing.

Guarantee
basic
Failures
initialization failures

Definition at line 377 of file Worker.cxx.

379 {
380 using namespace msgEventLoop;
382
383 const bool xAODInput = m_metaData->castBool (Job::optXAODInput, false);
384
385 ANA_MSG_INFO ("xAODInput = " << xAODInput);
386
387 if (metaData()->castBool (Job::optAlgorithmMemoryMonitor, false))
388 m_moduleConfig.emplace_back ("EL::Detail::MemoryMonitorModule/EarlyMemoryMonitorModule");
389 if (auto cacheSize = metaData()->castDouble (Job::optCacheSize, 0); cacheSize > 0)
390 {
391 m_moduleConfig.emplace_back ("EL::Detail::TreeCacheModule/TreeCacheModule");
392 ANA_CHECK (m_moduleConfig.back().setProperty ("cacheSize", Long64_t (cacheSize)));
393 ANA_CHECK (m_moduleConfig.back().setProperty ("cacheLearnEntries", Long64_t (metaData()->castInteger (Job::optCacheLearnEntries, 0))));
394 ANA_CHECK (m_moduleConfig.back().setProperty ("printPerFileStats", metaData()->castBool (Job::optPrintPerFileStats, false)));
395 }
396 if (xAODInput)
397 {
398 m_moduleConfig.emplace_back ("EL::Detail::TEventModule/TEventModule");
399 ANA_CHECK (m_moduleConfig.back().setProperty ("accessMode", metaData()->castString (Job::optXaodAccessMode)));
400 ANA_CHECK (m_moduleConfig.back().setProperty ("otherMetaDataTreeNamePattern", metaData()->castString (Job::optOtherMetaDataTreeNamePattern)));
401 if (metaData()->castDouble (Job::optXAODSummaryReport, 1) == 0)
402 ANA_CHECK (m_moduleConfig.back().setProperty ("summaryReport", false));
403 ANA_CHECK (m_moduleConfig.back().setProperty ("useStats", metaData()->castBool (Job::optXAODPerfStats, false)));
404 }
405 auto factoryPreload = metaData()->castString (Job::optFactoryPreload, "");
406 if (!factoryPreload.empty())
407 {
408 m_moduleConfig.emplace_back ("EL::Detail::FactoryPreloadModule/FactoryPreloadModule");
409 ANA_CHECK (m_moduleConfig.back().setProperty ("preloader", factoryPreload));
410 }
411 m_moduleConfig.emplace_back ("EL::Detail::LeakCheckModule/LeakCheckModule");
412 ANA_CHECK (m_moduleConfig.back().setProperty ("failOnLeak", metaData()->castBool (Job::optMemFailOnLeak, false)));
413 ANA_CHECK (m_moduleConfig.back().setProperty ("absResidentLimit", metaData()->castInteger (Job::optMemResidentIncreaseLimit, 10000)));
414 ANA_CHECK (m_moduleConfig.back().setProperty ("absVirtualLimit", metaData()->castInteger (Job::optMemVirtualIncreaseLimit, 0)));
415 ANA_CHECK (m_moduleConfig.back().setProperty ("perEvResidentLimit", metaData()->castInteger (Job::optMemResidentPerEventIncreaseLimit, 10)));
416 ANA_CHECK (m_moduleConfig.back().setProperty ("perEvVirtualLimit", metaData()->castInteger (Job::optMemVirtualPerEventIncreaseLimit, 0)));
417 m_moduleConfig.emplace_back ("EL::Detail::StopwatchModule/StopwatchModule");
418 if (metaData()->castBool (Job::optGridReporting, false))
419 m_moduleConfig.emplace_back ("EL::Detail::GridReportingModule/GridReportingModule");
420 if (metaData()->castBool (Job::optAlgorithmTimer, false))
421 m_moduleConfig.emplace_back ("EL::Detail::AlgorithmTimerModule/AlgorithmTimerModule");
422 if (metaData()->castBool (Job::optAlgorithmMemoryMonitor, false))
423 m_moduleConfig.emplace_back ("EL::Detail::AlgorithmMemoryModule/AlgorithmMemoryModule");
424 m_moduleConfig.emplace_back ("EL::Detail::FileExecutedModule/FileExecutedModule");
425 m_moduleConfig.emplace_back ("EL::Detail::EventCountModule/EventCountModule");
426 m_moduleConfig.emplace_back ("EL::Detail::WorkerConfigModule/WorkerConfigModule");
427 m_moduleConfig.emplace_back ("EL::Detail::AlgorithmStateModule/AlgorithmStateModule");
428 m_moduleConfig.emplace_back ("EL::Detail::PostClosedOutputsModule/PostClosedOutputsModule");
429 if (metaData()->castBool (Job::optAlgorithmMemoryMonitor, false))
430 m_moduleConfig.emplace_back ("EL::Detail::MemoryMonitorModule/LateMemoryMonitorModule");
431
432 for (const auto& config : m_moduleConfig)
433 {
434 std::unique_ptr<Detail::Module> module;
435 ANA_CHECK (make_module (module, config));
436 m_modules.push_back (std::move (module));
437 }
438
439 if (m_outputs.find (Job::histogramStreamName) == m_outputs.end())
440 {
441 Detail::OutputStreamData data {
442 m_outputTarget + "/hist-" + m_segmentName + ".root", "RECREATE"};
444 }
447 if (auto aliases = metaData()->castString (Job::optStreamAliases, ""); !aliases.empty())
448 {
449 // the format of aliases is "alias1=realname1,alias2=realname2"
450 std::istringstream iss (aliases);
451 std::string alias;
452 while (std::getline (iss, alias, ','))
453 {
454 auto pos = alias.find ('=');
455 if (pos == std::string::npos)
456 {
457 ANA_MSG_ERROR ("Invalid alias format: " << alias);
458 return ::StatusCode::FAILURE;
459 }
460 auto aliasName = alias.substr (0, pos);
461 auto realName = alias.substr (pos + 1);
462 auto realOutput = m_outputs.find (realName);
463 if (realOutput == m_outputs.end())
464 {
465 ANA_MSG_ERROR ("output stream " << realName << " not found for alias " << aliasName);
466 return ::StatusCode::FAILURE;
467 }
468 auto [aliasOutput, success] = m_outputs.emplace (aliasName, realOutput->second);
469 if (!success)
470 {
471 ANA_MSG_ERROR ("output stream " << aliasName << " already exists, can't make alias");
472 return ::StatusCode::FAILURE;
473 }
474 }
475 }
476
477 m_jobStats = std::make_unique<TTree>
478 ("EventLoop_JobStats", "EventLoop job statistics");
479 m_jobStats->SetDirectory (nullptr);
480
481 ANA_MSG_INFO ("calling firstInitialize on all modules");
482 for (auto& module : m_modules)
483 ANA_CHECK (module->firstInitialize (*this));
484 ANA_MSG_INFO ("calling preFileInitialize on all modules");
485 for (auto& module : m_modules)
486 ANA_CHECK (module->preFileInitialize (*this));
487
488 return ::StatusCode::SUCCESS;
489 }
static const std::string optPrintPerFileStats
description: the option to turn on printing of i/o statistics at the end of each file rationale: whil...
Definition Job.h:425
static const std::string optMemFailOnLeak
Failure behaviour of the code when a "significant memory leak" is found.
Definition Job.h:607
static const std::string optAlgorithmTimer
a boolean flag for whether to add a timer for the algorithms
Definition Job.h:205
static const std::string optMemResidentIncreaseLimit
The minimal resident memory increase necessary to trigger an error.
Definition Job.h:585
static const std::string optXAODPerfStats
description: the name of the option for turning on XAODPerfStats.
Definition Job.h:356
static const std::string optXAODSummaryReport
the option to turn on/off the xAOD summary reporting at the end of the job
Definition Job.h:415
static const std::string optXaodAccessMode
description: the option to select the access mode for xAODs.
Definition Job.h:400
static const std::string optCacheLearnEntries
description: this option allows to configure the number of tree entries used for learning cache behav...
Definition Job.h:327
static const std::string optCacheSize
description: this option allows to configure the TTreeCache size for this job.
Definition Job.h:312
static const std::string optAlgorithmMemoryMonitor
a boolean flag for whether to add a memory monitor for the algorithms
Definition Job.h:210
static const std::string optXAODInput
the option to select whether our input is xAODs
Definition Job.h:393
static const std::string optMemResidentPerEventIncreaseLimit
The minimal per-event resident memory increase for triggering an error.
Definition Job.h:567
static const std::string optMemVirtualIncreaseLimit
The minimal virtual memory increase necessary to trigger an error.
Definition Job.h:593
static const std::string optMemVirtualPerEventIncreaseLimit
The minimal per-event virtual memory increase for triggering an error.
Definition Job.h:577
static const std::string optStreamAliases
an option for stream aliases
Definition Job.h:217
static const std::string optFactoryPreload
a boolean flag for whether to perform a component factory preload
Definition Job.h:214
static const std::string optOtherMetaDataTreeNamePattern
Pattern for other MetaData tree name in input xAODs Can be useful for augmented file reading or exclu...
Definition Job.h:409
std::string m_segmentName
the name of the segment we are processing
Definition Worker.h:431
std::string m_outputTarget
the target file to which we will write the histogram output
Definition Worker.h:426
std::string castString(const std::string &name, const std::string &def_val="", CastMode mode=CAST_ERROR_THROW) const
the meta-data string with the given name
const SH::MetaObject * m_metaData
the meta-data we use
Definition ModuleData.h:85

◆ inputFile()

TFile * EL::Worker::inputFile ( ) const
overridevirtual

description: the file we are reading the current tree from guarantee: no-fail

Implements EL::IWorker.

Definition at line 227 of file Worker.cxx.

229 {
230 RCU_READ_INVARIANT (this);
231 return m_inputFile.get();
232 }
std::unique_ptr< TFile > m_inputFile
the input file pointer of the currently opened filed
Definition ModuleData.h:72

◆ inputFileName()

std::string EL::Worker::inputFileName ( ) const
overridevirtual

the name of the file we are reading the current tree from, without the path component

Guarantee
no-fail

Implements EL::IWorker.

Definition at line 236 of file Worker.cxx.

238 {
239 // no invariant used
240 std::string path = inputFile()->GetName();
241 auto split = path.rfind ('/');
242 if (split != std::string::npos)
243 return path.substr (split + 1);
244 else
245 return path;
246 }
TFile * inputFile() const override
description: the file we are reading the current tree from guarantee: no-fail
Definition Worker.cxx:228
std::vector< std::string > split(const std::string &s, const std::string &t=":")
Definition hcg.cxx:177

◆ inputFileNumEntries()

Long64_t EL::Worker::inputFileNumEntries ( ) const
overrideprotectedvirtual

the number of events in the input file

Guarantee
no-fail
Precondition
inputFile() != 0

Implements EL::Detail::IInputModuleActions.

Definition at line 764 of file Worker.cxx.

766 {
767 RCU_READ_INVARIANT (this);
768 RCU_REQUIRE (inputFile() != 0);
769
770 if (m_inputTree != 0)
771 return m_inputTree->GetEntries();
772 else
773 return 0;
774 }
#define RCU_REQUIRE(x)
Definition Assert.h:208
TTree * m_inputTree
the (main) tree in the input file
Definition ModuleData.h:75

◆ metaData()

const SH::MetaObject * EL::Worker::metaData ( ) const
overridevirtual

description: the sample meta-data we are working on guarantee: no-fail invariant: metaData != 0 rationale: this can be used for accessing sample meta-data

Implements EL::IWorker.

Definition at line 200 of file Worker.cxx.

202 {
203 RCU_READ_INVARIANT (this);
204 return m_metaData;
205 }

◆ openInputFile()

StatusCode EL::Worker::openInputFile ( const std::string & inputFileUrl)
overrideprotectedvirtual

open the given input file without processing it

This is mostly to allow the driver to query the number of events in the input file without processing it, usually to determine the range of events to process.

Guarantee
basic
Failures
file can't be opened

Implements EL::Detail::IInputModuleActions.

Definition at line 663 of file Worker.cxx.

665 {
666 using namespace msgEventLoop;
667
668 // Enable custom error handling in a nice way
669 RootUtils::WithRootErrorHandler my_handler( fileOpenErrorFilter );
670
672
673 if (m_inputFileUrl == inputFileUrl)
674 return ::StatusCode::SUCCESS;
675
676 if (!m_inputFileUrl.empty())
677 {
678 if (m_newInputFile == false)
679 {
680 for (auto& module : m_modules)
681 ANA_CHECK (module->onCloseInputFile (*this));
682 for (auto& module : m_modules)
683 ANA_CHECK (module->postCloseInputFile (*this));
684 }
685 m_newInputFile = false;
686 m_inputTree = nullptr;
687 m_inputFile.reset ();
688 m_inputFileUrl.clear ();
689 }
690
691 if (inputFileUrl.empty())
692 return ::StatusCode::SUCCESS;
693
694 ANA_MSG_INFO ("Opening file " << inputFileUrl);
695 std::unique_ptr<TFile> inputFile;
696 try
697 {
698 inputFile = SH::openFile (inputFileUrl, *metaData());
699 } catch (...)
700 {
701 Detail::report_exception (std::current_exception());
702 }
703 if (inputFile.get() == 0)
704 {
705 ANA_MSG_ERROR ("failed to open file " << inputFileUrl);
706 for (auto& module : m_modules)
707 module->reportInputFailure (*this);
708 return ::StatusCode::FAILURE;
709 }
710 if (inputFile->IsZombie())
711 {
712 ANA_MSG_ERROR ("input file is a zombie: " << inputFileUrl);
713 for (auto& module : m_modules)
714 module->reportInputFailure (*this);
715 return ::StatusCode::FAILURE;
716 }
717
718 TTree *tree = 0;
719 const std::string treeName
721 tree = dynamic_cast<TTree*>(inputFile->Get (treeName.c_str()));
722 if (tree == nullptr)
723 {
724 ANA_MSG_INFO ("tree " << treeName << " not found in input file: " << inputFileUrl);
725 ANA_MSG_INFO ("treating this like a tree with no events");
726 }
727
728 m_newInputFile = true;
731 m_inputFile = std::move (inputFile);
732 m_inputFileUrl = std::move (inputFileUrl);
733
734 return ::StatusCode::SUCCESS;
735 }
static bool fileOpenErrorFilter(int level, bool, const char *, const char *)
Error handler for file opening.
Definition Worker.cxx:639
bool m_newInputFile
whether this is a new input file (i.e.
Definition Worker.h:421
std::unique_ptr< TFile > openFile(const std::string &name, const MetaObject &options)
open a file with the given options
std::string m_inputFileUrl
the input file url of the currently opened file
Definition ModuleData.h:69
uint64_t m_inputTreeEntry
the entry in the input tree we are currently looking at
Definition ModuleData.h:79
static const std::string treeName_default
the default value of treeName
Definition MetaFields.h:55
static const std::string treeName
the name of the tree in the sample
Definition MetaFields.h:52

◆ processEvents()

StatusCode EL::Worker::processEvents ( EventRange & eventRange)
overrideprotectedvirtual

process the given event range

This will update eventRange if the end is set to eof

Guarantee
basic
Failures
file can't be opened
event range exceeds length of file
processing failures

Implements EL::Detail::IInputModuleActions.

Definition at line 560 of file Worker.cxx.

562 {
563 using namespace msgEventLoop;
564
566 RCU_REQUIRE (!eventRange.m_url.empty());
567 RCU_REQUIRE (eventRange.m_beginEvent >= 0);
568 RCU_REQUIRE (eventRange.m_endEvent == EventRange::eof || eventRange.m_endEvent >= eventRange.m_beginEvent);
569
570 ANA_CHECK (openInputFile (eventRange.m_url));
571
572 if (eventRange.m_beginEvent > inputFileNumEntries())
573 {
574 ANA_MSG_ERROR ("first event (" << eventRange.m_beginEvent << ") points beyond last event in file (" << inputFileNumEntries() << ")");
575 return ::StatusCode::FAILURE;
576 }
577 if (eventRange.m_endEvent == EventRange::eof)
578 {
579 eventRange.m_endEvent = inputFileNumEntries();
580 } else if (eventRange.m_endEvent > inputFileNumEntries())
581 {
582 ANA_MSG_ERROR ("end event (" << eventRange.m_endEvent << ") points beyond last event in file (" << inputFileNumEntries() << ")");
583 return ::StatusCode::FAILURE;
584 }
585
586 m_inputTreeEntry = eventRange.m_beginEvent;
587
588 if (m_algorithmsInitialized == false)
589 {
590 for (auto& module : m_modules)
591 ANA_CHECK (module->onInitialize (*this));
593 }
594
595 if (m_newInputFile)
596 {
597 m_newInputFile = false;
598 for (auto& module : m_modules)
599 ANA_CHECK (module->onNewInputFile (*this));
600 }
601
602 if (eventRange.m_beginEvent == 0)
603 {
604 for (auto& module : m_modules)
605 ANA_CHECK (module->onFileExecute (*this));
606 }
607
608 ANA_MSG_INFO ("Processing events " << eventRange.m_beginEvent << "-" << eventRange.m_endEvent << " in file " << eventRange.m_url);
609
610 for (uint64_t event = eventRange.m_beginEvent;
611 event != uint64_t (eventRange.m_endEvent);
612 ++ event)
613 {
615 for (auto& module : m_modules)
616 {
617 if (module->onExecute (*this).isFailure())
618 {
619 ANA_MSG_ERROR ("processing event " << treeEntry() << " on file " << inputFileName());
620 return ::StatusCode::FAILURE;
621 }
622 }
623 if (m_firstEvent)
624 {
625 m_firstEvent = false;
626 for (auto& module : m_modules)
627 ANA_CHECK (module->postFirstEvent (*this));
628 }
630 if (m_eventsProcessed % 10000 == 0)
631 ANA_MSG_INFO ("Processed " << m_eventsProcessed << " events");
632 }
633 return ::StatusCode::SUCCESS;
634 }
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
Long64_t inputFileNumEntries() const override
the number of events in the input file
Definition Worker.cxx:765
bool m_firstEvent
whether we are still to process the first event
Definition Worker.h:441
static constexpr Long64_t eof
the special value to indicate that the range includes all events until the end of the file
Definition EventRange.h:34

◆ processInputs()

StatusCode EL::Worker::processInputs ( )
protected

process all the inputs

This method ought to be called after initialize and before finalize. It will rely on the defined modules to steer it to the files and events it ought to process.

Definition at line 493 of file Worker.cxx.

495 {
496 using namespace msgEventLoop;
497
499
500 for (auto& module : m_modules)
501 ANA_CHECK (module->processInputs (*this, *this));
502 return ::StatusCode::SUCCESS;
503 }

◆ setFilterPassed()

void EL::Worker::setFilterPassed ( bool val_filterPassed)
finaloverridevirtualnoexcept

set the value of filterPassed

Guarantee
no-fail

Implements EL::IFilterWorker.

Definition at line 315 of file Worker.cxx.

317 {
319 m_skipEvent = !val_filterPassed;
320 }

◆ setJobConfig()

void EL::Worker::setJobConfig ( JobConfig && jobConfig)
protected

set the JobConfig

This takes care of adding the algorithms, etc. (only algorithms for now, 03 Feb 17).

Note the rvalue calling convention here: Algorithms are objects that get modified, so if you use them more than once you need to copy/clone them. However, in practice no driver should need that (though many do for now, 03 Feb 17), as drivers generally stream the JobConfig in for one-time use.

Guarantee
basic
Failures
job configuration/streaming errors

Definition at line 365 of file Worker.cxx.

367 {
369 for (std::unique_ptr<IAlgorithmWrapper>& alg : jobConfig.extractAlgorithms())
370 {
371 m_algs.push_back (std::move (alg));
372 }
373 }

◆ setMetaData()

void EL::Worker::setMetaData ( const SH::MetaObject * val_metaData)
protected

set the metaData

Guarantee
no-fail

Definition at line 334 of file Worker.cxx.

336 {
338 RCU_REQUIRE (val_metaData != 0);
339
340 m_metaData = val_metaData;
341 }

◆ setOutputHist()

void EL::Worker::setOutputHist ( const std::string & val_outputTarget)
protected

set the histogram output list

Guarantee
no-fail

Definition at line 345 of file Worker.cxx.

347 {
349
350 m_outputTarget = val_outputTarget;
351 }

◆ setSegmentName()

void EL::Worker::setSegmentName ( const std::string & val_segmentName)
protected

set the segment name

Guarantee
no-fail

Definition at line 355 of file Worker.cxx.

357 {
359
360 m_segmentName = val_segmentName;
361 }

◆ skipEvent()

void EL::Worker::skipEvent ( )
overridevirtual

effects: skip the current event, i.e.

skip the rest of the algorithms for this event guarantee: no-fail rationale: if you have an analysis strategy in which you divide work into multiple algorithms you may want to have dedicated algorithms for event selection that then skip later algorithms that fill histograms

Implements EL::IWorker.

Definition at line 297 of file Worker.cxx.

299 {
301 m_skipEvent = true;
302 }

◆ testInvariant()

void EL::Worker::testInvariant ( ) const

effects: test the invariant of this object guarantee: no-fail

Definition at line 68 of file Worker.cxx.

70 {
71 RCU_INVARIANT (this != nullptr);
72 for (std::size_t iter = 0, end = m_algs.size(); iter != end; ++ iter)
73 {
74 RCU_INVARIANT (m_algs[iter].m_algorithm != nullptr);
75 }
76 }
#define RCU_INVARIANT(x)
Definition Assert.h:201

◆ tree()

TTree * EL::Worker::tree ( ) const
overridevirtual

description: the tree we are running on guarantee: no-fail

Implements EL::IWorker.

Definition at line 209 of file Worker.cxx.

211 {
212 RCU_READ_INVARIANT (this);
213 return m_inputTree;
214 }

◆ treeEntry()

Long64_t EL::Worker::treeEntry ( ) const
overridevirtual

description: the entry in the tree we are reading guarantee: no-fail

Implements EL::IWorker.

Definition at line 218 of file Worker.cxx.

220 {
221 RCU_READ_INVARIANT (this);
222 return m_inputTreeEntry;
223 }

◆ triggerConfig()

TTree * EL::Worker::triggerConfig ( ) const
overridevirtual

description: the trigger config tree from the input file, or NULL if we did not find it guarantee: strong failures: i/o errors

Implements EL::IWorker.

Definition at line 250 of file Worker.cxx.

252 {
253 RCU_READ_INVARIANT (this);
254 return dynamic_cast<TTree*>(inputFile()->Get("physicsMeta/TrigConfTree"));
255 }

◆ xaodEvent()

xAOD::TEvent * EL::Worker::xaodEvent ( ) const
overridevirtual

description: the xAOD event and store guarantee: strong failures: out of memory I failures: TEventSvc not configured postcondition: result != 0

Implements EL::IWorker.

Definition at line 259 of file Worker.cxx.

261 {
262 RCU_READ_INVARIANT (this);
263
264 if (m_tevent == nullptr)
265 RCU_THROW_MSG ("Job not configured for xAOD support");
266 return m_tevent;
267 }
xAOD::TEvent * m_tevent
the TEvent structure, if we use one
Definition ModuleData.h:97

◆ xaodStore()

xAOD::TStore * EL::Worker::xaodStore ( ) const
overridevirtual

Implements EL::IWorker.

Definition at line 271 of file Worker.cxx.

273 {
274 RCU_READ_INVARIANT (this);
275
276 if (m_tstore == nullptr)
277 RCU_THROW_MSG ("Job not configured for xAOD support");
278 return m_tstore;
279 }
xAOD::TStore * m_tstore
the TStore structure, if we use one
Definition ModuleData.h:100

Member Data Documentation

◆ m_algorithmsInitialized

bool EL::Worker::m_algorithmsInitialized {false}
private

whether the algorithms are initialized

Definition at line 436 of file Worker.h.

436{false};

◆ m_algs

std::vector<Detail::AlgorithmData> EL::Detail::ModuleData::m_algs
inherited

the list of algorithms

Definition at line 66 of file ModuleData.h.

◆ m_batchJob

BatchJob* EL::Detail::ModuleData::m_batchJob = nullptr
inherited

the BatchJob configuration (if used)

Definition at line 112 of file ModuleData.h.

◆ m_eventsProcessed

uint64_t EL::Detail::ModuleData::m_eventsProcessed {0}
inherited

the number of events that have been processed

Definition at line 88 of file ModuleData.h.

88{0};

◆ m_evtStore

asg::SgTEvent* EL::Detail::ModuleData::m_evtStore {nullptr}
inherited

the SgTEvent structure, if we use one

Definition at line 103 of file ModuleData.h.

103{nullptr};

◆ m_firstEvent

bool EL::Worker::m_firstEvent {true}
private

whether we are still to process the first event

Definition at line 441 of file Worker.h.

441{true};

◆ m_histOutput

OutputStreamData* EL::Detail::ModuleData::m_histOutput {nullptr}
inherited

the histogram output stream

Definition at line 91 of file ModuleData.h.

91{nullptr};

◆ m_inputFile

std::unique_ptr<TFile> EL::Detail::ModuleData::m_inputFile
inherited

the input file pointer of the currently opened filed

Definition at line 72 of file ModuleData.h.

◆ m_inputFileUrl

std::string EL::Detail::ModuleData::m_inputFileUrl
inherited

the input file url of the currently opened file

Definition at line 69 of file ModuleData.h.

◆ m_inputTree

TTree* EL::Detail::ModuleData::m_inputTree {nullptr}
inherited

the (main) tree in the input file

Definition at line 75 of file ModuleData.h.

75{nullptr};

◆ m_inputTreeEntry

uint64_t EL::Detail::ModuleData::m_inputTreeEntry {0}
inherited

the entry in the input tree we are currently looking at

Definition at line 79 of file ModuleData.h.

79{0};

◆ m_jobStats

std::unique_ptr<TTree> EL::Detail::ModuleData::m_jobStats
inherited

Tree saving per-job statistics information.

Definition at line 94 of file ModuleData.h.

◆ m_metaData

const SH::MetaObject* EL::Detail::ModuleData::m_metaData {nullptr}
inherited

the meta-data we use

Definition at line 85 of file ModuleData.h.

85{nullptr};

◆ m_moduleConfig

std::vector<asg::AsgComponentConfig> EL::Worker::m_moduleConfig
private

the module configurations we use

Definition at line 446 of file Worker.h.

◆ m_modules

std::vector<std::unique_ptr<Detail::Module> > EL::Worker::m_modules
private

the list of modules we hold

Definition at line 415 of file Worker.h.

◆ m_newInputFile

bool EL::Worker::m_newInputFile {false}
private

whether this is a new input file (i.e.

one that has not yet been connected to the algorithms)

Definition at line 421 of file Worker.h.

421{false};

◆ m_outputHistMap

std::map<std::string,TH1*> EL::Worker::m_outputHistMap
private

Definition at line 403 of file Worker.h.

◆ m_outputs

std::map<std::string,std::shared_ptr<Detail::OutputStreamData> > EL::Detail::ModuleData::m_outputs
inherited

the list of output files

Definition at line 109 of file ModuleData.h.

◆ m_outputTarget

std::string EL::Worker::m_outputTarget
private

the target file to which we will write the histogram output

Definition at line 426 of file Worker.h.

◆ m_outputTreeMap

std::map<std::pair<std::string,std::string>,TTree*> EL::Worker::m_outputTreeMap
private

Definition at line 410 of file Worker.h.

◆ m_segmentName

std::string EL::Worker::m_segmentName
private

the name of the segment we are processing

Definition at line 431 of file Worker.h.

◆ m_skipEvent

bool EL::Detail::ModuleData::m_skipEvent = false
inherited

whether we are skipping the current event

Definition at line 82 of file ModuleData.h.

◆ m_tevent

xAOD::TEvent* EL::Detail::ModuleData::m_tevent {nullptr}
inherited

the TEvent structure, if we use one

Definition at line 97 of file ModuleData.h.

97{nullptr};

◆ m_tstore

xAOD::TStore* EL::Detail::ModuleData::m_tstore {nullptr}
inherited

the TStore structure, if we use one

Definition at line 100 of file ModuleData.h.

100{nullptr};

◆ m_worker

Worker* EL::Detail::ModuleData::m_worker {nullptr}
inherited

the worker (to pass on to the algorithms)

Definition at line 106 of file ModuleData.h.

106{nullptr};

The documentation for this class was generated from the following files: