54 using MeshScoreMap = G4VScoringMesh::MeshScoreMap;
56 if(verboseLevel > 0) {
57 G4cout <<
"User-defined DumpQuantityToFile() method is invoked."
59 G4cout <<
" -- to obtain a projection of the quantity <"
61 <<
"> onto the x-y plane --" << G4endl;
66 std::transform(opt.begin(), opt.end(), opt.begin(), (int (*)(
int))(tolower));
69 if(opt.size() == 0) opt =
"csv";
72 std::ofstream ofile(fileName);
74 G4cerr <<
"ERROR : DumpToFile : File open error -> "
75 << fileName << G4endl;
78 ofile <<
"# mesh name: " << fScoringMesh->GetWorldName() << G4endl;
82 MeshScoreMap scMap = fScoringMesh->GetScoreMap();
84 MeshScoreMap::const_iterator msMapItr = scMap.find(psName);
85 if(msMapItr == scMap.end()) {
86 G4cerr <<
"ERROR : DumpToFile : Unknown quantity, \""
87 << psName <<
"\"." << G4endl;
90 std::map<G4int, G4StatDouble*> * score = msMapItr->second->GetMap();
91 ofile <<
"# primitive scorer name: " << msMapItr->first << G4endl;
94 ofile <<
"# xy projection" << G4endl;
95 ofile << fNMeshSegments[0] <<
" " << fNMeshSegments[1] <<
" " << G4endl;
98 std::vector<double> projy;
99 for(
int y = 0; y < fNMeshSegments[1]; y++) projy.push_back(0.);
100 std::vector<std::vector<double> > projxy;
101 for(
int x = 0; x < fNMeshSegments[0]; x++) projxy.push_back(projy);
103 ofile << std::setprecision(16);
104 for(
int x = 0; x < fNMeshSegments[0]; x++) {
105 for(
int y = 0; y < fNMeshSegments[1]; y++) {
106 for(
int z = 0; z < fNMeshSegments[2]; z++) {
108 G4int idx = GetIndex(x, y, z);
110 std::map<G4int, G4StatDouble*>::iterator value = score->find(idx);
111 if(value != score->end()) projxy[x][y] += value->second->sum_wx();
118 ofile << std::setprecision(16);
119 for(
int x = 0; x < fNMeshSegments[0]; x++) {
120 for(
int y = 0; y < fNMeshSegments[1]; y++) {
122 ofile << x <<
"," << y <<
",";
123 ofile << projxy[x][y] << G4endl;
127 ofile << std::setprecision(6);