ECCE @ EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
comparison.C
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file comparison.C
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 };