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-2026 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
ATH_MSG_WARNING
(
"Could not locate filter {}/{}"
,
66
theFilter.type(), theFilter.name());
67
}
68
return
pFilter;
69
}
70
bool
71
MultipleEventLoopMgr::doNextPass
() {
72
INextPassFilter
* pFilter(
nextPassFilter
());
73
//if no tool found or tool not an INextPassFilter we return false
74
//and terminate the multiple pass iteration
75
return
(
nullptr
!= pFilter && pFilter->
doNextPass
() );
76
}
77
StatusCode
78
MultipleEventLoopMgr::reInitList
() {
79
StatusCode
sc
;
80
for
(
const
std::string&
name
:
m_toBeReInitializedNames
.value()) {
81
SmartIF<IService>& svc = serviceLocator()->service(
name
,
/*createIf*/
false
);
82
if
(svc)
sc
= svc->reinitialize();
83
if
(!
sc
.isSuccess())
return
sc
;
84
}
85
return
sc
;
86
}
87
88
StatusCode
89
MultipleEventLoopMgr::nextEvent
(
int
maxevt) {
90
StatusCode
sc
;
91
do
{
92
ATH_MSG_INFO
(
"nextEvent: starting pass #{}"
,
m_passDone
);
93
// Reset run number to assure BeginRun each rewind
94
m_currentRun
= 0;
95
sc
=
AthenaEventLoopMgr::nextEvent
(maxevt);
96
ATH_MSG_INFO
(
"nextEvent: finished pass #{}"
,
m_passDone
);
97
m_passDone
++;
98
}
while
(
sc
.isSuccess() &&
//pass ok
99
doNextPass
() &&
//another one?
100
(
sc
=
reInitList
()).isSuccess() &&
//then reinit svcs
101
(
sc
=
seek
(0)).isSuccess() );
//and rewind selector
102
return
sc
;
103
}
104
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x,...)
Definition
AthMsgStreamMacros.h:46
ATH_MSG_INFO
#define ATH_MSG_INFO(x,...)
Definition
AthMsgStreamMacros.h:45
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:849
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:58
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:713
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:71
MultipleEventLoopMgr::reInitList
StatusCode reInitList()
called at each end of pass.
Definition
MultipleEventLoopMgr.cxx:78
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:89
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