VMC Version 2.2
Loading...
Searching...
No Matches
TMCRNTupleParallelWriter.cxx
Go to the documentation of this file.
1//------------------------------------------------
2// The Geant4 Virtual Monte Carlo package
3// Copyright (C) 2013 - 2018 Ivana Hrivnacova
4// All rights reserved.
5//
6// For the licensing terms see geant4_vmc/LICENSE.
7// Contact: root-vmc@cern.ch
8//-------------------------------------------------
9
17
19
20#include <TFile.h>
21
22#if (ROOT_VERSION_CODE >= ROOT_VERSION(6, 38, 0))
23
24std::shared_ptr<RNTParaWriter> TMCRNTupleParallelWriter::fgParaWriter = nullptr;
25
26//
27// ctors, dtor
28//
29
30//_____________________________________________________________________________
31TMCRNTupleParallelWriter::TMCRNTupleParallelWriter(const char *storageName, TFile* file, Bool_t workerMode)
32 : TMCVNtupleWriter(storageName, file, workerMode)
33 {
34 if (!workerMode) {
35 fModel = RNTupleModel::Create();
36 }
37 }
38
39//
40// public methods
41//
42
43//_____________________________________________________________________________
45{
46 if (!fWorkerMode) {
47 if (!fFile) {
48 Error("TMCRNTupleParallelWriter", "File not found, cannot create rntuple.");
49 return;
50 }
51 fgParaWriter = std::shared_ptr<RNTParaWriter>(
52 RNTupleParallelWriter::Append(std::move(fModel), fStorageName.c_str(), *fFile).release());
53 } else {
54 fFillContext = fgParaWriter->CreateFillContext();
55 fEntry = fFillContext->CreateEntry();
56 for (auto nameAddress : fNameAddress) {
57 fEntry->BindRawPtr(nameAddress.first, nameAddress.second);
58 }
59 }
60}
61
62//_____________________________________________________________________________
68
69//_____________________________________________________________________________
71{
73 fEntry.reset();
74 fFillContext.reset();
75}
76
77//_____________________________________________________________________________
79{
80 fgParaWriter->CommitDataset();
81}
82
83#endif
Definition of the TMCRNTupleParallelWriter class.
std::shared_ptr< RNTupleFillContext > fFillContext
std::unique_ptr< REntry > fEntry
static std::shared_ptr< RNTParaWriter > fgParaWriter
std::vector< std::pair< std::string, void * > > fNameAddress
virtual void CreateRNTuple() override
std::unique_ptr< RNTupleModel > fModel
std::string fStorageName
TMCVNtupleWriter(const char *storageName, TFile *file, Bool_t workerMode)