g4tools  5.4.0
Classes | Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
tools::wroot::base_pntuple_column_wise Class Reference
Inheritance diagram for tools::wroot::base_pntuple_column_wise:
Inheritance graph
[legend]
Collaboration diagram for tools::wroot::base_pntuple_column_wise:
Collaboration graph
[legend]

Classes

class  file
 

Public Member Functions

 base_pntuple_column_wise (std::ostream &a_out, bool a_byte_swap, uint32 a_compression, seek a_seek_directory, const std::string &a_name, const std::string &a_title, bool a_verbose)
 
 base_pntuple_column_wise (std::ostream &a_out, bool a_byte_swap, uint32 a_compression, seek a_seek_directory, const std::vector< uint32 > &a_basket_sizes, const ntuple_booking &a_bkg, bool a_verbose)
 
virtual ~base_pntuple_column_wise ()
 
template<class T >
column_ref< T > * create_column_ref (uint32 a_basket_size, const std::string &a_name, const T &a_ref)
 
template<class T >
column< T > * create_column (uint32 a_basket_size, const std::string &a_name, const T &a_def=T())
 
column_string_ref * create_column_string_ref (uint32 a_basket_size, const std::string &a_name, const std::string &a_ref)
 
column_string * create_column_string (uint32 a_basket_size, const std::string &a_name, const std::string &a_def=std::string())
 
column_vector_string_ref * create_column_vector_string_ref (uint32 a_basket_size, const std::string &a_name, const std::vector< std::string > &a_ref, char a_sep)
 
column_vector_string * create_column_vector_string (uint32 a_basket_size, const std::string &a_name, const std::vector< std::string > &a_def, char a_sep)
 
template<class T >
std_vector_column_ref< T > * create_column_vector_ref (uint32 a_basket_size, const std::string &a_name, const std::vector< T > &a_ref)
 
template<class T >
std_vector_column< T > * create_column_vector (uint32 a_basket_size, const std::string &a_name, const std::vector< T > &a_def=std::vector< T >())
 
- Public Member Functions inherited from tools::wroot::base_pntuple
 base_pntuple (std::ostream &a_out, seek a_seek_directory, const std::string &a_name, const std::string &a_title)
 
virtual ~base_pntuple ()
 
const std::vector< icol * > & columns () const
 
template<class T >
column_ref< T > * find_column_ref (const std::string &a_name)
 
template<class T >
column< T > * find_column (const std::string &a_name)
 
column_string_ref * find_column_string_ref (const std::string &a_name)
 
column_string * find_column_string (const std::string &a_name)
 
template<class T >
std_vector_column_ref< T > * find_column_vector_ref (const std::string &a_name)
 
template<class T >
std_vector_column< T > * find_column_vector (const std::string &a_name)
 
column_vector_string_ref * find_column_vector_string_ref (const std::string &a_name)
 
column_vector_string * find_column_vector_string (const std::string &a_name)
 
void print_columns (std::ostream &a_out)
 

Protected Member Functions

 base_pntuple_column_wise (const base_pntuple_column_wise &a_from)
 
base_pntuple_column_wiseoperator= (const base_pntuple_column_wise &)
 
- Protected Member Functions inherited from tools::wroot::base_pntuple
 base_pntuple (const base_pntuple &a_from)
 
base_pntupleoperator= (const base_pntuple &)
 

Protected Attributes

file m_file
 
std::vector< branch * > m_branches
 
- Protected Attributes inherited from tools::wroot::base_pntuple
std::ostream & m_out
 
seek m_seek_directory
 
std::string m_name
 
std::string m_title
 
std::vector< icol * > m_cols
 

Detailed Description

Definition at line 20 of file base_pntuple_column_wise.

Constructor & Destructor Documentation

◆ base_pntuple_column_wise() [1/3]

tools::wroot::base_pntuple_column_wise::base_pntuple_column_wise ( std::ostream &  a_out,
bool  a_byte_swap,
uint32  a_compression,
seek  a_seek_directory,
const std::string &  a_name,
const std::string &  a_title,
bool  a_verbose 
)
inline

Definition at line 53 of file base_pntuple_column_wise.

