ATLAS Offline Software
Loading...
Searching...
No Matches
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/BatchJob.h>
21
22//
23// method implementations
24//
25
26namespace EL
27{
28 namespace Detail
29 {
30 StatusCode BatchInputModule ::
31 processInputs (ModuleData& data, IInputModuleActions& actions)
32 {
33 BatchSegment *segment = &data.m_batchJob->segments.at(jobId.value());
34 if (int (segment->job_id) != jobId.value())
35 {
36 ANA_MSG_ERROR ("inconsistenty in job id " << jobId.value() << " != " << segment->job_id);
37 return StatusCode::FAILURE;
38 }
39 BatchSample *sample = &data.m_batchJob->samples.at(segment->sample);
40
41 Long64_t beginFile = segment->begin_file;
42 Long64_t endFile = segment->end_file;
43 Long64_t lastFile = segment->end_file;
44 RCU_ASSERT (beginFile <= endFile);
45 Long64_t beginEvent = segment->begin_event;
46 Long64_t endEvent = segment->end_event;
47 if (endEvent > 0) endFile += 1;
48
49 for (Long64_t file = beginFile; file != endFile; ++ file)
50 {
51 RCU_ASSERT (std::size_t(file) < sample->files.size());
52 EventRange eventRange;
53 eventRange.m_url = sample->files[file];
54 eventRange.m_beginEvent = (file == beginFile ? beginEvent : 0);
55 eventRange.m_endEvent = (file == lastFile ? endEvent : EventRange::eof);
56 if (maxEvents != -1)
57 {
58 if (eventRange.m_endEvent == EventRange::eof)
59 {
60 ANA_CHECK (actions.openInputFile (eventRange.m_url));
61 eventRange.m_endEvent = actions.inputFileNumEntries();
62 }
63 eventRange.m_endEvent = std::min<std::uint64_t> (eventRange.m_endEvent, eventRange.m_beginEvent + maxEvents.value());
64 }
65
66 ANA_CHECK (actions.processEvents (eventRange));
67 }
68
69 return StatusCode::SUCCESS;
70 }
71 }
72}
#define RCU_ASSERT(x)
Definition Assert.h:222
#define ANA_MSG_ERROR(xmsg)
Macro printing error messages.
#define ANA_CHECK(EXP)
check whether the given expression was successful
char data[hepevt_bytes_allocation_ATLAS]
Definition HepEvt.cxx:11
Gaudi::Property< std::int64_t > maxEvents
Gaudi::Property< int > jobId
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.
UInt_t job_id
description: the job id of this segment
Long64_t begin_event
UInt_t sample
description: the index of the sample we are using
Long64_t begin_file
description: the starting and ending file and event number
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
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
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
TFile * file