Problem 1621

Summary: Several files created when running "/score/dumpQuantityToFile"
Product: Geant4 Reporter: Jonas Nilsson <jonas.nilsson>
Component: processes/scoringAssignee: asai
Status: RESOLVED FIXED    
Severity: normal CC: asai, jonas.nilsson
Priority: P5    
Version: 10.0   
Hardware: Apple   
OS: Mac OS X   

Description Jonas Nilsson 2014-04-24 12:10:11 CEST
This problem is possibly (probably) related to bug 1554. As an attempt to solve that problem, I used a custom scoring writer. I found that running "dumpQuantityToFile" will still yield a file created with the built in scoring writer when using a loop to create the file. When using the code and macro files at the end of this post, both corrupt "neutron_{pos}.txt"-files as well as "test.txt" from my custom scorer should be written to disk.

My computer is running MacOSX 10.9.2 and the output of "clang -v" is:
Apple LLVM version 5.1 (clang-503.0.40) (based on LLVM 3.4svn)
Target: x86_64-apple-darwin13.1.0
Thread model: posix

//=============== in int main() ==================
G4ScoringManager* scoringManager = G4ScoringManager::GetScoringManager();
scoringManager->SetScoreWriter(new CustomScoreWriter());


//=============== CustomScoreWriter.h ==================
#include "globals.hh"
#include "G4VScoreWriter.hh"
#include <fstream>

class CustomScoreWriter : public G4VScoreWriter {	
public:
	CustomScoreWriter();
	virtual ~CustomScoreWriter();
public:
	virtual void DumpQuantityToFile(const G4String & psName, const G4String & fileName, const G4String & option) {std::ofstream ofile("test.txt", std::ios::binary); ofile << "Test\n"; ofile.close();};
};

#============== run1.mac================
/score/create/boxMesh detMesh
/score/mesh/boxSize 25. 1500. 50. mm
/score/mesh/nBin 1 60 1
/score/mesh/translate/xyz 0.0 -1.0 -1.37 m
/score/quantity/energyDeposit eDep MeV
/score/close

/control/loop loop_neutron.mac pos -305 305 5

#============== loop_neutron.mac================
/scanner/container/containerPosition {pos} cm
/run/beamOn 100
/score/dumpQuantityToFile detMesh eDep neutron_{pos}.txt
Comment 1 asai 2014-04-27 03:19:04 CEST
Thanks Jonas for reporting this.
We will look into this problem and will keep you updated.
Makoto
Comment 2 asai 2014-05-27 14:11:21 CEST
Thanks again for reporting this.
We identified the problem. The fix is now under our test and will be included in the patch-02 release that should come out very soon.
Makoto