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

#include <G4RootPNtupleManager.hh>

Inheritance diagram for G4RootPNtupleManager:
G4BaseNtupleManager G4VNtupleManager G4BaseAnalysisManager

Public Member Functions

 G4RootPNtupleManager ()=delete
 
 G4RootPNtupleManager (const G4AnalysisManagerState &state, std::shared_ptr< G4NtupleBookingManager > bookingManger, std::shared_ptr< G4RootMainNtupleManager > main, G4bool rowWise, G4bool rowMode)
 
G4int GetFirstId () const
 
G4bool SetFirstId (G4int firstId)
 
void SetLockFirstId (G4bool lockFirstId)
 
virtual ~G4RootPNtupleManager ()
 

Protected Member Functions

G4bool IsVerbose (G4int verboseLevel) const
 
void Message (G4int level, const G4String &action, const G4String &objectType, const G4String &objectName="", G4bool success=true) const
 
virtual G4bool SetFirstNtupleColumnId (G4int firstId) final
 

Protected Attributes

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

Private Member Functions

virtual G4bool AddNtupleRow () final
 
virtual G4bool AddNtupleRow (G4int ntupleId) final
 
virtual G4bool AddNtupleRow (G4int ntupleId)=0
 
virtual void Clear () final
 
virtual G4int CreateNtuple (G4NtupleBooking *booking) final
 
void CreateNtupleFromMain (G4RootPNtupleDescription *ntupleDescription, tools::wroot::ntuple *mainNtuple)
 
void CreateNtuplesFromMain ()
 
virtual G4bool FillNtupleDColumn (G4int id, G4double value) final
 
virtual G4bool FillNtupleDColumn (G4int ntupleId, G4int columnId, G4double value) final
 
virtual G4bool FillNtupleDColumn (G4int ntupleId, G4int columnId, G4double value)=0
 
virtual G4bool FillNtupleFColumn (G4int id, G4float value) final
 
virtual G4bool FillNtupleFColumn (G4int ntupleId, G4int columnId, G4float value) final
 
virtual G4bool FillNtupleFColumn (G4int ntupleId, G4int columnId, G4float value)=0
 
virtual G4bool FillNtupleIColumn (G4int id, G4int value) final
 
virtual G4bool FillNtupleIColumn (G4int ntupleId, G4int columnId, G4int value) final
 
virtual G4bool FillNtupleIColumn (G4int ntupleId, G4int columnId, G4int value)=0
 
virtual G4bool FillNtupleSColumn (G4int id, const G4String &value) final
 
virtual G4bool FillNtupleSColumn (G4int ntupleId, G4int columnId, const G4String &value) final
 
virtual G4bool FillNtupleSColumn (G4int ntupleId, G4int columnId, const G4String &value)=0
 
template<typename T >
G4bool FillNtupleTColumn (G4int columnId, const T &value)
 
template<typename T >
G4bool FillNtupleTColumn (G4int ntupleId, G4int columnId, const T &value)
 
virtual G4bool GetActivation (G4int ntupleId) const final
 
tools::wroot::ntuple * GetMainNtupleInFunction (G4int id, std::string_view function, G4bool warn=true) const
 
virtual G4int GetNofNtuples () const final
 
G4RootPNtupleDescriptionGetNtupleDescriptionInFunction (G4int id, std::string_view function, G4bool warn=true) const
 
tools::wroot::base_pntuple * GetNtupleInFunction (G4int id, std::string_view function, G4bool warn=true) const
 
virtual G4bool Merge () final
 
virtual void SetActivation (G4bool activation) final
 
virtual void SetActivation (G4int ntupleId, G4bool activation) final
 
void SetNtupleRowWise (G4bool rowWise, G4bool rowMode)
 

Private Attributes

std::shared_ptr< G4NtupleBookingManagerfBookingManager
 
G4bool fCreateNtuples { true }
 
std::shared_ptr< G4RootMainNtupleManagerfMainNtupleManager
 
std::vector< G4RootPNtupleDescription * > fNtupleDescriptionVector
 
std::vector< tools::wroot::imt_ntuple * > fNtupleVector
 
G4bool fRowMode
 
G4bool fRowWise
 

Static Private Attributes

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

Friends

class G4RootAnalysisManager
 
class G4RootNtupleFileManager
 

Detailed Description

Definition at line 79 of file G4RootPNtupleManager.hh.

Constructor & Destructor Documentation

