41 : fScoringMesh(nullptr), verboseLevel(0) {
59 std::transform(opt.begin(), opt.end(), opt.begin(), (
int (*)(
int))(tolower));
62 if(opt.size() == 0) opt =
"csv";
63 if(opt.find(
"csv") == std::string::npos &&
64 opt.find(
"sequence") == std::string::npos) {
65 G4cerr <<
"ERROR : DumpToFile : Unknown option -> "
71 std::ofstream
ofile(fileName);
73 G4cerr <<
"ERROR : DumpToFile : File open error -> "
84 MeshScoreMap::const_iterator msMapItr = fSMap.find(psName);
85 if(msMapItr == fSMap.end()) {
86 G4cerr <<
"ERROR : DumpToFile : Unknown quantity, \""
87 << psName <<
"\"." <<
G4endl;
92 std::map<G4int, G4StatDouble*> * score = msMapItr->second->GetMap();
93 ofile <<
"# primitive scorer name: " << msMapItr->first << std::endl;
101 ofile <<
"# i" << divisionAxisNames[0]
102 <<
", i" << divisionAxisNames[1]
103 <<
", i" << divisionAxisNames[2];
105 ofile <<
", total(value) ";
106 if(unit.size() > 0) ofile <<
"[" << unit <<
"]";
107 ofile <<
", total(val^2), entry" <<
G4endl;
110 if(opt.find(
"sequence") != std::string::npos) {
117 ofile << std::setprecision(16);
119 for(
int y = 0;
y < fNMeshSegments[1];
y++) {
120 for(
int z = 0;
z < fNMeshSegments[2];
z++) {
123 if(opt.find(
"csv") != std::string::npos)
124 ofile <<
x <<
"," <<
y <<
"," <<
z <<
",";
126 std::map<G4int, G4StatDouble*>::iterator
value = score->find(idx);
127 if(value == score->end()) {
128 ofile << 0. <<
"," << 0. <<
"," << 0;
130 ofile << (value->second->sum_wx())/unitValue <<
","
131 << (value->second->sum_wx2())/unitValue/unitValue <<
","
132 << value->second->n();
135 if(opt.find(
"csv") != std::string::npos) {
137 }
else if(opt.find(
"sequence") != std::string::npos) {
139 if(count++%5 == 4) ofile <<
G4endl;
145 ofile << std::setprecision(6);
157 std::transform(opt.begin(), opt.end(), opt.begin(), (
int (*)(
int))(tolower));
160 if(opt.size() == 0) opt =
"csv";
161 if(opt.find(
"csv") == std::string::npos &&
162 opt.find(
"sequence") == std::string::npos) {
163 G4cerr <<
"ERROR : DumpToFile : Unknown option -> "
169 std::ofstream
ofile(fileName);
171 G4cerr <<
"ERROR : DumpToFile : File open error -> "
179 MeshScoreMap::const_iterator msMapItr = fSMap.begin();
180 std::map<G4int, G4StatDouble*> * score;
181 for(; msMapItr != fSMap.end(); msMapItr++) {
185 score = msMapItr->second->GetMap();
186 ofile <<
"# primitive scorer name: " << msMapItr->first << std::endl;
193 ofile <<
"# i" << divisionAxisNames[0]
194 <<
", i" << divisionAxisNames[1]
195 <<
", i" << divisionAxisNames[2];
197 ofile <<
", total(value) ";
198 if(unit.size() > 0) ofile <<
"[" << unit <<
"]";
199 ofile <<
", total(val^2), entry" <<
G4endl;
203 if(opt.find(
"sequence") != std::string::npos) {
210 ofile << std::setprecision(16);
212 for(
int y = 0;
y < fNMeshSegments[1];
y++) {
213 for(
int z = 0;
z < fNMeshSegments[2];
z++) {
216 if(opt.find(
"csv") != std::string::npos)
217 ofile <<
x <<
"," <<
y <<
"," <<
z <<
",";
219 std::map<G4int, G4StatDouble*>::iterator
value = score->find(idx);
220 if(value == score->end()) {
221 ofile << 0. <<
"," << 0. <<
"," << 0;
223 ofile << (value->second->sum_wx())/unitValue <<
","
224 << (value->second->sum_wx2())/unitValue/unitValue <<
","
225 << value->second->n();
228 if(opt.find(
"csv") != std::string::npos) {
230 }
else if(opt.find(
"sequence") != std::string::npos) {
232 if(count++%5 == 4) ofile <<
G4endl;
238 ofile << std::setprecision(6);
MeshScoreMap GetScoreMap() const
G4int GetIndex(G4int x, G4int y, G4int z) const
G4VScoringMesh * fScoringMesh
const G4String & GetWorldName() const
G4String GetPSUnit(const G4String &psname)
void GetDivisionAxisNames(G4String divisionAxisNames[3])
virtual ~G4VScoreWriter()
virtual void DumpAllQuantitiesToFile(const G4String &fileName, const G4String &option)
const XML_Char int const XML_Char * value
void GetNumberOfSegments(G4int nSegment[3])
virtual void DumpQuantityToFile(const G4String &psName, const G4String &fileName, const G4String &option)
typedef int(XMLCALL *XML_NotStandaloneHandler)(void *userData)
G4double GetPSUnitValue(const G4String &psname)
G4GLOB_DLL std::ostream G4cerr
void SetScoringMesh(G4VScoringMesh *sm)
std::map< G4String, RunScore * > MeshScoreMap