Loading...
Searching...
No Matches
Public Member Functions | List of all members
RE03UserScoreWriter Class Reference

#include <Doxymodules_runAndEvent.h>

Inheritance diagram for RE03UserScoreWriter:
G4VScoreWriter

Public Member Functions

 RE03UserScoreWriter ()
 
virtual ~RE03UserScoreWriter ()
 
virtual void DumpQuantityToFile (const G4String &psName, const G4String &fileName, const G4String &option)
 

Detailed Description

Definition at line 73 of file Doxymodules_runAndEvent.h.

Constructor & Destructor Documentation

◆ RE03UserScoreWriter()

RE03UserScoreWriter::RE03UserScoreWriter ( )

Definition at line 42 of file RE03UserScoreWriter.cc.

◆ ~RE03UserScoreWriter()

RE03UserScoreWriter::~RE03UserScoreWriter ( )
virtual

Definition at line 47 of file RE03UserScoreWriter.cc.

48{;}

Member Function Documentation

◆ DumpQuantityToFile()

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

Definition at line 51 of file RE03UserScoreWriter.cc.

53 {
54 using MeshScoreMap = G4VScoringMesh::MeshScoreMap;
55 //
56 if(verboseLevel > 0) {
57 G4cout << "User-defined DumpQuantityToFile() method is invoked."
58 << G4endl;
59 G4cout << " -- to obtain a projection of the quantity <"
60 << psName
61 << "> onto the x-y plane --" << G4endl;
62 }
63
64 // change the option string into lowercase to the case-insensitive.
65 G4String opt = option;
66 std::transform(opt.begin(), opt.end(), opt.begin(), (int (*)(int))(tolower));
67
68 // confirm the option
69 if(opt.size() == 0) opt = "csv";
70
71 // open the file
72 std::ofstream ofile(fileName);
73 if(!ofile) {
74 G4cerr << "ERROR : DumpToFile : File open error -> "
75 << fileName << G4endl;
76 return;
77 }
78 ofile << "# mesh name: " << fScoringMesh->GetWorldName() << G4endl;
79
80
81 // retrieve the map
82 MeshScoreMap scMap = fScoringMesh->GetScoreMap();
83
84 MeshScoreMap::const_iterator msMapItr = scMap.find(psName);
85 if(msMapItr == scMap.end()) {
86 G4cerr << "ERROR : DumpToFile : Unknown quantity, \""
87 << psName << "\"." << G4endl;
88 return;
89 }
90 std::map<G4int, G4StatDouble*> * score = msMapItr->second->GetMap();
91 ofile << "# primitive scorer name: " << msMapItr->first << G4endl;
92
93 // write header info
94 ofile << "# xy projection" << G4endl;
95 ofile << fNMeshSegments[0] << " " << fNMeshSegments[1] << " " << G4endl;
96
97 // declare xy array
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);
102 // accumulate
103 ofile << std::setprecision(16); // for double value with 8 bytes
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++) {
107
108 G4int idx = GetIndex(x, y, z);
109
110 std::map<G4int, G4StatDouble*>::iterator value = score->find(idx);
111 if(value != score->end()) projxy[x][y] += value->second->sum_wx();
112
113 } // z
114 } // y
115 } // x
116
117 // write quantity
118 ofile << std::setprecision(16); // for double value with 8 bytes
119 for(int x = 0; x < fNMeshSegments[0]; x++) {
120 for(int y = 0; y < fNMeshSegments[1]; y++) {
121
122 ofile << x << "," << y << ",";
123 ofile << projxy[x][y] << G4endl;
124
125 } // y
126 } // x
127 ofile << std::setprecision(6);
128
129 // close the file
130 ofile.close();
131
132}

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

Applications | User Support | Publications | Collaboration