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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/histo/dps (Version 11.3.0) and /externals/g4tools/include/tools/histo/dps (Version 5.2)


  1 // Copyright (C) 2010, Guy Barrand. All rights    
  2 // See the file tools.license for terms.          
  3                                                   
  4 #ifndef tools_histo_dps                           
  5 #define tools_histo_dps                           
  6                                                   
  7 // data point set.                                
  8                                                   
  9 #include <vector>                                 
 10 #include <string>                                 
 11 #include "../mnmx"                                
 12                                                   
 13 #ifdef TOOLS_MEM                                  
 14 #include "../mem"                                 
 15 #endif                                            
 16                                                   
 17 namespace tools {                                 
 18 namespace histo {                                 
 19                                                   
 20 class measurement {                               
 21   static const std::string& s_class() {           
 22     static const std::string s_v("tools::histo    
 23     return s_v;                                   
 24   }                                               
 25 public:                                           
 26   measurement():m_value(0),m_error_plus(0),m_e    
 27 #ifdef TOOLS_MEM                                  
 28     mem::increment(s_class().c_str());            
 29 #endif                                            
 30   }                                               
 31   measurement(double a_value,double a_error_pl    
 32   :m_value(a_value)                               
 33   ,m_error_plus(a_error_plus)                     
 34   ,m_error_minus(a_error_minus)                   
 35   {                                               
 36 #ifdef TOOLS_MEM                                  
 37     mem::increment(s_class().c_str());            
 38 #endif                                            
 39   }                                               
 40   virtual ~measurement(){                         
 41 #ifdef TOOLS_MEM                                  
 42     mem::decrement(s_class().c_str());            
 43 #endif                                            
 44   }                                               
 45 public:                                           
 46   measurement(const measurement& a_from)          
 47   :m_value(a_from.m_value)                        
 48   ,m_error_plus(a_from.m_error_plus)              
 49   ,m_error_minus(a_from.m_error_minus)            
 50   {                                               
 51 #ifdef TOOLS_MEM                                  
 52     mem::increment(s_class().c_str());            
 53 #endif                                            
 54   }                                               
 55   measurement& operator=(const measurement& a_    
 56     if(&a_from==this) return *this;               
 57     m_value = a_from.m_value;                     
 58     m_error_plus = a_from.m_error_plus;           
 59     m_error_minus = a_from.m_error_minus;         
 60     return *this;                                 
 61   }                                               
 62 public:                                           
 63   double value() const {return m_value;}          
 64   double error_plus() const {return m_error_pl    
 65   double error_minus() const {return m_error_m    
 66   void set_value(double a_v) {m_value = a_v;}     
 67   void set_error_plus(double a_v) {m_error_plu    
 68   void set_error_minus(double a_v) {m_error_mi    
 69 protected:                                        
 70   double m_value;                                 
 71   double m_error_plus;                            
 72   double m_error_minus;                           
 73 };                                                
 74                                                   
 75 class data_point {                                
 76   static const std::string& s_class() {           
 77     static const std::string s_v("tools::histo    
 78     return s_v;                                   
 79   }                                               
 80 public:                                           
 81   data_point(unsigned int a_dim):m_measurement    
 82 #ifdef TOOLS_MEM                                  
 83     mem::increment(s_class().c_str());            
 84 #endif                                            
 85   }                                               
 86   virtual ~data_point() {                         
 87 #ifdef TOOLS_MEM                                  
 88     mem::decrement(s_class().c_str());            
 89 #endif                                            
 90   }                                               
 91 public:                                           
 92   data_point(const data_point& a_from)            
 93   :m_measurements(a_from.m_measurements)          
 94   {                                               
 95 #ifdef TOOLS_MEM                                  
 96     mem::increment(s_class().c_str());            
 97 #endif                                            
 98   }                                               
 99   data_point& operator=(const data_point& a_fr    
100     if(&a_from==this) return *this;               
101     m_measurements = a_from.m_measurements;       
102     return *this;                                 
103   }                                               
104 public: //AIDA/Idata_point                        
105   size_t dimension() const {return m_measureme    
106   measurement& coordinate(unsigned int a_coord    
107     //WARNING : no check done on a_coord vs m_    
108     return m_measurements[a_coord];               
109   }                                               
110   const measurement& coordinate(unsigned int a    
111     //WARNING : no check done on a_coord vs m_    
112     return m_measurements[a_coord];               
113   }                                               
114 protected:                                        
115   std::vector<measurement> m_measurements;        
116 };                                                
117                                                   
118                                                   
119 class dps {                                       
120 public:                                           
121   static const std::string& s_class() {           
122     static const std::string s_v("tools::histo    
123     return s_v;                                   
124   }                                               
125 public:                                           
126   dps():m_dim(0){}                                
127                                                   
128   dps(const std::string& a_title,unsigned int     
129   :m_title(a_title),m_dim(a_dim)                  
130   {}                                              
131   virtual ~dps(){}                                
132 public:                                           
133   dps(const dps& a_from)                          
134   :m_title(a_from.m_title)                        
135   ,m_dim(a_from.m_dim)                            
136   ,m_points(a_from.m_points)                      
137   {}                                              
138   dps& operator=(const dps& a_from) {             
139     if(&a_from==this) return *this;               
140     m_title = a_from.m_title;                     
141     m_dim = a_from.m_dim;                         
142     m_points = a_from.m_points;                   
143     return *this;                                 
144   }                                               
145                                                   
146 public:                                           
147   const std::string& title() const {return m_t    
148                                                   
149   void set_title(const std::string& a_s) {m_ti    
150                                                   
151   unsigned int dimension() const {return m_dim    
152   void clear() {m_points.clear();}                
153   size_t size() const {return m_points.size();    
154                                                   
155   const data_point& point(size_t a_index) cons    
156     //WARNING : no check done on a_index.         
157     return m_points[a_index];                     
158   }                                               
159   data_point& point(size_t a_index) {             
160     //WARNING : no check done on a_index.         
161     return m_points[a_index];                     
162   }                                               
163                                                   
164   data_point& add_point() {                       
165     m_points.push_back(data_point(m_dim));        
166     return m_points.back();                       
167   }                                               
168                                                   
169   bool remove_point(size_t a_index) {             
170     bool done = false;                            
171     if(a_index<m_points.size()){                  
172       std::vector<data_point>::iterator it = m    
173       it += a_index;                              
174       m_points.erase(it);                         
175       done = true;                                
176     }                                             
177     return done;                                  
178   }                                               
179                                                   
180   bool lower_extent(unsigned int a_coord,doubl    
181     if(m_points.empty()||(a_coord>=m_dim)){       
182       a_value = 0;                                
183       return false;                               
184     }                                             
185     std::vector<data_point>::const_iterator it    
186     a_value = (*it).coordinate(a_coord).value(    
187     ++it;                                         
188     for(;it!=m_points.end();++it) {               
189       a_value = mn<double>(a_value,(*it).coord    
190     }                                             
191     return true;                                  
192   }                                               
193                                                   
194   bool upper_extent(unsigned int a_coord,doubl    
195     if(m_points.empty()||(a_coord>=m_dim)){       
196       a_value = 0;                                
197       return false;                               
198     }                                             
199     std::vector<data_point>::const_iterator it    
200     a_value = (*it).coordinate(a_coord).value(    
201     ++it;                                         
202     for(;it!=m_points.end();++it) {               
203       a_value = mx<double>(a_value,(*it).coord    
204     }                                             
205     return true;                                  
206   }                                               
207                                                   
208   void scale(double a_scale) {                    
209     std::vector<data_point>::iterator it;         
210     for(it=m_points.begin();it!=m_points.end()    
211       for(unsigned int coord=0;coord<m_dim;coo    
212         measurement& _m = (*it).coordinate(coo    
213         _m.set_value(_m.value() * a_scale);       
214         _m.set_error_plus(_m.error_plus() * a_    
215         _m.set_error_minus(_m.error_minus() *     
216       }                                           
217     }                                             
218   }                                               
219                                                   
220   void scale_value(double a_scale) {              
221     std::vector<data_point>::iterator it;         
222     for(it=m_points.begin();it!=m_points.end()    
223       for(unsigned int coord=0;coord<m_dim;coo    
224         measurement& _m = (*it).coordinate(coo    
225         _m.set_value(_m.value() * a_scale);       
226       }                                           
227     }                                             
228   }                                               
229                                                   
230   void scale_errors(double a_scale) {             
231     std::vector<data_point>::iterator it;         
232     for(it=m_points.begin();it!=m_points.end()    
233       for(unsigned int coord=0;coord<m_dim;coo    
234         measurement& _m = (*it).coordinate(coo    
235         _m.set_error_plus(_m.error_plus() * a_    
236         _m.set_error_minus(_m.error_minus() *     
237       }                                           
238     }                                             
239   }                                               
240                                                   
241 protected:                                        
242   std::string m_title;                            
243   unsigned int m_dim;                             
244   std::vector<data_point> m_points;               
245 };                                                
246                                                   
247 }}                                                
248                                                   
249 #endif