33 #include "tools/wroot/file"
34 #include "tools/wroot/ntuple"
48 fMainNtupleManager(main),
58 delete ntupleDescription;
74 G4String inFunction =
"G4RootPNtupleManager::";
75 inFunction += functionName;
77 description <<
" " <<
"ntuple " <<
id <<
" does not exist.";
87 tools::wroot::base_pntuple*
92 if ( ! ntupleDescription )
return nullptr;
94 if ( ! ntupleDescription->fBasePNtuple ) {
96 G4String inFunction =
"G4RootPNtupleManager::";
97 inFunction += functionName;
99 description <<
" " <<
"ntupleId " <<
id <<
" does not exist.";
104 return ntupleDescription->fBasePNtuple;
112 auto& mainNtupleVector
116 if ( index < 0 || index >=
G4int(mainNtupleVector.size()) ) {
118 G4String inFunction =
"G4RootPNtupleManager::";
119 inFunction += functionName;
121 description <<
" " <<
"main ntuple " <<
id <<
" does not exist.";
127 return mainNtupleVector[index];
142 ->
Message(
"create from main",
"pntuple", mainNtuple->name());
154 auto mainBranch = mainNtuple->get_row_wise_branch();
155 tools::wroot::mt_ntuple_row_wise* mtNtuple
156 =
new tools::wroot::mt_ntuple_row_wise(
158 mainNtuple->dir().seek_directory(),
159 *mainBranch, mainBranch->basket_size(),
163 =
static_cast<tools::wroot::imt_ntuple*
>(mtNtuple);
165 =
static_cast<tools::wroot::base_pntuple*
>(mtNtuple);
168 std::vector<tools::uint32> basketSizes;
169 tools_vforcit(tools::wroot::branch*, ntupleDescription->
fMainBranches,
it) {
170 basketSizes.push_back((*it)->basket_size());
174 tools::wroot::mt_ntuple_column_wise* mtNtuple =
175 new tools::wroot::mt_ntuple_column_wise(
177 mainNtuple->dir().seek_directory(),
183 =
static_cast<tools::wroot::imt_ntuple*
>(mtNtuple);
185 =
static_cast<tools::wroot::base_pntuple*
>(mtNtuple);
196 ->
Message(
"create from main",
"pntuple", mainNtuple->name());
208 fCreateMode = G4PNtupleCreateMode::kSlaveBeforeOpen;
211 fCreateMode = G4PNtupleCreateMode::kSlaveAfterOpen;
216 if (
fCreateMode == G4PNtupleCreateMode::kSlaveAfterOpen ) {
222 auto& mainNtupleVector
226 for (
auto mainNtuple : mainNtupleVector ) {
228 auto& ntupleDescription
248 fCreateMode = G4PNtupleCreateMode::kSlaveAfterOpen;
250 fCreateMode = G4PNtupleCreateMode::kSlaveBeforeOpen;
260 ntupleDescription->fNtupleBooking.set_name(name);
261 ntupleDescription->fNtupleBooking.set_title(title);
268 description << name <<
" ntupleId " << index +
fFirstId;
280 return CreateNtupleTColumn<int>(ntupleId,
name, vector);
287 return CreateNtupleTColumn<float>(ntupleId,
name, vector);
295 return CreateNtupleTColumn<double>(ntupleId,
name, vector);
302 return CreateNtupleTColumn<std::string>(ntupleId,
name,
nullptr);
311 if (
fCreateMode == G4PNtupleCreateMode::kSlaveAfterOpen ) {
312 auto ntupleDescription
314 if ( ! ntupleDescription )
return;
317 if ( ! mainNtuple )
return;
327 return FillNtupleTColumn<int>(ntupleId, columnId,
value);
334 return FillNtupleTColumn<float>(ntupleId, columnId,
value);
341 return FillNtupleTColumn<double>(ntupleId, columnId,
value);
348 return FillNtupleTColumn<std::string>(ntupleId, columnId,
value);
362 description <<
" ntupleId " << ntupleId;
368 if ( ! ntupleDescription )
return false;
372 mutex toolsLock(lock);
374 = ntupleDescription->fNtuple
375 ->add_row(toolsLock, *ntupleDescription->fFile);
379 description <<
" " <<
" ntupleId " << ntupleId
380 <<
"adding row has failed.";
381 G4Exception(
"G4RootPNtupleManager::AddNtupleRow()",
388 description <<
" ntupleId " << ntupleId;
402 if ( ! ntupleDescription->fActivation )
continue;
407 ->
Message(
"merge",
"pntuple", ntupleDescription->fNtupleBooking.name());
413 mutex toolsLock(lock);
415 = ntupleDescription->fNtuple
416 ->end_fill(toolsLock, *ntupleDescription->fFile);
420 description <<
" " <<
" ntuple " << ntupleDescription->fNtupleBooking.name()
421 <<
"end fill has failed.";
426 delete ntupleDescription->fNtuple;
427 ntupleDescription->fNtuple =
nullptr;
432 ->
Message(
"merge",
"pntuple", ntupleDescription->fNtupleBooking.name());
444 if ( deleteNtuple ) {
445 delete ntupleDescription->fNtuple;
447 ntupleDescription->fNtuple =
nullptr;
461 ntupleDescription->fActivation = activation;
471 if ( ! ntupleDescription )
return;
473 ntupleDescription->fActivation = activation;
478 G4int ntupleId)
const
481 if ( ! ntupleDescription )
return false;
483 return ntupleDescription->fActivation;