Back to home page

Project CMSSW displayed by LXR

 
 

    


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 branchlist()
0009 {
0010   std::string fname;
0011   std::string tname;
0012   gErrorIgnoreLevel = kError;
0013   while(true) {
0014     std::cin >> fname;
0015     if(fname == "quit")  return;
0016     std::cin >> tname;
0017     std::cout << "\nAll branches for TTree " << tname
0018               << " in file " << fname << "\n" << std::endl;
0019     TFile * file = new TFile(fname.c_str(),"READ","Test file");
0020     if(file) {
0021       TTree * tree;
0022       tname = tname + ";";
0023       file->GetObject(tname.c_str(),tree);
0024       if (tree)  {
0025     tree->Print("all");
0026       } else {
0027     std::cout << "There is no TTree object named " << tname << std::endl;
0028       }
0029     }
0030   }
0031 }