ATLAS Offline Software
Loading...
Searching...
No Matches
TgcDigtJitterTestAlg.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
9#include "CLHEP/Random/RandomEngine.h"
10#include "CLHEP/Random/RandFlat.h"
11
12
13// Constructor
14TgcDigtJitterTestAlg::TgcDigtJitterTestAlg(const std::string& name, ISvcLocator* pSvcLocator) :
15 AthAlgorithm(name, pSvcLocator) {}
16
17// Destructor
19
20// Initialize
22 ATH_MSG_INFO("Calling initialize");
23 ATH_CHECK(m_readKey.initialize());
24 ATH_CHECK(m_rndmSvc.retrieve());
25 return StatusCode::SUCCESS;
26}
27
28// Execute
30 const EventContext& ctx{Gaudi::Hive::currentContext()};
31 ATH_MSG_INFO("Calling execute");
33 if (!readHandle.isValid()) {
34 ATH_MSG_ERROR("Null pointer to the read conditions object");
35 return StatusCode::FAILURE;
36 }
37 ATHRNG::RNGWrapper* rngWrapper = m_rndmSvc->getEngine(this);
38 rngWrapper->setSeed(name(), ctx);
39 CLHEP::HepRandomEngine* rndmEngine = rngWrapper->getEngine(ctx);
40 for (unsigned int trial = 0; trial < m_testJitters; ++trial){
42 const Amg::Vector3D dir{CLHEP::RandFlat::shoot(rndmEngine,-1., 1.) * Amg::Vector3D::UnitX()+
43 CLHEP::RandFlat::shoot(rndmEngine,-1., 1.) *Amg::Vector3D::UnitZ()};
44 const double jitter = readHandle->drawJitter(dir, rndmEngine);
45 ATH_MSG_ALWAYS("Direction "<<Amg::toString(dir,2)<<" drawn jitter: "<<jitter);
46 }
47
48 return StatusCode::SUCCESS;
49}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_ERROR(x)
#define ATH_MSG_INFO(x)
#define ATH_MSG_ALWAYS(x)
A wrapper class for event-slot-local random engines.
Definition RNGWrapper.h:56
void setSeed(const std::string &algName, const EventContext &ctx)
Set the random seed using a string (e.g.
Definition RNGWrapper.h:169
CLHEP::HepRandomEngine * getEngine(const EventContext &ctx) const
Retrieve the random engine corresponding to the provided EventContext.
Definition RNGWrapper.h:134
AthAlgorithm(const std::string &name, ISvcLocator *pSvcLocator)
Constructor with parameters:
TgcDigtJitterTestAlg(const std::string &name, ISvcLocator *pSvcLocator)
Gaudi::Property< unsigned int > m_testJitters
ServiceHandle< IAthRNGSvc > m_rndmSvc
SG::ReadCondHandleKey< TgcDigitJitterData > m_readKey
virtual StatusCode initialize() override
virtual ~TgcDigtJitterTestAlg()
virtual StatusCode execute() override
std::string toString(const Translation3D &translation, int precision=4)
GeoPrimitvesToStringConverter.
Eigen::Matrix< double, 3, 1 > Vector3D