Geant4 Cross Reference

Cross-Referencing   Geant4
Geant4/externals/g4tools/include/tools/rroot/THistogram

Version: [ ReleaseNotes ] [ 1.0 ] [ 1.1 ] [ 2.0 ] [ 3.0 ] [ 3.1 ] [ 3.2 ] [ 4.0 ] [ 4.0.p1 ] [ 4.0.p2 ] [ 4.1 ] [ 4.1.p1 ] [ 5.0 ] [ 5.0.p1 ] [ 5.1 ] [ 5.1.p1 ] [ 5.2 ] [ 5.2.p1 ] [ 5.2.p2 ] [ 6.0 ] [ 6.0.p1 ] [ 6.1 ] [ 6.2 ] [ 6.2.p1 ] [ 6.2.p2 ] [ 7.0 ] [ 7.0.p1 ] [ 7.1 ] [ 7.1.p1 ] [ 8.0 ] [ 8.0.p1 ] [ 8.1 ] [ 8.1.p1 ] [ 8.1.p2 ] [ 8.2 ] [ 8.2.p1 ] [ 8.3 ] [ 8.3.p1 ] [ 8.3.p2 ] [ 9.0 ] [ 9.0.p1 ] [ 9.0.p2 ] [ 9.1 ] [ 9.1.p1 ] [ 9.1.p2 ] [ 9.1.p3 ] [ 9.2 ] [ 9.2.p1 ] [ 9.2.p2 ] [ 9.2.p3 ] [ 9.2.p4 ] [ 9.3 ] [ 9.3.p1 ] [ 9.3.p2 ] [ 9.4 ] [ 9.4.p1 ] [ 9.4.p2 ] [ 9.4.p3 ] [ 9.4.p4 ] [ 9.5 ] [ 9.5.p1 ] [ 9.5.p2 ] [ 9.6 ] [ 9.6.p1 ] [ 9.6.p2 ] [ 9.6.p3 ] [ 9.6.p4 ] [ 10.0 ] [ 10.0.p1 ] [ 10.0.p2 ] [ 10.0.p3 ] [ 10.0.p4 ] [ 10.1 ] [ 10.1.p1 ] [ 10.1.p2 ] [ 10.1.p3 ] [ 10.2 ] [ 10.2.p1 ] [ 10.2.p2 ] [ 10.2.p3 ] [ 10.3 ] [ 10.3.p1 ] [ 10.3.p2 ] [ 10.3.p3 ] [ 10.4 ] [ 10.4.p1 ] [ 10.4.p2 ] [ 10.4.p3 ] [ 10.5 ] [ 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/rroot/THistogram (Version 11.3.0) and /externals/g4tools/include/tools/rroot/THistogram (Version 10.2)


  1 // Copyright (C) 2010, Guy Barrand. All rights    
  2 // See the file tools.license for terms.          
  3                                                   
  4 #ifndef tools_rroot_THistogram                    
  5 #define tools_rroot_THistogram                    
  6                                                   
  7 // to read some files produced with BatchLab (    
  8                                                   
  9 #include "../histo/profile_data"                  
 10                                                   
 11 #include "named"                                  
 12 #include "../vmanip"                              
 13                                                   
 14 namespace tools {                                 
 15 namespace rroot {                                 
 16                                                   
 17 //typedef histo::histo_data<double,unsigned in    
 18 typedef histo::profile_data<double,unsigned in    
 19 typedef histo::axis<double,unsigned int> axis_    
 20 typedef std::map<std::string,std::string> anno    
 21                                                   
 22 inline bool Axis_read_v0_v3(buffer& a_buffer,a    
 23   int idummy;                                     
 24   double ddummy;                                  
 25   if(!a_buffer.read(a_axis.m_minimum_value)) r    
 26   if(!a_buffer.read(a_axis.m_maximum_value)) r    
 27   if(!a_buffer.read(a_axis.m_offset)) return f    
 28   if(!a_buffer.read(a_axis.m_number_of_bins))     
 29   if(!a_buffer.read(idummy)) return false; //f    
 30   if(!a_buffer.read(idummy)) return false; //f    
 31   if(!a_buffer.read(a_axis.m_bin_width)) retur    
 32   if(!a_buffer.read(ddummy)) return false; //f    
 33   if(!a_buffer.read(ddummy)) return false; //f    
 34   a_axis.m_fixed = true;                          
 35   a_axis.m_edges.clear();                         
 36   return true;                                    
 37 }                                                 
 38                                                   
 39 inline bool Axis_read_v4_v6(buffer& a_buffer,a    
 40   int idummy;                                     
 41   double ddummy;                                  
 42   if(!a_buffer.read(a_axis.m_offset)) return f    
 43   if(!a_buffer.read(idummy)) return false; //f    
 44   if(!a_buffer.read(idummy)) return false; //f    
 45   if(!a_buffer.read(ddummy)) return false; //f    
 46   if(!a_buffer.read(ddummy)) return false; //f    
 47   if(!a_buffer.read(a_axis.m_number_of_bins))     
 48   if(!a_buffer.read(a_axis.m_minimum_value)) r    
 49   if(!a_buffer.read(a_axis.m_maximum_value)) r    
 50   if(!a_buffer.read(a_axis.m_fixed)) return fa    
 51   if(!a_buffer.read(a_axis.m_bin_width)) retur    
 52   int edgen;                                      
 53   if(!a_buffer.read(edgen)) return false;         
 54   for(int count=0;count<edgen;count++) {          
 55     double value;                                 
 56     if(!a_buffer.read(value)) return false;       
 57     a_axis.m_edges.push_back(value);              
 58   }                                               
 59   return true;                                    
 60 }                                                 
 61                                                   
 62 inline bool Axis_read_v7(buffer& a_buffer,axis    
 63   if(!a_buffer.read(a_axis.m_offset)) return f    
 64   if(!a_buffer.read(a_axis.m_number_of_bins))     
 65   if(!a_buffer.read(a_axis.m_minimum_value)) r    
 66   if(!a_buffer.read(a_axis.m_maximum_value)) r    
 67   if(!a_buffer.read(a_axis.m_fixed)) return fa    
 68   if(!a_buffer.read(a_axis.m_bin_width)) retur    
 69   int edgen;                                      
 70   if(!a_buffer.read(edgen)) return false;         
 71   for(int count=0;count<edgen;count++) {          
 72     double value;                                 
 73     if(!a_buffer.read(value)) return false;       
 74     a_axis.m_edges.push_back(value);              
 75   }                                               
 76   return true;                                    
 77 }                                                 
 78                                                   
 79 inline unsigned int new_bin_number(const std::    
 80   unsigned int number = 1;                        
 81   for(unsigned int iaxis=0;iaxis<aAxes.size();    
 82     number *= (aAxes[iaxis].bins()+2);            
 83   return number;                                  
 84 }                                                 
 85                                                   
 86 template <class T>                                
 87 inline void add_outflow(const std::vector< axi    
 88   // aAxes[].m_offset contains the offset with    
 89   std::size_t dim = aAxes.size();                 
 90   // new size and offsets :                       
 91   std::vector<int> aoff(dim);                     
 92                                                   
 93   int newn = 1;                                   
 94  {for(unsigned iaxis=0;iaxis<dim;iaxis++) newn    
 95                                                   
 96   aoff[0] = 1;                                    
 97  {for(unsigned iaxis=1;iaxis<dim;iaxis++) {       
 98     aoff[iaxis] = aoff[iaxis-1] * (aAxes[iaxis    
 99   }}                                              
100   // copy :                                       
101   std::vector<T> tmp = aVector;                   
102   int oldn = (int)tmp.size();                     
103   aVector.resize(newn,0);                         
104   // Copy :                                       
105   std::vector<int> is(dim);                       
106   int offset;                                     
107   for(int index=0;index<oldn;index++) {           
108     // Get new offset of index :                  
109     offset = index;                               
110    {for(int iaxis=(int)dim-1;iaxis>=0;iaxis--)    
111       is[iaxis] = offset/aAxes[iaxis].m_offset    
112       offset -= is[iaxis] * aAxes[iaxis].m_off    
113     }}                                            
114     // new offset :                               
115     offset = 0;                                   
116    {for(std::size_t iaxis=0;iaxis<dim;iaxis++)    
117     aVector[offset] = tmp[index];                 
118   }                                               
119 }                                                 
120                                                   
121 inline void add_outflow(std::vector< axis_t >&    
122   // Restore new offsets :                        
123   aAxes[0].m_offset = 1;                          
124   for(unsigned int iaxis=1;iaxis<aAxes.size();    
125     aAxes[iaxis].m_offset = aAxes[iaxis-1].m_o    
126 }                                                 
127                                                   
128 inline bool read_v0(buffer& a_buffer,pd_data_t    
129   int idummy;                                     
130   double ddummy;                                  
131   std::string sdummy;                             
132   if(!a_buffer.read(sdummy)) return false;        
133   if(!a_buffer.read(a_data.m_title)) return fa    
134                                                   
135  {int dim;                                        
136   if(!a_buffer.read(dim)) return false;           
137   a_data.m_dimension = dim;}                      
138                                                   
139  {int nbin;                                       
140   if(!a_buffer.read(nbin)) return false;          
141   a_data.m_bin_number = nbin;}                    
142                                                   
143   if(!a_buffer.read(idummy)) return false; //f    
144   if(!a_buffer.read(idummy)) return false; //f    
145   if(!a_buffer.read(ddummy)) return false; //f    
146                                                   
147   std::vector<int> vec;                           
148   if(!a_buffer.read_array<int>(vec)) return fa    
149   convert<int,unsigned int>(vec,a_data.m_bin_e    
150                                                   
151   if(a_data.m_bin_entries.size()!=a_data.m_bin    
152   if(!a_buffer.read_array<double>(a_data.m_bin    
153   if(a_data.m_bin_Sw.size()!=a_data.m_bin_numb    
154   if(!a_buffer.read_array<double>(a_data.m_bin    
155   if(a_data.m_bin_Sw2.size()!=a_data.m_bin_num    
156   if(a_data.m_dimension>0) {                      
157     a_data.m_axes.resize(a_data.m_dimension);     
158     for(unsigned int iaxis=0;iaxis<a_data.m_di    
159       if(!Axis_read_v0_v3(a_buffer,a_data.m_ax    
160     }                                             
161   }                                               
162   axis_t axisOfValues;                            
163   if(!Axis_read_v0_v3(a_buffer,axisOfValues))     
164  {int dummy;                                      
165   if(!a_buffer.read(dummy)) return false;} //m    
166                                                   
167   // Add outflow :                                
168   a_data.m_bin_number = new_bin_number(a_data.    
169   add_outflow<unsigned int>(a_data.m_axes,a_da    
170   add_outflow<double>(a_data.m_axes,a_data.m_b    
171   add_outflow<double>(a_data.m_axes,a_data.m_b    
172   add_outflow(a_data.m_axes);                     
173                                                   
174   // Not here in v0 :                             
175   std::vector<double> empty;                      
176   empty.resize(a_data.m_dimension,0);             
177   a_data.m_bin_Sxw.resize(a_data.m_bin_number,    
178   a_data.m_bin_Sx2w.resize(a_data.m_bin_number    
179   a_data.m_is_profile = false;                    
180   a_data.m_bin_Svw.clear();                       
181   a_data.m_bin_Sv2w.clear();                      
182                                                   
183   return true;                                    
184 }                                                 
185                                                   
186 inline bool read_v1(buffer& a_buffer,pd_data_t    
187   int idummy;                                     
188   double ddummy;                                  
189   if(!a_buffer.read(a_data.m_title)) return fa    
190                                                   
191  {int dim;                                        
192   if(!a_buffer.read(dim)) return false;           
193   a_data.m_dimension = dim;}                      
194                                                   
195  {int nbin;                                       
196   if(!a_buffer.read(nbin)) return false;          
197   a_data.m_bin_number = nbin;}                    
198                                                   
199   if(!a_buffer.read(idummy)) return false; //f    
200   if(!a_buffer.read(idummy)) return false; //f    
201   if(!a_buffer.read(ddummy)) return false; //f    
202                                                   
203   std::vector<int> vec;                           
204   if(!a_buffer.read_array<int>(vec)) return fa    
205   convert<int,unsigned int>(vec,a_data.m_bin_e    
206                                                   
207   if(a_data.m_bin_entries.size()!=a_data.m_bin    
208   if(!a_buffer.read_array<double>(a_data.m_bin    
209   if(a_data.m_bin_Sw.size()!=a_data.m_bin_numb    
210   if(!a_buffer.read_array<double>(a_data.m_bin    
211   if(a_data.m_bin_Sw2.size()!=a_data.m_bin_num    
212   if(a_data.m_dimension>0) {                      
213     a_data.m_axes.resize(a_data.m_dimension);     
214     for(unsigned int iaxis=0;iaxis<a_data.m_di    
215       if(!Axis_read_v0_v3(a_buffer,a_data.m_ax    
216     }                                             
217   }                                               
218   axis_t axisOfValues;                            
219   if(!Axis_read_v0_v3(a_buffer,axisOfValues))     
220  {int dummy;                                      
221   if(!a_buffer.read(dummy)) return false;} //m    
222                                                   
223   // Add outflow :                                
224   a_data.m_bin_number = new_bin_number(a_data.    
225   add_outflow<unsigned int>(a_data.m_axes,a_da    
226   add_outflow<double>(a_data.m_axes,a_data.m_b    
227   add_outflow<double>(a_data.m_axes,a_data.m_b    
228   add_outflow(a_data.m_axes);                     
229                                                   
230   // Not here in v1 :                             
231   std::vector<double> empty;                      
232   empty.resize(a_data.m_dimension,0);             
233   a_data.m_bin_Sxw.resize(a_data.m_bin_number,    
234   a_data.m_bin_Sx2w.resize(a_data.m_bin_number    
235   a_data.m_is_profile = false;                    
236   a_data.m_bin_Svw.clear();                       
237   a_data.m_bin_Sv2w.clear();                      
238                                                   
239   return true;                                    
240 }                                                 
241                                                   
242 inline bool read_v2(buffer& a_buffer,pd_data_t    
243   int idummy;                                     
244   double ddummy;                                  
245   std::string sdummy;                             
246   if(!a_buffer.read(a_data.m_title)) return fa    
247   if(!a_buffer.read(sdummy)) return false;        
248                                                   
249  {int dim;                                        
250   if(!a_buffer.read(dim)) return false;           
251   a_data.m_dimension = dim;}                      
252                                                   
253  {int nbin;                                       
254   if(!a_buffer.read(nbin)) return false;          
255   a_data.m_bin_number = nbin;}                    
256                                                   
257   if(!a_buffer.read(idummy)) return false; //f    
258   if(!a_buffer.read(idummy)) return false; //f    
259   if(!a_buffer.read(ddummy)) return false; //f    
260                                                   
261   std::vector<int> vec;                           
262   if(!a_buffer.read_array<int>(vec)) return fa    
263   convert<int,unsigned int>(vec,a_data.m_bin_e    
264                                                   
265   if(a_data.m_bin_entries.size()!=a_data.m_bin    
266   if(!a_buffer.read_array<double>(a_data.m_bin    
267   if(a_data.m_bin_Sw.size()!=a_data.m_bin_numb    
268   if(!a_buffer.read_array<double>(a_data.m_bin    
269   if(a_data.m_bin_Sw2.size()!=a_data.m_bin_num    
270   if(a_data.m_dimension>0) {                      
271     a_data.m_axes.resize(a_data.m_dimension);     
272     for(unsigned int iaxis=0;iaxis<a_data.m_di    
273       if(!Axis_read_v0_v3(a_buffer,a_data.m_ax    
274     }                                             
275   }                                               
276   axis_t axisOfValues;                            
277   if(!Axis_read_v0_v3(a_buffer,axisOfValues))     
278  {int dummy;                                      
279   if(!a_buffer.read(dummy)) return false;} //m    
280                                                   
281   // Add outflow :                                
282   a_data.m_bin_number = new_bin_number(a_data.    
283   add_outflow<unsigned int>(a_data.m_axes,a_da    
284   add_outflow<double>(a_data.m_axes,a_data.m_b    
285   add_outflow<double>(a_data.m_axes,a_data.m_b    
286   add_outflow(a_data.m_axes);                     
287                                                   
288   // Not here in v2 :                             
289   std::vector<double> empty;                      
290   empty.resize(a_data.m_dimension,0);             
291   a_data.m_bin_Sxw.resize(a_data.m_bin_number,    
292   a_data.m_bin_Sx2w.resize(a_data.m_bin_number    
293   a_data.m_is_profile = false;                    
294   a_data.m_bin_Svw.clear();                       
295   a_data.m_bin_Sv2w.clear();                      
296                                                   
297   return true;                                    
298 }                                                 
299                                                   
300 inline bool read_v3(buffer& a_buffer,pd_data_t    
301   int idummy;                                     
302   double ddummy;                                  
303                                                   
304   int l;                                          
305   if(!a_buffer.read(l)) return false;             
306   char* str = new char[l+1];                      
307   for (int i = 0; i < l; i++) {                   
308     if(!a_buffer.read(str[i])) { delete [] str    
309   }                                               
310   str[l] = '\0';                                  
311   a_data.m_title = str;                           
312   delete [] str;                                  
313                                                   
314  {int dim;                                        
315   if(!a_buffer.read(dim)) return false;           
316   a_data.m_dimension = dim;}                      
317                                                   
318  {int nbin;                                       
319   if(!a_buffer.read(nbin)) return false;          
320   a_data.m_bin_number = nbin;}                    
321                                                   
322   if(!a_buffer.read(idummy)) return false; //f    
323   if(!a_buffer.read(idummy)) return false; //f    
324   if(!a_buffer.read(ddummy)) return false; //f    
325                                                   
326   std::vector<int> vec;                           
327   if(!a_buffer.read_array<int>(vec)) return fa    
328   convert<int,unsigned int>(vec,a_data.m_bin_e    
329                                                   
330   if(a_data.m_bin_entries.size()!=a_data.m_bin    
331   if(!a_buffer.read_array<double>(a_data.m_bin    
332   if(a_data.m_bin_Sw.size()!=a_data.m_bin_numb    
333   if(!a_buffer.read_array<double>(a_data.m_bin    
334   if(a_data.m_bin_Sw2.size()!=a_data.m_bin_num    
335   if(a_data.m_dimension>0) {                      
336     a_data.m_axes.resize(a_data.m_dimension);     
337     for(unsigned int iaxis=0;iaxis<a_data.m_di    
338       if(!Axis_read_v0_v3(a_buffer,a_data.m_ax    
339     }                                             
340   }                                               
341   axis_t axisOfValues;                            
342   if(!Axis_read_v0_v3(a_buffer,axisOfValues))     
343  {int dummy;                                      
344   if(!a_buffer.read(dummy)) return false;} //m    
345                                                   
346   // Add outflow :                                
347   a_data.m_bin_number = new_bin_number(a_data.    
348   add_outflow<unsigned int>(a_data.m_axes,a_da    
349   add_outflow<double>(a_data.m_axes,a_data.m_b    
350   add_outflow<double>(a_data.m_axes,a_data.m_b    
351   add_outflow(a_data.m_axes);                     
352                                                   
353   // Not here in v3 :                             
354   std::vector<double> empty;                      
355   empty.resize(a_data.m_dimension,0);             
356   a_data.m_bin_Sxw.resize(a_data.m_bin_number,    
357   a_data.m_bin_Sx2w.resize(a_data.m_bin_number    
358   a_data.m_is_profile = false;                    
359   a_data.m_bin_Svw.clear();                       
360   a_data.m_bin_Sv2w.clear();                      
361                                                   
362   return true;                                    
363 }                                                 
364                                                   
365 inline bool read_v4(buffer& a_buffer,pd_data_t    
366   int idummy;                                     
367   double ddummy;                                  
368                                                   
369   int l;                                          
370   if(!a_buffer.read(l)) return false;             
371   char* str = new char[l+1];                      
372   for (int i = 0; i < l; i++) {                   
373     if(!a_buffer.read(str[i])) { delete [] str    
374   }                                               
375   str[l] = '\0';                                  
376   a_data.m_title = str;                           
377   delete [] str;                                  
378                                                   
379  {int dim;                                        
380   if(!a_buffer.read(dim)) return false;           
381   a_data.m_dimension = dim;}                      
382                                                   
383  {int nbin;                                       
384   if(!a_buffer.read(nbin)) return false;          
385   a_data.m_bin_number = nbin;}                    
386                                                   
387   if(!a_buffer.read(idummy)) return false; //f    
388   if(!a_buffer.read(idummy)) return false; //f    
389   if(!a_buffer.read(ddummy)) return false; //f    
390                                                   
391   std::vector<int> vec;                           
392   if(!a_buffer.read_array<int>(vec)) return fa    
393   convert<int,unsigned int>(vec,a_data.m_bin_e    
394                                                   
395   if(a_data.m_bin_entries.size()!=a_data.m_bin    
396   if(!a_buffer.read_array<double>(a_data.m_bin    
397   if(a_data.m_bin_Sw.size()!=a_data.m_bin_numb    
398   if(!a_buffer.read_array<double>(a_data.m_bin    
399   if(a_data.m_bin_Sw2.size()!=a_data.m_bin_num    
400   if(a_data.m_dimension>0) {                      
401     a_data.m_axes.resize(a_data.m_dimension);     
402     for(unsigned int iaxis=0;iaxis<a_data.m_di    
403       if(!Axis_read_v4_v6(a_buffer,a_data.m_ax    
404     }                                             
405   }                                               
406  {int dummy;                                      
407   if(!a_buffer.read(dummy)) return false;} //m    
408                                                   
409   // Add outflow :                                
410   a_data.m_bin_number = new_bin_number(a_data.    
411   add_outflow<unsigned int>(a_data.m_axes,a_da    
412   add_outflow<double>(a_data.m_axes,a_data.m_b    
413   add_outflow<double>(a_data.m_axes,a_data.m_b    
414   add_outflow(a_data.m_axes);                     
415                                                   
416   // Not here in v4 :                             
417   std::vector<double> empty;                      
418   empty.resize(a_data.m_dimension,0);             
419   a_data.m_bin_Sxw.resize(a_data.m_bin_number,    
420   a_data.m_bin_Sx2w.resize(a_data.m_bin_number    
421   a_data.m_is_profile = false;                    
422   a_data.m_bin_Svw.clear();                       
423   a_data.m_bin_Sv2w.clear();                      
424                                                   
425   return true;                                    
426 }                                                 
427                                                   
428 inline bool read_v5(buffer& a_buffer,pd_data_t    
429   int idummy;                                     
430   double ddummy;                                  
431   if(!a_buffer.read(a_data.m_title)) return fa    
432                                                   
433  {int dim;                                        
434   if(!a_buffer.read(dim)) return false;           
435   a_data.m_dimension = dim;}                      
436                                                   
437  {int nbin;                                       
438   if(!a_buffer.read(nbin)) return false;          
439   a_data.m_bin_number = nbin;}                    
440                                                   
441   if(!a_buffer.read(idummy)) return false; //f    
442   if(!a_buffer.read(idummy)) return false; //f    
443   if(!a_buffer.read(ddummy)) return false; //f    
444                                                   
445   std::vector<int> vec;                           
446   if(!a_buffer.read_array<int>(vec)) return fa    
447   convert<int,unsigned int>(vec,a_data.m_bin_e    
448                                                   
449   if(a_data.m_bin_entries.size()!=a_data.m_bin    
450   if(!a_buffer.read_array<double>(a_data.m_bin    
451   if(a_data.m_bin_Sw.size()!=a_data.m_bin_numb    
452   if(!a_buffer.read_array<double>(a_data.m_bin    
453   if(a_data.m_bin_Sw2.size()!=a_data.m_bin_num    
454   if(a_data.m_dimension>0) {                      
455     a_data.m_axes.resize(a_data.m_dimension);     
456     for(unsigned int iaxis=0;iaxis<a_data.m_di    
457       if(!Axis_read_v4_v6(a_buffer,a_data.m_ax    
458     }                                             
459   }                                               
460  {int dummy;                                      
461   if(!a_buffer.read(dummy)) return false;} //m    
462                                                   
463   // Add outflow :                                
464   a_data.m_bin_number = new_bin_number(a_data.    
465   add_outflow<unsigned int>(a_data.m_axes,a_da    
466   add_outflow<double>(a_data.m_axes,a_data.m_b    
467   add_outflow<double>(a_data.m_axes,a_data.m_b    
468   add_outflow(a_data.m_axes);                     
469                                                   
470   // Not here in v5 :                             
471   std::vector<double> empty;                      
472   empty.resize(a_data.m_dimension,0);             
473   a_data.m_bin_Sxw.resize(a_data.m_bin_number,    
474   a_data.m_bin_Sx2w.resize(a_data.m_bin_number    
475   a_data.m_is_profile = false;                    
476   a_data.m_bin_Svw.clear();                       
477   a_data.m_bin_Sv2w.clear();                      
478                                                   
479   return true;                                    
480 }                                                 
481                                                   
482 inline bool read_v6(buffer& a_buffer,pd_data_t    
483   int idummy;                                     
484   double ddummy;                                  
485   if(!a_buffer.read(a_data.m_title)) return fa    
486                                                   
487  {int dim;                                        
488   if(!a_buffer.read(dim)) return false;           
489   a_data.m_dimension = dim;}                      
490                                                   
491  {int nbin;                                       
492   if(!a_buffer.read(nbin)) return false;          
493   a_data.m_bin_number = nbin;}                    
494                                                   
495   if(!a_buffer.read(idummy)) return false; //f    
496   if(!a_buffer.read(idummy)) return false; //f    
497   if(!a_buffer.read(ddummy)) return false; //f    
498                                                   
499   std::vector<int> vec;                           
500   if(!a_buffer.read_array<int>(vec)) return fa    
501   convert<int,unsigned int>(vec,a_data.m_bin_e    
502                                                   
503   if(a_data.m_bin_entries.size()!=a_data.m_bin    
504   if(!a_buffer.read_array<double>(a_data.m_bin    
505   if(a_data.m_bin_Sw.size()!=a_data.m_bin_numb    
506   if(!a_buffer.read_array<double>(a_data.m_bin    
507   if(a_data.m_bin_Sw2.size()!=a_data.m_bin_num    
508   if(a_data.m_dimension>0) {                      
509     a_data.m_axes.resize(a_data.m_dimension);     
510     for(unsigned int iaxis=0;iaxis<a_data.m_di    
511       if(!Axis_read_v4_v6(a_buffer,a_data.m_ax    
512     }                                             
513   }                                               
514  {int dummy;                                      
515   if(!a_buffer.read(dummy)) return false;} //m    
516                                                   
517   // Profile :                                    
518   if(!a_buffer.read(a_data.m_is_profile)) retu    
519   if(a_data.m_is_profile) {                       
520     if(!a_buffer.read_array<double>(a_data.m_b    
521     if(a_data.m_bin_Svw.size()!=a_data.m_bin_n    
522     if(!a_buffer.read(a_data.m_cut_v)) return     
523     if(!a_buffer.read(a_data.m_min_v)) return     
524     if(!a_buffer.read(a_data.m_max_v)) return     
525   }                                               
526                                                   
527   // Add outflow :                                
528   a_data.m_bin_number = new_bin_number(a_data.    
529   add_outflow<unsigned int>(a_data.m_axes,a_da    
530   add_outflow<double>(a_data.m_axes,a_data.m_b    
531   add_outflow<double>(a_data.m_axes,a_data.m_b    
532   add_outflow<double>(a_data.m_axes,a_data.m_b    
533   add_outflow(a_data.m_axes);                     
534                                                   
535   // Not here in v6 :                             
536   std::vector<double> empty;                      
537   empty.resize(a_data.m_dimension,0);             
538   a_data.m_bin_Sxw.resize(a_data.m_bin_number,    
539   a_data.m_bin_Sx2w.resize(a_data.m_bin_number    
540   if(a_data.m_is_profile) {                       
541     a_data.m_bin_Sv2w.resize(a_data.m_bin_numb    
542   }                                               
543                                                   
544   return true;                                    
545 }                                                 
546                                                   
547 inline bool read_v7(buffer& a_buffer,pd_data_t    
548   if(!a_buffer.read(a_data.m_title)) return fa    
549                                                   
550  {int dim;                                        
551   if(!a_buffer.read(dim)) return false;           
552   a_data.m_dimension = dim;}                      
553                                                   
554  {int nbin;                                       
555   if(!a_buffer.read(nbin)) return false;          
556   a_data.m_bin_number = nbin;}                    
557                                                   
558   std::vector<int> vec;                           
559   if(!a_buffer.read_array<int>(vec)) return fa    
560   convert<int,unsigned int>(vec,a_data.m_bin_e    
561                                                   
562   if(a_data.m_bin_entries.size()!=a_data.m_bin    
563   if(!a_buffer.read_array<double>(a_data.m_bin    
564   if(a_data.m_bin_Sw.size()!=a_data.m_bin_numb    
565   if(!a_buffer.read_array<double>(a_data.m_bin    
566   if(a_data.m_bin_Sw2.size()!=a_data.m_bin_num    
567   if(!a_buffer.read_array2<double>(a_data.m_bi    
568   if(a_data.m_bin_Sxw.size()!=a_data.m_bin_num    
569   if(!a_buffer.read_array2<double>(a_data.m_bi    
570   if(a_data.m_bin_Sx2w.size()!=a_data.m_bin_nu    
571   if(a_data.m_dimension>0) {                      
572     a_data.m_axes.resize(a_data.m_dimension);     
573     for(unsigned int iaxis=0;iaxis<a_data.m_di    
574       if(!Axis_read_v7(a_buffer,a_data.m_axes[    
575     }                                             
576   }                                               
577  {int dummy;                                      
578   if(!a_buffer.read(dummy)) return false;} //m    
579   // Profile :                                    
580   if(!a_buffer.read(a_data.m_is_profile)) retu    
581   if(a_data.m_is_profile) {                       
582     if(!a_buffer.read_array<double>(a_data.m_b    
583     if(a_data.m_bin_Svw.size()!=a_data.m_bin_n    
584     if(!a_buffer.read_array<double>(a_data.m_b    
585     if(a_data.m_bin_Sv2w.size()!=a_data.m_bin_    
586     if(!a_buffer.read(a_data.m_cut_v)) return     
587     if(!a_buffer.read(a_data.m_min_v)) return     
588     if(!a_buffer.read(a_data.m_max_v)) return     
589   }                                               
590                                                   
591   return true;                                    
592 }                                                 
593                                                   
594 inline bool read_annotations(buffer& a_buffer,    
595   a_annotations.clear(); //reset() does not re    
596   int number;                                     
597   if(!a_buffer.read(number)) return false;        
598   for(int index=0;index<number;index++) {         
599     std::string key;                              
600     if(!a_buffer.read(key)) return false;         
601     std::string value;                            
602     if(!a_buffer.read(value)) return false;       
603     bool sticky;                                  
604     if(!a_buffer.read(sticky)) return false;      
605     //if(!a_annotations.addItem(key,value,stic    
606     a_annotations[key] = value;                   
607   }                                               
608   return true;                                    
609 }                                                 
610                                                   
611 inline bool read_THistogram(buffer& a_buffer,p    
612                                                   
613   short v;                                        
614   if(!a_buffer.read_version(v)) return false;     
615                                                   
616  {std::string name,title;                         
617   if(!Named_stream(a_buffer,name,title)) retur    
618                                                   
619   if(v==0) {                                      
620     if(!read_v0(a_buffer,a_data)) return false    
621   } else if(v==1) {                               
622     if(!read_v1(a_buffer,a_data)) return false    
623   } else if(v==2) {                               
624     if(!read_v2(a_buffer,a_data)) return false    
625   } else if(v==3) {                               
626     if(!read_v3(a_buffer,a_data)) return false    
627   } else if(v==4) {                               
628     if(!read_v4(a_buffer,a_data)) return false    
629   } else if(v==5) {                               
630     if(!read_v5(a_buffer,a_data)) return false    
631   } else if(v==6) {                               
632     if(!read_v6(a_buffer,a_data)) return false    
633   } else if(v==7) {                               
634     if(!read_v7(a_buffer,a_data)) return false    
635   } else if(v==8) {                               
636     if(!read_annotations(a_buffer,a_annotation    
637     if(!read_v7(a_buffer,a_data)) return false    
638   } else {                                        
639     return false;                                 
640   }                                               
641                                                   
642   //data.m_coords.resize(data.m_dimension,0);     
643   //data.m_ints.resize(data.m_dimension,0);       
644                                                   
645   a_data.update_fast_getters();                   
646                                                   
647   return true;                                    
648 }                                                 
649                                                   
650 inline const std::string& THistogram_cls(){       
651   static const std::string s_v("THistogram");     
652   return s_v;                                     
653 }                                                 
654                                                   
655 }}                                                
656                                                   
657 #include "key"                                    
658                                                   
659 namespace tools {                                 
660 namespace rroot {                                 
661                                                   
662 inline bool read_key_THistogram(ifile& a_file,    
663   std::ostream& out = a_key.out();                
664   if(a_key.object_class()!=THistogram_cls()) {    
665     if(a_warn) out << "tools::rroot::read_key_    
666     return 0;                                     
667   }                                               
668   unsigned int sz;                                
669   char* buf = a_key.get_object_buffer(a_file,s    
670   if(!buf) {                                      
671     out << "tools::rroot::read_key_THisogram :    
672     return 0;                                     
673   }                                               
674   buffer b(out,a_file.byte_swap(),sz,buf,a_key    
675   return read_THistogram(b,a_data,a_annotation    
676 }                                                 
677                                                   
678 }}                                                
679                                                   
680 #include "../histo/h1d"                           
681 #include "../histo/h2d"                           
682 #include "../histo/p1d"                           
683 #include "../histo/p2d"                           
684                                                   
685 namespace tools {                                 
686 namespace rroot {                                 
687                                                   
688 inline histo::h1d* THistogram_to_h1d(const pd_    
689   unsigned int dim = a_data.m_dimension;          
690   bool is_profile = a_data.m_is_profile;          
691   if(dim!=1) return 0;                            
692   if(is_profile) return 0;                        
693   histo::h1d* histo = new histo::h1d("",10,0,1    
694   histo->copy_from_data(a_data);                  
695   return histo;                                   
696 }                                                 
697                                                   
698 inline histo::h2d* THistogram_to_h2d(const pd_    
699   unsigned int dim = a_data.m_dimension;          
700   bool is_profile = a_data.m_is_profile;          
701   if(dim!=2) return 0;                            
702   if(is_profile) return 0;                        
703   histo::h2d* histo = new histo::h2d("",10,0,1    
704   histo->copy_from_data(a_data);                  
705   return histo;                                   
706 }                                                 
707                                                   
708 inline histo::p1d* THistogram_to_p1d(const pd_    
709   unsigned int dim = a_data.m_dimension;          
710   bool is_profile = a_data.m_is_profile;          
711   if(dim!=1) return 0;                            
712   if(!is_profile) return 0;                       
713   histo::p1d* histo = new histo::p1d("",10,0,1    
714   histo->copy_from_data(a_data);                  
715   return histo;                                   
716 }                                                 
717                                                   
718 inline histo::p2d* THistogram_to_p2d(const pd_    
719   unsigned int dim = a_data.m_dimension;          
720   bool is_profile = a_data.m_is_profile;          
721   if(dim!=2) return 0;                            
722   if(!is_profile) return 0;                       
723   histo::p2d* histo = new histo::p2d("",10,0,1    
724   histo->copy_from_data(a_data);                  
725   return histo;                                   
726 }                                                 
727                                                   
728 }}                                                
729                                                   
730 #endif