3 #include "TInterpreter.h"
5 #include "TApplication.h"
26 TString normToZeroPos;
27 cout <<
"Normalize to first bin? (Y/N):";
30 TCanvas *
c1 =
new TCanvas(
"Bragg curve",
"Bragg curve comparison");
33 gStyle->SetOptStat(0000000000);
35 gROOT->SetStyle(
"clearRetro");
37 TString
dir = gSystem->UnixPathName(gInterpreter->GetCurrentMacroName());
38 dir.ReplaceAll(
"basic.C",
"");
39 dir.ReplaceAll(
"/./",
"/");
41 in.open(Form(
"experimentalData/iaeaBenchmark/400tdk.dat",dir.Data()));
45 TFile *
f =
new TFile(
"fragmentAngularDistribution.root",
"RECREATE");
46 TNtuple *
ntuple =
new TNtuple(
"ntuple",
"Data from ascii file",
"d:i:err1:err2");
50 Char_t n1[15], n2[15], n3[15], n4[15];
51 in >> DATAFLAG >> NDATA ;
52 in >> n1 >> n2 >> n3 >> n4;
54 cout <<n1<<
" "<<n2<<
" "<<n3<<
" "<<n4<<
"\n";
56 in >> f1 >> f2 >> f3 >>
f4;
60 if (nlines < 500 )
printf(
"%f %f %f %f\n",f1,f2,f3,f4);
61 ntuple->Fill(f1,f2,f3,f4);
66 TFile* simulation = TFile::Open(
"IAEA_braggPeak.root");
67 TH1F* simBragg = (TH1F*) simulation->Get(
"braggPeak");
70 TNtuple *metadata = (TNtuple*) simulation->Get(
"metaData");
71 Float_t events, detectorDistance,waterThickness,beamEnergy,energyError,phantomCenterDistance;
72 metadata->SetBranchAddress(
"events",&events);
73 metadata->SetBranchAddress(
"waterThickness",&waterThickness);
74 metadata->SetBranchAddress(
"detectorDistance",&detectorDistance);
75 metadata->SetBranchAddress(
"beamEnergy",&beamEnergy);
76 metadata->SetBranchAddress(
"energyError",&energyError);
77 metadata->SetBranchAddress(
"phantomCenterDistance",&phantomCenterDistance);
78 metadata->GetEntry(0);
83 simBragg->GetXaxis()->SetLimits(0.0, waterThickness);
84 simBragg->SetLineColor(kBlue);
85 simBragg->SetXTitle(
"Depth in phantom (cm)");
87 simBragg->GetYaxis()->SetTitleOffset(1.5);
88 std::cout <<
"Maximum (Bragg peak) for simulation data is at: " << simBragg->GetBinCenter(simBragg->GetMaximumBin()) + 0.478/2 + 0.027 + 0.073 << endl;
89 std::cout <<
"Bin width is " << simBragg->GetBinWidth(simBragg->GetMaximumBin()) << endl;
92 if(normToZeroPos ==
"Y"){
94 ntuple->SetBranchAddress(
"i",&normElement);
96 scaleTuple = Form(
"/%f", normElement);
97 simBragg->Scale(1.0/simBragg->GetBinContent(0));
98 simBragg->SetYTitle(
"Relative ionization");
100 simBragg->Scale(1.0/(100*events*simBragg->GetBinWidth(0)));
101 simBragg->SetYTitle(
"Ionization (MeV/m)");
107 ntuple->SetMarkerColor(kRed);
108 ntuple->SetMarkerStyle(22);
109 std::cout << ntuple->GetEntries() << endl;
110 ntuple->Draw(
"i" + scaleTuple +
":d-(0.478+0.027+0.073)",
"",
"p,same");
111 c1->SaveAs(
"braggPeakComparisonToData_norm_" + normToZeroPos +
".png");
printf("%d Experimental points found\n", nlines)