ATLAS Offline Software
Loading...
Searching...
No Matches
Analysis::PrimaryVertexRefitter Class Reference

#include <PrimaryVertexRefitter.h>

Inheritance diagram for Analysis::PrimaryVertexRefitter:
Collaboration diagram for Analysis::PrimaryVertexRefitter:

Public Member Functions

 PrimaryVertexRefitter (const std::string &t, const std::string &n, const IInterface *p)
 ~PrimaryVertexRefitter ()
StatusCode initialize ()
xAOD::VertexrefitVertex (const xAOD::Vertex *vertex, const xAOD::Vertex *excludeVertex, bool ReturnCopy=true, int *exitcode=nullptr) const
xAOD::VertexrefitVertex (const xAOD::Vertex *vertex, const std::vector< const xAOD::TrackParticle * > &tps, bool ReturnCopy=true, int *exitcode=nullptr) const
ServiceHandle< StoreGateSvc > & evtStore ()
 The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc.
const ServiceHandle< StoreGateSvc > & detStore () const
 The standard StoreGateSvc/DetectorStore Returns (kind of) a pointer to the StoreGateSvc.
virtual StatusCode sysInitialize () override
 Perform system initialization for an algorithm.
virtual StatusCode sysStart () override
 Handle START transition.
virtual std::vector< Gaudi::DataHandle * > inputHandles () const override
 Return this algorithm's input handles.
virtual std::vector< Gaudi::DataHandle * > outputHandles () const override
 Return this algorithm's output handles.
Gaudi::Details::PropertyBase & declareProperty (Gaudi::Property< T, V, H > &t)
void updateVHKA (Gaudi::Details::PropertyBase &)
MsgStream & msg () const
bool msgLvl (const MSG::Level lvl) const

Static Public Member Functions

static const InterfaceID & interfaceID ()

Protected Member Functions

void renounceArray (SG::VarHandleKeyArray &handlesArray)
 remove all handles from I/O resolution
std::enable_if_t< std::is_void_v< std::result_of_t< decltype(&T::renounce)(T)> > &&!std::is_base_of_v< SG::VarHandleKeyArray, T > &&std::is_base_of_v< Gaudi::DataHandle, T >, void > renounce (T &h)
void extraDeps_update_handler (Gaudi::Details::PropertyBase &ExtraDeps)
 Add StoreName to extra input/output deps as needed.

Private Types

typedef ServiceHandle< StoreGateSvcStoreGateSvc_t

Private Member Functions

Gaudi::Details::PropertyBase & declareGaudiProperty (Gaudi::Property< T, V, H > &hndl, const SG::VarHandleKeyType &)
 specialization for handling Gaudi::Property<SG::VarHandleKey>

Private Attributes

Gaudi::Property< unsigned int > m_ntrk_min {this,"MinimumNumberOfTracksInVertex",2}
ToolHandle< Trk::ITrackToVertexIPEstimatorm_trackToVertexIPEstimator { this, "TrackToVertexIPEstimator", "Trk::TrackToVertexIPEstimator" }
StoreGateSvc_t m_evtStore
 Pointer to StoreGate (event store by default)
StoreGateSvc_t m_detStore
 Pointer to StoreGate (detector store by default)
std::vector< SG::VarHandleKeyArray * > m_vhka
bool m_varHandleArraysDeclared

Detailed Description

Definition at line 26 of file PrimaryVertexRefitter.h.

Member Typedef Documentation

◆ StoreGateSvc_t

typedef ServiceHandle<StoreGateSvc> AthCommonDataStore< AthCommonMsg< AlgTool > >::StoreGateSvc_t
privateinherited

Definition at line 388 of file AthCommonDataStore.h.

Constructor & Destructor Documentation

◆ PrimaryVertexRefitter()

Analysis::PrimaryVertexRefitter::PrimaryVertexRefitter ( const std::string & t,
const std::string & n,
const IInterface * p )

Definition at line 31 of file PrimaryVertexRefitter.cxx.

31 :
32AthAlgTool(t,n,p)
33{
34 declareInterface<PrimaryVertexRefitter>(this);
35}
AthAlgTool()
Default constructor:

◆ ~PrimaryVertexRefitter()

Analysis::PrimaryVertexRefitter::~PrimaryVertexRefitter ( )

Definition at line 37 of file PrimaryVertexRefitter.cxx.

37{ }

Member Function Documentation

◆ declareGaudiProperty()

