ATLAS Offline Software
BatchInputModule.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
3 */
4 
6 
7 
8 //
9 // includes
10 //
11 
13 
14 #include <EventLoop/BatchSample.h>
15 #include <EventLoop/BatchSegment.h>
16 #include <EventLoop/EventRange.h>
18 #include <RootCoreUtils/Assert.h>
19 
20 //
21 // method implementations
22 //
23 
24 namespace EL
25 {
26  namespace Detail
27  {
29  processInputs (ModuleData& /*data*/, IInputModuleActions& actions)
30  {
31  Long64_t beginFile = segment->begin_file;
32  Long64_t endFile = segment->end_file;
33  Long64_t lastFile = segment->end_file;
34  RCU_ASSERT (beginFile <= endFile);
35  Long64_t beginEvent = segment->begin_event;
36  Long64_t endEvent = segment->end_event;
37  if (endEvent > 0) endFile += 1;
38 
39  for (Long64_t file = beginFile; file != endFile; ++ file)
40  {
41  RCU_ASSERT (std::size_t(file) < sample->files.size());
42  EventRange eventRange;
43  eventRange.m_url = sample->files[file];
44  eventRange.m_beginEvent = (file == beginFile ? beginEvent : 0);
45  eventRange.m_endEvent = (file == lastFile ? endEvent : EventRange::eof);
46  if (maxEvents.has_value())
47  {
48  if (eventRange.m_endEvent == EventRange::eof)
49  {
50  ANA_CHECK (actions.openInputFile (eventRange.m_url));
51  eventRange.m_endEvent = actions.inputFileNumEntries();
52  }
53  eventRange.m_endEvent = std::min<std::uint64_t> (eventRange.m_endEvent, eventRange.m_beginEvent + maxEvents.value());
54  }
55 
56  ANA_CHECK (actions.processEvents (eventRange));
57  }
58 
59  return StatusCode::SUCCESS;
60  }
61  }
62 }
EL::Detail::BatchInputModule::sample
BatchSample * sample
Definition: BatchInputModule.h:33
BatchInputModule.h
EL::Detail::BatchInputModule::maxEvents
std::optional< uint64_t > maxEvents
Definition: BatchInputModule.h:35
EL::Detail::IInputModuleActions::processEvents
virtual ::StatusCode processEvents(EventRange &eventRange)=0
process the given event range
EL::Detail::ModuleData
the data the EventLoop core classes are sharing with the Module implementation
Definition: ModuleData.h:64
EL::EventRange::m_url
std::string m_url
the location of the file
Definition: EventRange.h:24
EL::BatchSegment::begin_event
Long64_t begin_event
Definition: BatchSegment.h:76
EL::EventRange::m_beginEvent
Long64_t m_beginEvent
the first event to process
Definition: EventRange.h:27
ANA_CHECK
#define ANA_CHECK(EXP)
check whether the given expression was successful
Definition: Control/AthToolSupport/AsgMessaging/AsgMessaging/MessageCheck.h:324
Assert.h
EL::Detail::IInputModuleActions::inputFileNumEntries
virtual Long64_t inputFileNumEntries() const =0
the number of events in the input file
BatchSegment.h
EL::Detail::BatchInputModule::processInputs
StatusCode processInputs(ModuleData &data, IInputModuleActions &actions) override
Definition: BatchInputModule.cxx:29
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
BatchSample.h
file
TFile * file
Definition: tile_monitor.h:29
EL
This module defines the arguments passed from the BATCH driver to the BATCH worker.
Definition: AlgorithmWorkerData.h:24
EL::EventRange::eof
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
EL::BatchSegment::begin_file
Long64_t begin_file
description: the starting and ending file and event number
Definition: BatchSegment.h:76
EL::BatchSample::files
std::vector< std::string > files
description: the list of files we are reading
Definition: BatchSample.h:61
EL::BatchSegment::end_file
Long64_t end_file
Definition: BatchSegment.h:77
xAOD::DiTauJetParameters::Detail
Detail
Definition: DiTauDefs.h:38
EL::Detail::BatchInputModule::segment
BatchSegment * segment
Definition: BatchInputModule.h:34
EL::Detail::IInputModuleActions
the actions that Module::processInputs can perform
Definition: IInputModuleActions.h:42
IInputModuleActions.h
RCU_ASSERT
#define RCU_ASSERT(x)
Definition: Assert.h:222
EL::EventRange
a range of events in a given file
Definition: EventRange.h:22
EL::Detail::IInputModuleActions::openInputFile
virtual ::StatusCode openInputFile(const std::string &inputFileUrl)=0
open the given input file without processing it
EL::BatchSegment::end_event
Long64_t end_event
Definition: BatchSegment.h:77
EventRange.h
EL::EventRange::m_endEvent
Long64_t m_endEvent
the event past the last event, or eof
Definition: EventRange.h:30