ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
PhysicsAnalysis
D3PDTools
EventLoop
Root
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
12
#include <
EventLoop/BatchInputModule.h
>
13
14
#include <
EventLoop/BatchJob.h
>
15
#include <
EventLoop/BatchSample.h
>
16
#include <
EventLoop/BatchSegment.h
>
17
#include <
EventLoop/EventRange.h
>
18
#include <
EventLoop/IInputModuleActions.h
>
19
#include <
EventLoop/ModuleData.h
>
20
#include <
RootCoreUtils/Assert.h
>
21
22
//
23
// method implementations
24
//
25
26
namespace
EL
27
{
28
namespace
Detail
29
{
30
StatusCode
BatchInputModule ::
31
processInputs (
ModuleData
& data,
IInputModuleActions
& actions)
32
{
33
if
(data.m_batchJob ==
nullptr
)
34
{
35
ANA_MSG_ERROR
(
"no batch job configured for the input module"
);
36
return
StatusCode::FAILURE;
37
}
38
if
(
jobId
.value() < 0)
39
{
40
ANA_MSG_ERROR
(
"no valid job id configured: "
<<
jobId
.value());
41
return
StatusCode::FAILURE;
42
}
43
if
(std::size_t (
jobId
.value()) >= data.m_batchJob->segments.size())
44
{
45
ANA_MSG_ERROR
(
"job id "
<<
jobId
.value() <<
" out of range, only "
46
<< data.m_batchJob->segments.size() <<
" segments"
);
47
return
StatusCode::FAILURE;
48
}
49
50
BatchSegment
*segment = &data.m_batchJob->segments.at(
jobId
.value());
51
if
(
int
(segment->
job_id
) !=
jobId
.value())
52
{
53
ANA_MSG_ERROR
(
"inconsistenty in job id "
<<
jobId
.value() <<
" != "
<< segment->
job_id
);
54
return
StatusCode::FAILURE;
55
}
56
BatchSample
*sample = &data.m_batchJob->samples.at(segment->
sample
);
57
58
Long64_t beginFile = segment->
begin_file
;
59
Long64_t endFile = segment->
end_file
;
60
Long64_t lastFile = segment->
end_file
;
61
RCU_ASSERT
(beginFile <= endFile);
62
Long64_t beginEvent = segment->
begin_event
;
63
Long64_t endEvent = segment->
end_event
;
64
if
(endEvent > 0) endFile += 1;
65
66
// the number of events still to be processed across the whole
67
// segment, so that maxEvents is honoured for the segment as a whole
68
// rather than being reapplied to every file
69
std::optional<std::int64_t> toProcess;
70
if
(
maxEvents
!= -1)
71
toProcess =
maxEvents
.value();
72
73
for
(Long64_t
file
= beginFile;
file
!= endFile; ++
file
)
74
{
75
RCU_ASSERT
(std::size_t(
file
) < sample->files.size());
76
EventRange
eventRange;
77
eventRange.
m_url
= sample->files[
file
];
78
eventRange.
m_beginEvent
= (
file
== beginFile ? beginEvent : 0);
79
eventRange.
m_endEvent
= (
file
== lastFile ? endEvent :
EventRange::eof
);
80
if
(toProcess.has_value())
81
{
82
if
(eventRange.
m_endEvent
==
EventRange::eof
)
83
{
84
ANA_CHECK
(actions.
openInputFile
(eventRange.
m_url
));
85
eventRange.
m_endEvent
= actions.
inputFileNumEntries
();
86
}
87
if
(eventRange.
m_endEvent
> eventRange.
m_beginEvent
+ toProcess.value())
88
eventRange.
m_endEvent
= eventRange.
m_beginEvent
+ toProcess.value();
89
toProcess.value() -= eventRange.
m_endEvent
- eventRange.
m_beginEvent
;
90
}
91
92
ANA_CHECK
(actions.
processEvents
(eventRange));
93
94
if
(toProcess.has_value() && toProcess.value() == 0)
95
{
96
ANA_MSG_INFO
(
"Reached maximum number of events, stopping."
);
97
break
;
98
}
99
}
100
101
return
StatusCode::SUCCESS;
102
}
103
}
104
}
Assert.h
RCU_ASSERT
#define RCU_ASSERT(x)
Definition
Assert.h:210
BatchInputModule.h
BatchJob.h
BatchSample.h
BatchSegment.h
ANA_MSG_INFO
#define ANA_MSG_INFO(xmsg)
Macro printing info messages.
Definition
Control/AthToolSupport/AsgMessaging/AsgMessaging/MessageCheck.h:288
ANA_MSG_ERROR
#define ANA_MSG_ERROR(xmsg)
Macro printing error messages.
Definition
Control/AthToolSupport/AsgMessaging/AsgMessaging/MessageCheck.h:292
ANA_CHECK
#define ANA_CHECK(EXP)
check whether the given expression was successful
Definition
Control/AthToolSupport/AsgMessaging/AsgMessaging/MessageCheck.h:322
EventRange.h
IInputModuleActions.h
ModuleData.h
EL::Detail::BatchInputModule::maxEvents
Gaudi::Property< std::int64_t > maxEvents
Definition
BatchInputModule.h:36
EL::Detail::BatchInputModule::jobId
Gaudi::Property< int > jobId
Definition
BatchInputModule.h:34
EL::Detail::IInputModuleActions
the actions that Module::processInputs can perform
Definition
IInputModuleActions.h:42
EL::Detail::IInputModuleActions::processEvents
virtual::StatusCode processEvents(EventRange &eventRange)=0
process the given event range
EL::Detail::IInputModuleActions::openInputFile
virtual::StatusCode openInputFile(const std::string &inputFileUrl)=0
open the given input file without processing it
EL::Detail::IInputModuleActions::inputFileNumEntries
virtual Long64_t inputFileNumEntries() const =0
the number of events in the input file
EL::Detail
Definition
AsgComponentFactories.h:20
EL
This module defines the arguments passed from the BATCH driver to the BATCH worker.
Definition
AsgComponentFactories.h:16
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition
PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
EL::BatchSample
Definition
BatchSample.h:23
EL::BatchSegment
Definition
BatchSegment.h:22
EL::BatchSegment::job_id
UInt_t job_id
description: the job id of this segment
Definition
BatchSegment.h:62
EL::BatchSegment::begin_event
Long64_t begin_event
Definition
BatchSegment.h:67
EL::BatchSegment::sample
UInt_t sample
description: the index of the sample we are using
Definition
BatchSegment.h:57
EL::BatchSegment::begin_file
Long64_t begin_file
description: the starting and ending file and event number
Definition
BatchSegment.h:67
EL::BatchSegment::end_file
Long64_t end_file
Definition
BatchSegment.h:68
EL::BatchSegment::end_event
Long64_t end_event
Definition
BatchSegment.h:68
EL::Detail::ModuleData
the data the EventLoop core classes are sharing with the Module implementation
Definition
ModuleData.h:64
EL::EventRange
a range of events in a given file
Definition
EventRange.h:22
EL::EventRange::m_url
std::string m_url
the location of the file
Definition
EventRange.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::EventRange::m_beginEvent
Long64_t m_beginEvent
the first event to process
Definition
EventRange.h:27
EL::EventRange::m_endEvent
Long64_t m_endEvent
the event past the last event, or eof
Definition
EventRange.h:30
file
TFile * file
Definition
tile_monitor.h:29
Generated on
for ATLAS Offline Software by
1.17.0