ATLAS Offline Software
Loading...
Searching...
No Matches
MSVtxPlotMaker.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#include "Utils.h"
6#include "PlotAnnotations.h"
7#include "MSVtxPlotMaker.h"
8
9
10using namespace MuonVertexValidationMacroUtils;
12
13MSVtxPlotMaker::MSVtxPlotMaker(const std::string &datapath, const std::string &pltdir, const std::string &treename) :
14 m_datapath(datapath), m_treename(treename),
15 m_plotdir(pltdir),
16 m_plotdir_truthVtx(m_plotdir+"truthVtx/"),
17 m_plotdir_recoVtx(m_plotdir+"recoVtx/"),
19 m_plotdir_vtxResiduals(m_plotdir+"vtxResiduals/"),
20 m_plotdir_inputObjects(m_plotdir+"inputObjects/"),
21 m_plotdir_vtxEfficiency(m_plotdir+"vtxEfficiency/"),
22 m_plotdir_vtxFakeRate(m_plotdir+"vtxFakeRate/")
23 {}
24
25
27
28
29// --- core functions --- //
30
32 // Generates a series of plots from the input data (m_datapath and m_treename) and stores these at m_plotdir
33 // as a figure and in a root file.
34 setup();
37 fillPlots();
39}
40
41
43 // set up input file and its tree as well as the output root file.
44 m_input_file = std::make_unique<TFile>(m_datapath.c_str(), "read");
45 m_tree = (TTree*)m_input_file->Get(m_treename.c_str());
47
48 gSystem->mkdir(m_plotdir, kTRUE);
49 gSystem->mkdir(m_plotdir_truthVtx, kTRUE);
50 gSystem->mkdir(m_plotdir_recoVtx, kTRUE);
51 gSystem->mkdir(m_plotdir_recoVtxHits, kTRUE);
52 gSystem->mkdir(m_plotdir_vtxResiduals, kTRUE);
53 gSystem->mkdir(m_plotdir_inputObjects, kTRUE);
54 gSystem->mkdir(m_plotdir_vtxEfficiency, kTRUE);
55 gSystem->mkdir(m_plotdir_vtxFakeRate, kTRUE);
56 m_output_file = std::make_unique<TFile>(m_plotdir+"Histograms.root", "recreate");
57
58 return;
59}
60
61
63 // set the plot style and the color palette
64 gROOT->SetStyle("ATLAS");
65 TStyle* plotStyle = gROOT->GetStyle("ATLAS");
66 plotStyle->SetOptTitle(0);
67 plotStyle->SetHistLineWidth(1.);
68
69 setColorPalette(plotStyle);
70 plotStyle->cd();
71 gROOT->ForceStyle();
72
73 return;
74}
75
76
78 // Call formating routines for the plots
80
81 return;
82}
83
84
86 // main loop over the events which fills the plots
87
88 for(int i=0; i<m_tree->GetEntries(); ++i){
89 m_tree->GetEntry(i);
90
91 const std::vector<Amg::Vector3D> truth_vertices = getVertexPos(*m_truthVtx_x, *m_truthVtx_y, *m_truthVtx_z);
92 const std::vector<Amg::Vector3D> reco_vertices = getVertexPos(*m_msVtx_x, *m_msVtx_y, *m_msVtx_z);
93 const std::vector<std::vector<Amg::Vector3D>> reco_constituentPos = getConstituentPos(reco_vertices.size(), *m_obj_vtxLink,
95
96 fillTruthVtxPlots(truth_vertices);
98 fillRecoVtxPlots(reco_vertices, reco_constituentPos);
99 fillTruthComparisonHists(reco_vertices, truth_vertices);
100
101 // histograms for vertex efficiency: fraction of truth vertices that are reconstructed
103 // histograms for vertex purity: fraction of reconstructed vertices that are truth vertices
105 }
106
107 return;
108}
109
110
112 // draw, save, write the plots
113 m_c = std::make_unique<TCanvas>();
114 m_output_file->cd();
115
116
117 // truth vertices
121 // position
124
125
126 // reconstructed vertices
130 // position
133 // chi squared
140 // constituents
141 saveTH1(m_h_Nconsti_b, m_plotdir_recoVtx+"Nconstituents_b");
142 saveTH1(m_h_Nconsti_e, m_plotdir_recoVtx+"Nconstituents_e");
144 saveTH1(m_h_VtxConsti_dRmax_b, m_plotdir_recoVtx+"VtxConsti_dRmax_b");
145 saveTH1(m_h_VtxConsti_dphimax_b, m_plotdir_recoVtx+"VtxConsti_dphimax_b");
146 saveTH1(m_h_VtxConsti_detamax_b, m_plotdir_recoVtx+"VtxConsti_detamax_b");
148 saveTH1(m_h_VtxConsti_dRmax_e, m_plotdir_recoVtx+"VtxConsti_dRmax_e");
149 saveTH1(m_h_VtxConsti_dphimax_e, m_plotdir_recoVtx+"VtxConsti_dphimax_e");
150 saveTH1(m_h_VtxConsti_detamax_e, m_plotdir_recoVtx+"VtxConsti_detamax_e");
151 // MDT hits
168 // RPC hits
177 // TGC hits
186
187
188 // input objects for the vertex reconstruction
189 // use counts from eta and phi histograms to fill the total number of objects available and used for reconstruction
191 TString::Format("#splitline{Used in}{reconstruction: %d}", int(m_h_objReco_eta->GetEntries())), TString::Format("Total: %d", int(m_h_obj_eta->GetEntries())),
192 TString("objN_stack; Number of objects; Events / bin"), m_plotdir_inputObjects+"objN_stack");
194 TString::Format("#splitline{Used in}{reconstruction: %d}", int(m_h_objReco_phi_b->GetEntries())), TString::Format("Total: %d", int(m_h_obj_phi_b->GetEntries())),
195 TString("objN_stack_b; Number of objects in the barrel; Events / bin"), m_plotdir_inputObjects+"objN_stack_b");
197 TString::Format("#splitline{Used in}{reconstruction: %d}", int(m_h_objReco_phi_e->GetEntries())), TString::Format("Total: %d", int(m_h_obj_phi_e->GetEntries())),
198 TString("objN_stack_e; Number of objects in the endcaps; Events / bin"), m_plotdir_inputObjects+"objN_stack_e");
200 TString::Format("#splitline{Used in}{reconstruction: %d}", int(m_h_objReco_eta->GetEntries())), TString::Format("Total: %d", int(m_h_obj_eta->GetEntries())),
201 TString("objEta_stack; Object #kern[-0.425]{#eta }; Events / bin"), m_plotdir_inputObjects+"objEta_stack");
203 TString::Format("#splitline{Used in}{reconstruction: %d}", int(m_h_objReco_phi_b->GetEntries())), TString::Format("Total: %d", int(m_h_obj_phi_b->GetEntries())),
204 TString("objPhi_stack_b; Object #kern[-0.09]{#phi in the barrel}; Events / bin"), m_plotdir_inputObjects+"objPhi_stack_b");
206 TString::Format("#splitline{Used in}{reconstruction: %d}", int(m_h_objReco_phi_e->GetEntries())), TString::Format("Total: %d", int(m_h_obj_phi_e->GetEntries())),
207 TString("objPhi_stack_e; Object #kern[-0.09]{#phi in the endcaps}; Events / bin"), m_plotdir_inputObjects+"objPhi_stack_e");
208 // objects used for reconstruction
215
216
217 // vertex residuals
218 // barrel
225 // endcaps
232 // split into positive and negative eta
233 saveTH1(m_h_delta_Lxy_posEta_b, m_plotdir_vtxResiduals+"delta_Lxy_posEta_b", TString::Format("0 < #kern[-0.45]{#eta <} %.2f", fidVol_barrel_etaCut).Data());
234 saveTH1(m_h_delta_Lxy_negEta_b, m_plotdir_vtxResiduals+"delta_Lxy_negEta_b", TString::Format("-%.2f < #kern[-0.45]{#eta <} 0", fidVol_barrel_etaCut).Data());
235 saveTH1(m_h_delta_Lxy_posEta_e, m_plotdir_vtxResiduals+"delta_Lxy_posEta_e", TString::Format("%.2f < #kern[-0.45]{#eta <} %.2f", fidVol_endcaps_etaCut_low, fidVol_endcaps_etaCut_up).Data());
236 saveTH1(m_h_delta_Lxy_negEta_e, m_plotdir_vtxResiduals+"delta_Lxy_negEta_e", TString::Format("-%.2f < #kern[-0.45]{#eta <} -%.2f", fidVol_endcaps_etaCut_up, fidVol_endcaps_etaCut_low).Data());
237 saveTH1(m_h_delta_z_posEta_b, m_plotdir_vtxResiduals+"delta_z_posEta_b", TString::Format("0 < #kern[-0.45]{#eta <} %.2f", fidVol_barrel_etaCut).Data());
238 saveTH1(m_h_delta_z_negEta_b, m_plotdir_vtxResiduals+"delta_z_negEta_b", TString::Format("-%.2f < #kern[-0.45]{#eta <} 0", fidVol_barrel_etaCut).Data());
239 saveTH1(m_h_delta_z_posEta_e, m_plotdir_vtxResiduals+"delta_z_posEta_e", TString::Format("%.2f < #kern[-0.45]{#eta <} %.2f", fidVol_endcaps_etaCut_low, fidVol_endcaps_etaCut_up).Data());
240 saveTH1(m_h_delta_z_negEta_e, m_plotdir_vtxResiduals+"delta_z_negEta_e", TString::Format("-%.2f < #kern[-0.45]{#eta <} -%.2f", fidVol_endcaps_etaCut_up, fidVol_endcaps_etaCut_low).Data());
241
242
243 // vertex efficiency
244 // transverse distance: barrel
246 TString::Format("#splitline{Truth vertices}{matched to reco: %d}", int(m_h_TruthReco_Lxy_b->GetEntries())), TString::Format("Truth vertices: %d", int(m_h_Truth_Lxy_b->GetEntries())),
247 TString("stack_vtxeff_Lxy_b; Truth vertex L_{xy} [m]; Vertices / bin"), m_plotdir_vtxEfficiency+"num_denom_vtxeff_Lxy_b");
249 TString("vtxeff_Lxy_b; Truth vertex L_{xy} [m]; Efficiency: n_{truth}^{reco matched} / n_{truth}"), m_plotdir_vtxEfficiency+"vtxeff_Lxy_b");
250
251 // longitudinal distance: endcap
253 TString::Format("#splitline{Truth vertices}{matched to reco: %d}", int(m_h_TruthReco_z_e->GetEntries())), TString::Format("Truth vertices: %d", int(m_h_Truth_z_e->GetEntries())),
254 TString("stack_vtxeff_z_e; Truth vertex |z| [m]; Vertices / bin"), m_plotdir_vtxEfficiency+"num_denom_vtxeff_z_e");
256 TString("vtxeff_z_e; Truth vertex |z| [m]; Efficiency: n_{truth}^{reco matched} / n_{truth}"), m_plotdir_vtxEfficiency+"vtxeff_z_e");
257
258 // eta-binned
260 TString::Format("#splitline{Truth vertices}{matched to reco: %d}", int(m_h_TruthReco_eta->GetEntries())), TString::Format("Truth vertices: %d", int(m_h_Truth_eta->GetEntries())),
261 TString("stack_vtxeff_eta; Truth vertex #kern[-0.425]{#eta }; Vertices / bin"), m_plotdir_vtxEfficiency+"num_denom_vtxeff_eta");
263 TString("vtxeff_eta; Truth vertex #kern[-0.425]{#eta }; Efficiency: n_{truth}^{reco matched} / n_{truth}"), m_plotdir_vtxEfficiency+"vtxeff_eta");
264
265 // distance form IP: barrel
267 TString::Format("#splitline{Truth vertices}{matched to reco: %d}", int(m_h_TruthReco_r_b->GetEntries())), TString::Format("Truth vertices: %d", int(m_h_Truth_r_b->GetEntries())),
268 TString("stack_vtxeff_r_b; Truth vertex |#bf{r}| [m]; Vertices / bin"), m_plotdir_vtxEfficiency+"num_denom_vtxeff_r_b");
270 TString("vtxeff_r_b; Truth vertex |#bf{r}| [m]; Efficiency: n_{truth}^{reco matched} / n_{truth}"), m_plotdir_vtxEfficiency+"vtxeff_r_b");
271
272 // distance form IP: endcap
274 TString::Format("#splitline{Truth vertices}{matched to reco: %d}", int(m_h_TruthReco_r_e->GetEntries())), TString::Format("Truth vertices: %d", int(m_h_Truth_r_e->GetEntries())),
275 TString("stack_vtxeff_r_e; Truth vertex |#bf{r}| [m]; Vertices / bin"), m_plotdir_vtxEfficiency+"num_denom_vtxeff_r_e");
277 TString("vtxeff_r_e; Truth vertex |#bf{r}| [m]; Efficiency: n_{truth}^{reco matched} / n_{truth}"), m_plotdir_vtxEfficiency+"vtxeff_r_e");
278
279
280 // vertex fakerate
281 // transverse distance: barrel
282 TH1 *h_RecoNoTruth_Lxy_b = getUnmatchedHist(m_h_Reco_Lxy_b, m_h_RecoTruth_Lxy_b, TString("RecoNoTruth_b"));
283 saveTHStack(h_RecoNoTruth_Lxy_b, m_h_Reco_Lxy_b,
284 TString::Format("#splitline{Reco vertices}{not matched to truth: %d}", int(h_RecoNoTruth_Lxy_b->GetEntries())), TString::Format("Reco vertices: %d", int(m_h_Reco_Lxy_b->GetEntries())),
285 TString("stack_vtxfrate_Lxy_b; Reco vertex L_{xy} [m]; Vertices / bin"), m_plotdir_vtxFakeRate+"num_denom_vtxfrate_Lxy_b");
286 saveTEfficiency(h_RecoNoTruth_Lxy_b, m_h_Reco_Lxy_b,
287 TString("vtxfrate_Lxy_b; Reco vertex L_{xy} [m]; Fake rate: n_{reco}^{not truth matched} / n_{reco}"), m_plotdir_vtxFakeRate+"vtxfrate_Lxy_b");
288 // longitudinal distance: endcap
289 TH1 *h_RecoNoTruth_z_e = getUnmatchedHist(m_h_Reco_z_e, m_h_RecoTruth_z_e, TString("RecoNoTruth_e"));
290 saveTHStack(h_RecoNoTruth_z_e, m_h_Reco_z_e,
291 TString::Format("#splitline{Reco vertices}{not matched to truth: %d}", int(h_RecoNoTruth_z_e->GetEntries())), TString::Format("Reco vertices: %d", int(m_h_Reco_z_e->GetEntries())),
292 TString("stack_vtxfrate_z_e; Reco vertex |z| [m]; Vertices / bin"), m_plotdir_vtxFakeRate+"num_denom_vtxfrate_z_e");
293 saveTEfficiency(h_RecoNoTruth_z_e, m_h_Reco_z_e,
294 TString("vtxfrate_z_e; Reco vertex |z| [m]; Fake rate: n_{reco}^{not truth matched} / n_{reco}"), m_plotdir_vtxFakeRate+"vtxfrate_z_e");
295
296 // eta-binned
297 TH1 *h_RecoNoTruth_eta = getUnmatchedHist(m_h_Reco_eta, m_h_RecoTruth_eta, TString("RecoNoTruth_eta"));
298 saveTHStack(h_RecoNoTruth_eta, m_h_Reco_eta,
299 TString::Format("#splitline{Reco vertices}{not matched to truth: %d}", int(h_RecoNoTruth_eta->GetEntries())), TString::Format("Reco vertices: %d", int(m_h_Reco_eta->GetEntries())),
300 TString("stack_vtxfrate_eta; Reco vertex #kern[-0.425]{#eta }; Vertices / bin"), m_plotdir_vtxFakeRate+"num_denom_vtxfrate_eta");
301 saveTEfficiency(h_RecoNoTruth_eta, m_h_Reco_eta,
302 TString("vtxfrate_eta; Reco vertex #kern[-0.425]{#eta }; Fake rate: n_{reco}^{not truth matched} / n_{reco}"), m_plotdir_vtxFakeRate+"vtxfrate_eta");
303
304 // distance form IP: barrel
305 TH1 *h_RecoNoTruth_r_b = getUnmatchedHist(m_h_Reco_r_b, m_h_RecoTruth_r_b, TString("RecoNoTruth_r_b"));
306 saveTHStack(h_RecoNoTruth_r_b, m_h_Reco_r_b,
307 TString::Format("#splitline{Reco vertices}{not matched to truth: %d}", int(h_RecoNoTruth_r_b->GetEntries())), TString::Format("Reco vertices: %d", int(m_h_Reco_r_b->GetEntries())),
308 TString("stack_vtxfrate_r_b; Reco vertex |#bf{r}| [m]; Vertices / bin"), m_plotdir_vtxFakeRate+"num_denom_vtxfrate_r_b");
309 saveTEfficiency(h_RecoNoTruth_r_b, m_h_Reco_r_b,
310 TString("vtxfrate_r_b; Reco vertex |#bf{r}| [m]; Fake rate: n_{reco}^{not truth matched} / n_{reco}"), m_plotdir_vtxFakeRate+"vtxfrate_r_b");
311
312 // distance form IP: endcaps
313 TH1 *h_RecoNoTruth_r_e = getUnmatchedHist(m_h_Reco_r_e, m_h_RecoTruth_r_e, TString("RecoNoTruth_r_e"));
314 saveTHStack(h_RecoNoTruth_r_e, m_h_Reco_r_e,
315 TString::Format("#splitline{Reco vertices}{not matched to truth: %d}", int(h_RecoNoTruth_r_e->GetEntries())), TString::Format("Reco vertices: %d", int(m_h_Reco_r_e->GetEntries())),
316 TString("stack_vtxfrate_r_e; Reco vertex |#bf{r}| [m]; Vertices / bin"), m_plotdir_vtxFakeRate+"num_denom_vtxfrate_r_e");
317 saveTEfficiency(h_RecoNoTruth_r_e, m_h_Reco_r_e,
318 TString("vtxfrate_r_e; Reco vertex |#bf{r}| [m]; Fake rate: n_{reco}^{not truth matched} / n_{reco}"), m_plotdir_vtxFakeRate+"vtxfrate_r_e");
319
320
321 m_output_file->Write();
322 m_output_file->Delete("*;2"); // delete all nameclye 2 objects
323 m_output_file->Close();
324
325 return;
326}
327
328
329
330// --- setup branches and declare plots --- //
331
333 // truth vertex variables
334 m_tree->SetBranchAddress("llpVtx_X", &m_truthVtx_x);
335 m_tree->SetBranchAddress("llpVtx_Y", &m_truthVtx_y);
336 m_tree->SetBranchAddress("llpVtx_Z", &m_truthVtx_z);
337
338 // reconstructed vertex variables
339 m_tree->SetBranchAddress("msVtx_chi2", &m_msVtx_chi2);
340 m_tree->SetBranchAddress("msVtx_Ntrklet", &m_msVtx_Ntrklet);
341 m_tree->SetBranchAddress("msVtx_X", &m_msVtx_x);
342 m_tree->SetBranchAddress("msVtx_Y", &m_msVtx_y);
343 m_tree->SetBranchAddress("msVtx_Z", &m_msVtx_z);
344 // MDT hits near the vertex: total and per layer
345 m_tree->SetBranchAddress("msVtx_nMDT", &m_msVtx_nMDT);
346 m_tree->SetBranchAddress("msVtx_nMDT_inwards", &m_msVtx_nMDT_inwards);
347 m_tree->SetBranchAddress("msVtx_nMDT_I", &m_msVtx_nMDT_I);
348 m_tree->SetBranchAddress("msVtx_nMDT_M", &m_msVtx_nMDT_M);
349 m_tree->SetBranchAddress("msVtx_nMDT_O", &m_msVtx_nMDT_O);
350 // RPC hits near the vertex: total and per layer
351 m_tree->SetBranchAddress("msVtx_nRPC", &m_msVtx_nRPC);
352 m_tree->SetBranchAddress("msVtx_nRPC_inwards", &m_msVtx_nRPC_inwards);
353 m_tree->SetBranchAddress("msVtx_nRPC_I", &m_msVtx_nRPC_I);
354 m_tree->SetBranchAddress("msVtx_nRPC_M", &m_msVtx_nRPC_M);
355 m_tree->SetBranchAddress("msVtx_nRPC_O", &m_msVtx_nRPC_O);
356 // TGC hits near the vertex: total and per layer
357 m_tree->SetBranchAddress("msVtx_nTGC", &m_msVtx_nTGC);
358 m_tree->SetBranchAddress("msVtx_nTGC_inwards", &m_msVtx_nTGC_inwards);
359 m_tree->SetBranchAddress("msVtx_nTGC_I", &m_msVtx_nTGC_I);
360 m_tree->SetBranchAddress("msVtx_nTGC_M", &m_msVtx_nTGC_M);
361 m_tree->SetBranchAddress("msVtx_nTGC_O", &m_msVtx_nTGC_O);
362
363 // input objects for the vertex reconstruction
364 m_tree->SetBranchAddress("trklet_posX", &m_obj_x);
365 m_tree->SetBranchAddress("trklet_posY", &m_obj_y);
366 m_tree->SetBranchAddress("trklet_posZ", &m_obj_z);
367 m_tree->SetBranchAddress("trklet_phi", &m_obj_phi);
368 m_tree->SetBranchAddress("trklet_theta", &m_obj_theta);
369 m_tree->SetBranchAddress("trklet_eta", &m_obj_eta);
370 m_tree->SetBranchAddress("trklet_vtxLink", &m_obj_vtxLink);
371
372 return;
373}
374
375
377 // Set the formating options for TGraph and TMultiGraph
378
379 // Lxy-z map of truth vertices
380 m_zLxy_truth->SetTitle("zLxy_truth; Truth vertex z [m]; Truth vertex L_{xy} [m]");
381 m_zLxy_truth_b->SetMarkerColor(1); m_zLxy_truth_b->SetMarkerStyle(20); m_zLxy_truth_b->SetMarkerSize(0.5);
382 m_zLxy_truth_e->SetMarkerColor(2); m_zLxy_truth_e->SetMarkerStyle(20); m_zLxy_truth_e->SetMarkerSize(0.5);
383 m_zLxy_truth_out->SetMarkerColor(14); m_zLxy_truth_out->SetMarkerStyle(24); m_zLxy_truth_out->SetMarkerSize(0.5);
384 // eta-phi map of truth vertices
385 m_etaphi_truth->SetTitle("etaphi_truth; Truth vertex #eta; Truth vertex #phi [rad]");
386 m_etaphi_truth_b->SetMarkerColor(1); m_etaphi_truth_b->SetMarkerStyle(20); m_etaphi_truth_b->SetMarkerSize(0.5);
387 m_etaphi_truth_e->SetMarkerColor(2); m_etaphi_truth_e->SetMarkerStyle(20); m_etaphi_truth_e->SetMarkerSize(0.5);
388 m_etaphi_truth_out->SetMarkerColor(14); m_etaphi_truth_out->SetMarkerStyle(24); m_etaphi_truth_out->SetMarkerSize(0.5);
389
390 // Lxy-z map of reconstructed vertices
391 m_zLxy->SetTitle("zLxy; Reco vertex z [m]; Reco vertex L_{xy} [m]");
392 m_zLxy_b->SetMarkerColor(1); m_zLxy_b->SetMarkerStyle(20); m_zLxy_b->SetMarkerSize(0.5);
393 m_zLxy_e->SetMarkerColor(2); m_zLxy_e->SetMarkerStyle(20); m_zLxy_e->SetMarkerSize(0.5);
394 m_zLxy_out->SetMarkerColor(14); m_zLxy_out->SetMarkerStyle(24); m_zLxy_out->SetMarkerSize(0.5);
395 // eta-phi map of reconstructed vertices
396 m_etaphi->SetTitle("etaphi; Reco vertex #eta; Reco vertex #phi [rad]");
397 m_etaphi_b->SetMarkerColor(1); m_etaphi_b->SetMarkerStyle(20); m_etaphi_b->SetMarkerSize(0.5);
398 m_etaphi_e->SetMarkerColor(2); m_etaphi_e->SetMarkerStyle(20); m_etaphi_e->SetMarkerSize(0.5);
399 m_etaphi_out->SetMarkerColor(14); m_etaphi_out->SetMarkerStyle(24); m_etaphi_out->SetMarkerSize(0.5);
400
401 return;
402}
403
404
405// --- main filling functions --- //
406
407void MSVtxPlotMaker::fillTruthVtxPlots(const std::vector<Amg::Vector3D> &truth_vertices){
408
409 fillNvtxHists(truth_vertices, m_h_NVtx_truth);
410 fillVtxPosMaps(truth_vertices, m_h_VtxPos_truth);
411 fillVtxPosHists(truth_vertices, m_h_VtxPosHists_truth);
412
413 return;
414}
415
416
418 // fill histograms for the objects from which vertices can be reconstructed
419
420 int Nobj_count = m_obj_phi->size();
421 int Nobj_count_b{0}, Nobj_count_e{0};
422 int NobjReco_count{0};
423 int NobjReco_count_b{0}, NobjReco_count_e{0};
424
425 for (int i=0; i<Nobj_count; ++i){
426 double obj_phi = (*m_obj_phi)[i];
427 double obj_eta = (*m_obj_eta)[i];
428 bool used_in_reco = (*m_obj_vtxLink)[i] != -1;
429 m_h_obj_eta->Fill(obj_eta);
430 if (used_in_reco){
431 ++NobjReco_count;
432 m_h_objReco_eta->Fill(obj_eta);
433 }
434
435 if (inBarrel(obj_eta)){
436 ++Nobj_count_b;
437 m_h_obj_phi_b->Fill(obj_phi);
438 if (used_in_reco){
439 ++NobjReco_count_b;
440 m_h_objReco_phi_b->Fill(obj_phi);
441 }
442 }
443 if (inEndcaps(obj_eta)){
444 ++Nobj_count_e;
445 m_h_obj_phi_e->Fill(obj_phi);
446 if (used_in_reco){
447 ++NobjReco_count_e;
448 m_h_objReco_phi_e->Fill(obj_phi);
449 }
450 }
451 }
452 m_h_Nobj->Fill(Nobj_count);
453 m_h_Nobj_b->Fill(Nobj_count_b);
454 m_h_Nobj_e->Fill(Nobj_count_e);
455 m_h_NobjReco->Fill(NobjReco_count);
456 m_h_NobjReco_b->Fill(NobjReco_count_b);
457 m_h_NobjReco_e->Fill(NobjReco_count_e);
458
459 return;
460}
461
462
463void MSVtxPlotMaker::fillRecoVtxPlots(const std::vector<Amg::Vector3D> &reco_vertices, const std::vector<std::vector<Amg::Vector3D>> &reco_constituentPos){
464
465 fillNvtxHists(reco_vertices, m_h_NVtx);
466 fillVtxPosMaps(reco_vertices, m_h_VtxPos);
467 fillVtxPosHists(reco_vertices, m_h_VtxPosHists);
468
469 for (unsigned int j=0; j<reco_vertices.size(); ++j){
470 if (inBarrel(reco_vertices[j])){
471 m_h_Nconsti_b->Fill((*m_msVtx_Ntrklet)[j]);
473 fillAngularVtxConstiHists(reco_vertices[j], reco_constituentPos[j], m_h_AngularVtxConsti_b);
476 }
477 if (inEndcaps(reco_vertices[j])){
478 m_h_Nconsti_e->Fill((*m_msVtx_Ntrklet)[j]);
480 fillAngularVtxConstiHists(reco_vertices[j], reco_constituentPos[j], m_h_AngularVtxConsti_e);
483 }
484 }
485
486 return;
487}
488
489
490void MSVtxPlotMaker::fillTruthComparisonHists(const std::vector<Amg::Vector3D> &reco_vertices, const std::vector<Amg::Vector3D> &truth_vertices){
491 // fills the histograms detailing the differences between reconstructed and truth vertices
492 for (const Amg::Vector3D &vtx : reco_vertices){
493 if (!inFiducialVol(vtx)) continue;
494 Amg::Vector3D truth_vtx = findBestMatch(vtx, truth_vertices);
495 if (!isValidMatch(truth_vtx)) continue;
496
497 double dR = xAOD::P4Helpers::deltaR(vtx.eta(), vtx.phi(), truth_vtx.eta(), truth_vtx.phi()); // angular distance
498 double d_theta = vtx.theta() - truth_vtx.theta();
499 double d_phi = Amg::deltaPhi(vtx, truth_vtx);
500 double d_Lxy = (vtx.perp() - truth_vtx.perp())/Gaudi::Units::cm; // distance in transverse plane
501 double d_z = (vtx.z() - truth_vtx.z())/Gaudi::Units::cm; // in cm
502 double d_phys = Amg::distance(vtx, truth_vtx)/Gaudi::Units::cm; // distance to the IP in cm
503
504 if (inFiducialVolBarrel(vtx)) fillResidualHists(truth_vtx.eta(), dR, d_theta, d_phi, d_Lxy, d_z, d_phys, m_h_VtxResiduals_b);
505 if (inFiducialVolEndcaps(vtx)) fillResidualHists(truth_vtx.eta(), dR, d_theta, d_phi, d_Lxy, d_z, d_phys, m_h_VtxResiduals_e);
506 }
507
508 return;
509}
510
511
512void MSVtxPlotMaker::fillEfficiency_NumeratorDenominatorHists(const std::vector<Amg::Vector3D> &vertices, const std::vector<Amg::Vector3D> &match_candidates,
513 std::unique_ptr<EffInputTH1> &denomHists, std::unique_ptr<EffInputTH1> &numHists){
514 // Fills the transverse distance (barrel vertices only), longitudinal distance (endcaps vertices only), eta-binned, and distance to the IP binned histograms
515 // for vertices passing the good vertex selection. These are the denominator histograms for efficiency calculations.
516 // If additionally, the vertex can be macthed to an element in match_candidates, the numerator histograms are filled.
517
518 for(const Amg::Vector3D &vtx : vertices){
519 if (!isGoodVtx(vtx)) continue;
520 fillVtxPosFiducialVolHists(vtx, denomHists);
521 if (!hasMatch(vtx, match_candidates)) continue;
522 fillVtxPosFiducialVolHists(vtx, numHists);
523 }
524
525 return;
526}
527
528
529// --- helper filling functions --- //
530
531void MSVtxPlotMaker::fillNvtxHists(const std::vector<Amg::Vector3D> &vertices, std::unique_ptr<NVtxTH1> &hists){
532 // Fills the number of vertices in the whole detector region and split into barrel and endcaps.
533 hists->h_Nvtx->Fill(getNvtxDetectorRegion(vertices));
534 hists->h_Nvtx_b->Fill(getNvtxBarrel(vertices));
535 hists->h_Nvtx_e->Fill(getNvtxEndcaps(vertices));
536
537 return;
538}
539
540
541void MSVtxPlotMaker::fillVtxPosMaps(const std::vector<Amg::Vector3D> &vertices, std::unique_ptr<VtxPosTGraph> &graphs){
542 // Fills the barrel, endcaps, or outside the detector region z-Lxy and eta-phi maps with the vertex position.
543 for (const Amg::Vector3D &vtx : vertices){
544 if (inBarrel(vtx)){
545 graphs->zLxy_b->SetPoint(graphs->zLxy_b->GetN(), vtx.z()/Gaudi::Units::m, vtx.perp()/Gaudi::Units::m);
546 graphs->etaphi_b->SetPoint(graphs->etaphi_b->GetN(), vtx.eta(), vtx.phi());
547 }
548 else if (inEndcaps(vtx)){
549 graphs->zLxy_e->SetPoint(graphs->zLxy_e->GetN(), vtx.z()/Gaudi::Units::m, vtx.perp()/Gaudi::Units::m);
550 graphs->etaphi_e->SetPoint(graphs->etaphi_e->GetN(), vtx.eta(), vtx.phi());
551 }
552 else {
553 graphs->zLxy_out->SetPoint(graphs->zLxy_out->GetN(), vtx.z()/Gaudi::Units::m, vtx.perp()/Gaudi::Units::m);
554 graphs->etaphi_out->SetPoint(graphs->etaphi_out->GetN(), vtx.eta(), vtx.phi());
555 }
556 }
557
558 return;
559}
560
561
562void MSVtxPlotMaker::fillVtxPosHists(const std::vector<Amg::Vector3D> &vertices, std::unique_ptr<VtxPosTH> &hists){
563 // Fills the transverse distance, longitudinal distance, eta-binned, phi-binned and distance to the IP -binned histograms
564 // Requires the vertex to be within the detector region (inside the barrel or endcaps).
565
566 for (const Amg::Vector3D &vtx : vertices){
567 if (!inDetectorRegion(vtx)) continue;
568 hists->h_zLxy->Fill(vtx.z()/Gaudi::Units::m, vtx.perp()/Gaudi::Units::m);
569 hists->h_etaphi->Fill(vtx.eta(), vtx.phi());
570 hists->h_distanceToIP->Fill(vtx.mag()/Gaudi::Units::m);
571 }
572
573 return;
574}
575
576
577void MSVtxPlotMaker::fillChi2Hists(double chi2, double NDoF, std::unique_ptr<Chi2TH1> &hists){
578 // Fills histograms related to the chi2 value of the vertex fit.
579 hists->h_chi2->Fill(chi2);
580 hists->h_chi2nDoF->Fill(chi2/NDoF);
581 hists->h_chi2prob->Fill( TMath::Prob(chi2, NDoF-1));
582
583 return;
584}
585
586
587void MSVtxPlotMaker::fillAngularVtxConstiHists(const Amg::Vector3D &vtx, const std::vector<Amg::Vector3D> &consti, std::unique_ptr<AngularVtxConstiTH1> &hists){
588 // Fills histograms with the angular differences between the vertex and its constituents.
589
590 if (consti.size() == 0) return; // no constituents
591
592 double dphi{-1}, deta{-1}, deltaR{-1};
593 double dphi_max{0}, deta_max{0}, dR_max{0};
594
595 for (const Amg::Vector3D &c : consti){
596 dphi = xAOD::P4Helpers::deltaPhi(vtx.phi(), c.phi());
597 deta = vtx.eta() - c.eta();
598 deltaR = xAOD::P4Helpers::deltaR(vtx.eta(), vtx.phi(), c.eta(), c.phi());
599 hists->h_dR->Fill(deltaR);
600 if (std::abs(dphi) > std::abs(dphi_max)) dphi_max = dphi;
601 if (std::abs(deta) > std::abs(deta_max)) deta_max = deta;
602 if (deltaR > dR_max) dR_max = deltaR;
603 }
604
605 hists->h_dphimax->Fill(dphi_max);
606 hists->h_detamax->Fill(deta_max);
607 hists->h_dRmax->Fill(dR_max);
608
609 return;
610}
611
612
613void MSVtxPlotMaker::fillVtxNhitsHists(double total, double inwards, double inner, double middle, double outer, std::unique_ptr<NHitsTH1> &hists){
614 // Fills histograms with the number of hits associated to the vertex, hits inwards of the vertex and the ratios between hits in different muon spectrometer layers.
615
616 if (total < 0) return; // no hits
617
618 hists->h_total->Fill(total);
619 hists->h_I->Fill(inner);
620 hists->h_M->Fill(middle);
621 hists->h_O->Fill(outer);
622 hists->h_inwardsTotal->Fill(inwards/total);
623 if (middle > 0) hists->h_IM->Fill(inner/middle);
624 if (outer > 0) hists->h_IO->Fill(inner/outer);
625 if (outer > 0) hists->h_MO->Fill(middle/outer);
626
627 return;
628}
629
630
631void MSVtxPlotMaker::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){
632 // Fills histograms with the differences between the reconstructed and the matched truth vertex.
633 // The value of eta can be used to split the histograms into positive and negative eta regions.
634 hists->h_delta_R->Fill(dR);
635 hists->h_delta_theta->Fill(d_theta);
636 hists->h_delta_phi->Fill(d_phi);
637 hists->h_delta_Lxy->Fill(d_Lxy);
638 hists->h_delta_z->Fill(d_z);
639 hists->h_delta_phys->Fill(d_phys);
640
641 if (eta >= 0){
642 hists->h_delta_Lxy_posEta->Fill(d_Lxy);
643 hists->h_delta_z_posEta->Fill(d_z);
644 }
645 else {
646 hists->h_delta_Lxy_negEta->Fill(d_Lxy);
647 hists->h_delta_z_negEta->Fill(d_z);
648 }
649
650 return;
651}
652
653
654void MSVtxPlotMaker::fillVtxPosFiducialVolHists(const Amg::Vector3D &vtx, std::unique_ptr<EffInputTH1> &hists){
655 // Fills the transverse distance (barrel vertices only), longitudinal distance (endcaps vertices only),
656 // eta-binned, and distance to the IP binned histograms.
657 if (inFiducialVolBarrel(vtx)){
658 hists->h_Lxy->Fill(vtx.perp()/Gaudi::Units::m);
659 hists->h_distanceToIP_b->Fill(vtx.mag()/Gaudi::Units::m);
660 }
661 if (inFiducialVolEndcaps(vtx)){
662 hists->h_z->Fill(std::abs(vtx.z()/Gaudi::Units::m));
663 hists->h_distanceToIP_e->Fill(vtx.mag()/Gaudi::Units::m);
664 }
665 hists->h_eta->Fill(vtx.eta());
666
667 return;
668}
669
670
671// --- plots savers --- //
672
673void MSVtxPlotMaker::saveVtxPos(std::unique_ptr<VtxPosTH> &hists, const TString &plotdir){
674 // Saves the passed TH2s and TH1.
675 saveTH2(hists->h_zLxy, plotdir+"zLxy");
676 saveTH2(hists->h_etaphi, plotdir+"etaphi");
677
678 // project and save the 1D histograms
679 const TString extra = plotdir.Contains("truth") ? TString("_truth") : TString("");
680
681 saveTH1(hists->h_zLxy->ProjectionX("z"+extra), plotdir+"z"+extra, "", "Vertices / bin");
682 saveTH1(hists->h_zLxy->ProjectionY("Lxy"+extra), plotdir+"Lxy"+extra, "", "Vertices / bin");
683 saveTH1(hists->h_etaphi->ProjectionX("eta"+extra), plotdir+"eta"+extra, "", "Vertices / bin");
684 TH1* h_phi = hists->h_etaphi->ProjectionY("phi"+extra);
685 h_phi->GetXaxis()->SetRangeUser(-TMath::Pi(), TMath::Pi()); // adjust range
686 saveTH1(h_phi, plotdir+"phi"+extra, "", "Vertices / bin");
687 saveTH1(hists->h_distanceToIP, plotdir+"distanceToIP");
688
689 return;
690}
691
692
693void MSVtxPlotMaker::saveTGraph(TMultiGraph* zLxy, TMultiGraph* etaphi, std::unique_ptr<VtxPosTGraph> &graphs, const TString &plotdir){
694 // Combines the TGraph objects to a the TMultiGraph and save it.
695 zLxy->Add(graphs->zLxy_b, "P");
696 zLxy->Add(graphs->zLxy_e, "P");
697 zLxy->Add(graphs->zLxy_out, "P");
698 zLxy->GetXaxis()->SetRangeUser(-16,16);
699 zLxy->GetYaxis()->SetRangeUser(-1,12);
700 zLxy->Draw("A");
701 drawATLASlabel("Simulation Internal");
702 TLegend* legend_zLxy = makeLegend(0.16, 0.02, 0.65, 0.07, 0.05);
703 legend_zLxy->SetNColumns(3);
704 legend_zLxy->AddEntry(graphs->zLxy_b, "Barrel", "p");
705 legend_zLxy->AddEntry(graphs->zLxy_e, "Endcaps", "p");
706 legend_zLxy->AddEntry(graphs->zLxy_out, "Outside", "p");
707 legend_zLxy->Draw();
708 m_c->SaveAs(plotdir+"map_zLxy.pdf");
709 zLxy->Write();
710
711 etaphi->Add(graphs->etaphi_b, "P");
712 etaphi->Add(graphs->etaphi_e, "P");
713 etaphi->Add(graphs->etaphi_out, "P");
714 etaphi->GetXaxis()->SetRangeUser(-2.6,2.6);
715 etaphi->GetYaxis()->SetRangeUser(-TMath::Pi()-0.25,TMath::Pi()+1);
716 etaphi->Draw("A");
717 drawATLASlabel("Simulation Internal");
718 TLegend* legend_etaphi = makeLegend(0.16, 0.02, 0.65, 0.07, 0.05);
719 legend_etaphi->SetNColumns(3);
720 legend_etaphi->AddEntry(graphs->etaphi_b, "Barrel", "p");
721 legend_etaphi->AddEntry(graphs->etaphi_e, "Endcaps", "p");
722 legend_etaphi->AddEntry(graphs->etaphi_out, "Outside", "p");
723 legend_etaphi->Draw();
724 m_c->SaveAs(plotdir+"map_etaphi.pdf");
725 etaphi->Write();
726
727 return;
728}
729
730
731void MSVtxPlotMaker::saveTH1(TH1* h, TString plotpath, const char* dectectorLabel, const char* new_ylabel, bool norm, bool logy){
732 // Saves the histogram with a detector label annotation and optionally normalizes (giving the frequency probability for each bin) it.
733 // Also allows to set a new y axis label and plot with a log y scale
734 // If normalisation or log scaling is applied, "_norm" or "_log" are appended to the histogram and file name
735
736 double maxy_factor = 1.4; // assures sufficeint space of annotations
737
738 if (norm){
739 h->Scale(1. / h->Integral()); // Add the argument "width" to normalize by bin-count*width to get the approximate pdf
740 h->SetName(TString(h->GetName())+"_norm");
741 plotpath = plotpath.Insert(plotpath.Last(*"."),"_norm");
742 }
743
744 if (logy){
745 gPad->SetLogy();
746 h->SetName(TString(h->GetName())+"_log");
747 plotpath = plotpath.Insert(plotpath.Last(*"."),"_log");
748 maxy_factor = 4;
749 }
750
751 if (new_ylabel){
752 h->GetYaxis()->SetTitle(new_ylabel);
753 }
754
755 h->SetMaximum(h->GetMaximum()*maxy_factor);
756 h->Draw("hist");
757 drawDetectorRegionLabel(h->GetName(), dectectorLabel);
758 drawATLASlabel("Simulation Internal");
759 m_c->SaveAs(plotpath+".pdf");
760 h->Write();
761
762 // reset log scale for next plots
763 gPad->SetLogy(0);
764
765 return;
766}
767
768
769void MSVtxPlotMaker::saveTHStack(TH1* h1, TH1* h2,
770 const TString &h1_legend, const TString &h2_legend,
771 const TString &title, const TString &plotpath,
772 int color1, int color2){
773 // save the passed TH1 as a THStack.
774 // The THStack title is required to have the format "name; x-axis label; y-axis label"
775 TObjArray *tx_stack = title.Tokenize(";");
776 auto name = ((TObjString*)(tx_stack->At(0)))->String();
777 THStack *h_stack = new THStack(name, name);
778 h1->SetLineColor(color1);
779 h2->SetLineColor(color2);
780 h_stack->Add(h1);
781 h_stack->Add(h2);
782 // adjust maximum for sufficent space for annotations and draw
783 double maxy = h2->GetMaximum()>h1->GetMaximum() ? h2->GetMaximum() : h1->GetMaximum();
784 h_stack->SetMaximum(1.4*maxy);
785 h_stack->Draw("nostack");
786 h_stack->GetXaxis()->SetTitle(((TObjString*)(tx_stack->At(1)))->String());
787 h_stack->GetYaxis()->SetTitle(((TObjString*)(tx_stack->At(2)))->String());
788 // add annotations
789 TLegend* legend = makeLegend();
790 legend->AddEntry(h1, h1_legend, "l");
791 legend->AddEntry(h2, h2_legend, "l");
792 legend->Draw();
794 drawATLASlabel("Simulation Internal");
795
796 m_c->SaveAs(plotpath+".pdf");
797 h_stack->Write();
798
799 return;
800}
801
802
803void MSVtxPlotMaker::saveTEfficiency(TH1* h_num, TH1* h_denom,
804 const TString &title, const TString &plotpath){
805 // computes a TEfficiency object from the passed numerator and denominator histogram and saves it
806
807 TEfficiency* h_eff = new TEfficiency(*h_num, *h_denom);
808 h_eff->SetTitle(title);
809 TObjArray *tx_eff = title.Tokenize(";");
810 h_eff->SetName(((TObjString*)(tx_eff->At(0)))->String());
811 // set drawing style and draw
812 h_eff->SetLineColor(1);
813 h_eff->SetMarkerColor(1);
814 h_eff->SetMarkerSize(0.5);
815 h_eff->SetMarkerStyle(24);
816 h_eff->Draw();
817 gPad->Update();
818 // adjust maximum for sufficient space for annotations and draw annotations
819 TGraphAsymmErrors* g_eff = h_eff->GetPaintedGraph();
820 double maxy = getMaxy(g_eff);
821 g_eff->GetYaxis()->SetRangeUser(0, 1.4*maxy);
822 g_eff->GetXaxis()->SetTitle(((TObjString*)(tx_eff->At(1)))->String());
823 g_eff->GetYaxis()->SetTitle(((TObjString*)(tx_eff->At(2)))->String());
824 // annotations
825 if (TString(h_eff->GetName()).Contains("_Lxy_")) drawDetectorBoundaryLines("Lxy", 1.1*maxy);
826 if (TString(h_eff->GetName()).Contains("_z_")) drawDetectorBoundaryLines("z", 1.1*maxy);
827 drawDetectorRegionLabel(h_eff->GetName());
828 drawATLASlabel("Simulation Internal");
829 gPad->Update();
830
831 m_c->SaveAs(plotpath+".pdf");
832 h_eff->Write();
833
834 return;
835}
836
837
838void MSVtxPlotMaker::saveTH2(TH2* h, const TString &plotpath){
839 // adjust margins to fit the palette on the pad
840 gPad->SetRightMargin(0.15);
841 h->Draw("colz");
842 drawATLASlabel("Simulation Internal");
843 m_c->SaveAs(plotpath+".pdf");
844 gPad->SetRightMargin(0.05); // reset margin for next plots
845
846 return;
847}
848
849
850// --- other helper functions --- //
851
852
853void MSVtxPlotMaker::setColorPalette(TStyle *plotStyle){
854 // define a custom colour palette
855 Int_t palette[100];
856 // define colours and compute the gradient between them.
857 // the i-th entry in the following arrays defines the rgb values
858 Double_t Red[] = {0.0, 0.0, 1.0, 1.0};
859 Double_t Green[] = {1.0, 1.0, 1.0, 0.0};
860 Double_t Blue[] = {1.0, 0.0, 0.0, 0.0};
861 Double_t Length[] = {0.0, 0.33, 0.66, 1.0};
862 Int_t firstColorIdx = TColor::CreateGradientColorTable(std::size(Length), Length, Red, Green, Blue, std::size(palette));
863 // fill the pallette with the gradient
864 for (unsigned int i=0; i<std::size(palette); i++) palette[i] = firstColorIdx+i;
865
866 plotStyle->SetPalette(std::size(palette), palette);
867 // plotStyle->SetPalette(kBlueRedYellow); // more standard color palette
868 plotStyle->SetNumberContours(100);
869
870 return;
871}
872
873
874TH1* MSVtxPlotMaker::getUnmatchedHist(TH1* h_all, TH1* h_matched, const TString &name_unmatched){
875 // takes the difference between the all vertices and the matched vertices to get the unmatched vertices
876 TH1* h_unmatched = (TH1*)h_all->Clone(name_unmatched);
877 h_unmatched->Add(h_matched, -1);
878 return h_unmatched;
879}
Scalar eta() const
pseudorapidity method
Scalar deltaR(const MatrixBase< Derived > &vec) const
@ Data
Definition BaseObject.h:11
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)
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
double deltaPhi(const Amg::Vector3D &v1, const Amg::Vector3D &v2)
float distance(const Amg::Vector3D &p1, const Amg::Vector3D &p2)
calculates the distance between two point in 3D space
Eigen::Matrix< double, 3, 1 > Vector3D
double getMaxy(const TGraphAsymmErrors *graph, double current_max)
void drawATLASlabel(const char *text, double x, double y, double textsize)
TLegend * makeLegend(double lower_x, double lower_y, double upper_x, double upper_y, double textsize)
void drawDetectorRegionLabel(const char *name, const char *customlabel, double x, double y, double textsize)
void drawDetectorBoundaryLines(const char *bin_var, double y_max)
int getNvtxDetectorRegion(const std::vector< Amg::Vector3D > &vertices)
bool hasMatch(const Amg::Vector3D &vtx1, const std::vector< Amg::Vector3D > &vtx2_vec)
std::vector< Amg::Vector3D > getVertexPos(const std::vector< double > &vtx_x, const std::vector< double > &vtx_y, const std::vector< double > &vtx_z)
Amg::Vector3D findBestMatch(const Amg::Vector3D &vtx, const std::vector< Amg::Vector3D > &candidates)
std::vector< std::vector< Amg::Vector3D > > getConstituentPos(int Nvtx, const std::vector< int > &obj_vtx_link, const std::vector< double > &obj_x, const std::vector< double > &obj_y, const std::vector< double > &obj_z)
double deltaPhi(double phiA, double phiB)
delta Phi in range [-pi,pi[
double deltaR(double rapidity1, double phi1, double rapidity2, double phi2)
from bare bare rapidity,phi