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 "../vmanip"
0013
0014 namespace tools {
0015 namespace wroot {
0016
0017 class base_pntuple {
0018 public:
0019
0020 #include "columns.icc"
0021
0022 public:
0023 base_pntuple(std::ostream& a_out,seek a_seek_directory,const std::string& a_name,const std::string& a_title)
0024 :m_out(a_out)
0025 ,m_seek_directory(a_seek_directory)
0026 ,m_name(a_name)
0027 ,m_title(a_title)
0028 {
0029 }
0030
0031 virtual ~base_pntuple() {
0032 safe_clear<icol>(m_cols);
0033 }
0034 protected:
0035 base_pntuple(const base_pntuple& a_from):m_out(a_from.m_out){
0036 }
0037 base_pntuple& operator=(const base_pntuple&){return *this;}
0038 public:
0039 const std::vector<icol*>& columns() const {return m_cols;}
0040
0041 template <class T>
0042 column_ref<T>* find_column_ref(const std::string& a_name) {
0043 icol* col = find_named<icol>(m_cols,a_name);
0044 if(!col) return 0;
0045 return id_cast<icol, column_ref<T> >(*col);
0046 }
0047
0048 template <class T>
0049 column<T>* find_column(const std::string& a_name) {
0050 icol* col = find_named<icol>(m_cols,a_name);
0051 if(!col) return 0;
0052 return id_cast<icol, column<T> >(*col);
0053 }
0054
0055 column_string_ref* find_column_string_ref(const std::string& a_name) {
0056 icol* col = find_named<icol>(m_cols,a_name);
0057 if(!col) return 0;
0058 return id_cast<icol, column_string_ref >(*col);
0059 }
0060
0061 column_string* find_column_string(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_string >(*col);
0065 }
0066
0067 template <class T>
0068 std_vector_column_ref<T>* find_column_vector_ref(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, std_vector_column_ref<T> >(*col);
0072 }
0073
0074 template <class T>
0075 std_vector_column<T>* find_column_vector(const std::string& a_name) {
0076 icol* col = find_named<icol>(m_cols,a_name);
0077 if(!col) return 0;
0078 return id_cast<icol, std_vector_column<T> >(*col);
0079 }
0080
0081 column_vector_string_ref* find_column_vector_string_ref(const std::string& a_name) {
0082 icol* col = find_named<icol>(m_cols,a_name);
0083 if(!col) return 0;
0084 return id_cast<icol, column_vector_string_ref >(*col);
0085 }
0086
0087 column_vector_string* find_column_vector_string(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, column_vector_string >(*col);
0091 }
0092
0093 void print_columns(std::ostream& a_out) {
0094 a_out << "for ntuple named " << sout(m_name) << ", number of columns " << m_cols.size() << " :" << std::endl;
0095 tools_vforit(icol*,m_cols,it) {
0096 a_out << " " << (*it)->name() << std::endl;
0097 }
0098 }
0099
0100 protected:
0101 std::ostream& m_out;
0102 seek m_seek_directory;
0103 std::string m_name;
0104 std::string m_title;
0105 std::vector<icol*> m_cols;
0106 };
0107
0108 }}
0109
0110 #endif