EIC 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]->Draw("COLZ");
36  vol->Draw();
37  surface->Draw();
38  surface_z->Draw();
39  c1->Print( (out_name+"_X0.pdf").c_str());
40  //c1->Print( (out_name+"_X0.root").c_str());
41 
42  delete c1;
43 
44  delete vol;
45  delete surface;
46  delete surface_z;
47  }
48 
49  // Cylinder
50  if(surface_info.type == 1){
51 
52  TText *vol = new TText(.1,.95,surface_info.name.c_str());
53  vol->SetNDC();
54  TText *surface = new TText(.1,.9,surface_info.id.c_str());
55  surface->SetNDC();
56  TText *surface_r = new TText(.1,.85,("R = " + to_string(surface_info.pos)).c_str() );
57  surface_r->SetNDC();
58 
59  TCanvas *c1 = new TCanvas("c1","mat_X0",1200,1200);
60  c1->SetRightMargin(0.14);
61  c1->SetTopMargin(0.14);
62  c1->SetLeftMargin(0.14);
63  c1->SetBottomMargin(0.14);
64  Map_prop[0]->Divide(Map_geant[0]);
65  Map_prop[0]->GetZaxis()->SetTitle("X0 ratio");
66  Map_prop[0]->Draw("COLZ");
67  vol->Draw();
68  surface->Draw();
69  surface_r->Draw();
70  c1->Print( (out_name+"_X0.pdf").c_str());
71  //c1->Print( (out_name+"_X0.root").c_str());
72 
73  delete c1;
74 
75  delete vol;
76  delete surface;
77  delete surface_r;
78  }
79 
80  return;
81 }
82 
83 
93 
94 void Mat_map_surface_plot_ratio(std::string input_file_prop = "", std::string input_file_geant = "", std::string json_surface_file = "", int nbprocess = -1, std::string name = "", std::string name_prop = "", std::string name_geant = ""){
95 
96  gStyle->SetOptStat(0);
97  gStyle->SetOptTitle(0);
98 
99  std::map<uint64_t,std::vector<TH2F*>> surface_hist_prop;
100  std::map<uint64_t,sinfo> surface_info_prop;
101 
102  std::map<uint64_t,std::vector<TH2F*>> surface_hist_geant;
103  std::map<uint64_t,sinfo> surface_info_geant;
104 
105  Fill(surface_hist_prop, surface_info_prop, input_file_prop, json_surface_file, nbprocess);
106  Fill(surface_hist_geant, surface_info_geant, input_file_geant, json_surface_file, nbprocess);
107 
108  for (auto hist_it = surface_hist_prop.begin(); hist_it != surface_hist_prop.end(); hist_it++){
109  if(name_prop != "") plot(hist_it->second, surface_info_prop[hist_it->first], name_prop);
110  if(name_geant != "") plot(surface_hist_geant[hist_it->first], surface_info_geant[hist_it->first], name_geant);
111  plot_ratio(hist_it->second,surface_hist_geant[hist_it->first], surface_info_prop[hist_it->first], name);
112 
113  for (auto hist : hist_it->second){
114  delete hist;
115  }
116  hist_it->second.clear();
117  for (auto hist : surface_hist_geant[hist_it->first]){
118  delete hist;
119  }
120  surface_hist_geant[hist_it->first].clear();
121  }
122 
123 }