Geant4 Cross Reference |
1 // Copyright (C) 2010, Guy Barrand. All rights 1 // Copyright (C) 2010, Guy Barrand. All rights reserved. 2 // See the file tools.license for terms. 2 // See the file tools.license for terms. 3 3 4 #ifndef tools_rroot_tree 4 #ifndef tools_rroot_tree 5 #define tools_rroot_tree 5 #define tools_rroot_tree 6 6 7 #include "ifac" 7 #include "ifac" 8 #include "branch_element" 8 #include "branch_element" 9 #include "../sout" 9 #include "../sout" 10 #include "iobject" 10 #include "iobject" 11 11 12 namespace tools { 12 namespace tools { 13 namespace rroot { 13 namespace rroot { 14 14 15 inline const std::string& TTree_cls(){ 15 inline const std::string& TTree_cls(){ 16 static const std::string s_v("TTree"); 16 static const std::string s_v("TTree"); 17 return s_v; 17 return s_v; 18 } 18 } 19 19 20 class tree : public virtual iobject { 20 class tree : public virtual iobject { 21 public: 21 public: 22 static const std::string& s_class() { 22 static const std::string& s_class() { 23 static const std::string s_v("tools::rroot 23 static const std::string s_v("tools::rroot::tree"); 24 return s_v; 24 return s_v; 25 } 25 } 26 virtual const std::string& s_cls() const {re 26 virtual const std::string& s_cls() const {return s_class();} 27 public: //iobject 27 public: //iobject 28 virtual const std::string& name() const {ret 28 virtual const std::string& name() const {return m_name;} 29 virtual const std::string& title() const {re 29 virtual const std::string& title() const {return m_title;} 30 virtual const std::string& store_class_name( 30 virtual const std::string& store_class_name() const { 31 static const std::string s_v("TTree"); 31 static const std::string s_v("TTree"); 32 return s_v; 32 return s_v; 33 } 33 } 34 public: 34 public: 35 tree(ifile& a_file,ifac& a_fac) 35 tree(ifile& a_file,ifac& a_fac) 36 :m_file(a_file) 36 :m_file(a_file) 37 ,m_fac(a_fac) 37 ,m_fac(a_fac) 38 ,m_out(a_file.out()) 38 ,m_out(a_file.out()) 39 ,m_name("") 39 ,m_name("") 40 ,m_title("") 40 ,m_title("") 41 ,m_branches(a_fac) 41 ,m_branches(a_fac) 42 ,m_entries(0) 42 ,m_entries(0) 43 { 43 { 44 #ifdef TOOLS_MEM 44 #ifdef TOOLS_MEM 45 mem::increment(s_class().c_str()); 45 mem::increment(s_class().c_str()); 46 #endif 46 #endif 47 } 47 } 48 virtual ~tree(){ 48 virtual ~tree(){ 49 #ifdef TOOLS_MEM 49 #ifdef TOOLS_MEM 50 mem::decrement(s_class().c_str()); 50 mem::decrement(s_class().c_str()); 51 #endif 51 #endif 52 } 52 } 53 protected: 53 protected: 54 tree(const tree& a_from) 54 tree(const tree& a_from) 55 :iobject(a_from) 55 :iobject(a_from) 56 ,m_file(a_from.m_file) 56 ,m_file(a_from.m_file) 57 ,m_fac(a_from.m_fac) 57 ,m_fac(a_from.m_fac) 58 ,m_out(a_from.m_out) 58 ,m_out(a_from.m_out) 59 ,m_branches(m_fac) 59 ,m_branches(m_fac) 60 {} 60 {} 61 tree& operator=(const tree&){return *this;} 61 tree& operator=(const tree&){return *this;} 62 public: 62 public: 63 std::ostream& out() const {return m_out;} 63 std::ostream& out() const {return m_out;} 64 64 65 ifile& file() {return m_file;} 65 ifile& file() {return m_file;} 66 ifac& fac() {return m_fac;} 66 ifac& fac() {return m_fac;} 67 67 68 const std::vector<branch*>& branches() const 68 const std::vector<branch*>& branches() const {return m_branches;} 69 69 70 bool find_entry(uint64 a_entry,uint32& a_nby 70 bool find_entry(uint64 a_entry,uint32& a_nbytes) { 71 a_nbytes = 0; 71 a_nbytes = 0; 72 if(a_entry>=m_entries) return false; 72 if(a_entry>=m_entries) return false; 73 int nbytes = 0; 73 int nbytes = 0; 74 //fReadEntry = a_entry; 74 //fReadEntry = a_entry; 75 tools_vforit(branch*,m_branches,it) { 75 tools_vforit(branch*,m_branches,it) { 76 uint32 n; 76 uint32 n; 77 if(!(*it)->find_entry(m_file,a_entry,n)) 77 if(!(*it)->find_entry(m_file,a_entry,n)) return false; 78 nbytes += n; 78 nbytes += n; 79 } 79 } 80 a_nbytes = nbytes; 80 a_nbytes = nbytes; 81 return true; 81 return true; 82 } 82 } 83 83 84 void dump(std::ostream& a_out,const std::str 84 void dump(std::ostream& a_out,const std::string& a_spaces = "",const std::string& a_indent = " "){ 85 a_out << a_spaces 85 a_out << a_spaces 86 << "tree :" 86 << "tree :" 87 << " name=" << sout(m_name) 87 << " name=" << sout(m_name) 88 << " title=" << sout(m_title) 88 << " title=" << sout(m_title) 89 << " entries=" << m_entries 89 << " entries=" << m_entries 90 << std::endl; 90 << std::endl; 91 _dump_branches(a_out,m_branches,a_spaces+a 91 _dump_branches(a_out,m_branches,a_spaces+a_indent,a_indent); 92 } 92 } 93 93 94 branch* find_branch(const std::string& a_nam 94 branch* find_branch(const std::string& a_name,bool a_recursive = false) const { 95 return _find_branch(m_branches,a_name,a_re 95 return _find_branch(m_branches,a_name,a_recursive); 96 } 96 } 97 97 98 branch_element* find_branch_element(const st 98 branch_element* find_branch_element(const std::string& a_name,bool a_recursive = false) const { 99 branch* b = _find_branch(m_branches,a_name 99 branch* b = _find_branch(m_branches,a_name,a_recursive); 100 if(!b) return 0; 100 if(!b) return 0; 101 return id_cast<branch,branch_element>(*b); 101 return id_cast<branch,branch_element>(*b); 102 } 102 } 103 103 104 base_leaf* find_leaf(const std::string& a_na 104 base_leaf* find_leaf(const std::string& a_name,bool a_recursive = false) const { 105 return _find_leaf(m_branches,a_name,a_recu 105 return _find_leaf(m_branches,a_name,a_recursive); 106 } 106 } 107 107 108 void find_leaves(std::vector<base_leaf*>& a_ 108 void find_leaves(std::vector<base_leaf*>& a_leaves) const { 109 a_leaves.clear(); 109 a_leaves.clear(); 110 _find_leaves(m_branches,a_leaves); 110 _find_leaves(m_branches,a_leaves); 111 } 111 } 112 112 113 void find_branches(std::vector<branch*>& a_b 113 void find_branches(std::vector<branch*>& a_branches) const { 114 a_branches.clear(); 114 a_branches.clear(); 115 _find_branches(m_branches,a_branches); 115 _find_branches(m_branches,a_branches); 116 } 116 } 117 117 118 branch* find_leaf_branch(const base_leaf& a_ 118 branch* find_leaf_branch(const base_leaf& a_leaf) const {return _find_leaf_branch(m_branches,a_leaf);} 119 119 120 bool show(std::ostream& a_out,uint64 a_entry 120 bool show(std::ostream& a_out,uint64 a_entry){ 121 a_out << "======> EVENT:" << a_entry << st 121 a_out << "======> EVENT:" << a_entry << std::endl; 122 tools_vforit(branch*,m_branches,it) { 122 tools_vforit(branch*,m_branches,it) { 123 if(!(*it)->show(a_out,m_file,a_entry)) r 123 if(!(*it)->show(a_out,m_file,a_entry)) return false; 124 } 124 } 125 return true; 125 return true; 126 } 126 } 127 127 128 uint64 entries() const {return m_entries;} 128 uint64 entries() const {return m_entries;} 129 129 130 virtual bool stream(buffer& a_buffer) { //vi 130 virtual bool stream(buffer& a_buffer) { //virtual for iobject. 131 //uint64 m_tot_bytes; 131 //uint64 m_tot_bytes; 132 //uint64 m_zip_bytes; 132 //uint64 m_zip_bytes; 133 //uint64 m_saved_bytes; 133 //uint64 m_saved_bytes; 134 134 135 short vers; 135 short vers; 136 unsigned int _s,_c; << 136 unsigned int s, c; 137 if(!a_buffer.read_version(vers,_s,_c)) ret << 137 if(!a_buffer.read_version(vers,s,c)) return false; 138 138 139 //::printf("debug : tree::stream : version 139 //::printf("debug : tree::stream : version %d count %d\n",vers,c); 140 140 141 //if (vers > 4) { 141 //if (vers > 4) { 142 //TTree::Class()->ReadBuffer(b, this, ve 142 //TTree::Class()->ReadBuffer(b, this, vers, s, c); 143 //if (fEstimate <= 10000) fEstimate = 10 143 //if (fEstimate <= 10000) fEstimate = 1000000; 144 //m_saved_bytes = m_tot_bytes; 144 //m_saved_bytes = m_tot_bytes; 145 //fDirectory = gDirectory; 145 //fDirectory = gDirectory; 146 //gDirectory->Append(this); 146 //gDirectory->Append(this); 147 //return; 147 //return; 148 //} 148 //} 149 149 150 if(!Named_stream(a_buffer,m_name,m_title)) 150 if(!Named_stream(a_buffer,m_name,m_title)) return false; 151 151 152 {short color,style,width; 152 {short color,style,width; 153 if(!AttLine_stream(a_buffer,color,style,wi 153 if(!AttLine_stream(a_buffer,color,style,width)) return false;} 154 {short color,style; 154 {short color,style; 155 if(!AttFill_stream(a_buffer,color,style)) 155 if(!AttFill_stream(a_buffer,color,style)) return false;} 156 if(!AttMarker_stream(a_buffer)) return fal 156 if(!AttMarker_stream(a_buffer)) return false; 157 157 158 if(vers<=4) { 158 if(vers<=4) { 159 int dummy_int; 159 int dummy_int; 160 160 161 if(!a_buffer.read(dummy_int)) return fal 161 if(!a_buffer.read(dummy_int)) return false; //fScanField 162 if(!a_buffer.read(dummy_int)) return fal 162 if(!a_buffer.read(dummy_int)) return false; //fMaxEntryLoop 163 {int fMaxVirtualSize; 163 {int fMaxVirtualSize; 164 if(!a_buffer.read(fMaxVirtualSize)) retu 164 if(!a_buffer.read(fMaxVirtualSize)) return false;} 165 {double v; 165 {double v; 166 if(!a_buffer.read(v)) return false; 166 if(!a_buffer.read(v)) return false; 167 m_entries = uint64(v);} 167 m_entries = uint64(v);} 168 {double v; 168 {double v; 169 if(!a_buffer.read(v)) return false; 169 if(!a_buffer.read(v)) return false; 170 //m_tot_bytes = uint64(v); 170 //m_tot_bytes = uint64(v); 171 } 171 } 172 {double v; 172 {double v; 173 if(!a_buffer.read(v)) return false; 173 if(!a_buffer.read(v)) return false; 174 //m_zip_bytes = uint64(v); 174 //m_zip_bytes = uint64(v); 175 } 175 } 176 {int fAutoSave; 176 {int fAutoSave; 177 if(!a_buffer.read(fAutoSave)) return fal 177 if(!a_buffer.read(fAutoSave)) return false;} 178 if(!a_buffer.read(dummy_int)) return fal 178 if(!a_buffer.read(dummy_int)) return false; //fEstimate 179 179 180 } else if(vers<=9) { 180 } else if(vers<=9) { 181 {double v; 181 {double v; 182 if(!a_buffer.read(v)) return false; 182 if(!a_buffer.read(v)) return false; 183 m_entries = uint64(v);} 183 m_entries = uint64(v);} 184 {double v; 184 {double v; 185 if(!a_buffer.read(v)) return false; 185 if(!a_buffer.read(v)) return false; 186 //m_tot_bytes = uint64(v); 186 //m_tot_bytes = uint64(v); 187 } 187 } 188 {double v; 188 {double v; 189 if(!a_buffer.read(v)) return false; 189 if(!a_buffer.read(v)) return false; 190 //m_zip_bytes = uint64(v); 190 //m_zip_bytes = uint64(v); 191 } 191 } 192 {double v; 192 {double v; 193 if(!a_buffer.read(v)) return false; 193 if(!a_buffer.read(v)) return false; 194 //m_saved_bytes = uint64(v); 194 //m_saved_bytes = uint64(v); 195 } 195 } 196 196 197 int dummy_int; 197 int dummy_int; 198 if(!a_buffer.read(dummy_int)) return fal 198 if(!a_buffer.read(dummy_int)) return false; //fTimerInterval 199 if(!a_buffer.read(dummy_int)) return fal 199 if(!a_buffer.read(dummy_int)) return false; //fScanField 200 if(!a_buffer.read(dummy_int)) return fal 200 if(!a_buffer.read(dummy_int)) return false; //fUpdate 201 if(!a_buffer.read(dummy_int)) return fal 201 if(!a_buffer.read(dummy_int)) return false; //fMaxEntryLoop 202 202 203 {int fMaxVirtualSize; 203 {int fMaxVirtualSize; 204 if(!a_buffer.read(fMaxVirtualSize)) retu 204 if(!a_buffer.read(fMaxVirtualSize)) return false;} 205 {int fAutoSave; 205 {int fAutoSave; 206 if(!a_buffer.read(fAutoSave)) return fal 206 if(!a_buffer.read(fAutoSave)) return false;} 207 if(!a_buffer.read(dummy_int)) return fal 207 if(!a_buffer.read(dummy_int)) return false; //fEstimate 208 208 209 } else if(vers<16) { //FIXME : what is the 209 } else if(vers<16) { //FIXME : what is the exact version ? 210 double dummy_double; 210 double dummy_double; 211 int dummy_int; 211 int dummy_int; 212 212 213 {double v; 213 {double v; 214 if(!a_buffer.read(v)) return false; 214 if(!a_buffer.read(v)) return false; 215 m_entries = uint64(v);} 215 m_entries = uint64(v);} 216 {double v; 216 {double v; 217 if(!a_buffer.read(v)) return false; 217 if(!a_buffer.read(v)) return false; 218 //m_tot_bytes = uint64(v); 218 //m_tot_bytes = uint64(v); 219 } 219 } 220 {double v; 220 {double v; 221 if(!a_buffer.read(v)) return false; 221 if(!a_buffer.read(v)) return false; 222 //m_zip_bytes = uint64(v); 222 //m_zip_bytes = uint64(v); 223 } 223 } 224 {double v; 224 {double v; 225 if(!a_buffer.read(v)) return false; 225 if(!a_buffer.read(v)) return false; 226 //m_saved_bytes = uint64(v); 226 //m_saved_bytes = uint64(v); 227 } 227 } 228 if(!a_buffer.read(dummy_double)) return 228 if(!a_buffer.read(dummy_double)) return false; //fWeight 229 if(!a_buffer.read(dummy_int)) return fal 229 if(!a_buffer.read(dummy_int)) return false; //fTimerInterval 230 if(!a_buffer.read(dummy_int)) return fal 230 if(!a_buffer.read(dummy_int)) return false; //fScanField 231 if(!a_buffer.read(dummy_int)) return fal 231 if(!a_buffer.read(dummy_int)) return false; //fUpdate 232 if(!a_buffer.read(dummy_int)) return fal 232 if(!a_buffer.read(dummy_int)) return false; //fMaxEntryLoop 233 233 234 {int fMaxVirtualSize; 234 {int fMaxVirtualSize; 235 if(!a_buffer.read(fMaxVirtualSize)) retu 235 if(!a_buffer.read(fMaxVirtualSize)) return false;} 236 {int fAutoSave; 236 {int fAutoSave; 237 if(!a_buffer.read(fAutoSave)) return fal 237 if(!a_buffer.read(fAutoSave)) return false;} 238 if(!a_buffer.read(dummy_int)) return fal 238 if(!a_buffer.read(dummy_int)) return false; //fEstimate 239 239 240 } else { //vers>=16 240 } else { //vers>=16 241 double dummy_double; 241 double dummy_double; 242 int dummy_int; 242 int dummy_int; 243 int64 dummy_int64; 243 int64 dummy_int64; 244 244 245 {uint64 v; 245 {uint64 v; 246 if(!a_buffer.read(v)) return false; 246 if(!a_buffer.read(v)) return false; 247 m_entries = v;} 247 m_entries = v;} 248 {uint64 v; 248 {uint64 v; 249 if(!a_buffer.read(v)) return false; 249 if(!a_buffer.read(v)) return false; 250 //m_tot_bytes = v; 250 //m_tot_bytes = v; 251 } 251 } 252 {uint64 v; 252 {uint64 v; 253 if(!a_buffer.read(v)) return false; 253 if(!a_buffer.read(v)) return false; 254 //m_zip_bytes = v; 254 //m_zip_bytes = v; 255 } 255 } 256 {uint64 v; 256 {uint64 v; 257 if(!a_buffer.read(v)) return false; 257 if(!a_buffer.read(v)) return false; 258 //m_saved_bytes = v; 258 //m_saved_bytes = v; 259 } 259 } 260 if(vers>=18) { 260 if(vers>=18) { 261 if(!a_buffer.read(dummy_int64)) return 261 if(!a_buffer.read(dummy_int64)) return false; //fFlushedBytes 262 } 262 } 263 263 264 if(!a_buffer.read(dummy_double)) return 264 if(!a_buffer.read(dummy_double)) return false; //fWeight 265 265 266 if(!a_buffer.read(dummy_int)) return fal 266 if(!a_buffer.read(dummy_int)) return false; //fTimerInterval 267 if(!a_buffer.read(dummy_int)) return fal 267 if(!a_buffer.read(dummy_int)) return false; //fScanField 268 if(!a_buffer.read(dummy_int)) return fal 268 if(!a_buffer.read(dummy_int)) return false; //fUpdate 269 269 270 if(vers>=18) { 270 if(vers>=18) { 271 if(!a_buffer.read(dummy_int)) return f 271 if(!a_buffer.read(dummy_int)) return false; //fDefaultEntryOffsetLen 272 } 272 } 273 int fNClusterRange; 273 int fNClusterRange; 274 if(vers>=20) { 274 if(vers>=20) { 275 if(!a_buffer.read(fNClusterRange)) ret 275 if(!a_buffer.read(fNClusterRange)) return false; //fNClusterRange 276 } 276 } 277 277 278 if(!a_buffer.read(dummy_int64)) return f 278 if(!a_buffer.read(dummy_int64)) return false; //fMaxEntries 279 if(!a_buffer.read(dummy_int64)) return f 279 if(!a_buffer.read(dummy_int64)) return false; //fMaxEntryLoop 280 {uint64 fMaxVirtualSize; 280 {uint64 fMaxVirtualSize; 281 if(!a_buffer.read(fMaxVirtualSize)) retu 281 if(!a_buffer.read(fMaxVirtualSize)) return false;} 282 {uint64 fAutoSave; 282 {uint64 fAutoSave; 283 if(!a_buffer.read(fAutoSave)) return fal 283 if(!a_buffer.read(fAutoSave)) return false;} 284 if(vers>=18) { 284 if(vers>=18) { 285 if(!a_buffer.read(dummy_int64)) return 285 if(!a_buffer.read(dummy_int64)) return false; //fAutoFlush 286 } 286 } 287 if(!a_buffer.read(dummy_int64)) return f 287 if(!a_buffer.read(dummy_int64)) return false; //fEstimate 288 if(vers>=20) { 288 if(vers>=20) { 289 int64* fClusterRangeEnd = 0; /// 289 int64* fClusterRangeEnd = 0; ///<[fNClusterRange] Last entry of a cluster range. 290 if(!fixed_array_stream<int64>(a_buffer 290 if(!fixed_array_stream<int64>(a_buffer,fNClusterRange,fClusterRangeEnd)) return false; 291 delete [] fClusterRangeEnd; 291 delete [] fClusterRangeEnd; 292 int64* fClusterSize = 0; /// 292 int64* fClusterSize = 0; ///<[fNClusterRange] Number of entries in each cluster for a given range. 293 if(!fixed_array_stream<int64>(a_buffer 293 if(!fixed_array_stream<int64>(a_buffer,fNClusterRange,fClusterSize)) return false; 294 delete [] fClusterSize; 294 delete [] fClusterSize; 295 dummy _dummy; 295 dummy _dummy; 296 if(!_dummy.stream(a_buffer)) { //TIOFe 296 if(!_dummy.stream(a_buffer)) { //TIOFeatures fIOFeatures 297 m_out << "tools::rroot::tree::stream 297 m_out << "tools::rroot::tree::stream : can't read (dummy) TIOFeatures." << std::endl; 298 return false; 298 return false; 299 } 299 } 300 } 300 } 301 } 301 } 302 302 303 //FIXME if (fEstimate <= 10000) fEstimate 303 //FIXME if (fEstimate <= 10000) fEstimate = 1000000; 304 304 305 //TObjArray 305 //TObjArray 306 //The below m_branches.read will create le 306 //The below m_branches.read will create leaves. 307 //::printf("debug : tree : read branches : 307 //::printf("debug : tree : read branches : begin\n"); 308 {ifac::args args; 308 {ifac::args args; 309 if(!m_branches.stream(a_buffer,args)) { 309 if(!m_branches.stream(a_buffer,args)) { 310 m_out << "tools::rroot::tree::stream : " 310 m_out << "tools::rroot::tree::stream : " 311 << "can't read branches." 311 << "can't read branches." 312 << std::endl; 312 << std::endl; 313 return false; 313 return false; 314 }} 314 }} 315 //::printf("debug : tree : read branches : 315 //::printf("debug : tree : read branches : end\n"); 316 316 317 //TObjArray 317 //TObjArray 318 // We read leaves in order to keep streami 318 // We read leaves in order to keep streaming synchronisation. 319 // In fact m_leaves are references to exis 319 // In fact m_leaves are references to existing leaves read by 320 // the branches in the upper line of code. 320 // the branches in the upper line of code. 321 //::printf("debug : tree : read leaves : b 321 //::printf("debug : tree : read leaves : begin\n"); 322 {obj_array<base_leaf> m_leaves(m_fac); 322 {obj_array<base_leaf> m_leaves(m_fac); 323 //branch b(m_out,m_fac); 323 //branch b(m_out,m_fac); 324 ifac::args args; 324 ifac::args args; 325 //args[ifac::arg_branch()] = &b; 325 //args[ifac::arg_branch()] = &b; 326 if(!m_leaves.stream(a_buffer,args)) { 326 if(!m_leaves.stream(a_buffer,args)) { 327 m_out << "tools::rroot::tree::stream : " 327 m_out << "tools::rroot::tree::stream : " 328 << "can't read leaves." 328 << "can't read leaves." 329 << std::endl; 329 << std::endl; 330 return false; 330 return false; 331 }} 331 }} 332 //::printf("debug : tree : read leaves : e 332 //::printf("debug : tree : read leaves : end\n"); 333 333 334 if(vers>=10) { 334 if(vers>=10) { 335 //TList* fAliases 335 //TList* fAliases 336 if(!dummy_TXxx_pointer_stream(a_buffer,m 336 if(!dummy_TXxx_pointer_stream(a_buffer,m_fac)) { 337 m_out << "tools::rroot::tree::stream : 337 m_out << "tools::rroot::tree::stream : " 338 << "can't read fAliases." 338 << "can't read fAliases." 339 << std::endl; 339 << std::endl; 340 return false; 340 return false; 341 } 341 } 342 } 342 } 343 343 344 //m_saved_bytes = m_tot_bytes; 344 //m_saved_bytes = m_tot_bytes; 345 {std::vector<double> v; 345 {std::vector<double> v; 346 if(!Array_stream<double>(a_buffer,v)) retu 346 if(!Array_stream<double>(a_buffer,v)) return false;} //fIndexValues TArrayD 347 347 348 {std::vector<int> v; 348 {std::vector<int> v; 349 if(!Array_stream<int>(a_buffer,v)) return 349 if(!Array_stream<int>(a_buffer,v)) return false;} // fIndex (TArrayI). 350 350 351 if(vers>=16) { 351 if(vers>=16) { 352 //TVirtualIndex* fTreeIndex //FIXME ??? 352 //TVirtualIndex* fTreeIndex //FIXME ??? 353 if(!dummy_TXxx_pointer_stream(a_buffer,m 353 if(!dummy_TXxx_pointer_stream(a_buffer,m_fac)) { 354 m_out << "tools::rroot::tree::stream : 354 m_out << "tools::rroot::tree::stream : " 355 << "can't read fTreeIndex." 355 << "can't read fTreeIndex." 356 << std::endl; 356 << std::endl; 357 return false; 357 return false; 358 } 358 } 359 } 359 } 360 360 361 if(vers>=6) { 361 if(vers>=6) { 362 //TList* fFriends 362 //TList* fFriends 363 if(!dummy_TXxx_pointer_stream(a_buffer,m 363 if(!dummy_TXxx_pointer_stream(a_buffer,m_fac)) { 364 m_out << "tools::rroot::tree::stream : 364 m_out << "tools::rroot::tree::stream : " 365 << "can't read fFriends." 365 << "can't read fFriends." 366 << std::endl; 366 << std::endl; 367 return false; 367 return false; 368 } 368 } 369 } 369 } 370 370 371 if(vers>=16) { 371 if(vers>=16) { 372 //TList* fUserInfo 372 //TList* fUserInfo 373 if(!dummy_TXxx_pointer_stream(a_buffer,m 373 if(!dummy_TXxx_pointer_stream(a_buffer,m_fac)) { 374 m_out << "tools::rroot::tree::stream : 374 m_out << "tools::rroot::tree::stream : " 375 << "can't read fUserInfo." 375 << "can't read fUserInfo." 376 << std::endl; 376 << std::endl; 377 return false; 377 return false; 378 } 378 } 379 //TBranchRef* fBranchRef 379 //TBranchRef* fBranchRef 380 if(!dummy_TXxx_pointer_stream(a_buffer,m 380 if(!dummy_TXxx_pointer_stream(a_buffer,m_fac)) { 381 m_out << "tools::rroot::tree::stream : 381 m_out << "tools::rroot::tree::stream : " 382 << "can't read fBranchRef." 382 << "can't read fBranchRef." 383 << std::endl; 383 << std::endl; 384 return false; 384 return false; 385 } 385 } 386 } 386 } 387 387 388 if(!a_buffer.check_byte_count(_s,_c,TTree_ << 388 if(!a_buffer.check_byte_count(s,c,TTree_cls())) return false; 389 389 390 return true; 390 return true; 391 } 391 } 392 protected: 392 protected: 393 void _dump_branches(std::ostream& a_out, 393 void _dump_branches(std::ostream& a_out, 394 const std::vector 394 const std::vector<branch*>& a_bs, 395 const std::string 395 const std::string& a_spaces = "", 396 const std::string 396 const std::string& a_indent = " "){ 397 tools_vforcit(branch*,a_bs,it) { 397 tools_vforcit(branch*,a_bs,it) { 398 if(branch_element* be = safe_cast<branch 398 if(branch_element* be = safe_cast<branch,branch_element>(*(*it))) { 399 a_out << a_spaces 399 a_out << a_spaces 400 << "branch_element :" 400 << "branch_element :" 401 << " name=" << sout((*it)->name( 401 << " name=" << sout((*it)->name()) 402 << " title=" << sout((*it)->titl 402 << " title=" << sout((*it)->title()) 403 << " entry_number=" << be->entry 403 << " entry_number=" << be->entry_number() 404 << " ref_cls=" << sout(be->class 404 << " ref_cls=" << sout(be->class_name()) 405 << " (type=" << be->type() 405 << " (type=" << be->type() 406 << ",id=" << be->id() 406 << ",id=" << be->id() 407 << ",stype=" << be->streamer_typ 407 << ",stype=" << be->streamer_type() 408 << ")." 408 << ")." 409 << std::endl; 409 << std::endl; 410 } else { 410 } else { 411 a_out << a_spaces 411 a_out << a_spaces 412 << "branch :" 412 << "branch :" 413 << " name=" << sout((*it)->name( 413 << " name=" << sout((*it)->name()) 414 << " title=" << sout((*it)->titl 414 << " title=" << sout((*it)->title()) 415 << " entry_number=" << (*it)->en 415 << " entry_number=" << (*it)->entry_number() 416 << std::endl; 416 << std::endl; 417 } 417 } 418 418 419 419 420 {const std::vector<base_leaf*>& lvs = (*i 420 {const std::vector<base_leaf*>& lvs = (*it)->leaves(); 421 tools_vforcit(base_leaf*,lvs,itl) { 421 tools_vforcit(base_leaf*,lvs,itl) { 422 a_out << a_spaces << a_indent 422 a_out << a_spaces << a_indent 423 << "leave :" 423 << "leave :" 424 << " name=" << sout((*itl)->name 424 << " name=" << sout((*itl)->name()) 425 << " title=" << sout((*itl)->tit 425 << " title=" << sout((*itl)->title()) 426 << " cls=" << sout((*itl)->s_cls 426 << " cls=" << sout((*itl)->s_cls()) 427 << std::endl; 427 << std::endl; 428 }} 428 }} 429 429 430 _dump_branches(a_out,(*it)->branches(),a 430 _dump_branches(a_out,(*it)->branches(),a_spaces+a_indent,a_indent); 431 } 431 } 432 } 432 } 433 433 434 static branch* _find_branch(const std::vecto 434 static branch* _find_branch(const std::vector<branch*>& a_bs,const std::string& a_name,bool a_recursive) { 435 tools_vforcit(branch*,a_bs,it) { 435 tools_vforcit(branch*,a_bs,it) { 436 if(rcmp((*it)->name(),a_name)) return *i 436 if(rcmp((*it)->name(),a_name)) return *it; 437 if(a_recursive) { 437 if(a_recursive) { 438 branch* br = _find_branch((*it)->branc 438 branch* br = _find_branch((*it)->branches(),a_name,a_recursive); 439 if(br) return br; 439 if(br) return br; 440 } 440 } 441 } 441 } 442 return 0; 442 return 0; 443 } 443 } 444 444 445 static base_leaf* _find_leaf(const std::vect 445 static base_leaf* _find_leaf(const std::vector<branch*>& a_bs,const std::string& a_name,bool a_recursive) { 446 tools_vforcit(branch*,a_bs,it) { 446 tools_vforcit(branch*,a_bs,it) { 447 tools_vforcit(base_leaf*,(*it)->leaves() 447 tools_vforcit(base_leaf*,(*it)->leaves(),itl) { 448 if(rcmp((*itl)->name(),a_name)) return 448 if(rcmp((*itl)->name(),a_name)) return *itl; 449 } 449 } 450 if(a_recursive) { 450 if(a_recursive) { 451 base_leaf* lf = _find_leaf((*it)->bran 451 base_leaf* lf = _find_leaf((*it)->branches(),a_name,a_recursive); 452 if(lf) return lf; 452 if(lf) return lf; 453 } 453 } 454 } 454 } 455 return 0; 455 return 0; 456 } 456 } 457 457 458 static void _find_leaves(const std::vector<b 458 static void _find_leaves(const std::vector<branch*>& a_bs,std::vector<base_leaf*>& a_leaves) { 459 tools_vforcit(branch*,a_bs,it) { 459 tools_vforcit(branch*,a_bs,it) { 460 tools_vforcit(base_leaf*,(*it)->leaves() 460 tools_vforcit(base_leaf*,(*it)->leaves(),itl) a_leaves.push_back(*itl); 461 _find_leaves((*it)->branches(),a_leaves) 461 _find_leaves((*it)->branches(),a_leaves); 462 } 462 } 463 } 463 } 464 464 465 static void _find_branches(const std::vector 465 static void _find_branches(const std::vector<branch*>& a_bs,std::vector<branch*>& a_branches){ 466 tools_vforcit(branch*,a_bs,it) { 466 tools_vforcit(branch*,a_bs,it) { 467 a_branches.push_back(*it); 467 a_branches.push_back(*it); 468 _find_branches((*it)->branches(),a_branc 468 _find_branches((*it)->branches(),a_branches); 469 } 469 } 470 } 470 } 471 471 472 static branch* _find_leaf_branch(const std:: 472 static branch* _find_leaf_branch(const std::vector<branch*>& a_bs,const base_leaf& a_leaf) { 473 tools_vforcit(branch*,a_bs,itb) { 473 tools_vforcit(branch*,a_bs,itb) { 474 tools_vforcit(base_leaf*,(*itb)->leaves( 474 tools_vforcit(base_leaf*,(*itb)->leaves(),itl) {if(*itl==&a_leaf) return *itb;} 475 {branch* br = _find_leaf_branch((*itb)->b 475 {branch* br = _find_leaf_branch((*itb)->branches(),a_leaf); 476 if(br) return br;} 476 if(br) return br;} 477 } 477 } 478 return 0; 478 return 0; 479 } 479 } 480 protected: 480 protected: 481 ifile& m_file; 481 ifile& m_file; 482 ifac& m_fac; 482 ifac& m_fac; 483 std::ostream& m_out; 483 std::ostream& m_out; 484 //Named 484 //Named 485 std::string m_name; 485 std::string m_name; 486 std::string m_title; 486 std::string m_title; 487 487 488 obj_array<branch> m_branches; 488 obj_array<branch> m_branches; 489 uint64 m_entries; // Number of entries 489 uint64 m_entries; // Number of entries 490 }; 490 }; 491 491 492 }} 492 }} 493 493 494 #endif 494 #endif