55  :parent(a_out,a_seek_directory,a_name,a_title)
56  ,m_file(a_out,a_byte_swap,a_compression,a_verbose)
57  {}

◆ base_pntuple_column_wise() [2/3]

tools::wroot::base_pntuple_column_wise::base_pntuple_column_wise ( std::ostream &  a_out,
bool  a_byte_swap,
uint32  a_compression,
seek  a_seek_directory,
const std::vector< uint32 > &  a_basket_sizes,
const ntuple_booking a_bkg,
bool  a_verbose 
)
inline

Definition at line 58 of file base_pntuple_column_wise.

61  :parent(a_out,a_seek_directory,a_bkg.name(),a_bkg.title())
62  ,m_file(a_out,a_byte_swap,a_compression,a_verbose)
63  {
64  const std::vector<column_booking>& cols = a_bkg.columns();
65 
66  if(a_basket_sizes.size()!=cols.size()) {
67  a_out << "tools::wroot::base_pntuple_column_wise :"
68  << " a_basket_sizes.size() (" << a_basket_sizes.size() << ") != "
69  << "a_bkg.columns().size() (" << a_bkg.columns().size() << ")."
70  << std::endl;
71  return;
72  }
73  std::vector<uint32>::const_iterator itb = a_basket_sizes.begin();
74 
75  tools_vforcit(column_booking,cols,it){
76 
77 #define TOOLS_WROOT_PNTUPLE_CREATE_COL(a__type) \
78  if((*it).cls_id()==_cid(a__type())) {\
79  a__type* user = (a__type*)(*it).user_obj();\
80  if(user) {\
81  if(!create_column_ref<a__type>(*itb,(*it).name(),*user)) {\
82  a_out << "tools::wroot::base_pntuple_column_wise : create_column_ref(" << (*it).name() << ") failed." << std::endl;\
83  safe_clear<icol>(m_cols);\
84  safe_clear<branch>(m_branches);\
85  return;\
86  }\
87  itb++;\
88  } else {\
89  if(!create_column<a__type>(*itb,(*it).name())) {\
90  a_out << "tools::wroot::base_pntuple_column_wise : create_column(" << (*it).name() << ") failed." << std::endl;\
91  safe_clear<icol>(m_cols);\
92  safe_clear<branch>(m_branches);\
93  return;\
94  }\
95  itb++;\
96  }\
97  }
98 
99 #define TOOLS_WROOT_PNTUPLE_CREATE_VEC_COL(a__type) \
100  if((*it).cls_id()==_cid_std_vector<a__type>()) {\
101  std::vector<a__type>* vec = (std::vector<a__type>*)(*it).user_obj();\
102  if(vec) {\
103  if(!create_column_vector_ref<a__type>(*itb,(*it).name(),*vec)) {\
104  a_out << "tools::wroot::base_pntuple_column_wise :"\
105  << " create_column failed for std::vector column_ref " << sout((*it).name()) << "."\
106  << std::endl;\
107  safe_clear<icol>(m_cols);\
108  safe_clear<branch>(m_branches);\
109  return;\
110  }\
111  itb++;\
112  } else {\
113  if(!create_column_vector<a__type>(*itb,(*it).name())) {\
114  a_out << "tools::wroot::base_pntuple_column_wise :"\
115  << " create_column failed for std::vector column " << sout((*it).name()) << "."\
116  << std::endl;\
117  safe_clear<icol>(m_cols);\
118  safe_clear<branch>(m_branches);\
119  return;\
120  }\
121  itb++;\
122  }\
123  }
124 
129  else TOOLS_WROOT_PNTUPLE_CREATE_COL(double)
130 
131  else if((*it).cls_id()==_cid(std::string())) {
132  std::string* user = (std::string*)(*it).user_obj();
133  if(user) {
134  if(!create_column_string_ref(*itb,(*it).name(),*user)) {
135  a_out << "tools::wroot::base_pntuple_column_wise : create_column_string_ref(" << (*it).name() << ") failed."
136  << std::endl;
137  safe_clear<icol>(m_cols);
138  safe_clear<branch>(m_branches);
139  return;
140  }
141  itb++;
142  } else {
143  if(!create_column_string(*itb,(*it).name())) {
144  a_out << "tools::wroot::base_pntuple_column_wise : create_column_string(" << (*it).name() << ") failed." << std::endl;
145  safe_clear<icol>(m_cols);
146  safe_clear<branch>(m_branches);
147  return;
148  }
149  itb++;
150  }
151  }
152 
158 
159  else if((*it).cls_id()==_cid_std_vector<std::string>()) {\
160  std::vector<std::string>* user = (std::vector<std::string>*)(*it).user_obj();
161  char sep = '\n';
162  if(user) {
163  if(!create_column_vector_string_ref(*itb,(*it).name(),*user,sep)) {
164  a_out << "tools::wroot::base_pntuple_column_wise :"
165  << " create_column_vector_string_ref(" << (*it).name() << ") failed." << std::endl;
166  safe_clear<icol>(m_cols);
167  safe_clear<branch>(m_branches);
168  return;
169  }
170  itb++;
171  } else {
172  if(!create_column_vector_string(*itb,(*it).name(),std::vector<std::string>(),sep)) {
173  a_out << "tools::wroot::base_pntuple_column_wise :"
174  << " create_column_vector_string(" << (*it).name() << ") failed." << std::endl;
175  safe_clear<icol>(m_cols);
176  safe_clear<branch>(m_branches);
177  return;
178  }
179  itb++;
180  }
181  }
182 
183  // no leaf_store_class() defined for the other types.
184 
185  else {
186  a_out << "tools::wroot::base_pntuple_column_wise :"
187  << " for column " << sout((*it).name())
188  << ", type with cid " << (*it).cls_id() << " not yet handled."
189  << std::endl;
190  //throw
191  safe_clear<icol>(m_cols);
192  safe_clear<branch>(m_branches);
193  return;
194  }
195 
196 #undef TOOLS_WROOT_PNTUPLE_CREATE_COL
197 #undef TOOLS_WROOT_PNTUPLE_CREATE_VEC_COL
198 
199  }
200  }

