ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
Control
AthenaServices
src
MultipleEventLoopMgr.cxx
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3
*/
4
5
#include <string>
6
#include <vector>
7
#include "GaudiKernel/GaudiException.h"
8
#include "GaudiKernel/TypeNameString.h"
9
#include "GaudiKernel/IAlgorithm.h"
10
#include "GaudiKernel/IAlgTool.h"
11
#include "GaudiKernel/IAlgManager.h"
12
#include "GaudiKernel/IToolSvc.h"
13
#include "GaudiKernel/MsgStream.h"
14
#include "GaudiKernel/SmartIF.h"
15
#include "
AthenaKernel/INextPassFilter.h
"
16
#include "
MultipleEventLoopMgr.h
"
17
18
using
std::string;
19
using
std::vector;
20
21
MultipleEventLoopMgr::MultipleEventLoopMgr
(
const
std::string& nam,
22
ISvcLocator* svcLoc) :
23
AthenaEventLoopMgr
(nam, svcLoc),
24
m_pToolSvc
(
"ToolSvc"
, nam ),
25
m_pAlgMgr
(nullptr),
m_passDone
(0)
26
{
27
declareProperty(
"NextPassFilter"
,
m_nextPassFilterName
);
28
declareProperty(
"ToBeReinitialized"
,
m_toBeReInitializedNames
);
29
}
30
31
MultipleEventLoopMgr::~MultipleEventLoopMgr
() {
32
if
(
m_pAlgMgr
)
m_pAlgMgr
->release();
33
}
34
35
IAlgManager*
36
MultipleEventLoopMgr::algMgr
() {
37
if
(
nullptr
==
m_pAlgMgr
) {
38
SmartIF<IAlgManager> algMan(serviceLocator());
39
if
( algMan.isValid() )
m_pAlgMgr
=&*algMan;
40
else
throw
GaudiException(
"IAlgManager not found"
,
name
(), StatusCode::FAILURE);
41
m_pAlgMgr
->addRef();
42
}
43
return
m_pAlgMgr
;
44
}
45
46
INextPassFilter
*
47
MultipleEventLoopMgr::nextPassFilter
() {
48
INextPassFilter
* pFilter(
nullptr
);
49
const
string
& filterName(
m_nextPassFilterName
.value());
50
if
(!(filterName.empty())) {
51
Gaudi::Utils::TypeNameString theFilter(filterName);
52
IAlgTool* pHoldTool(
nullptr
);
53
if
( (
m_pToolSvc
->retrieveTool(theFilter.type(), theFilter.name(),
54
pHoldTool)).isSuccess() ) {
55
pFilter=
dynamic_cast<
INextPassFilter
*
>
(pHoldTool);
56
}
57
58
SmartIF<IAlgorithm>& pHoldAlg =
algMgr
()->algorithm(theFilter,
/*createIf*/
false
);
59
if
(
nullptr
== pFilter && pHoldAlg) {
60
pFilter=
dynamic_cast<
INextPassFilter
*
>
(pHoldAlg.get());
61
}
62
}
63
if
(
nullptr
== pFilter) {
64
Gaudi::Utils::TypeNameString theFilter(filterName);
65
MsgStream log(msgSvc(),
name
());
66
log << MSG::WARNING <<
"Could not locate filter "
67
<< theFilter.type() <<
'/'
<< theFilter.name() <<
endmsg
;
68
}
69
return
pFilter;
70
}
71
bool
72
MultipleEventLoopMgr::doNextPass
() {
73
INextPassFilter
* pFilter(
nextPassFilter
());
74
//if no tool found or tool not an INextPassFilter we return false
75
//and terminate the multiple pass iteration
76
return
(
nullptr
!= pFilter && pFilter->
doNextPass
() );
77
}
78
StatusCode
79
MultipleEventLoopMgr::reInitList
() {
80
StatusCode
sc
;
81
for
(
const
std::string&
name
:
m_toBeReInitializedNames
.value()) {
82
SmartIF<IService>& svc = serviceLocator()->service(
name
,
/*createIf*/
false
);
83
if
(svc)
sc
= svc->reinitialize();
84
if
(!
sc
.isSuccess())
return
sc
;
85
}
86
return
sc
;
87
}
88
89
StatusCode
90
MultipleEventLoopMgr::nextEvent
(
int
maxevt) {
91
StatusCode
sc
;
92
do
{
93
MsgStream log(msgSvc(),
name
());
94
log << MSG::INFO <<
"nextEvent: starting pass #"
<<
m_passDone
<<
endmsg
;
95
// Reset run number to assure BeginRun each rewind
96
m_currentRun
= 0;
97
sc
=
AthenaEventLoopMgr::nextEvent
(maxevt);
98
log << MSG::INFO <<
"nextEvent: finished pass #"
<<
m_passDone
<<
endmsg
;
99
m_passDone
++;
100
}
while
(
sc
.isSuccess() &&
//pass ok
101
doNextPass
() &&
//another one?
102
(
sc
=
reInitList
()).isSuccess() &&
//then reinit svcs
103
(
sc
=
seek
(0)).isSuccess() );
//and rewind selector
104
return
sc
;
105
}
106
endmsg
#define endmsg
Definition
AnalysisConfig_Ntuple.cxx:54
INextPassFilter.h
sc
static Double_t sc
Definition
LArPhysWaveHECTool.cxx:37
MultipleEventLoopMgr.h
A specialize AthenaEventLoopMgr that allows multiple passes over an event collection.
AthenaEventLoopMgr::seek
virtual StatusCode seek(int evt) override
Seek to a given event.
Definition
AthenaEventLoopMgr.cxx:859
AthenaEventLoopMgr::name
virtual const std::string & name() const override
Definition
AthenaEventLoopMgr.h:188
AthenaEventLoopMgr::AthenaEventLoopMgr
AthenaEventLoopMgr(const std::string &nam, ISvcLocator *svcLoc)
Standard Constructor.
Definition
AthenaEventLoopMgr.cxx:57
AthenaEventLoopMgr::m_currentRun
number_type m_currentRun
current run number
Definition
AthenaEventLoopMgr.h:102
AthenaEventLoopMgr::nextEvent
virtual StatusCode nextEvent(int maxevt) override
implementation of IAppMgrUI::nextEvent. maxevt==0 returns immediately
Definition
AthenaEventLoopMgr.cxx:723
INextPassFilter
interface to a tool (typically) that decides whether the event loop mgr (typically) need to do anothe...
Definition
INextPassFilter.h:15
INextPassFilter::doNextPass
virtual bool doNextPass()=0
decide whether we need another iteration
MultipleEventLoopMgr::MultipleEventLoopMgr
MultipleEventLoopMgr()
implementation of IEventProcessor::executeEvent(void* par)
MultipleEventLoopMgr::doNextPass
bool doNextPass()
called at end of pass. Calls nextPassFilter
Definition
MultipleEventLoopMgr.cxx:72
MultipleEventLoopMgr::reInitList
StatusCode reInitList()
called at each end of pass.
Definition
MultipleEventLoopMgr.cxx:79
MultipleEventLoopMgr::algMgr
IAlgManager * algMgr()
Definition
MultipleEventLoopMgr.cxx:36
MultipleEventLoopMgr::m_nextPassFilterName
StringProperty m_nextPassFilterName
the name of the INextPassFilter object queried at end of pass
Definition
MultipleEventLoopMgr.h:76
MultipleEventLoopMgr::nextEvent
virtual StatusCode nextEvent(int maxevt)
Dump out histograms as needed.
Definition
MultipleEventLoopMgr.cxx:90
MultipleEventLoopMgr::m_pToolSvc
ServiceHandle< IToolSvc > m_pToolSvc
handle to the ToolSvc
Definition
MultipleEventLoopMgr.h:94
MultipleEventLoopMgr::m_toBeReInitializedNames
StringArrayProperty m_toBeReInitializedNames
a list of services to be reinit at the end of the pass
Definition
MultipleEventLoopMgr.h:79
MultipleEventLoopMgr::m_pAlgMgr
IAlgManager * m_pAlgMgr
Definition
MultipleEventLoopMgr.h:97
MultipleEventLoopMgr::~MultipleEventLoopMgr
virtual ~MultipleEventLoopMgr()
Standard Destructor.
Definition
MultipleEventLoopMgr.cxx:31
MultipleEventLoopMgr::m_passDone
unsigned int m_passDone
number of passes already completed
Definition
MultipleEventLoopMgr.h:99
MultipleEventLoopMgr::nextPassFilter
INextPassFilter * nextPassFilter()
Locate filter.
Definition
MultipleEventLoopMgr.cxx:47
Generated on
for ATLAS Offline Software by
1.17.0