ATLAS Offline Software
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 {
38 
40 
41  return sc;
42 }
43 
45 // Compute RoI
47 
48 std::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 
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
SG::ReadCondHandle
Definition: ReadCondHandle.h:44
initialize
void initialize()
Definition: run_EoverP.cxx:894
read_hist_ntuple.t
t
Definition: read_hist_ntuple.py:5
InDet::RandomRoISeedTool::RandomRoISeedTool
RandomRoISeedTool()=delete
AthenaPoolTestRead.sc
sc
Definition: AthenaPoolTestRead.py:27
InDet::RandomRoISeedTool::getRoIs
virtual std::vector< ZWindow > getRoIs(const EventContext &ctx) const override
Compute RoI.
Definition: RandomRoISeedTool.cxx:48
python.utils.AtlRunQueryDQUtils.p
p
Definition: AtlRunQueryDQUtils.py:210
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
InDet::IZWindowRoISeedTool::ZWindow
Definition: IZWindowRoISeedTool.h:46
InDet::RandomRoISeedTool::m_atRndmSvc
ServiceHandle< IAthRNGSvc > m_atRndmSvc
Definition: RandomRoISeedTool.h:65
beamspotman.n
n
Definition: beamspotman.py:731
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
InDet::RandomRoISeedTool::m_beamSpotKey
SG::ReadCondHandleKey< InDet::BeamSpotData > m_beamSpotKey
Definition: RandomRoISeedTool.h:64
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
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
InDet::IZWindowRoISeedTool::ZWindow::zWindow
float zWindow[2]
Definition: IZWindowRoISeedTool.h:49
SG::CondHandleKey::initialize
StatusCode initialize(bool used=true)
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
InDet::RandomRoISeedTool::initialize
virtual StatusCode initialize() override
Definition: RandomRoISeedTool.cxx:35
RandomRoISeedTool.h
InDet::IZWindowRoISeedTool::ZWindow::zReference
float zReference
Definition: IZWindowRoISeedTool.h:51
InDet::RandomRoISeedTool::m_z0Window
FloatProperty m_z0Window
Definition: RandomRoISeedTool.h:63
InDet::RandomRoISeedTool::m_rndmEngineName
std::string m_rndmEngineName
Definition: RandomRoISeedTool.h:67