64 if ( fgInstance ==
nullptr ) {
75 return ( fgInstance != 0 );
81 fNtupleFileManager(nullptr),
85#ifndef H5_HAVE_THREADSAFE
88 <<
"Your HDF5 lib is not built with H5_HAVE_THREADSAFE.";
89 G4Exception(
"G4Hdf5AnalysisManager::G4Hdf5AnalysisManager",
94 if ( ( isMaster && fgMasterInstance ) || ( fgInstance ) ) {
98 <<
"G4Hdf5AnalysisManager already exists."
99 <<
"Cannot create another instance.";
100 G4Exception(
"G4Hdf5AnalysisManager::G4Hdf5AnalysisManager",
103 if ( isMaster ) fgMasterInstance =
this;
107 fFileManager = std::make_shared<G4Hdf5FileManager>(
fState);
109 fFileManager->SetBasketSize(fgkDefaultBasketSize);
112 fNtupleFileManager = std::make_shared<G4Hdf5NtupleFileManager>(
fState);
113 fNtupleFileManager->SetFileManager(fFileManager);
121 fgInstance =
nullptr;
129G4bool G4Hdf5AnalysisManager::WriteH1()
134 if ( ! h1Vector.size() )
return true;
139 result = WriteHn(h1Vector, hnVector,
"h1");
153G4bool G4Hdf5AnalysisManager::WriteH2()
158 if ( ! h2Vector.size() )
return true;
163 result = WriteHn(h2Vector, hnVector,
"h2");
177G4bool G4Hdf5AnalysisManager::WriteH3()
182 if ( ! h3Vector.size() )
return true;
187 result = WriteHn(h3Vector, hnVector,
"h3");
201G4bool G4Hdf5AnalysisManager::WriteP1()
206 if ( ! p1Vector.size() )
return true;
211 result = WritePn(p1Vector, hnVector,
"p1");
225G4bool G4Hdf5AnalysisManager::WriteP2()
230 if ( ! p2Vector.size() )
return true;
235 result = WritePn(p2Vector, hnVector,
"p2");
249G4bool G4Hdf5AnalysisManager::Reset()
253 auto finalResult =
true;
256 finalResult = finalResult && result;
258 result = fNtupleFileManager->Reset();
259 finalResult = finalResult && result;
275 auto finalResult =
true;
278 auto result = fFileManager->OpenFile(fileName);
279 finalResult = finalResult && result;
281 result = fNtupleFileManager->ActionAtOpenFile(fFileManager->GetFullFileName());
282 finalResult = finalResult && result;
291 auto finalResult =
true;
299 auto result = WriteH1();
300 finalResult = finalResult && result;
304 finalResult = finalResult && result;
308 finalResult = finalResult && result;
312 finalResult = finalResult && result;
316 finalResult = finalResult && result;
320 result =
WriteAscii(fFileManager->GetFileName());
321 finalResult = finalResult && result;
336 auto finalResult =
true;
339 auto result = fFileManager->CloseFiles();
340 finalResult = finalResult && result;
347 description <<
" " <<
"Resetting data failed";
352 finalResult = finalResult && result;
354 result = fNtupleFileManager->ActionAtCloseFile(reset);
355 finalResult = finalResult && result;
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
std::ostringstream G4ExceptionDescription
#define G4MUTEX_INITIALIZER
const G4AnalysisVerbose * GetVerboseL2() const
G4bool GetIsMaster() const
const G4AnalysisVerbose * GetVerboseL4() const
void Message(const G4String &action, const G4String &object, const G4String &objectName, G4bool success=true) const
virtual G4bool CloseFileImpl(G4bool reset) final
G4Hdf5AnalysisManager(G4bool isMaster=true)
virtual G4bool OpenFileImpl(const G4String &fileName) final
virtual G4bool WriteImpl() final
static G4bool IsInstance()
static G4Hdf5AnalysisManager * Instance()
std::shared_ptr< G4NtupleBookingManager > fNtupleBookingManager
G4AnalysisManagerState fState
void SetFileManager(std::shared_ptr< G4VFileManager > fileManager)
G4bool WriteAscii(const G4String &fileName)
void SetNtupleManager(std::shared_ptr< G4VNtupleManager > ntupleManager)