Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 13:28:46

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 treelist()
0009 {
0010   std::string fname;
0011   gErrorIgnoreLevel = kError;
0012   std::cin >> fname;
0013   if(fname == "quit")  return;
0014   TObject * obj;
0015   TKey * key;
0016   TFile * file = new TFile(fname.c_str(),"READ","Test file");
0017   if(file) {
0018     std::cout << "\nNames of TTree objects in file: " << fname << std::endl;
0019     gErrorIgnoreLevel = kError;
0020     TIter next(file->GetListOfKeys());
0021     while( (key = (TKey*)next()) ) {
0022       obj = key->ReadObj();
0023       if ( (obj->InheritsFrom("TTree")) ) {
0024         std::cout << "\t\t" << ((TTree*)obj)->GetName() << std::endl;
0025       }
0026     }
0027   }
0028   std::cout << " " << std::endl;
0029 }