Gaudi::Details::PropertyBase & AthCommonDataStore< AthCommonMsg< AlgTool > >::declareGaudiProperty ( Gaudi::Property< T, V, H > & hndl,
const SG::VarHandleKeyType &  )
inlineprivateinherited

specialization for handling Gaudi::Property<SG::VarHandleKey>

Definition at line 156 of file AthCommonDataStore.h.

158 {
160 hndl.value(),
161 hndl.documentation());
162
163 }
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)

◆ declareProperty()

Gaudi::Details::PropertyBase & AthCommonDataStore< AthCommonMsg< AlgTool > >::declareProperty ( Gaudi::Property< T, V, H > & t)
inlineinherited

Definition at line 145 of file AthCommonDataStore.h.

145 {
146 typedef typename SG::HandleClassifier<T>::type htype;
148 }
Gaudi::Details::PropertyBase & declareGaudiProperty(Gaudi::Property< T, V, H > &hndl, const SG::VarHandleKeyType &)
specialization for handling Gaudi::Property<SG::VarHandleKey>

◆ detStore()

const ServiceHandle< StoreGateSvc > & AthCommonDataStore< AthCommonMsg< AlgTool > >::detStore ( ) const
inlineinherited

The standard StoreGateSvc/DetectorStore Returns (kind of) a pointer to the StoreGateSvc.

Definition at line 95 of file AthCommonDataStore.h.

◆ evtStore()

ServiceHandle< StoreGateSvc > & AthCommonDataStore< AthCommonMsg< AlgTool > >::evtStore ( )
inlineinherited

The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc.

Definition at line 85 of file AthCommonDataStore.h.

◆ extraDeps_update_handler()

void AthCommonDataStore< AthCommonMsg< AlgTool > >::extraDeps_update_handler ( Gaudi::Details::PropertyBase & ExtraDeps)
protectedinherited

Add StoreName to extra input/output deps as needed.

use the logic of the VarHandleKey to parse the DataObjID keys supplied via the ExtraInputs and ExtraOuputs Properties to add the StoreName if it's not explicitly given

◆ initialize()

StatusCode Analysis::PrimaryVertexRefitter::initialize ( )

Definition at line 21 of file PrimaryVertexRefitter.cxx.

21 {
22
24
25 ATH_MSG_DEBUG("Initialize successful");
26
27 return StatusCode::SUCCESS;
28
29}
#define ATH_MSG_DEBUG(x)
#define CHECK(...)
Evaluate an expression and check for errors.
ToolHandle< Trk::ITrackToVertexIPEstimator > m_trackToVertexIPEstimator

◆ inputHandles()

virtual std::vector< Gaudi::DataHandle * > AthCommonDataStore< AthCommonMsg< AlgTool > >::inputHandles ( ) const
overridevirtualinherited

Return this algorithm's input handles.

We override this to include handle instances from key arrays if they have not yet been declared. See comments on updateVHKA.

◆ interfaceID()

const InterfaceID & Analysis::PrimaryVertexRefitter::interfaceID ( )
inlinestatic

Definition at line 32 of file PrimaryVertexRefitter.h.

static const InterfaceID IID_PrimaryVertexRefitter("PrimaryVertexRefitter", 1, 0)

◆ msg()

MsgStream & AthCommonMsg< AlgTool >::msg ( ) const
inlineinherited

Definition at line 24 of file AthCommonMsg.h.

24 {
25 return this->msgStream();
26 }

◆ msgLvl()

bool AthCommonMsg< AlgTool >::msgLvl ( const MSG::Level lvl) const
inlineinherited

Definition at line 30 of file AthCommonMsg.h.

30 {
31 return this->msgLevel(lvl);
32 }

◆ outputHandles()

virtual std::vector< Gaudi::DataHandle * > AthCommonDataStore< AthCommonMsg< AlgTool > >::outputHandles ( ) const
overridevirtualinherited

Return this algorithm's output handles.

We override this to include handle instances from key arrays if they have not yet been declared. See comments on updateVHKA.

◆ refitVertex() [1/2]

xAOD::Vertex * Analysis::PrimaryVertexRefitter::refitVertex ( const xAOD::Vertex * vertex,
const std::vector< const xAOD::TrackParticle * > & tps,
bool ReturnCopy = true,
int * exitcode = nullptr ) const

Definition at line 76 of file PrimaryVertexRefitter.cxx.

