File indexing completed on 2024-04-06 12:12:48
0001 #include "TFile.h"
0002 #include "TKey.h"
0003 #include "TTree.h"
0004 #include "TError.h"
0005 #include "TCollection.h"
0006 #include <iostream>
0007
0008 void allbranches()
0009 {
0010 char * charname;
0011 std::string fname;
0012 gErrorIgnoreLevel = kError;
0013 std::cin >> fname;
0014 if(fname == "quit") return;
0015 TObject * obj;
0016 TTree * tree;
0017 TKey * key;
0018 TFile * file = new TFile(fname.c_str(),"READ","Test file");
0019 if(file) {
0020 TIter next(file->GetListOfKeys());
0021 while( (key = (TKey*)next()) ) {
0022 obj = key->ReadObj();
0023 if ( (obj->InheritsFrom("TTree")) ) {
0024 charname = ((TTree*)obj)->GetName();
0025 std::cout << "\nAll branches for TTree " << charname
0026 << " in file " << fname << "\n" << std::endl;
0027 file->GetObject(charname,tree);
0028 if(tree) {
0029 tree->Print("all");
0030 } else {
0031 std::cout << "Anomoly. There is no tree named " << charname << std::endl;
0032 }
0033 }
0034 }
0035 }
0036 std::cout << " " << std::endl;
0037 }