RootfileCreation.cxx
Go to the documentation of this file.
2 
3 #include "TFile.h"
4 
6 
9 
10 WIRECELL_FACTORY(RootfileCreation_frames, WireCell::Root::RootfileCreation_frames,
12 
13 
14 using namespace WireCell;
15 
17 }
18 
19 Root::RootfileCreation_depos::~RootfileCreation_depos(){
20 }
21 
22 
24 {
25  m_cfg = cfg;
26  create_file();
27 }
28 
30 {
32  cfg["output_filename"] = "";
33  cfg["root_file_mode"] = "RECREATE";
34  return cfg;
35 }
36 
38  WireCell::IDepo::pointer& outdepo)
39 {
40  outdepo = indepo;
41  if (!indepo) {
42  // eos
43  std::cerr << "RootfileCreation_depos: EOS\n";
44  return true;
45  }
46  return true;
47 }
48 
50  const std::string ofname = m_cfg["output_filename"].asString();
51  const std::string mode = m_cfg["root_file_mode"].asString();
52  TFile* output_tf = TFile::Open(ofname.c_str(), mode.c_str());
53  output_tf->Close("R");
54  delete output_tf;
55  output_tf = nullptr;
56 }
57 
58 
60 }
61 
63 }
64 
65 
67 {
68  m_cfg = cfg;
69  create_file();
70 }
71 
73 {
75  cfg["output_filename"] = "";
76  cfg["root_file_mode"] = "RECREATE";
77  return cfg;
78 }
79 
81  const std::string ofname = m_cfg["output_filename"].asString();
82  const std::string mode = m_cfg["root_file_mode"].asString();
83 
84  // std::cout << "Xin: " << ofname << std::endl;
85 
86  TFile* output_tf = TFile::Open(ofname.c_str(), mode.c_str());
87  output_tf->Close("R");
88  delete output_tf;
89  output_tf = nullptr;
90 }
91 
92 
94  out = in;
95  if (!in) {
96  // eos
97  std::cerr << "RootfileCreation_frames: EOS\n";
98  return true;
99  }
100  return true;
101 }
102 
WIRECELL_FACTORY(RootfileCreation_depos, WireCell::Root::RootfileCreation_depos, WireCell::IDepoFilter, WireCell::IConfigurable) WIRECELL_FACTORY(RootfileCreation_frames
std::shared_ptr< const IDepo > pointer
Definition: IData.h:19
std::string string
Definition: nybbler.cc:12
virtual bool operator()(const IFrame::pointer &in, IFrame::pointer &out)
The calling signature:
virtual void configure(const WireCell::Configuration &config)
Accept a configuration.
virtual bool operator()(const WireCell::IDepo::pointer &indepo, WireCell::IDepo::pointer &outdepo)
The calling signature:
cfg
Definition: dbjson.py:29
virtual void configure(const WireCell::Configuration &config)
Accept a configuration.
virtual WireCell::Configuration default_configuration() const
IConfigurable.
Definition: Main.h:22
Json::Value Configuration
Definition: Configuration.h:50
virtual WireCell::Configuration default_configuration() const
IConfigurable.