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

#include <G4CsvRNtupleManager.hh>

Inheritance diagram for G4CsvRNtupleManager:
G4TRNtupleManager< tools::rcsv::ntuple > G4BaseRNtupleManager G4VRNtupleManager G4BaseAnalysisManager

Public Member Functions

 G4CsvRNtupleManager ()=delete
 
 G4CsvRNtupleManager (const G4AnalysisManagerState &state)
 
G4int GetFirstId () const
 
G4bool SetFirstId (G4int firstId)
 
void SetLockFirstId (G4bool lockFirstId)
 
virtual ~G4CsvRNtupleManager ()=default
 

Protected Member Functions

virtual G4int GetNofNtuples () const final
 
tools::rcsv::ntuple * GetNtuple () const
 
tools::rcsv::ntuple * GetNtuple (G4int ntupleId) const
 
G4TRNtupleDescription< tools::rcsv::ntuple > * GetNtupleDescriptionInFunction (G4int id, std::string_view function, G4bool warn=true) const
 
virtual G4bool GetNtupleRow () final
 
virtual G4bool GetNtupleRow (G4int ntupleId) final
 
virtual G4bool GetNtupleRow (G4int ntupleId)=0
 
G4bool IsEmpty () const
 
G4bool IsVerbose (G4int verboseLevel) const
 
void Message (G4int level, const G4String &action, const G4String &objectType, const G4String &objectName="", G4bool success=true) const
 
G4bool Reset ()
 
G4int SetNtuple (G4TRNtupleDescription< tools::rcsv::ntuple > *rntupleDescription)
 
virtual G4bool SetNtupleDColumn (const G4String &columnName, G4double &value) final
 
virtual G4bool SetNtupleDColumn (const G4String &columnName, std::vector< G4double > &vector) final
 
virtual G4bool SetNtupleDColumn (G4int ntupleId, const G4String &columnName, G4double &value) final
 
virtual G4bool SetNtupleDColumn (G4int ntupleId, const G4String &columnName, G4double &value)=0
 
virtual G4bool SetNtupleDColumn (G4int ntupleId, const G4String &columnName, std::vector< G4double > &vector) override
 
virtual G4bool SetNtupleDColumn (G4int ntupleId, const G4String &columnName, std::vector< G4double > &vector)=0
 
virtual G4bool SetNtupleFColumn (const G4String &columnName, G4float &value) final
 
virtual G4bool SetNtupleFColumn (const G4String &columnName, std::vector< G4float > &vector) final
 
virtual G4bool SetNtupleFColumn (G4int ntupleId, const G4String &columnName, G4float &value) final
 
virtual G4bool SetNtupleFColumn (G4int ntupleId, const G4String &columnName, G4float &value)=0
 
virtual G4bool SetNtupleFColumn (G4int ntupleId, const G4String &columnName, std::vector< G4float > &vector) override
 
virtual G4bool SetNtupleFColumn (G4int ntupleId, const G4String &columnName, std::vector< G4float > &vector)=0
 
virtual G4bool SetNtupleIColumn (const G4String &columnName, G4int &value) final
 
virtual G4bool SetNtupleIColumn (const G4String &columnName, std::vector< G4int > &vector) final
 
virtual G4bool SetNtupleIColumn (G4int ntupleId, const G4String &columnName, G4int &value) final
 
virtual G4bool SetNtupleIColumn (G4int ntupleId, const G4String &columnName, G4int &value)=0
 
virtual G4bool SetNtupleIColumn (G4int ntupleId, const G4String &columnName, std::vector< G4int > &vector) override
 
virtual G4bool SetNtupleIColumn (G4int ntupleId, const G4String &columnName, std::vector< G4int > &vector)=0
 
virtual G4bool SetNtupleSColumn (const G4String &columnName, G4String &value) final
 
virtual G4bool SetNtupleSColumn (const G4String &columnName, std::vector< std::string > &vector) final
 
virtual G4bool SetNtupleSColumn (G4int ntupleId, const G4String &columnName, G4String &value) final
 
virtual G4bool SetNtupleSColumn (G4int ntupleId, const G4String &columnName, G4String &value)=0
 
virtual G4bool SetNtupleSColumn (G4int ntupleId, const G4String &columnName, std::vector< std::string > &vector) override
 
virtual G4bool SetNtupleSColumn (G4int ntupleId, const G4String &columnName, std::vector< std::string > &vector)=0
 

Protected Attributes

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

Private Member Functions

G4int GetCurrentNtupleId () const
 
virtual G4bool GetTNtupleRow (G4TRNtupleDescription< tools::rcsv::ntuple > *ntupleDescription) final
 
