ATLAS Offline Software
DirectInputModule.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 
15 #include <EventLoop/EventRange.h>
16 #include <RootCoreUtils/Assert.h>
17 
18 //
19 // method implementations
20 //
21 
22 namespace EL
23 {
24  namespace Detail
25  {
27  processInputs (ModuleData& /*data*/, IInputModuleActions& actions)
28  {
29  Long64_t toSkip = this->skipEvents.value_or (0);
30  std::optional<Long64_t> toProcess;
31  if (this->maxEvents.has_value())
32  toProcess = this->maxEvents.value();
33  for (const std::string& fileName : fileList)
34  {
35  // open the input file to inspect it
36  ANA_CHECK (actions.openInputFile (fileName));
37  ANA_MSG_DEBUG ("Opened input file: " << fileName);
38 
39  EventRange eventRange;
40  eventRange.m_url = fileName;
41  eventRange.m_endEvent = actions.inputFileNumEntries();
42 
43  if (toSkip > 0)
44  {
45  if (toSkip >= eventRange.m_endEvent)
46  {
47  toSkip -= eventRange.m_endEvent;
48  ANA_MSG_INFO ("File " << fileName << " has only " << eventRange.m_endEvent << " events, skipping it.");
49  continue;
50  }
51  eventRange.m_beginEvent = toSkip;
52  toSkip = 0u;
53  }
54 
55  if (toProcess.has_value())
56  {
57  if (eventRange.m_endEvent >= eventRange.m_beginEvent + toProcess.value())
58  {
59  eventRange.m_endEvent = eventRange.m_beginEvent + toProcess.value();
60  toProcess = 0u;
61  } else
62  {
63  toProcess.value() -= eventRange.m_endEvent - eventRange.m_beginEvent;
64  }
65  }
66  ANA_CHECK (actions.processEvents (eventRange));
67  if (toProcess.has_value() && toProcess.value() == 0u)
68  {
69  ANA_MSG_INFO ("Reached maximum number of events, stopping.");
70  break;
71  }
72  }
73  return StatusCode::SUCCESS;
74  }
75  }
76 }
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::Detail::DirectInputModule::fileList
std::vector< std::string > fileList
Definition: DirectInputModule.h:31
EL::EventRange::m_url
std::string m_url
the location of the file
Definition: EventRange.h:24
EL::Detail::DirectInputModule::skipEvents
std::optional< uint64_t > skipEvents
Definition: DirectInputModule.h:32
checkFileSG.toSkip
def toSkip(inpName)
Definition: checkFileSG.py:22
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
Trk::u
@ u
Enums for curvilinear frames.
Definition: ParamDefs.h:83
FortranAlgorithmOptions.fileName
fileName
Definition: FortranAlgorithmOptions.py:13
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
ANA_MSG_INFO
#define ANA_MSG_INFO(xmsg)
Macro printing info messages.
Definition: Control/AthToolSupport/AsgMessaging/AsgMessaging/MessageCheck.h:290
EL
This module defines the arguments passed from the BATCH driver to the BATCH worker.
Definition: AlgorithmWorkerData.h:24
xAOD::DiTauJetParameters::Detail
Detail
Definition: DiTauDefs.h:38
DirectInputModule.h
EL::Detail::DirectInputModule::processInputs
StatusCode processInputs(ModuleData &data, IInputModuleActions &actions) override
Definition: DirectInputModule.cxx:27
EL::Detail::IInputModuleActions
the actions that Module::processInputs can perform
Definition: IInputModuleActions.h:42
IInputModuleActions.h
EL::Detail::DirectInputModule::maxEvents
std::optional< uint64_t > maxEvents
Definition: DirectInputModule.h:33
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
EventRange.h
EL::EventRange::m_endEvent
Long64_t m_endEvent
the event past the last event, or eof
Definition: EventRange.h:30
ANA_MSG_DEBUG
#define ANA_MSG_DEBUG(xmsg)
Macro printing debug messages.
Definition: Control/AthToolSupport/AsgMessaging/AsgMessaging/MessageCheck.h:288