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

Public Member Functions

 ntuple (idir &a_dir, const std::string &a_name, const std::string &a_title, bool a_row_wise=false)
 
 ntuple (idir &a_dir, const ntuple_booking &a_bkg, bool a_row_wise=false)
 
virtual ~ntuple ()
 
const std::vector< icol * > & columns () const
 
std::vector< icol * > & columns ()
 
template<class T >
column_ref< T > * create_column_ref (const std::string &a_name, const T &a_ref)
 
template<class T >
column< T > * create_column (const std::string &a_name, const T &a_def=T())
 
column_string_ref * create_column_string_ref (const std::string &a_name, const std::string &a_ref)
 
column_string * create_column_string (const std::string &a_name, const std::string &a_def=std::string())
 
column_vector_string_ref * create_column_vector_string_ref (const std::string &a_name, const std::vector< std::string > &a_ref, char a_sep)
 
column_vector_string * create_column_vector_string (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 (const std::string &a_name, const std::vector< T > &a_ref)
 
template<class T >
std_vector_column< T > * create_column_vector (const std::string &a_name, const std::vector< T > &a_def=std::vector< T >())
 
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)
 
bool add_row ()
 
void set_basket_size (uint32 a_size)
 
branchget_row_wise_branch () const
 for parallelization : ///////////////////////////////////////////////// More...
 
void get_branches (std::vector< branch * > &a_vec) const
 
bool merge_number_of_entries ()
 
bool mpi_add_basket (impi &a_impi)
 
bool mpi_add_baskets (impi &a_impi)
 
bool mpi_end_fill (impi &a_impi)
 
- Public Member Functions inherited from tools::wroot::tree
virtual const std::string & name () const
 
virtual const std::string & title () const
 
virtual const std::string & store_class_name () const
 
virtual bool stream (buffer &a_buffer) const
 
virtual idirdir ()
 
virtual const idirdir () const
 
 tree (idir &a_dir, const std::string &a_name, const std::string &a_title, bool a_managed=true)
 
virtual ~tree ()
 
std::ostream & out () const
 
const std::vector< branch * > & branches () const
 
uint64 entries () const
 
branchcreate_branch (const std::string &a_name)
 
template<class TYPE >
leaf_ref< TYPE > * create_leaf_ref (const std::string &a_name, const TYPE &a_ref)
 ref : ////////////////////////////////////// More...
 
leaf_string_refcreate_leaf_string_ref (const std::string &a_name, const std::string &a_ref)
 
template<class T >
leaf_elementcreate_std_vector_leaf_ref (const std::string &a_name, const std::vector< T > &a_ref)
 
template<class T >
std_vector_be_ref< T > * create_std_vector_be_ref (const std::string &a_name, const std::vector< T > &a_ref)
 
template<class T >
std_vector_be< T > * create_std_vector_be (const std::string &a_name, const std::vector< T > &a_def=std::vector< T >())
 
template<class T >
std_vector_be_pointer< T > * create_std_vector_be_pointer (const std::string &a_name, std::vector< T > *a_pointer)
 
template<class TYPE >
leaf< TYPE > * create_leaf (const std::string &a_name)
 
leaf_objectcreate_leaf (const std::string &a_name, const iobject &a_obj)
 
bool fill (uint32 &a_nbytes)
 
void reset ()
 
- Public Member Functions inherited from tools::wroot::iobject
virtual ~iobject ()
 
- Public Member Functions inherited from tools::wroot::itree
virtual ~itree ()
 

Protected Member Functions

 ntuple (const ntuple &a_from)
 
ntupleoperator= (const ntuple &)
 
- Protected Member Functions inherited from tools::wroot::tree
 tree (const tree &a_from)
 
treeoperator= (const tree &)
 

Protected Attributes

std::vector< icol * > m_cols
 
bool m_row_wise
 
branchm_row_wise_branch
 
- Protected Attributes inherited from tools::wroot::tree
idirm_dir
 
std::ostream & m_out
 
std::string m_name
 
std::string m_title
 
obj_array< branchm_branches
 
uint64 m_entries
 
uint64 m_tot_bytes
 
