Geant4_10
comparison.C
Go to the documentation of this file.
1 // G.A.P.Cirrone (2009)
2 
3 // Comparison beetwen experimental and simulated non modulated Bragg Peak
4 // Remember to run this file only if simulation has been run with the
5 // proton_therapy.mac file
6 
7 {
8 gROOT->Reset();
9 #include "Riostream.h"
10 
11  ifstream in;
12 
13 
14  // LOAD THE EXPERIMENTAL DATA FILE
15  // CONTAINED IN THE DIRECTORY
16  // hadrontherapy/experimentalData/proton/BraggPeak
17  TFile *experimentalFile = new TFile("../../../experimentalData/proton/BraggPeak/62MeVInWater.root","READ");
18 
19  // HERE THE ROOT FILE IS INTERPRETED AS A TREE
20  TTree *experimentalTree = (TTree*)experimentalFile -> Get("Experimental62MeVInWater");
21 
23  experimentalTree -> SetBranchAddress("EdepExp", &EdepExp);
24  experimentalTree -> SetBranchAddress("depthExp", &depthExp);
25 
26 
27  // CREATION AND NORMALISATION TO THE FIRST POINT OF AN NTUPLE CONTAINING THE EXPERIMENTAL DATA
28  TNtuple *ntupleExperimental = new TNtuple("ntupleExperimental","Protons, exp. data", "depthExp:EdepExp");
29  Int_t nentries = (Int_t)experimentalTree -> GetEntries();
30  for (Int_t i = 0; i<nentries; i++)
31  {
32  experimentalTree -> GetEntry(0);
34  experimentalTree -> GetEntry(i);
35  ntupleExperimental -> Fill(depthExp, EdepExp/normFactor);
36 
37  }
38 
39  // LOAD THE SIMULATION RESULT FILE
40  // CONTAINED IN THE DIRECTORY
41  // hadrontherapy/simulationResults/proton/BraggPeak
42  TFile *simulationFile = new TFile("../../../SimulationOutputs/proton/BraggPeak/protonBraggPeak.root","READ");
43 
44  // EXTRACTION, FROM THE SIMULATION FILE OF THE INTERESTING HISTOGRAMS
45  TH1D *simulatedPeak = (TH1D*) simulationFile -> Get("braggPeak");
46 
47  Float_t simulationNormalisationFactor = simulatedPeak -> GetBinContent(1);
48  simulatedPeak -> Scale(1/simulationNormalisationFactor);
49 
50 
51  TCanvas *c1 = new TCanvas ("c1","c1",200,10,600,400);
52 
53  // PLOT
54  ntupleExperimental -> SetMarkerStyle(4);
55  simulatedPeak -> SetMarkerSize(2);
56 
57  ntupleExperimental -> Draw("EdepExp:depthExp");
58  simulatedPeak-> Draw("same");
59 
60  // LEGEND
61  leg = new TLegend(0.50,0.60,0.20,0.70);
62  leg -> SetTextSize(0.035);
63  leg -> SetFillColor(0);
64  leg -> AddEntry(ntupleExperimental, "Experiment","P");
65  leg -> AddEntry(simulatedPeak, "Simulation");
66  leg -> Draw();
67 
68 
69 
70 
71 };
TFile * experimentalFile
Definition: comparison.C:17
Float_t simulationNormalisationFactor
Definition: comparison.C:47
Float_t normFactor
hist1 Draw("HIST")
TH1D * simulatedPeak
Definition: comparison.C:45
ifstream in
Definition: comparison.C:7
ntupleExperimental Fill(depthExp, EdepExp)
Int_t nentries
Definition: comparison.C:29
leg AddEntry(ntupleExperimental,"Experiment","P")
TCanvas * c1
Definition: plotHisto.C:7
TFile * simulationFile
Definition: comparison.C:42
Float_t depthExp
Definition: comparison.C:22
Float_t EdepExp
Definition: comparison.C:22
ntuple SetMarkerStyle(20)
G4int Int_t
cout<< "Opened file "<< fin<< " ixs= "<< ixs<< endl;if(ixs==0) hhh=(TH1F *) fff-> Get("h1")
Definition: AddMC.C:8
cout<< t1-> GetEntries()
Definition: plottest35.C:29
TTree * experimentalTree
Definition: comparison.C:20
experimentalTree SetBranchAddress("EdepExp",&EdepExp)
TNtuple * ntupleExperimental
Definition: comparison.C:28
G4float Float_t
simulatedPeak Scale(1/simulationNormalisationFactor)
hipStyle SetTextSize(0.05)
ntuple SetMarkerSize(1)
leg
Definition: comparison.C:61
ntupleExperimental GetEntry(0)
ntuple SetFillColor(2)