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
29StatusCode TgcDigtJitterTestAlg::execute(const EventContext& ctx) {
30 ATH_MSG_INFO("Calling execute");
32 if (!readHandle.isValid()) {
33 ATH_MSG_ERROR("Null pointer to the read conditions object");
34 return StatusCode::FAILURE;
35 }
36 ATHRNG::RNGWrapper* rngWrapper = m_rndmSvc->getEngine(this);
37 rngWrapper->setSeed(name(), ctx);
38 CLHEP::HepRandomEngine* rndmEngine = rngWrapper->getEngine(ctx);
39 for (unsigned int trial = 0; trial < m_testJitters; ++trial){
41 const Amg::Vector3D dir{CLHEP::RandFlat::shoot(rndmEngine,-1., 1.) * Amg::Vector3D::UnitX()+
42 CLHEP::RandFlat::shoot(rndmEngine,-1., 1.) *Amg::Vector3D::UnitZ()};
43 const double jitter = readHandle->drawJitter(dir, rndmEngine);
44 ATH_MSG_ALWAYS("Direction "<<Amg::toString(dir,2)<<" drawn jitter: "<<jitter);
45 }
46
47 return StatusCode::SUCCESS;
48}
#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:154
CLHEP::HepRandomEngine * getEngine(const EventContext &ctx) const
Retrieve the random engine corresponding to the provided EventContext.
Definition RNGWrapper.h:108
AthAlgorithm(const std::string &name, ISvcLocator *pSvcLocator)
Constructor.
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(const EventContext &ctx) override
Execute method.
std::string toString(const Translation3D &translation, int precision=4)
GeoPrimitvesToStringConverter.
Eigen::Matrix< double, 3, 1 > Vector3D