virtual G4int ReadNtupleImpl (const G4String &ntupleName, const G4String &fileName, const G4String &dirName, G4bool isUserFileName) final
 
void SetFileManager (std::shared_ptr< G4CsvRFileManager > fileManager)
 
G4bool SetNtupleTColumn (G4int ntupleId, const G4String &name, std::vector< T > &vector)
 
G4bool SetNtupleTColumn (G4int ntupleId, const G4String &name, T &value)
 

Private Attributes

std::shared_ptr< G4CsvRFileManagerfFileManager { nullptr }
 
std::vector< G4TRNtupleDescription< tools::rcsv::ntuple > * > fNtupleDescriptionVector
 

Static Private Attributes

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

Friends

class G4CsvAnalysisReader
 

Detailed Description

Definition at line 44 of file G4CsvRNtupleManager.hh.

Constructor & Destructor Documentation

◆ G4CsvRNtupleManager() [1/2]

G4CsvRNtupleManager::G4CsvRNtupleManager ( const G4AnalysisManagerState state)
explicit

◆ G4CsvRNtupleManager() [2/2]

G4CsvRNtupleManager::G4CsvRNtupleManager ( )
delete

◆ ~G4CsvRNtupleManager()

virtual G4CsvRNtupleManager::~G4CsvRNtupleManager ( )
virtualdefault

Member Function Documentation

◆ GetCurrentNtupleId()

G4int G4BaseRNtupleManager::GetCurrentNtupleId ( ) const
privateinherited

◆ GetFirstId()

G4int G4BaseAnalysisManager::GetFirstId ( ) const
inlineinherited

Definition at line 94 of file G4BaseAnalysisManager.hh.

94 {
95 return fFirstId;
96}

References G4BaseAnalysisManager::fFirstId.

◆ GetNofNtuples()

virtual G4int G4TRNtupleManager< tools::rcsv::ntuple >::GetNofNtuples ( ) const
finalprotectedvirtualinherited

Implements G4BaseRNtupleManager.

◆ GetNtuple() [1/2]

tools::rcsv::ntuple * G4TRNtupleManager< tools::rcsv::ntuple >::GetNtuple ( ) const
protectedinherited

◆ GetNtuple() [2/2]

tools::rcsv::ntuple * G4TRNtupleManager< tools::rcsv::ntuple >::GetNtuple ( G4int  ntupleId) const
protectedinherited

◆ GetNtupleDescriptionInFunction()

G4TRNtupleDescription< tools::rcsv::ntuple > * G4TRNtupleManager< tools::rcsv::ntuple >::GetNtupleDescriptionInFunction ( G4int  id,
std::string_view  function,
G4bool  warn = true 
) const
protectedinherited

◆ GetNtupleRow() [1/3]

G4bool G4BaseRNtupleManager::GetNtupleRow ( )
finalprotectedvirtualinherited

Reimplemented from G4BaseRNtupleManager.

Definition at line 88 of file G4BaseRNtupleManager.cc.

102{
103 return GetNtupleRow(fFirstId);
104}

◆ GetNtupleRow() [2/3]

virtual G4bool G4TRNtupleManager< tools::rcsv::ntuple >::GetNtupleRow ( G4int  ntupleId)
finalprotectedvirtualinherited

Implements G4BaseRNtupleManager.

◆ GetNtupleRow() [3/3]

virtual G4bool G4BaseRNtupleManager::GetNtupleRow ( G4int  ntupleId)
protectedvirtualinherited

Implements G4BaseRNtupleManager.

◆ GetTNtupleRow()

G4bool G4CsvRNtupleManager::GetTNtupleRow ( G4TRNtupleDescription< tools::rcsv::ntuple > *  ntupleDescription)
finalprivatevirtual

Implements G4TRNtupleManager< tools::rcsv::ntuple >.

Definition at line 80 of file G4CsvRNtupleManager.cc.

82{
83 auto ntuple = ntupleDescription->fNtuple;
84
85 auto isInitialized = ntupleDescription->fIsInitialized;
86 if ( ! isInitialized ) {
87 auto ntupleBinding = ntupleDescription->fNtupleBinding;
88 if ( ! ntuple->initialize(G4cout, *ntupleBinding) ) {
89 Warn("Ntuple initialization failed !!", fkClass, "GetTNtupleRow");
90 return false;
91 }
92 ntupleDescription->fIsInitialized = true;
93 ntuple->start();
94 }
95
96 auto next = ntuple->next();
97 if ( next ) {
98 if ( ! ntuple->get_row() ) {
99 Warn("Ntuple get_row() failed !!", fkClass, "GetTNtupleRow");
100 return false;
101 }
102 }
103
104 return next;
105}
G4GLOB_DLL std::ostream G4cout
static constexpr std::string_view fkClass
void Warn(const G4String &message, const std::string_view inClass, const std::string_view inFunction)
G4bool isInitialized()
tools::ntuple_binding * fNtupleBinding

