3 #include "TInterpreter.h"
5 #include "TApplication.h"
33 gStyle->SetOptStat(0000000000);
34 gROOT->SetStyle(
"clearRetro");
36 TString
dir = gSystem->UnixPathName(gInterpreter->GetCurrentMacroName());
37 dir.ReplaceAll(
"fragmentAngularDistribution.C",
"");
38 dir.ReplaceAll(
"/./",
"/");
42 TString pDepth, fragment, Znum, normToOneAtZeroAngle;
43 cout <<
"Enter phantom depth (eg. 27.9, see experimentalData directory for choices): ";
45 cout <<
"Enter fragment Z-number (eg. 1): ";
49 TString fragmentNameChoices[6] = {
"H",
"He",
"Li",
"Be",
"B",
"C"};
50 TString fragment = fragmentNameChoices[ZnumInt - 1];
51 Znum = Form(
"%i",ZnumInt);
52 cout <<
"Normalize to 1 at zero angle? (Y/N): ";
53 cin >> normToOneAtZeroAngle;
55 TString experimentalDataPath =
"experimentalData/iaeaBenchmark/angularDistributions/" + pDepth +
"/" + fragment +
"" + pDepth +
".dat";
56 TString simulationDataPath =
"IAEA_" + pDepth +
".root";
58 TCanvas *
c1 =
new TCanvas(
"AngularDistribution",
"Angular distribution with discrete measurement annuluses");
61 in.open(experimentalDataPath);
65 TFile *
f =
new TFile(
"fragmentAngularDistribution.root",
"RECREATE");
66 TNtuple *
ntuple =
new TNtuple(
"ntuple",
"Data from ascii file",
"x:y");
70 Char_t n1[15], n2[15];
71 in >> DATAFLAG >> NDATA ;
74 cout <<n1<<
" "<<n2<<
"\n";
77 if (!in.good())
break;
78 if (nlines < 500 )
printf(
"%f %f\n",f1,f2);
82 std::cout <<
"Imported " << nlines <<
" lines from data-file" << endl;
86 TFile *MCData = TFile::Open(simulationDataPath);
87 TNtuple *fragments = (TNtuple*) MCData->Get(
"fragmentNtuple");
90 TNtuple *metadata = (TNtuple*) MCData->Get(
"metaData");
91 Float_t events, detectorDistance,waterThickness,beamEnergy,energyError,phantomCenterDistance;
92 metadata->SetBranchAddress(
"events",&events);
93 metadata->SetBranchAddress(
"waterThickness",&waterThickness);
94 metadata->SetBranchAddress(
"detectorDistance",&detectorDistance);
95 metadata->SetBranchAddress(
"beamEnergy",&beamEnergy);
96 metadata->SetBranchAddress(
"energyError",&energyError);
97 metadata->SetBranchAddress(
"phantomCenterDistance",&phantomCenterDistance);
98 metadata->GetEntry(0);
105 Double_t scatteringDistance = detectorDistance - phantomCenterDistance;
111 TString rMinString, rMaxString, experimentalNorm;
115 TNtuple* distrib =
new TNtuple(
"angularDistrib",
"FragmentAngularDistrib",
"angle:particleAmount:normalized");
116 std::cout <<
"Fragments comparison to the graphs in appendices of E.Haettner\n";
117 std::cout <<
"Scattering distance: " << scatteringDistance <<
" cm" << endl ;
118 std::cout <<
"(scattering distance may vary with data-files too, see haettner A.1." << endl << endl;
122 rMaxString = Form(
"%f", detectorSideLength/2);
129 Double_t deltaPhi = TMath::ATan((detectorSideLength/2)/scatteringDistance);
138 Double_t normEntries = fragments->GetEntries(
"(Z == " + Znum +
" && posY < " + rMaxString +
" && posY > -" + rMaxString +
" && posZ > -" + rMaxString +
" && posZ < " + rMaxString +
")");
139 Double_t zeroSA = 4 * TMath::ASin(pow(detectorSideLength,2.0) / (4*pow(scatteringDistance,2) + pow(detectorSideLength,2)) );
140 Double_t zeroYieldNormed = normEntries / (events * zeroSA);
141 if(normToOneAtZeroAngle ==
"Y"){
142 Double_t zeroNorm = zeroYieldNormed;
147 distrib->Fill(0,normEntries,zeroYieldNormed/zeroNorm);
149 std::cout <<
"Norming events: " << normEntries << endl;
151 for(
Double_t j = deltaPhi*TMath::RadToDeg(); j <= 15.0; j=j+.05){
153 degrees = j * TMath::DegToRad();
155 r = scatteringDistance * TMath::Tan(degrees);
174 Double_t deltaPhi = TMath::ATan((TMath::Cos(degrees)*detectorSideLength)/(2*scatteringDistance));
175 rMin = TMath::Max(0.0,r - (detectorSideLength/(2*TMath::Cos(degrees))));
176 rMax = rMin + ((detectorSideLength*TMath::Sin(degrees))/TMath::Tan((TMath::Pi()/2) - degrees - deltaPhi)) + (detectorSideLength*TMath::Cos(degrees));
177 rMinString = Form(
"%f", rMin);
178 rMaxString = Form(
"%f", rMax);
183 Double_t deltaOmega = 2*TMath::Pi()*(TMath::Cos(TMath::Max(0.0,degrees-deltaPhi)) - TMath::Cos(degrees+deltaPhi));
184 int numEntries = fragments->GetEntries(
"(Z == " + Znum +
" && sqrt(posY^2 + posZ^2) < " + rMaxString +
"&& sqrt(posY*posY + posZ*posZ) > " + rMinString +
")");
185 distrib->Fill(j,numEntries,numEntries/(deltaOmega * events * zeroNorm));
186 distrib->Fill(-j,numEntries,numEntries/(deltaOmega * events * zeroNorm));
187 maxValue = TMath::Max(maxValue, numEntries/(deltaOmega * events * zeroNorm));
189 distrib->SetMarkerStyle(2);
190 distrib->SetMarkerColor(kBlue);
191 ntuple->SetMarkerStyle(22);
192 ntuple->SetMarkerColor(kRed);
194 TH1F* dummHisto =
new TH1F(
"dummyHisto", fragment +
", " + Form(
"%.1f", waterThickness) +
" cm",100, -3.0,14);
195 dummyHisto->SetXTitle(
"Angle (degrees)");
196 dummyHisto->SetYTitle(
"(N/N0) [sr^-1]");
197 if(normToOneAtZeroAngle ==
"Y"){
198 dummyHisto->SetMaximum(1.1);
199 dummyHisto->SetYTitle(
"[sr^-1]");
202 ntuple->SetBranchAddress(
"y",&zeroPosData);
203 ntuple->SetBranchAddress(
"x",&zeroPosAngle);
205 ntuple->GetEntry(row);
206 while(zeroPosAngle*zeroPosAngle > .01){
208 ntuple->GetEntry(row);
209 if(row == ntuple->GetEntries()){
210 std::cerr <<
"Could not find zero angle data in imported experimental data. Change normalization or relax exactness of this check." << endl;
215 std::cout <<
"For zero-position of experimental data using angle " << zeroPosAngle <<
" with amount " << zeroPosData <<
" on row " << row << endl;
216 experimentalNorm = Form(
"(1/%f)*", zeroPosData);
219 dummyHisto->SetMaximum(ntuple->GetMaximum(
"y")+ ntuple->GetMaximum(
"y")*.1);
220 experimentalNorm =
"";
223 ntuple->Draw(experimentalNorm +
"y:x",
"",
"p,same");
224 distrib->Draw(
"normalized:angle",
"angle > -3 && angle < 14",
"p,same");
227 Float_t fwhm = 0.0, middle = 0.0, currentX, currentY;
228 distrib->SetBranchAddress(
"normalized",¤tY);
229 distrib->SetBranchAddress(
"angle",¤tX);
230 for(
int i = 0; i < distrib->GetEntries(); i++){
231 distrib->GetEntry(i);
232 if(pow(maxValue/2 - middle, 2.0) > pow(maxValue/2 - currentY, 2.0)){
238 std::cout <<
"Calculated (closest point) FWHM of Monte-Carlo simulation to be: " << fwhm <<
" degrees" << endl;
258 pDepth.ReplaceAll(
".",
"");
259 c1->SaveAs(
"AD_" + pDepth +
"_" + Znum +
"_" + normToOneAtZeroAngle +
".png");
void fragmentAngularDistribution()
printf("%d Experimental points found\n", nlines)