77{
78
79 if (vertex == 0) {
80 ATH_MSG_DEBUG("Empty original xAOD::Vertex pointer passed: returning 0");
81 if(exitcode) *exitcode =-1;
82 return 0;
83 }
84 unsigned int ntrk_pv = vertex->nTrackParticles();
85 if (ntrk_pv == 0) {
86 ATH_MSG_DEBUG("Input vertex has no associated tracks: returning 0");
87 if(exitcode) *exitcode = -2;
88 return 0;
89 }
90 if (ntrk_pv <= m_ntrk_min) {
91 ATH_MSG_DEBUG("The number of tracks " << ntrk_pv << " in the original vertex is already <= the allowed minimum number of tracks " << m_ntrk_min << ", returning original vertex");
92 if(exitcode) *exitcode = 2;
93 return returnCopy ? new xAOD::Vertex(*vertex) : nullptr;
94 }
95 unsigned int ntrk = tps.size();
96 if (ntrk == 0) {
97 ATH_MSG_DEBUG("No tracks requested to be removed: returning original vertex");
98 if(exitcode) *exitcode = 3;
99 return returnCopy ? new xAOD::Vertex(*vertex) : nullptr;
100 }
101
102 xAOD::Vertex* reducedVertex(0);
103 const xAOD::Vertex* tmpVert = vertex;
104 std::vector <const xAOD::TrackParticle*>::const_iterator pb = tps.begin();
105 std::vector <const xAOD::TrackParticle*>::const_iterator pe = tps.end();
106 for (;pb!=pe;++pb) {
107 const xAOD::TrackParticle* tp = (*pb);
108 reducedVertex = m_trackToVertexIPEstimator->getUnbiasedVertex(tp,tmpVert);
109 if (tmpVert != vertex) delete tmpVert;
110 if (reducedVertex == 0) {
111 ATH_MSG_DEBUG("Refit failed: returning original vertex");
112 if(exitcode) *exitcode = -4;
113 return returnCopy ? new xAOD::Vertex(*vertex) : nullptr;
114 }
115 tmpVert = reducedVertex;
116 if (tmpVert->nTrackParticles() <= m_ntrk_min-1) {
117 ATH_MSG_DEBUG("The number of tracks in the refitted vertex would be less than the allowed minimum number of tracks: " << m_ntrk_min << ", returning original vertex");
118 delete reducedVertex;
119 if(exitcode) *exitcode = 5;
120 return returnCopy ? new xAOD::Vertex(*vertex) : nullptr;
121 }
122 }
123 if(exitcode) *exitcode = 1;
124 return reducedVertex;
125}
Gaudi::Property< unsigned int > m_ntrk_min
size_t nTrackParticles() const
Get the number of tracks associated with this vertex.
int exitcode
Definition athena.py:161
TrackParticle_v1 TrackParticle
Reference the current persistent version:
Vertex_v1 Vertex
Define the latest version of the vertex class.

◆ refitVertex() [2/2]

xAOD::Vertex * Analysis::PrimaryVertexRefitter::refitVertex ( const xAOD::Vertex * vertex,
const xAOD::Vertex * excludeVertex,
bool ReturnCopy = true,
int * exitcode = nullptr ) const

Definition at line 40 of file PrimaryVertexRefitter.cxx.

41{
42
43 if (vertex == 0) {
44 ATH_MSG_DEBUG("Empty original xAOD::Vertex pointer passed: returning 0");
45 if(exitcode) *exitcode = -1;
46 return 0;
47 }
48 unsigned int ntrk_pv = vertex->nTrackParticles();
49 if (ntrk_pv == 0) {
50 ATH_MSG_DEBUG("Input vertex has no associated tracks: returning 0");
51 if(exitcode) *exitcode =-2;
52 return 0;
53 }
54 if (excludeVertex == 0) {
55 ATH_MSG_DEBUG("Empty exclude xAOD::Vertex pointer passed: returning original vertex");
56 if(exitcode) *exitcode = 10;
57 return returnCopy ? new xAOD::Vertex(*vertex) : nullptr;
58 }
59 std::vector<const xAOD::TrackParticle*> tps; tps.clear();
60 unsigned int ntrk = excludeVertex->nTrackParticles();
61 if (ntrk == 0) {
62 ATH_MSG_DEBUG("Exclude vertex has no associated tracks: returning original vertex");
63 if(exitcode) *exitcode = 11;
64 return returnCopy ? new xAOD::Vertex(*vertex) : nullptr;
65 }
66
67 for (unsigned int i = 0; i < ntrk ; ++i) {
68 const xAOD::TrackParticle* tp = excludeVertex->trackParticle(i);
69 if (tp==0) continue;
70 tps.push_back(tp);
71 }
72 return refitVertex(vertex,tps, returnCopy, exitcode);
73}
xAOD::Vertex * refitVertex(const xAOD::Vertex *vertex, const xAOD::Vertex *excludeVertex, bool ReturnCopy=true, int *exitcode=nullptr) const
const TrackParticle * trackParticle(size_t i) const
Get the pointer to a given track that was used in vertex reco.

