50 std::string_view functionName,
53 if (
GetExtension(fileName) ==
"hdf5" && ( ! hdf5Warn ) )
return;
55 Warn(
"Cannot get file manager for " + fileName,
75 auto outputId =
static_cast<size_t>(output);
78 " type already exists.",
91 fHdf5FileManager = std::make_shared<G4Hdf5FileManager>(
fState);
95 Warn(
"Hdf5 type is not available.",
fkClass,
"CreateFileManager");
126std::shared_ptr<G4VFileManager>
133std::shared_ptr<G4VFileManager>
138 if ( ! extension.size() ) {
145 Warn(
"The file extension " + extension +
"is not supported.",
150 std::shared_ptr<G4VFileManager> fileManager =
GetFileManager(output);
167 if ( ! fileManager )
return false;
172 Warn(
"Default file manager changed "
174 ", new:" + fileManager->GetFileType() +
")",
193 Message(
kVL1,
"open",
"analysis file", fileName, result);
210 if ( ! fileManager ) {
215 result &= fileManager->CreateFile(fileName);
218 Message(
kVL3,
"open",
"analysis files",
"", result);
233 if ( ! fileManager )
continue;
235 Message(
kVL4,
"write", fileManager->GetFileType(),
"files");
237 result &= fileManager->WriteFiles();
240 Message(
kVL3,
"write",
"analysis files",
"", result);
255 if ( ! fileManager )
continue;
257 Message(
kVL4,
"close", fileManager->GetFileType(),
"files");
259 result &= fileManager->CloseFiles();
264 Message(
kVL3,
"close",
"analysis files",
"", result);
279 if ( ! fileManager )
continue;
281 Message(
kVL4,
"delete", fileManager->GetFileType(),
"empty files");
283 result &= fileManager->DeleteEmptyFiles();
286 Message(
kVL3,
"delete",
"empty files",
"", result);
297 if ( ! fileManager )
continue;
299 fileManager->Clear();
310 if ( ! fileManager ) {
315 return fileManager->CreateFile(fileName);
324 if ( ! fileManager ) {
329 return fileManager->WriteFile(fileName);
338 if ( ! fileManager ) {
343 return fileManager->CloseFile(fileName);
350 if ( ! fileManager ) {
355 return fileManager->SetIsEmpty(fileName, isEmpty);
364 if ( fileManager !=
nullptr ) {
365 result &= fileManager->SetHistoDirectoryName(dirName);
377 if ( fileManager !=
nullptr ) {
378 result &= fileManager->SetNtupleDirectoryName(dirName);
390 Warn(
"The file type " + value +
"is not supported.\n" +
392 fkClass,
"SetDeafultFileType");
400std::shared_ptr<G4VNtupleFileManager>
407 std::shared_ptr<G4VNtupleFileManager> vNtupleFileManager =
nullptr;
412 auto ntupleFileManager = std::make_shared<G4CsvNtupleFileManager>(
fState);
414 vNtupleFileManager = ntupleFileManager;
419 auto ntupleFileManager = std::make_shared<G4Hdf5NtupleFileManager>(
fState);
420 ntupleFileManager->SetFileManager(fHdf5FileManager);
421 vNtupleFileManager = ntupleFileManager;
423 failure =
" Hdf5 is not available";
428 auto ntupleFileManager = std::make_shared<G4RootNtupleFileManager>(
fState);
430 vNtupleFileManager = ntupleFileManager;
434 auto ntupleFileManager = std::make_shared<G4XmlNtupleFileManager>(
fState);
436 vNtupleFileManager = ntupleFileManager;
443 if ( ! vNtupleFileManager ) {
444 Warn(
"Failed to create ntuple file manager of " +
446 fkClass,
"CreateNtupleFileManager");
449 return vNtupleFileManager;
const std::vector< G4String > & GetFileNames() const
void Message(G4int level, const G4String &action, const G4String &objectType, const G4String &objectName="", G4bool success=true) const
const G4AnalysisManagerState & fState
virtual G4bool SetIsEmpty(const G4String &fileName, G4bool isEmpty) final
virtual G4bool WriteFiles() final
virtual G4bool CreateFile(const G4String &fileName) final
std::shared_ptr< G4VNtupleFileManager > CreateNtupleFileManager(G4AnalysisOutput output)
std::shared_ptr< G4VFileManager > fDefaultFileManager
G4String fDefaultFileType
virtual G4bool OpenFiles() final
std::vector< std::shared_ptr< G4VFileManager > > fFileManagers
virtual G4bool SetHistoDirectoryName(const G4String &dirName)
virtual G4bool CloseFile(const G4String &fileName) final
std::shared_ptr< G4VFileManager > GetFileManager(const G4String &fileName)
virtual G4bool OpenFile(const G4String &fileName) final
virtual void Clear() final
std::shared_ptr< G4CsvFileManager > fCsvFileManager
std::shared_ptr< G4XmlFileManager > fXmlFileManager
virtual G4bool SetNtupleDirectoryName(const G4String &dirName)
void CreateFileManager(G4AnalysisOutput output)
static constexpr std::string_view fkClass
void SetDefaultFileType(const G4String &value)
virtual G4bool WriteFile(const G4String &fileName) final
G4GenericFileManager(const G4AnalysisManagerState &state)
std::shared_ptr< G4RootFileManager > fRootFileManager
virtual G4bool CloseFiles() final
virtual G4bool DeleteEmptyFiles() final
G4String GetNtupleDirectoryName() const
G4String GetHistoDirectoryName() const
virtual G4bool SetHistoDirectoryName(const G4String &dirName)
virtual G4bool SetFileName(const G4String &fileName) final
virtual G4bool SetNtupleDirectoryName(const G4String &dirName)
void LockDirectoryNames()
void UnlockDirectoryNames()
G4String GetExtension(const G4String &fileName, const G4String &defaultExtension="")
G4String GetOutputName(G4AnalysisOutput outputType)
G4AnalysisOutput GetOutput(const G4String &outputName, G4bool warn=true)
void Warn(const G4String &message, const std::string_view inClass, const std::string_view inFunction)
void FileManagerWarning(const G4String &fileName, std::string_view className, std::string_view functionName, G4bool hdf5Warn=true)