62 if ( fgInstance ==
nullptr ) {
73 return ( fgInstance != 0 );
79 fNtupleManager(nullptr),
82 if ( ( isMaster && fgMasterInstance ) || ( fgInstance ) ) {
85 <<
"G4CsvAnalysisManager already exists."
86 <<
"Cannot create another instance.";
87 G4Exception(
"G4CsvAnalysisManager::G4CsvAnalysisManager()",
91 if ( isMaster ) fgMasterInstance =
this;
94 fFileManager = std::make_shared<G4CsvFileManager>(
fState);
95 fNtupleManager->SetFileManager(fFileManager);
107 fgInstance =
nullptr;
115 G4bool G4CsvAnalysisManager::CloseNtupleFiles()
118 = fNtupleManager->GetNtupleDescriptionVector();
121 for (
auto ntupleDescription : ntupleVector) {
122 fFileManager->CloseNtupleFile(ntupleDescription);
139 G4bool G4CsvAnalysisManager::WriteH1()
144 if ( ! h1Vector.size() )
return true;
149 result = WriteT(h1Vector, hnVector,
"h1");
163 G4bool G4CsvAnalysisManager::WriteH2()
168 if ( ! h2Vector.size() )
return true;
173 result = WriteT(h2Vector, hnVector,
"h2");
187 G4bool G4CsvAnalysisManager::WriteH3()
192 if ( ! h3Vector.size() )
return true;
197 result = WriteT(h3Vector, hnVector,
"h3");
211 G4bool G4CsvAnalysisManager::WriteP1()
216 if ( ! p1Vector.size() )
return true;
221 result = WriteT(p1Vector, hnVector,
"p1");
235 G4bool G4CsvAnalysisManager::WriteP2()
240 if ( ! p2Vector.size() )
return true;
245 result = WriteT(p2Vector, hnVector,
"p2");
259 G4bool G4CsvAnalysisManager::Reset()
263 auto finalResult =
true;
266 finalResult = finalResult &&
result;
268 result = fNtupleManager->
Reset(
true);
269 finalResult = finalResult &&
result;
277 auto finalResult =
true;
278 auto result = fFileManager->SetFileName(fileName);
279 finalResult = finalResult &&
result;
282 result = fFileManager->OpenFile(fileName);
283 finalResult = finalResult &&
result;
299 auto finalResult =
true;
307 if ( ! fgMasterInstance &&
314 <<
" " <<
"No master G4CsvAnalysisManager instance exists."
316 <<
" " <<
"Histogram data will not be merged.";
322 auto result = WriteH1();
323 finalResult = finalResult &&
result;
327 finalResult = finalResult &&
result;
331 finalResult = finalResult &&
result;
335 finalResult = finalResult &&
result;
339 finalResult = finalResult &&
result;
353 ->
Message(
"write",
"files",
"", finalResult);
362 auto finalResult =
true;
365 auto result = fFileManager->CloseFile();
366 finalResult = finalResult &&
result;
371 result = CloseNtupleFiles();
372 finalResult = finalResult &&
result;
378 description <<
" " <<
"Resetting data failed";
383 finalResult = finalResult &&
result;
G4double G4ParticleHPJENDLHEData::G4double result
void Message(const G4String &action, const G4String &object, const G4String &objectName, G4bool success=true) const
std::ostringstream G4ExceptionDescription
static G4bool IsInstance()
G4CsvAnalysisManager(G4bool isMaster=true)
virtual G4bool WriteImpl() final
void CreateNtuplesFromBooking()
#define G4MUTEX_INITIALIZER
static G4CsvAnalysisManager * Instance()
G4bool Reset(G4bool deleteNtuple)
const G4AnalysisVerbose * GetVerboseL4() const
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
void SetFileManager(std::shared_ptr< G4VFileManager > fileManager)
G4bool GetIsMaster() const
virtual G4bool OpenFileImpl(const G4String &fileName) final
G4AnalysisManagerState fState
virtual G4bool CloseFileImpl() final
const G4AnalysisVerbose * GetVerboseL1() const
void SetNtupleManager(G4VNtupleManager *ntupleManager)