3 #include "TInterpreter.h"
5 #include "TApplication.h"
27 gStyle->SetOptStat(0000000000);
29 cout <<
"Enter fragment Z-number (eg. 1): ";
32 TCanvas *
c1 =
new TCanvas(
"fragmentYieldsPlot",
"Total yield of fragments zero to ten degrees as function of depth");
34 TString fragmentNameChoices[6] = {
"H",
"He",
"Li",
"Be",
"B",
"C"};
36 TString fragmentName = fragmentNameChoices[ZNumGiven-1];
38 std::cout << fragmentName << endl;
40 TH1F* dummyHisto =
new TH1F(
"dummyHisto", fragmentName +
" yields 0-10 degrees" ,100, 0.0,40);
41 dummyHisto->SetXTitle(
"Depth (cm)");
42 dummyHisto->SetYTitle(
"N/N0");
45 TString experimentalDataPath =
"experimentalData/iaeaBenchmark/yields/TDK" + fragmentName +
".dat";
50 in.open(experimentalDataPath);
54 TFile *
f =
new TFile(
"fragmentAngularDistribution.root",
"RECREATE");
55 TNtuple *
ntuple =
new TNtuple(
"ntuple",
"Data from ascii file",
"x:y");
59 Char_t n1[15], n2[15];
60 in >> DATAFLAG >> NDATA ;
63 cout <<n1<<
" "<<n2<<
"\n";
66 if (!in.good())
break;
67 if (nlines < 500 )
printf(
"%f %f\n",f1,f2);
71 std::cout <<
"Imported " << nlines <<
" lines from data-file" << endl;
76 TNtuple *simData =
new TNtuple(
"ntuple",
"Data from ascii file",
"depth:H:He:Li:Be:B:C");
80 TString
dir = gSystem->UnixPathName(gInterpreter->GetCurrentMacroName());
81 dir.ReplaceAll(
"fragmentAngularDistribution.C",
"");
82 dir.ReplaceAll(
"/./",
"/");
84 simData->Fill(0.0,0.0,0.0,0.0,0.0,0.0,1.0);
85 for(
int j = 1; j <= 40;j=j=j+1){
86 TString pDepth, fragment, Znum, normToOneAtZeroAngle;
87 pDepth = Form(
"%i",j);
92 TString simulationDataPath =
"IAEA_" + pDepth +
".root";
96 TFile *MCData = TFile::Open(simulationDataPath);
97 TNtuple *fragments = (TNtuple*) MCData->Get(
"fragmentNtuple");
100 TNtuple *metadata = (TNtuple*) MCData->Get(
"metaData");
101 Float_t events, detectorDistance,waterThickness,beamEnergy,energyError,phantomCenterDistance;
102 metadata->SetBranchAddress(
"events",&events);
103 metadata->SetBranchAddress(
"waterThickness",&waterThickness);
104 metadata->SetBranchAddress(
"detectorDistance",&detectorDistance);
105 metadata->SetBranchAddress(
"beamEnergy",&beamEnergy);
106 metadata->SetBranchAddress(
"energyError",&energyError);
107 metadata->SetBranchAddress(
"phantomCenterDistance",&phantomCenterDistance);
108 metadata->GetEntry(0);
110 Double_t scatteringDistance = detectorDistance - phantomCenterDistance;
113 Double_t r, rMin, rMax, graphMaximum = 0.0;
119 rMaxString = Form(
"%f", scatteringDistance*
TMath::ATan(degrees*TMath::DegToRad()));
121 Double_t H = ((
Double_t*) fragments->GetEntries(
"(Z == " + TString::Format(
"%i",1) +
" && sqrt(posY^2 + posZ^2) < " + rMaxString +
"&& sqrt(posY*posY + posZ*posZ) > " + rMinString +
")")) / norming;
122 Double_t He = ((
Double_t*) fragments->GetEntries(
"(Z == " + TString::Format(
"%i",2) +
" && sqrt(posY^2 + posZ^2) < " + rMaxString +
"&& sqrt(posY*posY + posZ*posZ) > " + rMinString +
")")) / norming;
123 Double_t Li = ((
Double_t*) fragments->GetEntries(
"(Z == " + TString::Format(
"%i",3) +
" && sqrt(posY^2 + posZ^2) < " + rMaxString +
"&& sqrt(posY*posY + posZ*posZ) > " + rMinString +
")")) / norming;
124 Double_t Be = ((
Double_t*) fragments->GetEntries(
"(Z == " + TString::Format(
"%i",4) +
" && sqrt(posY^2 + posZ^2) < " + rMaxString +
"&& sqrt(posY*posY + posZ*posZ) > " + rMinString +
")")) / norming;
125 Double_t B = ((
Double_t*) fragments->GetEntries(
"(Z == " + TString::Format(
"%i",5) +
" && sqrt(posY^2 + posZ^2) < " + rMaxString +
"&& sqrt(posY*posY + posZ*posZ) > " + rMinString +
")")) / norming;
126 Double_t C = ((
Double_t*) fragments->GetEntries(
"(Z == " + TString::Format(
"%i",6) +
" && sqrt(posY^2 + posZ^2) < " + rMaxString +
"&& sqrt(posY*posY + posZ*posZ) > " + rMinString +
")")) / norming;
127 simData->Fill(waterThickness,H,He,Li,Be,B,C);
131 simData->SetMarkerStyle(2);
132 simData->SetMarkerColor(kBlue);
133 graphMaximum = TMath::Max(graphMaximum, simData->GetMaximum(fragmentName));
134 graphMaximum = TMath::Max(graphMaximum, ntuple->GetMaximum(
"y"));
135 dummyHisto->SetMaximum(graphMaximum + .05*graphMaximum);
138 simData->Draw(fragmentName +
":depth",
"",
"p,same");
140 ntuple->SetMarkerStyle(22);
141 ntuple->SetMarkerColor(kRed);
142 ntuple->Draw(
"y:x",
"",
"p,same");
143 c1->SaveAs(
"fragmentYieldsFor" + fragmentName +
".png");
void fragmentYieldsPlot()
printf("%d Experimental points found\n", nlines)