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 ] [ 10.5.p1 ] [ 10.6 ] [ 10.6.p1 ] [ 10.6.p2 ] [ 10.6.p3 ] [ 10.7 ] [ 10.7.p1 ] [ 10.7.p2 ] [ 10.7.p3 ] [ 10.7.p4 ] [ 11.0 ] [ 11.0.p1 ] [ 11.0.p2 ] [ 11.0.p3, ] [ 11.0.p4 ] [ 11.1 ] [ 11.1.1 ] [ 11.1.2 ] [ 11.1.3 ] [ 11.2 ] [ 11.2.1 ] [ 11.2.2 ] [ 11.3.0 ]

  1 // Copyright (C) 2010, Guy Barrand. All rights reserved.
  2 // See the file tools.license for terms.
  3 
  4 #ifndef tools_wroot_base_pntuple
  5 #define tools_wroot_base_pntuple
  6 
  7 // pntuple = for parallel ntupling.
  8 
  9 #include "branch_element"
 10 #include "icol"
 11 
 12 #include "../vfind"
 13 
 14 #ifdef TOOLS_MEM
 15 #include "../mem"
 16 #endif
 17 
 18 namespace tools {
 19 namespace wroot {
 20 
 21 class base_pntuple {
 22 #ifdef TOOLS_MEM
 23   static const std::string& s_class() {
 24     static const std::string s_v("tools::wroot::base_pntuple");
 25     return s_v;
 26   }
 27 #endif
 28 public:
 29 
 30 #include "columns.icc"
 31 
 32 public:
 33   base_pntuple(std::ostream& a_out,seek a_seek_directory,const std::string& a_name,const std::string& a_title)
 34   :m_out(a_out)
 35   ,m_seek_directory(a_seek_directory)
 36   ,m_name(a_name)
 37   ,m_title(a_title)
 38   {
 39 #ifdef TOOLS_MEM
 40     mem::increment(s_class().c_str());
 41 #endif
 42   }
 43 
 44   virtual ~base_pntuple() {
 45     safe_clear<icol>(m_cols);
 46 #ifdef TOOLS_MEM
 47     mem::decrement(s_class().c_str());
 48 #endif
 49   }
 50 protected:
 51   base_pntuple(const base_pntuple& a_from):m_out(a_from.m_out){
 52 #ifdef TOOLS_MEM
 53     mem::increment(s_class().c_str());
 54 #endif
 55   }
 56   base_pntuple& operator=(const base_pntuple&){return *this;}
 57 public:
 58   const std::vector<icol*>& columns() const {return m_cols;}
 59 
 60   template <class T>
 61   column_ref<T>* find_column_ref(const std::string& a_name) {
 62     icol* col = find_named<icol>(m_cols,a_name);
 63     if(!col) return 0;
 64     return id_cast<icol, column_ref<T> >(*col);
 65   }
 66 
 67   template <class T>
 68   column<T>* find_column(const std::string& a_name) {
 69     icol* col = find_named<icol>(m_cols,a_name);
 70     if(!col) return 0;
 71     return id_cast<icol, column<T> >(*col);
 72   }
 73 
 74   column_string_ref* find_column_string_ref(const std::string& a_name) {
 75     icol* col = find_named<icol>(m_cols,a_name);
 76     if(!col) return 0;
 77     return id_cast<icol, column_string_ref >(*col);
 78   }
 79 
 80   column_string* find_column_string(const std::string& a_name) {
 81     icol* col = find_named<icol>(m_cols,a_name);
 82     if(!col) return 0;
 83     return id_cast<icol, column_string >(*col);
 84   }
 85 
 86   template <class T>
 87   std_vector_column_ref<T>* find_column_vector_ref(const std::string& a_name) {
 88     icol* col = find_named<icol>(m_cols,a_name);
 89     if(!col) return 0;
 90     return id_cast<icol, std_vector_column_ref<T> >(*col);
 91   }
 92 
 93   template <class T>
 94   std_vector_column<T>* find_column_vector(const std::string& a_name) {
 95     icol* col = find_named<icol>(m_cols,a_name);
 96     if(!col) return 0;
 97     return id_cast<icol, std_vector_column<T> >(*col);
 98   }
 99 
100   column_vector_string_ref* find_column_vector_string_ref(const std::string& a_name) {
101     icol* col = find_named<icol>(m_cols,a_name);
102     if(!col) return 0;
103     return id_cast<icol, column_vector_string_ref >(*col);
104   }
105 
106   column_vector_string* find_column_vector_string(const std::string& a_name) {
107     icol* col = find_named<icol>(m_cols,a_name);
108     if(!col) return 0;
109     return id_cast<icol, column_vector_string >(*col);
110   }
111 
112   void print_columns(std::ostream& a_out) {
113     a_out << "for ntuple named " << sout(m_name) << ", number of columns " << m_cols.size() << " :" << std::endl;
114     tools_vforit(icol*,m_cols,it) {
115       a_out << " " << (*it)->name() << std::endl;
116     }
117   }
118 
119   //void set_basket_size(uint32 a_size) {tools_vforit(icol*,m_cols,it) (*it)->set_basket_size(a_size);}
120 
121 protected:
122   std::ostream& m_out;
123   seek m_seek_directory;
124   std::string m_name;
125   std::string m_title;
126   std::vector<icol*> m_cols;
127 };
128 
129 }}
130 
131 #endif