|
ATLAS Offline Software
|
Go to the documentation of this file.
56 #include <TObjString.h>
71 for (std::size_t iter = 0,
end =
m_algs.size(); iter !=
end; ++ iter)
90 std::unique_ptr<TObject>
output (output_swallow);
96 ModuleData::addOutput (std::move (
output));
104 std::unique_ptr<TObject>
output (output_swallow);
110 std::unique_ptr<TList>
list (
new TList);
149 return iter->second.file();
157 using namespace msgEventLoop;
165 return ::StatusCode::FAILURE;
168 outputIter->second.addClone (
tree);
171 return ::StatusCode::SUCCESS;
179 using namespace msgEventLoop;
189 TTree *
result = outputIter->second.getOutputTree(
name );
241 if (
split != std::string::npos)
253 return dynamic_cast<TTree*
>(
inputFile()->Get(
"physicsMeta/TrigConfTree"));
289 return alg.m_algorithm->getLegacyAlg();
368 for (std::unique_ptr<IAlgorithmWrapper>&
alg :
jobConfig.extractAlgorithms())
379 using namespace msgEventLoop;
386 m_modules.push_back (std::make_unique<Detail::MemoryMonitorModule> (
"EarlyMemoryMonitorModule"));
388 m_modules.push_back (std::make_unique<Detail::TEventModule> (
"TEventModule"));
390 if (!factoryPreload.empty())
392 auto module = std::make_unique<Detail::FactoryPreloadModule> (
"FactoryPreloadModule");
393 module->preloader = factoryPreload;
396 m_modules.push_back (std::make_unique<Detail::LeakCheckModule> (
"LeakCheckModule"));
397 m_modules.push_back (std::make_unique<Detail::StopwatchModule> (
"StopwatchModule"));
399 m_modules.push_back (std::make_unique<Detail::GridReportingModule>(
"GridReportingModule"));
401 m_modules.push_back (std::make_unique<Detail::AlgorithmTimerModule> (
"AlgorithmTimerModule"));
403 m_modules.push_back (std::make_unique<Detail::AlgorithmMemoryModule> (
"AlgorithmMemoryModule"));
404 m_modules.push_back (std::make_unique<Detail::FileExecutedModule> (
"FileExecutedModule"));
405 m_modules.push_back (std::make_unique<Detail::EventCountModule> (
"EventCountModule"));
406 m_modules.push_back (std::make_unique<Detail::WorkerConfigModule> (
"WorkerConfigModule"));
407 m_modules.push_back (std::make_unique<Detail::AlgorithmStateModule> (
"AlgorithmStateModule"));
408 m_modules.push_back (std::make_unique<Detail::PostClosedOutputsModule> (
"PostClosedOutputsModule"));
410 m_modules.push_back (std::make_unique<Detail::MemoryMonitorModule> (
"LateMemoryMonitorModule"));
422 (
"EventLoop_JobStats",
"EventLoop job statistics");
425 ANA_MSG_INFO (
"calling firstInitialize on all modules");
428 ANA_MSG_INFO (
"calling preFileInitialize on all modules");
432 return ::StatusCode::SUCCESS;
440 using namespace msgEventLoop;
446 return ::StatusCode::SUCCESS;
454 using namespace msgEventLoop;
461 return StatusCode::FAILURE;
471 output.second.saveOutput ();
473 std::string
path =
output.second.finalFileName ();
480 if (
m_jobStats->GetListOfBranches()->GetEntries() > 0)
485 return ::StatusCode::FAILURE;
487 ModuleData::addOutput (std::move (
m_jobStats));
499 return ::StatusCode::SUCCESS;
507 using namespace msgEventLoop;
519 return ::StatusCode::FAILURE;
527 return ::StatusCode::FAILURE;
561 if (
module->onExecute (*this).isFailure())
564 return ::StatusCode::FAILURE;
577 return ::StatusCode::SUCCESS;
586 if (strstr (
s2,
"no streamer or dictionary") !=
nullptr) {
591 if(
level > kWarning ) {
593 std::string
msg =
"ROOT error detected in Worker.cxx: ";
597 throw std::runtime_error(
msg);
610 using namespace msgEventLoop;
618 return ::StatusCode::SUCCESS;
635 if (inputFileUrl.empty())
636 return ::StatusCode::SUCCESS;
651 module->reportInputFailure (*
this);
652 return ::StatusCode::FAILURE;
658 module->reportInputFailure (*
this);
659 return ::StatusCode::FAILURE;
669 ANA_MSG_INFO (
"treating this like a tree with no events");
678 return ::StatusCode::SUCCESS;
687 using namespace msgEventLoop;
693 return ::StatusCode::FAILURE;
695 if (
data.file() ==
nullptr)
697 ANA_MSG_ERROR (
"output stream does not have a file attached");
698 return ::StatusCode::FAILURE;
701 return ::StatusCode::SUCCESS;
743 using namespace msgEventLoop;
761 out->output()->makeWriter (
sample->name(),
"",
".root")};
766 auto module = std::make_unique<Detail::DirectInputModule> (
"DirectInputModule");
780 return ::StatusCode::SUCCESS;
788 using namespace msgEventLoop;
793 std::unique_ptr<TFile>
file (TFile::Open (confFile,
"READ"));
794 if (
file.get() ==
nullptr ||
file->IsZombie())
797 return ::StatusCode::FAILURE;
800 std::unique_ptr<BatchJob>
job (
dynamic_cast<BatchJob*
>(
file->Get (
"job")));
801 if (
job.get() ==
nullptr)
804 return ::StatusCode::FAILURE;
807 if (job_id >=
job->segments.size())
809 ANA_MSG_ERROR (
"invalid job-id " << job_id <<
", max is " <<
job->segments.size());
810 return ::StatusCode::FAILURE;
817 gSystem->Exec (
"pwd");
818 gSystem->MakeDirectory (
"output");
835 auto module = std::make_unique<Detail::BatchInputModule> (
"BatchInputModule");
848 std::ostringstream job_name;
850 std::ofstream
completed ((
job->location +
"/status/completed-" + job_name.str()).c_str());
851 return ::StatusCode::SUCCESS;
855 return ::StatusCode::FAILURE;
864 using namespace msgEventLoop;
867 ANA_MSG_INFO (
"Running with ROOT version " << gROOT->GetVersion()
868 <<
" (" << gROOT->GetVersionDate() <<
")");
877 std::unique_ptr<TFile>
f (TFile::Open(
"jobdef.root"));
878 if (
f ==
nullptr ||
f->IsZombie()) {
880 return ::StatusCode::FAILURE;
888 return ::StatusCode::FAILURE;
895 return ::StatusCode::FAILURE;
899 std::unique_ptr<TList> outs ((TList*)
f->Get(
"outputs"));
903 return ::StatusCode::FAILURE;
906 TIter itr(outs.get());
908 while ((
obj = itr())) {
914 ANA_MSG_ERROR (
"Encountered unexpected entry in list of outputs");
915 return ::StatusCode::FAILURE;
923 const std::string location =
".";
933 TIter itr(&bigOutputs);
935 while ((
obj = itr())) {
940 return ::StatusCode::FAILURE;
944 location +
"/" +
os->label() +
".root",
"RECREATE"};
953 auto module = std::make_unique<Detail::DirectInputModule> (
"DirectInputModule");
954 std::ifstream
infile(
"input.txt");
957 if (!getline(
infile, sLine))
break;
958 std::istringstream ssLine(sLine);
961 if (!getline(ssLine, sFile,
','))
break;
962 module->fileList.push_back(sFile);
965 if (
module->fileList.size() == 0) {
988 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]
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
::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
TFile * inputFile() const override
description: the file we are reading the current tree from guarantee: no-fail
void addModule(std::unique_ptr< Detail::Module > module)
add the given module to this worker
::StatusCode openInputFile(const std::string &inputFileUrl) override
open the given input file without processing it
bool m_algorithmsInitialized
whether the algorithms are initialized
Long64_t m_beginEvent
the first event to process
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 optXAODInput
the option to select whether our input is xAODs
::StatusCode processEvents(EventRange &eventRange) override
process the given event range
static bool fileOpenErrorFilter(int level, bool, const char *, const char *)
Error handler for file opening.
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
::StatusCode StatusCode
StatusCode definition for legacy code.
xAOD::TStore * m_tstore
the TStore structure, if we use one
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
TObject * getOutputHist(const std::string &name) const final override
get the output histogram with the given name
Long64_t inputFileNumEntries() const override
the number of events in the input file
void setJobConfig(JobConfig &&jobConfig)
set the JobConfig
std::map< std::string, Detail::OutputStreamData > m_outputs
the list of output files
static const std::string optAlgorithmTimer
a boolean flag for whether to add a timer for the algorithms
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
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
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)