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);
97 for (
const auto& manager : fMainNtupleManagers ) {
99 manager->CreateNtuple(ntupleDescription);
105void G4RootNtupleManager::FinishTNtuple(
112G4bool G4RootNtupleManager::Reset()
119 for (
const auto& manager : fMainNtupleManagers ) {
120 result &= manager->Reset();
127void G4RootNtupleManager::Clear()
132 for (
const auto& manager : fMainNtupleManagers ) {
133 manager->ClearData();
142 for (
const auto& manager : fMainNtupleManagers ) {
143 result &= manager->Delete(
id);
150G4bool G4RootNtupleManager::Merge()
154 for (
const auto& manager : fMainNtupleManagers ) {
155 result &= manager->Merge();
162void G4RootNtupleManager::SetFileManager(
163 const std::shared_ptr<G4RootFileManager>& fileManager)
165 fFileManager = fileManager;
167 for (
const auto& manager : fMainNtupleManagers ) {
168 manager->SetFileManager(fileManager);
173void G4RootNtupleManager::SetNtupleRowWise(
G4bool rowWise,
G4bool rowMode)
180 for (
auto& mainNtupleManager : fMainNtupleManagers ) {
181 mainNtupleManager->SetRowWise(rowWise);
186void G4RootNtupleManager::SetNewCycle(
G4bool value)
190 for (
const auto& manager : fMainNtupleManagers ) {
191 manager->SetNewCycle(value);
196std::shared_ptr<G4RootMainNtupleManager>
197G4RootNtupleManager::GetMainNtupleManager(
G4int index)
const
199 if ( index < 0 || index >=
G4int(fMainNtupleManagers.size()) ) {
200 Warn(
"main ntuple manager " + to_string(index) +
" does not exist.",
201 fkClass,
"GetMainNtupleManager");
205 return fMainNtupleManagers[index];
209unsigned int G4RootNtupleManager::GetBasketSize()
const
211 if ( ! fFileManager ) {
212 Warn(
"File manager must be defined first.", fkClass,
"GetBasketSize");
216 return fFileManager->GetBasketSize();
220unsigned int G4RootNtupleManager::GetBasketEntries()
const
222 if ( ! fFileManager ) {
223 Warn(
"File manager must be defined first.", fkClass,
"GetBasketEntries");
227 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)
void SetNewCycle(G4bool value) override
void Warn(const G4String &message, const std::string_view inClass, const std::string_view inFunction)