ATLAS Offline Software
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 
5 #include "TgcDigtJitterTestAlg.h"
6 
9 #include "CLHEP/Random/RandomEngine.h"
10 #include "CLHEP/Random/RandFlat.h"
11 
12 
13 // Constructor
14 TgcDigtJitterTestAlg::TgcDigtJitterTestAlg(const std::string& name, ISvcLocator* pSvcLocator) :
15  AthAlgorithm(name, pSvcLocator) {}
16 
17 // Destructor
19 
20 // Initialize
22  ATH_MSG_INFO("Calling 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 }
ATHRNG::RNGWrapper::setSeed
void setSeed(const std::string &algName, const EventContext &ctx)
Set the random seed using a string (e.g.
Definition: RNGWrapper.h:169
TgcDigtJitterTestAlg::m_readKey
SG::ReadCondHandleKey< TgcDigitJitterData > m_readKey
Definition: TgcDigtJitterTestAlg.h:29
TgcDigtJitterTestAlg::execute
virtual StatusCode execute() override
Definition: TgcDigtJitterTestAlg.cxx:29
SG::ReadCondHandle
Definition: ReadCondHandle.h:44
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
TgcDigtJitterTestAlg::m_testJitters
Gaudi::Property< unsigned int > m_testJitters
Definition: TgcDigtJitterTestAlg.h:33
Amg::toString
std::string toString(const Translation3D &translation, int precision=4)
GeoPrimitvesToStringConverter.
Definition: GeoPrimitivesToStringConverter.h:40
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
ATH_MSG_ALWAYS
#define ATH_MSG_ALWAYS(x)
Definition: AthMsgStreamMacros.h:35
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
TgcDigtJitterTestAlg.h
AthAlgorithm
Definition: AthAlgorithm.h:47
beamspotman.dir
string dir
Definition: beamspotman.py:623
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:221
ATHRNG::RNGWrapper
A wrapper class for event-slot-local random engines.
Definition: RNGWrapper.h:56
TgcDigtJitterTestAlg::TgcDigtJitterTestAlg
TgcDigtJitterTestAlg(const std::string &name, ISvcLocator *pSvcLocator)
Definition: TgcDigtJitterTestAlg.cxx:14
SG::CondHandleKey::initialize
StatusCode initialize(bool used=true)
Amg::Vector3D
Eigen::Matrix< double, 3, 1 > Vector3D
Definition: GeoPrimitives.h:47
TgcDigtJitterTestAlg::m_rndmSvc
ServiceHandle< IAthRNGSvc > m_rndmSvc
Definition: TgcDigtJitterTestAlg.h:31
ATHRNG::RNGWrapper::getEngine
CLHEP::HepRandomEngine * getEngine(const EventContext &ctx) const
Retrieve the random engine corresponding to the provided EventContext.
Definition: RNGWrapper.h:134
RNGWrapper.h
TgcDigtJitterTestAlg::initialize
virtual StatusCode initialize() override
Definition: TgcDigtJitterTestAlg.cxx:21
GeoPrimitivesToStringConverter.h
TgcDigtJitterTestAlg::~TgcDigtJitterTestAlg
virtual ~TgcDigtJitterTestAlg()