ATLAS Offline Software
Loading...
Searching...
No Matches
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
17
18//
19// method implementations
20//
21
22namespace EL
23{
24 namespace Detail
25 {
26 StatusCode DirectInputModule ::
27 processInputs (ModuleData& /*data*/, IInputModuleActions& actions)
28 {
29 Long64_t toSkip = this->skipEvents.value ();
30 std::optional<Long64_t> toProcess;
31 if (this->maxEvents.value() != -1)
32 toProcess = this->maxEvents.value();
33 for (const std::string& fileName : fileList.value())
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}
#define ANA_MSG_INFO(xmsg)
Macro printing info messages.
#define ANA_MSG_DEBUG(xmsg)
Macro printing debug messages.
#define ANA_CHECK(EXP)
check whether the given expression was successful
Gaudi::Property< uint64_t > skipEvents
Gaudi::Property< std::vector< std::string > > fileList
Gaudi::Property< int64_t > maxEvents
the actions that Module::processInputs can perform
virtual::StatusCode processEvents(EventRange &eventRange)=0
process the given event range
virtual::StatusCode openInputFile(const std::string &inputFileUrl)=0
open the given input file without processing it
virtual Long64_t inputFileNumEntries() const =0
the number of events in the input file
This module defines the arguments passed from the BATCH driver to the BATCH worker.
::StatusCode StatusCode
StatusCode definition for legacy code.
the data the EventLoop core classes are sharing with the Module implementation
Definition ModuleData.h:64
a range of events in a given file
Definition EventRange.h:22
std::string m_url
the location of the file
Definition EventRange.h:24
Long64_t m_beginEvent
the first event to process
Definition EventRange.h:27
Long64_t m_endEvent
the event past the last event, or eof
Definition EventRange.h:30