uint64 m_zip_bytes
 

Detailed Description

Definition at line 31 of file ntuple.

Constructor & Destructor Documentation

◆ ntuple() [1/3]

tools::wroot::ntuple::ntuple ( idir a_dir,
const std::string &  a_name,
const std::string &  a_title,
bool  a_row_wise = false 
)
inline

Definition at line 39 of file ntuple.

40  :tree(a_dir,a_name,a_title),m_row_wise(a_row_wise),m_row_wise_branch(0)
41  {
42  if(m_row_wise) m_row_wise_branch = create_branch("row_wise_branch");
43  }

◆ ntuple() [2/3]

tools::wroot::ntuple::ntuple ( idir a_dir,
const ntuple_booking a_bkg,
bool  a_row_wise = false 
)
inline

Definition at line 45 of file ntuple.

46  :tree(a_dir,a_bkg.name(),a_bkg.title()),m_row_wise(a_row_wise),m_row_wise_branch(0)
47  {
48  if(m_row_wise) m_row_wise_branch = create_branch("row_wise_branch");
49 
50  const std::vector<column_booking>& cols = a_bkg.columns();
51  tools_vforcit(column_booking,cols,it){
52 
53 #define TOOLS_WROOT_NTUPLE_CREATE_COL(a__type) \
54  if((*it).cls_id()==_cid(a__type())) {\
55  a__type* user = (a__type*)(*it).user_obj();\
56  if(user) {\
57  if(!create_column_ref<a__type>((*it).name(),*user)) {\
58  m_out << "tools::wroot::ntuple : create_column_ref(" << (*it).name() << ") failed." << std::endl;\
59  safe_clear<icol>(m_cols);\
60  safe_clear<branch>(m_branches);\
61  return;\
62  }\
63  } else {\
64  if(!create_column<a__type>((*it).name())) {\
65  m_out << "tools::wroot::ntuple : create_column(" << (*it).name() << ") failed." << std::endl;\
66  safe_clear<icol>(m_cols);\
67  safe_clear<branch>(m_branches);\
68  return;\
69  }\
70  }\
71  }
72 
73 #define TOOLS_WROOT_NTUPLE_CREATE_VEC_COL(a__type) \
74  if((*it).cls_id()==_cid_std_vector<a__type>()) {\
75  std::vector<a__type>* vec = (std::vector<a__type>*)(*it).user_obj();\
76  if(vec) {\
77  if(!create_column_vector_ref<a__type>((*it).name(),*vec)) {\
78  m_out << "tools::wroot::ntuple : create_column_vector_ref(" << (*it).name() << ") failed." << std::endl;\
79  safe_clear<icol>(m_cols);\
80  safe_clear<branch>(m_branches);\
81  return;\
82  }\
83  } else {\
84  if(!create_column_vector<a__type>((*it).name())) {\
85  m_out << "tools::wroot::ntuple : create_column_vector(" << (*it).name() << ") failed." << std::endl;\
86  safe_clear<icol>(m_cols);\
87  safe_clear<branch>(m_branches);\
88  return;\
89  }\
90  }\
91  }
92 
93  //below types are in sync with rroot/ntuple.
94 
100 
101  else if((*it).cls_id()==_cid(std::string())) {
102  std::string* user = (std::string*)(*it).user_obj();
103  if(user) {
104  if(!create_column_string_ref((*it).name(),*user)) {
105  m_out << "tools::wroot::ntuple : create_column_string_ref(" << (*it).name() << ") failed." << std::endl;
106  safe_clear<icol>(m_cols);
107  safe_clear<branch>(m_branches);
108  return;
109  }
110  } else {
111  if(!create_column_string((*it).name())) {
112  m_out << "tools::wroot::ntuple : create_column_string(" << (*it).name() << ") failed." << std::endl;
113  safe_clear<icol>(m_cols);
114  safe_clear<branch>(m_branches);
115  return;
116  }
117  }
118  }
119 
125 
126  else if((*it).cls_id()==_cid_std_vector<std::string>()) {\
127  std::vector<std::string>* user = (std::vector<std::string>*)(*it).user_obj();
128  char sep = '\n';
129  if(user) {
130  if(!create_column_vector_string_ref((*it).name(),*user,sep)) {
131  m_out << "tools::wroot::ntuple : create_column_vector_string_ref(" << (*it).name() << ") failed." << std::endl;
132  safe_clear<icol>(m_cols);
133  safe_clear<branch>(m_branches);
134  return;
135  }
136  } else {
137  if(!create_column_vector_string((*it).name(),std::vector<std::string>(),sep)) {
138  m_out << "tools::wroot::ntuple : create_column_vector_string(" << (*it).name() << ") failed." << std::endl;
139  safe_clear<icol>(m_cols);
140  safe_clear<branch>(m_branches);
141  return;
142  }
143  }
144  }
145 
146  // no leaf_store_class() defined for the other types.
147 
148  else {
149  m_out << "tools::wroot::ntuple :"
150  << " for column " << sout((*it).name())
151  << ", type with cid " << (*it).cls_id() << " not yet handled."
152  << std::endl;
153  //throw
154  safe_clear<icol>(m_cols);
155  safe_clear<branch>(m_branches);
156  return;
157  }
158  }
159 #undef TOOLS_WROOT_NTUPLE_CREATE_VEC_COL
160 #undef TOOLS_WROOT_NTUPLE_CREATE_COL
161 
162  }

