ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
Tracking
TrkVertexFitter
TrkVertexTools
src
DummyVertexSelectionTool.cxx
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3
*/
4
5
#include "
TrkVertexTools/DummyVertexSelectionTool.h
"
6
#include "
TrkEventPrimitives/ParamDefs.h
"
7
#include "
AthenaKernel/RNGWrapper.h
"
8
#include "CLHEP/Random/RandFlat.h"
9
#include <vector>
10
11
namespace
Trk
{
12
13
//constructor
14
DummyVertexSelectionTool::DummyVertexSelectionTool
(
const
std::string& t,
const
std::string& n,
const
IInterface* p )
15
: base_class ( t,n,p ),
m_randomEngineName
(
"VertexRnd"
)
16
{
17
declareProperty(
"RandomStreamName"
,
m_randomEngineName
,
"Name of the random number stream"
);
18
}
19
20
//destructor
21
DummyVertexSelectionTool::~DummyVertexSelectionTool
()=
default
;
22
23
//initialize
24
StatusCode
DummyVertexSelectionTool::initialize
()
25
{
26
ATH_CHECK
(
m_randomSvc
.retrieve() );
27
return
StatusCode::SUCCESS;
28
}
29
30
StatusCode
DummyVertexSelectionTool::finalize
()
31
{
32
return
StatusCode::SUCCESS;
33
}
34
35
unsigned
int
DummyVertexSelectionTool::findVertexInContainer
(
const
xAOD::VertexContainer
* vertexContainer )
const
36
{
37
if
(vertexContainer->
size
()>2)
38
{
39
40
// Get the RNG engine. Reseed if a new event.
41
const
EventContext& ctx = Gaudi::Hive::currentContext();
42
ATHRNG::RNGWrapper
* wrapper =
m_randomSvc
->getEngine(
this
,
m_randomEngineName
);
43
if
(wrapper->
evtSeeded
(ctx) != ctx.evt()) {
44
wrapper->
setSeed
(name(), ctx);
45
}
46
CLHEP::HepRandomEngine* engine = wrapper->
getEngine
(ctx);
47
48
//only do anything if >1 real vertex is actually present
49
if
( CLHEP::RandFlat::shoot(engine)>0.9)
50
{
51
//and only in 10% of cases let us randomize the vertex choice
52
unsigned
int
ivtx = (
unsigned
int)( CLHEP::RandFlat::shoot(engine) * vertexContainer->
size
());
53
54
ATH_MSG_VERBOSE
(
"Vertex Selection changed to "
<< ivtx <<
"!"
);
55
return
ivtx;
56
57
}
//end of random selection
58
ATH_MSG_VERBOSE
(
"Vertex Selection unchanged!"
);
59
60
}
//end of VertexContainer size check
61
62
//nothing happened, return the default primary vertex position
63
return
0;
64
}
65
66
}
ATH_CHECK
#define ATH_CHECK
Evaluate an expression and check for errors.
Definition
AthCheckMacros.h:40
ATH_MSG_VERBOSE
#define ATH_MSG_VERBOSE(x)
Definition
AthMsgStreamMacros.h:28
DummyVertexSelectionTool.h
ParamDefs.h
RNGWrapper.h
ATHRNG::RNGWrapper
A wrapper class for event-slot-local random engines.
Definition
RNGWrapper.h:56
ATHRNG::RNGWrapper::setSeed
void setSeed(const std::string &algName, const EventContext &ctx)
Set the random seed using a string (e.g.
Definition
RNGWrapper.h:154
ATHRNG::RNGWrapper::evtSeeded
EventContext::ContextEvt_t evtSeeded(const EventContext &ctx) const
Return the event count at which the current slot of CTX was last seeded.
Definition
RNGWrapper.h:113
ATHRNG::RNGWrapper::getEngine
CLHEP::HepRandomEngine * getEngine(const EventContext &ctx) const
Retrieve the random engine corresponding to the provided EventContext.
Definition
RNGWrapper.h:108
DataVector::size
size_type size() const noexcept
Returns the number of elements in the collection.
Trk::DummyVertexSelectionTool::finalize
virtual StatusCode finalize() override
EndOfInitialize.
Definition
DummyVertexSelectionTool.cxx:30
Trk::DummyVertexSelectionTool::m_randomEngineName
std::string m_randomEngineName
Name of the random number stream.
Definition
DummyVertexSelectionTool.h:62
Trk::DummyVertexSelectionTool::m_randomSvc
ServiceHandle< IAthRNGSvc > m_randomSvc
Pointer to the random number generator service.
Definition
DummyVertexSelectionTool.h:61
Trk::DummyVertexSelectionTool::initialize
virtual StatusCode initialize() override
Definition
DummyVertexSelectionTool.cxx:24
Trk::DummyVertexSelectionTool::~DummyVertexSelectionTool
virtual ~DummyVertexSelectionTool()
destructor
Trk::DummyVertexSelectionTool::DummyVertexSelectionTool
DummyVertexSelectionTool(const std::string &t, const std::string &n, const IInterface *p)
constructor
Definition
DummyVertexSelectionTool.cxx:14
Trk::DummyVertexSelectionTool::findVertexInContainer
virtual unsigned int findVertexInContainer(const xAOD::VertexContainer *) const override
Definition
DummyVertexSelectionTool.cxx:35
Trk
Ensure that the ATLAS eigen extensions are properly loaded.
Definition
FakeTrackBuilder.h:9
xAOD::VertexContainer
VertexContainer_v1 VertexContainer
Definition of the current "Vertex container version".
Definition
VertexContainer.h:14
Generated on
for ATLAS Offline Software by
1.17.0