◆ ~base_pntuple_column_wise()

virtual tools::wroot::base_pntuple_column_wise::~base_pntuple_column_wise ( )
inlinevirtual

Definition at line 202 of file base_pntuple_column_wise.

202 {safe_clear<branch>(m_branches);}

◆ base_pntuple_column_wise() [3/3]

tools::wroot::base_pntuple_column_wise::base_pntuple_column_wise ( const base_pntuple_column_wise a_from)
inlineprotected

Definition at line 204 of file base_pntuple_column_wise.

204 :parent(a_from),m_file(a_from.m_file){}

Member Function Documentation

◆ create_column()

template<class T >
column<T>* tools::wroot::base_pntuple_column_wise::create_column ( uint32  a_basket_size,
const std::string &  a_name,
const T &  a_def = T() 
)
inline

Definition at line 221 of file base_pntuple_column_wise.

221  {
222  if(find_named<icol>(m_cols,a_name)) return 0;
223  branch* _branch = new branch(m_file.out(),m_file.byte_swap(),m_file.compression(),
225  _branch->set_basket_size(a_basket_size);
226  column<T>* col = new column<T>(*_branch,a_name,a_def);
227  if(!col) {delete _branch;return 0;}
228  m_branches.push_back(_branch);
229  m_cols.push_back(col);
230  return col;
231  }

◆ create_column_ref()

template<class T >
column_ref<T>* tools::wroot::base_pntuple_column_wise::create_column_ref ( uint32  a_basket_size,
const std::string &  a_name,
const T &  a_ref 
)
inline

Definition at line 208 of file base_pntuple_column_wise.

208  {
209  if(find_named<icol>(m_cols,a_name)) return 0;
210  branch* _branch = new branch(m_file.out(),m_file.byte_swap(),m_file.compression(),
212  _branch->set_basket_size(a_basket_size);
213  column_ref<T>* col = new column_ref<T>(*_branch,a_name,a_ref);
214  if(!col) {delete _branch;return 0;}
215  m_branches.push_back(_branch);
216  m_cols.push_back(col);
217  return col;
218  }

◆ create_column_string()

column_string* tools::wroot::base_pntuple_column_wise::create_column_string ( uint32  a_basket_size,
const std::string &  a_name,
const std::string &  a_def = std::string() 
)
inline

Definition at line 245 of file base_pntuple_column_wise.

247  {
248  if(find_named<icol>(m_cols,a_name)) return 0;
249  branch* _branch = new branch(m_file.out(),m_file.byte_swap(),m_file.compression(),
251  _branch->set_basket_size(a_basket_size);
252  column_string* col = new column_string(*_branch,a_name,a_def);
253  if(!col) {delete _branch;return 0;}
254  m_branches.push_back(_branch);
255  m_cols.push_back(col);
256  return col;
257  }

◆ create_column_string_ref()

column_string_ref* tools::wroot::base_pntuple_column_wise::create_column_string_ref ( uint32  a_basket_size,
const std::string &  a_name,
const std::string &  a_ref 
)
inline

Definition at line 233 of file base_pntuple_column_wise.

233  {
234  if(find_named<icol>(m_cols,a_name)) return 0;
235  branch* _branch = new branch(m_file.out(),m_file.byte_swap(),m_file.compression(),
237  _branch->set_basket_size(a_basket_size);
238  column_string_ref* col = new column_string_ref(*_branch,a_name,a_ref);
239  if(!col) {delete _branch;return 0;}
240  m_branches.push_back(_branch);
241  m_cols.push_back(col);
242  return col;
243  }

◆ create_column_vector()

template<class T >
std_vector_column<T>* tools::wroot::base_pntuple_column_wise::create_column_vector ( uint32  a_basket_size,
const std::string &  a_name,
const std::vector< T > &  a_def = std::vector<T>() 
)
inline

Definition at line 300 of file base_pntuple_column_wise.

300  {
301  if(find_named<icol>(m_cols,a_name)) return 0;
302  std_vector_be_pointer<T>* _branch = new std_vector_be_pointer<T>(m_file.out(),m_file.byte_swap(),m_file.compression(),
304  _branch->set_basket_size(a_basket_size);
305  std_vector_column<T>* col = new std_vector_column<T>(*_branch,a_name,a_def);
306  if(!col) {delete _branch;return 0;}
307  _branch->set_pointer(&(col->variable()));
308  m_branches.push_back(_branch);
309  m_cols.push_back(col);
310  return col;
311  }

◆ create_column_vector_ref()

template<class T >
std_vector_column_ref<T>* tools::wroot::base_pntuple_column_wise::create_column_vector_ref ( uint32  a_basket_size,
const std::string &  a_name,
const std::vector< T > &  a_ref 
)
inline

Definition at line 287 of file base_pntuple_column_wise.

287  {
288  if(find_named<icol>(m_cols,a_name)) return 0;
289  std_vector_be_ref<T>* _branch = new std_vector_be_ref<T>(m_file.out(),m_file.byte_swap(),m_file.compression(),
290  m_seek_directory,a_name,m_name,a_ref,m_file.verbose());
291  _branch->set_basket_size(a_basket_size);
292  std_vector_column_ref<T>* col = new std_vector_column_ref<T>(*_branch,a_name,a_ref);
293  if(!col) {delete _branch;return 0;}
294  m_branches.push_back(_branch);
295  m_cols.push_back(col);
296  return col;
297  }

◆ create_column_vector_string()

column_vector_string* tools::wroot::base_pntuple_column_wise::create_column_vector_string ( uint32  a_basket_size,
const std::string &  a_name,
const std::vector< std::string > &  a_def,
char  a_sep 
)
inline

Definition at line 272 of file base_pntuple_column_wise.

274  {
275  if(find_named<icol>(m_cols,a_name)) return 0;
276  branch* _branch = new branch(m_file.out(),m_file.byte_swap(),m_file.compression(),
278  _branch->set_basket_size(a_basket_size);
279  column_vector_string* col = new column_vector_string(*_branch,a_name,a_def,a_sep);
280  if(!col) {delete _branch;return 0;}
281  m_branches.push_back(_branch);
282  m_cols.push_back(col);
283  return col;
284  }

◆ create_column_vector_string_ref()

column_vector_string_ref* tools::wroot::base_pntuple_column_wise::create_column_vector_string_ref ( uint32  a_basket_size,
const std::string &  a_name,
const std::vector< std::string > &  a_ref,
char  a_sep 
)
inline

Definition at line 259 of file base_pntuple_column_wise.

260  {
261  if(find_named<icol>(m_cols,a_name)) return 0;
262  branch* _branch = new branch(m_file.out(),m_file.byte_swap(),m_file.compression(),
264  _branch->set_basket_size(a_basket_size);
265  column_vector_string_ref* col = new column_vector_string_ref(*_branch,a_name,a_ref,a_sep);
266  if(!col) {delete _branch;return 0;}
267  m_branches.push_back(_branch);
268  m_cols.push_back(col);
269  return col;
270  }

◆ operator=()

base_pntuple_column_wise& tools::wroot::base_pntuple_column_wise::operator= ( const base_pntuple_column_wise )
inlineprotected

Definition at line 205 of file base_pntuple_column_wise.

205 {return *this;}

Member Data Documentation

◆ m_branches

std::vector<branch*> tools::wroot::base_pntuple_column_wise::m_branches
protected

Definition at line 314 of file base_pntuple_column_wise.

◆ m_file

file tools::wroot::base_pntuple_column_wise::m_file
protected

Definition at line 313 of file base_pntuple_column_wise.


The documentation for this class was generated from the following file:
tools::_cid
cid _cid(byte)
Definition: cids:14
TOOLS_WROOT_PNTUPLE_CREATE_VEC_COL
#define TOOLS_WROOT_PNTUPLE_CREATE_VEC_COL(a__type)
tools::wroot::base_pntuple::m_name
std::string m_name
Definition: base_pntuple:124
TOOLS_WROOT_PNTUPLE_CREATE_COL
#define TOOLS_WROOT_PNTUPLE_CREATE_COL(a__type)
tools::wroot::base_pntuple_column_wise::create_column_vector_string_ref
column_vector_string_ref * create_column_vector_string_ref(uint32 a_basket_size, const std::string &a_name, const std::vector< std::string > &a_ref, char a_sep)
Definition: base_pntuple_column_wise:259
tools::wroot::base_pntuple_column_wise::m_file
file m_file
Definition: base_pntuple_column_wise:313
tools::wroot::base_pntuple_column_wise::file::compression
uint32 compression() const
Definition: base_pntuple_column_wise:44
tools::wroot::base_pntuple_column_wise::file::byte_swap
bool byte_swap() const
Definition: base_pntuple_column_wise:43
tools::wroot::base_pntuple_column_wise::m_branches
std::vector< branch * > m_branches
Definition: base_pntuple_column_wise:314
tools::wroot::base_pntuple::m_seek_directory
seek m_seek_directory
Definition: base_pntuple:123
tools::wroot::base_pntuple_column_wise::create_column_string
column_string * create_column_string(uint32 a_basket_size, const std::string &a_name, const std::string &a_def=std::string())
Definition: base_pntuple_column_wise:245
tools::wroot::base_pntuple_column_wise::create_column_string_ref
column_string_ref * create_column_string_ref(uint32 a_basket_size, const std::string &a_name, const std::string &a_ref)
Definition: base_pntuple_column_wise:233
tools::wroot::base_pntuple::m_cols
std::vector< icol * > m_cols
Definition: base_pntuple:126
tools::wroot::base_pntuple_column_wise::create_column_vector_string
column_vector_string * create_column_vector_string(uint32 a_basket_size, const std::string &a_name, const std::vector< std::string > &a_def, char a_sep)
Definition: base_pntuple_column_wise:272
tools::sep
const std::string & sep()
Definition: sep:11
tools_vforcit
#define tools_vforcit(a__T, a__v, a__it)
Definition: forit:7
tools::wroot::base_pntuple_column_wise::file::verbose
bool verbose() const
Definition: base_pntuple_column_wise:41
tools::wroot::base_pntuple_column_wise::file::out
std::ostream & out() const
Definition: base_pntuple_column_wise:42