Geant4 Cross Reference

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

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/branch_element (Version 11.3.0) and /externals/g4tools/include/tools/rroot/branch_element (Version 9.4.p2)


  1 // Copyright (C) 2010, Guy Barrand. All rights    
  2 // See the file tools.license for terms.          
  3                                                   
  4 #ifndef tools_rroot_branch_element                
  5 #define tools_rroot_branch_element                
  6                                                   
  7 #include "branch"                                 
  8 #include "stl_vector"                             
  9                                                   
 10 #include "info"                                   
 11 #include "obj_list"                               
 12                                                   
 13 //#define TOOLS_RROOT_BRANCH_ELEMENT_DUMP         
 14                                                   
 15 namespace tools {                                 
 16 namespace rroot {                                 
 17                                                   
 18 class branch_element : public branch {            
 19   typedef branch parent;                          
 20 public:                                           
 21   static const std::string& s_class() {           
 22     static const std::string s_v("tools::rroot    
 23     return s_v;                                   
 24   }                                               
 25 public: //iro                                     
 26   virtual void* cast(const std::string& a_clas    
 27     if(void* p = cmp_cast<branch_element>(this    
 28     return parent::cast(a_class);                 
 29   }                                               
 30   virtual const std::string& s_cls() const {re    
 31 public:                                           
 32   static cid id_class() {return branch_element    
 33   virtual void* cast(cid a_class) const {         
 34     if(void* p = cmp_cast<branch_element>(this    
 35     return parent::cast(a_class);                 
 36   }                                               
 37 public:                                           
 38   virtual bool stream(buffer& a_buffer) {         
 39     _clear();                                     
 40                                                   
 41     short v;                                      
 42     unsigned int _s,_c;                           
 43     if(!a_buffer.read_version(v,_s,_c)) return    
 44                                                   
 45     //::printf("debug : tools::branch_element:    
 46                                                   
 47     if(!parent::stream(a_buffer)) {               
 48       m_out << "tools::rroot::branch_element::    
 49       return false;                               
 50     }                                             
 51                                                   
 52     if(v<=7) {                                    
 53       if(!a_buffer.read(fClassName)) return fa    
 54       if(!a_buffer.read(fClassVersion)) return    
 55       if(!a_buffer.read(fID)) return false;       
 56       if(!a_buffer.read(fType)) return false;     
 57       if(!a_buffer.read(fStreamerType)) return    
 58     } else { //v>=8                               
 59       if(!a_buffer.read(fClassName)) return fa    
 60       //::printf("debug : tools::branch_elemen    
 61       std::string fParentName;                    
 62       if(!a_buffer.read(fParentName)) return f    
 63       //::printf("debug : tools::branch_elemen    
 64       std::string fCloneName;                     
 65       if(!a_buffer.read(fCloneName)) return fa    
 66       //::printf("debug : tools::branch_elemen    
 67       int dummy_int;                              
 68       if(!a_buffer.read(dummy_int)) return fal    
 69       //::printf("debug : tools::branch_elemen    
 70                                                   
 71       if(v>=10) {                                 
 72         short dummy_short;                        
 73         if(!a_buffer.read(dummy_short)) return    
 74         //::printf("debug : tools::branch_elem    
 75       } else {                                    
 76         if(!a_buffer.read(dummy_int)) return f    
 77       }                                           
 78                                                   
 79       if(!a_buffer.read(fID)) return false;       
 80       //::printf("debug : tools::branch_elemen    
 81       if(!a_buffer.read(fType)) return false;     
 82       //::printf("debug : tools::branch_elemen    
 83       if(!a_buffer.read(fStreamerType)) return    
 84       //::printf("debug : tools::branch_elemen    
 85                                                   
 86       if(!a_buffer.read(dummy_int)) return fal    
 87       //::printf("debug : tools::branch_elemen    
 88                                                   
 89       //TBranchElement* fBranchCount;             
 90       ifac::args args;                            
 91       if(!pointer_stream(a_buffer,m_fac,args,f    
 92         m_out << "tools::rroot::branch_element    
 93               << "can't read fBranchCount."       
 94               << std::endl;                       
 95         return false;                             
 96       }                                           
 97                                                   
 98       //TBranchElement* fBranchCount2;            
 99       if(!pointer_stream(a_buffer,m_fac,args,f    
100         m_out << "tools::rroot::branch_element    
101               << "can't read fBranchCount2."      
102               << std::endl;                       
103         _clear();                                 
104         return false;                             
105       }                                           
106                                                   
107     }                                             
108                                                   
109     if(!a_buffer.check_byte_count(_s,_c,"TBran    
110     return true;                                  
111   }                                               
112 public: //branch                                  
113                                                   
114   virtual bool read_leaves(ifile& a_file,buffe    
115                                                   
116     // For k<type> value, see the below commen    
117     static int kInt      = 3;                     
118     static int kDouble   = 8;                     
119     static int kDouble32 = 9;                     
120     static int kUInt     = 13;                    
121     static int kBits     = 15;  // In v4-00-01    
122     static int kObject   = 61;                    
123     static int kObjectP  = 64;                    
124                                                   
125     if(fType==3) { // TClonesArray master bran    
126       //from v4-00-01                             
127       int n;                                      
128       if(!a_buffer.read(n)) return false;         
129       /* ROOT-6.12.06 code :                      
130       if ((n < 0) || (n > fMaximum)) {            
131          if (IsMissingCollection()) {             
132             n = 0;                                
133             b.SetBufferOffset(b.Length() - siz    
134          } else {                                 
135             Error("ReadLeaves", "Incorrect siz    
136             n = 0;                                
137          }                                        
138       }*/                                         
139       //::printf("debug : uuuu : ndata %d\n",n    
140       fNdata = n;                                 
141                                                   
142       //TClonesArray *clones = (TClonesArray*)    
143       //if (!clones) return;                      
144       //if (clones->IsZombie()) return;           
145       //clones->Clear();                          
146       //clones->ExpandCreateFast(fNdata);         
147                                                   
148       //m_out << "debug : tools::rroot::branch    
149       //      << " name " << m_name << " ref_c    
150       //      << " : type " << fType << ", fNd    
151       //      << std::endl;                       
152       return true;                                
153                                                   
154     } else if(fType==31) { // TClonesArray sub    
155       if(fStreamerType==kObject) { //to read E    
156         int ndata = fBranchCount->get_ndata();    
157 #ifdef TOOLS_RROOT_BRANCH_ELEMENT_DUMP            
158         ::printf("debug : %s : fClassName %s :    
159 #endif                                            
160         streamer_info* _info = a_file.find_str    
161         if(!_info) {                              
162           m_out << "tools::rroot::branch_eleme    
163                 << " read(kObject) : streamer_    
164                 << std::endl;                     
165           return false;                           
166         }                                         
167         streamer_element* _element = _info->fi    
168         if(!_element) {                           
169           m_out << "tools::rroot::branch_eleme    
170                 << " read(kObject) : for ref_c    
171                 << std::endl;                     
172           return false;                           
173         }                                         
174         //::printf("debug : element type name     
175                                                   
176         obj_list* _list = 0;                      
177         if(!m_obj) {                              
178           _list = new obj_list(m_fac);            
179           m_obj = _list;                          
180         } else {                                  
181           _list = id_cast<iro,obj_list>(*m_obj    
182           if(!_list) {                            
183             m_out << "tools::rroot::branch_ele    
184                   << " read(kObject) : m_obj i    
185                   << std::endl;                   
186             return false;                         
187           }                                       
188         }                                         
189                                                   
190         _list->safe_clear();                      
191                                                   
192         for(int index=0;index<ndata;index++) {    
193           ifac::args args;                        
194           iro* _obj = m_fac.create(_element->t    
195           if(!_obj) {_list->safe_clear();retur    
196           if(!_obj->stream(a_buffer)){            
197             m_out << "tools::rroot::branch_ele    
198                   << " kObject : obj stream of    
199                   << " failed at index " << in    
200             _list->safe_clear();                  
201             return false;                         
202           }                                       
203           _list->add_object(_obj); //give owne    
204         }                                         
205                                                   
206         return true;                              
207       }                                           
208       if(fStreamerType==kObjectP) return true;    
209       //from v4-00-01                             
210       if(fStreamerType==kDouble32) {              
211         int ndata = fBranchCount->get_ndata();    
212 #ifdef TOOLS_RROOT_BRANCH_ELEMENT_DUMP            
213         ::printf("debug : %s : fID %d : double    
214 #endif                                            
215         stl_vector<double>* vec = 0;              
216         if(!m_obj) {                              
217           vec = new stl_vector<double>;           
218           m_obj = vec;                            
219         } else {                                  
220           vec = id_cast<iro, stl_vector<double    
221           if(!vec) {                              
222             m_out << "tools::rroot::branch_ele    
223                   << " read(kDouble32) : m_obj    
224                   << std::endl;                   
225             return false;                         
226           }                                       
227         }                                         
228                                                   
229         vec->resize(ndata);                       
230         float afloat;                             
231         for(int ii=0;ii<ndata;ii++) {             
232           if(!a_buffer.read(afloat)) {            
233             m_out << "tools::rroot::branch_ele    
234                   << " read(float) failed."       
235                   << std::endl;                   
236             vec->clear();                         
237             return false;                         
238           }                                       
239           //::printf("debug : zzzz %g\n",afloa    
240           (*vec)[ii] = afloat;                    
241         }                                         
242                                                   
243         return true;                              
244                                                   
245       } else if(fStreamerType==kDouble) {         
246         int ndata = fBranchCount->get_ndata();    
247 #ifdef TOOLS_RROOT_BRANCH_ELEMENT_DUMP            
248         ::printf("debug : %s : fID %d : double    
249 #endif                                            
250         stl_vector<double>* vec = 0;              
251         if(!m_obj) {                              
252           vec = new stl_vector<double>;           
253           m_obj = vec;                            
254         } else {                                  
255           vec = id_cast<iro, stl_vector<double    
256           if(!vec) {                              
257             m_out << "tools::rroot::branch_ele    
258                   << " read(kDouble) : m_obj i    
259                   << std::endl;                   
260             return false;                         
261           }                                       
262         }                                         
263                                                   
264         vec->resize(ndata);                       
265         double* _value = vec_data(*vec);          
266         if(!a_buffer.read_fast_array(_value,nd    
267           m_out << "tools::rroot::branch_eleme    
268                 << " read_fast_array(double) f    
269                 << std::endl;                     
270           vec->clear();                           
271           return false;                           
272         }                                         
273                                                   
274         return true;                              
275                                                   
276       } else if(fStreamerType==kInt) {            
277         int ndata = fBranchCount->get_ndata();    
278 #ifdef TOOLS_RROOT_BRANCH_ELEMENT_DUMP            
279         ::printf("debug : %s : fID %d : int :     
280 #endif                                            
281         stl_vector<int>* vec = 0;                 
282         if(!m_obj) {                              
283           vec = new stl_vector<int>;              
284     m_obj = vec;                                  
285         } else {                                  
286           vec = id_cast<iro, stl_vector<int> >    
287           if(!vec) {                              
288             m_out << "tools::rroot::branch_ele    
289                   << " read(kInt) : m_obj is n    
290                   << std::endl;                   
291             return false;                         
292           }                                       
293         }                                         
294                                                   
295         vec->resize(ndata);                       
296         int* _value = vec_data(*vec);             
297         if(!a_buffer.read_fast_array(_value,nd    
298           m_out << "tools::rroot::branch_eleme    
299                 << " read_fast_array(int) fail    
300                 << std::endl;                     
301           vec->clear();                           
302           return false;                           
303         }                                         
304                                                   
305         return true;                              
306                                                   
307       } else if((fStreamerType==kUInt)||(fStre    
308         int ndata = fBranchCount->get_ndata();    
309 #ifdef TOOLS_RROOT_BRANCH_ELEMENT_DUMP            
310         if(fStreamerType==kUInt) ::printf("deb    
311         else                     ::printf("deb    
312 #endif                                            
313         stl_vector<uint32>* vec = 0;              
314         if(!m_obj) {                              
315           vec = new stl_vector<uint32>;           
316     m_obj = vec;                                  
317         } else {                                  
318           vec = id_cast<iro, stl_vector<uint32    
319           if(!vec) {                              
320             m_out << "tools::rroot::branch_ele    
321                   << " read(kUInt) : m_obj is     
322                   << std::endl;                   
323             return false;                         
324           }                                       
325         }                                         
326                                                   
327         vec->resize(ndata);                       
328         uint32* _value = vec_data(*vec);          
329         if(!a_buffer.read_fast_array(_value,nd    
330           m_out << "tools::rroot::branch_eleme    
331                 << " read_fast_array(uint) fai    
332                 << std::endl;                     
333           vec->clear();                           
334           return false;                           
335         }                                         
336                                                   
337         return true;                              
338                                                   
339       } else {                                    
340         m_out << "tools::rroot::branch_element    
341               << " name " << m_name << " ref_c    
342               << " : for type " << fType << ",    
343               << std::endl;                       
344         return false;                             
345       }                                           
346   /*                                              
347         //m_obj = clones_array<float>(m_fac,tr    
348         uint32 ndata = 1;                         
349         float* _value = new float[ndata];         
350         if(!a_buffer.read_fast_array(_value,nd    
351           m_out << "tools::rroot::branch_eleme    
352                 << " read_fast_array failed."     
353                 << std::endl;                     
354           return false;                           
355         }                                         
356   */                                              
357   //} else if(fType<=2) { //in v5-18-00d          
358     } else if(fType==0) { // to read wroot.roo    
359 //     if(fID>=0) {                               
360 //       // branch in split mode                  
361 //       m_out << "tools::rroot::branch_elemen    
362 //             << " name " << m_name << " ref_    
363 //             << " type 0 with ID " << fID <<    
364 //             << std::endl;                      
365 //       return true;                             
366 //                                                
367                                                   
368        if((fID==-1)||                             
369           (fID==1)     // for pmx to read LHCb    
370          ){                                       
371          //from v4-00-01                          
372          //if (fBranchCount) fNdata = (Int_t)f    
373          //else fNdata = 1;                       
374    if(fBranchCount) {                             
375            fNdata = fBranchCount->get_ndata();    
376            //::printf("debug : branch_element:    
377    } else {                                       
378      fNdata = 1;                                  
379    }                                              
380                                                   
381          // read object :                         
382    bool created = false;                          
383          if(!m_obj) {                             
384            ifac::args args;                       
385            m_obj = m_fac.create(fClassName,arg    
386            if(!m_obj) return false;               
387      created = true;                              
388          }                                        
389                                                   
390          if(!m_obj->stream(a_buffer)){            
391            m_out << "tools::rroot::branch_elem    
392                  << " name " << sout(m_name) <    
393                  << " obj stream failed."         
394                  << std::endl;                    
395      if(created) {delete m_obj;m_obj = 0;}        
396            return false;                          
397          }                                        
398                                                   
399          return true;                             
400                                                   
401        } else {                                   
402          m_out << "tools::rroot::branch_elemen    
403                << " name " << m_name << " ref_    
404                << " type 0 with ID " << fID <<    
405                << std::endl;                      
406          return false;                            
407        }                                          
408                                                   
409     }                                             
410                                                   
411     m_out << "tools::rroot::branch_element::re    
412           << " name " << m_name << " ref_cls "    
413           << " : type " << fType << " not trea    
414           << std::endl;                           
415     return false;                                 
416                                                   
417 /*                                                
418     //////////////////////////////////////////    
419     /// STL container ////////////////////////    
420     //////////////////////////////////////////    
421     if(fType==4) {                                
422       // STL container master branch (has only    
423       //from v4-00-01                             
424       int n;                                      
425       if(!a_buffer.read(n)) return false;         
426       //fNdata = n;                               
427                                                   
428       m_out << "tools::rroot::branch_element::    
429             << " name " << m_name << " ref_cls    
430             << " : type " << fType << " not tr    
431             << std::endl;                         
432       return false;                               
433                                                   
434     } else if(fType==41) {                        
435       // STL container sub-branch (contains th    
436       m_out << "tools::rroot::branch_element::    
437             << " name " << m_name << " ref_cls    
438             << " : type " << fType << " not tr    
439             << std::endl;                         
440       return false;                               
441                                                   
442     //////////////////////////////////////////    
443     /// TClonesArray container ///////////////    
444     //////////////////////////////////////////    
445     } else if(fType==3) {                         
446       // TClonesArray master branch (has only     
447       //from v4-00-01                             
448       int n;                                      
449       if(!a_buffer.read(n)) return false;         
450                                                   
451       //fNdata = n;                               
452       //TClonesArray *clones = (TClonesArray*)    
453       //if (!clones) return;                      
454       //if (clones->IsZombie()) return;           
455       //clones->Clear();                          
456       //clones->ExpandCreateFast(fNdata);         
457                                                   
458       m_out << "tools::rroot::branch_element::    
459             << " name " << m_name << " ref_cls    
460             << " : type " << fType << " not tr    
461             << std::endl;                         
462       return false;                               
463                                                   
464     } else if(fType==31) {                        
465       // TClonesArray sub-branch (contains the    
466       m_out << "tools::rroot::branch_element::    
467             << " name " << m_name << " ref_cls    
468             << " : type " << fType << " not tr    
469             << std::endl;                         
470       return false;                               
471                                                   
472     //////////////////////////////////////////    
473     //////////////////////////////////////////    
474     //////////////////////////////////////////    
475     } else if(fType<=2) {                         
476       // branch in split mode                     
477                                                   
478       //from v4-00-01                             
479       //if (fBranchCount) fNdata = (Int_t)fBra    
480       //else fNdata = 1;                          
481       //if (!fInfo) return;                       
482       //fInfo->ReadBuffer(b,fObject,fID);         
483       //if (fStreamerType == 6) fNdata = (Int_    
484                                                   
485       //from 3.0.06                               
486       //if (fID >= 0) {                           
487       //  fInfo->ReadBuffer(b,fAddress,fID);      
488       //} else if (fID == -1) {   // top level    
489       //  char **ppointer = (char**)fAddress;     
490       //  fInfo->ReadBuffer(b,*ppointer,fID);     
491       //}                                         
492                                                   
493       //m_out << "tools::rroot::branch_element    
494       //      << " name " << m_name << " ref_c    
495       //      << " type " << fType << " with I    
496       //      << " and then ?"                    
497       //      << std::endl;                       
498                                                   
499       // read object ?                            
500       bool created = false;                       
501       if(!m_obj) {                                
502         ifac::args args;                          
503         m_obj = m_fac.create(fClassName,args);    
504         if(!m_obj) return false;                  
505         created = true;                           
506       }                                           
507                                                   
508       if(!m_obj->stream(a_buffer)){               
509         m_out << "tools::rroot::branch_element    
510               << " name " << m_name << " ref_c    
511               << " obj stream failed."            
512               << std::endl;                       
513         if(created) {delete m_obj;m_obj = 0;}     
514         return false;                             
515       }                                           
516                                                   
517       //m_out << "tools::rroot::branch_element    
518       //      << " name " << m_name << " ref_c    
519       //      << " obj streamed."                 
520       //      << std::endl;                       
521                                                   
522       return true;                                
523                                                   
524 //  } else if(fType==0) {                         
525 //     if(fID>=0) {                               
526 //       // branch in split mode                  
527 //       m_out << "tools::rroot::branch_elemen    
528 //             << " name " << m_name << " ref_    
529 //             << " type 0 with ID " << fID <<    
530 //             << std::endl;                      
531 //       return true;                             
532 //                                                
533 //     } else if(fID==-1) {                       
534 //       // top level branch in non split mode    
535 //       m_out << "tools::rroot::branch_elemen    
536 //             << " name " << m_name << " ref_    
537 //             << " type 0 with ID " << fID       
538 //             << " : fill object."               
539 //             << std::endl;                      
540                                                   
541 //       if(!m_obj) {                             
542 //         m_out << "tools::rroot::branch_elem    
543 //               << " name " << m_name << " re    
544 //               << " m_obj is null."             
545 //               << std::endl;                    
546 //         return false;                          
547 //       }                                        
548 //       if(!m_obj->stream(a_buffer)){            
549 //         m_out << "tools::rroot::branch_elem    
550 //               << " name " << m_name << " re    
551 //               << " obj stream failed."         
552 //               << std::endl;                    
553 //         return false;                          
554 //       }                                        
555 //       return true;                             
556                                                   
557 //     } else {                                   
558 //       m_out << "tools::rroot::branch_elemen    
559 //             << " name " << m_name << " ref_    
560 //             << " type 0 with ID " << fID <<    
561 //             << std::endl;                      
562 //       return false;                            
563 //     }                                          
564                                                   
565 //  //LHCb files :                                
566 //  } else if(fType==1) {                         
567 //    // parent branch is a base class branch.    
568 //    // Ok, and then ?                           
569 //    m_out << "tools::rroot::branch_element::    
570 //          << " name " << m_name << " ref_cls    
571 //          << " type " << fType << " with ID     
572 //          << std::endl;                         
573 //    return true;                                
574                                                   
575     } else {                                      
576       m_out << "tools::rroot::branch_element::    
577             << " name " << m_name << " ref_cls    
578             << " type " << fType << " with ID     
579             << " unknown case."                   
580             << std::endl;                         
581       return false;                               
582     }                                             
583 */                                                
584   }                                               
585                                                   
586   virtual bool find_entry(ifile& a_file,uint64    
587     //The below line will call the upper read_    
588     if(!parent::find_entry(a_file,a_entry,a_nb    
589                                                   
590     if(m_branches.size()) {                       
591       //if(!m_obj) {                              
592       //  m_obj = m_fac.create(fClassName);       
593       //  if(!m_obj) return false;                
594       //}                                         
595                                                   
596       tools_vforcit(branch*,m_branches,it) {      
597         uint32 n;                                 
598         if(!(*it)->find_entry(a_file,a_entry,n    
599         a_nbytes += n;                            
600       }                                           
601     }                                             
602                                                   
603     return true;                                  
604   }                                               
605                                                   
606   virtual bool show(std::ostream& a_out,ifile&    
607     uint32 n;                                     
608     if(!find_entry(a_file,a_entry,n)) return f    
609                                                   
610    {std::string _s;                               
611     uint32 len = uint32(name().size())+128;       
612     sprintf(_s,len," %-15s = ",name().c_str())    
613     a_out << _s;}                                 
614                                                   
615     a_out << m_obj << std::endl;                  
616                                                   
617     return true;                                  
618     //return parent::show(a_out,a_file,a_entry    
619   }                                               
620 public:                                           
621   branch_element(std::ostream& a_out,ifac& a_f    
622   :parent(a_out,a_fac)                            
623   ,m_obj(0)                                       
624   ,fClassVersion(0)                               
625   ,fID(0)                                         
626   ,fType(0)                                       
627   ,fStreamerType(-1)                              
628   ,fBranchCount(0)   //not owner                  
629   ,fBranchCount_created(false)                    
630   ,fBranchCount2(0)  //not owner                  
631   ,fBranchCount2_created(false)                   
632   ,fNdata(1)                                      
633   {}                                              
634                                                   
635   virtual ~branch_element() {                     
636     _clear();                                     
637     if(m_obj) delete m_obj;                       
638   }                                               
639 protected:                                        
640   branch_element(const branch_element& a_from)    
641   branch_element& operator=(const branch_eleme    
642 public:                                           
643   const std::string& class_name() const {retur    
644   int type() const {return fType;}                
645   int streamer_type() const {return fStreamerT    
646   int id() const {return fID;}                    
647   iro* object() {return m_obj;}                   
648   int get_ndata() const {return fNdata;}          
649                                                   
650   template <class T>                              
651   stl_vector<T>* object_to_stl_vector() const     
652     if(!m_obj) {                                  
653       m_out << "tools::rroot::branch_element::    
654       return 0;                                   
655     }                                             
656     stl_vector<T>* od = id_cast<iro, stl_vecto    
657     if(!od) {                                     
658       m_out << "tools::rroot::branch_element::    
659             << " object of class " << sout(m_o    
660       << std::endl;                               
661       return 0;                                   
662     }                                             
663     return od; //WARNING : we are not owner.      
664   }                                               
665                                                   
666   obj_list* object_to_obj_list() const {          
667     if(!m_obj) {                                  
668       m_out << "tools::rroot::branch_element::    
669       return 0;                                   
670     }                                             
671     obj_list* od = id_cast<iro,obj_list>(*m_ob    
672     if(!od) {                                     
673       m_out << "tools::rroot::branch_element::    
674             << " object of class " << sout(m_o    
675       << std::endl;                               
676       return 0;                                   
677     }                                             
678     return od; //WARNING : we are not owner.      
679   }                                               
680                                                   
681   template <class T>                              
682   stl_vector<T>* find_entry_vec(ifile& a_file,    
683     unsigned int n;                               
684     if(!find_entry(a_file,a_event,n)) {           
685       m_out << "tools::rroot::branch_element::    
686       return 0;                                   
687     }                                             
688     if(!m_obj) {                                  
689       m_out << "tools::rroot::branch_element::    
690       return 0;                                   
691     }                                             
692     stl_vector<T>* od = id_cast<iro, stl_vecto    
693     if(!od) {                                     
694       m_out << "tools::rroot::branch_element::    
695             << " object not a tools::rroot::st    
696       << std::endl;                               
697       return 0;                                   
698     }                                             
699     return od; //WARNING : we are not owner.      
700   }                                               
701                                                   
702 protected:                                        
703   void _clear() {                                 
704     if(fBranchCount_created) {delete fBranchCo    
705     if(fBranchCount2_created) {delete fBranchC    
706   }                                               
707 protected:                                        
708   iro* m_obj;                                     
709 protected:                                        
710   std::string fClassName; //Class name of refe    
711   int fClassVersion;  //Version number of clas    
712   int fID;            //element serial number     
713   int fType;          //branch type               
714   int fStreamerType;  //branch streamer type      
715   branch_element* fBranchCount;  // pointer to    
716   bool fBranchCount_created;                      
717   branch_element* fBranchCount2; // pointer to    
718   bool fBranchCount2_created;                     
719   int fNdata;         // Number of data in thi    
720 };                                                
721                                                   
722 }}                                                
723                                                   
724 #ifdef TOOLS_RROOT_BRANCH_ELEMENT_DUMP            
725 #undef TOOLS_RROOT_BRANCH_ELEMENT_DUMP            
726 #endif                                            
727                                                   
728 #endif                                            
729                                                   
730 //////////////////////////////////////////////    
731 //////////////////////////////////////////////    
732 //////////////////////////////////////////////    
733 /* In v4-00-01 version 8 :                        
734           case  1:  {b.ReadFastArray((Char_t*)    
735           case  2:  {b.ReadFastArray((Short_t*    
736           case  3:  {b.ReadFastArray((Int_t*)     
737           case  4:  {b.ReadFastArray((Long_t*)    
738           case  5:  {b.ReadFastArray((Float_t*    
739           case  6:  {b.ReadFastArray((Int_t*)     
740           case  8:  {b.ReadFastArray((Double_t    
741           case 11:  {b.ReadFastArray((UChar_t*    
742           case 12:  {b.ReadFastArray((UShort_t    
743           case 13:  {b.ReadFastArray((UInt_t*)    
744           case 14:  {b.ReadFastArray((ULong_t*    
745           case 15:  {b.ReadFastArray((Long64_t    
746           case 16:  {b.ReadFastArray((ULong64_    
747       case  9:  {Double_t *xx = (Double_t*)fAd    
748                   Float_t afloat;                 
749             for (Int_t ii=0;ii<n;ii++) {          
750                     b>> afloat; xx[ii] = Doubl    
751             } break;}                             
752 */                                                
753 /* 6.12.06 version 10 : fStreamerType : from m    
754                                                   
755    enum EReadWrite {                              
756       kBase        =  0,  kOffsetL = 20,  kOff    
757       kChar        =  1,  kShort   =  2,  kInt    
758       kDouble      =  8,  kDouble32=  9,          
759       kUChar       = 11,  kUShort  = 12,  kUIn    
760       kLong64      = 16,  kULong64 = 17,  kBoo    
761       kObject      = 61,  kAny     = 62,  kObj    
762       kTObject     = 66,  kTNamed  = 67,  kAny    
763       kSTLp        = 71,                          
764       kSkip        = 100, kSkipL = 120, kSkipP    
765       kConv        = 200, kConvL = 220, kConvP    
766       kSTL         = ROOT::kSTLany, // 300        
767       kSTLstring   = ROOT::kSTLstring, // 365     
768       kStreamer    = 500, kStreamLoop = 501,      
769       kCache       = 600,  // Cache the value     
770       kArtificial  = 1000,                        
771       kCacheNew    = 1001,                        
772       kCacheDelete = 1002,                        
773       kNeedObjectForVirtualBaseClass = 99997,     
774       kMissing     = 99999                        
775    };                                             
776                                                   
777 // Some comments about EReadWrite                 
778 // kBase    : base class element                  
779 // kOffsetL : fixed size array                    
780 // kOffsetP : pointer to object                   
781 // kCounter : counter for array size              
782 // kCharStar: pointer to array of char            
783 // kBits    : TObject::fBits in case of a refe    
784 // kObject  : Class  derived from TObject         
785 // kObjectp : Class* derived from TObject and     
786 // kObjectP : Class* derived from TObject and     
787 // kAny     : Class  not derived from TObject     
788 // kAnyp    : Class* not derived from TObject     
789 // kAnyP    : Class* not derived from TObject     
790 // kAnyPnoVT: Class* not derived from TObject     
791 // kSTLp    : Pointer to STL container.           
792 // kTString : TString, special case               
793 // kTObject : TObject, special case               
794 // kTNamed  : TNamed , special case               
795                                                   
796 */