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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/wroot/streamers (Version 11.3.0) and /externals/g4tools/include/tools/wroot/streamers (Version 7.1.p1)


  1 // Copyright (C) 2010, Guy Barrand. All rights    
  2 // See the file tools.license for terms.          
  3                                                   
  4 #ifndef tools_wroot_streamers                     
  5 #define tools_wroot_streamers                     
  6                                                   
  7 #include "named"                                  
  8 #include "directory"                              
  9 #include "file"                                   
 10 #include "../vmanip" //convert                    
 11                                                   
 12 #include "../histo/h1d"                           
 13 #include "../histo/h2d"                           
 14 #include "../histo/h3d"                           
 15 #include "../histo/p1d"                           
 16 #include "../histo/p2d"                           
 17                                                   
 18 #include "../histo/h1df"                          
 19 #include "../histo/h2df"                          
 20 #include "../histo/h3df"                          
 21                                                   
 22 namespace tools {                                 
 23 namespace wroot {                                 
 24                                                   
 25 typedef histo::histo_data<double,unsigned int,    
 26 typedef histo::histo_data<double,unsigned int,    
 27 typedef histo::profile_data<double,unsigned in    
 28                                                   
 29 inline bool AttAxis_stream(buffer& a_buffer) {    
 30   int fNdivisions = 510;   //Number of divisio    
 31   short fAxisColor = 1;    //color of the line    
 32   short fLabelColor = 1;   //color of labels      
 33   short fLabelFont = 62;    //font for labels     
 34   float fLabelOffset = 0.005F;  //offset of la    
 35   float fLabelSize = 0.04F;    //size of label    
 36   float fTickLength = 0.03F;   //length of tic    
 37   float fTitleOffset = 1;  //offset of axis ti    
 38   float fTitleSize = 0.04F;    //size of axis     
 39   short fTitleColor = 1;   //color of axis tit    
 40   short fTitleFont = 62;    //font for axis ti    
 41                                                   
 42   // Version 4 streaming (ROOT/v3-00-6).          
 43   unsigned int beg;                               
 44   if(!a_buffer.write_version(4,beg)) return fa    
 45                                                   
 46   if(!a_buffer.write(fNdivisions)) return fals    
 47   if(!a_buffer.write(fAxisColor)) return false    
 48   if(!a_buffer.write(fLabelColor)) return fals    
 49   if(!a_buffer.write(fLabelFont)) return false    
 50   if(!a_buffer.write(fLabelOffset)) return fal    
 51   if(!a_buffer.write(fLabelSize)) return false    
 52   if(!a_buffer.write(fTickLength)) return fals    
 53   if(!a_buffer.write(fTitleOffset)) return fal    
 54   if(!a_buffer.write(fTitleSize)) return false    
 55   if(!a_buffer.write(fTitleColor)) return fals    
 56   if(!a_buffer.write(fTitleFont)) return false    
 57                                                   
 58   if(!a_buffer.set_byte_count(beg)) return fal    
 59   return true;                                    
 60 }                                                 
 61                                                   
 62 inline bool axis_stream(buffer& a_buffer,         
 63                         const histo::axis<doub    
 64                         const std::string& a_n    
 65                         const std::string& a_t    
 66     // Version 6 streaming (ROOT/v3-00-6).        
 67                                                   
 68     unsigned int beg;                             
 69     if(!a_buffer.write_version(6,beg)) return     
 70                                                   
 71     if(!Named_stream(a_buffer,a_name,a_title))    
 72                                                   
 73     if(!AttAxis_stream(a_buffer)) return false    
 74                                                   
 75     if(!a_buffer.write(a_axis.bins())) return     
 76     if(!a_buffer.write(a_axis.lower_edge())) r    
 77     if(!a_buffer.write(a_axis.upper_edge())) r    
 78                                                   
 79     // fXbins                                     
 80     //if(a_axis.m_fixed) {                        
 81     //  std::vector<double> v;                    
 82     //  ArrayT<double> dummy(v);                  
 83     //  if(!dummy.stream(a_buffer)) return fal    
 84     //} else {                                    
 85       if(!a_buffer.write_array(a_axis.edges())    
 86     //}                                           
 87                                                   
 88     if(!a_buffer.write((int)0)) return false;     
 89     if(!a_buffer.write((int)0)) return false;     
 90                                                   
 91     //Bool_t                                      
 92     if(!a_buffer.write((unsigned char)0)) retu    
 93                                                   
 94     //TString                                     
 95     if(!a_buffer.write(std::string())) return     
 96                                                   
 97     if(!a_buffer.set_byte_count(beg)) return f    
 98                                                   
 99     return true;                                  
100 }                                                 
101                                                   
102 inline bool List_empty_stream(buffer& a_buffer    
103   unsigned int beg;                               
104   if(!a_buffer.write_version(4,beg)) return fa    
105   if(!Object_stream(a_buffer)) return false;      
106   std::string name;                               
107   if(!a_buffer.write(name)) return false;         
108   int nobjects = 0;                               
109   if(!a_buffer.write(nobjects)) return false;     
110   if(!a_buffer.set_byte_count(beg)) return fal    
111   return true;                                    
112 }                                                 
113                                                   
114 template <class HIST>                             
115 inline std::string axis_title(const HIST& a_h,    
116   typedef std::map<std::string,std::string> an    
117   annotations_t::const_iterator it = a_h.annot    
118   if(it==a_h.annotations().end()) return std::    
119   return (*it).second;                            
120 }                                                 
121                                                   
122 template <class HIST>                             
123 inline bool TH_write_1D(buffer& a_buffer,         
124                         const HIST& a_h,          
125                         const std::string& a_n    
126                         const std::vector<doub    
127                                                   
128     if(!a_buffer.write_version(3)) return fals    
129                                                   
130     if(!Named_stream(a_buffer,a_name,a_h.title    
131                                                   
132     if(!AttLine_stream(a_buffer)) return false    
133     if(!AttFill_stream(a_buffer)) return false    
134     if(!AttMarker_stream(a_buffer)) return fal    
135                                                   
136     if(!a_buffer.write((int)a_h.get_bins())) r    
137                                                   
138     //fXAxis,fYAxis,fZAxis                        
139     if(a_h.dimension()==3) {                      
140                                                   
141      {histo::axis<double,unsigned int> haxis(a    
142       if(!axis_stream(a_buffer,haxis,"xaxis",a    
143                                                   
144      {histo::axis<double,unsigned int> haxis(a    
145       if(!axis_stream(a_buffer,haxis,"yaxis",a    
146                                                   
147      {histo::axis<double,unsigned int> haxis(a    
148       if(!axis_stream(a_buffer,haxis,"zaxis",a    
149                                                   
150     } else if(a_h.dimension()==2) {               
151                                                   
152      {histo::axis<double,unsigned int> haxis(a    
153       if(!axis_stream(a_buffer,haxis,"xaxis",a    
154                                                   
155      {histo::axis<double,unsigned int> haxis(a    
156       if(!axis_stream(a_buffer,haxis,"yaxis",a    
157                                                   
158      {histo::axis<double,unsigned int> dummy;     
159       dummy.configure(1,0,1);                     
160       if(!axis_stream(a_buffer,dummy,"zaxis",a    
161                                                   
162     } else if(a_h.dimension()==1) {               
163                                                   
164      {histo::axis<double,unsigned int> haxis(a    
165       if(!axis_stream(a_buffer,haxis,"xaxis",a    
166                                                   
167      {histo::axis<double,unsigned int> dummy;     
168       dummy.configure(1,0,1);                     
169       if(!axis_stream(a_buffer,dummy,"yaxis",a    
170                                                   
171      {histo::axis<double,unsigned int> dummy;     
172       dummy.configure(1,0,1);                     
173       if(!axis_stream(a_buffer,dummy,"zaxis",a    
174                                                   
175     } else {                                      
176       return false;                               
177     }                                             
178                                                   
179     if(!a_buffer.write((short)(1000 * 0.25)))     
180     if(!a_buffer.write((short)(1000 * 0.5))) r    
181                                                   
182     if(!a_buffer.write((double)a_h.all_entries    
183     if(!a_buffer.write((double)a_h.get_in_rang    
184     if(!a_buffer.write((double)a_h.get_in_rang    
185                                                   
186    {double value;                                 
187     a_h.get_ith_axis_Sxw(0,value);                
188     if(!a_buffer.write(value)) return false;}     
189                                                   
190    {double value;                                 
191     a_h.get_ith_axis_Sx2w(0,value);               
192     if(!a_buffer.write(value)) return false;}     
193                                                   
194     if(!a_buffer.write((double)-1111)) return     
195     if(!a_buffer.write((double)-1111)) return     
196     if(!a_buffer.write((double)0)) return fals    
197                                                   
198     if(!a_buffer.write_array(std::vector<doubl    
199                                                   
200     if(!a_buffer.write_array(a_bin_Sw2)) retur    
201                                                   
202     // store annotation on fOption                
203     // but try to fool CERN-ROOT in order that    
204     // understand fOption as.. CERN-ROOT optio    
205    //{std::string opt = " "+fAnnotation;          
206    // opt[0] = 0; //awfull trick                  
207    // if(!a_buffer.write(opt)) return false;}     
208    {std::string opt;                              
209     if(!a_buffer.write(opt)) return false;} //    
210                                                   
211     if(!List_empty_stream(a_buffer)) return fa    
212                                                   
213     return true;                                  
214 }                                                 
215                                                   
216 template <class HIST>                             
217 inline bool TH_write_2D(buffer& a_buffer,         
218                         const HIST& a_h,          
219                         const std::string& a_n    
220                         const std::vector<doub    
221   if(!a_buffer.write_version(3)) return false;    
222   if(!TH_write_1D(a_buffer,a_h,a_name,a_bin_Sw    
223   if(!a_buffer.write((double)1)) return false;    
224                                                   
225  {double value;                                   
226   a_h.get_ith_axis_Sxw(1,value);                  
227   if(!a_buffer.write(value)) return false;}       
228                                                   
229  {double value;                                   
230   a_h.get_ith_axis_Sx2w(1,value);                 
231   if(!a_buffer.write(value)) return false;}       
232                                                   
233   if(!a_buffer.write((double)a_h.Sxyw())) retu    
234                                                   
235   return true;                                    
236 }                                                 
237                                                   
238 template <class HIST>                             
239 inline bool TH_write_3D(buffer& a_buffer,         
240                         const HIST& a_h,          
241                         const std::string& a_n    
242                         const std::vector<doub    
243   if(!a_buffer.write_version(4)) return false;    
244   if(!TH_write_1D(a_buffer,a_h,a_name,a_bin_Sw    
245   if(!Att3D_stream(a_buffer)) return false;       
246                                                   
247  {double value;                                   
248   a_h.get_ith_axis_Sxw(1,value);                  
249   if(!a_buffer.write(value)) return false;}       
250  {double value;                                   
251   a_h.get_ith_axis_Sx2w(1,value);                 
252   if(!a_buffer.write(value)) return false;}       
253   if(!a_buffer.write((double)a_h.Sxyw())) retu    
254                                                   
255  {double value;                                   
256   a_h.get_ith_axis_Sxw(2,value);                  
257   if(!a_buffer.write(value)) return false;}       
258  {double value;                                   
259   a_h.get_ith_axis_Sx2w(2,value);                 
260   if(!a_buffer.write(value)) return false;}       
261   if(!a_buffer.write((double)a_h.Szxw())) retu    
262   if(!a_buffer.write((double)a_h.Syzw())) retu    
263                                                   
264   return true;                                    
265 }                                                 
266                                                   
267 inline bool TH1F_stream(buffer& a_buffer,const    
268   if(!a_buffer.write_version(1)) return false;    
269   std::vector<double> bins_sum_w2d;               
270   convert<float,double>(a_h.bins_sum_w2(),bins    
271   if(!TH_write_1D(a_buffer,a_h,a_name,bins_sum    
272   if(!a_buffer.write_array(a_h.bins_sum_w()))     
273   return true;                                    
274 }                                                 
275                                                   
276 inline bool TH1F_stream(buffer& a_buffer,const    
277   if(!a_buffer.write_version(1)) return false;    
278   if(!TH_write_1D(a_buffer,a_h,a_name,a_h.bins    
279   std::vector<float> bins_sum_wf;                 
280   convert<double,float>(a_h.bins_sum_w(),bins_    
281   if(!a_buffer.write_array(bins_sum_wf)) retur    
282   return true;                                    
283 }                                                 
284                                                   
285 inline bool TH1D_stream(buffer& a_buffer,const    
286   if(!a_buffer.write_version(1)) return false;    
287   if(!TH_write_1D(a_buffer,a_h,a_name,a_h.bins    
288   if(!a_buffer.write_array(a_h.bins_sum_w()))     
289   return true;                                    
290 }                                                 
291                                                   
292 inline bool TH2F_stream(buffer& a_buffer,const    
293   if(!a_buffer.write_version(3)) return false;    
294   if(!TH_write_2D(a_buffer,a_h,a_name,a_h.bins    
295   std::vector<float> bins_sum_wf;                 
296   convert<double,float>(a_h.bins_sum_w(),bins_    
297   if(!a_buffer.write_array(bins_sum_wf)) retur    
298   return true;                                    
299 }                                                 
300                                                   
301 inline bool TH2F_stream(buffer& a_buffer,const    
302   if(!a_buffer.write_version(3)) return false;    
303   std::vector<double> bins_sum_w2d;               
304   convert<float,double>(a_h.bins_sum_w2(),bins    
305   if(!TH_write_2D(a_buffer,a_h,a_name,bins_sum    
306   if(!a_buffer.write_array(a_h.bins_sum_w()))     
307   return true;                                    
308 }                                                 
309                                                   
310 inline bool TH2D_stream(buffer& a_buffer,const    
311   if(!a_buffer.write_version(3)) return false;    
312   if(!TH_write_2D(a_buffer,a_h,a_name,a_h.bins    
313   if(!a_buffer.write_array(a_h.bins_sum_w()))     
314   return true;                                    
315 }                                                 
316                                                   
317 inline bool TH3F_stream(buffer& a_buffer,const    
318   if(!a_buffer.write_version(3)) return false;    
319   if(!TH_write_3D(a_buffer,a_h,a_name,a_h.bins    
320   std::vector<float> bins_sum_wf;                 
321   convert<double,float>(a_h.bins_sum_w(),bins_    
322   if(!a_buffer.write_array(bins_sum_wf)) retur    
323   return true;                                    
324 }                                                 
325                                                   
326 inline bool TH3F_stream(buffer& a_buffer,const    
327   if(!a_buffer.write_version(3)) return false;    
328   std::vector<double> bins_sum_w2d;               
329   convert<float,double>(a_h.bins_sum_w2(),bins    
330   if(!TH_write_3D(a_buffer,a_h,a_name,bins_sum    
331   if(!a_buffer.write_array(a_h.bins_sum_w()))     
332   return true;                                    
333 }                                                 
334                                                   
335 inline bool TH3D_stream(buffer& a_buffer,const    
336   if(!a_buffer.write_version(3)) return false;    
337   if(!TH_write_3D(a_buffer,a_h,a_name,a_h.bins    
338   if(!a_buffer.write_array(a_h.bins_sum_w()))     
339   return true;                                    
340 }                                                 
341                                                   
342 inline bool TProfile_stream(buffer& a_buffer,c    
343   if(!a_buffer.write_version(4)) return false;    
344                                                   
345   //WARNING : the mapping histo::p1d / TProfil    
346   //p1d::m_bin_Svw  <---> TProfile::fArray        
347   //p1d::m_bin_Sv2w <---> TProfile::fSumw2        
348   //p1d::m_bin_Sw   <---> TProfile::fBinEntrie    
349                                                   
350   // TH1D_stream(a_buffer,h,a_name) :             
351   //if(!a_buffer.write_version(1)) return fals    
352   //if(!TH_write_1D(a_buffer,a_h,a_name,a_h.bi    
353   //if(!a_buffer.write_array(a_h.bins_sum_w())    
354   // but for profile :                            
355   if(!a_buffer.write_version(1)) return false;    
356   if(!TH_write_1D(a_buffer,a_p,a_name,a_p.bins    
357   if(!a_buffer.write_array(a_p.bins_sum_vw()))    
358                                                   
359   //TProfile specific :                           
360   if(!a_buffer.write_array(a_p.bins_sum_w()))     
361                                                   
362   int errorMode = 0;                              
363   if(!a_buffer.write(errorMode)) return false;    
364   if(!a_buffer.write(a_p.min_v())) return fals    
365   if(!a_buffer.write(a_p.max_v())) return fals    
366                                                   
367   // version 4 :                                  
368   if(!a_buffer.write(a_p.get_Svw())) return fa    
369   if(!a_buffer.write(a_p.get_Sv2w())) return f    
370                                                   
371   return true;                                    
372 }                                                 
373                                                   
374 inline bool TProfile2D_stream(buffer& a_buffer    
375   if(!a_buffer.write_version(5)) return false;    
376                                                   
377   //WARNING : the mapping histo::p2d / TProfil    
378   //p2d::m_bin_Svw  <---> TProfile2D::fArray      
379   //p2d::m_bin_Sv2w <---> TProfile2D::fSumw2      
380   //p2d::m_bin_Sw   <---> TProfile2D::fBinEntr    
381                                                   
382   // TH2D_stream(a_buffer,h,a_name) :             
383   //if(!a_buffer.write_version(3)) return fals    
384   //if(!TH_write_2D(a_buffer,a_h,a_name,a_h.bi    
385   //if(!a_buffer.write_array(a_h.bins_sum_w())    
386   // for profile :                                
387   if(!a_buffer.write_version(3)) return false;    
388   if(!TH_write_2D(a_buffer,a_p,a_name,a_p.bins    
389   if(!a_buffer.write_array(a_p.bins_sum_vw()))    
390                                                   
391   //TProfile2D specific :                         
392   if(!a_buffer.write_array(a_p.bins_sum_w()))     
393                                                   
394   int errorMode = 0;                              
395   if(!a_buffer.write(errorMode)) return false;    
396   if(!a_buffer.write(a_p.min_v())) return fals    
397   if(!a_buffer.write(a_p.max_v())) return fals    
398                                                   
399   // version 5 :                                  
400   if(!a_buffer.write(a_p.get_Svw())) return fa    
401   if(!a_buffer.write(a_p.get_Sv2w())) return f    
402                                                   
403   return true;                                    
404 }                                                 
405                                                   
406 }}                                                
407                                                   
408 #endif