EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
perigeeParamResolution.C
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file perigeeParamResolution.C
1 // This file is part of the Acts project.
2 //
3 // Copyright (C) 2019 CERN for the benefit of the Acts project
4 //
5 // This Source Code Form is subject to the terms of the Mozilla Public
6 // License, v. 2.0. If a copy of the MPL was not distributed with this
7 // file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 
9 #include <TF1.h>
10 #include <TH1F.h>
11 #include <TMath.h>
12 #include <TTree.h>
13 #include <iostream>
14 #include <map>
15 #include <vector>
16 
17 using namespace ROOT;
18 
19 void
20 setHistStyle(TH1F* hist, short color);
21 
22 // This ROOT script will plot the residual and pull of perigee track parameters (d0,
23 // z0, phi, theta, q/p, t) from root file produced by the TrackFitterPerformanceWriter
24 //
25 void
26 perigeeParamResolution(const std::string& inFile)
27 {
28  gStyle->SetOptFit(0000);
29  gStyle->SetOptStat(0000);
30  gStyle->SetPadLeftMargin(0.20);
31  gStyle->SetPadRightMargin(0.05);
32  gStyle->SetPadTopMargin(0.1);
33  gStyle->SetPadBottomMargin(0.15);
34 
35  // Open root file written by RootTrajectoryWriter
36  std::cout << "Opening file: " << inFile << std::endl;
37  TFile* file = TFile::Open(inFile.c_str(), "read");
38 
39  // Track parameter name
40  std::vector<std::string> paramNames
41  = {"d0", "z0", "phi", "theta", "qop", "t"};
42 
43  map<string, TH1F*> res;
44  map<string, TH1F*> pull;
45 
46  // Create the hists and set up
47  for (const auto& par: paramNames) {
48  // residual hists
49  res[par] = (TH1F*) file->Get(Form("res_%s", par.c_str()));
50  // pull hists
51  pull[par] = (TH1F*) file->Get(Form("pull_%s", par.c_str()));
52 
53  // set style
54  setHistStyle(res[par], 2);
55  setHistStyle(pull[par], 2);
56  }
57 
58 
59  // plotting residual
60  TCanvas* c1 = new TCanvas("c1", "c1", 1200, 800);
61  c1->Divide(3, 2);
62  for (size_t ipar = 0; ipar < paramNames.size(); ipar++) {
63  c1->cd(ipar + 1);
64  res[paramNames.at(ipar)]->Draw("");
65  }
66 
67  // plotting pull
68  TCanvas* c2 = new TCanvas("c2", "c2", 1200, 800);
69  c2->Divide(3, 2);
70  for (size_t ipar = 0; ipar < paramNames.size(); ipar++) {
71  c2->cd(ipar + 1);
72  pull[paramNames.at(ipar)]->Draw("");
73  }
74 }
75 
76 // function to set up the histgram style
77 void
78 setHistStyle(TH1F* hist, short color = 1)
79 {
80  hist->GetXaxis()->SetTitleSize(0.05);
81  hist->GetYaxis()->SetTitleSize(0.05);
82  hist->GetXaxis()->SetLabelSize(0.05);
83  hist->GetYaxis()->SetLabelSize(0.05);
84  hist->GetXaxis()->SetTitleOffset(1.);
85  hist->GetYaxis()->SetTitleOffset(1.8);
86  hist->GetXaxis()->SetNdivisions(505);
87  hist->SetMarkerStyle(20);
88  hist->SetMarkerSize(0.8);
89  hist->SetLineWidth(2);
90  //hist->SetTitle("");
91  hist->SetLineColor(1);
92  hist->SetMarkerColor(color);
93 }