Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Mat_map_surface_plot_ratio.C
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file Mat_map_surface_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 
9 #include "Mat_map_surface_plot.C"
10 
12 
13 void plot_ratio(std::vector<TH2F*> Map_prop, std::vector<TH2F*> Map_geant, const sinfo& surface_info, const std::string& name){
14 
15  std::string out_name = name+"/"+surface_info.name+"/"+surface_info.name+"_"+surface_info.idname;
16  gSystem->Exec( Form("mkdir %s", (name+"/"+surface_info.name).c_str()) );
17 
18  // Disk
19  if(surface_info.type == 2){
20 
21  TText *vol = new TText(.1,.95,surface_info.name.c_str());
22  vol->SetNDC();
23  TText *surface = new TText(.1,.9,surface_info.id.c_str());
24  surface->SetNDC();
25  TText *surface_z = new TText(.1,.85,("Z = " + to_string(surface_info.pos)).c_str() );
26  surface_z->SetNDC();
27 
28  TCanvas *c1 = new TCanvas("c1","mat_X0",1200,1200);
29  c1->SetRightMargin(0.14);
30  c1->SetTopMargin(0.14);
31  c1->SetLeftMargin(0.14);
32  c1->SetBottomMargin(0.14);
33  Map_prop[0]->Divide(Map_geant[0]);
34  Map_prop[0]->GetZaxis()->SetTitle("X0 ratio");
35  Map_prop[0]->SetMaximum(2.);
36  Map_prop[0]->Draw("COLZ");
37  vol->Draw();
38  surface->Draw();
39  surface_z->Draw();
40  c1->Print( (out_name+"_X0.pdf").c_str());
41  //c1->Print( (out_name+"_X0.root").c_str());
42 
43  delete c1;
44 
45  delete vol;
46  delete surface;
47  delete surface_z;
48  }
49 
50  // Cylinder
51  if(surface_info.type == 1){
52 
53  TText *vol = new TText(.1,.95,surface_info.name.c_str());
54  vol->SetNDC();
55  TText *surface = new TText(.1,.9,surface_info.id.c_str());
56  surface->SetNDC();
57  TText *surface_r = new TText(.1,.85,("R = " + to_string(surface_info.pos)).c_str() );
58  surface_r->SetNDC();
59 
60  TCanvas *c1 = new TCanvas("c1","mat_X0",1200,1200);
61  c1->SetRightMargin(0.14);
62  c1->SetTopMargin(0.14);
63  c1->SetLeftMargin(0.14);
64  c1->SetBottomMargin(0.14);
65  Map_prop[0]->Divide(Map_geant[0]);
66  Map_prop[0]->GetZaxis()->SetTitle("X0 ratio");
67  Map_prop[0]->SetMaximum(2.);
68  Map_prop[0]->Draw("COLZ");
69  vol->Draw();
70  surface->Draw();
71  surface_r->Draw();
72  c1->Print( (out_name+"_X0.pdf").c_str());
73  //c1->Print( (out_name+"_X0.root").c_str());
74 
75  delete c1;
76 
77  delete vol;
78  delete surface;
79  delete surface_r;
80  }
81 
82  return;
83 }
84 
85 
92 
93 void Mat_map_surface_plot_ratio(std::string input_file_prop = "", std::string input_file_geant = "", int nbprocess = -1, std::string name = "", std::string name_prop = "", std::string name_geant = ""){
94 
95  gStyle->SetOptStat(0);
96  gStyle->SetOptTitle(0);
97 
98  std::map<uint64_t,std::vector<TH2F*>> surface_hist_prop;
99  std::map<uint64_t,sinfo> surface_info_prop;
100 
101  std::map<uint64_t,std::vector<TH2F*>> surface_hist_geant;
102  std::map<uint64_t,sinfo> surface_info_geant;
103 
104  Fill(surface_hist_prop, surface_info_prop, input_file_prop, nbprocess);
105  Fill(surface_hist_geant, surface_info_geant, input_file_geant, nbprocess);
106 
107  for (auto hist_it = surface_hist_prop.begin(); hist_it != surface_hist_prop.end(); hist_it++){
108  if(name_prop != "") plot(hist_it->second, surface_info_prop[hist_it->first], name_prop);
109  if(name_geant != "") plot(surface_hist_geant[hist_it->first], surface_info_geant[hist_it->first], name_geant);
110  plot_ratio(hist_it->second,surface_hist_geant[hist_it->first], surface_info_prop[hist_it->first], name);
111 
112  for (auto hist : hist_it->second){
113  delete hist;
114  }
115  hist_it->second.clear();
116  for (auto hist : surface_hist_geant[hist_it->first]){
117  delete hist;
118  }
119  surface_hist_geant[hist_it->first].clear();
120  }
121 
122 }