g4tools  5.4.0
mt_ntuple_row_wise
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_mt_ntuple_row_wise
5 #define tools_wroot_mt_ntuple_row_wise
6 
7 // pntuple = for parallel ntupling.
8 
9 #include "base_pntuple_row_wise"
10 #include "mt_basket_add"
11 #include "imt_ntuple"
12 
13 namespace tools {
14 namespace wroot {
15 
16 class mt_ntuple_row_wise : public base_pntuple_row_wise, public virtual imt_ntuple {
18 public:
19  virtual bool add_row(imutex& a_mutex,ifile& a_main_file) {
20  if(m_cols.empty()) return false;
21  tools_vforit(icol*,m_cols,it) (*it)->add();
22  mt_basket_add _badd(a_mutex,a_main_file,m_main_branch);
23  if(!m_row_wise_branch.pfill(_badd,0)) return false;
24  tools_vforit(icol*,m_cols,it) (*it)->set_def();
25  return true;
26  }
27  virtual bool end_fill(imutex& a_mutex,ifile& a_main_file) {
28  mt_basket_add _badd(a_mutex,a_main_file,m_main_branch);
29  if(!m_row_wise_branch.end_pfill(_badd)) return false;
30  return end_leaves(a_mutex);
31  }
32 public:
33  mt_ntuple_row_wise(std::ostream& a_out,bool a_byte_swap,uint32 a_compression,seek a_seek_directory,
34  branch& a_main_branch,
35  const std::string& a_name,const std::string& a_title,
36  uint32 a_basket_size,
37  bool a_verbose)
38  :parent(a_out,a_byte_swap,a_compression,a_seek_directory,a_name,a_title,a_basket_size,a_verbose)
39  ,m_main_branch(a_main_branch)
40  {}
41 
42  mt_ntuple_row_wise(std::ostream& a_out,bool a_byte_swap,uint32 a_compression,seek a_seek_directory,
43  branch& a_main_branch,
44  uint32 a_basket_size,
45  const ntuple_booking& a_bkg,bool a_verbose)
46  :parent(a_out,a_byte_swap,a_compression,a_seek_directory,a_basket_size,a_bkg,a_verbose)
47  ,m_main_branch(a_main_branch)
48  {}
49 
50  virtual ~mt_ntuple_row_wise() {}
51 protected:
53  :imt_ntuple(a_from)
54  ,parent(a_from)
56  {}
57  mt_ntuple_row_wise& operator=(const mt_ntuple_row_wise& a_from){parent::operator=(a_from);return *this;}
58 protected:
59  bool end_leaves(imutex& a_mutex) const {
60  if(m_main_branch.leaves().size()!=m_row_wise_branch.leaves().size()) {
61  m_out << "tools::wroot::mt_ntuple_row_wise::end_leaves :"
62  << " m_main_branch.leaves().size() (" << m_main_branch.leaves().size() << ") != "
63  << "m_row_wise_branch.leaves().size() (" << m_row_wise_branch.leaves().size() << ")."
64  << std::endl;
65  return false;
66  }
67 
68 #include "MT_SET_MAX.icc"
69 
70  std::vector<base_leaf*>::iterator pit = const_cast< std::vector<base_leaf*>& >(m_row_wise_branch.leaves()).begin();
72  base_leaf* _mleaf = *mit;
73  base_leaf* _pleaf = *pit; pit++; //WARNING.
74 
75  TOOLS_WROOT_MT_NTUPLE_SET_MAX(char)
76  TOOLS_WROOT_MT_NTUPLE_SET_MAX(short)
77  TOOLS_WROOT_MT_NTUPLE_SET_MAX(int)
78  TOOLS_WROOT_MT_NTUPLE_SET_MAX(float)
79  TOOLS_WROOT_MT_NTUPLE_SET_MAX(double)
80 
81  TOOLS_WROOT_MT_NTUPLE_STRING_SET_MAX
82 
83  }
84 #undef TOOLS_WROOT_MT_NTUPLE_SET_MAX
85 #undef TOOLS_WROOT_MT_NTUPLE_STRING_SET_MAX
86 
87  return true;
88  }
89 protected:
91 };
92 
93 }}
94 
95 #endif
tools::wroot::seek
int64 seek
Definition: seek:16
tools::wroot::icol
Definition: icol:21
tools::wroot::mt_ntuple_row_wise::end_leaves
bool end_leaves(imutex &a_mutex) const
Definition: mt_ntuple_row_wise:59
tools::wroot::base_pntuple_row_wise::operator=
base_pntuple_row_wise & operator=(const base_pntuple_row_wise &)
Definition: base_pntuple_row_wise:156
tools::wroot::mt_ntuple_row_wise::operator=
mt_ntuple_row_wise & operator=(const mt_ntuple_row_wise &a_from)
Definition: mt_ntuple_row_wise:57
tools::wroot::ifile
Definition: ifile:18
tools::wroot::mt_ntuple_row_wise::mt_ntuple_row_wise
mt_ntuple_row_wise(std::ostream &a_out, bool a_byte_swap, uint32 a_compression, seek a_seek_directory, branch &a_main_branch, uint32 a_basket_size, const ntuple_booking &a_bkg, bool a_verbose)
Definition: mt_ntuple_row_wise:42
tools::wroot::base_pntuple_row_wise
Definition: base_pntuple_row_wise:20
tools::wroot::imutex
Definition: imutex:10
tools::wroot::branch
Definition: branch:16
tools::wroot::base_pntuple::m_out
std::ostream & m_out
Definition: base_pntuple:122
tools::wroot::branch::pfill
bool pfill(iadd_basket &a_badd, uint32 a_nev)
Definition: branch:416
tools::wroot::branch::leaves
const std::vector< base_leaf * > & leaves() const
Definition: branch:243
tools::wroot::mt_ntuple_row_wise::mt_ntuple_row_wise
mt_ntuple_row_wise(const mt_ntuple_row_wise &a_from)
Definition: mt_ntuple_row_wise:52
tools::wroot::mt_basket_add
Definition: mt_basket_add:14
tools::waxml::begin
void begin(std::ostream &a_writer)
Definition: begend:15
tools::wroot::mt_ntuple_row_wise::mt_ntuple_row_wise
mt_ntuple_row_wise(std::ostream &a_out, bool a_byte_swap, uint32 a_compression, seek a_seek_directory, branch &a_main_branch, const std::string &a_name, const std::string &a_title, uint32 a_basket_size, bool a_verbose)
Definition: mt_ntuple_row_wise:33
tools::wroot::branch::end_pfill
bool end_pfill(iadd_basket &a_badd)
Definition: branch:478
tools::wroot::base_leaf
Definition: base_leaf:19
MT_SET_MAX.icc
tools::wroot::imt_ntuple
Definition: imt_ntuple:15
tools_vforit
#define tools_vforit(a__T, a__v, a__it)
Definition: forit:13
base_pntuple_row_wise
tools::wroot::mt_ntuple_row_wise::add_row
virtual bool add_row(imutex &a_mutex, ifile &a_main_file)
Definition: mt_ntuple_row_wise:19
tools
inlined C code : ///////////////////////////////////
Definition: aida_ntuple:26
tools::wroot::base_pntuple
Definition: base_pntuple:21
tools::wroot::base_pntuple_row_wise::m_row_wise_branch
branch m_row_wise_branch
Definition: base_pntuple_row_wise:228
imt_ntuple
tools::wroot::mt_ntuple_row_wise::m_main_branch
branch & m_main_branch
Definition: mt_ntuple_row_wise:90
mt_basket_add
tools::wroot::base_pntuple::m_cols
std::vector< icol * > m_cols
Definition: base_pntuple:126
tools::wroot::mt_ntuple_row_wise::~mt_ntuple_row_wise
virtual ~mt_ntuple_row_wise()
Definition: mt_ntuple_row_wise:50
tools::wroot::mt_ntuple_row_wise
Definition: mt_ntuple_row_wise:16
tools_vforcit
#define tools_vforcit(a__T, a__v, a__it)
Definition: forit:7
tools::wroot::mt_ntuple_row_wise::end_fill
virtual bool end_fill(imutex &a_mutex, ifile &a_main_file)
Definition: mt_ntuple_row_wise:27
tools::uint32
unsigned int uint32
Definition: typedefs:71
tools::ntuple_booking
Definition: ntuple_booking:49