#include <RunAction.hh>
Public Member Functions | |
RunAction (DetectorConstruction *) | |
~RunAction () | |
void | BeginOfRunAction (const G4Run *) |
void | EndOfRunAction (const G4Run *) |
void | SumEvents (G4double e) |
void | SumDepthDose (G4double, G4double) |
void | SumDepthDoseSD (G4double, G4double) |
void | WriteDepthDose (G4String) |
Private Attributes | |
DetectorConstruction * | m_detector |
G4double | m_sumEdep |
G4double | m_sumEdep2 |
G4int | m_nbEntry |
std::vector< G4double > | m_depthDose |
std::vector< G4double > | m_depthDoseSD |
G4double | m_astronautHeight |
G4double | m_sliceWidth |
G4int | m_nbSlices |
Definition at line 19 of file RunAction.hh.
RunAction::RunAction | ( | DetectorConstruction * | det | ) |
RunAction::~RunAction | ( | ) |
void RunAction::BeginOfRunAction | ( | const G4Run * | run | ) |
Definition at line 28 of file RunAction.cc.
00029 { 00030 G4cout << "### Run " << run->GetRunID() << " start." << G4endl; 00031 00032 //initialize total energy deposit 00033 // 00034 m_sumEdep = m_sumEdep2 = 0.; 00035 m_nbEntry = 0; 00036 00037 //construct vector of m_depthDose distribution 00038 // 00039 m_nbSlices = 100; 00040 m_astronautHeight = m_detector->GetAstronautHeight(); 00041 m_sliceWidth = m_astronautHeight/m_nbSlices; 00042 m_depthDose.resize(m_nbSlices, 0.); 00043 m_depthDoseSD.resize(m_nbSlices, 0.); 00044 00045 }
void RunAction::EndOfRunAction | ( | const G4Run * | ) |
Definition at line 86 of file RunAction.cc.
00087 { 00088 G4double meanEd = 0., meanEd2 = 0., rmsEd = 0., error_rel_sum = 0.; 00089 if (m_nbEntry) { 00090 meanEd = m_sumEdep/m_nbEntry; meanEd2 = m_sumEdep2/m_nbEntry; 00091 G4double variance = meanEd2 - meanEd*meanEd; 00092 if (variance > 0.) rmsEd = std::sqrt(variance); 00093 error_rel_sum = rmsEd/(meanEd*std::sqrt(double(m_nbEntry))); 00094 } 00095 00096 // choose printing format 00097 std::ios::fmtflags mode = G4cout.flags(); 00098 G4cout.setf(std::ios::fixed,std::ios::floatfield); 00099 G4int prec = G4cout.precision(3); 00100 00101 //print total energy deposit 00102 // 00103 G4cout 00104 << "\n ---> Nb of non-empty events = " << m_nbEntry 00105 << "\n ---> Mean Edep per event = " << G4BestUnit(meanEd,"Energy") 00106 << "\n ---> Total Energy deposited = " << G4BestUnit(m_sumEdep,"Energy") 00107 << " +- " << G4BestUnit(m_sumEdep*error_rel_sum,"Energy") 00108 << " (-> " << 100*error_rel_sum << " %)" 00109 << G4endl; 00110 00111 //get mass of astronaut 00112 // 00113 G4double mass = m_detector->GetAstronaut()->GetLogicalVolume()->GetMass(); 00114 00115 //compute dose 00116 // 00117 G4double dose = m_sumEdep/mass; 00118 G4cout.setf(mode,std::ios::floatfield); 00119 G4cout.precision(5); 00120 G4cout << " ---> Dose = " << G4BestUnit(dose,"Dose") 00121 << " +- " << G4BestUnit(dose*error_rel_sum,"Dose") << "\n" 00122 << G4endl; 00123 00124 // restaure default formats 00125 G4cout.setf(mode,std::ios::floatfield); 00126 G4cout.precision(prec); 00127 00128 // convert m_depthDose array from energy to dose 00129 // 00130 for (G4int k=0; k<m_nbSlices; k++) m_depthDose[k] /= mass; 00131 // 00132 for (G4int k=0; k<m_nbSlices; k++) m_depthDoseSD[k] /= mass; 00133 00134 00135 00136 // write m_depthDose array on a file 00137 // 00138 WriteDepthDose("depthDose"); 00139 00140 // restaure default formats 00141 G4cout.setf(mode,std::ios::floatfield); 00142 G4cout.precision(prec); 00143 }
void RunAction::SumEvents | ( | G4double | e | ) | [inline] |
Definition at line 29 of file RunAction.hh.
Referenced by EventAction::EndOfEventAction().
00029 { m_sumEdep += e; m_sumEdep2 += e*e; m_nbEntry++; };
void RunAction::SumDepthDose | ( | G4double | zLocal, | |
G4double | edep | |||
) |
Definition at line 49 of file RunAction.cc.
Referenced by SteppingAction::UserSteppingAction().
00050 { 00051 // check coherence 00052 if (zLocal > m_astronautHeight) { 00053 G4cout << "\n --> warning from RunAction::SumDepthDose() : " 00054 << " zLocal beyond astronaut height : " << zLocal/mm << G4endl; 00055 return; 00056 } 00057 00058 // compute slice number 00059 G4int k = int(zLocal/m_sliceWidth); 00060 00061 // sum edep 00062 m_depthDose[k] += edep; 00063 }
void RunAction::SumDepthDoseSD | ( | G4double | zLocal, | |
G4double | edep | |||
) |
Definition at line 67 of file RunAction.cc.
00068 { 00069 // check coherence 00070 if (zLocal > m_astronautHeight) { 00071 G4cout << "\n --> warning from RunAction::SumDepthDose() : " 00072 << " zLocal beyond astronaut height : " << zLocal/mm << G4endl; 00073 return; 00074 } 00075 00076 // compute slice number 00077 G4int k = int(zLocal/m_sliceWidth); 00078 00079 // sum edep 00080 m_depthDoseSD[k] += edep; 00081 }
void RunAction::WriteDepthDose | ( | G4String | name | ) |
Definition at line 149 of file RunAction.cc.
Referenced by EndOfRunAction().
00150 { 00151 G4String fileName = name + ".ascii"; 00152 std::ofstream File(fileName, std::ios::out); 00153 00154 // -- jour3a: 00155 G4String fileNameSD = name + "SD"+ ".ascii"; 00156 std::ofstream FileSD(fileNameSD, std::ios::out); 00157 00158 std::ios::fmtflags mode = File.flags(); 00159 File.setf( std::ios::scientific, std::ios::floatfield ); 00160 G4int prec = File.precision(4); 00161 00162 // -- jour3a: 00163 std::ios::fmtflags modeSD = FileSD.flags(); 00164 FileSD.setf( std::ios::scientific, std::ios::floatfield ); 00165 G4int precSD = FileSD.precision(4); 00166 00167 File << " Longitudinal depth dose distribution \n " 00168 << "\n zLocal (mm)\t m_depthDose(gray) \n" << G4endl; 00169 00170 // -- jour3a: 00171 FileSD << " Longitudinal depth dose distribution \n " 00172 << "\n zLocal (mm)\t m_depthDose(gray) \n" << G4endl; 00173 00174 G4double zLocal; 00175 for (G4int k=0; k<m_nbSlices; k++) { 00176 zLocal = (k+0.5)*m_sliceWidth; 00177 File << " " << zLocal/mm 00178 << "\t " << m_depthDose[k]/gray << G4endl; 00179 } 00180 00181 // -- jour3a: 00182 // -- write date from SD : 00183 for (G4int k=0; k<m_nbSlices; k++) { 00184 zLocal = (k+0.5)*m_sliceWidth; 00185 FileSD << " " << zLocal/mm 00186 << "\t " << m_depthDoseSD[k]/gray << G4endl; 00187 } 00188 00189 // restaure default formats 00190 File.setf(mode,std::ios::floatfield); 00191 File.precision(prec); 00192 00193 // -- jour3a: 00194 FileSD.setf(modeSD,std::ios::floatfield); 00195 FileSD.precision(precSD); 00196 00197 }
DetectorConstruction* RunAction::m_detector [private] |
G4double RunAction::m_sumEdep [private] |
Definition at line 40 of file RunAction.hh.
Referenced by BeginOfRunAction(), EndOfRunAction(), and SumEvents().
G4double RunAction::m_sumEdep2 [private] |
Definition at line 40 of file RunAction.hh.
Referenced by BeginOfRunAction(), EndOfRunAction(), and SumEvents().
G4int RunAction::m_nbEntry [private] |
Definition at line 41 of file RunAction.hh.
Referenced by BeginOfRunAction(), EndOfRunAction(), and SumEvents().
std::vector<G4double> RunAction::m_depthDose [private] |
Definition at line 43 of file RunAction.hh.
Referenced by BeginOfRunAction(), EndOfRunAction(), SumDepthDose(), and WriteDepthDose().
std::vector<G4double> RunAction::m_depthDoseSD [private] |
Definition at line 44 of file RunAction.hh.
Referenced by BeginOfRunAction(), EndOfRunAction(), SumDepthDoseSD(), and WriteDepthDose().
G4double RunAction::m_astronautHeight [private] |
Definition at line 45 of file RunAction.hh.
Referenced by BeginOfRunAction(), SumDepthDose(), and SumDepthDoseSD().
G4double RunAction::m_sliceWidth [private] |
Definition at line 46 of file RunAction.hh.
Referenced by BeginOfRunAction(), SumDepthDose(), SumDepthDoseSD(), and WriteDepthDose().
G4int RunAction::m_nbSlices [private] |
Definition at line 47 of file RunAction.hh.
Referenced by BeginOfRunAction(), EndOfRunAction(), and WriteDepthDose().