34#include "tools/wroot/file"
35#include "tools/wroot/ntuple"
42 std::shared_ptr<G4NtupleBookingManager> bookingManager,
47 fNtupleBuilder(ntupleBuilder),
48 fBookingManager(
std::move(bookingManager)),
50 fFileNumber(fileNumber)
64 auto ntupleFile = fFileManager->CreateNtupleFile(ntupleDescription, fFileNumber);
65 if ( ntupleFile ==
nullptr ) {
67 Warn(
"Ntuple file must be defined first.\n"
68 "Cannot create main ntuple.",
69 fkClass,
"CreateNtuple");
77 Message(
kVL4,
"create",
"main ntuple", ntupleBooking.name());
80 auto ntuple =
new tools::wroot::ntuple(*std::get<2>(*ntupleFile), ntupleBooking, fRowWise);
82 auto basketSize = fNtupleBuilder->GetBasketSize();
83 ntuple->set_basket_size(basketSize);
85 fNtupleVector.push_back(ntuple);
86 fNtupleDescriptionVector.push_back(std::make_pair(ntupleDescription, ntupleFile));
88 Message(
kVL3,
"create",
"main ntuple", ntupleBooking.name());
94 std::size_t counter = 0;
96 for (
auto ntuple : fNtupleVector ) {
97 ntuple->merge_number_of_entries();
100 if (ntuple->entries() != 0u) {
101 auto ntupleDescription = fNtupleDescriptionVector.at(counter).first;
102 ntupleDescription->SetHasFill(
true);
116 fNtupleVector.clear();
124 fNtupleDescriptionVector.clear();
125 fNtupleVector.clear();
131std::shared_ptr<G4RootFile>
134 auto perThread =
false;
135 return fFileManager->GetNtupleFile(ntupleDescription, perThread, fFileNumber);
148 for (
auto [ntupleDescription, ntupleFile] : fNtupleDescriptionVector) {
151 const auto& ntupleBooking = ntupleDescription->GetNtupleBooking();
153 Message(
kVL4,
"create",
"main ntuple", ntupleBooking.name());
156 auto ntuple =
new tools::wroot::ntuple(*std::get<2>(*ntupleFile), ntupleBooking, fRowWise);
158 auto basketSize = fNtupleBuilder->GetBasketSize();
159 ntuple->set_basket_size(basketSize);
161 fNtupleVector.push_back(ntuple);
163 Message(
kVL3,
"create",
"main ntuple", ntupleBooking.name());
void Message(G4int level, const G4String &action, const G4String &objectType, const G4String &objectName="", G4bool success=true) const
void CreateNtuplesFromBooking()
std::shared_ptr< G4RootFile > GetNtupleFile(RootNtupleDescription *ntupleDescription) const
G4RootMainNtupleManager()=delete
void SetNewCycle(G4bool value)
void CreateNtuple(RootNtupleDescription *ntupleDescription, G4bool warn=true)
const tools::ntuple_booking & GetNtupleBooking() const
void Warn(const G4String &message, const std::string_view inClass, const std::string_view inFunction)