References G4TRNtupleDescription< NT >::fIsInitialized, fkClass, G4TRNtupleDescription< NT >::fNtuple, G4TRNtupleDescription< NT >::fNtupleBinding, G4cout, G4INCL::Random::isInitialized(), and G4Analysis::Warn().

◆ IsEmpty()

G4bool G4TRNtupleManager< tools::rcsv::ntuple >::IsEmpty ( ) const
protectedinherited

◆ 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().

◆ Message()

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

◆ ReadNtupleImpl()

G4int G4CsvRNtupleManager::ReadNtupleImpl ( const G4String ntupleName,
const G4String fileName,
const G4String dirName,
G4bool  isUserFileName 
)
finalprivatevirtual

Implements G4VRNtupleManager.

Definition at line 46 of file G4CsvRNtupleManager.cc.

50{
51 Message(kVL4, "read", "ntuple", ntupleName);
52
53 // Ntuples are saved per object and per thread
54 // but apply the ntuple name and the thread suffixes
55 // only if fileName is not provided explicitly
56 G4String fullFileName = fileName;
57 if ( ! isUserFileName ) {
58 fullFileName = fFileManager->GetNtupleFileName(ntupleName);
59 }
60
61 // Update directory path
62 if ( ! dirName.empty() ) {
63 fullFileName = "./" + dirName + "/" + fullFileName;
64 }
65
66 // Open file
67 if ( ! fFileManager->OpenRFile(fullFileName) ) return kInvalidId;
68 auto ntupleFile = fFileManager->GetRFile(fullFileName);
69
70 // Create ntuple
71 auto rntuple = new tools::rcsv::ntuple(*ntupleFile);
73
74 Message(kVL2, "read", "ntuple", ntupleName, id > kInvalidId);
75
76 return id;
77}
void Message(G4int level, const G4String &action, const G4String &objectType, const G4String &objectName="", G4bool success=true) const
std::shared_ptr< G4CsvRFileManager > fFileManager
G4int SetNtuple(G4TRNtupleDescription< tools::rcsv::ntuple > *rntupleDescription)
constexpr G4int kVL2
constexpr G4int kVL4
constexpr G4int kInvalidId

References fFileManager, G4Analysis::kInvalidId, G4Analysis::kVL2, G4Analysis::kVL4, G4BaseAnalysisManager::Message(), and G4TRNtupleManager< tools::rcsv::ntuple >::SetNtuple().

◆ Reset()

G4bool G4TRNtupleManager< tools::rcsv::ntuple >::Reset ( )
protectedinherited

◆ SetFileManager()

void G4CsvRNtupleManager::SetFileManager ( std::shared_ptr< G4CsvRFileManager fileManager)
inlineprivate

Definition at line 70 of file G4CsvRNtupleManager.hh.

