38 #include "tools/waxml/histos"
55 if ( fgInstance == 0 ) {
71 if ( ( isMaster && fgMasterInstance ) || ( fgInstance ) ) {
75 <<
"G4XmlAnalysisManager already exists."
76 <<
"Cannot create another instance.";
77 G4Exception(
"G4XmlAnalysisManager::G4XmlAnalysisManager",
80 if ( isMaster ) fgMasterInstance =
this;
110 G4bool G4XmlAnalysisManager::WriteH1()
112 const std::vector<tools::histo::h1d*>& h1Vector
114 const std::vector<G4HnInformation*>& hnVector
117 if ( ! h1Vector.size() )
return true;
121 for (
G4int i=0; i<
G4int(h1Vector.size()); ++i ) {
127 tools::histo::h1d* h1 = h1Vector[i];
134 std::ofstream* hnFile = fFileManager->
GetHnFile();
136 = tools::waxml::write(*hnFile, *h1, path, name);
139 description <<
" " <<
"saving histogram " << name <<
" failed";
151 fgMasterInstance->fH1Manager->
AddH1Vector(h1Vector);
159 G4bool G4XmlAnalysisManager::WriteH2()
161 const std::vector<tools::histo::h2d*>& h2Vector
163 const std::vector<G4HnInformation*>& hnVector
166 if ( ! h2Vector.size() )
return true;
171 for (
G4int i=0; i<
G4int(h2Vector.size()); ++i ) {
177 tools::histo::h2d* h2 = h2Vector[i];
184 std::ofstream* hnFile = fFileManager->
GetHnFile();
186 = tools::waxml::write(*hnFile, *h2, path, name);
189 description <<
" " <<
"saving histogram " << name <<
" failed";
201 fgMasterInstance->fH2Manager->
AddH2Vector(h2Vector);
209 G4bool G4XmlAnalysisManager::WriteNtuple()
211 const std::vector<G4XmlNtupleDescription*>& ntupleVector
214 for (
G4int i=0; i<
G4int(ntupleVector.size()); ++i ) {
215 if ( ntupleVector[i]->fNtuple ) ntupleVector[i]->fNtuple->write_trailer();
222 G4bool G4XmlAnalysisManager::CloseNtupleFiles()
224 const std::vector<G4XmlNtupleDescription*>& ntupleVector
228 std::vector<G4XmlNtupleDescription*>::const_iterator it;
229 for (it = ntupleVector.begin(); it != ntupleVector.end(); it++ ) {
238 G4bool G4XmlAnalysisManager::Reset()
242 G4bool finalResult =
true;
245 finalResult = finalResult && result;
247 result = fH2Manager->
Reset();
248 finalResult = finalResult && result;
250 result = fNtupleManager->
Reset();
251 finalResult = finalResult && result;
263 G4bool finalResult =
true;
265 finalResult = finalResult && result;
275 result = fFileManager->
OpenFile(fileName);
276 finalResult = finalResult && result;
281 finalResult = finalResult && result;
299 G4bool finalResult =
true;
310 if ( ! fgMasterInstance &&
311 ( ( ! fH1Manager->
IsEmpty() ) || ( ! fH2Manager->
IsEmpty() ) ) ) {
315 <<
" " <<
"No master G4XmlAnalysisManager instance exists."
317 <<
" " <<
"Histogram data will not be merged.";
323 if ( ! result )
return false;
327 G4bool result = WriteH1();
328 finalResult = finalResult && result;
332 finalResult = finalResult && result;
337 finalResult = finalResult && result;
352 G4bool finalResult =
true;
361 finalResult = finalResult && result;
365 finalResult = finalResult && result;
370 result = CloseNtupleFiles();
371 finalResult = finalResult && result;
378 description <<
" " <<
"Resetting data failed";
382 finalResult = finalResult && result;
void Message(const G4String &action, const G4String &object, const G4String &objectName, G4bool success=true) const
virtual G4bool CloseFileImpl()
std::ostringstream G4ExceptionDescription
G4String GetFullFileName() const
void SetH1Manager(G4VH1Manager *h1Manager)
static G4XmlAnalysisManager * Instance()
void LockHistoDirectoryName()
G4XmlAnalysisManager(G4bool isMaster=true)
#define G4MUTEX_INITIALIZER
void SetFileManager(G4XmlFileManager *fileManager)
const G4AnalysisVerbose * GetVerboseL3() const
const std::vector< G4XmlNtupleDescription * > & GetNtupleVector() const
virtual G4bool OpenFileImpl(const G4String &fileName)
const G4AnalysisVerbose * GetVerboseL4() const
G4String GetFileName() const
G4String GetHistoDirectoryName() const
virtual G4bool CloseFile()
virtual G4bool OpenFile(const G4String &fileName)
virtual G4bool WriteImpl()
void SetFileManager(G4VFileManager *fileManager)
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
void SetH2Manager(G4VH2Manager *h2Manager)
std::ofstream * GetHnFile() const
G4bool CloseNtupleFile(G4XmlNtupleDescription *ntupleDescription)
G4String & append(const G4String &)
void CreateNtuplesFromBooking()
G4bool GetIsMaster() const
const XML_Char XML_Encoding * info
G4bool SetFileName(const G4String &fileName)
G4AnalysisManagerState fState
G4bool GetIsActivation() const
const G4AnalysisVerbose * GetVerboseL1() const
void SetNtupleManager(G4VNtupleManager *ntupleManager)
G4bool WriteAscii(const G4String &fileName)