◆ ~ntuple()

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

Definition at line 164 of file ntuple.

164  {
165  safe_clear<icol>(m_cols);
166  }

◆ ntuple() [3/3]

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

Definition at line 168 of file ntuple.

168 :iobject(a_from),itree(a_from),tree(a_from),m_row_wise(a_from.m_row_wise){}

Member Function Documentation

◆ add_row()

bool tools::wroot::ntuple::add_row ( )
inline

Definition at line 328 of file ntuple.

328  {
329  if(m_cols.empty()) return false;
330  tools_vforit(icol*,m_cols,it) (*it)->add();
331  uint32 n;
332  bool status = tree::fill(n);
333  tools_vforit(icol*,m_cols,it) (*it)->set_def();
334  return status;
335  }

◆ columns() [1/2]

std::vector<icol*>& tools::wroot::ntuple::columns ( )
inline

Definition at line 172 of file ntuple.

172 {return m_cols;}

◆ columns() [2/2]

const std::vector<icol*>& tools::wroot::ntuple::columns ( ) const
inline

Definition at line 171 of file ntuple.

171 {return m_cols;}

◆ create_column()

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

Definition at line 186 of file ntuple.

186  {
187  if(find_named<icol>(m_cols,a_name)) return 0;
188  branch* _branch = m_row_wise?m_row_wise_branch:create_branch(a_name);
189  if(!_branch) return 0;
190  column<T>* col = new column<T>(*_branch,a_name,a_def);
191  if(!col) return 0;
192  m_cols.push_back(col);
193  return col;
194  }

◆ create_column_ref()

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

Definition at line 175 of file ntuple.

175  {
176  if(find_named<icol>(m_cols,a_name)) return 0;
177  branch* _branch = m_row_wise?m_row_wise_branch:create_branch(a_name);
178  if(!_branch) return 0;
179  column_ref<T>* col = new column_ref<T>(*_branch,a_name,a_ref);
180  if(!col) return 0;
181  m_cols.push_back(col);
182  return col;
183  }

◆ create_column_string()

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

Definition at line 206 of file ntuple.

206  {
207  if(find_named<icol>(m_cols,a_name)) return 0;
208  branch* _branch = m_row_wise?m_row_wise_branch:create_branch(a_name);
209  if(!_branch) return 0;
210  column_string* col = new column_string(*_branch,a_name,a_def);
211  if(!col) return 0;
212  m_cols.push_back(col);
213  return col;
214  }

◆ create_column_string_ref()

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

Definition at line 196 of file ntuple.

196  {
197  if(find_named<icol>(m_cols,a_name)) return 0;
198  branch* _branch = m_row_wise?m_row_wise_branch:create_branch(a_name);
199  if(!_branch) return 0;
200  column_string_ref* col = new column_string_ref(*_branch,a_name,a_ref);
201  if(!col) return 0;
202  m_cols.push_back(col);
203  return col;
204  }

