Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 13:34:57

0001 #include <vector.h>
0002 void DrawJetValidation()
0003 {  
0004   PrintMessage();
0005 }
0006 void DrawJetValidation(char s1[1024])
0007 {  
0008   char filename[1][1024];
0009   sprintf(filename[0],"%s",s1);
0010   MainProgram(1,filename);
0011 }
0012 void DrawJetValidation(char s1[1024],char s2[1024])
0013 { 
0014   char filename[2][1024];
0015   sprintf(filename[0],"%s",s1);
0016   sprintf(filename[1],"%s",s2);
0017   MainProgram(2,filename);
0018 }
0019 void MainProgram(const int NAlg,char filename[][1024])
0020 {
0021   gROOT->SetStyle("Plain");
0022   //gStyle->SetOptStat(0000);
0023   //gStyle->SetOptFit(000); 
0024   gStyle->SetPalette(1);
0025  
0026   char name[100];
0027   int alg,hCounter,pCounter,i;
0028   TFile *inf[NAlg]; 
0029   TH1F *h[NAlg][100];
0030   TProfile *p[NAlg][100];
0031   TCanvas *hCan[100];
0032   TCanvas *pCan[100];
0033   TKey *key;
0034   ///////////////////////////////////////////////////////////////
0035   for(alg=0;alg<NAlg;alg++)
0036     {
0037       inf[alg] = new TFile(filename[alg],"r");
0038       TIter next(inf[alg]->GetListOfKeys());
0039       hCounter = 0;
0040       pCounter = 0;
0041       while ((key = (TKey*)next()))
0042        {
0043          if (strcmp(key->GetClassName(),"TH1F")==0)
0044            {
0045              h[alg][hCounter] = (TH1F*)inf[alg]->Get(key->GetName());
0046              hCounter++;
0047            } 
0048          if (strcmp(key->GetClassName(),"TProfile")==0)
0049            {
0050              p[alg][pCounter] = (TProfile*)inf[alg]->Get(key->GetName());
0051              pCounter++;
0052            }
0053        }
0054     }
0055   for(i=0;i<hCounter;i++)
0056     {
0057       sprintf(name,"can_%s",h[0][i]->GetName());       
0058       hCan[i] = new TCanvas(name,name,900,600);
0059       TLegend *leg = new TLegend(0.5,0.15,0.85,0.4);
0060       for(alg=0;alg<NAlg;alg++)
0061         {
0062           h[alg][i]->SetLineColor(alg+1);   
0063           h[alg][i]->SetMarkerColor(alg+1); 
0064           h[alg][i]->Draw("same");
0065           leg->AddEntry(h[alg][i],filename[alg],"L");
0066         }
0067       leg->SetFillColor(0);
0068       leg->SetLineColor(0);
0069       leg->Draw();
0070     }
0071   for(i=0;i<pCounter;i++)
0072     {
0073       sprintf(name,"can_%s",p[0][i]->GetName());       
0074       pCan[i] = new TCanvas(name,name,900,600);
0075       TLegend *leg = new TLegend(0.5,0.15,0.85,0.4);
0076       for(alg=0;alg<NAlg;alg++)
0077         {
0078           p[alg][i]->SetLineColor(alg+1); 
0079           p[alg][i]->SetMarkerColor(alg+1);   
0080           p[alg][i]->Draw("same");
0081           leg->AddEntry(h[alg][i],filename[alg],"L");
0082         }
0083       leg->SetFillColor(0);
0084       leg->SetLineColor(0);
0085       leg->Draw();
0086     }
0087 }
0088 
0089 void PrintMessage()
0090 {
0091   cout<<"This ROOT macro compares histograms from up to 2 files."<<endl;
0092   cout<<"Usage: .X DrawJetValidation.C(\"filename1\",\"filename2\")"<<endl;
0093 }