ATLAS Offline Software
InDetGlobalPrimaryVertexMonAlg.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 
17 //main header
19 
23 
24 
25 //Standard c++
26 #include <vector>
27 
28 
29 InDetGlobalPrimaryVertexMonAlg::InDetGlobalPrimaryVertexMonAlg( const std::string& name, ISvcLocator* pSvcLocator ) :
30  AthMonitorAlgorithm(name, pSvcLocator),
31  m_splitVertexTrkInvFraction(2),
32  m_distanceSplitVxMatch(5.0),
33  m_splitMatchingMetric(3),
34  m_doEnhancedMonitoring(false)
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 
47 
48 
49  ATH_CHECK( m_vxContainerName.initialize() );
50  //ATH_CHECK( m_vxContainerNameSplit.initialize() );
51 
52 
54 }
55 
56 
58  using namespace Monitored;
59 
60  //*******************************************************************************
61  //************************** Begin of filling Track Histograms ******************
62  //*******************************************************************************
63 
64  ATH_MSG_DEBUG("Filling InDetGlobalPrimaryVertexMonAlg");
65 
66  // For histogram naming
67  auto pvGroup = getGroup("PrimaryVertex");
68 
69  // retrieving vertices
70  auto handle_vxContainer = SG::makeHandle(m_vxContainerName, ctx); // another way to access ??
71 
72  if (!handle_vxContainer.isPresent()) {
73  ATH_MSG_DEBUG ("InDetGlobalPrimaryVertexMonAlg: StoreGate doesn't contain primary vertex container with key "+m_vxContainerName.key());
74  return StatusCode::SUCCESS;
75  }
76  if (!handle_vxContainer.isValid()) {
77  ATH_MSG_ERROR ("InDetGlobalPrimaryVertexMonAlg: Could not retrieve primary vertex container with key "+m_vxContainerName.key());
78  return StatusCode::RECOVERABLE;
79  }
80 
81  auto vertexContainer = handle_vxContainer.cptr();
82 
83 
84  // Total number of vertices (primary and pile up)
85  int pvN = vertexContainer->size()-1; // exclude dummy vertex
86  auto pvN_m = Monitored::Scalar<int>( "m_PvN", pvN);
87  fill(pvGroup, pvN_m);
88 
89  int nPriVtx = 0;
90  int nPileupVtx = 0;
91 
92  for(const auto vtx : *vertexContainer) {
93 
94  if ( !vtx ) continue;
95 
96  // Count different types of vertices
97  if (vtx->vertexType() == xAOD::VxType::PriVtx) nPriVtx++;
98  if (vtx->vertexType() == xAOD::VxType::PileUp) nPileupVtx++;
99 
100 
101  // Select primary vertex
102  if (vtx->vertexType() != xAOD::VxType::PriVtx) continue;
103  if (vtx->numberDoF() <= 0) continue;
104 
105  float pvX = vtx->position().x();
106  auto pvX_m = Monitored::Scalar<float>( "m_PvX", pvX);
107  fill(pvGroup, pvX_m);
108 
109  float pvY = vtx->position().y();
110  auto pvY_m = Monitored::Scalar<float>( "m_PvY", pvY);
111  fill(pvGroup, pvY_m);
112 
113  float pvZ = vtx->position().z();
114  auto pvZ_m = Monitored::Scalar<float>( "m_PvZ", pvZ);
115  fill(pvGroup, pvZ_m);
116 
117  float pvErrX = Amg::error( vtx->covariancePosition(), Trk::x);
118  auto pvErrX_m = Monitored::Scalar<float>( "m_PvErrX", pvErrX);
119  fill(pvGroup, pvErrX_m);
120 
121  float pvErrY = Amg::error( vtx->covariancePosition(), Trk::y);
122  auto pvErrY_m = Monitored::Scalar<float>( "m_PvErrY", pvErrY);
123  fill(pvGroup, pvErrY_m);
124 
125  float pvErrZ = Amg::error( vtx->covariancePosition(), Trk::z);
126  auto pvErrZ_m = Monitored::Scalar<float>( "m_PvErrZ", pvErrZ);
127  fill(pvGroup, pvErrZ_m);
128 
129  float pvChiSqDoF = vtx->chiSquared() / vtx->numberDoF() ;
130  auto pvChiSqDoF_m = Monitored::Scalar<float>( "m_PvChiSqDoF", pvChiSqDoF);
131  fill(pvGroup, pvChiSqDoF_m);
132 
133 
134  auto & trackparticles = vtx->trackParticleLinks();
135 
136  int pvNTracks = trackparticles.size() ;
137  auto pvNTracks_m = Monitored::Scalar<int>( "m_PvNTracks", pvNTracks);
138  fill(pvGroup, pvNTracks_m);
139 
140 
141  // original tracks used for primary vertex
142  for (const auto & trackparticle : trackparticles)
143  {
144  const Trk::Perigee & measuredPerigee = (*trackparticle)->perigeeParameters();
145 
146  float pvTrackEta = measuredPerigee.eta() ;
147  auto pvTrackEta_m = Monitored::Scalar<float>( "m_PvTrackEta", pvTrackEta);
148  fill(pvGroup, pvTrackEta_m);
149 
150  float pvTrackPt = measuredPerigee.pT()/1000. ; // Histo is in GeV
151  auto pvTrackPt_m = Monitored::Scalar<float>( "m_PvTrackPt", pvTrackPt);
152  fill(pvGroup, pvTrackPt_m);
153 
154  }
155 
156  } // vxContainer
157 
158 
159  auto nPriVtx_m = Monitored::Scalar<int>( "m_nPriVtx", nPriVtx);
160  fill(pvGroup, nPriVtx_m);
161 
162  auto nPileupVtx_m = Monitored::Scalar<int>( "m_nPileupVtx", nPileupVtx);
163  fill(pvGroup, nPileupVtx_m);
164 
165 
166  // EnhancedMonitoring is OFF
167 
168 
169  //*******************************************************************************
170  //**************************** End of filling Track Histograms ******************
171  //*******************************************************************************
172 
173  return StatusCode::SUCCESS;
174 }
InDetGlobalPrimaryVertexMonAlg::fillHistograms
virtual StatusCode fillHistograms(const EventContext &ctx) const override
adds event to the monitoring histograms
Definition: InDetGlobalPrimaryVertexMonAlg.cxx:57
Trk::y
@ y
Definition: ParamDefs.h:56
Trk::z
@ z
global position (cartesian)
Definition: ParamDefs.h:57
InDetGlobalPrimaryVertexMonAlg::~InDetGlobalPrimaryVertexMonAlg
virtual ~InDetGlobalPrimaryVertexMonAlg()
Definition: InDetGlobalPrimaryVertexMonAlg.cxx:43
AthCommonDataStore< AthCommonMsg< Gaudi::Algorithm > >::declareProperty
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T > &t)
Definition: AthCommonDataStore.h:145
Trk::ParametersT
Dummy class used to allow special convertors to be called for surfaces owned by a detector element.
Definition: EMErrorDetail.h:25
EventPrimitivesHelpers.h
InDetGlobalPrimaryVertexMonAlg::InDetGlobalPrimaryVertexMonAlg
InDetGlobalPrimaryVertexMonAlg(const std::string &name, ISvcLocator *pSvcLocator)
Definition: InDetGlobalPrimaryVertexMonAlg.cxx:29
ParamDefs.h
AthMonitorAlgorithm
Base class for Athena Monitoring Algorithms.
Definition: AthMonitorAlgorithm.h:36
SG::makeHandle
SG::ReadCondHandle< T > makeHandle(const SG::ReadCondHandleKey< T > &key, const EventContext &ctx=Gaudi::Hive::currentContext())
Definition: ReadCondHandle.h:270
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
InDetGlobalPrimaryVertexMonAlg::m_distanceSplitVxMatch
float m_distanceSplitVxMatch
store maximum distance for matching split vertices to original non-BC vertex
Definition: InDetGlobalPrimaryVertexMonAlg.h:55
Monitored
Generic monitoring tool for athena components.
Definition: GenericMonitoringTool.h:30
InDetGlobalPrimaryVertexMonAlg::m_splitVertexTrkInvFraction
int m_splitVertexTrkInvFraction
store inverse of the fraction of input tracks used for probe vertex (1:N)
Definition: InDetGlobalPrimaryVertexMonAlg.h:54
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
xAOD::VxType::PriVtx
@ PriVtx
Primary vertex.
Definition: TrackingPrimitives.h:571
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
AthMonitorAlgorithm::fill
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.
InDetGlobalPrimaryVertexMonAlg::m_vxContainerName
SG::ReadHandleKey< xAOD::VertexContainer > m_vxContainerName
Definition: InDetGlobalPrimaryVertexMonAlg.h:51
xAOD::VxType::PileUp
@ PileUp
Pile-up vertex.
Definition: TrackingPrimitives.h:573
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:228
Amg::error
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 ...
Definition: EventPrimitivesHelpers.h:40
InDetGlobalPrimaryVertexMonAlg::m_splitMatchingMetric
int m_splitMatchingMetric
store metric to be used for split vertex matching in selection efficiency Values currently implemente...
Definition: InDetGlobalPrimaryVertexMonAlg.h:64
AthMonitorAlgorithm::initialize
virtual StatusCode initialize() override
initialize
Definition: AthMonitorAlgorithm.cxx:18
InDetGlobalPrimaryVertexMonAlg::initialize
virtual StatusCode initialize() override
initialize
Definition: InDetGlobalPrimaryVertexMonAlg.cxx:46
InDetGlobalPrimaryVertexMonAlg::m_doEnhancedMonitoring
bool m_doEnhancedMonitoring
Definition: InDetGlobalPrimaryVertexMonAlg.h:65
Monitored::Scalar
Declare a monitored scalar variable.
Definition: MonitoredScalar.h:34
Trk::x
@ x
Definition: ParamDefs.h:55
TrackParticleContainer.h
AthMonitorAlgorithm::getGroup
const ToolHandle< GenericMonitoringTool > & getGroup(const std::string &name) const
Get a specific monitoring tool from the tool handle array.
Definition: AthMonitorAlgorithm.cxx:164
InDetGlobalPrimaryVertexMonAlg.h