 |
ATLAS Offline Software
|
Go to the documentation of this file.
43 #include <TObjString.h>
58 using namespace msgEventLoop;
62 return StatusCode::SUCCESS;
91 std::unique_ptr<TObject> output (output_swallow);
97 ModuleData::addOutput (std::move (output));
105 std::unique_ptr<TObject> output (output_swallow);
111 std::unique_ptr<TList>
list (
new TList);
113 list->Add (output.release());
150 return iter->second->file();
158 using namespace msgEventLoop;
166 return ::StatusCode::FAILURE;
169 outputIter->second->addClone (
tree);
172 return ::StatusCode::SUCCESS;
180 using namespace msgEventLoop;
190 TTree *
result = outputIter->second->getOutputTree(
name );
242 if (
split != std::string::npos)
254 return dynamic_cast<TTree*
>(
inputFile()->Get(
"physicsMeta/TrigConfTree"));
290 return alg.m_algorithm->getLegacyAlg();
369 for (std::unique_ptr<IAlgorithmWrapper>&
alg :
jobConfig.extractAlgorithms())
380 using namespace msgEventLoop;
388 m_moduleConfig.emplace_back (
"EL::Detail::MemoryMonitorModule/EarlyMemoryMonitorModule");
391 m_moduleConfig.emplace_back (
"EL::Detail::TreeCacheModule/TreeCacheModule");
398 m_moduleConfig.emplace_back (
"EL::Detail::TEventModule/TEventModule");
405 if (!factoryPreload.empty())
407 m_moduleConfig.emplace_back (
"EL::Detail::FactoryPreloadModule/FactoryPreloadModule");
410 m_moduleConfig.emplace_back (
"EL::Detail::LeakCheckModule/LeakCheckModule");
416 m_moduleConfig.emplace_back (
"EL::Detail::StopwatchModule/StopwatchModule");
418 m_moduleConfig.emplace_back (
"EL::Detail::GridReportingModule/GridReportingModule");
420 m_moduleConfig.emplace_back (
"EL::Detail::AlgorithmTimerModule/AlgorithmTimerModule");
422 m_moduleConfig.emplace_back (
"EL::Detail::AlgorithmMemoryModule/AlgorithmMemoryModule");
423 m_moduleConfig.emplace_back (
"EL::Detail::FileExecutedModule/FileExecutedModule");
424 m_moduleConfig.emplace_back (
"EL::Detail::EventCountModule/EventCountModule");
425 m_moduleConfig.emplace_back (
"EL::Detail::WorkerConfigModule/WorkerConfigModule");
426 m_moduleConfig.emplace_back (
"EL::Detail::AlgorithmStateModule/AlgorithmStateModule");
427 m_moduleConfig.emplace_back (
"EL::Detail::PostClosedOutputsModule/PostClosedOutputsModule");
429 m_moduleConfig.emplace_back (
"EL::Detail::MemoryMonitorModule/LateMemoryMonitorModule");
433 std::unique_ptr<Detail::Module>
module;
449 std::istringstream iss (aliases);
451 while (std::getline (iss,
alias,
','))
454 if (
pos == std::string::npos)
457 return ::StatusCode::FAILURE;
459 auto aliasName =
alias.substr (0,
pos);
460 auto realName =
alias.substr (
pos + 1);
461 auto realOutput =
m_outputs.find (realName);
464 ANA_MSG_ERROR (
"output stream " << realName <<
" not found for alias " << aliasName);
465 return ::StatusCode::FAILURE;
467 auto [aliasOutput, success] =
m_outputs.emplace (aliasName, realOutput->second);
470 ANA_MSG_ERROR (
"output stream " << aliasName <<
" already exists, can't make alias");
471 return ::StatusCode::FAILURE;
477 (
"EventLoop_JobStats",
"EventLoop job statistics");
480 ANA_MSG_INFO (
"calling firstInitialize on all modules");
483 ANA_MSG_INFO (
"calling preFileInitialize on all modules");
487 return ::StatusCode::SUCCESS;
495 using namespace msgEventLoop;
501 return ::StatusCode::SUCCESS;
509 using namespace msgEventLoop;
516 return StatusCode::FAILURE;
526 output.second->saveOutput ();
527 output.second->close ();
528 std::string
path = output.second->finalFileName ();
530 addOutputList (
"EventLoop_OutputStream_" + output.first,
new TObjString (
path.c_str()));
535 if (
m_jobStats->GetListOfBranches()->GetEntries() > 0)
540 return ::StatusCode::FAILURE;
542 ModuleData::addOutput (std::move (
m_jobStats));
554 return ::StatusCode::SUCCESS;
562 using namespace msgEventLoop;
574 return ::StatusCode::FAILURE;
582 return ::StatusCode::FAILURE;
616 if (
module->onExecute (*this).isFailure())
619 return ::StatusCode::FAILURE;
632 return ::StatusCode::SUCCESS;
641 if (strstr (
s2,
"no streamer or dictionary") !=
nullptr) {
646 if(
level > kWarning ) {
648 std::string
msg =
"ROOT error detected in Worker.cxx: ";
652 throw std::runtime_error(
msg);
665 using namespace msgEventLoop;
673 return ::StatusCode::SUCCESS;
690 if (inputFileUrl.empty())
691 return ::StatusCode::SUCCESS;
706 module->reportInputFailure (*
this);
707 return ::StatusCode::FAILURE;
713 module->reportInputFailure (*
this);
714 return ::StatusCode::FAILURE;
724 ANA_MSG_INFO (
"treating this like a tree with no events");
733 return ::StatusCode::SUCCESS;
742 using namespace msgEventLoop;
748 return ::StatusCode::FAILURE;
750 if (
data.file() ==
nullptr)
752 ANA_MSG_ERROR (
"output stream does not have a file attached");
753 return ::StatusCode::FAILURE;
755 if (
data.mainStreamName().empty())
757 m_outputs.insert (std::make_pair (
label, std::make_shared<Detail::OutputStreamData>(std::move (
data))));
758 return ::StatusCode::SUCCESS;
790 using namespace msgEventLoop;
808 out->output()->makeWriter (
sample->name(),
"",
".root")};
813 m_moduleConfig.emplace_back (
"EL::Detail::DirectInputModule/DirectInputModule");
826 return ::StatusCode::SUCCESS;
834 using namespace msgEventLoop;
839 std::unique_ptr<TFile>
file (TFile::Open (confFile,
"READ"));
840 if (
file.get() ==
nullptr ||
file->IsZombie())
843 return ::StatusCode::FAILURE;
846 std::unique_ptr<BatchJob>
job (
dynamic_cast<BatchJob*
>(
file->Get (
"job")));
848 if (
job.get() ==
nullptr)
851 return ::StatusCode::FAILURE;
854 if (job_id >=
job->segments.size())
856 ANA_MSG_ERROR (
"invalid job-id " << job_id <<
", max is " <<
job->segments.size());
857 return ::StatusCode::FAILURE;
864 gSystem->Exec (
"pwd");
865 gSystem->MakeDirectory (
"output");
882 m_moduleConfig.emplace_back (
"EL::Detail::BatchInputModule/BatchInputModule");
893 std::ostringstream job_name;
895 std::ofstream
completed ((
job->location +
"/status/completed-" + job_name.str()).c_str());
896 return ::StatusCode::SUCCESS;
900 return ::StatusCode::FAILURE;
909 using namespace msgEventLoop;
912 ANA_MSG_INFO (
"Running with ROOT version " << gROOT->GetVersion()
913 <<
" (" << gROOT->GetVersionDate() <<
")");
922 std::unique_ptr<TFile>
f (TFile::Open(
"jobdef.root"));
923 if (
f ==
nullptr ||
f->IsZombie()) {
925 return ::StatusCode::FAILURE;
933 return ::StatusCode::FAILURE;
940 return ::StatusCode::FAILURE;
944 std::unique_ptr<TList> outs ((TList*)
f->Get(
"outputs"));
948 return ::StatusCode::FAILURE;
951 TIter itr(outs.get());
953 while ((
obj = itr())) {
959 ANA_MSG_ERROR (
"Encountered unexpected entry in list of outputs");
960 return ::StatusCode::FAILURE;
968 const std::string location =
".";
978 TIter itr(&bigOutputs);
980 while ((
obj = itr())) {
985 return ::StatusCode::FAILURE;
989 location +
"/" +
os->label() +
".root",
"RECREATE"};
999 std::ifstream
infile(
"input.txt");
1002 if (!getline(
infile, sLine))
break;
1003 std::istringstream ssLine(sLine);
1006 if (!getline(ssLine, sFile,
','))
break;
1015 m_moduleConfig.emplace_back (
"EL::Detail::DirectInputModule/DirectInputModule");
1034 return ::StatusCode::SUCCESS;
::StatusCode finalize()
finalize the worker
static const std::string optMaxEvents
description: the name of the option used for setting the maximum number of events to process per samp...
bool m_newInputFile
whether this is a new input file (i.e.
void addOutput(TObject *output_swallow) final override
effects: add an object to the output.
bool m_firstEvent
whether we are still to process the first event
std::vector< std::unique_ptr< Detail::Module > > m_modules
the list of modules we hold
all data needed to manage a given output stream
std::string m_outputTarget
the target file to which we will write the histogram output
char data[hepevt_bytes_allocation_ATLAS]
an object that stores the configuration for an AsgComponent and is able to create one from it
virtual bool filterPassed() const noexcept final override
whether the current algorithm passed its filter criterion for the current event
TFile * getOutputFileNull(const std::string &label) const override
effects: get the output file that goes into the dataset with the given label.
TObject * getOutputHist(const std::string &name) const noexcept
get the output histogram with the given name, or nullptr if there is no histogam with such a name
TTree * m_inputTree
the (main) tree in the input file
path
python interpreter configuration --------------------------------------—
uint64_t eventsProcessed() const noexcept
the number of events that have been processed
static const std::string optXaodAccessMode
description: the option to select the access mode for xAODs.
::StatusCode directExecute(const SH::SamplePtr &sample, const Job &job, const std::string &location, const SH::MetaObject &options)
run the job
std::string inputFileName() const override
the name of the file we are reading the current tree from, without the path component
std::string m_url
the location of the file
static const std::string optPrintPerFileStats
description: the option to turn on printing of i/o statistics at the end of each file rationale: whil...
TFile * inputFile() const override
description: the file we are reading the current tree from guarantee: no-fail
::StatusCode openInputFile(const std::string &inputFileUrl) override
open the given input file without processing it
static const std::string optMemResidentPerEventIncreaseLimit
The minimal per-event resident memory increase for triggering an error.
bool m_algorithmsInitialized
whether the algorithms are initialized
Long64_t m_beginEvent
the first event to process
BatchJob * m_batchJob
the BatchJob configuration (if used)
void close()
close this file
static const std::string optFactoryPreload
a boolean flag for whether to perform a component factory preload
bool const RAWDATA *ch2 const
std::unique_ptr< TFile > m_inputFile
the input file pointer of the currently opened filed
virtual void setFilterPassed(bool val_filterPassed) noexcept final override
set the value of filterPassed
std::unique_ptr< TTree > m_jobStats
Tree saving per-job statistics information.
static const std::string optXAODSummaryReport
the option to turn on/off the xAOD summary reporting at the end of the job
static const std::string optXAODInput
the option to select whether our input is xAODs
::StatusCode processEvents(EventRange &eventRange) override
process the given event range
std::map< std::string, std::shared_ptr< Detail::OutputStreamData > > m_outputs
the list of output files
static bool fileOpenErrorFilter(int level, bool, const char *, const char *)
Error handler for file opening.
static const std::string optStreamAliases
an option for stream aliases
const SH::MetaObject * metaData() const override
description: the sample meta-data we are working on guarantee: no-fail invariant: metaData !...
POOL::TEvent event(POOL::TEvent::kClassAccess)
#define RCU_REQUIRE_SOFT(x)
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...
void setSegmentName(const std::string &val_segmentName)
set the segment name
void setOutputHist(const std::string &val_outputTarget)
set the histogram output list
static const std::string optCacheSize
description: this option allows to configure the TTreeCache size for this job.
::StatusCode StatusCode
StatusCode definition for legacy code.
xAOD::TStore * m_tstore
the TStore structure, if we use one
static const std::string optXAODPerfStats
description: the name of the option for turning on XAODPerfStats.
TTree * triggerConfig() const override
description: the trigger config tree from the input file, or NULL if we did not find it guarantee: st...
virtual ~Worker()
effects: standard destructor guarantee: no-fail
This module defines the arguments passed from the BATCH driver to the BATCH worker.
std::unique_ptr< TFile > openFile(const std::string &name, const MetaObject &options)
open a file with the given options
static constexpr Long64_t eof
the special value to indicate that the range includes all events until the end of the file
std::vector< asg::AsgComponentConfig > m_moduleConfig
the module configurations we use
TObject * getOutputHist(const std::string &name) const final override
get the output histogram with the given name
static const std::string optCacheLearnEntries
description: this option allows to configure the number of tree entries used for learning cache behav...
static const std::string optMemFailOnLeak
Failure behaviour of the code when a "significant memory leak" is found.
Long64_t inputFileNumEntries() const override
the number of events in the input file
void setJobConfig(JobConfig &&jobConfig)
set the JobConfig
static const std::string optAlgorithmTimer
a boolean flag for whether to add a timer for the algorithms
static const std::string optMemResidentIncreaseLimit
The minimal resident memory increase necessary to trigger an error.
void skipEvent() override
effects: skip the current event, i.e.
static const std::string histogramStreamName
the name of the histogram output stream
static const std::string optAlgorithmMemoryMonitor
a boolean flag for whether to add a memory monitor for the algorithms
::StatusCode addOutputStream(const std::string &label, Detail::OutputStreamData output)
effects: add another output file guarantee: strong failures: low level errors II failures: label alre...
::StatusCode batchExecute(unsigned job_id, const char *confFile)
effects: do what is needed to execute the given job segment guarantee: basic failures: job specific
bool SetDirectory(TObject *object, TDirectory *directory)
effects: set the directory this object is associated with returns: whether the object type actively k...
Run a MT piece of code with an alternate root error handler.
the job configuration that is independent of driver and dataset
uint64_t m_inputTreeEntry
the entry in the input tree we are currently looking at
A smart pointer class that holds a single Sample object.
::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...
void testInvariant() const
effects: test the invariant of this object guarantee: no-fail
std::vector< Detail::AlgorithmData > m_algs
the list of algorithms
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
Run a MT piece of code with an alternate root error handler.
std::string m_inputFileUrl
the input file url of the currently opened file
OutputStreamData * m_histOutput
the histogram output stream
uint64_t m_eventsProcessed
the number of events that have been processed
A relatively simple transient store for objects created in analysis.
TFile * getOutputFile(const std::string &label) const override
effects: get the output file that goes into the dataset with the given label.
#define RCU_DESTROY_INVARIANT(x)
xAOD::TEvent * m_tevent
the TEvent structure, if we use one
bool m_skipEvent
whether we are skipping the current event
#define RCU_CHANGE_INVARIANT(x)
void setMetaData(const SH::MetaObject *val_metaData)
set the metaData
xAOD::TEvent * xaodEvent() const override
description: the xAOD event and store guarantee: strong failures: out of memory I failures: TEventSvc...
Long64_t treeEntry() const override
description: the entry in the tree we are reading guarantee: no-fail
::StatusCode gridExecute(const std::string &sampleName, Long64_t SkipEvents, Long64_t nEventsPerJob)
#define RCU_THROW_MSG(message)
static const std::string optSkipEvents
description: the name of the option used for skipping a certain number of events in the beginning rat...
::StatusCode initialize()
initialize the worker
void saveOutput()
write the list of output objects to disk and clear it
Worker * m_worker
the worker (to pass on to the algorithms)
xAOD::TStore * xaodStore() const override
static const std::string optMemVirtualPerEventIncreaseLimit
The minimal per-event virtual memory increase for triggering an error.
const SH::MetaObject * m_metaData
the meta-data we use
a range of events in a given file
#define RCU_READ_INVARIANT(x)
void report_exception(std::exception_ptr eptr)
print out the currently evaluated exception
TTree * tree() const override
description: the tree we are running on guarantee: no-fail
static const std::string optMemVirtualIncreaseLimit
The minimal virtual memory increase necessary to trigger an error.
void addOutputList(const std::string &name, TObject *output_swallow) override
effects: add a given object to the output.
Tool for accessing xAOD files outside of Athena.
Worker()
standard constructor
::StatusCode processInputs()
process all the inputs
static const std::string optGridReporting
whether to use grid reporting even when not running on the grid
Long64_t m_endEvent
the event past the last event, or eof
std::string m_segmentName
the name of the segment we are processing
Muon::NSW_PadTriggerSegment segment(const NSWL1::PadTrigger &data)
#define RCU_NEW_INVARIANT(x)