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 #ifndef G4RootMainNtupleManager_h
0032 #define G4RootMainNtupleManager_h 1
0033
0034 #include "G4BaseAnalysisManager.hh"
0035 #include "G4NtupleBookingManager.hh"
0036 #include "G4RootFileDef.hh"
0037 #include "G4RootNtupleManager.hh"
0038 #include "G4TNtupleDescription.hh"
0039 #include "globals.hh"
0040
0041 #include <string_view>
0042 #include <utility>
0043 #include <vector>
0044
0045 class G4RootFileManager;
0046 class G4RootNtupleManager;
0047 class G4NtupleBookingManager;
0048
0049 namespace tools {
0050 namespace wroot {
0051 class ntuple;
0052 }
0053 }
0054
0055
0056 using RootNtupleDescription = G4TNtupleDescription<tools::wroot::ntuple, G4RootFile>;
0057 using RootMainNtupleDescription = std::pair<RootNtupleDescription*, std::shared_ptr<G4RootFile>>;
0058
0059 class G4RootMainNtupleManager : public G4BaseAnalysisManager
0060 {
0061 friend class G4RootPNtupleManager;
0062 friend class G4RootNtupleManager;
0063
0064 public:
0065 G4RootMainNtupleManager(
0066 G4RootNtupleManager* ntupleBuilder,
0067 std::shared_ptr<G4NtupleBookingManager> bookingManager,
0068 G4bool rowWise, G4int fileNumber,
0069 const G4AnalysisManagerState& state);
0070 G4RootMainNtupleManager() = delete;
0071 ~G4RootMainNtupleManager() override = default;
0072
0073 void CreateNtuplesFromBooking();
0074
0075 protected:
0076
0077 void CreateNtuple(RootNtupleDescription* ntupleDescription, G4bool warn = true);
0078 G4bool Delete(G4int id);
0079 G4bool Merge();
0080 G4bool Reset();
0081 void ClearData();
0082
0083
0084 void SetFileManager(std::shared_ptr<G4RootFileManager> fileManager);
0085 void SetRowWise(G4bool rowWise);
0086 std::shared_ptr<G4RootFile> GetNtupleFile(RootNtupleDescription* ntupleDescription) const;
0087
0088
0089 void SetNewCycle(G4bool value);
0090 G4bool GetNewCycle() const;
0091
0092
0093 const std::vector<tools::wroot::ntuple*>& GetNtupleVector()
0094 { return fNtupleVector; }
0095 unsigned int GetBasketEntries() const;
0096
0097 private:
0098
0099 static constexpr std::string_view fkClass { "G4RootMainNtupleManager" };
0100
0101
0102 G4int CreateNtupleFromBooking(G4NtupleBooking* ntupleBooking,
0103 std::shared_ptr<G4RootFile> ntupleFile);
0104
0105
0106 G4RootNtupleManager* fNtupleBuilder { nullptr };
0107 std::shared_ptr<G4NtupleBookingManager> fBookingManager { nullptr };
0108 std::shared_ptr<G4RootFileManager> fFileManager { nullptr };
0109 G4bool fRowWise;
0110 G4int fFileNumber;
0111 std::vector<tools::wroot::ntuple*> fNtupleVector;
0112 std::vector<RootMainNtupleDescription> fNtupleDescriptionVector;
0113 G4bool fNewCycle { false };
0114 };
0115
0116 inline void G4RootMainNtupleManager::SetFileManager(
0117 std::shared_ptr<G4RootFileManager> fileManager)
0118 {
0119 fFileManager = std::move(fileManager);
0120 }
0121
0122 inline void G4RootMainNtupleManager::SetRowWise(G4bool rowWise)
0123 { fRowWise = rowWise; }
0124
0125 inline unsigned int G4RootMainNtupleManager::GetBasketEntries() const
0126 { return fNtupleBuilder->GetBasketEntries(); }
0127
0128 inline void G4RootMainNtupleManager::SetNewCycle(G4bool value)
0129 { fNewCycle = value; }
0130
0131 inline G4bool G4RootMainNtupleManager::GetNewCycle() const
0132 { return fNewCycle; }
0133
0134 #endif