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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/rntuple (Version 11.3.0) and /externals/g4tools/include/tools/rntuple (Version 9.6.p4)


  1 // Copyright (C) 2010, Guy Barrand. All rights    
  2 // See the file tools.license for terms.          
  3                                                   
  4 #ifndef tools_rntuple                             
  5 #define tools_rntuple                             
  6                                                   
  7 // interfaces to read ntuple.                     
  8                                                   
  9 #include "scast"                                  
 10 #include "cids"                                   
 11 #include "touplow"                                
 12 #include "forit"                                  
 13 #include "mnmx"                                   
 14                                                   
 15 #include <string>                                 
 16 #include <vector>                                 
 17                                                   
 18 namespace tools {                                 
 19 namespace read {                                  
 20                                                   
 21 class icol {                                      
 22 public:                                           
 23   virtual ~icol(){}                               
 24 public:                                           
 25   virtual void* cast(cid) const = 0;              
 26   virtual cid id_cls() const = 0;                 
 27 public:                                           
 28   virtual const std::string& name() const = 0;    
 29 public:                                           
 30   virtual void stop() {}                          
 31   virtual bool fetch_entry() const {return fal    
 32 };                                                
 33                                                   
 34 template <class T>                                
 35 class icolumn : public virtual icol {             
 36 public:                                           
 37   typedef T entry_t;                              
 38 public:                                           
 39   static cid id_class() {                         
 40     static const T s_v = T(); //do that for T     
 41     return _cid(s_v);                             
 42   }                                               
 43 public: //icol                                    
 44   virtual void* cast(cid a_class) const {         
 45     if(void* p = cmp_cast<icolumn>(this,a_clas    
 46     return 0;                                     
 47   }                                               
 48   virtual cid id_cls() const {return id_class(    
 49 public:                                           
 50   virtual ~icolumn(){}                            
 51 public:                                           
 52   virtual bool get_entry(T&) const = 0;           
 53 };                                                
 54                                                   
 55 class intuple {                                   
 56 public:                                           
 57   static const std::string& s_class() {           
 58     static const std::string s_v("tools::read:    
 59     return s_v;                                   
 60   }                                               
 61 public:                                           
 62   virtual ~intuple(){}                            
 63 public:                                           
 64   virtual void start() = 0;                       
 65   virtual bool next() = 0;                        
 66   virtual icol* find_icol(const std::string&)     
 67   virtual const std::vector<icol*>& columns()     
 68   virtual const std::string& title() const = 0    
 69   virtual bool number_of_entries(uint64&) cons    
 70 public:                                           
 71   virtual void stop() {}                          
 72 public:                                           
 73   size_t number_of_columns() const {return col    
 74                                                   
 75   void column_names(std::vector<std::string>&     
 76     a_names.clear();                              
 77     const std::vector<icol*>& _cols = columns(    
 78     tools_vforcit(icol*,_cols,it) a_names.push    
 79   }                                               
 80                                                   
 81   icol* find_icol_case_insensitive(const std::    
 82     std::string low_a_name = a_name;              
 83     tolowercase(low_a_name);                      
 84     std::string low_name;                         
 85     const std::vector<icol*>& _cols = columns(    
 86     tools_vforcit(icol*,_cols,it) {               
 87       low_name = (*it)->name();                   
 88       tolowercase(low_name);                      
 89       if(low_name==low_a_name) return *it;        
 90     }                                             
 91     return 0;                                     
 92   }                                               
 93                                                   
 94   template <class T>                              
 95   icolumn<T>* find_column(const std::string& a    
 96     icol* col = find_icol(a_name);                
 97     if(!col) return 0;                            
 98     return id_cast<icol, icolumn<T> >(*col);      
 99   }                                               
100                                                   
101   template <class T>                              
102   bool find_column(const std::string& a_name,i    
103     icol* col = a_case_sensitive ? find_icol(a    
104     if(!col) {a_col = 0;return false;}            
105     a_col = id_cast<icol, icolumn<T> >(*col);     
106     return a_col?true:false;                      
107   }                                               
108                                                   
109   template <class T>                              
110   bool column_is_of_type(const std::string& a_    
111     icol* col = a_case_sensitive ? find_icol(a    
112     if(!col) {a_is = false;return false;}         
113     a_is = id_cast<icol, icolumn<T> >(*col)?tr    
114     return true;                                  
115   }                                               
116                                                   
117   template <class T>                              
118   bool column_min(unsigned int a_col,T& a_valu    
119     a_value = T();                                
120     const std::vector<icol*>& cols = columns()    
121     if(cols.empty()) return false;                
122     if(a_col>=cols.size()) return false;          
123     icol* _base_col = cols[a_col];                
124     icolumn<T>* _col = id_cast<icol, icolumn<T    
125     if(!_col) return false;                       
126     uint64 _rows;                                 
127     if(!number_of_entries(_rows)) return false    
128     start();                                      
129     T v;                                          
130    {for(uint64 row=0;row<_rows;row++) {           
131       if(!next()) {a_value = T();return false;    
132       if(!_col->get_entry(v)) {}                  
133       if(!row) {                                  
134         a_value = v;                              
135       } else {                                    
136         a_value = mn<T>(a_value,v);               
137       }                                           
138     }}                                            
139     return true;                                  
140   }                                               
141                                                   
142   template <class T>                              
143   bool column_max(unsigned int a_col,T& a_valu    
144     a_value = T();                                
145     const std::vector<icol*>& cols = columns()    
146     if(cols.empty()) return false;                
147     if(a_col>=cols.size()) return false;          
148     icol* _base_col = cols[a_col];                
149     icolumn<T>* _col = id_cast<icol, icolumn<T    
150     if(!_col) return false;                       
151     uint64 _rows;                                 
152     if(!number_of_entries(_rows)) return false    
153     start();                                      
154     T v;                                          
155    {for(uint64 row=0;row<_rows;row++) {           
156       if(!next()) {a_value = T();return false;    
157       if(!_col->get_entry(v)) {}                  
158       if(!row) {                                  
159         a_value = v;                              
160       } else {                                    
161         a_value = mx<T>(a_value,v);               
162       }                                           
163     }}                                            
164     return true;                                  
165   }                                               
166                                                   
167 };                                                
168                                                   
169 }}                                                
170                                                   
171 #endif