71{ 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().

◆ SetNtuple()

G4int G4TRNtupleManager< tools::rcsv::ntuple >::SetNtuple ( G4TRNtupleDescription< tools::rcsv::ntuple > *  rntupleDescription)
protectedinherited

◆ SetNtupleDColumn() [1/6]

G4bool G4BaseRNtupleManager::SetNtupleDColumn ( const G4String columnName,
G4double value 
)
finalprotectedvirtualinherited

Reimplemented from G4BaseRNtupleManager.

Definition at line 65 of file G4BaseRNtupleManager.cc.

61{
62 return SetNtupleDColumn(GetCurrentNtupleId(), columnName, value);
63}
G4int GetCurrentNtupleId() const
virtual G4bool SetNtupleDColumn(G4int ntupleId, const G4String &columnName, G4double &value) final

◆ SetNtupleDColumn() [2/6]

G4bool G4BaseRNtupleManager::SetNtupleDColumn ( const G4String columnName,
std::vector< G4double > &  vector 
)
finalprotectedvirtualinherited

Reimplemented from G4BaseRNtupleManager.

Definition at line 65 of file G4BaseRNtupleManager.cc.

89{
90 return SetNtupleDColumn(GetCurrentNtupleId(), columnName, vector);
91}

◆ SetNtupleDColumn() [3/6]

virtual G4bool G4TRNtupleManager< tools::rcsv::ntuple >::SetNtupleDColumn ( G4int  ntupleId,
const G4String columnName,
G4double value 
)
finalprotectedvirtualinherited

Implements G4BaseRNtupleManager.

◆ SetNtupleDColumn() [4/6]

virtual G4bool G4BaseRNtupleManager::SetNtupleDColumn ( G4int  ntupleId,
const G4String columnName,
G4double value 
)
protectedvirtualinherited

Implements G4BaseRNtupleManager.

◆ SetNtupleDColumn() [5/6]

virtual G4bool G4TRNtupleManager< tools::rcsv::ntuple >::SetNtupleDColumn ( G4int  ntupleId,
const G4String columnName,
std::vector< G4double > &  vector 
)
overrideprotectedvirtualinherited

Implements G4BaseRNtupleManager.

◆ SetNtupleDColumn() [6/6]

virtual G4bool G4BaseRNtupleManager::SetNtupleDColumn ( G4int  ntupleId,
const G4String columnName,
std::vector< G4double > &  vector 
)
protectedvirtualinherited

Implements G4BaseRNtupleManager.

◆ SetNtupleFColumn() [1/6]

G4bool G4BaseRNtupleManager::SetNtupleFColumn ( const G4String columnName,
G4float value 
)
finalprotectedvirtualinherited

Reimplemented from G4BaseRNtupleManager.

Definition at line 64 of file G4BaseRNtupleManager.cc.

54{
55 return SetNtupleFColumn(GetCurrentNtupleId(), columnName, value);
56}
virtual G4bool SetNtupleFColumn(G4int ntupleId, const G4String &columnName, G4float &value) final

◆ SetNtupleFColumn() [2/6]

G4bool G4BaseRNtupleManager::SetNtupleFColumn ( const G4String columnName,
std::vector< G4float > &  vector 
)
finalprotectedvirtualinherited

Reimplemented from G4BaseRNtupleManager.

Definition at line 64 of file G4BaseRNtupleManager.cc.

82{
83 return SetNtupleFColumn(GetCurrentNtupleId(), columnName, vector);
84}

◆ SetNtupleFColumn() [3/6]

virtual G4bool G4TRNtupleManager< tools::rcsv::ntuple >::SetNtupleFColumn ( G4int  ntupleId,
const G4String columnName,
G4float value 
)
finalprotectedvirtualinherited

Implements G4BaseRNtupleManager.

◆ SetNtupleFColumn() [4/6]

virtual G4bool G4BaseRNtupleManager::SetNtupleFColumn ( G4int  ntupleId,
const G4String columnName,
G4float value 
)
protectedvirtualinherited

Implements G4BaseRNtupleManager.

◆ SetNtupleFColumn() [5/6]

virtual G4bool G4TRNtupleManager< tools::rcsv::ntuple >::SetNtupleFColumn ( G4int  ntupleId,
const G4String columnName,
std::vector< G4float > &  vector 
)
overrideprotectedvirtualinherited

Implements G4BaseRNtupleManager.

◆ SetNtupleFColumn() [6/6]

virtual G4bool G4BaseRNtupleManager::SetNtupleFColumn ( G4int  ntupleId,
const G4String columnName,
std::vector< G4float > &  vector 
)
protectedvirtualinherited

Implements G4BaseRNtupleManager.

◆ SetNtupleIColumn() [1/6]

G4bool G4BaseRNtupleManager::SetNtupleIColumn ( const G4String columnName,
G4int value 
)
finalprotectedvirtualinherited

Reimplemented from G4BaseRNtupleManager.

Definition at line 63 of file G4BaseRNtupleManager.cc.

48{
49 return SetNtupleIColumn(GetCurrentNtupleId(), columnName, value);
50}
virtual G4bool SetNtupleIColumn(G4int ntupleId, const G4String &columnName, G4int &value) final

◆ SetNtupleIColumn() [2/6]

G4bool G4BaseRNtupleManager::SetNtupleIColumn ( const G4String columnName,
std::vector< G4int > &  vector 
)
finalprotectedvirtualinherited

Reimplemented from G4BaseRNtupleManager.

Definition at line 63 of file G4BaseRNtupleManager.cc.

75{
76 return SetNtupleIColumn(GetCurrentNtupleId(), columnName, vector);
77}

◆ SetNtupleIColumn() [3/6]

virtual G4bool G4TRNtupleManager< tools::rcsv::ntuple >::SetNtupleIColumn ( G4int  ntupleId,
const G4String columnName,
G4int value 
)
finalprotectedvirtualinherited

Implements G4BaseRNtupleManager.

◆ SetNtupleIColumn() [4/6]

virtual G4bool G4BaseRNtupleManager::SetNtupleIColumn ( G4int  ntupleId,
const G4String columnName,
G4int value 
)
protectedvirtualinherited

Implements G4BaseRNtupleManager.

◆ SetNtupleIColumn() [5/6]

virtual G4bool G4TRNtupleManager< tools::rcsv::ntuple >::SetNtupleIColumn ( G4int  ntupleId,
const G4String columnName,
std::vector< G4int > &  vector 
)
overrideprotectedvirtualinherited

Implements G4BaseRNtupleManager.

◆ SetNtupleIColumn() [6/6]

virtual G4bool G4BaseRNtupleManager::SetNtupleIColumn ( G4int  ntupleId,
const G4String columnName,
std::vector< G4int > &  vector 
)
protectedvirtualinherited

Implements G4BaseRNtupleManager.

◆ SetNtupleSColumn() [1/6]

G4bool G4BaseRNtupleManager::SetNtupleSColumn ( const G4String columnName,
G4String value 
)
finalprotectedvirtualinherited

Reimplemented from G4BaseRNtupleManager.

Definition at line 66 of file G4BaseRNtupleManager.cc.

68{
69 return SetNtupleSColumn(GetCurrentNtupleId(), columnName, value);
70}
virtual G4bool SetNtupleSColumn(G4int ntupleId, const G4String &columnName, G4String &value) final

◆ SetNtupleSColumn() [2/6]

G4bool G4BaseRNtupleManager::SetNtupleSColumn ( const G4String columnName,
std::vector< std::string > &  vector 
)
finalprotectedvirtualinherited

Reimplemented from G4BaseRNtupleManager.

Definition at line 66 of file G4BaseRNtupleManager.cc.

96{
97 return SetNtupleSColumn(GetCurrentNtupleId(), columnName, vector);
98}

◆ SetNtupleSColumn() [3/6]

virtual G4bool G4TRNtupleManager< tools::rcsv::ntuple >::SetNtupleSColumn ( G4int  ntupleId,
const G4String columnName,
G4String value 
)
finalprotectedvirtualinherited

Implements G4BaseRNtupleManager.

◆ SetNtupleSColumn() [4/6]

virtual G4bool G4BaseRNtupleManager::SetNtupleSColumn ( G4int  ntupleId,
const G4String columnName,
G4String value 
)
protectedvirtualinherited

Implements G4BaseRNtupleManager.

◆ SetNtupleSColumn() [5/6]

virtual G4bool G4TRNtupleManager< tools::rcsv::ntuple >::SetNtupleSColumn ( G4int  ntupleId,
const G4String columnName,
std::vector< std::string > &  vector 
)
overrideprotectedvirtualinherited

Implements G4BaseRNtupleManager.

◆ SetNtupleSColumn() [6/6]

virtual G4bool G4BaseRNtupleManager::SetNtupleSColumn ( G4int  ntupleId,
const G4String columnName,
std::vector< std::string > &  vector 
)
protectedvirtualinherited

Implements G4BaseRNtupleManager.

◆ SetNtupleTColumn() [1/2]

G4bool G4TRNtupleManager< tools::rcsv::ntuple >::SetNtupleTColumn ( G4int  ntupleId,
const G4String name,
std::vector< T > &  vector 
)
privateinherited

◆ SetNtupleTColumn() [2/2]

G4bool G4TRNtupleManager< tools::rcsv::ntuple >::SetNtupleTColumn ( G4int  ntupleId,
const G4String name,
T &  value 
)
privateinherited

Friends And Related Function Documentation

◆ G4CsvAnalysisReader

friend class G4CsvAnalysisReader
friend

Definition at line 46 of file G4CsvRNtupleManager.hh.

Field Documentation

◆ fFileManager

std::shared_ptr<G4CsvRFileManager> G4CsvRNtupleManager::fFileManager { nullptr }
private

Definition at line 66 of file G4CsvRNtupleManager.hh.

Referenced by ReadNtupleImpl(), and SetFileManager().

◆ fFirstId

G4int G4BaseAnalysisManager::fFirstId { 0 }
protectedinherited

◆ fkClass

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

Definition at line 63 of file G4CsvRNtupleManager.hh.

Referenced by GetTNtupleRow().

◆ fLockFirstId

G4bool G4BaseAnalysisManager::fLockFirstId { false }
protectedinherited

◆ fNtupleDescriptionVector

std::vector<G4TRNtupleDescription<tools::rcsv::ntuple >*> G4TRNtupleManager< tools::rcsv::ntuple >::fNtupleDescriptionVector
privateinherited

Definition at line 118 of file G4TRNtupleManager.hh.

◆ fState

const G4AnalysisManagerState& G4BaseAnalysisManager::fState
protectedinherited

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