◆ G4RootPNtupleManager() [1/2]

G4RootPNtupleManager::G4RootPNtupleManager ( const G4AnalysisManagerState state,
std::shared_ptr< G4NtupleBookingManager bookingManger,
std::shared_ptr< G4RootMainNtupleManager main,
G4bool  rowWise,
G4bool  rowMode 
)

Definition at line 59 of file G4RootPNtupleManager.cc.

63 : G4BaseNtupleManager(state),
64 fBookingManager(std::move(bookingManger)),
65 fMainNtupleManager(std::move(main)),
66 fRowWise(rowWise),
67 fRowMode(rowMode)
68{}
int main(int argc, char *argv[])
G4BaseNtupleManager()=delete
std::shared_ptr< G4NtupleBookingManager > fBookingManager
std::shared_ptr< G4RootMainNtupleManager > fMainNtupleManager

◆ G4RootPNtupleManager() [2/2]

G4RootPNtupleManager::G4RootPNtupleManager ( )
delete

◆ ~G4RootPNtupleManager()

G4RootPNtupleManager::~G4RootPNtupleManager ( )
virtual

Definition at line 71 of file G4RootPNtupleManager.cc.

72{
73 for ( auto ntupleDescription : fNtupleDescriptionVector ) {
74 delete ntupleDescription;
75 }
76}
std::vector< G4RootPNtupleDescription * > fNtupleDescriptionVector

References fNtupleDescriptionVector.

Member Function Documentation

◆ AddNtupleRow() [1/3]

G4bool G4BaseNtupleManager::AddNtupleRow ( )
finalprivatevirtual

Reimplemented from G4BaseNtupleManager.

Definition at line 59 of file G4BaseNtupleManager.cc.

62{
63 return AddNtupleRow(fFirstId);
64}
virtual G4bool AddNtupleRow() final

◆ AddNtupleRow() [2/3]

G4bool G4RootPNtupleManager::AddNtupleRow ( G4int  ntupleId)
finalprivatevirtual

Implements G4BaseNtupleManager.

Definition at line 263 of file G4RootPNtupleManager.cc.

264{
265 if (fCreateNtuples) {
267 }
268
269 if ( fState.GetIsActivation() && ( ! GetActivation(ntupleId) ) ) {
270 //G4cout << "Skipping AddNtupleRow for " << ntupleId << G4endl;
271 return false;
272 }
273
274 if ( IsVerbose(kVL4) ) {
275 Message(kVL4, "add", "pntuple row", " ntupleId " + to_string(ntupleId));
276 }
277
278 auto ntupleDescription = GetNtupleDescriptionInFunction(ntupleId, "AddNtupleRow");
279 if ( ! ntupleDescription ) return false;
280
281 auto rfile = std::get<0>(*ntupleDescription->fDescription.fFile);
282
284 lock.unlock();
285 mutex toolsLock(lock);
286 auto result
287 = ntupleDescription->fNtuple->add_row(toolsLock, *rfile);
288
289 if ( ! result ) {
290 Warn("NtupleId " + to_string(ntupleId) + "adding row failed.",
291 fkClass, "AddNtupleRow");
292 }
293
294 ntupleDescription->fDescription.fHasFill = true;
295
296 if ( IsVerbose(kVL3) ) {
297 Message(kVL3, "add", "pntuple row", " ntupleId " + to_string(ntupleId));
298 }
299
300
301 return true;
302}
void Message(G4int level, const G4String &action, const G4String &objectType, const G4String &objectName="", G4bool success=true) const
const G4AnalysisManagerState & fState
G4bool IsVerbose(G4int verboseLevel) const
G4RootPNtupleDescription * GetNtupleDescriptionInFunction(G4int id, std::string_view function, G4bool warn=true) const
static constexpr std::string_view fkClass
virtual G4bool GetActivation(G4int ntupleId) const final
constexpr G4int kVL3
constexpr G4int kVL4
void Warn(const G4String &message, const std::string_view inClass, const std::string_view inFunction)

References CreateNtuplesFromMain(), fCreateNtuples, fkClass, G4BaseAnalysisManager::fState, GetActivation(), G4AnalysisManagerState::GetIsActivation(), GetNtupleDescriptionInFunction(), G4BaseAnalysisManager::IsVerbose(), G4Analysis::kVL3, G4Analysis::kVL4, G4BaseAnalysisManager::Message(), anonymous_namespace{G4RootPNtupleManager.cc}::pntupleMutex, G4TemplateAutoLock< _Mutex_t >::unlock(), and G4Analysis::Warn().

