ATLAS Offline Software
Loading...
Searching...
No Matches
VertexSelectionAlg.cxx
Go to the documentation of this file.
1//
2// Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3//
4
5// Local include(s):
7
9
10namespace CP {
11
13
14 // Greet the user:
15 ATH_MSG_INFO( "Requiring " << m_minVertices << " vertex/vertices from \""
16 << m_vertexKey << "\" with " << m_minTracks
17 << " track(s) each" );
18
19 ANA_CHECK (m_filterParams.initialize());
20 ANA_CHECK (m_vertexKey.initialize());
21
22 // Return gracefully:
23 return StatusCode::SUCCESS;
24 }
25
27 ANA_MSG_INFO (m_filterParams.summary());
28
29 // Return gracefully:
30 return StatusCode::SUCCESS;
31 }
32
33 StatusCode VertexSelectionAlg::execute(const EventContext &ctx) const {
34
35 FilterReporter filter (m_filterParams, false, ctx);
36
37 // Retrieve the vertex container:
39
40 // The number of "good" vertices found:
41 unsigned goodVertices = 0;
42
43 // Check how many "good" vertices we have in the current event:
44 for( const xAOD::Vertex* vx : *vertices ) {
45 // It has to be either a primary or a pileup vertex:
46 if( ( vx->vertexType() != xAOD::VxType::PriVtx ) &&
47 ( vx->vertexType() != xAOD::VxType::PileUp ) ) {
48 continue;
49 }
50 // With the minimum number of tracks specified:
51 if( vx->nTrackParticles() < m_minTracks ) {
52 continue;
53 }
54 // Apparently this is a "good" vertex:
55 ++goodVertices;
56 }
57
58 // Decide about the event:
59 filter.setPassed( goodVertices >= m_minVertices );
60
61 // Return gracefully:
62 return StatusCode::SUCCESS;
63 }
64
65} // namespace CP
#define ATH_MSG_INFO(x)
#define ANA_MSG_INFO(xmsg)
Macro printing info messages.
#define ANA_CHECK(EXP)
check whether the given expression was successful
FilterReporterParams m_filterParams
Gaudi::Property< unsigned > m_minTracks
Number of track particles required per vertex.
virtual StatusCode finalize() override
Function finalize the algorithm.
SG::ReadHandleKey< xAOD::VertexContainer > m_vertexKey
Event store key of the vertex container.
virtual StatusCode initialize() override
Function initialising the algorithm.
virtual StatusCode execute(const EventContext &ctx) const override
Function executing the algorithm.
Gaudi::Property< unsigned > m_minVertices
Number of vertices required in the event.
a guard class for use with ref FilterReporterParams
Select isolated Photons, Electrons and Muons.
@ PileUp
Pile-up vertex.
@ PriVtx
Primary vertex.
Vertex_v1 Vertex
Define the latest version of the vertex class.