36 #include "tools/wroot/file"
38 using namespace G4Analysis;
42 G4int nofMainManagers)
45 fFileManager(nullptr),
46 fNtupleDirectory(nullptr),
49 for (
G4int i=0; i<nofMainManagers; ++i) {
50 fMainNtupleManagers.push_back(
64 void G4RootNtupleManager::SetCreateMode()
71 ->
Message(
"set",
"ntuple create mode",
"");
76 if ( fMainNtupleManagers.size() ) {
77 if ( fFileManager->GetNtupleFile(0) ) {
79 createMode =
"G4NtupleCreateMode::kMainAfterOpen";
82 createMode =
"G4NtupleCreateMode::kMainBeforeOpen";
86 if ( fNtupleDirectory ) {
88 createMode =
"G4NtupleCreateMode::kNoMergeAfterOpen";
91 createMode =
"G4NtupleCreateMode::kNoMergeBeforeOpen";
99 ->
Message(
"set",
"ntuple create mode", createMode);
104 void G4RootNtupleManager::CreateTNtuple(
113 =
new tools::wroot::ntuple(*fNtupleDirectory, name, title);
121 void G4RootNtupleManager::CreateTNtupleFromBooking(
126 =
new tools::wroot::ntuple(
129 auto basketSize = fFileManager->GetBasketSize();
130 ntupleDescription->
fNtuple->set_basket_size(basketSize);
139 for (
auto manager : fMainNtupleManagers ) {
140 if ( ! manager->GetNtupleVector().size() ) {
142 manager->SetNtupleFile(fFileManager->GetNtupleFile(counter));
143 manager->SetNtupleDirectory(fFileManager->GetMainNtupleDirectory(counter++));
144 manager->CreateNtuplesFromBooking();
151 void G4RootNtupleManager::FinishTNtuple(
158 for (
auto manager : fMainNtupleManagers ) {
160 manager->SetNtupleFile(fFileManager->GetNtupleFile(counter));
161 manager->SetNtupleDirectory(fFileManager->GetMainNtupleDirectory(counter++));
178 auto finalResult =
true;
179 for (
auto manager : fMainNtupleManagers ) {
180 auto result = manager->Reset(
false);
181 finalResult =
result && finalResult;
188 G4bool G4RootNtupleManager::Merge()
190 auto finalResult =
true;
192 for (
auto manager : fMainNtupleManagers ) {
193 auto result = manager->Merge();
194 finalResult =
result && finalResult;
203 if ( index < 0 || index >=
G4int(fMainNtupleManagers.size()) ) {
204 G4String inFunction =
"G4RootNtupleManager::::GetMainNtupleManager";
206 description <<
" " <<
"main ntuple manager " << index <<
" does not exist.";
211 return fMainNtupleManagers[index];
215 unsigned int G4RootNtupleManager::GetBasketSize()
const
217 if ( ! fFileManager ) {
218 G4String inFunction =
"G4RootNtupleManager::::GetBasketSize";
220 description <<
" " <<
"File manager must be defined first.";
225 return fFileManager->GetBasketSize();
G4double G4ParticleHPJENDLHEData::G4double result
void Message(const G4String &action, const G4String &object, const G4String &objectName, G4bool success=true) const
std::ostringstream G4ExceptionDescription
G4RootNtupleManager(const G4AnalysisManagerState &state, G4int nofMainManagers=0)
std::vector< G4TNtupleDescription< tools::wroot::ntuple > * > fNtupleDescriptionVector
const G4AnalysisVerbose * GetVerboseL2() const
G4bool Reset(G4bool deleteNtuple)
virtual ~G4RootNtupleManager()
const G4AnalysisVerbose * GetVerboseL4() const
friend class G4RootMainNtupleManager
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
std::vector< tools::wroot::ntuple * > fNtupleVector
tools::ntuple_booking fNtupleBooking
const G4AnalysisManagerState & fState