CMS 3D CMS Logo

List of all members | Public Member Functions | Static Public Member Functions | Private Types | Private Member Functions | Private Attributes | Static Private Attributes
RntDumper Class Reference

#include <RntDumper.h>

Public Member Functions

std::unique_ptr< RNTupleModelCreateModel ()
 
TFile * file ()
 
void RegisterTree (TTree *t)
 
RNTupleWriterWritifyModel (std::unique_ptr< RNTupleModel > &model, std::string_view mname)
 

Static Public Member Functions

static RntDumperCreate (const char *fname)
 
static void FinalizeAll ()
 

Private Types

using RNTupleModel = ROOT::Experimental::RNTupleModel
 
using RNTupleWriter = ROOT::Experimental::RNTupleWriter
 

Private Member Functions

 RntDumper (const char *fname)
 
 ~RntDumper ()
 

Private Attributes

std::unique_ptr< TFile > m_file
 
std::vector< TTree * > m_trees
 
std::unordered_map< std::string, std::unique_ptr< RNTupleWriter > > m_writers
 

Static Private Attributes

static std::vector< RntDumper * > s_instances
 

Detailed Description

Definition at line 17 of file RntDumper.h.

Member Typedef Documentation

◆ RNTupleModel

using RntDumper::RNTupleModel = ROOT::Experimental::RNTupleModel
private

Definition at line 18 of file RntDumper.h.

◆ RNTupleWriter

using RntDumper::RNTupleWriter = ROOT::Experimental::RNTupleWriter
private

Definition at line 19 of file RntDumper.h.

Constructor & Destructor Documentation

◆ RntDumper()

RntDumper::RntDumper ( const char *  fname)
explicitprivate

Definition at line 15 of file RntDumper.cc.

References alignmentValidation::fname, and m_file.

Referenced by Create().

15  : m_file(TFile::Open(fname, "recreate")) {
16  if (!m_file || !m_file->IsOpen()) {
17  printf("RntDumper::RntDumper() failed creeating file '%s'.\n", fname);
18  throw std::runtime_error("Failed creating file");
19  }
20  printf("RntDumper::RntDumper() succesfully opened file '%s'.\n", fname);
21 }
std::unique_ptr< TFile > m_file
Definition: RntDumper.h:36
string fname
main script

◆ ~RntDumper()

RntDumper::~RntDumper ( )
private

Definition at line 23 of file RntDumper.cc.

References m_file, m_trees, m_writers, and cmsswSequenceInfo::tp.

23  {
24  printf("RntDumper::~RntDumper() destroying writers and closing file '%s'.\n", m_file->GetName());
25  // Finish up trees first, ntuple-writers seem to write everything reulting
26  // in two cycles of trees.
27  for (auto &tp : m_trees) {
28  tp->Write();
29  delete tp;
30  }
31  m_trees.clear();
32  m_writers.clear();
33  if (m_file) {
34  m_file->Close();
35  }
36 }
std::unique_ptr< TFile > m_file
Definition: RntDumper.h:36
std::unordered_map< std::string, std::unique_ptr< RNTupleWriter > > m_writers
Definition: RntDumper.h:37
std::vector< TTree * > m_trees
Definition: RntDumper.h:38

Member Function Documentation

◆ Create()

RntDumper * RntDumper::Create ( const char *  fname)
static

Definition at line 51 of file RntDumper.cc.

References ztail::d, alignmentValidation::fname, RntDumper(), and s_instances.

51  {
52  // Should check fnames ?
53  RntDumper *d = new RntDumper(fname);
54  s_instances.push_back(d);
55  return d;
56 }
RntDumper(const char *fname)
Definition: RntDumper.cc:15
static std::vector< RntDumper * > s_instances
Definition: RntDumper.h:40
d
Definition: ztail.py:151
string fname
main script

◆ CreateModel()

std::unique_ptr< REX::RNTupleModel > RntDumper::CreateModel ( )

Definition at line 38 of file RntDumper.cc.

38 { return RNTupleModel::Create(); }

◆ file()

TFile* RntDumper::file ( )
inline

Definition at line 30 of file RntDumper.h.

References m_file.

30 { return m_file.get(); }
std::unique_ptr< TFile > m_file
Definition: RntDumper.h:36

◆ FinalizeAll()

void RntDumper::FinalizeAll ( )
static

Definition at line 58 of file RntDumper.cc.

References ztail::d, and s_instances.

Referenced by main().

58  {
59  printf("RntDumper::FinalizeAll() shutting down %d instances.\n", (int)s_instances.size());
60  for (auto &d : s_instances)
61  delete d;
62 }
static std::vector< RntDumper * > s_instances
Definition: RntDumper.h:40
d
Definition: ztail.py:151

◆ RegisterTree()

void RntDumper::RegisterTree ( TTree *  t)

Definition at line 47 of file RntDumper.cc.

References m_trees, and submitPVValidationJobs::t.

47 { m_trees.push_back(t); }
std::vector< TTree * > m_trees
Definition: RntDumper.h:38

◆ WritifyModel()

REX::RNTupleWriter * RntDumper::WritifyModel ( std::unique_ptr< RNTupleModel > &  model,
std::string_view  mname 
)

Definition at line 40 of file RntDumper.cc.

References m_file, m_writers, ReggeGribovPartonMC_EposLHC_2760GeV_PbPb_cfi::model, eostools::move(), AlCaHLTBitMon_QueryRunRegistry::string, and w().

40  {
41  auto wup = RNTupleWriter::Append(std::move(model), mname, *m_file);
42  REX::RNTupleWriter *w = wup.get();
43  m_writers.insert({std::string(mname), std::move(wup)});
44  return w;
45 }
std::unique_ptr< TFile > m_file
Definition: RntDumper.h:36
std::unordered_map< std::string, std::unique_ptr< RNTupleWriter > > m_writers
Definition: RntDumper.h:37
T w() const
def move(src, dest)
Definition: eostools.py:511

Member Data Documentation

◆ m_file

std::unique_ptr<TFile> RntDumper::m_file
private

Definition at line 36 of file RntDumper.h.

Referenced by file(), RntDumper(), WritifyModel(), and ~RntDumper().

◆ m_trees

std::vector<TTree *> RntDumper::m_trees
private

Definition at line 38 of file RntDumper.h.

Referenced by RegisterTree(), and ~RntDumper().

◆ m_writers

std::unordered_map<std::string, std::unique_ptr<RNTupleWriter> > RntDumper::m_writers
private

Definition at line 37 of file RntDumper.h.

Referenced by WritifyModel(), and ~RntDumper().

◆ s_instances

std::vector< RntDumper * > RntDumper::s_instances
staticprivate

Definition at line 40 of file RntDumper.h.

Referenced by Create(), and FinalizeAll().