ATLAS Offline Software
Loading...
Searching...
No Matches
InDetGlobalPrimaryVertexMonAlg.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
3*/
4
5
16
17//main header
19
23
24
25//Standard c++
26#include <vector>
27
28
29InDetGlobalPrimaryVertexMonAlg::InDetGlobalPrimaryVertexMonAlg( const std::string& name, ISvcLocator* pSvcLocator ) :
30 AthMonitorAlgorithm(name, pSvcLocator),
35{
36 declareProperty("splitVertexTrkInvFraction", m_splitVertexTrkInvFraction, "inverse fraction to split tracks (1:N)");
37 declareProperty("distanceSplitVertexMatch", m_distanceSplitVxMatch, "Distance for matching split-original Vertex in selection efficiency");
38 declareProperty("splitMatchingMetric", m_splitMatchingMetric, "Determines which function to use to calculate matching between split vertices and original input vertex -- used in selection efficiency");
39 declareProperty("doEnhancedMonitoring" , m_doEnhancedMonitoring, "turn on the enhanced vertex monitoring, it is triggered by the same InDetFlag that also triggers the creation of no beam constraint and split vertices");
40}
41
42
44
45
50
51
52StatusCode InDetGlobalPrimaryVertexMonAlg::fillHistograms( const EventContext& ctx ) const {
53 using namespace Monitored;
54
55 //*******************************************************************************
56 //************************** Begin of filling Track Histograms ******************
57 //*******************************************************************************
58
59 ATH_MSG_DEBUG("Filling InDetGlobalPrimaryVertexMonAlg");
60
61 // For histogram naming
62 const auto & pvGroup = getGroup("PrimaryVertex");
63
64 // retrieving vertices
65 auto handle_vxContainer = SG::makeHandle(m_vxContainerName, ctx); // another way to access ??
66
67 if (!handle_vxContainer.isPresent()) {
68 ATH_MSG_DEBUG ("InDetGlobalPrimaryVertexMonAlg: StoreGate doesn't contain primary vertex container with key "+m_vxContainerName.key());
69 return StatusCode::SUCCESS;
70 }
71 if (!handle_vxContainer.isValid()) {
72 ATH_MSG_ERROR ("InDetGlobalPrimaryVertexMonAlg: Could not retrieve primary vertex container with key "+m_vxContainerName.key());
73 return StatusCode::RECOVERABLE;
74 }
75
76 auto vertexContainer = handle_vxContainer.cptr();
77
78
79 // Total number of vertices (primary and pile up)
80 int pvN = vertexContainer->size()-1; // exclude dummy vertex
81 auto pvN_m = Monitored::Scalar<int>( "m_PvN", pvN);
82 fill(pvGroup, pvN_m);
83
84 int nPriVtx = 0;
85 int nPileupVtx = 0;
86
87 for(const auto vtx : *vertexContainer) {
88
89 if ( !vtx ) continue;
90
91 // Count different types of vertices
92 if (vtx->vertexType() == xAOD::VxType::PriVtx) nPriVtx++;
93 if (vtx->vertexType() == xAOD::VxType::PileUp) nPileupVtx++;
94
95
96 // Select primary vertex
97 if (vtx->vertexType() != xAOD::VxType::PriVtx) continue;
98 if (vtx->numberDoF() <= 0) continue;
99
100 float pvX = vtx->position().x();
101 auto pvX_m = Monitored::Scalar<float>( "m_PvX", pvX);
102 fill(pvGroup, pvX_m);
103
104 float pvY = vtx->position().y();
105 auto pvY_m = Monitored::Scalar<float>( "m_PvY", pvY);
106 fill(pvGroup, pvY_m);
107
108 float pvZ = vtx->position().z();
109 auto pvZ_m = Monitored::Scalar<float>( "m_PvZ", pvZ);
110 fill(pvGroup, pvZ_m);
111
112 float pvErrX = Amg::error( vtx->covariancePosition(), Trk::x);
113 auto pvErrX_m = Monitored::Scalar<float>( "m_PvErrX", pvErrX);
114 fill(pvGroup, pvErrX_m);
115
116 float pvErrY = Amg::error( vtx->covariancePosition(), Trk::y);
117 auto pvErrY_m = Monitored::Scalar<float>( "m_PvErrY", pvErrY);
118 fill(pvGroup, pvErrY_m);
119
120 float pvErrZ = Amg::error( vtx->covariancePosition(), Trk::z);
121 auto pvErrZ_m = Monitored::Scalar<float>( "m_PvErrZ", pvErrZ);
122 fill(pvGroup, pvErrZ_m);
123
124 float pvChiSqDoF = vtx->chiSquared() / vtx->numberDoF() ;
125 auto pvChiSqDoF_m = Monitored::Scalar<float>( "m_PvChiSqDoF", pvChiSqDoF);
126 fill(pvGroup, pvChiSqDoF_m);
127
128
129 auto & trackparticles = vtx->trackParticleLinks();
130
131 int pvNTracks = trackparticles.size() ;
132 auto pvNTracks_m = Monitored::Scalar<int>( "m_PvNTracks", pvNTracks);
133 fill(pvGroup, pvNTracks_m);
134
135
136 // original tracks used for primary vertex
137 for (const auto & trackparticle : trackparticles)
138 {
139 const Trk::Perigee & measuredPerigee = (*trackparticle)->perigeeParameters();
140
141 float pvTrackEta = measuredPerigee.eta() ;
142 auto pvTrackEta_m = Monitored::Scalar<float>( "m_PvTrackEta", pvTrackEta);
143 fill(pvGroup, pvTrackEta_m);
144
145 float pvTrackPt = measuredPerigee.pT()/1000. ; // Histo is in GeV
146 auto pvTrackPt_m = Monitored::Scalar<float>( "m_PvTrackPt", pvTrackPt);
147 fill(pvGroup, pvTrackPt_m);
148
149 }
150
151 } // vxContainer
152
153
154 auto nPriVtx_m = Monitored::Scalar<int>( "m_nPriVtx", nPriVtx);
155 fill(pvGroup, nPriVtx_m);
156
157 auto nPileupVtx_m = Monitored::Scalar<int>( "m_nPileupVtx", nPileupVtx);
158 fill(pvGroup, nPileupVtx_m);
159
160
161 // EnhancedMonitoring is OFF
162
163
164 //*******************************************************************************
165 //**************************** End of filling Track Histograms ******************
166 //*******************************************************************************
167
168 return StatusCode::SUCCESS;
169}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_ERROR(x)
#define ATH_MSG_DEBUG(x)
Implementation of inner detector global Primary Vertex monitoring tool.
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)
const ToolHandle< GenericMonitoringTool > & getGroup(const std::string &name) const
Get a specific monitoring tool from the tool handle array.
virtual StatusCode initialize() override
initialize
AthMonitorAlgorithm(const std::string &name, ISvcLocator *pSvcLocator)
Constructor.
virtual StatusCode initialize() override
initialize
int m_splitMatchingMetric
store metric to be used for split vertex matching in selection efficiency Values currently implemente...
InDetGlobalPrimaryVertexMonAlg(const std::string &name, ISvcLocator *pSvcLocator)
SG::ReadHandleKey< xAOD::VertexContainer > m_vxContainerName
float m_distanceSplitVxMatch
store maximum distance for matching split vertices to original non-BC vertex
virtual StatusCode fillHistograms(const EventContext &ctx) const override
adds event to the monitoring histograms
int m_splitVertexTrkInvFraction
store inverse of the fraction of input tracks used for probe vertex (1:N)
Declare a monitored scalar variable.
double eta() const
Access method for pseudorapidity - from momentum.
double pT() const
Access method for transverse momentum.
void fill(const ToolHandle< GenericMonitoringTool > &groupHandle, std::vector< std::reference_wrapper< Monitored::IMonitoredVariable > > &&variables) const
Fills a vector of variables to a group by reference.
double error(const Amg::MatrixX &mat, int index)
return diagonal error of the matrix caller should ensure the matrix is symmetric and the index is in ...
Generic monitoring tool for athena components.
SG::ReadCondHandle< T > makeHandle(const SG::ReadCondHandleKey< T > &key, const EventContext &ctx=Gaudi::Hive::currentContext())
ParametersT< TrackParametersDim, Charged, PerigeeSurface > Perigee
@ x
Definition ParamDefs.h:55
@ z
global position (cartesian)
Definition ParamDefs.h:57
@ y
Definition ParamDefs.h:56
@ PileUp
Pile-up vertex.
@ PriVtx
Primary vertex.