ATLAS Offline Software
Loading...
Searching...
No Matches
MSVtxPlotMaker.h
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3*/
4
5#ifndef MSVTXPLOTMAKER_H
6#define MSVTXPLOTMAKER_H
7
8#include <memory>
9#include <string>
10
11#include "GaudiKernel/SystemOfUnits.h"
15
16#include "TTree.h"
17#include "TFile.h"
18#include "TSystem.h"
19
20#include "TROOT.h"
21#include "TStyle.h"
22
23#include "TCanvas.h"
24#include "TH1.h"
25#include "TH2.h"
26#include "THStack.h"
27#include "TEfficiency.h"
28#include "TGraphAsymmErrors.h"
29#include "TGraph.h"
30#include "TMultiGraph.h"
31
32#include "TMath.h"
33#include "TString.h"
34#include "TLatex.h"
35#include "TLegend.h"
36#include "TObjArray.h"
37#include "TObjString.h"
38
39
41 public:
42 MSVtxPlotMaker(const std::string &datapath, const std::string &pltdir, const std::string &treename="MSVtxValidTree");
43 virtual ~MSVtxPlotMaker();
44 void makePlots();
45
46 private:
47 // structs to pass a set of plots easier between functions
48
49 // number of vertices
50 struct NVtxTH1 {
51 TH1* h_Nvtx{nullptr};
52 TH1* h_Nvtx_b{nullptr};
53 TH1* h_Nvtx_e{nullptr};
54
57 };
58 // vertex position graphs
59 struct VtxPosTGraph {
60 TGraph* zLxy_b{nullptr};
61 TGraph* etaphi_b{nullptr};
62 TGraph* zLxy_e{nullptr};
63 TGraph* etaphi_e{nullptr};
64 TGraph* zLxy_out{nullptr};
65 TGraph* etaphi_out{nullptr};
66
69 };
70 // vertex position histograms
71 struct VtxPosTH {
72 TH2* h_zLxy{nullptr};
73 TH2* h_etaphi{nullptr};
74 TH1* h_distanceToIP{nullptr};
75
78 };
79 // vertex chi2 histograms
80 struct Chi2TH1 {
81 TH1* h_chi2{nullptr};
82 TH1* h_chi2nDoF{nullptr};
83 TH1* h_chi2prob{nullptr};
84
87 };
88 // angular distances histograms between vertex and its constituents
90 TH1* h_dR{nullptr};
91 TH1* h_dRmax{nullptr};
92 TH1* h_dphimax{nullptr};
93 TH1* h_detamax{nullptr};
94
97 };
98 // residuals between reconstructed and matched truth vertices
116 // hits near the vertex
117 struct NHitsTH1 {
118 TH1* h_total{nullptr};
119 TH1* h_I{nullptr};
120 TH1* h_M{nullptr};
121 TH1* h_O{nullptr};
122 TH1* h_inwardsTotal{nullptr};
123 TH1* h_IM{nullptr};
124 TH1* h_IO{nullptr};
125 TH1* h_MO{nullptr};
126
127 NHitsTH1(TH1* h_total, TH1* h_I, TH1* h_M, TH1* h_O, TH1* h_inwardsTotal, TH1* h_IM, TH1* h_IO, TH1* h_MO)
129 };
130 // TH1s for different vertex efficiency and purity plot
131 struct EffInputTH1 {
132 TH1* h_Lxy{nullptr};
133 TH1* h_distanceToIP_b{nullptr};
134 TH1* h_z{nullptr};
135 TH1* h_distanceToIP_e{nullptr};
136 TH1* h_eta{nullptr};
137
140 };
141
142
143 // core functions
144 void setup();
145 void setPlotStyle();
146 void formatPlots();
147 void fillPlots();
148 void outputResults();
149 // helper functions to setup branches and declare plots
150 void setupBranches();
151 void formatTGraphs();
152 // main filling functions
153 void fillTruthVtxPlots(const std::vector<Amg::Vector3D> &truth_vertices);
155 void fillRecoVtxPlots(const std::vector<Amg::Vector3D> &reco_vertices, const std::vector<std::vector<Amg::Vector3D>> &reco_constituentPos);
156 void fillTruthComparisonHists(const std::vector<Amg::Vector3D> &reco_vertices, const std::vector<Amg::Vector3D> &truth_vertices);
157 void fillEfficiency_NumeratorDenominatorHists(const std::vector<Amg::Vector3D> &vertices, const std::vector<Amg::Vector3D> &match_candidates,
158 std::unique_ptr<EffInputTH1> &denomHists, std::unique_ptr<EffInputTH1> &numHists);
159 // helper filling functions
160 void fillNvtxHists(const std::vector<Amg::Vector3D> &vertices, std::unique_ptr<NVtxTH1> &hists);
161 void fillVtxPosMaps(const std::vector<Amg::Vector3D> &vertices, std::unique_ptr<VtxPosTGraph> &graphs);
162 void fillVtxPosHists(const std::vector<Amg::Vector3D> &vertices, std::unique_ptr<VtxPosTH> &hists);
163 void fillChi2Hists(double chi2, double NDoF, std::unique_ptr<Chi2TH1> &hists);
164 void fillAngularVtxConstiHists(const Amg::Vector3D &vtx, const std::vector<Amg::Vector3D> &consti, std::unique_ptr<AngularVtxConstiTH1> &hists);
165 void fillVtxNhitsHists(double total, double inwards, double inner, double middle, double outer, std::unique_ptr<NHitsTH1> &hists);
166 void fillResidualHists(double eta, double dR, double d_theta, double d_phi, double d_Lxy, double d_z, double d_phys, std::unique_ptr<ResidualTH1> &hists);
167 void fillVtxPosFiducialVolHists(const Amg::Vector3D &vtx, std::unique_ptr<EffInputTH1> &hists);
168 // saving plots
169 void saveVtxPos(std::unique_ptr<VtxPosTH> &hists, const TString &plotdir);
170 void saveTGraph(TMultiGraph* zLxy, TMultiGraph* etaphi, std::unique_ptr<VtxPosTGraph> &graphs, const TString &plotdir);
171 void saveTH1(TH1* h, TString plotpath, const char* dectectorLabel="", const char* new_ylabel=nullptr, bool norm=false, bool logy=false);
172 void saveTHStack(TH1* h1, TH1* h2, const TString &h1_legend, const TString &h2_legend, const TString &title, const TString &plotpath, int color1=2, int color2=1);
173 void saveTEfficiency(TH1* h_num, TH1* h_denom, const TString &title, const TString &plotpath);
174 void saveTH2(TH2* h, const TString &plotpath);
175 // other helper functions
176 void setColorPalette(TStyle *plotStyle);
177 TH1* getUnmatchedHist(TH1* h_all, TH1* h_matched, const TString &name_unmatched);
178
179
180 // input/output variables
181 std::string m_datapath{};
182 std::string m_treename{};
183 TString m_plotdir{};
191 TTree* m_tree{nullptr}; // TTree is attached to the input file i.e. no smart pointer needed
192 std::unique_ptr<TFile> m_input_file{nullptr};
193 std::unique_ptr<TFile> m_output_file{nullptr};
194 std::unique_ptr<TCanvas> m_c{nullptr};
195
196 // branches
197 std::vector<double>* m_truthVtx_x{nullptr};
198 std::vector<double>* m_truthVtx_y{nullptr};
199 std::vector<double>* m_truthVtx_z{nullptr};
200
201 std::vector<double>* m_msVtx_chi2{nullptr};
202 std::vector<int>* m_msVtx_Ntrklet{nullptr};
203 std::vector<double>* m_msVtx_x{nullptr};
204 std::vector<double>* m_msVtx_y{nullptr};
205 std::vector<double>* m_msVtx_z{nullptr};
206 std::vector<int>* m_msVtx_nMDT{nullptr};
207 std::vector<int>* m_msVtx_nMDT_inwards{nullptr};
208 std::vector<int>* m_msVtx_nMDT_I{nullptr};
209 std::vector<int>* m_msVtx_nMDT_M{nullptr};
210 std::vector<int>* m_msVtx_nMDT_O{nullptr};
211 std::vector<int>* m_msVtx_nRPC{nullptr};
212 std::vector<int>* m_msVtx_nRPC_inwards{nullptr};
213 std::vector<int>* m_msVtx_nRPC_I{nullptr};
214 std::vector<int>* m_msVtx_nRPC_M{nullptr};
215 std::vector<int>* m_msVtx_nRPC_O{nullptr};
216 std::vector<int>* m_msVtx_nTGC{nullptr};
217 std::vector<int>* m_msVtx_nTGC_inwards{nullptr};
218 std::vector<int>* m_msVtx_nTGC_I{nullptr};
219 std::vector<int>* m_msVtx_nTGC_M{nullptr};
220 std::vector<int>* m_msVtx_nTGC_O{nullptr};
221
222 std::vector<double>* m_obj_x{nullptr};
223 std::vector<double>* m_obj_y{nullptr};
224 std::vector<double>* m_obj_z{nullptr};
225 std::vector<double>* m_obj_phi{nullptr};
226 std::vector<double>* m_obj_theta{nullptr};
227 std::vector<double>* m_obj_eta{nullptr};
228 std::vector<int>* m_obj_vtxLink{nullptr};
229
230
231 // histograms and graphs
232
233 // truth vertices
234 // number of vertices per event
235 TH1* m_h_Nvtx_truth = new TH1D("Nvtx_truth", "Nvtx_truth; Number of truth vertices in the barrel or endcaps; Events / bin", 4, 0, 4);
236 TH1* m_h_Nvtx_truth_b = new TH1D("Nvtx_truth_b", "Nvtx_truth_b; Number of truth vertices in the barrel; Events / bin", 4, 0, 4);
237 TH1* m_h_Nvtx_truth_e = new TH1D("Nvtx_truth_e", "Nvtx_truth_e; Number of truth vertices in the endcaps; Events / bin", 4, 0, 4);
238 // position 2D maps: TMultiGraph is composed of TGraphs for vertices in the barrel, the endcaps or in neither (outside the detector region)
239 // Lxy-z map
240 TMultiGraph* m_zLxy_truth = new TMultiGraph("zLxy_mg_truth", "zLxy_mg_truth");
241 TGraph* m_zLxy_truth_b = new TGraph();
242 TGraph* m_zLxy_truth_e = new TGraph();
243 TGraph* m_zLxy_truth_out = new TGraph();
244 // eta-phi map
245 TMultiGraph* m_etaphi_truth = new TMultiGraph("etaphi_mg_truth", "etaphi_mg_truth");
246 TGraph* m_etaphi_truth_b = new TGraph();
247 TGraph* m_etaphi_truth_e = new TGraph();
248 TGraph* m_etaphi_truth_out = new TGraph();
249 // position 1D histograms
250 TH1* m_h_distanceToIP_truth = new TH1D("distanceToIP_truth", "distanceToIP_truth; Truth vertex |#bf{r}| [m]; Vertices / bin", 50, 0, 20);
251 // position 2D histograms
252 TH2* m_h_zLxy_truth = new TH2D("zLxy_truth", "zLxy_truth; Truth vertex z [m]; Truth vertex L_{xy} [m]", 128, -16, 16, 52, -1, 12);
253 TH2* m_h_etaphi_truth = new TH2D("etaphi_truth", "etaphi_truth; Truth vertex #kern[-1.0]{ #eta}; Truth vertex #kern[-1.0]{ #phi} [rad]", 80, -2.6, 2.6, 40, -TMath::Pi(), TMath::Pi()+1);
254
255 // reconstructed vertices
256 // number per event
257 TH1* m_h_Nvtx = new TH1D("Nvtx", "Nvtx; Number of reco vertices in barrel or endcaps; Events / bin", 3, 0, 3);
258 TH1* m_h_Nvtx_b = new TH1D("Nvtx_b", "Nvtx_b; Number of reco vertices in the barrel; Events / bin", 3, 0, 3);
259 TH1* m_h_Nvtx_e = new TH1D("Nvtx_e", "Nvtx_e; Number of reco vertices in the endcaps; Events / bin", 3, 0, 3);
260 // position 2D maps: TMultiGraph is composed of TGraphs for vertices in the barrel, the endcaps or in neither (outside the detector region)
261 // Lxy-z map of reconstructed vertices
262 TMultiGraph* m_zLxy = new TMultiGraph("zLxy_mg", "zLxy_mg");
263 TGraph* m_zLxy_b = new TGraph();
264 TGraph* m_zLxy_e = new TGraph();
265 TGraph* m_zLxy_out = new TGraph();
266 // eta-phi map of reconstructed vertices
267 TMultiGraph* m_etaphi = new TMultiGraph("etaphi_mg", "etaphi_mg");
268 TGraph* m_etaphi_b = new TGraph();
269 TGraph* m_etaphi_e = new TGraph();
270 TGraph* m_etaphi_out = new TGraph();
271 // position 1D histograms
272 TH1* m_h_distanceToIP = new TH1D("distanceToIP", "distanceToIP; Reco vertex |#bf{r}| [m]; Vertices / bin", 50, 0, 20);
273 // position 2D histograms
274 TH2* m_h_zLxy = new TH2D("zLxy", "zLxy; Reco vertex z [m]; Reco vertex L_{xy} [m]", 128, -16, 16, 52, -1, 12);
275 TH2* m_h_etaphi = new TH2D("etaphi", "etaphi; Reco vertex #kern[-1.0]{ #eta}; Reco vertex #kern[-1.0]{ #phi} [rad]", 80, -2.6, 2.6, 40, -TMath::Pi(), TMath::Pi()+1);
276 // chi2, chi2 per degree of freedom, and chi2 probability of vertex
277 TH1* m_h_chi2_b = new TH1D("chi2_b", "chi2_b; Reco vertex #chi^{2}; Vertices / bin", 100, 0, 10);
278 TH1* m_h_chi2_e = new TH1D("chi2_e", "chi2_e; Reco vertex #chi^{2}; Vertices / bin", 100, 0, 10);
279 TH1* m_h_chi2nDoF_b = new TH1D("chi2nDoF_b", "chi2nDoF_b; Reco vertex #chi^{2}/n_{DoF}; Vertices / bin", 100, 0, 5);
280 TH1* m_h_chi2nDoF_e = new TH1D("chi2nDoF_e", "chi2nDoF_e; Reco vertex #chi^{2}/n_{DoF}; Vertices / bin", 100, 0, 5);
281 TH1* m_h_chi2prob_b = new TH1D("chi2_prob_b", "chi2_prob_b; Reco vertex #chi^{2} probability; Vertices / bin", 100, 0, 1);
282 TH1* m_h_chi2prob_e = new TH1D("chi2_prob_e", "chi2_prob_e; Reco vertex #chi^{2} probability; Vertices / bin", 100, 0, 1);
283 // number of constituents
284 TH1* m_h_Nconsti_b = new TH1D("Nconstituents_b", "Nconstituents_b; Reco vertex number of constituents; Vertices / bin", 39, 1, 40);
285 TH1* m_h_Nconsti_e = new TH1D("Nconstituents_e", "Nconstituents_e; Reco vertex number of constituents; Vertices / bin", 39, 1, 40);
286 // delta R to constituents
287 TH1* m_h_VtxConsti_dR_b = new TH1D("VtxConsti_dR_b", "VtxConsti_dR_b; #Delta R(reco vtx, constituent); Number of vertex-constituent pairs / bin", 100, 0, 3);
288 TH1* m_h_VtxConsti_dRmax_b = new TH1D("VtxConsti_dRmax_b", "VtxConsti_dRmax_b; max #kern[-0.3]{#Delta } #kern[-0.2]{ R(reco vtx, constituent)}; Vertices / bin", 50, 0, 3);
289 TH1* m_h_VtxConsti_dphimax_b = new TH1D("VtxConsti_dphimax_b", "VtxConsti_dphimax_b; max #kern[-0.3]{#Delta } #kern[-0.3]{ #phi (reco vtx, constituent)}; Vertices / bin", 50, -2.5, 2.5);
290 TH1* m_h_VtxConsti_detamax_b = new TH1D("VtxConsti_detamax_b", "VtxConsti_detamax_b; max #kern[-0.3]{#Delta } #kern[-0.3]{ #eta (reco vtx, constituent)}; Vertices / bin", 50, -1.0, 1.0);
291 TH1* m_h_VtxConsti_dR_e = new TH1D("VtxConsti_dR_e", "VtxConsti_dR_e; #Delta R(reco vtx, constituent); Number of vertex-constituent pairs / bin", 100, 0, 3);
292 TH1* m_h_VtxConsti_dRmax_e = new TH1D("VtxConsti_dRmax_e", "VtxConsti_dRmax_e; max #kern[-0.3]{#Delta } #kern[-0.2]{ R(reco vtx, constituent)}; Vertices / bin", 50, 0, 3);
293 TH1* m_h_VtxConsti_dphimax_e = new TH1D("VtxConsti_dphimax_e", "VtxConsti_dphimax_e; max #kern[-0.3]{#Delta } #kern[-0.3]{ #phi (reco vtx, constituent)}; Vertices / bin", 50, -2.5, 2.5);
294 TH1* m_h_VtxConsti_detamax_e = new TH1D("VtxConsti_detamax_e", "VtxConsti_detamax_e; max #kern[-0.3]{#Delta } #kern[-0.3]{ #eta (reco vtx, constituent)}; Vertices / bin", 50, -1.0, 1.0);
295
296 // hits near the vertex (not necessarily used for the reconstruction)
297 // total and split by layer
298 // fraction that are further inwards than the vertex,
299 // rations by layer: inner/middle, inner/outer, middle/outer
300 // MDT
301 TH1* m_h_nMDT_b = new TH1D("nMDT_b", "nMDT_b; Number of MDT hits near the reco vertex; Vertices / bin", 100, 0, 4000);
302 TH1* m_h_nMDT_e = new TH1D("nMDT_e", "nMDT_e; Number of MDT hits near the reco vertex; Vertices / bin", 100, 0, 4000);
303 TH1* m_h_nMDT_I_b = new TH1D("nMDT_I_b", "nMDT_I_b; Number of inner layer MDT hits near the reco vertex; Vertices / bin", 100, 0, 1000);
304 TH1* m_h_nMDT_I_e = new TH1D("nMDT_I_e", "nMDT_I_e; Number of inner layer MDT hits near the reco vertex; Vertices / bin", 100, 0, 1000);
305 TH1* m_h_nMDT_M_b = new TH1D("nMDT_M_b", "nMDT_M_b; Number of middle layer MDT hits near the reco vertex; Vertices / bin", 100, 0, 2500);
306 TH1* m_h_nMDT_M_e = new TH1D("nMDT_M_e", "nMDT_M_e; Number of middle layer MDT hits near the reco vertex; Vertices / bin", 100, 0, 2500);
307 TH1* m_h_nMDT_O_b = new TH1D("nMDT_O_b", "nMDT_O_b; Number of outer layer MDT hits near the reco vertex; Vertices / bin", 100, 0, 2500);
308 TH1* m_h_nMDT_O_e = new TH1D("nMDT_O_e", "nMDT_O_e; Number of outer layer MDT hits near the reco vertex; Vertices / bin", 100, 0, 2500);
309 TH1* m_h_nMDT_InwardsTotal_b = new TH1D("nMDT_InwardsTotal_b", "nMDT_InwardsTotal_b; fraction of MDT hits inwards of the reco vertex; Vertices / bin", 100, 0, 3);
310 TH1* m_h_nMDT_InwardsTotal_e = new TH1D("nMDT_InwardsTotal_e", "nMDT_InwardsTotal_e; fraction of MDT hits inwards of the reco vertex; Vertices / bin", 100, 0, 3);
311 TH1* m_h_nMDT_IM_b = new TH1D("nMDT_IM_b", "nMDT_IM_b; Reco vertex inner/middle layer MDT hits; Vertices / bin", 100, 0, 3);
312 TH1* m_h_nMDT_IM_e = new TH1D("nMDT_IM_e", "nMDT_IM_e; Reco vertex inner/middle layer MDT hits; Vertices / bin", 100, 0, 3);
313 TH1* m_h_nMDT_IO_b = new TH1D("nMDT_IO_b", "nMDT_IO_b; Reco vertex inner/outer layer MDT hits; Vertices / bin", 100, 0, 3);
314 TH1* m_h_nMDT_IO_e = new TH1D("nMDT_IO_e", "nMDT_IO_e; Reco vertex inner/outer layer MDT hits; Vertices / bin", 100, 0, 3);
315 TH1* m_h_nMDT_MO_b = new TH1D("nMDT_MO_b", "nMDT_MO_b; Reco vertex middle/outer layer MDT hits; Vertices / bin", 100, 0, 3);
316 TH1* m_h_nMDT_MO_e = new TH1D("nMDT_MO_e", "nMDT_MO_e; Reco vertex middle/outer layer MDT hits; Vertices / bin", 100, 0, 3);
317 // RPC
318 TH1* m_h_nRPC = new TH1D("nRPC", "nRPC_e; Number of RPC hits near the reco vertex; Vertices / bin", 50, 0, 1500);
319 TH1* m_h_nRPC_I = new TH1D("nRPC_I", "nRPC_I_e; Number of inner layer RPC hits near the reco vertex; Vertices / bin", 50, 0, 500);
320 TH1* m_h_nRPC_M = new TH1D("nRPC_M", "nRPC_M_e; Number of middle layer RPC hits near the reco vertex; Vertices / bin", 50, 0, 1000);
321 TH1* m_h_nRPC_O = new TH1D("nRPC_O", "nRPC_O_e; Number of outer layer RPC hits near the reco vertex; Vertices / bin", 50, 0, 1000);
322 TH1* m_h_nRPC_InwardsTotal = new TH1D("nRPC_InwardsTotal", "nRPC_InwardsTotal_e; fraction of RPC hits inwards of the reco vertex; Vertices / bin", 50, 0, 1);
323 TH1* m_h_nRPC_IM = new TH1D("nRPC_IM", "nRPC_IM_e; Reco vertex inner/middle layer RPC hits; Vertices / bin", 50, 0, 3);
324 TH1* m_h_nRPC_IO = new TH1D("nRPC_IO", "nRPC_IO_e; Reco vertex inner/outer layer RPC hits; Vertices / bin", 50, 0, 3);
325 TH1* m_h_nRPC_MO = new TH1D("nRPC_MO", "nRPC_MO_e; Reco vertex middle/outer layer RPC hits; Vertices / bin", 50, 0, 3);
326 // TGC
327 TH1* m_h_nTGC = new TH1D("nTGC", "nTGC_e; Number of TGC hits near the reco vertex; Vertices / bin", 50, 0, 1500);
328 TH1* m_h_nTGC_I = new TH1D("nTGC_I", "nTGC_I_e; Number of inner layer TGC hits near the reco vertex; Vertices / bin", 50, 0, 500);
329 TH1* m_h_nTGC_M = new TH1D("nTGC_M", "nTGC_M_e; Number of middle layer TGC hits near the reco vertex; Vertices / bin", 50, 0, 1000);
330 TH1* m_h_nTGC_O = new TH1D("nTGC_O", "nTGC_O_e; Number of outer layer TGC hits near the reco vertex; Vertices / bin", 50, 0, 1000);
331 TH1* m_h_nTGC_InwardsTotal = new TH1D("nTGC_InwardsTotal", "nTGC_InwardsTotal_e; fraction of TGC hits inwards of the reco vertex; Vertices / bin", 50, 0, 1);
332 TH1* m_h_nTGC_IM = new TH1D("nTGC_IM", "nTGC_IM_e; Reco vertex inner/middle layer TGC hits; Vertices / bin", 50, 0, 3);
333 TH1* m_h_nTGC_IO = new TH1D("nTGC_IO", "nTGC_IO_e; Reco vertex inner/outer layer TGC hits; Vertices / bin", 50, 0, 3);
334 TH1* m_h_nTGC_MO = new TH1D("nTGC_MO", "nTGC_MO_e; Reco vertex middle/outer layer TGC hits; Vertices / bin", 50, 0, 3);
335
336 // objects available and used for reconstruction
337 // number per event
338 TH1* m_h_Nobj = new TH1D("Nobj", "Nobj; Number of objects; Events / bin", 20, 0, 20);
339 TH1* m_h_Nobj_b = new TH1D("Nobj_b", "Nobj_b; Number of objects in the barrel; Events / bin", 20, 0, 20);
340 TH1* m_h_Nobj_e = new TH1D("Nobj_e", "Nobj_e; Number of objects in the endcaps; Events / bin", 20, 0, 20);
341 TH1* m_h_NobjReco = new TH1D("objN_reco", "objN_reco; Number of objects used for reconstruction in the barrel; Events / bin", 20, 0, 20);
342 TH1* m_h_NobjReco_b = new TH1D("objN_reco_b", "objN_reco_b; Number of objects used for reconstruction in the barrel; Events / bin", 20, 0, 20);
343 TH1* m_h_NobjReco_e = new TH1D("objN_reco_e", "objN_reco_e; Number of objects used for reconstruction in the endcaps; Events / bin", 20, 0, 20);
344 // position
345 TH1* m_h_obj_phi_b = new TH1D("objPhi_b", "objPhi_b; Object #kern[-0.05]{#phi in the barrel}; Objects / bin", 100, -TMath::Pi(), TMath::Pi());
346 TH1* m_h_obj_phi_e = new TH1D("objPhi_e", "objPhi_e; Object #kern[-0.05]{#phi in the endcaps}; Objects / bin", 100, -TMath::Pi(), TMath::Pi());
347 TH1* m_h_obj_eta = new TH1D("objEta", "objEta; Object #eta; Objects / bin", 50, -2.7, 2.7);
348 TH1* m_h_objReco_phi_b = new TH1D("objPhi_reco_b", "objPhi_reco_b; Object #kern[-0.04]{#phi used for reconstruction in the barrel}; Objects / bin", 100, -TMath::Pi(), TMath::Pi());
349 TH1* m_h_objReco_phi_e = new TH1D("objPhi_reco_e", "objPhi_reco_e; Object #kern[-0.04]{#phi used for reconstruction in the endcaps}; Objects / bin", 100, -TMath::Pi(), TMath::Pi());
350 TH1* m_h_objReco_eta = new TH1D("objEta_reco", "objEta_reco; Object #kern[-0.06]{#eta used for reconstruction}; Objects / bin", 50, -2.7, 2.7);
351
352 // residuals between reconstructed and the matched truth vertex.
353 TH1* m_h_delta_R_b = new TH1D("delta_R_b", "delta_R; #Delta R(reco Vtx, truth Vtx); Vertices / bin", 50, 0, 0.5);
354 TH1* m_h_delta_R_e = new TH1D("delta_R_e", "delta_R; #Delta R(reco Vtx, truth Vtx); Vertices / bin", 50, 0, 0.5);
355 TH1* m_h_delta_theta_b = new TH1D("delta_theta_b", "delta_theta; #theta_{reco} - #theta_{truth} [rad]; Vertices / 0.01 rad", 100, -0.5, 0.5);
356 TH1* m_h_delta_theta_e = new TH1D("delta_theta_e", "delta_theta; #theta_{reco} - #theta_{truth} [rad]; Vertices / 0.01 rad", 100, -0.5, 0.5);
357 TH1* m_h_delta_phi_b = new TH1D("delta_phi_b", "delta_phi; #phi_{reco} - #phi_{truth} [rad]; Vertices / 0.02 rad", 50, -0.5, 0.5);
358 TH1* m_h_delta_phi_e = new TH1D("delta_phi_e", "delta_phi; #phi_{reco} - #phi_{truth} [rad]; Vertices / 0.02 rad", 50, -0.5, 0.5);
359 TH1* m_h_delta_Lxy_b = new TH1D("delta_Lxy_b", "delta_Lxy; L_{xy}^{reco} - L_{xy}^{truth} [cm]; Vertices / 10 cm", 100, -500, 500);
360 TH1* m_h_delta_Lxy_e = new TH1D("delta_Lxy_e", "delta_Lxy; L_{xy}^{reco} - L_{xy}^{truth} [cm]; Vertices / 10 cm", 100, -500, 500);
361 TH1* m_h_delta_z_b = new TH1D("delta_z_b", "delta_z; z_{reco} - z_{truth} [cm]; Vertices / 10 cm", 100, -500, 500);
362 TH1* m_h_delta_z_e = new TH1D("delta_z_e", "delta_z; z_{reco} - z_{truth} [cm]; Vertices / 10 cm", 100, -500, 500);
363 TH1* m_h_delta_phys_b = new TH1D("delta_phys_b", "delta_phys; |#bf{r}_{reco} - #bf{r}_{truth}| [cm]; Vertices / 10 cm", 50, 0, 500);
364 TH1* m_h_delta_phys_e = new TH1D("delta_phys_e", "delta_phys; |#bf{r}_{reco} - #bf{r}_{truth}| [cm]; Vertices / 10 cm", 75, 0, 750);
365 // split into positve and negative eta
366 TH1* m_h_delta_Lxy_posEta_b = new TH1D("delta_Lxy_posEta_b", "delta_Lxy; L_{xy}^{reco} - L_{xy}^{truth} [cm]; Vertices / 10 cm", 100, -500, 500);
367 TH1* m_h_delta_Lxy_posEta_e = new TH1D("delta_Lxy_posEta_e", "delta_Lxy; L_{xy}^{reco} - L_{xy}^{truth} [cm]; Vertices / 10 cm", 100, -500, 500);
368 TH1* m_h_delta_Lxy_negEta_b = new TH1D("delta_Lxy_negEta_b", "delta_Lxy; L_{xy}^{reco} - L_{xy}^{truth} [cm]; Vertices / 10 cm", 100, -500, 500);
369 TH1* m_h_delta_Lxy_negEta_e = new TH1D("delta_Lxy_negEta_e", "delta_Lxy; L_{xy}^{reco} - L_{xy}^{truth} [cm]; Vertices / 10 cm", 100, -500, 500);
370 TH1* m_h_delta_z_posEta_b = new TH1D("delta_z_posEta_b", "delta_z; z_{reco} - z_{truth} [cm]; Vertices / 10 cm", 100, -500, 500);
371 TH1* m_h_delta_z_negEta_b = new TH1D("delta_z_negEta_b", "delta_z; z_{reco} - z_{truth} [cm]; Vertices / 10 cm", 100, -500, 500);
372 TH1* m_h_delta_z_posEta_e = new TH1D("delta_z_posEta_e", "delta_z; z_{reco} - z_{truth} [cm]; Vertices / 10 cm", 100, -500, 500);
373 TH1* m_h_delta_z_negEta_e = new TH1D("delta_z_negEta_e", "delta_z; z_{reco} - z_{truth} [cm]; Vertices / 10 cm", 100, -500, 500);
374
375 // histograms for efficiency and fake rate calculations
376 // m_h_<vtx type>_<binning variable> contains all reco or truth vertices
377 // m_h_<vtx type 1>_<vtx type 2>_<binning variable> contains all vertices of type <vtx type 1> that can be matched to a vertex of type <vtx type 2>
378 // barrel vertices, binned in the transverse truth decay position
379 TH1* m_h_Reco_Lxy_b = new TH1D("vReco_Lxy_b", "reco vertex b; Reco vertex L_{xy} [m]; Vertices / bin", 30, 0, 9);
380 TH1* m_h_RecoTruth_Lxy_b = new TH1D("RecoTruth_Lxy_b", "reco vertex matched to truth in the barrel; Reco vertex L_{xy} [m]; Vertices / bin", 30, 0, 9);
381 TH1* m_h_Truth_Lxy_b = new TH1D("Truth_Lxy_b", "truth vertex b; Truth vertex L_{xy} [m]; Truth vertices / bin", 30, 0, 9);
382 TH1* m_h_TruthReco_Lxy_b = new TH1D("TruthReco_Lxy_b", "truth vertex matched to reco in the barrel; Truth vertex L_{xy} [m]; Vertices / bin", 30, 0, 9);
383 // endcap vertices, binned in z truth decay position
384 TH1* m_h_Reco_z_e = new TH1D("Reco_z_e", "reco vertex z; Reco vertex |z| [m]; Vertices / bin", 40, 0, 16);
385 TH1* m_h_RecoTruth_z_e = new TH1D("RecoTruth_z_e", "reco vertex z matched to truth in the endcaps; Reco vertex |z| [m]; Vertices / bin", 40, 0, 16);
386 TH1* m_h_Truth_z_e = new TH1D("Truth_z_e", "truth vertex z; Truth vertex |z| [m]; Truth vertices / bin", 40, 0, 16);
387 TH1* m_h_TruthReco_z_e = new TH1D("TruthReco_z_e", "truth vertex z matched to reco in the endcaps; Truth vertex |z| [m]; Vertices / bin", 40, 0, 16);
388 // binned in eta
389 TH1* m_h_Reco_eta = new TH1D("Reco_eta", "reco vertex eta; Reco vertex #eta; Vertices / bin", 30, -3, 3);
390 TH1* m_h_RecoTruth_eta = new TH1D("RecoTruth_eta", "reco vertex matched to truth; Reco vertex #eta; Vertices / bin", 30, -3, 3);
391 TH1* m_h_Truth_eta = new TH1D("Truth_eta", "truth vertex eta; Truth vertex #eta; Truth vertices / bin", 30, -3, 3);
392 TH1* m_h_TruthReco_eta = new TH1D("TruthReco_eta", "truth vertex matched to reco; Truth vertex #eta; Vertices / bin", 30, -3, 3);
393 // barrel vertices, binned in distance from IP
394 TH1* m_h_Reco_r_b = new TH1D("Reco_r_b", "reco vertex r; Reco vertex |#bf{r}| [m]; Vertices / bin", 60, 0, 18);
395 TH1* m_h_RecoTruth_r_b = new TH1D("RecoTruth_r_b", "reco vertex matched to truth; Reco vertex |#bf{r}| [m]; Vertices / bin", 60, 0, 18);
396 TH1* m_h_Truth_r_b = new TH1D("Truth_r_b", "truth vertex r; Truth vertex |#bf{r}| [m]; Truth vertices / bin", 60, 0, 18);
397 TH1* m_h_TruthReco_r_b = new TH1D("TruthReco_r_b", "truth vertex matched to reco; Truth vertex |#bf{r}| [m]; Vertices / bin", 60, 0, 18);
398 // endcap vertices, binned in distance from IP
399 TH1* m_h_Reco_r_e = new TH1D("Reco_r_e", "reco vertex r; Reco vertex |#bf{r}| [m]; Vertices / bin", 60, 0, 18);
400 TH1* m_h_RecoTruth_r_e = new TH1D("RecoTruth_r_e", "reco vertex matched to truth; Reco vertex |#bf{r}| [m]; Vertices / bin", 60, 0, 18);
401 TH1* m_h_Truth_r_e = new TH1D("Truth_r_e", "truth vertex r; Truth vertex |#bf{r}| [m]; Truth vertices / bin", 60, 0, 18);
402 TH1* m_h_TruthReco_r_e = new TH1D("TruthReco_r_e", "truth vertex matched to reco; Truth vertex |#bf{r}| [m]; Vertices / bin", 60, 0, 18);
403
404
405 // bind the plots into structs for easier passing between functions
406 // std::unique_ptr<NVtxTH1> m_h_NVtx_truth = std::make_unique<NVtxTH1>();
407 std::unique_ptr<NVtxTH1> m_h_NVtx_truth = std::make_unique<NVtxTH1>(m_h_Nvtx_truth, m_h_Nvtx_truth_b, m_h_Nvtx_truth_e);
408 std::unique_ptr<NVtxTH1> m_h_NVtx = std::make_unique<NVtxTH1>(m_h_Nvtx, m_h_Nvtx_b, m_h_Nvtx_e);
409
410 std::unique_ptr<VtxPosTGraph> m_h_VtxPos = std::make_unique<VtxPosTGraph>(m_zLxy_b, m_etaphi_b, m_zLxy_e, m_etaphi_e, m_zLxy_out, m_etaphi_out);
411 std::unique_ptr<VtxPosTGraph> m_h_VtxPos_truth = std::make_unique<VtxPosTGraph>(m_zLxy_truth_b, m_etaphi_truth_b, m_zLxy_truth_e, m_etaphi_truth_e, m_zLxy_truth_out, m_etaphi_truth_out);
412 std::unique_ptr<VtxPosTH> m_h_VtxPosHists = std::make_unique<VtxPosTH>(m_h_zLxy, m_h_etaphi, m_h_distanceToIP);
413 std::unique_ptr<VtxPosTH> m_h_VtxPosHists_truth = std::make_unique<VtxPosTH>(m_h_zLxy_truth, m_h_etaphi_truth, m_h_distanceToIP_truth);
414
415 std::unique_ptr<Chi2TH1> m_h_VtxChi2_b = std::make_unique<Chi2TH1>(m_h_chi2_b, m_h_chi2nDoF_b, m_h_chi2prob_b);
416 std::unique_ptr<Chi2TH1> m_h_VtxChi2_e = std::make_unique<Chi2TH1>(m_h_chi2_e, m_h_chi2nDoF_e, m_h_chi2prob_e);
417
418 std::unique_ptr<AngularVtxConstiTH1> m_h_AngularVtxConsti_b = std::make_unique<AngularVtxConstiTH1>(m_h_VtxConsti_dR_b, m_h_VtxConsti_dRmax_b, m_h_VtxConsti_dphimax_b, m_h_VtxConsti_detamax_b);
419 std::unique_ptr<AngularVtxConstiTH1> m_h_AngularVtxConsti_e = std::make_unique<AngularVtxConstiTH1>(m_h_VtxConsti_dR_e, m_h_VtxConsti_dRmax_e, m_h_VtxConsti_dphimax_e, m_h_VtxConsti_detamax_e);
420
425 std::unique_ptr<NHitsTH1> m_h_Nhits_RPC = std::make_unique<NHitsTH1>(m_h_nRPC, m_h_nRPC_I, m_h_nRPC_M, m_h_nRPC_O, m_h_nRPC_InwardsTotal, m_h_nRPC_IM, m_h_nRPC_IO, m_h_nRPC_MO);
426 std::unique_ptr<NHitsTH1> m_h_Nhits_TGC = std::make_unique<NHitsTH1>(m_h_nTGC, m_h_nTGC_I, m_h_nTGC_M, m_h_nTGC_O, m_h_nTGC_InwardsTotal, m_h_nTGC_IM, m_h_nTGC_IO, m_h_nTGC_MO);
427
428 std::unique_ptr<EffInputTH1> m_h_Truth = std::make_unique<EffInputTH1>(m_h_Truth_Lxy_b, m_h_Truth_r_b, m_h_Truth_z_e, m_h_Truth_r_e, m_h_Truth_eta);
430 std::unique_ptr<EffInputTH1> m_h_Reco = std::make_unique<EffInputTH1>(m_h_Reco_Lxy_b, m_h_Reco_r_b, m_h_Reco_z_e, m_h_Reco_r_e, m_h_Reco_eta);
432};
433
434#endif // MSVTXPLOTMAKER_H
Scalar eta() const
pseudorapidity method
Header file for AthHistogramAlgorithm.
std::vector< double > * m_msVtx_y
TH1 * m_h_delta_Lxy_negEta_b
std::vector< double > * m_msVtx_chi2
TGraph * m_etaphi_truth_e
std::vector< double > * m_obj_phi
TH1 * m_h_nTGC_InwardsTotal
TGraph * m_etaphi_out
std::vector< int > * m_msVtx_nMDT_inwards
std::unique_ptr< ResidualTH1 > m_h_VtxResiduals_e
void fillNvtxHists(const std::vector< Amg::Vector3D > &vertices, std::unique_ptr< NVtxTH1 > &hists)
TH1 * m_h_VtxConsti_dRmax_b
TH1 * m_h_VtxConsti_detamax_b
std::vector< int > * m_msVtx_Ntrklet
std::vector< double > * m_obj_eta
std::unique_ptr< TFile > m_input_file
TH1 * m_h_VtxConsti_detamax_e
void saveVtxPos(std::unique_ptr< VtxPosTH > &hists, const TString &plotdir)
TGraph * m_zLxy_truth_b
std::unique_ptr< NHitsTH1 > m_h_Nhits_TGC
TString m_plotdir_inputObjects
std::string m_datapath
TH1 * m_h_VtxConsti_dphimax_e
TH1 * m_h_VtxConsti_dRmax_e
void fillTruthComparisonHists(const std::vector< Amg::Vector3D > &reco_vertices, const std::vector< Amg::Vector3D > &truth_vertices)
TMultiGraph * m_etaphi_truth
std::unique_ptr< VtxPosTGraph > m_h_VtxPos
std::vector< int > * m_msVtx_nRPC
std::vector< int > * m_msVtx_nRPC_inwards
std::unique_ptr< AngularVtxConstiTH1 > m_h_AngularVtxConsti_b
std::vector< int > * m_msVtx_nMDT_M
std::unique_ptr< EffInputTH1 > m_h_TruthRecoMatched
void saveTGraph(TMultiGraph *zLxy, TMultiGraph *etaphi, std::unique_ptr< VtxPosTGraph > &graphs, const TString &plotdir)
std::string m_treename
TGraph * m_etaphi_truth_out
std::unique_ptr< Chi2TH1 > m_h_VtxChi2_e
std::unique_ptr< NVtxTH1 > m_h_NVtx
TH1 * m_h_nMDT_InwardsTotal_e
std::vector< int > * m_msVtx_nTGC_O
TString m_plotdir_recoVtxHits
std::vector< double > * m_msVtx_z
void fillTruthVtxPlots(const std::vector< Amg::Vector3D > &truth_vertices)
TString m_plotdir_recoVtx
void fillResidualHists(double eta, double dR, double d_theta, double d_phi, double d_Lxy, double d_z, double d_phys, std::unique_ptr< ResidualTH1 > &hists)
void fillReconstructionObjectsHists()
void fillRecoVtxPlots(const std::vector< Amg::Vector3D > &reco_vertices, const std::vector< std::vector< Amg::Vector3D > > &reco_constituentPos)
std::vector< double > * m_obj_theta
void saveTH1(TH1 *h, TString plotpath, const char *dectectorLabel="", const char *new_ylabel=nullptr, bool norm=false, bool logy=false)
std::vector< int > * m_msVtx_nTGC_M
TH1 * m_h_delta_Lxy_posEta_b
std::unique_ptr< VtxPosTH > m_h_VtxPosHists
std::unique_ptr< ResidualTH1 > m_h_VtxResiduals_b
std::vector< int > * m_msVtx_nRPC_I
std::vector< int > * m_obj_vtxLink
std::unique_ptr< VtxPosTGraph > m_h_VtxPos_truth
void fillEfficiency_NumeratorDenominatorHists(const std::vector< Amg::Vector3D > &vertices, const std::vector< Amg::Vector3D > &match_candidates, std::unique_ptr< EffInputTH1 > &denomHists, std::unique_ptr< EffInputTH1 > &numHists)
std::unique_ptr< NHitsTH1 > m_h_Nhits_MDT_b
std::vector< double > * m_obj_x
TMultiGraph * m_zLxy_truth
std::vector< int > * m_msVtx_nMDT_O
TH1 * m_h_VtxConsti_dphimax_b
void fillVtxPosHists(const std::vector< Amg::Vector3D > &vertices, std::unique_ptr< VtxPosTH > &hists)
std::vector< int > * m_msVtx_nRPC_M
TString m_plotdir_truthVtx
virtual ~MSVtxPlotMaker()
void fillVtxNhitsHists(double total, double inwards, double inner, double middle, double outer, std::unique_ptr< NHitsTH1 > &hists)
void saveTHStack(TH1 *h1, TH1 *h2, const TString &h1_legend, const TString &h2_legend, const TString &title, const TString &plotpath, int color1=2, int color2=1)
TString m_plotdir_vtxResiduals
std::vector< double > * m_truthVtx_y
std::vector< int > * m_msVtx_nRPC_O
TH1 * m_h_delta_Lxy_negEta_e
TGraph * m_zLxy_truth_out
std::unique_ptr< TCanvas > m_c
TH1 * m_h_nMDT_InwardsTotal_b
TString m_plotdir_vtxEfficiency
std::vector< double > * m_truthVtx_x
std::unique_ptr< Chi2TH1 > m_h_VtxChi2_b
std::vector< int > * m_msVtx_nMDT_I
std::unique_ptr< NHitsTH1 > m_h_Nhits_RPC
TMultiGraph * m_etaphi
std::vector< int > * m_msVtx_nMDT
std::vector< double > * m_truthVtx_z
MSVtxPlotMaker(const std::string &datapath, const std::string &pltdir, const std::string &treename="MSVtxValidTree")
TString m_plotdir_vtxFakeRate
TGraph * m_zLxy_truth_e
std::unique_ptr< VtxPosTH > m_h_VtxPosHists_truth
TMultiGraph * m_zLxy
std::vector< int > * m_msVtx_nTGC
TH1 * getUnmatchedHist(TH1 *h_all, TH1 *h_matched, const TString &name_unmatched)
std::unique_ptr< AngularVtxConstiTH1 > m_h_AngularVtxConsti_e
TGraph * m_etaphi_truth_b
TH1 * m_h_delta_Lxy_posEta_e
std::unique_ptr< NVtxTH1 > m_h_NVtx_truth
TH1 * m_h_nRPC_InwardsTotal
void setColorPalette(TStyle *plotStyle)
TH1 * m_h_distanceToIP_truth
std::unique_ptr< EffInputTH1 > m_h_Truth
std::vector< double > * m_obj_y
std::unique_ptr< NHitsTH1 > m_h_Nhits_MDT_e
std::vector< double > * m_msVtx_x
std::unique_ptr< EffInputTH1 > m_h_RecoTruthMatched
void fillVtxPosMaps(const std::vector< Amg::Vector3D > &vertices, std::unique_ptr< VtxPosTGraph > &graphs)
void saveTEfficiency(TH1 *h_num, TH1 *h_denom, const TString &title, const TString &plotpath)
std::vector< int > * m_msVtx_nTGC_inwards
void saveTH2(TH2 *h, const TString &plotpath)
std::vector< int > * m_msVtx_nTGC_I
void fillAngularVtxConstiHists(const Amg::Vector3D &vtx, const std::vector< Amg::Vector3D > &consti, std::unique_ptr< AngularVtxConstiTH1 > &hists)
std::vector< double > * m_obj_z
void fillVtxPosFiducialVolHists(const Amg::Vector3D &vtx, std::unique_ptr< EffInputTH1 > &hists)
std::unique_ptr< EffInputTH1 > m_h_Reco
void fillChi2Hists(double chi2, double NDoF, std::unique_ptr< Chi2TH1 > &hists)
std::unique_ptr< TFile > m_output_file
double chi2(TH1 *h0, TH1 *h1)
static std::string treename
Definition iLumiCalc.h:31
bool logy
Definition listroot.cxx:45
Eigen::Matrix< double, 3, 1 > Vector3D
AngularVtxConstiTH1(TH1 *h_dR, TH1 *h_dRmax, TH1 *h_dphimax, TH1 *h_detamax)
Chi2TH1(TH1 *h_chi2, TH1 *h_chi2nDoF, TH1 *h_chi2prob)
EffInputTH1(TH1 *h_Lxy, TH1 *h_distanceToIP_b, TH1 *h_z, TH1 *h_distanceToIP_e, TH1 *h_eta)
NHitsTH1(TH1 *h_total, TH1 *h_I, TH1 *h_M, TH1 *h_O, TH1 *h_inwardsTotal, TH1 *h_IM, TH1 *h_IO, TH1 *h_MO)
NVtxTH1(TH1 *h_Nvtx, TH1 *h_Nvtx_b, TH1 *h_Nvtx_e)
ResidualTH1(TH1 *h_delta_R, TH1 *h_delta_theta, TH1 *h_delta_phi, TH1 *h_delta_Lxy, TH1 *h_delta_z, TH1 *h_delta_phys, TH1 *h_delta_Lxy_posEta, TH1 *h_delta_Lxy_negEta, TH1 *h_delta_z_posEta, TH1 *h_delta_z_negEta)
VtxPosTGraph(TGraph *zLxy_b, TGraph *etaphi_b, TGraph *zLxy_e, TGraph *etaphi_e, TGraph *zLxy_out, TGraph *etaphi_out)
VtxPosTH(TH2 *h_zLxy, TH2 *h_etaphi, TH1 *h_distanceToIP)