EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Mat_map_detector_plot_ratio.C
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file Mat_map_detector_plot_ratio.C
1 // This file is part of the Acts project.
2 //
3 // Copyright (C) 2020 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 
10 
12 
13 void plot_ratio(std::vector<TH2F*> Map_prop, std::vector<TH2F*> Map_geant, std::vector<int> detectors, const std::string& name){
14 
15 
16  TH2F *Unit_Map_prop = (TH2F*) Map_prop[2]->Clone();
17  Unit_Map_prop->Divide(Map_prop[2]);
18  TH2F *Unit_Map_geant = (TH2F*) Map_geant[2]->Clone();
19  Unit_Map_geant->Divide(Map_geant[2]);
20 
21  TH1D *Proj_eta_prop = (TH1D*) Map_prop[0]->ProjectionX()->Clone();
22  Proj_eta_prop->Divide(Unit_Map_prop->ProjectionX());
23  TH1D *Proj_eta_geant = (TH1D*) Map_geant[0]->ProjectionX()->Clone();
24  Proj_eta_geant->Divide(Unit_Map_geant->ProjectionX());
25 
26  TH1D *Proj_phi_prop = (TH1D*) Map_prop[0]->ProjectionY()->Clone();
27  Proj_phi_prop->Divide(Unit_Map_prop->ProjectionY());
28  TH1D *Proj_phi_geant = (TH1D*) Map_geant[0]->ProjectionY()->Clone();
29  Proj_phi_geant->Divide(Unit_Map_geant->ProjectionY());
30 
31  std::string sVol = "Detector volumes :";
32  for(auto const& det: detectors) {
33  sVol += " ";
34  sVol += std::to_string(det);
35  }
36  TText *vol = new TText(.1, .95, sVol.c_str());
37  vol->SetNDC();
38 
39  TCanvas *c1 = new TCanvas("c1","mat_X0",1200,1200);
40  c1->SetRightMargin(0.14);
41  c1->SetTopMargin(0.14);
42  c1->SetLeftMargin(0.14);
43  c1->SetBottomMargin(0.14);
44  Map_prop[0]->Divide(Map_geant[0]);
45  Map_prop[0]->GetZaxis()->SetTitle("X0 Val/Geant");
46  Map_prop[0]->SetMaximum(2.);
47  Map_prop[0]->Draw("COLZ");
48  vol->Draw();
49  c1->Print( (name+"ratio_X0.pdf").c_str());
50 
51  TCanvas *c2 = new TCanvas("c2", "mat_X0/eta", 1200, 1200);
52  c2->SetRightMargin(0.14);
53  c2->SetTopMargin(0.14);
54  c2->SetLeftMargin(0.14);
55  c2->SetBottomMargin(0.14);
56 
57  Proj_eta_prop->Divide(Proj_eta_geant);
58  Proj_eta_prop->GetYaxis()->SetTitle("X0 Val/Geant");
59  Proj_eta_prop->SetMarkerStyle(7);
60  Proj_eta_prop->Draw("HIST PC");
61  c2->Print((name + "ratio_X0_eta.pdf").c_str());
62 
63  TCanvas *c3 = new TCanvas("c3", "mat_X0/phi", 1200, 1200);
64  c3->SetRightMargin(0.14);
65  c3->SetTopMargin(0.14);
66  c3->SetLeftMargin(0.14);
67  c3->SetBottomMargin(0.14);
68  Proj_phi_prop->Divide(Proj_phi_geant);
69  Proj_phi_prop->GetYaxis()->SetTitle("X0 Val/Geant");
70  Proj_phi_prop->SetMarkerStyle(7);
71  Proj_phi_prop->Draw("HIST PC");
72  c3->Print((name + "ratio_X0_phi.pdf").c_str());
73 
74  delete c1;
75  delete c2;
76  delete c3;
77  delete vol;
78  delete Unit_Map_prop;
79  delete Unit_Map_geant;
80 }
81 
82 
90 
91 void Mat_map_detector_plot_ratio(std::string input_file_prop = "", std::string input_file_geant = "", std::vector<int> detectors = vector<int>(), int nbprocess = -1, std::string name = "", std::string name_prop = "", std::string name_geant = ""){
92 
93  gStyle->SetOptStat(0);
94  gStyle->SetOptTitle(0);
95 
96  std::vector<TH2F*> detector_hist_prop;
97  std::vector<TH2F*> detector_hist_geant;
98 
99  Fill(detector_hist_prop, input_file_prop, detectors, nbprocess);
100  Fill(detector_hist_geant, input_file_geant, detectors, nbprocess);
101 
102  plot(detector_hist_prop, detectors, name_prop);
103  plot(detector_hist_geant, detectors, name_geant);
104  plot_ratio(detector_hist_prop, detector_hist_geant, detectors, name);
105 }