ATLAS Offline Software
TestRandomSeqAlg.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
3 */
4 
6 #include "CLHEP/Random/RandomEngine.h"
7 #include "TestRandomSeqAlg.h"
8 TestRandomSeqAlg::TestRandomSeqAlg(const std::string& name, ISvcLocator* pSvcLocator) :
9  AthAlgorithm(name, pSvcLocator),
10  m_rndmSvc("AtRanluxGenSvc", name),
11  m_streamName("TEST"),
12  m_noOfNo(10),
13  m_pEng(nullptr)
14 {
15  declareProperty("RndmSvc", m_rndmSvc, "the IAtRndmGenSvc we want to test (default AtRanluxGenSvc");
16  declareProperty("StreamName", m_streamName, " random number stream to use (default TEST");
17  declareProperty("NoOfNo", m_noOfNo, "the number of random numbers to shoot and print per event (default 10)");
18 }
19 
22  msg() << MSG::INFO << " Initializing " << endmsg;
23  return ((m_rndmSvc.retrieve()).isSuccess() &&
24  (m_pEng = m_rndmSvc->GetEngine(m_streamName.value()))) ?
25  StatusCode::SUCCESS :
26  StatusCode::FAILURE;
27 }
28 
31  msg() << MSG::DEBUG << "execute: random sequence: ";
32  for (int i=0; i<m_noOfNo.value(); ++i) msg() << m_pEng->flat() << " ";
33  msg() << endmsg;
34  return StatusCode::SUCCESS;
35 }
AthCommonDataStore< AthCommonMsg< Algorithm > >::declareProperty
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T > &t)
Definition: AthCommonDataStore.h:145
TestRandomSeqAlg::TestRandomSeqAlg
TestRandomSeqAlg(const std::string &name, ISvcLocator *pSvcLocator)
Definition: TestRandomSeqAlg.cxx:8
TestRandomSeqAlg::m_rndmSvc
ServiceHandle< IAtRndmGenSvc > m_rndmSvc
handle to the IAtRndmGenSvc we want to test
Definition: TestRandomSeqAlg.h:35
TestRandomSeqAlg::initialize
virtual StatusCode initialize()
Definition: TestRandomSeqAlg.cxx:21
TestRandomSeqAlg::m_streamName
StringProperty m_streamName
Definition: TestRandomSeqAlg.h:36
lumiFormat.i
int i
Definition: lumiFormat.py:92
endmsg
#define endmsg
Definition: AnalysisConfig_Ntuple.cxx:63
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
AthAlgorithm
Definition: AthAlgorithm.h:47
IAtRndmGenSvc.h
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:195
TestRandomSeqAlg.h
TestRandomSeqAlg::m_noOfNo
IntegerProperty m_noOfNo
number of random numbers to shoot (and print)
Definition: TestRandomSeqAlg.h:38
TestRandomSeqAlg::execute
virtual StatusCode execute()
Definition: TestRandomSeqAlg.cxx:30
DEBUG
#define DEBUG
Definition: page_access.h:11
AthCommonMsg< Algorithm >::msg
MsgStream & msg() const
Definition: AthCommonMsg.h:24
TestRandomSeqAlg::m_pEng
CLHEP::HepRandomEngine * m_pEng
Definition: TestRandomSeqAlg.h:39