Geant4  10.03.p03
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
G4RootMainNtupleManager Class Reference

#include <G4RootMainNtupleManager.hh>

Inheritance diagram for G4RootMainNtupleManager:
Collaboration diagram for G4RootMainNtupleManager:

Public Member Functions

 G4RootMainNtupleManager (G4RootNtupleManager *ntupleBuilder, const G4AnalysisManagerState &state)
 
 ~G4RootMainNtupleManager ()
 
- Public Member Functions inherited from G4BaseAnalysisManager
 G4BaseAnalysisManager (const G4AnalysisManagerState &state)
 
virtual ~G4BaseAnalysisManager ()
 
G4bool SetFirstId (G4int firstId)
 
void SetLockFirstId (G4bool lockFirstId)
 
G4int GetFirstId () const
 

Protected Types

using NtupleType = tools::wroot::ntuple
 
using NtupleDescriptionType = G4TNtupleDescription< NtupleType >
 

Protected Member Functions

void CreateNtuple (const tools::ntuple_booking &ntupleBooking, G4bool warn=true)
 
void CreateNtuplesFromBooking ()
 
G4bool Merge ()
 
G4bool Reset (G4bool deleteNtuple)
 
void SetNtupleFile (std::shared_ptr< tools::wroot::file > rfile)
 
void SetNtupleDirectory (tools::wroot::directory *directory)
 
std::shared_ptr
< tools::wroot::file > 
GetNtupleFile () const
 
tools::wroot::directory * GetNtupleDirectory () const
 
const std::vector
< NtupleDescriptionType * > & 
GetNtupleDescriptionVector ()
 
const std::vector
< tools::wroot::ntuple * > & 
GetNtupleVector ()
 
unsigned int GetBasketSize () const
 

Friends

class G4RootPNtupleManager
 
class G4RootNtupleManager
 

Additional Inherited Members

- Protected Attributes inherited from G4BaseAnalysisManager
const G4AnalysisManagerStatefState
 
G4int fFirstId
 
G4bool fLockFirstId
 

Detailed Description

Definition at line 51 of file G4RootMainNtupleManager.hh.

Member Typedef Documentation

using G4RootMainNtupleManager::NtupleType = tools::wroot::ntuple
protected

Definition at line 63 of file G4RootMainNtupleManager.hh.

Constructor & Destructor Documentation

G4RootMainNtupleManager::G4RootMainNtupleManager ( G4RootNtupleManager ntupleBuilder,
const G4AnalysisManagerState state 
)
explicit

Definition at line 38 of file G4RootMainNtupleManager.cc.

40  : G4BaseAnalysisManager(state),
41  fNtupleBuilder(ntupleBuilder),
42  fNtupleDirectory(nullptr),
43  fNtupleVector()
44 {}
G4BaseAnalysisManager(const G4AnalysisManagerState &state)
G4RootMainNtupleManager::~G4RootMainNtupleManager ( )

Definition at line 47 of file G4RootMainNtupleManager.cc.

48 {
49  // ntuple objects are deleted automatically when closing a file
50 }

Member Function Documentation

void G4RootMainNtupleManager::CreateNtuple ( const tools::ntuple_booking &  ntupleBooking,
G4bool  warn = true 
)
protected

Definition at line 61 of file G4RootMainNtupleManager.cc.

63 {
64 // Create ntuple from booking if file was open
65 
66  // Check that file is set
67  if ( ! fNtupleDirectory ) {
68  if ( warn ) {
69  G4ExceptionDescription description;
70  description
71  << " " << "Ntuple file must be defined first."
72  << G4endl
73  << " " << "Cannot create main ntuples from builder.";
74  G4Exception("G4RootAnalysisManager::CreateNtuplesFromBooking",
75  "Analysis_W002", JustWarning, description);
76  }
77  return;
78  }
79 
80 #ifdef G4VERBOSE
81  if ( fState.GetVerboseL4() )
83  ->Message("create", "main ntuple", ntupleBooking.name());
84 #endif
85 
86  // Create ntuple
87  auto ntuple = new tools::wroot::ntuple(*fNtupleDirectory, ntupleBooking);
88  // ntuple object is deleted automatically when closing a file
89  auto basketSize = fNtupleBuilder->GetBasketSize();
90  ntuple->set_basket_size(basketSize);
91 
92  fNtupleVector.push_back(ntuple);
93 
94 #ifdef G4VERBOSE
95  if ( fState.GetVerboseL3() )
97  ->Message("create", "main ntuple", ntupleBooking.name());
98 #endif
99 }
void Message(const G4String &action, const G4String &object, const G4String &objectName, G4bool success=true) const
std::ostringstream G4ExceptionDescription
Definition: globals.hh:76
const G4AnalysisVerbose * GetVerboseL3() const
const G4AnalysisVerbose * GetVerboseL4() const
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41
#define G4endl
Definition: G4ios.hh:61
const G4AnalysisManagerState & fState

