ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
Control
AthenaExamples
AthExHive
src
HiveAlgBase.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 "
HiveAlgBase.h
"
6
#include <thread>
7
8
#include "
AthenaKernel/RNGWrapper.h
"
9
#include "CLHEP/Random/RandomEngine.h"
10
#include "CLHEP/Random/RandFlat.h"
11
12
HiveAlgBase::HiveAlgBase
(
const
std::string& name,
13
ISvcLocator* pSvcLocator ) :
14
::
AthReentrantAlgorithm
( name, pSvcLocator )
15
{}
16
17
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
18
19
HiveAlgBase::~HiveAlgBase
() =
default
;
20
21
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
22
23
StatusCode
HiveAlgBase::initialize
() {
24
ATH_MSG_DEBUG
(
"initialize "
<< name() <<
" for "
<<
this
);
25
26
// retrieve the CPUCrunchSvc if Alg chooses to Crunch instead of Sleep
27
if
(
m_doCrunch
) {
28
ATH_CHECK
(
m_ccs
.retrieve() );
29
}
30
31
ATH_CHECK
(
m_hes
.retrieve() );
32
ATH_CHECK
(
m_rngSvc
.retrieve() );
33
34
return
StatusCode::SUCCESS;
35
}
36
37
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
38
39
unsigned
int
40
HiveAlgBase::sleep
(
const
EventContext& ctx)
const
{
41
42
ATHRNG::RNGWrapper
* rngWrapper =
m_rngSvc
->getEngine(
this
);
43
rngWrapper->
setSeed
( name(), ctx );
44
45
// add a bit of variability to the sleep/crunch time
46
const
unsigned
int
sleep
= CLHEP::RandFlat::shoot(rngWrapper->
getEngine
(ctx), 0,
m_time
);
47
48
if
(
m_doCrunch
) {
49
ATH_MSG_INFO
(
" crunch for: "
<<
sleep
<<
" ms"
);
50
m_ccs
->crunch_for( std::chrono::milliseconds(
sleep
) );
51
}
else
{
52
ATH_MSG_INFO
(
" sleep for: "
<<
sleep
<<
" ms"
);
53
std::this_thread::sleep_for(std::chrono::milliseconds(
sleep
));
54
}
55
56
// accumulate data in the HiveExSvc
57
m_hes
->add( ctx, name(),
sleep
);
58
59
return
sleep
;
60
61
}
ATH_CHECK
#define ATH_CHECK
Evaluate an expression and check for errors.
Definition
AthCheckMacros.h:40
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition
AthMsgStreamMacros.h:31
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition
AthMsgStreamMacros.h:29
HiveAlgBase.h
Base class for AthExHive example Algs to provide functionality to sleep for a certain amount of time,...
RNGWrapper.h
ATHRNG::RNGWrapper
A wrapper class for event-slot-local random engines.
Definition
RNGWrapper.h:56
ATHRNG::RNGWrapper::setSeed
void setSeed(const std::string &algName, const EventContext &ctx)
Set the random seed using a string (e.g.
Definition
RNGWrapper.h:154
ATHRNG::RNGWrapper::getEngine
CLHEP::HepRandomEngine * getEngine(const EventContext &ctx) const
Retrieve the random engine corresponding to the provided EventContext.
Definition
RNGWrapper.h:108
AthReentrantAlgorithm
An algorithm that can be simultaneously executed in multiple threads.
Definition
AthReentrantAlgorithm.h:74
HiveAlgBase::m_time
Gaudi::Property< unsigned int > m_time
Definition
HiveAlgBase.h:54
HiveAlgBase::HiveAlgBase
HiveAlgBase(const std::string &name, ISvcLocator *pSvcLocator)
Definition
HiveAlgBase.cxx:12
HiveAlgBase::sleep
unsigned int sleep(const EventContext &ctx) const
Definition
HiveAlgBase.cxx:40
HiveAlgBase::m_ccs
ServiceHandle< ICPUCrunchSvc > m_ccs
Definition
HiveAlgBase.h:47
HiveAlgBase::m_rngSvc
ServiceHandle< IAthRNGSvc > m_rngSvc
Definition
HiveAlgBase.h:50
HiveAlgBase::m_hes
ServiceHandle< IHiveExSvc > m_hes
Definition
HiveAlgBase.h:44
HiveAlgBase::initialize
virtual StatusCode initialize() override
Definition
HiveAlgBase.cxx:23
HiveAlgBase::~HiveAlgBase
virtual ~HiveAlgBase()
HiveAlgBase::m_doCrunch
Gaudi::Property< bool > m_doCrunch
Definition
HiveAlgBase.h:55
Generated on
for ATLAS Offline Software by
1.17.0