Geant4  10.03.p03
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
DicomRunAction Class Reference

#include <DicomRunAction.hh>

Inheritance diagram for DicomRunAction:
Collaboration diagram for DicomRunAction:

Public Member Functions

 DicomRunAction ()
 Constructor. More...
 
virtual ~DicomRunAction ()
 Destructor. More...
 
virtual G4RunGenerateRun ()
 
virtual void BeginOfRunAction (const G4Run *)
 
virtual 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)
 
- Public Member Functions inherited from G4UserRunAction
 G4UserRunAction ()
 
virtual ~G4UserRunAction ()
 
virtual void SetMaster (G4bool val=true)
 
G4bool IsMaster () const
 

Static Public Member Functions

static DicomRunActionInstance ()
 

Additional Inherited Members

- Protected Attributes inherited from G4UserRunAction
G4bool isMaster
 

Detailed Description

Definition at line 42 of file DicomRunAction.hh.

Constructor & Destructor Documentation

DicomRunAction::DicomRunAction ( )

Constructor.

Definition at line 55 of file DicomRunAction.cc.

56 : G4UserRunAction(), fDcmrun(0), fFieldValue(14)
57 {
58  // - Prepare data member for DicomRun.
59  // vector represents a list of MultiFunctionalDetector names.
60  fSDName.push_back(G4String("phantomSD"));
61  fInstance = this;
62 }
DicomRunAction::~DicomRunAction ( )
virtual

Destructor.

Definition at line 66 of file DicomRunAction.cc.

67 {
68  fSDName.clear();
69  fInstance = 0;
70 }

Member Function Documentation

void DicomRunAction::BeginOfRunAction ( const G4Run aRun)
virtual

Reimplemented from G4UserRunAction.

Definition at line 83 of file DicomRunAction.cc.

84 {
85  G4cout << "### Run " << aRun->GetRunID() << " start." << G4endl;
86  //inform the runManager to save random number seed
88 }
void SetRandomNumberStore(G4bool flag)
G4GLOB_DLL std::ostream G4cout
G4int GetRunID() const
Definition: G4Run.hh:76
static G4RunManager * GetRunManager()
Definition: G4RunManager.cc:79
#define G4endl
Definition: G4ios.hh:61

Here is the call graph for this function:

void DicomRunAction::EndOfRunAction ( const G4Run aRun)
virtual

Reimplemented from G4UserRunAction.

Definition at line 91 of file DicomRunAction.cc.

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

Here is the call graph for this function:

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

Definition at line 226 of file DicomRunAction.cc.

228 {
229  std::string fname("");
230  G4int k = n - name.size();
231  if (k > 0) {
232  if (back) {
233  fname = name;
234  fname += std::string(k,c);
235  }
236  else {
237  fname = std::string(k,c);
238  fname += name;
239  }
240  }
241  else {
242  fname = name;
243  }
244  return fname;
245 }
const XML_Char * name
Definition: expat.h:151
int G4int
Definition: G4Types.hh:78
const G4int n
string fname
Definition: test.py:308
tuple c
Definition: test.py:13
G4Run * DicomRunAction::GenerateRun ( void  )
virtual

Reimplemented from G4UserRunAction.

Definition at line 73 of file DicomRunAction.cc.

74 {
75  // Generate new RUN object, which is specially
76  // dedicated for MultiFunctionalDetector scheme.
77  // Detail description can be found in DicomRun.hh/cc.
78  //return new DicomRun(fSDName);
79  return fDcmrun = new DicomRun(fSDName);
80 }
DicomRun* DicomRunAction::GetDicomRun ( ) const
inline

Definition at line 57 of file DicomRunAction.hh.

57 { return fDcmrun; }
DicomRunAction * DicomRunAction::Instance ( void  )
static

Definition at line 51 of file DicomRunAction.cc.

51 { return fInstance; }
void DicomRunAction::PrintHeader ( std::ostream *  out)

Definition at line 204 of file DicomRunAction.cc.

205 {
206  std::vector<G4String> vecScoreName;
207  vecScoreName.push_back("DoseDeposit");
208 
209  // head line
210  //
211  std::string vname;
212  *out << std::setw(10) << "Voxel" << " |";
213  for (std::vector<G4String>::iterator it = vecScoreName.begin();
214  it != vecScoreName.end(); it++) {
215  //vname = FillString((*it),
216  // ' ',
217  // FieldValue+1,
218  // false);
219  // *out << vname << '|';
220  *out << std::setw(fFieldValue) << (*it) << " |";
221  }
222  *out << G4endl;
223 }
#define G4endl
Definition: G4ios.hh:61

Here is the caller graph for this function:


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