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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 ]

Diff markup

Differences between /externals/g4tools/include/tools/ntuple_booking (Version 11.3.0) and /externals/g4tools/include/tools/ntuple_booking (Version 11.2)


  1 // Copyright (C) 2010, Guy Barrand. All rights      1 // Copyright (C) 2010, Guy Barrand. All rights reserved.
  2 // See the file tools.license for terms.            2 // See the file tools.license for terms.
  3                                                     3 
  4 #ifndef tools_ntuple_booking                        4 #ifndef tools_ntuple_booking
  5 #define tools_ntuple_booking                        5 #define tools_ntuple_booking
  6                                                     6 
  7 // a little class to capture booking parameter      7 // a little class to capture booking parameters
  8 // to create an ntuple.                             8 // to create an ntuple.
  9                                                     9 
 10 #include "cids"                                    10 #include "cids"
 11                                                    11 
 12 #include <ostream>                                 12 #include <ostream>
 13 #include "forit"                                   13 #include "forit"
 14                                                    14 
 15 namespace tools {                                  15 namespace tools {
 16                                                    16 
 17 class column_booking {                             17 class column_booking {
 18 public:                                            18 public:
 19   column_booking(const std::string& a_name,cid     19   column_booking(const std::string& a_name,cid a_cid,void* a_user_obj)
 20   :m_name(a_name)                                  20   :m_name(a_name)
 21   ,m_cid(a_cid)                                    21   ,m_cid(a_cid)
 22   ,m_user_obj(a_user_obj) //WARNING : not owne     22   ,m_user_obj(a_user_obj) //WARNING : not owner.
 23   {}                                               23   {}
 24   virtual ~column_booking() {}                     24   virtual ~column_booking() {}
 25 public:                                            25 public:
 26   column_booking(const column_booking& a_from)     26   column_booking(const column_booking& a_from)
 27   :m_name(a_from.m_name)                           27   :m_name(a_from.m_name)
 28   ,m_cid(a_from.m_cid)                             28   ,m_cid(a_from.m_cid)
 29   ,m_user_obj(a_from.m_user_obj)                   29   ,m_user_obj(a_from.m_user_obj)
 30   {}                                               30   {}
 31   column_booking& operator=(const column_booki     31   column_booking& operator=(const column_booking& a_from) {
 32     if(&a_from==this) return *this;                32     if(&a_from==this) return *this;
 33     m_name = a_from.m_name;                        33     m_name = a_from.m_name;
 34     m_cid = a_from.m_cid;                          34     m_cid = a_from.m_cid;
 35     m_user_obj = a_from.m_user_obj;                35     m_user_obj = a_from.m_user_obj;
 36     return *this;                                  36     return *this;
 37   }                                                37   }
 38 public:                                            38 public:
 39   const std::string& name() const {return m_na     39   const std::string& name() const {return m_name;}
 40   cid cls_id() const {return m_cid;}               40   cid cls_id() const {return m_cid;}
 41   void* user_obj() const {return m_user_obj;}      41   void* user_obj() const {return m_user_obj;}
 42   void set_user_obj(void* a_obj) {m_user_obj =     42   void set_user_obj(void* a_obj) {m_user_obj = a_obj;}
 43 protected:                                         43 protected:
 44   std::string m_name;                              44   std::string m_name;
 45   cid m_cid;                                       45   cid m_cid;
 46   void* m_user_obj;                                46   void* m_user_obj;
 47 };                                                 47 };
 48                                                    48 
 49 class ntuple_booking {                             49 class ntuple_booking {
 50 public:                                            50 public:
 51   ntuple_booking(const std::string& a_name = "     51   ntuple_booking(const std::string& a_name = "",const std::string& a_title = "")
 52   :m_name(a_name)                                  52   :m_name(a_name)
 53   ,m_title(a_title)                                53   ,m_title(a_title)
 54   {}                                               54   {}
 55   virtual ~ntuple_booking(){}                      55   virtual ~ntuple_booking(){}
 56 public:                                            56 public:
 57   ntuple_booking(const ntuple_booking& a_from)     57   ntuple_booking(const ntuple_booking& a_from)
 58   :m_name(a_from.m_name)                           58   :m_name(a_from.m_name)
 59   ,m_title(a_from.m_title)                         59   ,m_title(a_from.m_title)
 60   ,m_columns(a_from.m_columns)                     60   ,m_columns(a_from.m_columns)
 61   {}                                               61   {}
 62   ntuple_booking& operator=(const ntuple_booki     62   ntuple_booking& operator=(const ntuple_booking& a_from){
 63     m_name = a_from.m_name;                        63     m_name = a_from.m_name;
 64     m_title = a_from.m_title;                      64     m_title = a_from.m_title;
 65     m_columns = a_from.m_columns;                  65     m_columns = a_from.m_columns;
 66     return *this;                                  66     return *this;
 67   }                                                67   }
 68 public:                                            68 public:
 69   template <class T>                               69   template <class T>
 70   void add_column(const std::string& a_name) {     70   void add_column(const std::string& a_name) {
 71     m_columns.push_back(column_booking(a_name,     71     m_columns.push_back(column_booking(a_name,_cid(T()),0));
 72   }                                                72   }
 73   template <class T>                               73   template <class T>
 74   void add_column(const std::string& a_name,T&     74   void add_column(const std::string& a_name,T& a_user) {
 75     m_columns.push_back(column_booking(a_name,     75     m_columns.push_back(column_booking(a_name,_cid(T()),(void*)&a_user));
 76   }                                                76   }
 77                                                    77 
 78   template <class T>                               78   template <class T>
 79   void add_column_vec(const std::string& a_nam     79   void add_column_vec(const std::string& a_name) {
 80     m_columns.push_back(column_booking(a_name,     80     m_columns.push_back(column_booking(a_name,_cid_std_vector<T>(),0));
 81   }                                                81   }
 82   template <class T>                               82   template <class T>
 83   void add_column_vec(const std::string& a_nam     83   void add_column_vec(const std::string& a_name,std::vector<T>& a_user_vec) {
 84     m_columns.push_back(column_booking(a_name,     84     m_columns.push_back(column_booking(a_name,_cid_std_vector<T>(),(void*)&a_user_vec));
 85   }                                                85   }
 86   template <class T>                               86   template <class T>
 87   void add_column(const std::string& a_name,st     87   void add_column(const std::string& a_name,std::vector<T>& a_user_vec) {
 88     m_columns.push_back(column_booking(a_name,     88     m_columns.push_back(column_booking(a_name,_cid_std_vector<T>(),(void*)&a_user_vec));
 89   }                                                89   }
 90                                                    90 
 91   const std::string& name() const {return m_na     91   const std::string& name() const {return m_name;}
 92   const std::string& title() const {return m_t     92   const std::string& title() const {return m_title;}
 93   const std::vector<column_booking>& columns()     93   const std::vector<column_booking>& columns() const {return m_columns;}
 94   std::vector<column_booking>& columns() {retu     94   std::vector<column_booking>& columns() {return m_columns;}
 95                                                    95 
 96   void set_name(const std::string& a_s) {m_nam     96   void set_name(const std::string& a_s) {m_name = a_s;}
 97   void set_title(const std::string& a_s) {m_ti     97   void set_title(const std::string& a_s) {m_title = a_s;}
 98                                                    98 
 99   bool has_similar_layout(std::ostream& a_out,     99   bool has_similar_layout(std::ostream& a_out,const ntuple_booking& a_nbk) {
100     if(m_columns.size()!=a_nbk.m_columns.size(    100     if(m_columns.size()!=a_nbk.m_columns.size()) {
101       a_out << "tools::ntuple_booking::has_sim    101       a_out << "tools::ntuple_booking::has_similar_layout :"
102             << " bookings have not the same nu    102             << " bookings have not the same number of columns."
103             << " (" << m_columns.size() << " !    103             << " (" << m_columns.size() << " != " << a_nbk.m_columns.size() << ")."
104             << std::endl;                         104             << std::endl;
105       return false;                               105       return false;
106     }                                             106     }
107     std::vector<column_booking>::const_iterato    107     std::vector<column_booking>::const_iterator ait = a_nbk.m_columns.begin();
108     tools_vforit(tools::column_booking,m_colum    108     tools_vforit(tools::column_booking,m_columns,it) {
109       if((*it).name()!=(*ait).name()) {           109       if((*it).name()!=(*ait).name()) {
110         a_out << "tools::ntuple_booking::has_s    110         a_out << "tools::ntuple_booking::has_similar_layout :"
111               << " columns don't have same nam    111               << " columns don't have same name."
112               << " (" << (*it).name() << " !=     112               << " (" << (*it).name() << " != " << (*ait).name() << ")."
113               << std::endl;                       113               << std::endl;
114         return false;                             114         return false;
115       }                                           115       }
116       if((*it).cls_id()!=(*ait).cls_id()) {       116       if((*it).cls_id()!=(*ait).cls_id()) {
117         a_out << "tools::ntuple_booking::has_s    117         a_out << "tools::ntuple_booking::has_similar_layout :"
118               << " columns don't have same cla    118               << " columns don't have same class id."
119               << " (" << (*it).cls_id() << " !    119               << " (" << (*it).cls_id() << " != " << (*ait).cls_id() << ")."
120               << std::endl;                       120               << std::endl;
121         return false;                             121         return false;
122       }                                           122       }
123                                                   123 
124       ait++;                                      124       ait++;
125     }                                             125     }
126     return true;                                  126     return true;
127   }                                               127   }
128                                                   128 
129 protected:                                        129 protected:
130   std::string m_name;                             130   std::string m_name;
131   std::string m_title;                            131   std::string m_title;
132   std::vector<column_booking> m_columns;          132   std::vector<column_booking> m_columns;
133 };                                                133 };
134                                                   134 
135 }                                                 135 }
136                                                   136 
137 #endif                                            137 #endif