◆ AddNtupleRow() [3/3]

virtual G4bool G4BaseNtupleManager::AddNtupleRow ( G4int  ntupleId)
privatevirtual

Implements G4BaseNtupleManager.

◆ Clear()

void G4RootPNtupleManager::Clear ( )
finalprivatevirtual

Implements G4VNtupleManager.

Definition at line 345 of file G4RootPNtupleManager.cc.

346{
347 for ( auto ntupleDescription : fNtupleDescriptionVector ) {
348 delete ntupleDescription->fNtuple;
349 }
350
352 fNtupleVector.clear();
353
354 Message(kVL2, "clear", "pntuples");
355}
std::vector< tools::wroot::imt_ntuple * > fNtupleVector
constexpr G4int kVL2

References fNtupleDescriptionVector, fNtupleVector, G4Analysis::kVL2, and G4BaseAnalysisManager::Message().

◆ CreateNtuple()

G4int G4RootPNtupleManager::CreateNtuple ( G4NtupleBooking booking)
finalprivatevirtual

Implements G4BaseNtupleManager.

Definition at line 226 of file G4RootPNtupleManager.cc.

227{
228// Create pntuple from g4 ntuple booking.
229// Nothing to be done here.
230
232}
constexpr G4int kInvalidId

References G4Analysis::kInvalidId.

◆ CreateNtupleFromMain()

void G4RootPNtupleManager::CreateNtupleFromMain ( G4RootPNtupleDescription ntupleDescription,
tools::wroot::ntuple *  mainNtuple 
)
private

Definition at line 138 of file G4RootPNtupleManager.cc.

141{
142 Message(kVL4, "create from main", "pntuple", mainNtuple->name());
143
144 auto file = fMainNtupleManager->GetNtupleFile(&ntupleDescription->fDescription);
145 if ( ! file ) {
146 Warn("Cannot create pntuple. Main ntuple file does not exist.",
147 fkClass, "CreateNtupleFromMain");
148 return;
149 }
150
151 ntupleDescription->fDescription.fFile = file;
152
153 // Get parameters from ntupleDescription
154 mainNtuple->get_branches(ntupleDescription->fMainBranches);
155
156 auto rfile = std::get<0>(*file);
157 G4bool verbose = true;
158 if ( fRowWise ) {
159 auto mainBranch = mainNtuple->get_row_wise_branch();
160 auto mtNtuple
161 = new tools::wroot::mt_ntuple_row_wise(
162 G4cout, rfile->byte_swap(), rfile->compression(),
163 mainNtuple->dir().seek_directory(),
164 *mainBranch, mainBranch->basket_size(),
165 ntupleDescription->fDescription.fNtupleBooking, verbose);
166
167 ntupleDescription->fNtuple
168 = static_cast<tools::wroot::imt_ntuple*>(mtNtuple);
169 ntupleDescription->fBasePNtuple
170 = static_cast<tools::wroot::base_pntuple*>(mtNtuple);
171 }
172 else {
173 std::vector<tools::uint32> basketSizes;
174 tools_vforcit(tools::wroot::branch*, ntupleDescription->fMainBranches, it) {
175 basketSizes.push_back((*it)->basket_size());
176 }
177 auto basketEntries = fMainNtupleManager->GetBasketEntries();
178
179 auto mtNtuple =
180 new tools::wroot::mt_ntuple_column_wise(
181 G4cout, rfile->byte_swap(), rfile->compression(),
182 mainNtuple->dir().seek_directory(),
183 ntupleDescription->fMainBranches, basketSizes,
184 ntupleDescription->fDescription.fNtupleBooking,
185 fRowMode, basketEntries, verbose);
186
187 ntupleDescription->fNtuple
188 = static_cast<tools::wroot::imt_ntuple*>(mtNtuple);
189 ntupleDescription->fBasePNtuple
190 = static_cast<tools::wroot::base_pntuple*>(mtNtuple);
191 }
192
193 ntupleDescription->fDescription.fIsNtupleOwner = true;
194 // // pntuple object is not deleted automatically
195 fNtupleVector.push_back(ntupleDescription->fNtuple);
196
197 Message(kVL3, "create from main", "pntuple", mainNtuple->name());
198}
bool G4bool
Definition: G4Types.hh:86
G4GLOB_DLL std::ostream G4cout
tools::wroot::base_pntuple * fBasePNtuple
tools::wroot::imt_ntuple * fNtuple
std::vector< tools::wroot::branch * > fMainBranches
RootNtupleDescription fDescription
tools::ntuple_booking fNtupleBooking
std::shared_ptr< FT > fFile

