Geant4 Cross Reference |
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 { 17 typedef base_pntuple_row_wise parent; 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: 52 mt_ntuple_row_wise(const mt_ntuple_row_wise& a_from) 53 :imt_ntuple(a_from) 54 ,parent(a_from) 55 ,m_main_branch(a_from.m_main_branch) 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(); 71 tools_vforcit(base_leaf*,m_main_branch.leaves(),mit) { 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: 90 branch& m_main_branch; 91 }; 92 93 }} 94 95 #endif