42using std::make_shared;
58 auto mergeNtuples =
false;
83 Warn(
"Merging ntuples is not applicable in sequential application.\n"
84 "Setting was ignored.",
85 fkClass,
"SetNtupleMergingMode");
92 Warn(
"Merging ntuples requires G4AnalysisManager instance on master.\n"
93 "Setting was ignored.",
94 fkClass,
"SetNtupleMergingMode");
99 if ( ( ! mergeNtuples ) || ( ! canMerge ) ) {
101 mergingMode =
"G4NtupleMergeMode::kNone";
109 Warn(
"Number of reduced files must be [0, nofThreads].\n"
110 "Cannot set " + to_string(nofNtupleFiles) +
" files.\n" +
111 "Setting was ignored.",
112 fkClass,
"SetNtupleMergingMode");
120 mergingMode =
"G4NtupleMergeMode::kMain";
123 mergingMode =
"G4NtupleMergeMode::kSlave";
127 Message(
kVL2,
"set",
"ntuple merging mode", mergingMode);
136 if ( ! nofMainManagers ) nofMainManagers = 1;
149 for (
auto ntupleDescription : ntupleVector) {
150 result &=
fFileManager->CloseNtupleFile(ntupleDescription);
162 G4int nofNtupleFiles)
166 Warn(
"Cannot change merging mode.\n"
167 "The function must be called before OpenFile().",
184 rowWiseMode =
"row-wise with extra branch";
186 else if ( rowMode ) {
187 rowWiseMode =
"row-wise";
190 rowWiseMode =
"column-wise";
193 Message(
kVL1,
"set",
"ntuple merging row mode", rowWiseMode);
233 std::shared_ptr<G4VNtupleManager> activeNtupleManager =
nullptr;
238 = make_shared<G4RootNtupleManager>(
246 if ( ! nofMainManagers ) nofMainManagers = 1;
249 = make_shared<G4RootNtupleManager>(
259 auto mainNtupleManager
262 = make_shared<G4RootPNtupleManager>(
277 mergeMode =
"slave ";
280 Message(
kVL3,
"create", mergeMode +
"ntuple manager");
284 return activeNtupleManager;
295 G4String objectType =
"analysis file";
297 objectType =
"main analysis file";
358 Warn(
"Resetting data failed",
fkClass,
"ActionAtCloseFile");
G4bool GetIsMaster() const
virtual void SetNtupleMerging(G4bool mergeNtuples, G4int nofReducedNtupleFiles=0) override
virtual void SetNtupleRowWise(G4bool rowWise, G4bool rowMode=true) override
virtual void SetBasketSize(unsigned int basketSize) override
static G4RootNtupleFileManager * fgMasterInstance
virtual std::shared_ptr< G4VNtupleManager > CreateNtupleManager() override
static constexpr std::string_view fkClass
virtual G4bool ActionAtCloseFile(G4bool reset) override
G4NtupleMergeMode fNtupleMergeMode
virtual G4bool ActionAtWrite() override
std::shared_ptr< G4RootPNtupleManager > fSlaveNtupleManager
void SetNtupleMergingMode(G4bool mergeNtuples, G4int nofNtupleFiles)
G4int GetNtupleFileNumber()
virtual void SetBasketEntries(unsigned int basketEntries) override
G4bool CloseNtupleFiles()
virtual G4bool Reset() override
std::shared_ptr< G4RootNtupleManager > fNtupleManager
virtual G4bool ActionAtOpenFile(const G4String &fileName) override
G4RootNtupleFileManager()=delete
virtual ~G4RootNtupleFileManager()
std::shared_ptr< G4RootFileManager > fFileManager
std::shared_ptr< G4NtupleBookingManager > fBookingManager
void Message(G4int level, const G4String &action, const G4String &objectType, const G4String &objectName="", G4bool success=true) const
const G4AnalysisManagerState & fState
void Warn(const G4String &message, const std::string_view inClass, const std::string_view inFunction)
G4bool IsMultithreadedApplication()