Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:24:46

0001 #include <queue>
0002 
0003 cmsListDir( const TObjString * firstdirname, const TDirectory * firstDir )
0004  {
0005   TObjArray * dirs = new TObjArray ;
0006   dirs->AddLast(new TPair(firstdirname,firstDir)) ;
0007   TList * keys ;
0008   TKey * key ;
0009   TH1 * histo ;
0010   TIter nextDir(dirs) ;
0011   TPair * pair ;
0012   const TObjString * dirname ;
0013   const TDirectory * dir ;
0014   while (pair = (TPair *)nextDir())
0015    {
0016     dirname = (TObjString *)pair->Key() ;
0017     dir = (TDirectory *)pair->Value() ;
0018     keys = dir->GetListOfKeys() ;
0019     TIter nextKey(keys) ;
0020     while (key = (TKey *)nextKey())
0021      {
0022       obj = key->ReadObj() ;
0023       if (obj->IsA()->InheritsFrom("TDirectory"))
0024        {
0025         dirs->AddLast(new TPair(new TObjString(dirname->String()+"/"+obj->GetName()),obj)) ;
0026        }
0027       else if (obj->IsA()->InheritsFrom("TH1"))
0028        {
0029         histo = (TH1 *)obj ;
0030         std::cout
0031           <<"Histo "<<dirname->String()<<"/"<<histo->GetName()
0032           <<" has "<<histo->GetEffectiveEntries()<<" entries"
0033           <<" of mean value "<<histo->GetMean()
0034           <<std::endl ;
0035        }
0036       else
0037        { std::cout<<"What is "<<obj->GetName()<<" ?"<<std::endl ; }
0038      }
0039    }
0040  }
0041 
0042 cmsListHistos()
0043  {
0044   TString input_file_name = gSystem->Getenv("TEST_INPUT_FILE") ;
0045   TString internal_path("DQMData/Run 1/EgammaV/Run summary") ;
0046 
0047   input_file = TFile::Open(input_file_name) ;
0048   if (input_file!=0)
0049    {
0050     std::cout<<"open "<<input_file_name<<std::endl ;
0051     if (input_file->cd(internal_path)!=kTRUE)
0052      {
0053       std::cerr<<"Failed move to: "<<internal_path<<std::endl ;
0054       cmsListDir("",gDirectory) ;
0055      }
0056     else
0057      {
0058       std::cout<<"cd "<<internal_path<<std::endl ;
0059       cmsListDir(new TObjString(internal_path),gDirectory) ;
0060      }
0061    }
0062   else
0063    {
0064     std::cerr<<"Failed to open: "<<input_file_name<<std::endl ;
0065     return ;
0066    }
0067   input_file->Close() ;
0068  }