Back to home page

Project CMSSW displayed by LXR

 
 

    


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

0001 #include <queue>
0002 
0003 void eleListDir( 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()<<";"<<key->GetCycle()
0032           <<" has "<<histo->GetEntries()<<" entries"
0033           <<" (~"<<histo->GetEffectiveEntries()<<")"
0034           <<" of mean value "<<histo->GetMean()
0035           <<std::endl ;
0036        }
0037       else
0038        { std::cout<<"What is "<<obj->GetName()<<" ?"<<std::endl ; }
0039      }
0040    }
0041  }
0042 
0043 int eleListHistos()
0044  {
0045   TString input_file_name = gSystem->Getenv("TEST_HISTOS_FILE") ;
0046   TString internal_path("DQMData") ;
0047 
0048   input_file = TFile::Open(input_file_name) ;
0049   if (input_file!=0)
0050    {
0051     std::cout<<"open "<<input_file_name<<std::endl ;
0052     if (input_file->cd(internal_path)!=kTRUE)
0053      {
0054       std::cerr<<"Failed move to: "<<internal_path<<std::endl ;
0055       eleListDir("",gDirectory) ;
0056      }
0057     else
0058      {
0059       std::cout<<"cd "<<internal_path<<std::endl ;
0060       eleListDir(new TObjString(internal_path),gDirectory) ;
0061      }
0062    }
0063   else
0064    {
0065     std::cerr<<"Failed to open: "<<input_file_name<<std::endl ;
0066     return ;
0067    }
0068   input_file->Close() ;
0069  }