VMC Version 2.2
Loading...
Searching...
No Matches
TMCRNTupleParallelWriter.h
Go to the documentation of this file.
1#ifndef ROOT_TMCRNTupleParallelWriter
2#define ROOT_TMCRNTupleParallelWriter
3
4//------------------------------------------------
5// The Geant4 Virtual Monte Carlo package
6// Copyright (C) 2013 - 2018 Ivana Hrivnacova
7// All rights reserved.
8//
9// For the licensing terms see geant4_vmc/LICENSE.
10// Contact: root-vmc@cern.ch
11//-------------------------------------------------
12
20
21#include <RVersion.h>
22
23#if (ROOT_VERSION_CODE >= ROOT_VERSION(6, 38, 0))
24
25#include "TMCVNtupleWriter.h"
26
27#include <ROOT/REntry.hxx>
28#include <ROOT/RNTupleFillContext.hxx>
29#include <ROOT/RNTuple.hxx>
30#include <ROOT/RNTupleModel.hxx>
31#include <ROOT/RNTupleParallelWriter.hxx>
32#include <ROOT/RNTupleReader.hxx>
33
34using ROOT::RNTuple;
35using ROOT::RNTupleParallelWriter;
36using REntry = ROOT::REntry;
37using RNTupleModel = ROOT::RNTupleModel;
38using RNTupleFillContext = ROOT::RNTupleFillContext;
39using RNTParaWriter = ROOT::RNTupleParallelWriter;
40
42public:
43 TMCRNTupleParallelWriter(const char *storageName, TFile* file, Bool_t workerMode);
45 virtual ~TMCRNTupleParallelWriter() = default;
46
47 template <typename T>
48 void Register(const char *name, T *&obj);
49
50 // Standard virtual interface for the rest of the lifecycle
51 virtual void CreateRNTuple() override;
52 virtual void Fill() override;
53 virtual void WriteAll() override;
54 virtual void Close() override;
55
56private:
57 // static data members
58 static std::shared_ptr<RNTParaWriter> fgParaWriter;
59
60 // data members
61 std::unique_ptr<RNTuple> fRNTuple;
62 std::vector<std::pair<std::string, void *>> fNameAddress;
63 std::unique_ptr<REntry> fEntry;
64 std::unique_ptr<RNTupleModel> fModel;
65 std::shared_ptr<RNTupleFillContext> fFillContext;
66};
67
68template <typename T>
69void TMCRNTupleParallelWriter::Register(const char *brname, T *&obj)
70{
71 if (fModel) {
72 fModel->MakeField<T>(brname);
73 }
74 fNameAddress.push_back(std::make_pair(std::string(brname), obj));
75}
76
77#endif // ROOT_VERSION_CODE
78
79#endif // ROOT_TMCRNTupleParallelWriter
ROOT::REntry REntry
ROOT::RNTupleParallelWriter RNTParaWriter
ROOT::RNTupleModel RNTupleModel
ROOT::RNTupleFillContext RNTupleFillContext
Definition of the TMCVNtupleWriter class.
std::shared_ptr< RNTupleFillContext > fFillContext
std::unique_ptr< REntry > fEntry
void Register(const char *name, T *&obj)
std::unique_ptr< RNTuple > fRNTuple
virtual ~TMCRNTupleParallelWriter()=default
static std::shared_ptr< RNTParaWriter > fgParaWriter
std::vector< std::pair< std::string, void * > > fNameAddress
virtual void CreateRNTuple() override
std::unique_ptr< RNTupleModel > fModel
TMCRNTupleParallelWriter(const char *storageName, TFile *file, Bool_t workerMode)
TMCVNtupleWriter(const char *storageName, TFile *file, Bool_t workerMode)