Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 14:33:38

0001 
0002 int electronWget()
0003  {
0004   TString TEST_HARVESTED_FILE = gSystem->Getenv("TEST_HARVESTED_FILE") ;
0005   TString TEST_HISTOS_FILE = gSystem->Getenv("TEST_HISTOS_FILE") ;
0006   TString VAL_ANALYZER = gSystem->Getenv("VAL_ANALYZER") ;
0007 
0008   TString input_path("DQMData/Run 1/EgammaV/Run summary/") ;
0009   input_path += VAL_ANALYZER ;
0010   TFile * input_file = TFile::Open(TEST_HARVESTED_FILE) ;
0011   TList * input_keys ;
0012   if (input_file!=0)
0013    {
0014     std::cout<<"open "<<TEST_HARVESTED_FILE<<std::endl ;
0015     if (input_file->cd(input_path)==kTRUE)
0016      {
0017       std::cerr<<"cd "<<input_path<<std::endl ;
0018       input_keys = gDirectory->GetListOfKeys() ;
0019      }
0020     else
0021      {
0022       std::cerr<<"Failed move to: "<<input_path<<std::endl ;
0023       return 2 ;
0024      }
0025    }
0026   else
0027    {
0028     std::cerr<<"Failed to open: "<<val_ref_file_name<<std::endl ;
0029     return 1 ;
0030    }
0031 
0032   TFile * output_file = TFile::Open(TEST_HISTOS_FILE,"RECREATE") ; ;
0033   TString output_path("DQMData/EgammaV/") ;
0034   output_path += VAL_ANALYZER ;
0035   if (output_file!=0)
0036    {
0037     std::cout<<"open "<<TEST_HISTOS_FILE<<std::endl ;
0038     if (output_file->mkdir("DQMData")!=0)
0039      { std::cerr<<"cd "<<"DQMData"<<std::endl ; output_file->cd("DQMData") ; }
0040     else
0041      { std::cerr<<"Failed move to: "<<"DQMData"<<std::endl ; return 4 ; }
0042     if (gDirectory->mkdir("EgammaV")!=0)
0043      { std::cerr<<"cd EgammaV"<<std::endl ; gDirectory->cd("EgammaV") ; }
0044     else
0045      { std::cerr<<"Failed move to: "<<"EgammaV"<<std::endl ; return 5 ; }
0046     if (gDirectory->mkdir(VAL_ANALYZER)!=0)
0047      { std::cerr<<"cd "<<VAL_ANALYZER<<std::endl ; gDirectory->cd(VAL_ANALYZER) ; }
0048     else
0049      { std::cerr<<"Failed move to: "<<VAL_ANALYZER<<std::endl ; return 6 ; }
0050    }
0051   else
0052    {
0053     std::cerr<<"Failed to create: "<<TEST_HISTOS_FILE<<std::endl ;
0054     return 3 ;
0055    }
0056 
0057   TObject * obj ;
0058   TH1 * histo ;
0059   TKey * key ;
0060   TIter nextKey(input_keys) ;
0061   while (key = (TKey *)nextKey())
0062    {
0063     obj = key->ReadObj() ;
0064     if (obj->IsA()->InheritsFrom("TH1"))
0065      {
0066       histo = (TH1 *)obj ;
0067       std::cout
0068         <<"Histo "<<histo->GetName()
0069         <<" has "<<histo->GetEntries()<<" entries"
0070         <<" (~"<<histo->GetEffectiveEntries()<<")"
0071         <<" of mean value "<<histo->GetMean()
0072         <<std::endl ;
0073       histo->Clone() ;
0074      }
0075     else
0076      { std::cout<<"What is "<<obj->GetName()<<" ?"<<std::endl ; }
0077    }
0078 
0079 
0080   input_file->Close() ;
0081   output_file->Write() ;
0082   output_file->Close() ;
0083   return 0 ;
0084 
0085  }