◆ renounce()

std::enable_if_t< std::is_void_v< std::result_of_t< decltype(&T::renounce)(T)> > &&!std::is_base_of_v< SG::VarHandleKeyArray, T > &&std::is_base_of_v< Gaudi::DataHandle, T >, void > AthCommonDataStore< AthCommonMsg< AlgTool > >::renounce ( T & h)
inlineprotectedinherited

Definition at line 380 of file AthCommonDataStore.h.

381 {
382 h.renounce();
384 }
std::enable_if_t< std::is_void_v< std::result_of_t< decltype(&T::renounce)(T)> > &&!std::is_base_of_v< SG::VarHandleKeyArray, T > &&std::is_base_of_v< Gaudi::DataHandle, T >, void > renounce(T &h)

◆ renounceArray()

void AthCommonDataStore< AthCommonMsg< AlgTool > >::renounceArray ( SG::VarHandleKeyArray & handlesArray)
inlineprotectedinherited

remove all handles from I/O resolution

Definition at line 364 of file AthCommonDataStore.h.

364 {
366 }

◆ sysInitialize()

virtual StatusCode AthCommonDataStore< AthCommonMsg< AlgTool > >::sysInitialize ( )
overridevirtualinherited

Perform system initialization for an algorithm.

We override this to declare all the elements of handle key arrays at the end of initialization. See comments on updateVHKA.

Reimplemented in asg::AsgMetadataTool, AthCheckedComponent< AthAlgTool >, AthCheckedComponent<::AthAlgTool >, and DerivationFramework::CfAthAlgTool.

◆ sysStart()

virtual StatusCode AthCommonDataStore< AthCommonMsg< AlgTool > >::sysStart ( )
overridevirtualinherited

Handle START transition.

We override this in order to make sure that conditions handle keys can cache a pointer to the conditions container.

◆ updateVHKA()

void AthCommonDataStore< AthCommonMsg< AlgTool > >::updateVHKA ( Gaudi::Details::PropertyBase & )
inlineinherited

Definition at line 308 of file AthCommonDataStore.h.

308 {
309 // debug() << "updateVHKA for property " << p.name() << " " << p.toString()
310 // << " size: " << m_vhka.size() << endmsg;
311 for (auto &a : m_vhka) {
313 for (auto k : keys) {
314 k->setOwner(this);
315 }
316 }
317 }
std::vector< SG::VarHandleKeyArray * > m_vhka

Member Data Documentation

◆ m_detStore

StoreGateSvc_t AthCommonDataStore< AthCommonMsg< AlgTool > >::m_detStore
privateinherited

Pointer to StoreGate (detector store by default)

Definition at line 393 of file AthCommonDataStore.h.

◆ m_evtStore

StoreGateSvc_t AthCommonDataStore< AthCommonMsg< AlgTool > >::m_evtStore
privateinherited

Pointer to StoreGate (event store by default)

Definition at line 390 of file AthCommonDataStore.h.

◆ m_ntrk_min

Gaudi::Property<unsigned int> Analysis::PrimaryVertexRefitter::m_ntrk_min {this,"MinimumNumberOfTracksInVertex",2}
private

Definition at line 41 of file PrimaryVertexRefitter.h.

41{this,"MinimumNumberOfTracksInVertex",2};

◆ m_trackToVertexIPEstimator

ToolHandle<Trk::ITrackToVertexIPEstimator> Analysis::PrimaryVertexRefitter::m_trackToVertexIPEstimator { this, "TrackToVertexIPEstimator", "Trk::TrackToVertexIPEstimator" }
private

Definition at line 42 of file PrimaryVertexRefitter.h.

42{ this, "TrackToVertexIPEstimator", "Trk::TrackToVertexIPEstimator" };

◆ m_varHandleArraysDeclared

bool AthCommonDataStore< AthCommonMsg< AlgTool > >::m_varHandleArraysDeclared
privateinherited

Definition at line 399 of file AthCommonDataStore.h.

◆ m_vhka

std::vector<SG::VarHandleKeyArray*> AthCommonDataStore< AthCommonMsg< AlgTool > >::m_vhka
privateinherited

Definition at line 398 of file AthCommonDataStore.h.


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