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[ 10.5 ] [ 10.5.p1 ] [ 10.6 ] [ 10.6.p1 ] [ 10.6.p2 ] [ 10.6.p3 ] [ 10.7 ] [ 10.7.p1 ] [ 10.7.p2 ] [ 10.7.p3 ] [ 10.7.p4 ] [ 11.0 ] [ 11.0.p1 ] [ 11.0.p2 ] [ 11.0.p3, ] [ 11.0.p4 ] [ 11.1 ] [ 11.1.1 ] [ 11.1.2 ] [ 11.1.3 ] [ 11.2 ] [ 11.2.1 ] [ 11.2.2 ] [ 11.3.0 ]

Diff markup

Differences between /examples/advanced/brachytherapy/comparison/TG43_relative_dose.C (Version 11.3.0) and /examples/advanced/brachytherapy/comparison/TG43_relative_dose.C (Version 11.1)


  1 void Read(TString source, TString physics_list      1 void Read(TString source, TString physics_list){
  2 // Create output file geant4_dose.txt with the      2 // Create output file geant4_dose.txt with the dose rate distribution, calculated
  3 // with the simulation results containted in b      3 // with the simulation results containted in brachytherapy.root
  4                                                     4 
  5 gROOT -> Reset();                                   5 gROOT -> Reset();
  6 TString fileName="brachytherapy_"+source+"_"+p      6 TString fileName="brachytherapy_"+source+"_"+physics_list+".root";
  7 std::cout<< "Reading " << fileName << std::end      7 std::cout<< "Reading " << fileName << std::endl;
  8 //const char * c = fileName.c_str();                8 //const char * c = fileName.c_str();
  9 TFile f(fileName);                                  9 TFile f(fileName);
 10                                                    10                
 11 Double_t Seed_length = 0.35; //seed length in      11 Double_t Seed_length = 0.35; //seed length in cm
 12                                                    12 
 13 Double_t EnergyMap[401]; //2D map of total ene     13 Double_t EnergyMap[401]; //2D map of total energy in "radial distance (mm)" and "angle (5 degrees)"
 14 Int_t Voxels[401]; //the number of voxels used     14 Int_t Voxels[401]; //the number of voxels used to provide dose to each element of the energy map
 15 Double_t normDose[401]; //Energy map divided b     15 Double_t normDose[401]; //Energy map divided by voxels used to make cell, normalised to energy deposition at 1cm, 90 degrees
 16 Double_t GeomFunction[401]; //Geometry Functio     16 Double_t GeomFunction[401]; //Geometry Function, normalised to the geometry function at the reference point
 17 Double_t GeometryFunctionZero;  //Geometry fun     17 Double_t GeometryFunctionZero;  //Geometry function at reference point, 1cm and 90 degrees
 18 Double_t beta;  //beta angle for Geometry Func     18 Double_t beta;  //beta angle for Geometry Function calculation
 19 Double_t R;     //radial distance in cm            19 Double_t R;     //radial distance in cm
 20 Double_t K;     //polar angle in radians           20 Double_t K;     //polar angle in radians
 21 Double_t Radial[401]; //radial dose function       21 Double_t Radial[401]; //radial dose function
 22 Double_t radius; //radius (mm)                     22 Double_t radius; //radius (mm)
 23 Int_t radInt; //nearest integer of radius (mm)     23 Int_t radInt; //nearest integer of radius (mm)
 24 Int_t numberOfBins=801;                            24 Int_t numberOfBins=801;
 25                                                    25 
 26 for (int i=0; i <401; i++)                         26 for (int i=0; i <401; i++)
 27  {                                                 27  {
 28  EnergyMap[i]=0.;                                  28  EnergyMap[i]=0.;
 29  Voxels[i]=0.;                                     29  Voxels[i]=0.;
 30 }                                                  30 }
 31                                                    31 
 32 //Build Energy Deposition Map                      32 //Build Energy Deposition Map
 33 for (int k=0; k< numberOfBins; k++)                33 for (int k=0; k< numberOfBins; k++)
 34  {                                                 34  {
 35    for (int m=0; m< numberOfBins; m++)             35    for (int m=0; m< numberOfBins; m++) 
 36  {                                                 36  {
 37    Double_t xx_histo = h20->GetXaxis()->GetBin     37    Double_t xx_histo = h20->GetXaxis()->GetBinCenter(k);
 38    Double_t yy_histo = h20->GetYaxis()->GetBin     38    Double_t yy_histo = h20->GetYaxis()->GetBinCenter(m);
 39    Double_t edep_histo=h20->GetBinContent(k, m     39    Double_t edep_histo=h20->GetBinContent(k, m);
 40    radius = sqrt(xx_histo*xx_histo+yy_histo*yy     40    radius = sqrt(xx_histo*xx_histo+yy_histo*yy_histo);
 41  //  if ((edep_histo!=0) && radius < 12. && ra     41  //  if ((edep_histo!=0) && radius < 12. && radius > 9) std::cout << "histo: " << xx_histo << ", " << yy_histo 
 42    //                                              42    //                                                             << ", radius: " << radius <<", edep: "<< edep_histo << std::endl;
 43                                                    43 
 44     if (radius != 0){                              44     if (radius != 0){
 45           radInt = TMath::Nint(4*radius);          45           radInt = TMath::Nint(4*radius);
 46           if ((radInt>0)&&(radInt<=400))           46           if ((radInt>0)&&(radInt<=400))
 47       {                                            47       {
 48        EnergyMap[radInt]+= edep_histo;             48        EnergyMap[radInt]+= edep_histo;
 49        Voxels[radInt]+= 1;                         49        Voxels[radInt]+= 1;
 50                       //   if (radius < 12. &&     50                       //   if (radius < 12. && radius > 9 && edep_histo!=0)std::cout<< "Radius: " << radius << ", radInt:"<<radInt << ", EnergyMap: "<< EnergyMap[radInt]<< ", voxels: " << Voxels[radInt]<< std::endl;
 51                                                    51                          
 52         }                                          52         }
 53       }                                            53       }
 54                                                    54 
 55 }}                                                 55 }}
 56                                                    56 
 57 //Create Normalised Dose Map                       57 //Create Normalised Dose Map
 58 std::cout << "The energy deposition at the ref     58 std::cout << "The energy deposition at the reference point is " << EnergyMap[40] << std::endl;
 59 Double_t tempNormValue = EnergyMap[40]/Voxels[     59 Double_t tempNormValue = EnergyMap[40]/Voxels[40]; 
 60 //value at 1cm, 90 degrees, the normalisation      60 //value at 1cm, 90 degrees, the normalisation point
 61 std::cout << "Dose rate ditribution (distances     61 std::cout << "Dose rate ditribution (distances in cm)" << std::endl;
 62                                                    62 
 63 ofstream myfile;                                   63 ofstream myfile;
 64 TString outputFileName ="geant4_dose_"+ source     64 TString outputFileName ="geant4_dose_"+ source+"_"+physics_list+".txt";
 65 //const char * cOutputFileName  = fileName.c_s     65 //const char * cOutputFileName  = fileName.c_str();
 66 myfile.open(outputFileName);                       66 myfile.open(outputFileName);
 67 std::cout << "file " << outputFileName << " is     67 std::cout << "file " << outputFileName << " is created "<<std::endl; 
 68                                                    68 
 69 for (int i=0; i<=400; i++)                         69 for (int i=0; i<=400; i++)
 70 {                                                  70 {
 71  R = double(i)/40; //distance in CM!!!             71  R = double(i)/40; //distance in CM!!!
 72  if (Voxels[i]>0) normDose[i] = EnergyMap[i]/V     72  if (Voxels[i]>0) normDose[i] = EnergyMap[i]/Voxels[i]/tempNormValue;
 73     else normDose[i] = 0;                          73     else normDose[i] = 0;
 74                                                    74 
 75                                                    75  
 76                                                    76             
 77  if (R>  0.05)                                     77  if (R>  0.05)
 78     {                                              78     {
 79    // cout << R << "     " << normDose[i] << e     79    // cout << R << "     " << normDose[i] << endl;  
 80     myfile << R <<  "     " << normDose[i] <<      80     myfile << R <<  "     " << normDose[i] << "\n";                     
 81     }                                              81     }
 82 }                                                  82 }
 83                                                    83 
 84 myfile.close();                                    84 myfile.close();
 85 }                                                  85 }
 86                                                    86 
 87                                                    87