Geant4  v4-10.4-release
TG43_relative_dose.C
이 파일의 문서화 페이지로 가기
1 {
2 // Create output file geant4_dose.txt with the dose rate distribution, calculated
3 // with the simulation results containted in brachytherapy.root
4
5 gROOT -> Reset();
6 TFile f("brachytherapy.root");
7
8 Double_t Seed_length = 0.35; //seed length in cm
9
10 Double_t EnergyMap[401]; //2D map of total energy in "radial distance (mm)" and "angle (5 degrees)"
11 Int_t Voxels[401]; //the number of voxels used to provide dose to each element of the energy map
12 Double_t normDose[401]; //Energy map divided by voxels used to make cell, normalised to energy deposition at 1cm, 90 degrees
13 Double_t GeomFunction[401]; //Geometry Function, normalised to the geometry function at the reference point
14 Double_t GeometryFunctionZero; //Geometry function at reference point, 1cm and 90 degrees
15 Double_t beta; //beta angle for Geometry Function calculation
16 Double_t R; //radial distance in cm
17 Double_t K; //polar angle in radians
22
23 for (int i=0; i <401; i++)
24  {
25  EnergyMap[i]=0.;
26  Voxels[i]=0.;
27 }
28
29 //Build Energy Deposition Map
30 for (int k=0; k< numberOfBins; k++)
31  {
32  for (int m=0; m< numberOfBins; m++)
33  {
34  Double_t xx_histo = h20.GetXaxis()->GetBinCenter(k);
35  Double_t yy_histo = h20.GetYaxis()->GetBinCenter(m);
36  Double_t edep_histo=h20.GetBinContent(k, m);
38  // if ((edep_histo!=0) && radius < 12. && radius > 9) std::cout << "histo: " << xx_histo << ", " << yy_histo
39  // << ", radius: " << radius <<", edep: "<< edep_histo << std::endl;
40
44  {
48
49  }
50  }
51
52 }}
53
54 std::cout << "Energy Map Complete" << std::endl;
55
56 //Create Normalised Dose Map
57 std::cout << "The energy deposition at the reference point is " << EnergyMap[40] << std::endl;
58 Double_t tempNormValue = EnergyMap[40]/Voxels[40];
59 //value at 1cm, 90 degrees, the normalisation point
60 std::cout << "Dose rate ditribution (distances in cm)" << std::endl;
61
62 ofstream myfile;
63
64 myfile.open ("geant4_dose.txt");
65
66 for (int i=0; i<=400; i++)
67 {
68  R = double(i)/40; //distance in CM!!!
69  if (Voxels[i]>0) normDose[i] = EnergyMap[i]/Voxels[i]/tempNormValue;
70  else normDose[i] = 0;
71
72
73
74  if (R> 0.05)
75  {
76  cout << R << " " << normDose[i] << endl;
77  myfile << R << " " << normDose[i] << "\n";
78  }
79 }
80
81 myfile.close();
82 }
83
Double_t EnergyMap[401]
G4double Double_t
Double_t GeometryFunctionZero
Double_t GeomFunction[401]
Double_t beta
Double_t K
static constexpr double m
Definition: G4SIunits.hh:129
G4int Int_t
Double_t normDose[401]
ntupleExperimental Reset()
Int_t numberOfBins