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 // Author: Sebastien Incerti, CNRS, France
7 // Date: 25 Feb. 2015
8 // The Geant4-DNA collaboration
9 // *********************************************************************
10 {
11 gROOT->Reset();
12 gStyle->SetPalette(1);
13 gROOT->SetStyle("Plain");
14 gStyle->SetOptStat(00000);
15 
16 //***************************************
17 //***************************************
18 // MAKE YOUR SELECTIONS
19 // for histograms
20 //***************************************
21 //***************************************
22 
23 Int_t linB=100; // linear histo: nb of bins in x - 1000 is best for integration
24 Double_t ymin=1; // minimum x-axis value
25 Double_t ymax=300; // maximum x-axis value
26 
27 //***************************************
28 //***************************************
29 
30 system ("rm -rf yz.root");
31 system ("hadd yz.root yz_*.root");
32 
33 c1 = new TCanvas ("c1","",60,60,800,800);
34 Int_t mycolor;
35 
36 TFile f("yz.root");
37 mycolor=4;
38 
39 TNtuple* ntuple;
40 ntuple = (TNtuple*)f.Get("yz");
41 
43 ntuple->SetBranchAddress("radius",&radius);
44 ntuple->SetBranchAddress("eventID",&eventID);
45 ntuple->SetBranchAddress("nbHits",&nofHits);
46 ntuple->SetBranchAddress("nbScoredHits",&nbEdep);
47 ntuple->SetBranchAddress("y",&y);
48 ntuple->SetBranchAddress("z",&z);
49 ntuple->SetBranchAddress("Einc",&Einc);
50 
51 //plot f(y)
52 
53 c1->cd(1);
54 
55 TH1F *hfyw = new TH1F ("hfyw","hfyw",linB,0,ymax);
56 
57 Int_t nentries = (Int_t)ntuple->GetEntries();
58 Double_t population=0;
59 Double_t yLocalMin=1e100;
60 Double_t yLocalMax=0;
61 
62 Double_t yF_anal=0;
63 Double_t yD_anal=0;
64 
65 for (Int_t i=0; i<nentries; i++)
66 {
67  ntuple->GetEntry(i);
68 
69  hfyw->Fill(y,nofHits/nbEdep);
70  if (yLocalMin>y) yLocalMin=y;
71  if (yLocalMax<y) yLocalMax=y;
72  population=population+nofHits/nbEdep;
73  yF_anal = yF_anal + (nofHits/nbEdep)*y;
74  yD_anal = yD_anal + (nofHits/nbEdep)*y*y;
75 }
76 
77 cout << "**** Results ****" << endl;
78 cout << endl;
79 cout << "---> yF =" << yF_anal/population << " keV/um" << endl;
80 cout << "---> yD =" << (yD_anal/population)/(yF_anal/population) << " keV/um" << endl;
81 cout << endl;
82 cout << "---> Limits: " << endl;
83 cout << " * min value of y = " << yLocalMin << " keV/um" << endl;
84 cout << " * max value of y = " << yLocalMax << " keV/um" << endl;
85 
86 if ( (yLocalMax>ymax) || (yLocalMin<ymin) )
87 {
88  cout << "WARNING: please check your histogram limits ! " << endl;
89 }
90 
91 gPad->SetLogy();
92 hfyw->Scale (1./(population*hfyw->GetBinWidth(1)));
93 hfyw->SetTitle("f(y) (um/keV)");
94 hfyw->GetXaxis()->SetTitle("y (keV/um)");
95 hfyw->SetFillColor(2);
96 hfyw->SetLineColor(2);
97 hfyw->Draw("HIST");
98 }
99 
Double_t population
Definition: plot.C:58
Double_t y
Definition: plot.C:277
Double_t Einc
Definition: plot.C:42
system("rm -rf microbeam.root")
TFile f("microbeam.root")
Double_t yLocalMax
Definition: plot.C:60
Double_t z
Definition: plot.C:277
Double_t yF_anal
Definition: plot.C:62
Int_t eventID
Definition: plot.C:81
TH1F * hfyw
Definition: plot.C:55
TNtuple * ntuple
Definition: plot.C:20
Double_t ymax
Definition: plot.C:25
Double_t nofHits
Definition: plot.C:42
Int_t mycolor
Definition: plot.C:34
Int_t nentries
Definition: plot.C:281
Double_t nbEdep
Definition: plot.C:42
Int_t linB
Definition: plot.C:23
Double_t radius
Definition: plot.C:42
OStream cout
Definition: OStream.cxx:6
Double_t yD_anal
Definition: plot.C:63
c1
Definition: plot.C:28
Double_t yLocalMin
Definition: plot.C:59
Double_t ymin
Definition: plot.C:24