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

#include <BrachyUserScoreWriter.hh>

Inheritance diagram for BrachyUserScoreWriter:
Collaboration diagram for BrachyUserScoreWriter:

Public Member Functions

 BrachyUserScoreWriter ()
 
virtual ~BrachyUserScoreWriter ()
 
void DumpQuantityToFile (const G4String &psName, const G4String &fileName, const G4String &option)
 
- Public Member Functions inherited from G4VScoreWriter
 G4VScoreWriter ()
 
virtual ~G4VScoreWriter ()
 
virtual void DumpAllQuantitiesToFile (const G4String &fileName, const G4String &option)
 
void SetScoringMesh (G4VScoringMesh *sm)
 
void SetVerboseLevel (G4int vl)
 

Additional Inherited Members

- Protected Member Functions inherited from G4VScoreWriter
G4int GetIndex (G4int x, G4int y, G4int z) const
 
- Protected Attributes inherited from G4VScoreWriter
G4int fNMeshSegments [3]
 
G4VScoringMeshfScoringMesh
 
G4int verboseLevel
 

Detailed Description

Definition at line 44 of file BrachyUserScoreWriter.hh.

Constructor & Destructor Documentation

BrachyUserScoreWriter::BrachyUserScoreWriter ( )

Definition at line 54 of file BrachyUserScoreWriter.cc.

54  :
56 {
57 }
BrachyUserScoreWriter::~BrachyUserScoreWriter ( )
virtual

Definition at line 59 of file BrachyUserScoreWriter.cc.

60 {;}

Member Function Documentation

void BrachyUserScoreWriter::DumpQuantityToFile ( const G4String psName,
const G4String fileName,
const G4String option 
)
virtual

Reimplemented from G4VScoreWriter.

Definition at line 62 of file BrachyUserScoreWriter.cc.

65 {
66 if(verboseLevel > 0)
67  {G4cout << "BrachyUserScorer-defined DumpQuantityToFile() method is invoked."
68  << G4endl;
69  }
70 
71 // change the option string into lowercase to the case-insensitive.
72 G4String opt = option;
73 std::transform(opt.begin(), opt.end(), opt.begin(), (int (*)(int))(tolower));
74 
75 // confirm the option
76 if(opt.size() == 0) opt = "csv";
77 
78 // open the file
79 std::ofstream ofile(fileName);
80 
81 if(!ofile)
82 {
83  G4cerr << "ERROR : DumpToFile : File open error -> " << fileName << G4endl;
84  return;
85 }
86  ofile << "# mesh name: " << fScoringMesh->GetWorldName() << G4endl;
87 
88 // retrieve the map
89 MeshScoreMap fSMap = fScoringMesh -> GetScoreMap();
90 
91 MeshScoreMap::const_iterator msMapItr = fSMap.find(psName);
92 
93 if(msMapItr == fSMap.end())
94  {
95  G4cerr << "ERROR : DumpToFile : Unknown quantity, \""<< psName
96  << "\"." << G4endl;
97  return;
98  }
99 
100 std::map<G4int, G4StatDouble*> * score = msMapItr -> second-> GetMap();
101 
102 ofile << "# primitive scorer name: " << msMapItr -> first << G4endl;
103 //
104 // Write quantity in the ASCII output file and in brachytherapy.root
105 //
106 ofile << std::setprecision(16); // for double value with 8 bytes
107 
108 for(int x = 0; x < fNMeshSegments[0]; x++) {
109  for(int y = 0; y < fNMeshSegments[1]; y++) {
110  for(int z = 0; z < fNMeshSegments[2]; z++){
111  G4int numberOfVoxel_x = fNMeshSegments[0];
112  G4int numberOfVoxel_y = fNMeshSegments[1];
113  G4int numberOfVoxel_z =fNMeshSegments[2];
114  // If the voxel width is changed in the macro file,
115  // the voxel width variable must be updated
116  G4double voxelWidth = 0.25 *mm;
117  //
118  G4double xx = ( - numberOfVoxel_x + 1+ 2*x )* voxelWidth/2;
119  G4double yy = ( - numberOfVoxel_y + 1+ 2*y )* voxelWidth/2;
120  G4double zz = ( - numberOfVoxel_z + 1+ 2*z )* voxelWidth/2;
121  G4int idx = GetIndex(x, y, z);
122  std::map<G4int, G4StatDouble*>::iterator value = score -> find(idx);
123 
124  if (value != score -> end())
125  {
126  // Print in the ASCII output file the information
127 
128  ofile << xx << " " << yy << " " << zz <<" "
129  <<(value->second->sum_wx())/keV << G4endl;
130 
131 #ifdef ANALYSIS_USE
132  // Save the same information in the output analysis file
134 
135  if(zz> -0.125 *mm && zz < 0.125*mm) analysis -> FillH2WithEnergyDeposition(xx,yy, (value->second->sum_wx())/keV);
136 #endif
137 }}}}
138 
139 ofile << std::setprecision(6);
140 
141 // Close the output ASCII file
142 ofile.close();
143 }
const G4String & GetWorldName() const
static constexpr double mm
Definition: G4SIunits.hh:115
static BrachyAnalysisManager * GetInstance()
tuple x
Definition: test.py:50
static constexpr double second
Definition: G4SIunits.hh:157
int G4int
Definition: G4Types.hh:78
G4VScoringMesh * fScoringMesh
G4int fNMeshSegments[3]
G4GLOB_DLL std::ostream G4cout
const XML_Char int const XML_Char * value
Definition: expat.h:331
typedef int(XMLCALL *XML_NotStandaloneHandler)(void *userData)
G4int GetIndex(G4int x, G4int y, G4int z) const
std::ofstream ofile
Definition: clparse.cc:45
tuple z
Definition: test.py:28
#define G4endl
Definition: G4ios.hh:61
double G4double
Definition: G4Types.hh:76
static constexpr double keV
Definition: G4SIunits.hh:216
std::map< G4String, RunScore * > MeshScoreMap
G4GLOB_DLL std::ostream G4cerr

Here is the call graph for this function:


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