3 #include "TInterpreter.h"
5 #include "TApplication.h"
33 TCanvas *
c1 =
new TCanvas(
"AngularDistribution",
"Angular distribution with discrete measurement annuluses");
35 gROOT->SetStyle(
"clearRetro");
37 TString
dir = gSystem->UnixPathName(gInterpreter->GetCurrentMacroName());
41 TString pDepth =
"5.9";
42 TString fragment =
"H";
46 in.open(Form(
"experimentalData/iaeaBenchmark/alternativeGMBeamAD.dat",dir.Data()));
47 std::cout <<
"experimentalData/iaeaBenchmark/angularDistributions/" + pDepth +
"/" + fragment + pDepth +
".dat" << endl;
48 std::cout <<
"didata" << dir.Data() << endl;
51 TFile *
f =
new TFile(
"fragmentAngularDistribution.root",
"RECREATE");
52 TNtuple *
ntuple =
new TNtuple(
"ntuple",
"Data from ascii file",
"x:y");
56 Char_t n1[15], n2[15];
57 in >> DATAFLAG >> NDATA ;
60 cout <<n1<<
" "<<n2<<
"\n";
63 if (!in.good())
break;
64 if (nlines < 500 )
printf(
"%f %f\n",f1,f2);
68 std::cout <<
"Imported " << nlines <<
" lines from data-file" << endl;
72 TFile *MCData = TFile::Open(
"IAEA_G-M.root");
73 TNtuple *fragments = (TNtuple*) MCData->Get(
"fragmentNtuple");
76 TNtuple *metadata = (TNtuple*) MCData->Get(
"metaData");
77 Float_t events, detectorDistance,waterThickness,beamEnergy,energyError,phantomCenterDistance;
78 metadata->SetBranchAddress(
"events",&events);
79 metadata->SetBranchAddress(
"waterThickness",&waterThickness);
80 metadata->SetBranchAddress(
"detectorDistance",&detectorDistance);
81 metadata->SetBranchAddress(
"beamEnergy",&beamEnergy);
82 metadata->SetBranchAddress(
"energyError",&energyError);
83 metadata->SetBranchAddress(
"phantomCenterDistance",&phantomCenterDistance);
84 metadata->GetEntry(0);
91 Double_t scatteringDistance = detectorDistance - phantomCenterDistance;
102 TNtuple* distrib =
new TNtuple(
"angularDistrib",
"FragmentAngularDistrib",
"angle:particleAmount:normalized");
103 std::cout <<
"Fragments comparison to the graphs in appendices of E.Haettner\n";
104 std::cout <<
"Scattering distance: " << scatteringDistance <<
" cm" << endl ;
105 std::cout <<
"(scattering distance may vary with data-files too, see haettner A.1." << endl << endl;
109 rMaxString = Form(
"%f", detectorSideLength/2);
116 Double_t deltaPhi = TMath::ATan((detectorSideLength/2)/scatteringDistance);
125 Double_t normEntries = fragments->GetEntries(
"(A == " + Anum +
" && posY < " + rMaxString +
" && posY > -" + rMaxString +
" && posZ > -" + rMaxString +
" && posZ < " + rMaxString +
")");
126 Double_t zeroSA = 4 * TMath::ASin(pow(detectorSideLength,2.0) / (4*pow(scatteringDistance,2) + pow(detectorSideLength,2)) );
127 Double_t zeroNorm = normEntries / (events * zeroSA);
128 distrib->Fill(0,normEntries,zeroNorm);
130 std::cout <<
"Norming events: " << normEntries << endl;
132 for(
Double_t j = deltaPhi*TMath::RadToDeg(); j <= 15.0; j=j+.05){
134 degrees = j * TMath::DegToRad();
136 r = scatteringDistance * TMath::Tan(degrees);
140 Double_t deltaPhi = TMath::ATan((TMath::Cos(degrees)*detectorSideLength)/(2*scatteringDistance));
141 rMin = TMath::Max(0.0,r - (detectorSideLength/(2*TMath::Cos(degrees))));
142 rMax = rMin + ((detectorSideLength*TMath::Sin(degrees))/TMath::Tan((TMath::Pi()/2) - degrees - deltaPhi)) + (detectorSideLength*TMath::Cos(degrees));
143 rMinString = Form(
"%f", rMin);
144 rMaxString = Form(
"%f", rMax);
148 Double_t deltaOmega = 2*TMath::Pi()*(TMath::Cos(TMath::Max(0.0,degrees-deltaPhi)) - TMath::Cos(degrees+deltaPhi));
149 int numEntries = fragments->GetEntries(
"(A == " + Anum +
" && sqrt(posY^2 + posZ^2) < " + rMaxString +
"&& sqrt(posY*posY + posZ*posZ) > " + rMinString +
")");
151 distrib->Fill(j,numEntries,numEntries/(deltaOmega * events));
153 distrib->Fill(-j,numEntries,numEntries/(deltaOmega * events));
154 maxValue = TMath::Max(maxValue, numEntries/(deltaOmega * events));
156 distrib->SetMarkerStyle(2);
157 distrib->SetMarkerColor(kBlue);
158 distrib->Draw(
"normalized:angle",
"angle > -3 && angle < 14",
"p");
159 ntuple->SetMarkerStyle(22);
160 ntuple->SetMarkerColor(kRed);
163 ntuple->SetBranchAddress(
"y",&zeroPosData);
164 ntuple->SetBranchAddress(
"x",&zeroPosAngle);
166 ntuple->GetEntry(row);
167 while(zeroPosAngle*zeroPosAngle > .01){
169 ntuple->GetEntry(row);
170 if(row == ntuple->GetEntries()){
171 std::cerr <<
"Could not find zero angle data in imported experimental data. Change normalization or relax exactness of this check." << endl;
175 std::cout <<
"For zero-position of experimental data using angle " << zeroPosAngle <<
" with amount " << zeroPosData <<
" on row " << row << endl;
176 TString experimentalNorm = Form(
"(1/%f)*", zeroPosData);
177 ntuple->Draw(experimentalNorm +
"y:x",
"",
"p,same");
180 Float_t fwhm = 0.0, middle = 0.0, currentX, currentY;
181 distrib->SetBranchAddress(
"normalized",¤tY);
182 distrib->SetBranchAddress(
"angle",¤tX);
183 for(
int i = 0; i < distrib->GetEntries(); i++){
184 distrib->GetEntry(i);
185 if(pow(maxValue/2 - middle, 2.0) > pow(maxValue/2 - currentY, 2.0)){
191 std::cout <<
"Calculated (closest point) FWHM of Monte-Carlo simulation to be: " << fwhm <<
" degrees" << endl;
210 c1->SaveAs(
"AD_for_Z_" + Anum +
"_ComparedToGM.png");
void fragmentAngularDistributionGM()
printf("%d Experimental points found\n", nlines)