Warning, /include/Geant4/tools/wroot/base_pntuple is written in an unsupported language. File is not indexed.
0001 // Copyright (C) 2010, Guy Barrand. All rights reserved.
0002 // See the file tools.license for terms.
0003
0004 #ifndef tools_wroot_base_pntuple
0005 #define tools_wroot_base_pntuple
0006
0007 // pntuple = for parallel ntupling.
0008
0009 #include "branch_element"
0010 #include "icol"
0011
0012 #include "../vfind"
0013
0014 #ifdef TOOLS_MEM
0015 #include "../mem"
0016 #endif
0017
0018 namespace tools {
0019 namespace wroot {
0020
0021 class base_pntuple {
0022 #ifdef TOOLS_MEM
0023 static const std::string& s_class() {
0024 static const std::string s_v("tools::wroot::base_pntuple");
0025 return s_v;
0026 }
0027 #endif
0028 public:
0029
0030 #include "columns.icc"
0031
0032 public:
0033 base_pntuple(std::ostream& a_out,seek a_seek_directory,const std::string& a_name,const std::string& a_title)
0034 :m_out(a_out)
0035 ,m_seek_directory(a_seek_directory)
0036 ,m_name(a_name)
0037 ,m_title(a_title)
0038 {
0039 #ifdef TOOLS_MEM
0040 mem::increment(s_class().c_str());
0041 #endif
0042 }
0043
0044 virtual ~base_pntuple() {
0045 safe_clear<icol>(m_cols);
0046 #ifdef TOOLS_MEM
0047 mem::decrement(s_class().c_str());
0048 #endif
0049 }
0050 protected:
0051 base_pntuple(const base_pntuple& a_from):m_out(a_from.m_out){
0052 #ifdef TOOLS_MEM
0053 mem::increment(s_class().c_str());
0054 #endif
0055 }
0056 base_pntuple& operator=(const base_pntuple&){return *this;}
0057 public:
0058 const std::vector<icol*>& columns() const {return m_cols;}
0059
0060 template <class T>
0061 column_ref<T>* find_column_ref(const std::string& a_name) {
0062 icol* col = find_named<icol>(m_cols,a_name);
0063 if(!col) return 0;
0064 return id_cast<icol, column_ref<T> >(*col);
0065 }
0066
0067 template <class T>
0068 column<T>* find_column(const std::string& a_name) {
0069 icol* col = find_named<icol>(m_cols,a_name);
0070 if(!col) return 0;
0071 return id_cast<icol, column<T> >(*col);
0072 }
0073
0074 column_string_ref* find_column_string_ref(const std::string& a_name) {
0075 icol* col = find_named<icol>(m_cols,a_name);
0076 if(!col) return 0;
0077 return id_cast<icol, column_string_ref >(*col);
0078 }
0079
0080 column_string* find_column_string(const std::string& a_name) {
0081 icol* col = find_named<icol>(m_cols,a_name);
0082 if(!col) return 0;
0083 return id_cast<icol, column_string >(*col);
0084 }
0085
0086 template <class T>
0087 std_vector_column_ref<T>* find_column_vector_ref(const std::string& a_name) {
0088 icol* col = find_named<icol>(m_cols,a_name);
0089 if(!col) return 0;
0090 return id_cast<icol, std_vector_column_ref<T> >(*col);
0091 }
0092
0093 template <class T>
0094 std_vector_column<T>* find_column_vector(const std::string& a_name) {
0095 icol* col = find_named<icol>(m_cols,a_name);
0096 if(!col) return 0;
0097 return id_cast<icol, std_vector_column<T> >(*col);
0098 }
0099
0100 column_vector_string_ref* find_column_vector_string_ref(const std::string& a_name) {
0101 icol* col = find_named<icol>(m_cols,a_name);
0102 if(!col) return 0;
0103 return id_cast<icol, column_vector_string_ref >(*col);
0104 }
0105
0106 column_vector_string* find_column_vector_string(const std::string& a_name) {
0107 icol* col = find_named<icol>(m_cols,a_name);
0108 if(!col) return 0;
0109 return id_cast<icol, column_vector_string >(*col);
0110 }
0111
0112 void print_columns(std::ostream& a_out) {
0113 a_out << "for ntuple named " << sout(m_name) << ", number of columns " << m_cols.size() << " :" << std::endl;
0114 tools_vforit(icol*,m_cols,it) {
0115 a_out << " " << (*it)->name() << std::endl;
0116 }
0117 }
0118
0119 //void set_basket_size(uint32 a_size) {tools_vforit(icol*,m_cols,it) (*it)->set_basket_size(a_size);}
0120
0121 protected:
0122 std::ostream& m_out;
0123 seek m_seek_directory;
0124 std::string m_name;
0125 std::string m_title;
0126 std::vector<icol*> m_cols;
0127 };
0128
0129 }}
0130
0131 #endif