Geant4 11.1.1
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, std::shared_ptr< G4NtupleBookingManager > bookingManager, G4bool rowWise, G4int fileNumber, const G4AnalysisManagerState &state)
 
 G4RootMainNtupleManager ()=delete
 
 ~G4RootMainNtupleManager () override=default
 
void CreateNtuplesFromBooking ()
 
- Public Member Functions inherited from G4BaseAnalysisManager
 G4BaseAnalysisManager (const G4AnalysisManagerState &state)
 
 G4BaseAnalysisManager ()=delete
 
virtual ~G4BaseAnalysisManager ()=default
 
G4bool SetFirstId (G4int firstId)
 
void SetLockFirstId (G4bool lockFirstId)
 
G4int GetFirstId () const
 
G4int GetCycle () const
 

Protected Member Functions

void CreateNtuple (RootNtupleDescription *ntupleDescription, G4bool warn=true)
 
G4bool Merge ()
 
G4bool Reset ()
 
void ClearData ()
 
void SetFileManager (std::shared_ptr< G4RootFileManager > fileManager)
 
void SetRowWise (G4bool rowWise)
 
std::shared_ptr< G4RootFileGetNtupleFile (RootNtupleDescription *ntupleDescription) const
 
void SetNewCycle (G4bool value)
 
G4bool GetNewCycle () const
 
const std::vector< tools::wroot::ntuple * > & GetNtupleVector ()
 
unsigned int GetBasketEntries () const
 
- Protected Member Functions inherited from G4BaseAnalysisManager
G4bool IsVerbose (G4int verboseLevel) const
 
void Message (G4int level, const G4String &action, const G4String &objectType, const G4String &objectName="", G4bool success=true) const
 

Friends

class G4RootPNtupleManager
 
class G4RootNtupleManager
 

Additional Inherited Members

- Protected Attributes inherited from G4BaseAnalysisManager
const G4AnalysisManagerStatefState
 
G4int fFirstId { 0 }
 
G4bool fLockFirstId { false }
 

Detailed Description

Definition at line 59 of file G4RootMainNtupleManager.hh.

Constructor & Destructor Documentation

◆ G4RootMainNtupleManager() [1/2]

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

Definition at line 40 of file G4RootMainNtupleManager.cc.

46 : G4BaseAnalysisManager(state),
47 fNtupleBuilder(ntupleBuilder),
48 fBookingManager(std::move(bookingManager)),
49 fRowWise(rowWise),
50 fFileNumber(fileNumber)
51{}
G4BaseAnalysisManager()=delete

◆ G4RootMainNtupleManager() [2/2]

G4RootMainNtupleManager::G4RootMainNtupleManager ( )
delete

◆ ~G4RootMainNtupleManager()

G4RootMainNtupleManager::~G4RootMainNtupleManager ( )
overridedefault

Member Function Documentation

◆ ClearData()

void G4RootMainNtupleManager::ClearData ( )
protected

Definition at line 122 of file G4RootMainNtupleManager.cc.

123{
124 fNtupleDescriptionVector.clear();
125 fNtupleVector.clear();
126
127 Message(G4Analysis::kVL2, "clear", "main ntuples");
128}
void Message(G4int level, const G4String &action, const G4String &objectType, const G4String &objectName="", G4bool success=true) const
constexpr G4int kVL2

◆ CreateNtuple()

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

Definition at line 58 of file G4RootMainNtupleManager.cc.

60{
61// Create ntuple from booking if file was open
62
63 // Get/Create main ntuple file
64 auto ntupleFile = fFileManager->CreateNtupleFile(ntupleDescription, fFileNumber);
65 if ( ntupleFile == nullptr ) {
66 if ( warn ) {
67 Warn("Ntuple file must be defined first.\n"
68 "Cannot create main ntuple.",
69 fkClass, "CreateNtuple");
70 }
71 return;
72 }
73
74 // Get ntuple booking
75 const auto& ntupleBooking = ntupleDescription->GetNtupleBooking();
76
77 Message(kVL4, "create", "main ntuple", ntupleBooking.name());
78
79 // Create ntuple
80 auto ntuple = new tools::wroot::ntuple(*std::get<2>(*ntupleFile), ntupleBooking, fRowWise);
81 // ntuple object is deleted automatically when closing a file
82 auto basketSize = fNtupleBuilder->GetBasketSize();
83 ntuple->set_basket_size(basketSize);
84
85 fNtupleVector.push_back(ntuple);
86 fNtupleDescriptionVector.push_back(std::make_pair(ntupleDescription, ntupleFile));
87
88 Message(kVL3, "create", "main ntuple", ntupleBooking.name());
89}
const tools::ntuple_booking & GetNtupleBooking() const
constexpr G4int kVL3
constexpr G4int kVL4
void Warn(const G4String &message, const std::string_view inClass, const std::string_view inFunction)

◆ CreateNtuplesFromBooking()

void G4RootMainNtupleManager::CreateNtuplesFromBooking ( )

Definition at line 143 of file G4RootMainNtupleManager.cc.

144{
145// Create ntuples from booking.
146// This function is triggered from workers at new cycle.
147
148 for (auto [ntupleDescription, ntupleFile] : fNtupleDescriptionVector) {
149
150 // Get ntuple booking
151 const auto& ntupleBooking = ntupleDescription->GetNtupleBooking();
152
153 Message(kVL4, "create", "main ntuple", ntupleBooking.name());
154
155 // Create ntuple
156 auto ntuple = new tools::wroot::ntuple(*std::get<2>(*ntupleFile), ntupleBooking, fRowWise);
157 // ntuple object is deleted automatically when closing a file
158 auto basketSize = fNtupleBuilder->GetBasketSize();
159 ntuple->set_basket_size(basketSize);
160
161 fNtupleVector.push_back(ntuple);
162
163 Message(kVL3, "create", "main ntuple", ntupleBooking.name());
164 }
165
166 SetNewCycle(false);
167}

◆ GetBasketEntries()

unsigned int G4RootMainNtupleManager::GetBasketEntries ( ) const
inlineprotected

Definition at line 120 of file G4RootMainNtupleManager.hh.

121{ return fNtupleBuilder->GetBasketEntries(); }

◆ GetNewCycle()

G4bool G4RootMainNtupleManager::GetNewCycle ( ) const
inlineprotected

Definition at line 126 of file G4RootMainNtupleManager.hh.

127{ return fNewCycle; }

◆ GetNtupleFile()

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

Definition at line 132 of file G4RootMainNtupleManager.cc.

133{
134 auto perThread = false;
135 return fFileManager->GetNtupleFile(ntupleDescription, perThread, fFileNumber);
136}

◆ GetNtupleVector()

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

Definition at line 92 of file G4RootMainNtupleManager.hh.

93 { return fNtupleVector; }

◆ Merge()

G4bool G4RootMainNtupleManager::Merge ( )
protected

Definition at line 92 of file G4RootMainNtupleManager.cc.

93{
94 std::size_t counter = 0;
95
96 for ( auto ntuple : fNtupleVector ) {
97 ntuple->merge_number_of_entries();
98
99 // Notify ntuple description that file is not empty
100 if (ntuple->entries() != 0u) {
101 auto ntupleDescription = fNtupleDescriptionVector.at(counter).first;
102 ntupleDescription->SetHasFill(true);
103 }
104 ++counter;
105 }
106
107 return true;
108}

◆ Reset()

G4bool G4RootMainNtupleManager::Reset ( )
protected

Definition at line 111 of file G4RootMainNtupleManager.cc.

112{
113 // The ntuples will be recreated with new cycle or new open file.
114 // Ntuple objects are deleted automatically when closing a file
115
116 fNtupleVector.clear();
117
118 return true;
119}

◆ SetFileManager()

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

Definition at line 111 of file G4RootMainNtupleManager.hh.

113{
114 fFileManager = std::move(fileManager);
115}

◆ SetNewCycle()

void G4RootMainNtupleManager::SetNewCycle ( G4bool  value)
inlineprotected

Definition at line 123 of file G4RootMainNtupleManager.hh.

124{ fNewCycle = value; }

Referenced by CreateNtuplesFromBooking().

◆ SetRowWise()

void G4RootMainNtupleManager::SetRowWise ( G4bool  rowWise)
inlineprotected

Definition at line 117 of file G4RootMainNtupleManager.hh.

118{ fRowWise = rowWise; }

Friends And Related Function Documentation

◆ G4RootNtupleManager

friend class G4RootNtupleManager
friend

Definition at line 62 of file G4RootMainNtupleManager.hh.

◆ G4RootPNtupleManager

friend class G4RootPNtupleManager
friend

Definition at line 61 of file G4RootMainNtupleManager.hh.


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