35#include "tools/wroot/file"
42 const std::shared_ptr<G4NtupleBookingManager>& bookingManger,
49 for (
G4int i=0; i<nofMainManagers; ++i) {
51 if ( (i == 0) && (nofFiles == 0) ) {
55 fMainNtupleManagers.push_back(
56 std::make_shared<G4RootMainNtupleManager>(
57 this, bookingManger, rowWise, fileNumber,
fState));
66void G4RootNtupleManager::CreateTNtupleFromBooking(
69 if (fMainNtupleManagers.size() == 0u) {
71 if (ntupleDescription->
GetNtuple() !=
nullptr) {
72 Warn(
"Cannot create ntuple. Ntuple already exists.",
73 fkClass,
"CreateTNtupleFromBooking");
78 auto ntupleFile = fFileManager->CreateNtupleFile(ntupleDescription);
80 Warn(
"Cannot create ntuple. Ntuple file does not exist.",
81 fkClass,
"CreateTNtupleFromBooking");
85 auto directory = std::get<2>(*ntupleFile);
87 new tools::wroot::ntuple(
90 auto basketSize = fFileManager->GetBasketSize();
91 ntupleDescription->
GetNtuple()->set_basket_size(basketSize);
99 for (
const auto& manager : fMainNtupleManagers ) {
100 manager->CreateNtuple(ntupleDescription);
106void G4RootNtupleManager::FinishTNtuple(
113G4bool G4RootNtupleManager::Reset()
120 for (
const auto& manager : fMainNtupleManagers ) {
121 result &= manager->Reset();
128void G4RootNtupleManager::Clear()
133 for (
const auto& manager : fMainNtupleManagers ) {
134 manager->ClearData();
139G4bool G4RootNtupleManager::Merge()
143 for (
const auto& manager : fMainNtupleManagers ) {
144 result &= manager->Merge();
151void G4RootNtupleManager::SetFileManager(
152 const std::shared_ptr<G4RootFileManager>& fileManager)
154 fFileManager = fileManager;
156 for (
const auto& manager : fMainNtupleManagers ) {
157 manager->SetFileManager(fileManager);
162void G4RootNtupleManager::SetNtupleRowWise(
G4bool rowWise,
G4bool rowMode)
169 for (
auto& mainNtupleManager : fMainNtupleManagers ) {
170 mainNtupleManager->SetRowWise(rowWise);
175void G4RootNtupleManager::SetNewCycle(
G4bool value)
179 for (
const auto& manager : fMainNtupleManagers ) {
180 manager->SetNewCycle(value);
185std::shared_ptr<G4RootMainNtupleManager>
186G4RootNtupleManager::GetMainNtupleManager(
G4int index)
const
188 if ( index < 0 || index >=
G4int(fMainNtupleManagers.size()) ) {
189 Warn(
"main ntuple manager " + to_string(index) +
" does not exist.",
190 fkClass,
"GetMainNtupleManager");
194 return fMainNtupleManagers[index];
198unsigned int G4RootNtupleManager::GetBasketSize()
const
200 if ( ! fFileManager ) {
201 Warn(
"File manager must be defined first.", fkClass,
"GetBasketSize");
205 return fFileManager->GetBasketSize();
209unsigned int G4RootNtupleManager::GetBasketEntries()
const
211 if ( ! fFileManager ) {
212 Warn(
"File manager must be defined first.", fkClass,
"GetBasketEntries");
216 return fFileManager->GetBasketEntries();
std::tuple< std::shared_ptr< tools::wroot::file >, tools::wroot::directory *, tools::wroot::directory * > G4RootFile
const G4AnalysisManagerState & fState
G4RootNtupleManager()=delete
const tools::ntuple_booking & GetNtupleBooking() const
void SetNtuple(NT *ntuple)
void SetIsNtupleOwner(G4bool isNtupleOwner)
std::vector< tools::wroot::ntuple * > fNtupleVector
void SetNewCycle(G4bool value) override
void Warn(const G4String &message, const std::string_view inClass, const std::string_view inFunction)