References G4RootPNtupleDescription::fBasePNtuple, G4RootPNtupleDescription::fDescription, G4TNtupleDescription< NT, FT >::fFile, geant4_check_module_cycles::file, G4TNtupleDescription< NT, FT >::fIsNtupleOwner, fkClass, G4RootPNtupleDescription::fMainBranches, fMainNtupleManager, G4RootPNtupleDescription::fNtuple, G4TNtupleDescription< NT, FT >::fNtupleBooking, fNtupleVector, fRowMode, fRowWise, G4cout, G4Analysis::kVL3, G4Analysis::kVL4, G4BaseAnalysisManager::Message(), and G4Analysis::Warn().

Referenced by CreateNtuplesFromMain().

◆ CreateNtuplesFromMain()

void G4RootPNtupleManager::CreateNtuplesFromMain ( )
private

Definition at line 201 of file G4RootPNtupleManager.cc.

202{
203// Create ntuple from booking (if not yet done) and main ntuple
204// This function is called from the first Fill call.
205
206 // Create pntuple descriptions from ntuple booking.
207 auto g4NtupleBookings = fBookingManager->GetNtupleBookingVector();
208 for ( auto g4NtupleBooking : g4NtupleBookings ) {
209 auto ntupleDescription = new G4RootPNtupleDescription(g4NtupleBooking);
210 // Save g4booking, activation in pntuple booking
211 fNtupleDescriptionVector.push_back(ntupleDescription);
212 }
213
214 auto& mainNtupleVector = fMainNtupleManager->GetNtupleVector();
215
216 G4int lcounter = 0;
217 for ( auto mainNtuple : mainNtupleVector ) {
218 auto& ntupleDescription = fNtupleDescriptionVector[lcounter++];
219 CreateNtupleFromMain(ntupleDescription, mainNtuple);
220 }
221
222 fCreateNtuples = false;
223}
int G4int
Definition: G4Types.hh:85
void CreateNtupleFromMain(G4RootPNtupleDescription *ntupleDescription, tools::wroot::ntuple *mainNtuple)

References CreateNtupleFromMain(), fBookingManager, fCreateNtuples, fMainNtupleManager, and fNtupleDescriptionVector.

Referenced by AddNtupleRow().

◆ FillNtupleDColumn() [1/3]

G4bool G4BaseNtupleManager::FillNtupleDColumn ( G4int  id,
G4double  value 
)
finalprivatevirtual

Reimplemented from G4BaseNtupleManager.

Definition at line 57 of file G4BaseNtupleManager.cc.

50{
51 return FillNtupleDColumn(fFirstId, id, value);
52}
virtual G4bool FillNtupleDColumn(G4int ntupleId, G4int columnId, G4double value) final

◆ FillNtupleDColumn() [2/3]

G4bool G4RootPNtupleManager::FillNtupleDColumn ( G4int  ntupleId,
G4int  columnId,
G4double  value 
)
finalprivatevirtual

Implements G4BaseNtupleManager.

Definition at line 249 of file G4RootPNtupleManager.cc.

251{
252 return FillNtupleTColumn<double>(ntupleId, columnId, value);
253}

◆ FillNtupleDColumn() [3/3]

virtual G4bool G4BaseNtupleManager::FillNtupleDColumn ( G4int  ntupleId,
G4int  columnId,
G4double  value 
)
privatevirtual

Implements G4BaseNtupleManager.

◆ FillNtupleFColumn() [1/3]

G4bool G4BaseNtupleManager::FillNtupleFColumn ( G4int  id,
G4float  value 
)
finalprivatevirtual

Reimplemented from G4BaseNtupleManager.

Definition at line 56 of file G4BaseNtupleManager.cc.

44{
45 return FillNtupleFColumn(fFirstId, id, value);
46}
virtual G4bool FillNtupleFColumn(G4int ntupleId, G4int columnId, G4float value) final

◆ FillNtupleFColumn() [2/3]

G4bool G4RootPNtupleManager::FillNtupleFColumn ( G4int  ntupleId,
G4int  columnId,
G4float  value 
)
finalprivatevirtual

