Geant4 10.7.0
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
G4RootMainNtupleManager Class Reference

#include <G4RootMainNtupleManager.hh>

+ Inheritance diagram for G4RootMainNtupleManager:

Public Member Functions

 G4RootMainNtupleManager (G4RootNtupleManager *ntupleBuilder, G4NtupleBookingManager *bookingManager, G4bool rowWise, G4int fileNumber, 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 Member Functions

void CreateNtuple (RootNtupleDescription *ntupleDescription, G4bool warn=true)
 
G4bool Merge ()
 
G4bool Reset (G4bool deleteNtuple)
 
void SetFileManager (std::shared_ptr< G4RootFileManager > fileManager)
 
void SetRowWise (G4bool rowWise)
 
std::shared_ptr< G4RootFileGetNtupleFile (RootNtupleDescription *ntupleDescription) const
 
const std::vector< tools::wroot::ntuple * > & GetNtupleVector ()
 
unsigned int GetBasketEntries () 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 56 of file G4RootMainNtupleManager.hh.

Constructor & Destructor Documentation

◆ G4RootMainNtupleManager()

G4RootMainNtupleManager::G4RootMainNtupleManager ( G4RootNtupleManager ntupleBuilder,
G4NtupleBookingManager bookingManager,
G4bool  rowWise,
G4int  fileNumber,
const G4AnalysisManagerState state 
)
explicit

Definition at line 38 of file G4RootMainNtupleManager.cc.

44 : G4BaseAnalysisManager(state),
45 fNtupleBuilder(ntupleBuilder),
46 fBookingManager(bookingManager),
47 fFileManager(nullptr),
48 fRowWise(rowWise),
49 fFileNumber(fileNumber),
50 fNtupleVector(),
51 fNtupleDescriptionVector()
52{}

◆ ~G4RootMainNtupleManager()

G4RootMainNtupleManager::~G4RootMainNtupleManager ( )

Definition at line 55 of file G4RootMainNtupleManager.cc.

56{
57 // ntuple objects are deleted automatically when closing a file
58}

Member Function Documentation

◆ CreateNtuple()

void G4RootMainNtupleManager::CreateNtuple ( RootNtupleDescription ntupleDescription,
G4bool  warn = true 
)
protected

Definition at line 65 of file G4RootMainNtupleManager.cc.

67{
68// Create ntuple from booking if file was open
69
70 // Get/Create main ntuple file
71 auto ntupleFile = fFileManager->CreateNtupleFile(ntupleDescription, fFileNumber);
72 if ( ! ntupleFile ) {
73 if ( warn ) {
74 G4ExceptionDescription description;
75 description
76 << "Ntuple file must be defined first." << G4endl
77 << "Cannot create main ntuple.";
78 G4Exception("G4RootMainAnalysisManager::CreateNtuple",
79 "Analysis_W002", JustWarning, description);
80 }
81 return;
82 }
83
84 // Get ntuple booking
85 auto ntupleBooking = ntupleDescription->fNtupleBooking;
86
87#ifdef G4VERBOSE
88 if ( fState.GetVerboseL4() )
90 ->Message("create", "main ntuple", ntupleBooking.name());
91#endif
92
93 // Create ntuple
94 auto ntuple = new tools::wroot::ntuple(*std::get<2>(*ntupleFile), ntupleBooking, fRowWise);
95 // ntuple object is deleted automatically when closing a file
96 auto basketSize = fNtupleBuilder->GetBasketSize();
97 ntuple->set_basket_size(basketSize);
98
99 fNtupleVector.push_back(ntuple);
100 fNtupleDescriptionVector.push_back(ntupleDescription);
101
102#ifdef G4VERBOSE
103 if ( fState.GetVerboseL3() )
105 ->Message("create", "main ntuple", ntupleBooking.name());
106#endif
107}
@ JustWarning
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
Definition: G4Exception.cc:35
std::ostringstream G4ExceptionDescription
Definition: G4Exception.hh:40
#define G4endl
Definition: G4ios.hh:57
const G4AnalysisVerbose * GetVerboseL3() const
const G4AnalysisVerbose * GetVerboseL4() const
void Message(const G4String &action, const G4String &object, const G4String &objectName, G4bool success=true) const
const G4AnalysisManagerState & fState
tools::ntuple_booking fNtupleBooking

◆ GetBasketEntries()

unsigned int G4RootMainNtupleManager::GetBasketEntries ( ) const
inlineprotected

Definition at line 103 of file G4RootMainNtupleManager.hh.

104{ return fNtupleBuilder->GetBasketEntries(); }

◆ GetNtupleFile()

std::shared_ptr< G4RootFile > G4RootMainNtupleManager::GetNtupleFile ( RootNtupleDescription ntupleDescription) const
protected

Definition at line 145 of file G4RootMainNtupleManager.cc.

146{
147 auto perThread = false;
148 return fFileManager->GetNtupleFile(ntupleDescription, perThread, fFileNumber);
149}

◆ GetNtupleVector()

const std::vector< tools::wroot::ntuple * > & G4RootMainNtupleManager::GetNtupleVector ( )
inlineprotected

Definition at line 81 of file G4RootMainNtupleManager.hh.

82 { return fNtupleVector; }

◆ Merge()

G4bool G4RootMainNtupleManager::Merge ( )
protected

Definition at line 110 of file G4RootMainNtupleManager.cc.

111{
112 std::size_t counter = 0;
113
114 for ( auto ntuple : fNtupleVector ) {
115 ntuple->merge_number_of_entries();
116
117 // Notify ntuple description that file is not empty
118 if ( ntuple->entries() ) {
119 auto ntupleDescription = fNtupleDescriptionVector.at(counter);
120 ntupleDescription->fHasFill = true;
121 }
122 ++counter;
123 }
124
125 return true;
126}

◆ Reset()

G4bool G4RootMainNtupleManager::Reset ( G4bool  deleteNtuple)
protected

Definition at line 129 of file G4RootMainNtupleManager.cc.

130{
131 for ( auto ntuple : fNtupleVector ) {
132 if ( deleteNtuple ) {
133 delete ntuple;
134 }
135 }
136
137 fNtupleVector.clear();
138 fNtupleDescriptionVector.clear();
139
140 return true;
141}

◆ SetFileManager()

void G4RootMainNtupleManager::SetFileManager ( std::shared_ptr< G4RootFileManager fileManager)
inlineprotected

Definition at line 96 of file G4RootMainNtupleManager.hh.

98{ fFileManager = fileManager; }

◆ SetRowWise()

void G4RootMainNtupleManager::SetRowWise ( G4bool  rowWise)
inlineprotected

Definition at line 100 of file G4RootMainNtupleManager.hh.

101{ fRowWise = rowWise; }

Friends And Related Function Documentation

◆ G4RootNtupleManager

friend class G4RootNtupleManager
friend

Definition at line 59 of file G4RootMainNtupleManager.hh.

◆ G4RootPNtupleManager

friend class G4RootPNtupleManager
friend

Definition at line 58 of file G4RootMainNtupleManager.hh.


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