ATLAS Offline Software
Loading...
Searching...
No Matches
Trk::DummyVertexSelectionTool Class Reference

#include <DummyVertexSelectionTool.h>

Inheritance diagram for Trk::DummyVertexSelectionTool:
Collaboration diagram for Trk::DummyVertexSelectionTool:

Public Member Functions

virtual StatusCode initialize () override
virtual StatusCode finalize () override
 EndOfInitialize.
 DummyVertexSelectionTool (const std::string &t, const std::string &n, const IInterface *p)
 constructor
virtual ~DummyVertexSelectionTool ()
 destructor
virtual unsigned int findVertexInContainer (const xAOD::VertexContainer *) const override

Private Attributes

ServiceHandle< IAthRNGSvcm_randomSvc { this, "RndmSvc", "AthRNGSvc", ""}
 Pointer to the random number generator service.
std::string m_randomEngineName
 Name of the random number stream.

Detailed Description

Author
Kirill Prokofiev, January 2012 A test class, meant to be an example of correct implementation for the veretx selector.

Changes:

David Shope david.nosp@m..ric.nosp@m.hard..nosp@m.shop.nosp@m.e@cer.nosp@m.n.ch (2016-06-01)

EDM Migration to xAOD - replace VxContainer with xAOD::VertexContainer

Definition at line 36 of file DummyVertexSelectionTool.h.

Constructor & Destructor Documentation

◆ DummyVertexSelectionTool()

Trk::DummyVertexSelectionTool::DummyVertexSelectionTool ( const std::string & t,
const std::string & n,
const IInterface * p )

constructor

Definition at line 14 of file DummyVertexSelectionTool.cxx.

15 : base_class ( t,n,p ),m_randomEngineName("VertexRnd")
16 {
17 declareProperty("RandomStreamName", m_randomEngineName, "Name of the random number stream");
18 }
std::string m_randomEngineName
Name of the random number stream.

◆ ~DummyVertexSelectionTool()

Trk::DummyVertexSelectionTool::~DummyVertexSelectionTool ( )
virtualdefault

destructor

Member Function Documentation

◆ finalize()

StatusCode Trk::DummyVertexSelectionTool::finalize ( )
overridevirtual

EndOfInitialize.

Definition at line 30 of file DummyVertexSelectionTool.cxx.

31 {
32 return StatusCode::SUCCESS;
33 }

◆ findVertexInContainer()

unsigned int Trk::DummyVertexSelectionTool::findVertexInContainer ( const xAOD::VertexContainer * vertexContainer) const
overridevirtual

Definition at line 35 of file DummyVertexSelectionTool.cxx.

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 }
#define ATH_MSG_VERBOSE(x)
void setSeed(const std::string &algName, const EventContext &ctx)
Set the random seed using a string (e.g.
Definition RNGWrapper.h:169
EventContext::ContextEvt_t evtSeeded() const
Return the event count at which the current slot was last seeded.
Definition RNGWrapper.h:139
CLHEP::HepRandomEngine * getEngine(const EventContext &ctx) const
Retrieve the random engine corresponding to the provided EventContext.
Definition RNGWrapper.h:134
size_type size() const noexcept
Returns the number of elements in the collection.
ServiceHandle< IAthRNGSvc > m_randomSvc
Pointer to the random number generator service.

◆ initialize()

StatusCode Trk::DummyVertexSelectionTool::initialize ( )
overridevirtual

Definition at line 24 of file DummyVertexSelectionTool.cxx.

25 {
26 ATH_CHECK( m_randomSvc.retrieve() );
27 return StatusCode::SUCCESS;
28 }
#define ATH_CHECK
Evaluate an expression and check for errors.

Member Data Documentation

◆ m_randomEngineName

std::string Trk::DummyVertexSelectionTool::m_randomEngineName
private

Name of the random number stream.

Definition at line 62 of file DummyVertexSelectionTool.h.

◆ m_randomSvc

ServiceHandle<IAthRNGSvc> Trk::DummyVertexSelectionTool::m_randomSvc { this, "RndmSvc", "AthRNGSvc", ""}
private

Pointer to the random number generator service.

< Random Svc

Definition at line 60 of file DummyVertexSelectionTool.h.

61{ this, "RndmSvc", "AthRNGSvc", ""};

The documentation for this class was generated from the following files: