Geant4-11
Public Member Functions | Protected Member Functions | Protected Attributes | Private Attributes | Static Private Attributes | Friends
G4RootMainNtupleManager Class Reference

#include <G4RootMainNtupleManager.hh>

Inheritance diagram for G4RootMainNtupleManager:
G4BaseAnalysisManager

Public Member Functions

 G4RootMainNtupleManager ()=delete
 
 G4RootMainNtupleManager (G4RootNtupleManager *ntupleBuilder, std::shared_ptr< G4NtupleBookingManager > bookingManager, G4bool rowWise, G4int fileNumber, const G4AnalysisManagerState &state)
 
G4int GetFirstId () const
 
G4bool SetFirstId (G4int firstId)
 
void SetLockFirstId (G4bool lockFirstId)
 
virtual ~G4RootMainNtupleManager ()=default
 

Protected Member Functions

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

Protected Attributes

G4int fFirstId { 0 }
 
G4bool fLockFirstId { false }
 
const G4AnalysisManagerStatefState
 

Private Attributes

std::shared_ptr< G4NtupleBookingManagerfBookingManager { nullptr }
 
std::shared_ptr< G4RootFileManagerfFileManager { nullptr }
 
G4int fFileNumber
 
G4RootNtupleManagerfNtupleBuilder { nullptr }
 
std::vector< RootNtupleDescription * > fNtupleDescriptionVector
 
std::vector< tools::wroot::ntuple * > fNtupleVector
 
G4bool fRowWise
 

Static Private Attributes

static constexpr std::string_view fkClass { "G4RootMainNtupleManager" }
 

Friends

class G4RootNtupleManager
 
class G4RootPNtupleManager
 

Detailed Description

Definition at line 57 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
std::shared_ptr< G4NtupleBookingManager > fBookingManager
G4RootNtupleManager * fNtupleBuilder

◆ G4RootMainNtupleManager() [2/2]

G4RootMainNtupleManager::G4RootMainNtupleManager ( )
delete

◆ ~G4RootMainNtupleManager()

virtual G4RootMainNtupleManager::~G4RootMainNtupleManager ( )
virtualdefault

Member Function Documentation

◆ ClearData()

void G4RootMainNtupleManager::ClearData ( )
protected

Definition at line 122 of file G4RootMainNtupleManager.cc.

123{
124 // Reset function clears all data
125 Reset();
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

References G4Analysis::kVL2, G4BaseAnalysisManager::Message(), and Reset().

◆ 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 ) {
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 auto ntupleBooking = ntupleDescription->fNtupleBooking;
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(ntupleDescription);
87
88 Message(kVL3, "create", "main ntuple", ntupleBooking.name());
89}
std::vector< tools::wroot::ntuple * > fNtupleVector
static constexpr std::string_view fkClass
std::shared_ptr< G4RootFileManager > fFileManager
std::vector< RootNtupleDescription * > fNtupleDescriptionVector
unsigned int GetBasketSize() const
constexpr G4int kVL3
constexpr G4int kVL4
void Warn(const G4String &message, const std::string_view inClass, const std::string_view inFunction)
tools::ntuple_booking fNtupleBooking

References fFileManager, fFileNumber, fkClass, G4TNtupleDescription< NT, FT >::fNtupleBooking, fNtupleBuilder, fNtupleDescriptionVector, fNtupleVector, fRowWise, G4RootNtupleManager::GetBasketSize(), G4Analysis::kVL3, G4Analysis::kVL4, G4BaseAnalysisManager::Message(), and G4Analysis::Warn().

◆ GetBasketEntries()

unsigned int G4RootMainNtupleManager::GetBasketEntries ( ) const
inlineprotected

Definition at line 109 of file G4RootMainNtupleManager.hh.

110{ return fNtupleBuilder->GetBasketEntries(); }
unsigned int GetBasketEntries() const

References fNtupleBuilder, and G4RootNtupleManager::GetBasketEntries().

◆ GetFirstId()

G4int G4BaseAnalysisManager::GetFirstId ( ) const
inlineinherited

Definition at line 94 of file G4BaseAnalysisManager.hh.

94 {
95 return fFirstId;
96}

References G4BaseAnalysisManager::fFirstId.

◆ 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}

References fFileManager, and fFileNumber.

◆ GetNtupleVector()

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

Definition at line 84 of file G4RootMainNtupleManager.hh.

85 { return fNtupleVector; }

References fNtupleVector.

◆ IsVerbose()

G4bool G4BaseAnalysisManager::IsVerbose ( G4int  verboseLevel) const
inlineprotectedinherited

Definition at line 80 of file G4BaseAnalysisManager.hh.

81{ return fState.IsVerbose(verboseLevel); }
G4bool IsVerbose(G4int verboseLevel) const
const G4AnalysisManagerState & fState

References G4BaseAnalysisManager::fState, and G4AnalysisManagerState::IsVerbose().

Referenced by G4RootPNtupleManager::AddNtupleRow(), and G4RootPNtupleManager::Merge().

