File indexing completed on 2025-01-18 09:58:05
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031 #ifndef G4CsvFileManager_h
0032 #define G4CsvFileManager_h 1
0033
0034 #include "G4VTFileManager.hh"
0035 #include "G4TNtupleDescription.hh"
0036 #include "globals.hh"
0037
0038 #include "tools/wcsv_ntuple"
0039
0040 #include <string_view>
0041
0042
0043 using CsvNtupleDescription = G4TNtupleDescription<tools::wcsv::ntuple, std::ofstream>;
0044
0045 class G4CsvFileManager : public G4VTFileManager<std::ofstream>
0046 {
0047 public:
0048 explicit G4CsvFileManager(const G4AnalysisManagerState& state);
0049 G4CsvFileManager() = delete;
0050 ~G4CsvFileManager() override = default;
0051
0052 using G4BaseFileManager::GetNtupleFileName;
0053 using G4VTFileManager<std::ofstream>::WriteFile;
0054 using G4VTFileManager<std::ofstream>::CloseFile;
0055
0056
0057 G4bool OpenFile(const G4String& fileName) final;
0058
0059 G4bool SetHistoDirectoryName(const G4String& dirName) final;
0060 G4bool SetNtupleDirectoryName(const G4String& dirName) final;
0061
0062 G4String GetFileType() const final { return "csv"; }
0063
0064
0065 G4bool NotifyNtupleFile(CsvNtupleDescription* ntupleDescription);
0066 G4bool CreateNtupleFile(CsvNtupleDescription* ntupleDescription);
0067 G4bool CloseNtupleFile(CsvNtupleDescription* ntupleDescription);
0068
0069 G4bool IsHistoDirectory() const;
0070 G4bool IsNtupleDirectory() const;
0071
0072 protected:
0073
0074 std::shared_ptr<std::ofstream> CreateFileImpl(const G4String& fileName) final;
0075 G4bool WriteFileImpl(std::shared_ptr<std::ofstream> file) final;
0076 G4bool CloseFileImpl(std::shared_ptr<std::ofstream> file) final;
0077
0078 private:
0079
0080 G4String GetNtupleFileName(CsvNtupleDescription* ntupleDescription);
0081
0082
0083 static constexpr std::string_view fkClass { "G4CsvFileManager" };
0084
0085
0086 G4bool fIsHistoDirectory { false };
0087 G4bool fIsNtupleDirectory { false };
0088 };
0089
0090
0091
0092 inline G4bool G4CsvFileManager::IsHistoDirectory() const
0093 { return fIsHistoDirectory; }
0094
0095 inline G4bool G4CsvFileManager::IsNtupleDirectory() const
0096 { return fIsNtupleDirectory; }
0097
0098 #endif