Loading...
Searching...
No Matches
Public Member Functions | Protected Attributes | Private Attributes | List of all members
DicomRunAction Class Reference

#include <Doxymodules_medical.h>

Inheritance diagram for DicomRunAction:
G4UserRunAction Dicom2RunAction

Public Member Functions

 DicomRunAction ()
 Constructor.
 
 ~DicomRunAction ()
 Destructor.
 
G4RunGenerateRun ()
 
void BeginOfRunAction (const G4Run *)
 
void EndOfRunAction (const G4Run *)
 
DicomRunGetDicomRun () const
 
void PrintHeader (std::ostream *out)
 
std::string FillString (const std::string &name, char c, G4int n, G4bool back=true)
 

Protected Attributes

DicomRunfDcmrun
 
std::vector< G4StringfSDName
 

Private Attributes

G4int fFieldValue
 

Detailed Description

Definition at line 31 of file Doxymodules_medical.h.

Constructor & Destructor Documentation

◆ DicomRunAction()

DicomRunAction::DicomRunAction ( )

Constructor.

Definition at line 46 of file DicomRunAction.cc.

48{
49 // - Prepare data member for DicomRun.
50 // vector represents a list of MultiFunctionalDetector names.
51 fSDName.push_back(G4String("phantomSD"));
52}
DicomRun * fDcmrun
std::vector< G4String > fSDName

◆ ~DicomRunAction()

DicomRunAction::~DicomRunAction ( )

Destructor.

Definition at line 56 of file DicomRunAction.cc.

57{
58 fSDName.clear();
59}

Member Function Documentation

◆ GenerateRun()

G4Run * DicomRunAction::GenerateRun ( )

Definition at line 62 of file DicomRunAction.cc.

63{
64 // Generate new RUN object, which is specially
65 // dedicated for MultiFunctionalDetector scheme.
66 // Detail description can be found in DicomRun.hh/cc.
67 //return new DicomRun(fSDName);
68 return fDcmrun = new DicomRun(fSDName);
69}
DicomRun class.

◆ BeginOfRunAction()

void DicomRunAction::BeginOfRunAction ( const G4Run aRun)

Definition at line 72 of file DicomRunAction.cc.

73{
74 G4cout << "### Run " << aRun->GetRunID() << " start." << G4endl;
75 //inform the runManager to save random number seed
76 G4RunManager::GetRunManager()->SetRandomNumberStore(true);
77 G4RunManager::GetRunManager()->SetRandomNumberStorePerEvent(false);
78 G4RunManager::GetRunManager()->SetRandomNumberStoreDir(
79 G4String("dicom-run-") + std::to_string(aRun->GetRunID()));
80
81 G4int progress = aRun->GetNumberOfEventToBeProcessed() / 100;
82 progress = (progress < 1) ? 1 : progress;
83 G4RunManager::GetRunManager()->SetPrintProgress(progress);
84}

◆ EndOfRunAction()

void DicomRunAction::EndOfRunAction ( const G4Run aRun)

Definition at line 87 of file DicomRunAction.cc.