◆ 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() ) {
101 auto ntupleDescription = fNtupleDescriptionVector.at(counter);
102 ntupleDescription->fHasFill = true;
103 }
104 ++counter;
105 }
106
107 return true;
108}

References fNtupleDescriptionVector, and fNtupleVector.

◆ Message()

void G4BaseAnalysisManager::Message ( G4int  level,
const G4String action,
const G4String objectType,
const G4String objectName = "",
G4bool  success = true 
) const
inlineprotectedinherited

◆ Reset()

G4bool G4RootMainNtupleManager::Reset ( )
protected

Definition at line 111 of file G4RootMainNtupleManager.cc.

112{
113 // ntuple object is deleted automatically when closing a file
114
115 fNtupleVector.clear();
117
118 return true;
119}

References fNtupleDescriptionVector, and fNtupleVector.

Referenced by ClearData().

◆ SetFileManager()

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

Definition at line 102 of file G4RootMainNtupleManager.hh.

104{ fFileManager = fileManager; }

References fFileManager.

◆ SetFirstId()

G4bool G4BaseAnalysisManager::SetFirstId ( G4int  firstId)
inherited

Definition at line 46 of file G4BaseAnalysisManager.cc.

47{
48 if ( fLockFirstId ) {
49 Warn("Cannot set FirstId as its value was already used.",
50 fkClass, "SetFirstId");
51
52 return false;
53 }
54
55 fFirstId = firstId;
56 return true;
57}
static constexpr std::string_view fkClass

References G4BaseAnalysisManager::fFirstId, G4BaseAnalysisManager::fkClass, G4BaseAnalysisManager::fLockFirstId, and G4Analysis::Warn().

◆ SetLockFirstId()

void G4BaseAnalysisManager::SetLockFirstId ( G4bool  lockFirstId)
inlineinherited

Definition at line 90 of file G4BaseAnalysisManager.hh.

90 {
91 fLockFirstId = lockFirstId;
92}

References G4BaseAnalysisManager::fLockFirstId.

Referenced by G4HnManager::ClearData().

◆ SetRowWise()

void G4RootMainNtupleManager::SetRowWise ( G4bool  rowWise)
inlineprotected

Definition at line 106 of file G4RootMainNtupleManager.hh.

107{ fRowWise = rowWise; }

References fRowWise.

Friends And Related Function Documentation

◆ G4RootNtupleManager

friend class G4RootNtupleManager
friend

Definition at line 60 of file G4RootMainNtupleManager.hh.

◆ G4RootPNtupleManager

friend class G4RootPNtupleManager
friend

Definition at line 59 of file G4RootMainNtupleManager.hh.

Field Documentation

◆ fBookingManager

std::shared_ptr<G4NtupleBookingManager> G4RootMainNtupleManager::fBookingManager { nullptr }
private

Definition at line 94 of file G4RootMainNtupleManager.hh.

◆ fFileManager

std::shared_ptr<G4RootFileManager> G4RootMainNtupleManager::fFileManager { nullptr }
private

Definition at line 95 of file G4RootMainNtupleManager.hh.

Referenced by CreateNtuple(), GetNtupleFile(), and SetFileManager().

◆ fFileNumber

G4int G4RootMainNtupleManager::fFileNumber
private

Definition at line 97 of file G4RootMainNtupleManager.hh.

Referenced by CreateNtuple(), and GetNtupleFile().

◆ fFirstId

G4int G4BaseAnalysisManager::fFirstId { 0 }
protectedinherited

◆ fkClass

constexpr std::string_view G4RootMainNtupleManager::fkClass { "G4RootMainNtupleManager" }
staticconstexprprivate

Definition at line 90 of file G4RootMainNtupleManager.hh.

Referenced by CreateNtuple().

◆ fLockFirstId

G4bool G4BaseAnalysisManager::fLockFirstId { false }
protectedinherited

◆ fNtupleBuilder

G4RootNtupleManager* G4RootMainNtupleManager::fNtupleBuilder { nullptr }
private

Definition at line 93 of file G4RootMainNtupleManager.hh.

Referenced by CreateNtuple(), and GetBasketEntries().

◆ fNtupleDescriptionVector

std::vector<RootNtupleDescription*> G4RootMainNtupleManager::fNtupleDescriptionVector
private

Definition at line 99 of file G4RootMainNtupleManager.hh.

Referenced by CreateNtuple(), Merge(), and Reset().

◆ fNtupleVector

std::vector<tools::wroot::ntuple*> G4RootMainNtupleManager::fNtupleVector
private

Definition at line 98 of file G4RootMainNtupleManager.hh.

Referenced by CreateNtuple(), GetNtupleVector(), Merge(), and Reset().

◆ fRowWise

G4bool G4RootMainNtupleManager::fRowWise
private

Definition at line 96 of file G4RootMainNtupleManager.hh.

Referenced by CreateNtuple(), and SetRowWise().

◆ fState

const G4AnalysisManagerState& G4BaseAnalysisManager::fState
protectedinherited

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