ATLAS Offline Software
Loading...
Searching...
No Matches
RandomRoISeedTool.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2020-2023 CERN for the benefit of the ATLAS collaboration
3*/
4
6// Implementation file for class RandomRoISeedTool
8// (c) ATLAS Detector software
10
11
14
15#include "TVector2.h"
16#include "CLHEP/Random/RandGauss.h"
17
18#include <map>
19
20
22// Constructor
24
26(const std::string& t,const std::string& n,const IInterface* p)
27 : base_class(t,n,p)
28{
29}
30
32// Initialization
34
36{
37 StatusCode sc = AlgTool::initialize();
38
39 ATH_CHECK( m_beamSpotKey.initialize() );
40
41 return sc;
42}
43
45// Compute RoI
47
48std::vector<InDet::IZWindowRoISeedTool::ZWindow> InDet::RandomRoISeedTool::getRoIs(const EventContext& ctx) const
49{
50
51 // Prepare output
52 std::vector<InDet::IZWindowRoISeedTool::ZWindow> listRoIs;
53 listRoIs.clear();
54
55 // Retrieve beamspot information
57 if (not beamSpotHandle.isValid()) {
58 ATH_MSG_ERROR("Cannot retrieve beam spot data. Bailing out with empty RoI list.");
59 return listRoIs;
60 }
61 float bsSigZ = 0.0;
62 bsSigZ = beamSpotHandle->beamSigma(2);
63 ATH_MSG_DEBUG("Beam spot data available!");
64
65 // Initialize random engine and find z-value of RoI
66 ATHRNG::RNGWrapper *rndmEngine = m_atRndmSvc->getEngine(this, m_rndmEngineName);
67 rndmEngine->setSeed (name(), ctx);
68 CLHEP::HepRandomEngine* engine = rndmEngine->getEngine (ctx);
69 float zVal;
70 zVal = CLHEP::RandGauss::shoot(engine, 0.0, 1.0) * bsSigZ; //This effectively samples from a beamspot with the correct beamspot sigma_z
71
73 RoI.zReference = zVal;
74 RoI.zWindow[0] = RoI.zReference - m_z0Window;
75 RoI.zWindow[1] = RoI.zReference + m_z0Window;
76 listRoIs.push_back(RoI);
77 ATH_MSG_DEBUG("Random RoI: " << RoI.zReference << " [" << RoI.zWindow[0] << ", " << RoI.zWindow[1] << "]");
78
79 return listRoIs;
80
81}
82
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_ERROR(x)
#define ATH_MSG_DEBUG(x)
static Double_t sc
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
SG::ReadCondHandleKey< InDet::BeamSpotData > m_beamSpotKey
ServiceHandle< IAthRNGSvc > m_atRndmSvc
virtual StatusCode initialize() override
virtual std::vector< ZWindow > getRoIs(const EventContext &ctx) const override
Compute RoI.