88{
89 G4int nofEvents = aRun->GetNumberOfEvent();
90
91 static G4double local_total_dose = 0;
92 G4double total_dose = 0;
93
94 const DicomRun* reRun = static_cast<const DicomRun*>(aRun);
95 //--- Dump all scored quantities involved in DicomRun.
96 for ( G4int i = 0; i < (G4int)fSDName.size(); i++ ){
97 //
98 //---------------------------------------------
99 // Dump accumulated quantities for this RUN.
100 // (Display only central region of x-y plane)
101 // 0 ConcreteSD/DoseDeposit
102 //---------------------------------------------
103 G4THitsMap<G4double>* DoseDeposit =
104 reRun->GetHitsMap(fSDName[i]+"/DoseDeposit");
105
106 if( DoseDeposit && DoseDeposit->GetMap()->size() != 0 ) {
107 std::map<G4int,G4double*>::iterator itr =
108 DoseDeposit->GetMap()->begin();
109 for(; itr != DoseDeposit->GetMap()->end(); itr++) {
110 if(!IsMaster()) { local_total_dose += *(itr->second); }
111 total_dose += *(itr->second);
112 }
113 }
114
115 }
116
117 if (IsMaster())
118 {
119 G4cout << "--------------------End of Global Run-----------------------"
120 << G4endl;
121 G4cout << " The run was " << nofEvents << " events " << G4endl;
122 G4cout << "LOCAL TOTAL DOSE : \t" << local_total_dose/gray
123 << " Gy" << G4endl;
124 G4cout << " TOTAL DOSE : \t" << total_dose/gray
125 << " Gy" << G4endl;
126
127 }
128 else
129 {
130 G4cout << "--------------------End of Local Run------------------------"
131 << G4endl;
132 G4cout << " The run was " << nofEvents << G4endl;
133 G4cout << "LOCAL TOTAL DOSE : \t" << local_total_dose/gray
134 << " Gy" << G4endl;
135 G4cout << " TOTAL DOSE : \t" << total_dose/gray
136 << " Gy" << G4endl;
137
138 }
139
140 if(IsMaster()) {
141 G4cout << " ###### EndOfRunAction ###### " << G4endl;
142 //- DicomRun object.
143 const DicomRun* re02Run = static_cast<const DicomRun*>(aRun);
144 //--- Dump all scored quantities involved in DicomRun.
145
146 for ( G4int i = 0; i < (G4int)fSDName.size(); i++ ){
147 //
148 //---------------------------------------------
149 // Dump accumulated quantities for this RUN.
150 // (Display only central region of x-y plane)
151 // 0 ConcreteSD/DoseDeposit
152 //---------------------------------------------
153 G4THitsMap<G4double>* DoseDeposit =
154 re02Run->GetHitsMap(fSDName[i]+"/DoseDeposit");
155
156 G4cout << "============================================================="
157 <<G4endl;
158 G4cout << " Number of event processed : "
159 << aRun->GetNumberOfEvent() << G4endl;
160 G4cout << "============================================================="
161 <<G4endl;
162
163 std::ofstream fileout;
164 G4String fname = "dicom.out";
165 fileout.open(fname);
166 G4cout << " opened file " << fname << " for dose output" << G4endl;
167
168 if( DoseDeposit && DoseDeposit->GetMap()->size() != 0 ) {
169 std::ostream *myout = &G4cout;
170 PrintHeader(myout);
171 std::map<G4int,G4double*>::iterator itr =DoseDeposit->GetMap()->begin();
172 for(; itr != DoseDeposit->GetMap()->end(); itr++) {
173 fileout << itr->first
174 << " " << *(itr->second)/CLHEP::gray
175 << G4endl;
176 //G4cout << " " << itr->first
177 // << " " << std::setprecision(6)
178 // << *(itr->second)/CLHEP::gray << " Gy"
179 // << G4endl;
180 }
181 G4cout << "============================================="<<G4endl;
182 } else {
183 G4Exception("DicomRunAction", "000", JustWarning,
184 "DoseDeposit HitsMap is either a null pointer of the HitsMap was empty");
185 }
186 fileout.close();
187 G4cout << " closed file " << fname << " for dose output" << G4endl;
188
189 }
190 }
191
192 G4cout << "Finished : End of Run Action " << aRun->GetRunID() << G4endl;
193
194}
void PrintHeader(std::ostream *out)
G4THitsMap< G4double > * GetHitsMap(G4int i) const
Definition DicomRun.hh:71

◆ GetDicomRun()

DicomRun * DicomRunAction::GetDicomRun ( ) const
inline

Definition at line 55 of file DicomRunAction.hh.

55{ return fDcmrun; }

◆ PrintHeader()

void DicomRunAction::PrintHeader ( std::ostream *  out)

Definition at line 197 of file DicomRunAction.cc.

198{
199 std::vector<G4String> vecScoreName;
200 vecScoreName.push_back("DoseDeposit");
201
202 // head line
203 //
204 std::string vname;
205 *out << std::setw(10) << "Voxel" << " |";
206 for (std::vector<G4String>::iterator it = vecScoreName.begin();
207 it != vecScoreName.end(); it++) {
208 //vname = FillString((*it),
209 // ' ',
210 // FieldValue+1,
211 // false);
212 // *out << vname << '|';
213 *out << std::setw(fFieldValue) << (*it) << " |";
214 }
215 *out << G4endl;
216}

◆ FillString()

std::string DicomRunAction::FillString ( const std::string &  name,
char  c,
G4int  n,
G4bool  back = true 
)

Definition at line 219 of file DicomRunAction.cc.

221{
222 std::string fname("");
223 G4int k = G4int(n - name.size());
224 if (k > 0) {
225 if (back) {
226 fname = name;
227 fname += std::string(k,c);
228 }
229 else {
230 fname = std::string(k,c);
231 fname += name;
232 }
233 }
234 else {
235 fname = name;
236 }
237 return fname;
238}

Member Data Documentation

◆ fDcmrun

DicomRun* DicomRunAction::fDcmrun
protected

Definition at line 62 of file DicomRunAction.hh.

◆ fSDName

std::vector<G4String> DicomRunAction::fSDName
protected

Definition at line 64 of file DicomRunAction.hh.

◆ fFieldValue

G4int DicomRunAction::fFieldValue
private

Definition at line 68 of file DicomRunAction.hh.


The documentation for this class was generated from the following files:

Applications | User Support | Publications | Collaboration