◆ create_column_vector()

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

Definition at line 250 of file ntuple.

250  {
251  if(find_named<icol>(m_cols,a_name)) return 0;
252  if(m_row_wise) {
253  branch* _branch = m_row_wise_branch;
254  std_vector_column<T>* col = new std_vector_column<T>(*_branch,a_name,a_def);
255  if(!col) return 0;
256  m_cols.push_back(col);
257  return col;
258  } else {
259  std_vector_be_pointer<T>* _branch = create_std_vector_be_pointer<T>(a_name,0);
260  if(!_branch) return 0;
261  std_vector_column<T>* col = new std_vector_column<T>(*_branch,a_name,a_def);
262  if(!col) return 0;
263  _branch->set_pointer(&(col->variable()));
264  m_cols.push_back(col);
265  return col;
266  }
267  }

◆ create_column_vector_ref()

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

Definition at line 239 of file ntuple.

239  {
240  if(find_named<icol>(m_cols,a_name)) return 0;
241  branch* _branch = m_row_wise?m_row_wise_branch:create_std_vector_be_ref<T>(a_name,a_ref);
242  if(!_branch) return 0;
243  std_vector_column_ref<T>* col = new std_vector_column_ref<T>(*_branch,a_name,a_ref);
244  if(!col) return 0;
245  m_cols.push_back(col);
246  return col;
247  }

◆ create_column_vector_string()

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

Definition at line 227 of file ntuple.

228  {
229  if(find_named<icol>(m_cols,a_name)) return 0;
230  branch* _branch = m_row_wise?m_row_wise_branch:create_branch(a_name);
231  if(!_branch) return 0;
232  column_vector_string* col = new column_vector_string(*_branch,a_name,a_def,a_sep);
233  if(!col) return 0;
234  m_cols.push_back(col);
235  return col;
236  }

◆ create_column_vector_string_ref()

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

Definition at line 216 of file ntuple.

217  {
218  if(find_named<icol>(m_cols,a_name)) return 0;
219  branch* _branch = m_row_wise?m_row_wise_branch:create_branch(a_name);
220  if(!_branch) return 0;
221  column_vector_string_ref* col = new column_vector_string_ref(*_branch,a_name,a_ref,a_sep);
222  if(!col) return 0;
223  m_cols.push_back(col);
224  return col;
225  }

◆ find_column()

template<class T >
column<T>* tools::wroot::ntuple::find_column ( const std::string &  a_name)
inline

Definition at line 277 of file ntuple.

277  {
278  icol* col = find_named<icol>(m_cols,a_name);
279  if(!col) return 0;
280  return id_cast<icol, column<T> >(*col);
281  }

◆ find_column_ref()

template<class T >
column_ref<T>* tools::wroot::ntuple::find_column_ref ( const std::string &  a_name)
inline

Definition at line 270 of file ntuple.

270  {
271  icol* col = find_named<icol>(m_cols,a_name);
272  if(!col) return 0;
273  return id_cast<icol, column_ref<T> >(*col);
274  }

◆ find_column_string()

column_string* tools::wroot::ntuple::find_column_string ( const std::string &  a_name)
inline

Definition at line 289 of file ntuple.

289  {
290  icol* col = find_named<icol>(m_cols,a_name);
291  if(!col) return 0;
292  return id_cast<icol, column_string >(*col);
293  }

◆ find_column_string_ref()

column_string_ref* tools::wroot::ntuple::find_column_string_ref ( const std::string &  a_name)
inline

Definition at line 283 of file ntuple.

283  {
284  icol* col = find_named<icol>(m_cols,a_name);
285  if(!col) return 0;
286  return id_cast<icol, column_string_ref >(*col);
287  }

◆ find_column_vector()

template<class T >
std_vector_column<T>* tools::wroot::ntuple::find_column_vector ( const std::string &  a_name)
inline

Definition at line 303 of file ntuple.

