ATLAS Offline Software
Loading...
Searching...
No Matches
InDetPerfPlot_Vertex.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3*/
4
9
13#include "xAODTracking/Vertex.h"
19
20
21using namespace IDPVM;
22
23
24InDetPerfPlot_Vertex::InDetPerfPlot_Vertex(InDetPlotBase* pParent, const std::string& sDir, bool isITk) :
25 InDetPlotBase(pParent, sDir), m_isITk(isITk) {
26 // nop
27}
28
29void
31 book(m_vx_x,"vx_x");
32 book(m_vx_y,"vx_y");
33 book(m_vx_z,"vx_z");
34 if(m_isITk) book(m_vx_time,"vx_time");
35
36 book(m_vx_err_x,"vx_err_x");
37 book(m_vx_err_y,"vx_err_y");
38 book(m_vx_err_z,"vx_err_z");
39 if(m_isITk) book(m_vx_err_time,"vx_err_time");
40
41 book(m_vx_chi2_over_ndf,"vx_chi2_over_ndf");
42 book(m_vx_type,"vx_type");
43
44 book(m_vx_nTracks,"vx_nTracks");
45 book(m_vx_track_weights,"vx_track_weights");
46
47
48
49 if (m_iDetailLevel >= 100) {
50 book(m_vx_track_pt,"vx_track_pt");
51 book(m_vx_track_eta,"vx_track_eta");
52 book(m_vx_track_nSiHits,"vx_track_nSiHits");
53 book(m_vx_track_nSiHoles,"vx_track_nSiHoles");
54 book(m_vx_track_d0,"vx_track_d0");
55 book(m_vx_track_err_d0,"vx_track_err_d0");
56 book(m_vx_track_z0,"vx_track_z0");
57 book(m_vx_track_err_z0,"vx_track_err_z0");
58 }
59}
60
61void
62InDetPerfPlot_Vertex::fill(const xAOD::Vertex& vertex, float weight) {
63 // fill position plots
64 fillHisto(m_vx_x, vertex.x(), weight);
65 fillHisto(m_vx_y, vertex.y(), weight);
66 fillHisto(m_vx_z, vertex.z(), weight);
67
68 // fill error plots
69 const AmgSymMatrix(3)& covariance = vertex.covariancePosition();
70 fillHisto(m_vx_err_x, Amg::error(covariance, 0), weight);
71 fillHisto(m_vx_err_y, Amg::error(covariance, 1), weight);
72 fillHisto(m_vx_err_z, Amg::error(covariance, 2), weight);
73
74 if(m_isITk){
75 static const SG::AuxElement::Accessor<uint8_t> accHasValidTime("hasValidTime");
76 static const SG::AuxElement::Accessor<float> accTime("time");
77 if (accHasValidTime.isAvailable(vertex) && accTime.isAvailable(vertex)) {
78 if (vertex.hasValidTime()) {
79 fillHisto(m_vx_time, vertex.time(), weight);
80 }
81 }
82
83 static const SG::AuxElement::Accessor<float> accTimeResolution("timeResolution");
84 if (accHasValidTime.isAvailable(vertex) && accTimeResolution.isAvailable(vertex)) {
85 if (vertex.hasValidTime()) {
86 fillHisto(m_vx_err_time, vertex.timeResolution(), weight);
87 }
88 }
89 }
90
91 // fill vertex quality and type
92 fillHisto(m_vx_type, vertex.vertexType(), weight);
93
94 float ndf = vertex.numberDoF();
95 if (ndf != 0) {
96 fillHisto(m_vx_chi2_over_ndf, vertex.chiSquared() / ndf, weight);
97 } else {
98 fillHisto(m_vx_chi2_over_ndf, -1, weight);
99 }
100
101 // fill vertex tracks properties
102 int nTracks = vertex.nTrackParticles();
103 fillHisto(m_vx_nTracks, nTracks, weight);
104 for (const float& trackWeight : vertex.trackWeights()) {
105 fillHisto(m_vx_track_weights, trackWeight, weight);
106 }
107
108 // fill expert plots: tracks properties at vertex
109 if (m_iDetailLevel >= 100) {
110 // loop over tracks at vertex
111 for (const auto& elTrk : vertex.trackParticleLinks()) {
115 if (!elTrk.isValid()){
118 std::cerr << "Invalid track link on vertex. Vertex track plots will be unreliable. Please check your input format. "<<std::endl;
119 continue;
120 }
121 const xAOD::TrackParticle* trk = *elTrk;
122 fillHisto(m_vx_track_pt, trk->pt() / Gaudi::Units::GeV, weight); // MeV -> GeV
123 fillHisto(m_vx_track_eta, trk->eta(), weight);
124 const xAOD::ParametersCovMatrix_t covTrk = trk->definingParametersCovMatrix();
125 fillHisto(m_vx_track_d0, trk->d0(), weight);
126 fillHisto(m_vx_track_err_d0, Amg::error(covTrk, 0), weight);
127 fillHisto(m_vx_track_z0, trk->z0() - vertex.z(), weight);
128 fillHisto(m_vx_track_err_z0, Amg::error(covTrk, 1), weight);
129 bool successfulRetrieval(false);
130 uint8_t iPixHits, iSctHits, iPixHoles, iSctHoles;
131 successfulRetrieval = trk->summaryValue(iPixHits, xAOD::numberOfPixelHits);
132 successfulRetrieval &= trk->summaryValue(iSctHits, xAOD::numberOfSCTHits);
133 if (successfulRetrieval) {
134 fillHisto(m_vx_track_nSiHits, iPixHits + iSctHits, weight);
135 }
136 successfulRetrieval = trk->summaryValue(iPixHoles, xAOD::numberOfPixelHoles);
137 successfulRetrieval &= trk->summaryValue(iSctHoles, xAOD::numberOfSCTHoles);
138 if (successfulRetrieval) {
139 fillHisto(m_vx_track_nSiHoles, iPixHoles + iSctHoles, weight);
140 }
141 }
142 }
143}
#define AmgSymMatrix(dim)
TH1 * m_vx_track_z0
Tracks z0 (iDetailLevel >= 100)
TH1 * m_vx_track_err_z0
Tracks z0 error (iDetailLevel >= 100)
TH1 * m_vx_track_eta
Tracks eta (iDetailLevel >= 100)
TH1 * m_vx_track_d0
Tracks d0 (iDetailLevel >= 100)
TH1 * m_vx_track_pt
Tracks pT (iDetailLevel >= 100)
TH1 * m_vx_track_nSiHits
Tracks silicon hits (iDetailLevel >= 100)
TH1 * m_vx_track_nSiHoles
Tracks silicon holes (iDetailLevel >= 100)
TH1 * m_vx_track_weights
Distribution of tracks' weights.
TH1 * m_vx_track_err_d0
Tracks d0 error (iDetailLevel >= 100)
void fill(const xAOD::Vertex &vertex, float weight)
TH1 * m_vx_err_time
Error time.
InDetPerfPlot_Vertex(InDetPlotBase *pParent, const std::string &dirName, bool isITk)
static void fillHisto(TProfile *pTprofile, const float bin, const float weight, const float weight2=1.0)
void book(Htype *&pHisto, const std::string &histoIdentifier, const std::string &nameOverride="", const std::string &folder="default")
Helper method to book histograms using an identifier string.
InDetPlotBase(InDetPlotBase *pParent, const std::string &dirName)
Constructor taking parent node and directory name for plots.
int m_iDetailLevel
Definition PlotBase.h:101
SG::Accessor< T, ALLOC > Accessor
Definition AuxElement.h:572
bool isAvailable(const ELT &e) const
Test to see if this variable exists in the store.
float z0() const
Returns the parameter.
const ParametersCovMatrix_t definingParametersCovMatrix() const
Returns the 5x5 symmetric matrix containing the defining parameters covariance matrix.
float d0() const
Returns the parameter.
bool summaryValue(uint8_t &value, const SummaryType &information) const
Accessor for TrackSummary values.
virtual double pt() const override final
The transverse momentum ( ) of the particle.
virtual double eta() const override final
The pseudorapidity ( ) of the particle.
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 ...
Class to retrieve associated truth from a track, implementing a cached response.
TrackParticle_v1 TrackParticle
Reference the current persistent version:
Vertex_v1 Vertex
Define the latest version of the vertex class.
@ numberOfPixelHoles
number of pixel layers on track with absence of hits [unit8_t].
@ numberOfSCTHits
number of hits in SCT [unit8_t].
@ numberOfPixelHits
these are the pixel hits, including the b-layer [unit8_t].
@ numberOfSCTHoles
number of SCT holes [unit8_t].