Implements G4BaseNtupleManager.

Definition at line 242 of file G4RootPNtupleManager.cc.

244{
245 return FillNtupleTColumn<float>(ntupleId, columnId, value);
246}

◆ FillNtupleFColumn() [3/3]

virtual G4bool G4BaseNtupleManager::FillNtupleFColumn ( G4int  ntupleId,
G4int  columnId,
G4float  value 
)
privatevirtual

Implements G4BaseNtupleManager.

◆ FillNtupleIColumn() [1/3]

G4bool G4BaseNtupleManager::FillNtupleIColumn ( G4int  id,
G4int  value 
)
finalprivatevirtual

Reimplemented from G4BaseNtupleManager.

Definition at line 55 of file G4BaseNtupleManager.cc.

38{
39 return FillNtupleIColumn(fFirstId, id, value);
40}
virtual G4bool FillNtupleIColumn(G4int ntupleId, G4int columnId, G4int value) final

◆ FillNtupleIColumn() [2/3]

G4bool G4RootPNtupleManager::FillNtupleIColumn ( G4int  ntupleId,
G4int  columnId,
G4int  value 
)
finalprivatevirtual

Implements G4BaseNtupleManager.

Definition at line 235 of file G4RootPNtupleManager.cc.

237{
238 return FillNtupleTColumn<int>(ntupleId, columnId, value);
239}

◆ FillNtupleIColumn() [3/3]

virtual G4bool G4BaseNtupleManager::FillNtupleIColumn ( G4int  ntupleId,
G4int  columnId,
G4int  value 
)
privatevirtual

Implements G4BaseNtupleManager.

◆ FillNtupleSColumn() [1/3]

G4bool G4BaseNtupleManager::FillNtupleSColumn ( G4int  id,
const G4String value 
)
finalprivatevirtual

Reimplemented from G4BaseNtupleManager.

Definition at line 58 of file G4BaseNtupleManager.cc.

56{
57 return FillNtupleSColumn(fFirstId, id, value);
58}
virtual G4bool FillNtupleSColumn(G4int ntupleId, G4int columnId, const G4String &value) final

◆ FillNtupleSColumn() [2/3]

G4bool G4RootPNtupleManager::FillNtupleSColumn ( G4int  ntupleId,
G4int  columnId,
const G4String value 
)
finalprivatevirtual

Implements G4BaseNtupleManager.

Definition at line 256 of file G4RootPNtupleManager.cc.

258{
259 return FillNtupleTColumn<std::string>(ntupleId, columnId, value);
260}

◆ FillNtupleSColumn() [3/3]

virtual G4bool G4BaseNtupleManager::FillNtupleSColumn ( G4int  ntupleId,
G4int  columnId,
const G4String value 
)
privatevirtual

Implements G4BaseNtupleManager.

◆ FillNtupleTColumn() [1/2]

template<typename T >
G4bool G4RootPNtupleManager::FillNtupleTColumn ( G4int  columnId,
const T &  value 
)
private

◆ FillNtupleTColumn() [2/2]

template<typename T >
G4bool G4RootPNtupleManager::FillNtupleTColumn ( G4int  ntupleId,
G4int  columnId,
const T &  value 
)
private

◆ GetActivation()

G4bool G4RootPNtupleManager::GetActivation ( G4int  ntupleId) const
finalprivatevirtual

Implements G4VNtupleManager.

Definition at line 379 of file G4RootPNtupleManager.cc.

381{
382 auto ntupleDescription = GetNtupleDescriptionInFunction(ntupleId, "GetActivation");
383 if ( ! ntupleDescription ) return false;
384
385 return ntupleDescription->fDescription.fActivation;
386}

References GetNtupleDescriptionInFunction().

Referenced by AddNtupleRow().

◆ GetFirstId()

G4int G4BaseAnalysisManager::GetFirstId ( ) const
inlineinherited

Definition at line 94 of file G4BaseAnalysisManager.hh.

94 {
95 return fFirstId;
96}

References G4BaseAnalysisManager::fFirstId.

◆ GetMainNtupleInFunction()

tools::wroot::ntuple * G4RootPNtupleManager::GetMainNtupleInFunction ( G4int  id,
std::string_view  function,
G4bool  warn = true 
) const
private

Definition at line 117 of file G4RootPNtupleManager.cc.

