g4tools  5.4.0
base_pntuple
Go to the documentation of this file.
1 // Copyright (C) 2010, Guy Barrand. All rights reserved.
2 // See the file tools.license for terms.
3 
4 #ifndef tools_wroot_base_pntuple
5 #define tools_wroot_base_pntuple
6 
7 // pntuple = for parallel ntupling.
8 
9 #include "branch_element"
10 #include "icol"
11 
12 #include "../vfind"
13 
14 #ifdef TOOLS_MEM
15 #include "../mem"
16 #endif
17 
18 namespace tools {
19 namespace wroot {
20 
21 class base_pntuple {
22 #ifdef TOOLS_MEM
23  static const std::string& s_class() {
24  static const std::string s_v("tools::wroot::base_pntuple");
25  return s_v;
26  }
27 #endif
28 public:
29 
30 #include "columns.icc"
31 
32 public:
33  base_pntuple(std::ostream& a_out,seek a_seek_directory,const std::string& a_name,const std::string& a_title)
34  :m_out(a_out)
35  ,m_seek_directory(a_seek_directory)
36  ,m_name(a_name)
37  ,m_title(a_title)
38  {
39 #ifdef TOOLS_MEM
40  mem::increment(s_class().c_str());
41 #endif
42  }
43 
44  virtual ~base_pntuple() {
45  safe_clear<icol>(m_cols);
46 #ifdef TOOLS_MEM
47  mem::decrement(s_class().c_str());
48 #endif
49  }
50 protected:
51  base_pntuple(const base_pntuple& a_from):m_out(a_from.m_out){
52 #ifdef TOOLS_MEM
53  mem::increment(s_class().c_str());
54 #endif
55  }
56  base_pntuple& operator=(const base_pntuple&){return *this;}
57 public:
58  const std::vector<icol*>& columns() const {return m_cols;}
59 
60  template <class T>
61  column_ref<T>* find_column_ref(const std::string& a_name) {
62  icol* col = find_named<icol>(m_cols,a_name);
63  if(!col) return 0;
64  return id_cast<icol, column_ref<T> >(*col);
65  }
66 
67  template <class T>
68  column<T>* find_column(const std::string& a_name) {
69  icol* col = find_named<icol>(m_cols,a_name);
70  if(!col) return 0;
71  return id_cast<icol, column<T> >(*col);
72  }
73 
74  column_string_ref* find_column_string_ref(const std::string& a_name) {
75  icol* col = find_named<icol>(m_cols,a_name);
76  if(!col) return 0;
77  return id_cast<icol, column_string_ref >(*col);
78  }
79 
80  column_string* find_column_string(const std::string& a_name) {
81  icol* col = find_named<icol>(m_cols,a_name);
82  if(!col) return 0;
83  return id_cast<icol, column_string >(*col);
84  }
85 
86  template <class T>
87  std_vector_column_ref<T>* find_column_vector_ref(const std::string& a_name) {
88  icol* col = find_named<icol>(m_cols,a_name);
89  if(!col) return 0;
90  return id_cast<icol, std_vector_column_ref<T> >(*col);
91  }
92 
93  template <class T>
94  std_vector_column<T>* find_column_vector(const std::string& a_name) {
95  icol* col = find_named<icol>(m_cols,a_name);
96  if(!col) return 0;
97  return id_cast<icol, std_vector_column<T> >(*col);
98  }
99 
100  column_vector_string_ref* find_column_vector_string_ref(const std::string& a_name) {
101  icol* col = find_named<icol>(m_cols,a_name);
102  if(!col) return 0;
103  return id_cast<icol, column_vector_string_ref >(*col);
104  }
105 
106  column_vector_string* find_column_vector_string(const std::string& a_name) {
107  icol* col = find_named<icol>(m_cols,a_name);
108  if(!col) return 0;
109  return id_cast<icol, column_vector_string >(*col);
110  }
111 
112  void print_columns(std::ostream& a_out) {
113  a_out << "for ntuple named " << sout(m_name) << ", number of columns " << m_cols.size() << " :" << std::endl;
114  tools_vforit(icol*,m_cols,it) {
115  a_out << " " << (*it)->name() << std::endl;
116  }
117  }
118 
119  //void set_basket_size(uint32 a_size) {tools_vforit(icol*,m_cols,it) (*it)->set_basket_size(a_size);}
120 
121 protected:
122  std::ostream& m_out;
124  std::string m_name;
125  std::string m_title;
126  std::vector<icol*> m_cols;
127 };
128 
129 }}
130 
131 #endif
tools::wroot::seek
int64 seek
Definition: seek:16
tools::wroot::icol
Definition: icol:21
tools::wroot::base_pntuple::m_title
std::string m_title
Definition: base_pntuple:125
tools::wroot::base_pntuple::find_column_vector_ref
std_vector_column_ref< T > * find_column_vector_ref(const std::string &a_name)
Definition: base_pntuple:87
tools::wroot::base_pntuple::find_column_string_ref
column_string_ref * find_column_string_ref(const std::string &a_name)
Definition: base_pntuple:74
tools::wroot::base_pntuple::m_name
std::string m_name
Definition: base_pntuple:124
tools::wroot::base_pntuple::find_column_string
column_string * find_column_string(const std::string &a_name)
Definition: base_pntuple:80
tools::wroot::base_pntuple::m_out
std::ostream & m_out
Definition: base_pntuple:122
tools::wroot::base_pntuple::find_column_ref
column_ref< T > * find_column_ref(const std::string &a_name)
Definition: base_pntuple:61
branch_element
tools::wroot::base_pntuple::print_columns
void print_columns(std::ostream &a_out)
Definition: base_pntuple:112
tools::wroot::base_pntuple::operator=
base_pntuple & operator=(const base_pntuple &)
Definition: base_pntuple:56
tools::wroot::base_pntuple::find_column_vector
std_vector_column< T > * find_column_vector(const std::string &a_name)
Definition: base_pntuple:94
tools::wroot::base_pntuple::columns
const std::vector< icol * > & columns() const
Definition: base_pntuple:58
tools::sout
Definition: sout:17
tools::wroot::base_pntuple::find_column_vector_string
column_vector_string * find_column_vector_string(const std::string &a_name)
Definition: base_pntuple:106
tools::wroot::base_pntuple::~base_pntuple
virtual ~base_pntuple()
Definition: base_pntuple:44
tools_vforit
#define tools_vforit(a__T, a__v, a__it)
Definition: forit:13
tools::wroot::base_pntuple::find_column
column< T > * find_column(const std::string &a_name)
Definition: base_pntuple:68
tools
inlined C code : ///////////////////////////////////
Definition: aida_ntuple:26
tools::wroot::base_pntuple
Definition: base_pntuple:21
tools::wroot::base_pntuple::base_pntuple
base_pntuple(const base_pntuple &a_from)
Definition: base_pntuple:51
tools::wroot::base_pntuple::m_seek_directory
seek m_seek_directory
Definition: base_pntuple:123
tools::wroot::base_pntuple::m_cols
std::vector< icol * > m_cols
Definition: base_pntuple:126
columns.icc
tools::wroot::base_pntuple::base_pntuple
base_pntuple(std::ostream &a_out, seek a_seek_directory, const std::string &a_name, const std::string &a_title)
Definition: base_pntuple:33
tools::wroot::base_pntuple::find_column_vector_string_ref
column_vector_string_ref * find_column_vector_string_ref(const std::string &a_name)
Definition: base_pntuple:100
icol