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_mpi_ntuple_row_wise 5 #define tools_wroot_mpi_ntuple_row_wise 6 7 // MPI pntuple. It uses the tools/impi interface. 8 9 #include "base_pntuple_row_wise" 10 #include "mpi_basket_add" 11 #include "impi_ntuple" 12 13 #include "../S_STRING" 14 #include "../forit" 15 16 namespace tools { 17 namespace wroot { 18 19 class mpi_ntuple_row_wise : public base_pntuple_row_wise, public virtual impi_ntuple { 20 typedef base_pntuple_row_wise parent; 21 public: 22 virtual bool add_row(impi& a_mpi,int a_dest,int a_tag) { 23 if(m_cols.empty()) return false; 24 tools_vforit(icol*,m_cols,it) (*it)->add(); 25 mpi_basket_add _badd(a_mpi,a_dest,a_tag,m_id,0); 26 if(!m_row_wise_branch.pfill(_badd,0)) return false; 27 tools_vforit(icol*,m_cols,it) (*it)->set_def(); 28 return true; 29 } 30 31 virtual bool end_fill(impi& a_mpi,int a_dest,int a_tag) { 32 mpi_basket_add _badd(a_mpi,a_dest,a_tag,m_id,0); 33 if(!m_row_wise_branch.end_pfill(_badd)) return false; 34 35 a_mpi.pack_reset(); 36 if(!a_mpi.pack(mpi_protocol_end_fill())) return false; 37 if(!a_mpi.pack(m_id)) return false; 38 if(!end_leaves(a_mpi)) return false; 39 if(!a_mpi.send_buffer(a_dest,a_tag)) return false; 40 41 return true; 42 } 43 44 public: 45 mpi_ntuple_row_wise(uint32 a_id,std::ostream& a_out, 46 bool a_byte_swap,uint32 a_compression,seek a_seek_directory, 47 const std::string& a_name,const std::string& a_title, 48 uint32 a_basket_size, 49 bool a_verbose) 50 :parent(a_out,a_byte_swap,a_compression,a_seek_directory,a_name,a_title,a_basket_size,a_verbose) 51 ,m_id(a_id) 52 {} 53 mpi_ntuple_row_wise(uint32 a_id,std::ostream& a_out, 54 bool a_byte_swap,uint32 a_compression,seek a_seek_directory, 55 uint32 a_basket_size, 56 const ntuple_booking& a_bkg,bool a_verbose) 57 :parent(a_out,a_byte_swap,a_compression,a_seek_directory,a_basket_size,a_bkg,a_verbose) 58 ,m_id(a_id) 59 {} 60 virtual ~mpi_ntuple_row_wise() {} 61 protected: 62 mpi_ntuple_row_wise(const mpi_ntuple_row_wise& a_from):impi_ntuple(a_from),parent(a_from){} 63 mpi_ntuple_row_wise& operator=(const mpi_ntuple_row_wise& a_from){parent::operator=(a_from);return *this;} 64 protected: 65 bool end_leaves(impi& a_mpi) const { 66 67 #include "MPI_SET_MAX.icc" 68 69 tools_vforcit(base_leaf*,m_row_wise_branch.leaves(),pit) { 70 base_leaf* _pleaf = *pit; 71 72 bool set_done = false; 73 74 TOOLS_WROOT_MPI_NTUPLE_LEAF_SET_LENGTH_MAX(char) 75 TOOLS_WROOT_MPI_NTUPLE_LEAF_SET_LENGTH_MAX(short) 76 TOOLS_WROOT_MPI_NTUPLE_LEAF_SET_LENGTH_MAX(int) 77 TOOLS_WROOT_MPI_NTUPLE_LEAF_SET_LENGTH_MAX(float) 78 TOOLS_WROOT_MPI_NTUPLE_LEAF_SET_LENGTH_MAX(double) 79 80 TOOLS_WROOT_MPI_NTUPLE_LEAF_STD_VECTOR_SET_LENGTH_MAX(char) 81 TOOLS_WROOT_MPI_NTUPLE_LEAF_STD_VECTOR_SET_LENGTH_MAX(short) 82 TOOLS_WROOT_MPI_NTUPLE_LEAF_STD_VECTOR_SET_LENGTH_MAX(int) 83 TOOLS_WROOT_MPI_NTUPLE_LEAF_STD_VECTOR_SET_LENGTH_MAX(float) 84 TOOLS_WROOT_MPI_NTUPLE_LEAF_STD_VECTOR_SET_LENGTH_MAX(double) 85 86 TOOLS_WROOT_MPI_NTUPLE_LEAF_STRING_SET_LENGTH_MAX 87 88 if(!set_done) { 89 m_out << "tools::wroot::mpi_ntuple_column_wise::end_leaves :" 90 << " leaf " << _pleaf->name() << " with cid " << _pleaf->id_cls() << " not treated." << std::endl; 91 return false; 92 } 93 } 94 95 #undef TOOLS_WROOT_MPI_NTUPLE_SET_MAX 96 #undef TOOLS_WROOT_MPI_NTUPLE_STRING_SET_MAX 97 98 return true; 99 } 100 protected: 101 uint32 m_id; 102 }; 103 104 }} 105 106 #endif