119{
120 auto& mainNtupleVector = fMainNtupleManager->GetNtupleVector();
121
122 auto index = id - fFirstId;
123 if ( index < 0 || index >= G4int(mainNtupleVector.size()) ) {
124 if ( warn) {
125 NotExistWarning("main ntuple", id, fkClass, functionName);
126 }
127 return nullptr;
128 }
129
130 return mainNtupleVector[index];
131}
void NotExistWarning(const G4String &what, G4int id, std::string_view className, std::string_view functionName)

References G4BaseAnalysisManager::fFirstId, fkClass, fMainNtupleManager, and anonymous_namespace{G4RootPNtupleManager.cc}::NotExistWarning().

◆ GetNofNtuples()

G4int G4RootPNtupleManager::GetNofNtuples ( ) const
finalprivatevirtual

Implements G4VNtupleManager.

Definition at line 389 of file G4RootPNtupleManager.cc.

390{
391 return fNtupleVector.size();
392}

References fNtupleVector.

◆ GetNtupleDescriptionInFunction()

G4RootPNtupleDescription * G4RootPNtupleManager::GetNtupleDescriptionInFunction ( G4int  id,
std::string_view  function,
G4bool  warn = true 
) const
private

Definition at line 84 of file G4RootPNtupleManager.cc.

86{
87 auto index = id - fFirstId;
88 if ( index < 0 || index >= G4int(fNtupleDescriptionVector.size()) ) {
89 if ( warn) {
90 NotExistWarning("ntuple description", id, fkClass, functionName);
91 }
92 return nullptr;
93 }
94
95 return fNtupleDescriptionVector[index];
96}

References G4BaseAnalysisManager::fFirstId, fkClass, fNtupleDescriptionVector, and anonymous_namespace{G4RootPNtupleManager.cc}::NotExistWarning().

Referenced by AddNtupleRow(), GetActivation(), GetNtupleInFunction(), and SetActivation().

◆ GetNtupleInFunction()

tools::wroot::base_pntuple * G4RootPNtupleManager::GetNtupleInFunction ( G4int  id,
std::string_view  function,
G4bool  warn = true 
) const
private

Definition at line 100 of file G4RootPNtupleManager.cc.

102{
103 auto ntupleDescription = GetNtupleDescriptionInFunction(id, functionName);
104 if ( ! ntupleDescription ) return nullptr;
105
106 if ( ! ntupleDescription->fBasePNtuple ) {
107 if ( warn ) {
108 NotExistWarning("ntuple", id, fkClass, functionName);
109 }
110 return nullptr;
111 }
112 return ntupleDescription->fBasePNtuple;
113}

References fkClass, GetNtupleDescriptionInFunction(), and anonymous_namespace{G4RootPNtupleManager.cc}::NotExistWarning().

◆ 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

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

Referenced by AddNtupleRow(), and Merge().

◆ Merge()

G4bool G4RootPNtupleManager::Merge ( )
finalprivatevirtual

Definition at line 305 of file G4RootPNtupleManager.cc.

306{
307 for ( auto ntupleDescription : fNtupleDescriptionVector) {
308
309 // skip inactivated ntuples
310 if(!ntupleDescription->fDescription.fActivation || !ntupleDescription->fNtuple) {
311 // G4cout << "skipping inactive ntuple " << G4endl;
312 continue;
313 }
314
315 if ( IsVerbose(kVL4) ) {
316 Message(kVL4, "merge", "pntuple", ntupleDescription->fDescription.fNtupleBooking.name());
317 }
318
319 auto rfile = std::get<0>(*ntupleDescription->fDescription.fFile);
320
322 lock.unlock();
323 mutex toolsLock(lock);
324 auto result
325 = ntupleDescription->fNtuple->end_fill(toolsLock, *rfile);
326
327 if ( ! result ) {
328 Warn("Ntuple " + ntupleDescription->fDescription.fNtupleBooking.name() +
329 "end fill has failed.", fkClass, "Merge");
330 }
331
332 delete ntupleDescription->fNtuple;
333 ntupleDescription->fNtuple = nullptr;
334
335 if ( IsVerbose(kVL3) ) {
336 Message(kVL3, "merge", "pntuple", ntupleDescription->fDescription.fNtupleBooking.name());
337 }
338
339 }
340 return true;
341
342}

