LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
plot.C
Go to the documentation of this file.
1 // *********************************************************************
2 // To execute this macro under ROOT after your simulation ended,
3 // 1 - launch ROOT (usually type 'root' at your machine's prompt)
4 // 2 - type '.X plot.C' at the ROOT session prompt
5 // *********************************************************************
6 {
7  gROOT->Reset();
8  gStyle->SetPalette(1);
9  gROOT->SetStyle("Plain");
10 
11  c1 = new TCanvas ("c1","",20,20,800,800);
12  c1->Divide(1,1);
13 
14  TFile f("slowing.root");
15 
16  TH1F* h1 ;
17  h1 = (TH1F*)f.Get("1");
18  h2 = (TH1F*)f.Get("2");
19  h3 = (TH1F*)f.Get("3");
20 
21 //goto end;
22 
23  Int_t nbinsx = h1->GetXaxis()->GetNbins();
24  //cout << nbinsx << endl;
25 
26  Double_t y = 0;
27  Double_t mini = 0;
28  Double_t maxi = 0;
29  Double_t largeur = 0;
30 
31  Double_t sum = 0;
32 
33  // Division by bin width to get y axis
34  // in nm/eV
35  //
36  // Scaling by 1E9/1.6 to get correct unit
37  // for Phi/D in (/cm2/eV/Gy)
38  // when histogram (in nm/eV) is
39  // multiplied by density(=1g/cm3)/E(eV)
40 
41  for (Int_t i=1; i<=nbinsx; i++)
42  {
43  sum = sum + h1->GetBinContent(i);
44 
45  mini = h1->GetBinLowEdge(i);
46  maxi = mini + h1->GetBinWidth(i);
47  largeur = std::pow(10,maxi)-std::pow(10,mini);
48  // cout << mini << " " << std::pow(10,mini)<< " " << largeur
49  // << " " << maxi << " " << std::pow(10,maxi) << endl;
50  h1->SetBinContent(i,h1->GetBinContent(i)*(1E9/1.6)/largeur);
51  h2->SetBinContent(i,h2->GetBinContent(i)*(1E9/1.6)/largeur);
52  h3->SetBinContent(i,h3->GetBinContent(i)*(1E9/1.6)/largeur);
53 
54  }
55 
56  gStyle->SetOptStat(000000);
57 
58  cout << endl;
59  cout << "--> Integral of Phi (nm/eV) = " << sum << endl;
60  cout << endl;
61 
62 c1->cd(1);
63 
64  TH2F *ht = new TH2F("","",2,1,6,2,1E2,1E8);
65  ht->Draw();
66  ht->GetXaxis()->SetTitle("Log(E (eV))");
67  ht->GetYaxis()->SetTitle("#phi/D (/cm^{2}/eV/Gy)");
68  ht->GetXaxis()->SetTitleSize(0.03);
69  ht->GetYaxis()->SetTitleSize(0.03);
70  ht->GetXaxis()->SetTitleOffset(1.7);
71  ht->GetYaxis()->SetTitleOffset(1.7);
72 
73  gPad->SetLogy();
74  h1->SetLineColor(2);
75  h1->Draw("HSAME");
76  h2->SetLineColor(3);
77  h2->Draw("HSAME");
78  h3->SetLineColor(4);
79  h3->Draw("HSAME");
80  h1->Draw("HSAME");
81 
82  TLegend *legend=new TLegend(0.6,0.65,0.88,0.85);
83  legend->AddEntry(h1,"All e-","L");
84  legend->AddEntry(h2,"Primaries","L");
85  legend->AddEntry(h3,"Secondaries","L");
86  legend->Draw();
87 
88 end:
89 }
Double_t y
Definition: plot.C:276
h3
Definition: plot.C:19
TFile f("microbeam.root")
TLegend * legend
Definition: plot.C:36
decltype(auto) constexpr end(T &&obj)
ADL-aware version of std::end.
Definition: StdUtils.h:77
Double_t maxi
Definition: plot.C:28
Double_t mini
Definition: plot.C:27
TH1F * h2
Definition: plot.C:44
Int_t nbinsx
Definition: plot.C:23
c1
Definition: plot.C:27
TH1F * h1
Definition: plot.C:41
Double_t sum
Definition: plot.C:31
Double_t largeur
Definition: plot.C:29