Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 11:59:38

0001 #include <iostream>
0002 #include <vector>
0003 #include "TKey.h"
0004 
0005 void make_summaryplots(){
0006   
0007   //  TFile *file = new TFile("/tmp/fblekman/DQM_R000003238__A__B__C.root");
0008   TFile *file = new TFile("DQM_R000002445__A__B__C.root");
0009   file->cd();
0010   //  TDirectory *dir = file->GetDirectory("DQMData/Run 3238/Pixel/Run summary");
0011   TDirectory *dir = file->GetDirectory("DQMData/Run 2445/Pixel/Run summary");
0012   // make a loop over all plots
0013   TList *list = dir->GetListOfKeys();
0014   gStyle->SetOptStat(0);
0015   Int_t nkeys = file->GetNkeys();
0016   if(dir==0)
0017     return;
0018 
0019   std::cout << "now opening " << dir->GetName() << std::endl;
0020 
0021   TLatex CMSprelim(0.3,0.3,"CMS Preliminary");
0022   CMSprelim.SetTextColor(2);
0023   CMSprelim.SetTextSize(CMSprelim.GetTextSize()*1.2);
0024   
0025   TString comparestring = "Module";
0026   TString curvestring = "row";
0027   std::vector<TString> keylist;
0028   std::vector<TString> hist1list;
0029   std::vector<TString> hist2list;
0030   std::vector<TString> dirlist;
0031   std::vector<TString> notdonelist;
0032   std::vector<int> nsubdirs;
0033   TDirectory *dirsav = dir;
0034   list = dir->GetListOfKeys();
0035   int ikey=0;
0036   int localkey=0;
0037   int ntimes=0;
0038 
0039   TCanvas *curvecanvas = new TCanvas();
0040   for(ikey=0;ikey<list->GetEntries();  ikey++){
0041     TKey *thekey = (TKey*)list->At(ikey);
0042     if(thekey==0)
0043       continue;
0044     TString keyname=thekey->GetName();
0045     //    keyname.ReplaceAll(" ","");
0046     TString keytype=thekey->GetClassName();
0047     keytype.ReplaceAll(" ","");
0048     if(keyname=="EventInfo")
0049       continue;
0050     //    std::cout <<  keytype << " " << keyname << std::endl;
0051     if(keytype=="TDirectoryFile"){
0052       TString dirname=dir->GetPath();
0053       dirname+="/";
0054       dirname+=keyname;
0055       //      std::cout << dirname << std::endl;
0056       dir=file->GetDirectory(dirname);
0057   
0058       list=dir->GetListOfKeys();
0059       if(dirname.Contains(comparestring))
0060     dirlist.push_back(dirname);
0061       else{
0062     notdonelist.push_back(dirname);
0063     nsubdirs.push_back(-1);
0064       }
0065     }
0066   }
0067   int nempty=0;
0068   while(nempty!=notdonelist.size()){
0069     for(int idir=0; idir<notdonelist.size(); ++idir){
0070       if(nsubdirs[idir]==0)
0071     continue;
0072       //std::cout << "now examining " << notdonelist[idir]<< " " << nsubdirs[idir] <<  std::endl;
0073       dir = file->GetDirectory(notdonelist[idir]); 
0074       //      std::cout << dir->GetName() << std::endl;
0075       list= dir->GetListOfKeys(); 
0076       //      std::cout << list->GetEntries() << std::endl;
0077       int ndirectories=0;
0078       for(ikey=0;ikey<list->GetEntries();  ikey++){
0079     TKey *thekey = (TKey*)list->At(ikey);
0080     if(thekey==0)
0081       continue;
0082     TString keyname=thekey->GetName();
0083     keyname.ReplaceAll(" ","");
0084     TString keytype=thekey->GetClassName();
0085     keytype.ReplaceAll(" ","");
0086     if(keytype=="TDirectoryFile"){
0087       TString dirname=dir->GetPath();
0088       dirname+="/";
0089       dirname+=keyname;
0090       //      std::cout << dirname << std::endl;
0091       ndirectories++;
0092       if(dirname.Contains(comparestring))
0093         dirlist.push_back(dirname);
0094       else{
0095         notdonelist.push_back(dirname);
0096         nsubdirs.push_back(-1);
0097       }
0098     }
0099       }
0100       nsubdirs[idir]=ndirectories;
0101       // std::cout << "now done examining " << notdonelist[idir]<< " " << nsubdirs[idir] <<  std::endl;
0102     }
0103     // count number of done dirs;
0104     nempty=0;
0105     for(int i=0; i<nsubdirs.size(); i++){
0106       if(nsubdirs[i]!=-1)
0107     nempty++;
0108     }
0109   }
0110   gStyle->SetOptStat(0);
0111   for(int i=0; i<dirlist.size() ; ++i){
0112     //    std::cout << "good dir "  << dirlist[i] << std::endl;
0113     // now count histograms:
0114     dir = file->GetDirectory(dirlist[i]); 
0115     list= dir->GetListOfKeys(); 
0116     //      std::cout << list->GetEntries() << std::endl;
0117     for(ikey=0;ikey<list->GetEntries();  ikey++){
0118       //      std::cout << ikey << std::endl;
0119       TKey *thekey = (TKey*)list->At(ikey);
0120       if(thekey==0)
0121     continue;
0122       TString keyname=thekey->GetName();
0123       keyname.ReplaceAll(" ","");
0124       TString keytype=thekey->GetClassName();
0125       keytype.ReplaceAll(" ","");
0126       if(keyname.Contains(curvestring))
0127     continue;
0128       if(keytype=="TH1F" || keytype=="TH2F" ){
0129     std::cout << keyname << std::endl;
0130     dir=file->GetDirectory(dirlist[i]);
0131     TH1F* temp = (TH1F*) dir->Get(keyname);
0132     curvecanvas->cd();
0133     curvecanvas->Clear();
0134     dir=file->GetDirectory(dirlist[i]);
0135     dir->cd();
0136     gStyle->SetOptStat(0);
0137     gStyle->SetOptFit(0);
0138     if(keytype=="TH1F"){
0139       temp->GetXaxis()->SetTitle(temp->GetXaxis()->GetTitle());
0140       temp->GetYaxis()->SetTitle(temp->GetYaxis()->GetTitle());
0141       temp->DrawClone(); 
0142       CMSprelim.DrawTextNDC(0.57,0.85,"CMS Pixel");
0143     }
0144     else{
0145       temp->GetXaxis()->SetTitle("Columns");
0146       temp->GetYaxis()->SetTitle("Rows");
0147       temp->SetMinimum(0.);
0148       temp->DrawClone("colz"); 
0149       CMSprelim.DrawTextNDC(0.02,0.01,"CMS Pixel");
0150     }
0151     curvecanvas->Update();
0152     curvecanvas->Print(keyname+".jpg");
0153     curvecanvas->Print(keyname+".eps");
0154       
0155       }
0156     }
0157   }
0158 }
0159 
0160 
0161