82 fNtupleRowWise(
false),
85 fNtupleManager(nullptr),
86 fSlaveNtupleManager(nullptr),
93 <<
"G4RootAnalysisManager already exists."
94 <<
"Cannot create another instance.";
95 G4Exception(
"G4RootAnalysisManager::G4RootAnalysisManager()",
110 auto mergeNtuples =
false;
130 G4int nofNtupleFiles)
136 ->
Message(
"set",
"ntuple merging mode",
"");
139 auto canMerge =
true;
143 if ( nofNtupleFiles > 0 ) {
146 <<
" " <<
"Merging ntuples is not applicable in sequential application."
148 <<
" " <<
"Setting was ignored.";
149 G4Exception(
"G4RootAnalysisManager::SetNtupleMergingMode()",
160 <<
" " <<
"Merging ntuples requires G4AnalysisManager instance on master."
162 <<
" " <<
"Setting was ignored.";
163 G4Exception(
"G4RootAnalysisManager::SetNtupleMergingMode()",
169 if ( ( ! mergeNtuples ) || ( ! canMerge ) ) {
171 mergingMode =
"G4NtupleMergeMode::kNone";
182 <<
" " <<
"Number of reduced files must be [0, nofThreads]."
184 <<
" " <<
"Cannot set " << nofNtupleFiles
187 <<
" " <<
"Ntuples will be merged in a single file.";
188 G4Exception(
"G4RootAnalysisManager::SetNtupleMergingMode()",
214 mergingMode =
"G4NtupleMergeMode::kMain";
217 mergingMode =
"G4NtupleMergeMode::kSlave";
224 ->
Message(
"set",
"ntuple merging mode", mergingMode);
262 case G4NtupleMergeMode::kNone:
268 case G4NtupleMergeMode::kMain: {
270 if ( ! nofMainManagers ) nofMainManagers = 1;
279 case G4NtupleMergeMode::kSlave:
282 auto mainNtupleManager
302 if ( ! nofMainManagers ) nofMainManagers = 1;
305 G4cout <<
"In GetNtupleFileNumber: "
318 if ( ! h1Vector.size() )
return true;
324 result =
WriteT(h1Vector, hnVector, directory,
"h1");
343 if ( ! h2Vector.size() )
return true;
349 result =
WriteT(h2Vector, hnVector, directory,
"h2");
368 if ( ! h3Vector.size() )
return true;
374 result =
WriteT(h3Vector, hnVector, directory,
"h3");
393 if ( ! p1Vector.size() )
return true;
399 result =
WriteT(p1Vector, hnVector, directory,
"p1");
418 if ( ! p2Vector.size() )
return true;
424 result =
WriteT(p2Vector, hnVector, directory,
"p2");
442 auto finalResult =
true;
445 if (
fNtupleMergeMode == G4NtupleMergeMode::kMain ) ntupleType =
"main ntuples";
446 if (
fNtupleMergeMode == G4NtupleMergeMode::kSlave ) ntupleType =
"slave ntuples";
455 finalResult = result && finalResult;
460 finalResult = result && finalResult;
476 auto finalResult =
true;
481 finalResult = result && finalResult;
492 auto finalResult =
true;
495 finalResult = finalResult && result;
498 finalResult = result && finalResult;
510 auto finalResult =
true;
512 finalResult = finalResult && result;
523 finalResult = finalResult && result;
546 finalResult = finalResult && result;
557 G4cout <<
"Going to create slave ntuples from main" <<
G4endl;
569 auto finalResult =
true;
577 <<
" " <<
"No master G4RootAnalysisManager instance exists."
579 <<
" " <<
"Histogram/profile data will not be merged.";
586 finalResult = finalResult && result;
590 finalResult = finalResult && result;
594 finalResult = finalResult && result;
598 finalResult = finalResult && result;
602 finalResult = finalResult && result;
606 finalResult = finalResult && result;
611 finalResult = finalResult && result;
617 finalResult = finalResult && result;
626 auto finalResult =
true;
641 description <<
" " <<
"Resetting data failed";
645 finalResult = finalResult && result;
661 result = ! std::remove(
fFileManager->GetFullFileName());
665 description <<
" " <<
"Removing file "
670 finalResult = finalResult && result;
687 G4int nofNtupleFiles)
708 rowWiseMode =
"row-wise with extra branch";
710 else if ( rowMode ) {
711 rowWiseMode =
"row-wise";
714 rowWiseMode =
"column-wise";
719 ->
Message(
"set",
"ntuple merging row mode", rowWiseMode);