303  {
304  icol* col = find_named<icol>(m_cols,a_name);
305  if(!col) return 0;
306  return id_cast<icol, std_vector_column<T> >(*col);
307  }

◆ find_column_vector_ref()

template<class T >
std_vector_column_ref<T>* tools::wroot::ntuple::find_column_vector_ref ( const std::string &  a_name)
inline

Definition at line 296 of file ntuple.

296  {
297  icol* col = find_named<icol>(m_cols,a_name);
298  if(!col) return 0;
299  return id_cast<icol, std_vector_column_ref<T> >(*col);
300  }

◆ find_column_vector_string()

column_vector_string* tools::wroot::ntuple::find_column_vector_string ( const std::string &  a_name)
inline

Definition at line 315 of file ntuple.

315  {
316  icol* col = find_named<icol>(m_cols,a_name);
317  if(!col) return 0;
318  return id_cast<icol, column_vector_string >(*col);
319  }

◆ find_column_vector_string_ref()

column_vector_string_ref* tools::wroot::ntuple::find_column_vector_string_ref ( const std::string &  a_name)
inline

Definition at line 309 of file ntuple.

309  {
310  icol* col = find_named<icol>(m_cols,a_name);
311  if(!col) return 0;
312  return id_cast<icol, column_vector_string_ref >(*col);
313  }

◆ get_branches()

void tools::wroot::ntuple::get_branches ( std::vector< branch * > &  a_vec) const
inline

Definition at line 349 of file ntuple.

349  {
350  a_vec.clear();
351  tools_vforcit(icol*,m_cols,it) a_vec.push_back(&((*it)->get_branch()));
352  }

◆ get_row_wise_branch()

branch* tools::wroot::ntuple::get_row_wise_branch ( ) const
inline

for parallelization : /////////////////////////////////////////////////

Definition at line 348 of file ntuple.

348 {return m_row_wise_branch;}

◆ merge_number_of_entries()

bool tools::wroot::ntuple::merge_number_of_entries ( )
inline

Definition at line 354 of file ntuple.

354  {
355  m_entries = 0; //it should be zero!
356  m_tot_bytes = 0;
357  m_zip_bytes = 0;
358  bool status = true;
359  tools_vforit(icol*,m_cols,it) {
360  if(it==m_cols.begin()) {
361  m_entries = (*it)->get_branch().entries();
362  } else if(m_entries!=(*it)->get_branch().entries()) {
363  m_out << "tools::wroot::ntuple::merge_number_of_entries :"
364  << " branches do not have same number of entries."
365  << std::endl;
366  status = false;
367  }
368  m_tot_bytes += (*it)->get_branch().tot_bytes();
369  m_zip_bytes += (*it)->get_branch().zip_bytes();
370  }
371  return status;
372  }

◆ mpi_add_basket()

bool tools::wroot::ntuple::mpi_add_basket ( impi a_impi)
inline

Definition at line 374 of file ntuple.

