3 #include "TInterpreter.h"
5 #include "TApplication.h"
24 TString
dir = gSystem->UnixPathName(gInterpreter->GetCurrentMacroName());
25 dir.ReplaceAll(
"fragmentEnergy.C",
"");
26 dir.ReplaceAll(
"/./",
"/");
28 TString macroPath(gROOT->GetMacroPath());
29 gROOT->SetMacroPath(macroPath +
":RootScripts/iaeaBenchmark");
34 in.open(Form(
"experimentalData/iaeaBenchmark/fragmentEnergySpctra279mmWater0deg.dat",dir.Data()));
37 TFile *
f =
new TFile(
"fragmentEnergy.root",
"RECREATE");
38 TNtuple *
ntuple =
new TNtuple(
"ntuple",
"Data from ascii file",
"Energy:He:B:H:Li:Be");
42 Char_t n1[6], n2[2], n3[2], n4[2], n5[2], n6[2];
43 in >> DATAFLAG >> NDATA ;
44 in >> n1 >> n2 >> n3 >> n4 >> n5 >> n6;
46 cout <<n1<<
" "<<n2<<
" "<<n3<<
" "<<n4<<
" "<<n5<<
" "<<n6<<
"\n";
48 in >> f1 >> f2 >> f3 >>f4 >> f5 >> f6;
49 if (!in.good())
break;
50 if (nlines < 500 )
printf(
"%f %0.2f %0.2f %0.2f %0.2f %0.2f \n",f1,f2,f3,f4,f5,f6);
51 ntuple->Fill(f1,f2,f3,f4,f5,f6);
55 printf(
" found %d points\n",nlines);
58 TFile *MCData = TFile::Open(
"IAEA_15.9.root");
59 TH1F* MC_helium = (TH1F*)MCData->Get(
"heliumEnergyAfterPhantom");
60 TH1F* MC_hydrogen = (TH1F*)MCData->Get(
"hydrogenEnergyAfterPhantom");
62 TNtuple *fragments = (TNtuple*) MCData->Get(
"fragmentNtuple");
65 TNtuple *metadata = (TNtuple*) MCData->Get(
"metaData");
66 Float_t events, detectorDistance,waterThickness,beamEnergy,energyError,phantomCenterDistance;
67 metadata->SetBranchAddress(
"events",&events);
68 metadata->SetBranchAddress(
"waterThickness",&waterThickness);
69 metadata->SetBranchAddress(
"detectorDistance",&detectorDistance);
70 metadata->SetBranchAddress(
"beamEnergy",&beamEnergy);
71 metadata->SetBranchAddress(
"energyError",&energyError);
72 metadata->SetBranchAddress(
"phantomCenterDistance",&phantomCenterDistance);
73 metadata->GetEntry(0);
76 Double_t scatteringDistance = detectorDistance - phantomCenterDistance;
82 fragments->SetLineColor(kRed);
83 fragments->SetMarkerStyle(22);
86 TH1F* posYHisto =
new TH1F(
"vertical",
"Vertical distribution of beam",200,-2.,2.);
87 TH1F* posZHisto =
new TH1F(
"horizontal",
"horizontal distribution of beam",200,-2.,2.);
88 TH2F* posHisto =
new TH2F(
"posHisto",
"Distribution of beam",200,-2.,2.,200,-2.,2.);
90 fragments->Project(
"vertical",
"posZ",
"abs(posZ) < 2 && abs(posY) < 2 && Z == 6");
91 fragments->Project(
"horizontal",
"posY",
"abs(posZ) < 2 && abs(posY) < 2 && Z == 6");
92 Float_t maxVal = posYHisto->GetMaximum();
93 std::cout <<
"maximum: " << maxVal << endl;
98 Float_t fwhm = 0.0, middle = 0.0, curVal;
101 for(
int i = 0; i < posYHisto->GetNbinsX(); i++){
103 curVal = posYHisto->GetBinContent(i);
104 if(pow(maxVal/2 - middle, 2.0) > pow(maxVal/2 - curVal, 2.0)){
105 fwhm = 2*TMath::Abs(posYHisto->GetBinCenter(i));
119 TF1* fitgaus =
new TF1(
"fitgaus",
"gaus");
120 fitgaus->SetLineColor(2);
121 posYHisto->Fit(fitgaus,
"");
123 std::cout <<
"fitted FWHM from normal distribution is: " << fitgaus->GetParameter(2)*10*2.35482 << endl;
128 std::cout <<
"Calculated (closest point) FWHM of Monte-Carlo simulation to be: " << fwhm*10 <<
" mm" << endl;
129 std::cout <<
"beam contained " << fragments->GetEntries(
"Z == 6") <<
" carbon nuclei." << endl;