35 #include "tools/wroot/file"
37 using namespace G4Analysis;
41 G4int nofMainManagers,
45 fFileManager(nullptr),
46 fNtupleDirectory(nullptr),
47 fMainNtupleManagers(),
51 for (
G4int i=0; i<nofMainManagers; ++i) {
74 ->
Message(
"set",
"ntuple create mode",
"");
82 createMode =
"G4NtupleCreateMode::kMainAfterOpen";
85 createMode =
"G4NtupleCreateMode::kMainBeforeOpen";
90 fCreateMode = G4NtupleCreateMode::kNoMergeAfterOpen;
91 createMode =
"G4NtupleCreateMode::kNoMergeAfterOpen";
93 fCreateMode = G4NtupleCreateMode::kNoMergeBeforeOpen;
94 createMode =
"G4NtupleCreateMode::kNoMergeBeforeOpen";
99 if (
fCreateMode == G4NtupleCreateMode::kNoMergeBeforeOpen &&
101 fCreateMode = G4NtupleCreateMode::kNoMergeAfterOpen;
102 createMode =
"G4NtupleCreateMode::kNoMergeAfterOpen";
105 if (
fCreateMode == G4NtupleCreateMode::kMainBeforeOpen &&
108 createMode =
"G4NtupleCreateMode::kMainAfterOpen";
114 ->
Message(
"set",
"ntuple create mode", createMode);
127 mainNtupleManager->SetRowWise(rowWise);
137 G4String inFunction =
"G4RootNtupleManager::::CreateTNtuple";
140 <<
"Cannot create ntuple. Ntuple directory does not exist." <<
G4endl;
150 ntupleDescription->
fNtuple->set_basket_size(basketSize);
161 if (
fCreateMode == G4NtupleCreateMode::kNoMergeBeforeOpen ) {
166 if (
fCreateMode == G4NtupleCreateMode::kMainBeforeOpen ) {
169 if ( ! manager->GetNtupleVector().size() ) {
171 manager->SetNtupleFile(
fFileManager->GetNtupleFile(counter));
172 manager->SetNtupleDirectory(
fFileManager->GetMainNtupleDirectory(counter++));
173 manager->CreateNtuplesFromBooking();
187 if ( ! fromBooking ) {
192 if (
fCreateMode == G4NtupleCreateMode::kNoMergeAfterOpen ) {
197 if (
fCreateMode == G4NtupleCreateMode::kMainAfterOpen ) {
201 manager->SetNtupleFile(
fFileManager->GetNtupleFile(counter));
202 manager->SetNtupleDirectory(
fFileManager->GetMainNtupleDirectory(counter++));
214 if (
fCreateMode == G4NtupleCreateMode::kNoMergeAfterOpen ) {
219 auto finalResult =
true;
221 auto result = manager->Reset(
false);
222 finalResult = result && finalResult;
231 auto finalResult =
true;
234 auto result = manager->Merge();
235 finalResult = result && finalResult;
245 G4String inFunction =
"G4RootNtupleManager::::GetMainNtupleManager";
247 description <<
" " <<
"main ntuple manager " << index <<
" does not exist.";
259 G4String inFunction =
"G4RootNtupleManager::::GetBasketSize";
261 description <<
" " <<
"File manager must be defined first.";
273 G4String inFunction =
"G4RootNtupleManager::::GetBasketEntries";
275 description <<
" " <<
"File manager must be defined first.";