LArSoft  v07_13_02
Liquid Argon Software toolkit - http://larsoft.org/
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 
22  Float_t depthExp, EdepExp;
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);
33  Float_t normFactor = EdepExp;
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 };
leg SetFillColor(0)
ntupleExperimental Draw("EdepExp:depthExp")
TNtupleSim Fill(f1, f2, f3, f4)
leg AddEntry(ntupleExperimental,"Experiment","P")
Float_t simulationNormalisationFactor
Definition: comparison.C:47
experimentalTree SetBranchAddress("EdepExp",&EdepExp)
Float_t normFactor
leg SetTextSize(0.035)
cout<< t1-> GetEntries()
Definition: plottest35.C:29
simulatedPeak SetMarkerSize(2)
TCanvas * c1
Definition: comparison.C:51
cout<< "Opened file "<< fin<< " ixs= "<< ixs<< endl;if(ixs==0) hhh=(TH1F *) fff-> Get("h1")
Definition: AddMC.C:8
Float_t depthExp
Definition: comparison.C:22
TFile * simulationFile
Definition: comparison.C:42
TH1D * simulatedPeak
Definition: comparison.C:45
TFile * experimentalFile
Definition: comparison.C:17
Float_t EdepExp
Definition: comparison.C:22
ntupleExperimental SetMarkerStyle(4)
leg
Definition: comparison.C:61
Int_t nentries
Definition: comparison.C:29
TTree * experimentalTree
Definition: comparison.C:20
ifstream in
Definition: comparison.C:7
TNtuple * ntupleExperimental
Definition: comparison.C:28
simulatedPeak Scale(1/simulationNormalisationFactor)
ntupleExperimental GetEntry(0)