Here is the call graph for this function:

Here is the caller graph for this function:

void G4RootMainNtupleManager::CreateNtuplesFromBooking ( )
protected

Definition at line 102 of file G4RootMainNtupleManager.cc.

103 {
104 // Create ntuple from booking in master
105 
106  // Check that file is set
107  if ( ! fNtupleDirectory ) {
108  G4ExceptionDescription description;
109  description
110  << " " << "Ntuple file must be defined first."
111  << G4endl
112  << " " << "Cannot create main ntuples from builder.";
113  G4Exception("G4RootAnalysisManager::CreateNtuplesFromBooking",
114  "Analysis_W002", JustWarning, description);
115  return;
116  }
117 
118  auto& ntupleDescriptionVector
119  = fNtupleBuilder->GetNtupleDescriptionVector();
120 
121  for ( auto ntupleDescription : ntupleDescriptionVector ) {
122  CreateNtuple(ntupleDescription->fNtupleBooking);
123  }
124 }
std::ostringstream G4ExceptionDescription
Definition: globals.hh:76
void CreateNtuple(const tools::ntuple_booking &ntupleBooking, G4bool warn=true)
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41
#define G4endl
Definition: G4ios.hh:61

Here is the call graph for this function:

unsigned int G4RootMainNtupleManager::GetBasketSize ( ) const
protected
const std::vector<NtupleDescriptionType*>& G4RootMainNtupleManager::GetNtupleDescriptionVector ( )
inlineprotected

Definition at line 79 of file G4RootMainNtupleManager.hh.

80  { return fNtupleBuilder->GetNtupleDescriptionVector(); }
tools::wroot::directory * G4RootMainNtupleManager::GetNtupleDirectory ( ) const
inlineprotected

Definition at line 102 of file G4RootMainNtupleManager.hh.

103 { return fNtupleDirectory; }
std::shared_ptr< tools::wroot::file > G4RootMainNtupleManager::GetNtupleFile ( ) const
inlineprotected

Definition at line 99 of file G4RootMainNtupleManager.hh.

100 { return fNtupleFile; }
const std::vector<tools::wroot::ntuple*>& G4RootMainNtupleManager::GetNtupleVector ( )
inlineprotected

Definition at line 81 of file G4RootMainNtupleManager.hh.

82  { return fNtupleVector; }
G4bool G4RootMainNtupleManager::Merge ( )
protected

Definition at line 127 of file G4RootMainNtupleManager.cc.

128 {
129  for ( auto ntuple : fNtupleVector ) {
130  ntuple->merge_number_of_entries();
131  }
132 
133  return true;
134 }
G4bool G4RootMainNtupleManager::Reset ( G4bool  deleteNtuple)
protected

Definition at line 137 of file G4RootMainNtupleManager.cc.

138 {
139  for ( auto ntuple : fNtupleVector ) {
140  if ( deleteNtuple ) {
141  delete ntuple;
142  }
143  }
144 
145  fNtupleVector.clear();
146 
147  return true;
148 }
void G4RootMainNtupleManager::SetNtupleDirectory ( tools::wroot::directory *  directory)
inlineprotected

Definition at line 96 of file G4RootMainNtupleManager.hh.

97 { fNtupleDirectory = directory; }
void G4RootMainNtupleManager::SetNtupleFile ( std::shared_ptr< tools::wroot::file >  rfile)
inlineprotected

Definition at line 93 of file G4RootMainNtupleManager.hh.

94 { fNtupleFile = rfile; }

Friends And Related Function Documentation

friend class G4RootNtupleManager
friend

Definition at line 54 of file G4RootMainNtupleManager.hh.

friend class G4RootPNtupleManager
friend

Definition at line 53 of file G4RootMainNtupleManager.hh.


The documentation for this class was generated from the following files: