File indexing completed on 2025-01-18 09:59:03
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
0032 #ifndef G4RootNtupleFileManager_h
0033 #define G4RootNtupleFileManager_h 1
0034
0035 #include "G4VNtupleFileManager.hh"
0036
0037 #include <string_view>
0038 #include <utility>
0039
0040 class G4RootFileManager;
0041 class G4RootNtupleManager;
0042 class G4RootPNtupleManager;
0043 class G4VNtupleManager;
0044 class G4NtupleBookingManager;
0045
0046 class G4RootNtupleFileManager : public G4VNtupleFileManager
0047 {
0048 friend class G4RootMpiNtupleFileManager;
0049
0050 public:
0051 explicit G4RootNtupleFileManager(const G4AnalysisManagerState& state);
0052 G4RootNtupleFileManager() = delete;
0053 ~G4RootNtupleFileManager() override;
0054
0055
0056 void SetNtupleMerging(G4bool mergeNtuples, G4int nofReducedNtupleFiles = 0) override;
0057 void SetNtupleRowWise(G4bool rowWise, G4bool rowMode = true) override;
0058 void SetBasketSize(unsigned int basketSize) override;
0059 void SetBasketEntries(unsigned int basketEntries) override;
0060
0061
0062 G4bool ActionAtOpenFile(const G4String& fileName) override;
0063 G4bool ActionAtWrite() override;
0064 G4bool ActionAtCloseFile() override;
0065 G4bool Reset() override;
0066 G4bool IsNtupleMergingSupported() const override;
0067
0068 std::shared_ptr<G4VNtupleManager> CreateNtupleManager() override;
0069
0070 void SetFileManager(std::shared_ptr<G4RootFileManager> fileManager);
0071
0072 G4NtupleMergeMode GetMergeMode() const override;
0073 std::shared_ptr<G4RootNtupleManager> GetNtupleManager() const;
0074
0075 private:
0076
0077 static G4RootNtupleFileManager* fgMasterInstance;
0078
0079 void SetNtupleMergingMode(G4bool mergeNtuples, G4int nofNtupleFiles);
0080 G4int GetNtupleFileNumber();
0081 G4bool CloseNtupleFiles();
0082
0083
0084 static constexpr std::string_view fkClass { "G4RootNtupleFileManager" };
0085
0086
0087 G4bool fIsInitialized { false };
0088 G4int fNofNtupleFiles { 0 };
0089 G4bool fNtupleRowWise { false };
0090 G4bool fNtupleRowMode { true };
0091 G4NtupleMergeMode fNtupleMergeMode { G4NtupleMergeMode::kNone };
0092 std::shared_ptr<G4RootNtupleManager> fNtupleManager { nullptr };
0093 std::shared_ptr<G4RootPNtupleManager> fSlaveNtupleManager { nullptr };
0094 std::shared_ptr<G4RootFileManager> fFileManager { nullptr };
0095 };
0096
0097 inline void G4RootNtupleFileManager::SetFileManager(
0098 std::shared_ptr<G4RootFileManager> fileManager)
0099 {
0100 fFileManager = std::move(fileManager);
0101 }
0102
0103 inline G4NtupleMergeMode G4RootNtupleFileManager::GetMergeMode() const
0104 { return fNtupleMergeMode; }
0105
0106 inline G4bool G4RootNtupleFileManager::IsNtupleMergingSupported() const
0107 { return true; }
0108
0109 inline std::shared_ptr<G4RootNtupleManager> G4RootNtupleFileManager::GetNtupleManager() const
0110 { return fNtupleManager; }
0111
0112 #endif