61 if ( fgInstance ==
nullptr ) {
72 return ( fgInstance != 0 );
78 fFileManager(nullptr),
79 fNtupleFileManager(nullptr)
81 if ( ( isMaster && fgMasterInstance ) || ( fgInstance ) ) {
84 <<
"G4CsvAnalysisManager already exists."
85 <<
"Cannot create another instance.";
86 G4Exception(
"G4CsvAnalysisManager::G4CsvAnalysisManager()",
90 if ( isMaster ) fgMasterInstance =
this;
94 fFileManager = std::make_shared<G4CsvFileManager>(
fState);
98 fNtupleFileManager = std::make_shared<G4CsvNtupleFileManager>(
fState);
99 fNtupleFileManager->SetFileManager(fFileManager);
107 fgInstance =
nullptr;
115G4bool G4CsvAnalysisManager::WriteH1()
120 if ( ! h1Vector.size() )
return true;
125 result = WriteT(h1Vector, hnVector,
"h1");
139G4bool G4CsvAnalysisManager::WriteH2()
144 if ( ! h2Vector.size() )
return true;
149 result = WriteT(h2Vector, hnVector,
"h2");
163G4bool G4CsvAnalysisManager::WriteH3()
168 if ( ! h3Vector.size() )
return true;
173 result = WriteT(h3Vector, hnVector,
"h3");
187G4bool G4CsvAnalysisManager::WriteP1()
192 if ( ! p1Vector.size() )
return true;
197 result = WriteT(p1Vector, hnVector,
"p1");
211G4bool G4CsvAnalysisManager::WriteP2()
216 if ( ! p2Vector.size() )
return true;
221 result = WriteT(p2Vector, hnVector,
"p2");
235G4bool G4CsvAnalysisManager::Reset()
239 auto finalResult =
true;
242 finalResult = finalResult && result;
244 result = fNtupleFileManager->Reset();
245 finalResult = finalResult && result;
257 auto finalResult =
true;
260 auto result = fFileManager->OpenFile(fileName);
261 finalResult = finalResult && result;
264 result = fNtupleFileManager->ActionAtOpenFile(fFileManager->GetFullFileName());
265 finalResult = finalResult && result;
274 auto finalResult =
true;
283 if ( ! fgMasterInstance &&
290 <<
" " <<
"No master G4CsvAnalysisManager instance exists."
292 <<
" " <<
"Histogram data will not be merged.";
298 auto result = WriteH1();
299 finalResult = finalResult && result;
303 finalResult = finalResult && result;
307 finalResult = finalResult && result;
311 finalResult = finalResult && result;
315 finalResult = finalResult && result;
338 auto finalResult =
true;
341 auto result = fFileManager->CloseFiles();
342 finalResult = finalResult && result;
347 result = fNtupleFileManager->ActionAtCloseFile(reset);
348 finalResult = finalResult && result;
355 description <<
" " <<
"Resetting data failed";
360 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
G4CsvAnalysisManager(G4bool isMaster=true)
virtual G4bool OpenFileImpl(const G4String &fileName) final
static G4CsvAnalysisManager * Instance()
virtual G4bool CloseFileImpl(G4bool reset) final
static G4bool IsInstance()
virtual G4bool WriteImpl() final
std::shared_ptr< G4NtupleBookingManager > fNtupleBookingManager
G4AnalysisManagerState fState
void SetFileManager(std::shared_ptr< G4VFileManager > fileManager)
void SetNtupleManager(std::shared_ptr< G4VNtupleManager > ntupleManager)