Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-02-23 09:19:27

0001 {
0002 // Read reference data in dolan.txt
0003 FILE * fg1=fopen("dolan.txt", "r");
0004 Int_t n_points_dolan = 8;
0005 Float_t x1[n_points_dolan], y1[n_points_dolan];
0006 Float_t x, y;
0007 Int_t ncols_dolan;
0008 Int_t nlines1 = 0;
0009 
0010 while(1)
0011 {
0012     ncols_dolan = fscanf(fg1, "%f %f", &x, &y);
0013     if (ncols_dolan<0) break;
0014     x1[nlines1]= x;
0015     y1[nlines1] = y;
0016     nlines1++;
0017 }
0018 
0019 fclose(fg1);
0020 
0021 // Read the results of the brachyadvanced example
0022 // OncuraSourceMacro.mac with 20 B events
0023 
0024 FILE *fg2=fopen("geant4_6711_dose.txt", "r");
0025 Int_t n_points_geant4 = 398;
0026 Float_t x2[n_points_geant4], y2[n_points_geant4];
0027 Int_t ncols_geant4;
0028 Int_t nlines2 = 0;
0029 
0030 while(1)
0031 {
0032     ncols_geant4 = fscanf(fg2, "%f %f", &x, &y);
0033     if (ncols_geant4<0) break;
0034     x2[nlines2] = x;
0035     y2[nlines2] = y;
0036     nlines2++;
0037 }
0038 
0039 fclose(fg2);
0040 
0041 TGraph *gr1 = new TGraph (nlines1, x1, y1);
0042 TGraph *gr2 = new TGraph (nlines2, x2, y2);
0043 
0044 TCanvas *c1 = new TCanvas("c1", "Graph Draw Options", 200, 10, 600, 400);
0045 
0046 gPad->SetLogy();
0047 
0048 // Draw the graph with axis, continuous line, and put a '*' at each point
0049 
0050 gr1->SetTitle("Dose rate distribution");
0051 gr1->GetXaxis()->SetTitle("Distance from the centre (cm)");
0052 gr1->GetYaxis()->SetTitle("Normalised dose rate distribution");
0053 gr1->SetLineWidth(1);
0054 gr1->SetMarkerColor(1);
0055 gr1->SetMarkerStyle(20);
0056 gr1->Draw("AP");
0057 
0058 gr2->SetLineWidth(1);
0059 gr2->SetMarkerColor(2);
0060 gr2->SetMarkerStyle(21);
0061 gr2->SetMarkerSize(0.5);
0062 gr2->SetLineColor(2);
0063 gr2->Draw("CP");
0064 
0065 TLegend *leg = new TLegend(0.3, 0.5, 0.6, 0.8);
0066 leg->SetFillColor(0);
0067 leg->AddEntry(gr1, "Reference data", "lp");
0068 leg->AddEntry(gr2, "Geant4 - 20B Events", "lp");
0069 leg->Draw();
0070 
0071 }
0072 
0073