374  {
375  uint32 icol; //not used if row_wise.
376  if(!a_impi.unpack(icol)) {
377  m_out << "tools::wroot::ntuple::mpi_add_basket : unpack(icol) failed."<< std::endl;
378  return false;
379  }
380 
381  if(m_row_wise) {
382  if(!m_row_wise_branch) return false;
383 
384  basket* basket = mpi_create_basket(m_out,a_impi,
387  if(!basket) {
388  m_out << "tools::wroot::ntuple::mpi_add_basket : mpi_create_basket() failed."<< std::endl;
389  return false;
390  }
391 
392  uint32 add_bytes,nout;
393  if(!m_row_wise_branch->add_basket(m_dir.file(),*basket,add_bytes,nout)) {
394  m_out << "tools::wroot::ntuple::mpi_add_basket : row wise : branch.add_basket() failed."<< std::endl;
395  delete basket;
396  return false;
397  }
398 
399  delete basket;
402 
403  } else {
404  if(icol>=m_cols.size()) {
405  m_out << "tools::wroot::ntuple::mpi_add_basket : column index " << icol << " >= " << m_cols.size() << std::endl;
406  return false;
407  }
408 
409  branch& _branch = m_cols[icol]->get_branch();
410 
411  basket* basket = mpi_create_basket(m_out,a_impi,
413  _branch.basket_size());
414  if(!basket) {
415  m_out << "tools::wroot::ntuple::mpi_add_basket : mpi_create_basket() failed."<< std::endl;
416  return false;
417  }
418 
419  uint32 add_bytes,nout;
420  if(!_branch.add_basket(m_dir.file(),*basket,add_bytes,nout)) {
421  m_out << "tools::wroot::ntuple::mpi_add_basket : column wise : branch.add_basket() failed."<< std::endl;
422  delete basket;
423  return false;
424  }
425 
426  delete basket;
427  _branch.set_tot_bytes(_branch.tot_bytes()+add_bytes);
428  _branch.set_zip_bytes(_branch.zip_bytes()+nout);
429  }
430  return true;
431  }

◆ mpi_add_baskets()

bool tools::wroot::ntuple::mpi_add_baskets ( impi a_impi)
inline

Definition at line 433 of file ntuple.

433  { //column_wise && row_mode only.
434  uint32 _icol = 0;
435  tools_vforcit(icol*,m_cols,it) {
436  uint32 icol;
437  if(!a_impi.unpack(icol)) {
438  m_out << "tools::wroot::ntuple::mpi_add_baskets : unpack(icol) failed."<< std::endl;
439  return false;
440  }
441  if(icol!=_icol) {
442  m_out << "tools::wroot::ntuple::mpi_add_basket : received column index " << icol << ", whilst " << _icol << " expected." << std::endl;
443  return false;
444  }
445  branch& _branch = m_cols[icol]->get_branch();
446  basket* basket = mpi_create_basket(m_out,a_impi,
448  _branch.basket_size());
449  if(!basket) {
450  m_out << "tools::wroot::ntuple::mpi_add_basket : mpi_create_basket() failed."<< std::endl;
451  return false;
452  }
453 
454  uint32 add_bytes,nout;
455  if(!_branch.add_basket(m_dir.file(),*basket,add_bytes,nout)) {
456  m_out << "tools::wroot::ntuple::mpi_add_basket : column wise : branch.add_basket() failed."<< std::endl;
457  delete basket;
458  return false;
459  }
460 
461  delete basket;
462  _branch.set_tot_bytes(_branch.tot_bytes()+add_bytes);
463  _branch.set_zip_bytes(_branch.zip_bytes()+nout);
464 
465  _icol++;
466  }
467  return true;
468  }

◆ mpi_end_fill()

bool tools::wroot::ntuple::mpi_end_fill ( impi a_impi)
inline

Definition at line 470 of file ntuple.

470  {
471 
472 #define TOOLS_WROOT_NTUPLE_SET_LEAF_LENGTH_MAX(a__type) \
473  {leaf_ref<a__type>* _mleaf_ = _mleaf?id_cast<base_leaf, leaf_ref<a__type> >(*_mleaf):0;\
474  if(_mleaf_) {\
475  uint32 _len;\
476  if(!a_impi.unpack(_len)) return false;\
477  a__type _mx;\
478  if(!a_impi.unpack(_mx)) return false;\
479  _mleaf_->set_length(mx(_len,_mleaf_->length()));\
480  _mleaf_->set_max(mx(_mx,_mleaf_->get_max()));\
481  set_done = true;\
482  }}
483 
484 #define TOOLS_WROOT_NTUPLE_SET_LEAF_STD_VECTOR_LENGTH_MAX(a__type) \
485  {leaf_std_vector_ref<a__type>* _mleaf_ = _mleaf?id_cast<base_leaf, leaf_std_vector_ref<a__type> >(*_mleaf):0;\
486  if(_mleaf_) {\
487  uint32 _len;\
488  if(!a_impi.unpack(_len)) return false;\
489  a__type _mx;\
490  if(!a_impi.unpack(_mx)) return false;\
491  _mleaf_->set_length(mx(_len,_mleaf_->length()));\
492  _mleaf_->set_max(mx(_mx,_mleaf_->get_max()));\
493  set_done = true;\
494  }}
495 
496 #define TOOLS_WROOT_NTUPLE_SET_LEAF_STRING_LENGTH_MAX \
497  {leaf_string_ref* _mleaf_ = _mleaf?id_cast<base_leaf,leaf_string_ref>(*_mleaf):0;\
498  if(_mleaf_) {\
499  uint32 _len;\
500  if(!a_impi.unpack(_len)) return false;\
501  int _mx;\
502  if(!a_impi.unpack(_mx)) return false;\
503  _mleaf_->set_length(mx(_len,_mleaf_->length()));\
504  _mleaf_->set_max(mx(_mx,_mleaf_->get_max()));\
505  set_done = true;\
506  }}
507 
508  if(m_row_wise) {
509  if(!m_row_wise_branch) return false;
510 
511  tools_vforcit(base_leaf*,m_row_wise_branch->leaves(),mit) {
512  base_leaf* _mleaf = *mit;
513 
514  bool set_done = false;
515 
521 
527 
529 
530  if(!set_done) {
531  m_out << "tools::wroot::ntuple::mpi_end_fill :"
532  << " leaf " << _mleaf->name() << " with cid " << _mleaf->id_cls() << " not treated." << std::endl;
533  return false;
534  }
535  }
536 
537  } else { // column wise :
538  tools_vforcit(wroot::icol*,m_cols,it) {
539  base_leaf* _mleaf = (*it)->get_leaf();
540 
541  bool set_done = false;
543 
544  if(!set_done) {
545  uint32 _len;
546  if(!a_impi.unpack(_len)) return false;
547  int _mx;
548  if(!a_impi.unpack(_mx)) return false;
549  }
550  }
551  }
552 
553 #undef TOOLS_WROOT_NTUPLE_SET_LEAF_LENGTH_MAX
554 #undef TOOLS_WROOT_NTUPLE_SET_LEAF_STD_VECTOR_LENGTH_MAX
555 #undef TOOLS_WROOT_NTUPLE_SET_LEAF_STRING_LENGTH_MAX
556 
557  return true;
558  }

◆ operator=()

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

Definition at line 169 of file ntuple.

169 {return *this;}

◆ print_columns()

void tools::wroot::ntuple::print_columns ( std::ostream &  a_out)
inline

Definition at line 321 of file ntuple.

321  {
322  a_out << "for ntuple named " << sout(m_name) << ", number of columns " << m_cols.size() << " :" << std::endl;
323  tools_vforit(icol*,m_cols,it) {
324  a_out << " " << (*it)->name() << std::endl;
325  }
326  }

◆ set_basket_size()

void tools::wroot::ntuple::set_basket_size ( uint32  a_size)
inline

Definition at line 337 of file ntuple.

337  {
338  if(m_row_wise) {
340  } else {
341  tools_vforit(icol*,m_cols,it) (*it)->set_basket_size(a_size);
342  }
343  }

Member Data Documentation

◆ m_cols

std::vector<icol*> tools::wroot::ntuple::m_cols
protected

Definition at line 561 of file ntuple.

◆ m_row_wise

bool tools::wroot::ntuple::m_row_wise
protected

Definition at line 562 of file ntuple.

◆ m_row_wise_branch

branch* tools::wroot::ntuple::m_row_wise_branch
protected

Definition at line 563 of file ntuple.


The documentation for this class was generated from the following file:
tools::wroot::tree::m_dir
idir & m_dir
Definition: tree:235
TOOLS_WROOT_NTUPLE_SET_LEAF_STRING_LENGTH_MAX
#define TOOLS_WROOT_NTUPLE_SET_LEAF_STRING_LENGTH_MAX
tools::_cid
cid _cid(byte)
Definition: cids:14
tools::wroot::branch::tot_bytes
uint64 tot_bytes() const
Definition: branch:187
tools::wroot::branch::zip_bytes
uint64 zip_bytes() const
Definition: branch:190
TOOLS_WROOT_NTUPLE_SET_LEAF_STD_VECTOR_LENGTH_MAX
#define TOOLS_WROOT_NTUPLE_SET_LEAF_STD_VECTOR_LENGTH_MAX(a__type)
tools::wroot::tree::create_branch
branch * create_branch(const std::string &a_name)
Definition: tree:119
tools::wroot::ntuple::m_row_wise_branch
branch * m_row_wise_branch
Definition: ntuple:563
tools::wroot::branch::leaves
const std::vector< base_leaf * > & leaves() const
Definition: branch:243
tools::wroot::tree::m_tot_bytes
uint64 m_tot_bytes
Definition: tree:243
tools::wroot::idir::file
virtual ifile & file()=0
tools::wroot::tree::m_out
std::ostream & m_out
Definition: tree:236
tools::wroot::ntuple::create_column_vector_string_ref
column_vector_string_ref * create_column_vector_string_ref(const std::string &a_name, const std::vector< std::string > &a_ref, char a_sep)
Definition: ntuple:216
tools::wroot::mpi_create_basket
basket * mpi_create_basket(std::ostream &a_out, impi &a_mpi, bool a_byte_swap, seek a_seek_directory, uint32 a_basket_size)
Definition: mpi_create_basket:13
TOOLS_WROOT_NTUPLE_CREATE_VEC_COL
#define TOOLS_WROOT_NTUPLE_CREATE_VEC_COL(a__type)
tools::wroot::tree::tree
tree(idir &a_dir, const std::string &a_name, const std::string &a_title, bool a_managed=true)
Definition: tree:86
tools::wroot::ntuple::create_column_vector_string
column_vector_string * create_column_vector_string(const std::string &a_name, const std::vector< std::string > &a_def, char a_sep)
Definition: ntuple:227
tools::wroot::branch::basket_size
uint32 basket_size() const
Definition: branch:194
tools::wroot::ntuple::m_cols
std::vector< icol * > m_cols
Definition: ntuple:561
tools::wroot::idir::seek_directory
virtual seek seek_directory() const =0
TOOLS_WROOT_NTUPLE_SET_LEAF_LENGTH_MAX
#define TOOLS_WROOT_NTUPLE_SET_LEAF_LENGTH_MAX(a__type)
tools::wroot::tree::m_zip_bytes
uint64 m_zip_bytes
Definition: tree:244
TOOLS_WROOT_NTUPLE_CREATE_COL
#define TOOLS_WROOT_NTUPLE_CREATE_COL(a__type)
tools::wroot::ntuple::m_row_wise
bool m_row_wise
Definition: ntuple:562
tools::wroot::tree::m_name
std::string m_name
Definition: tree:238
tools_vforit
#define tools_vforit(a__T, a__v, a__it)
Definition: forit:13
tools::wroot::tree::m_entries
uint64 m_entries
Definition: tree:242
tools::wroot::ifile::byte_swap
virtual bool byte_swap() const =0
tools::wroot::branch::set_basket_size
void set_basket_size(uint32 a_size)
Definition: branch:193
tools::wroot::ntuple::create_column_string_ref
column_string_ref * create_column_string_ref(const std::string &a_name, const std::string &a_ref)
Definition: ntuple:196
tools::wroot::ntuple::create_column_string
column_string * create_column_string(const std::string &a_name, const std::string &a_def=std::string())
Definition: ntuple:206
tools::wroot::branch::add_basket
bool add_basket(ifile &a_file, basket &a_basket, uint32 &a_add_bytes, uint32 &a_nout)
for parallelization : /////////////////////////////////////////////////
Definition: branch:364
tools::wroot::branch::set_zip_bytes
void set_zip_bytes(uint64 a_value)
Definition: branch:191
tools::sep
const std::string & sep()
Definition: sep:11
tools::wroot::tree::fill
bool fill(uint32 &a_nbytes)
Definition: tree:198
tools_vforcit
#define tools_vforcit(a__T, a__v, a__it)
Definition: forit:7
tools::wroot::branch::set_tot_bytes
void set_tot_bytes(uint64 a_value)
Definition: branch:188
tools::uint32
unsigned int uint32
Definition: typedefs:71
tools::wroot::tree::m_branches
obj_array< branch > m_branches
Definition: tree:241