References fkClass, fNtupleDescriptionVector, G4BaseAnalysisManager::IsVerbose(), G4Analysis::kVL3, G4Analysis::kVL4, G4BaseAnalysisManager::Message(), anonymous_namespace{G4RootPNtupleManager.cc}::pntupleMutex, G4TemplateAutoLock< _Mutex_t >::unlock(), and G4Analysis::Warn().

◆ Message()

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

◆ SetActivation() [1/2]

void G4RootPNtupleManager::SetActivation ( G4bool  activation)
finalprivatevirtual

Implements G4VNtupleManager.

Definition at line 359 of file G4RootPNtupleManager.cc.

361{
362 for ( auto ntupleDescription : fNtupleDescriptionVector ) {
363 ntupleDescription->fDescription.fActivation = activation;
364 }
365}

References fNtupleDescriptionVector.

◆ SetActivation() [2/2]

void G4RootPNtupleManager::SetActivation ( G4int  ntupleId,
G4bool  activation 
)
finalprivatevirtual

Implements G4VNtupleManager.

Definition at line 369 of file G4RootPNtupleManager.cc.

371{
372 auto ntupleDescription = GetNtupleDescriptionInFunction(ntupleId, "SetActivation");
373 if ( ! ntupleDescription ) return;
374
375 ntupleDescription->fDescription.fActivation = activation;
376}

References GetNtupleDescriptionInFunction().

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

◆ SetFirstNtupleColumnId()

G4bool G4BaseNtupleManager::SetFirstNtupleColumnId ( G4int  firstId)
finalprotectedvirtualinherited

Implements G4VNtupleManager.

Definition at line 67 of file G4BaseNtupleManager.cc.

68{
69 fFirstNtupleColumnId = firstId;
70 return true;
71}

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

◆ SetNtupleRowWise()

void G4RootPNtupleManager::SetNtupleRowWise ( G4bool  rowWise,
G4bool  rowMode 
)
private

Definition at line 395 of file G4RootPNtupleManager.cc.

396{
397 fRowWise = rowWise;
398 fRowMode = rowMode;
399}

References fRowMode, and fRowWise.

Friends And Related Function Documentation

◆ G4RootAnalysisManager

friend class G4RootAnalysisManager
friend

Definition at line 81 of file G4RootPNtupleManager.hh.

◆ G4RootNtupleFileManager

friend class G4RootNtupleFileManager
friend

Definition at line 82 of file G4RootPNtupleManager.hh.

Field Documentation

◆ fBookingManager

std::shared_ptr<G4NtupleBookingManager> G4RootPNtupleManager::fBookingManager
private

Definition at line 153 of file G4RootPNtupleManager.hh.

Referenced by CreateNtuplesFromMain().

◆ fCreateNtuples

G4bool G4RootPNtupleManager::fCreateNtuples { true }
private

Definition at line 159 of file G4RootPNtupleManager.hh.

Referenced by AddNtupleRow(), and CreateNtuplesFromMain().

◆ fFirstId

G4int G4BaseAnalysisManager::fFirstId { 0 }
protectedinherited

◆ fFirstNtupleColumnId

G4int G4BaseNtupleManager::fFirstNtupleColumnId { 0 }
protectedinherited

Definition at line 73 of file G4BaseNtupleManager.hh.

◆ fkClass

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

◆ fLockFirstId

G4bool G4BaseAnalysisManager::fLockFirstId { false }
protectedinherited

◆ fMainNtupleManager

std::shared_ptr<G4RootMainNtupleManager> G4RootPNtupleManager::fMainNtupleManager
private

◆ fNtupleDescriptionVector

std::vector<G4RootPNtupleDescription*> G4RootPNtupleManager::fNtupleDescriptionVector
private

◆ fNtupleVector

std::vector<tools::wroot::imt_ntuple*> G4RootPNtupleManager::fNtupleVector
private

Definition at line 156 of file G4RootPNtupleManager.hh.

Referenced by Clear(), CreateNtupleFromMain(), and GetNofNtuples().

◆ fRowMode

G4bool G4RootPNtupleManager::fRowMode
private

Definition at line 158 of file G4RootPNtupleManager.hh.

Referenced by CreateNtupleFromMain(), and SetNtupleRowWise().

◆ fRowWise

G4bool G4RootPNtupleManager::fRowWise
private

Definition at line 157 of file G4RootPNtupleManager.hh.

Referenced by CreateNtupleFromMain(), and SetNtupleRowWise().

◆ fState

const G4AnalysisManagerState& G4BaseAnalysisManager::fState
protectedinherited

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