Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 14:20:54

0001 #include <iostream>
0002 #include <string.h>
0003 #include <iomanip>
0004 #include<fstream>
0005 #include <math.h>
0006 
0007 #include "TFile.h"
0008 #include "TH1F.h"
0009 #include "TH2F.h"
0010 
0011 
0012 void drawall(char* f1, char* f2 ,char* label1, char* label2, char* var , string outname){
0013   TFile* file1 = TFile::Open(f1);
0014   TFile* file2 = TFile::Open(f2);
0015 
0016   TH1F* hf1=0, *hf2=0;
0017 
0018   TH1F* num1=0, *denom1=0;
0019 
0020   char* name1=0, *name2=0;
0021 
0022   const int npaths = 3;
0023   string paths[npaths]={"singleElectron","singleElectronRelaxed","singleElectronLargeWindow"};
0024   string Histo_paths[npaths];
0025   for(int i=0;i<npaths;i++){Histo_paths[i]=paths[i]+"DQM/total eff";}
0026 
0027   string fname= outname + "(";
0028   TCanvas* c1= new TCanvas("c1","c1");
0029   c1->SetFillColor(0);
0030   c1->Divide(2,2);
0031 
0032   for(int path=0; path< npaths ; path++){
0033     
0034     hf1 = (TH1F*)file1->Get(Histo_paths[path].c_str());
0035     hf2 = (TH1F*)file2->Get(Histo_paths[path].c_str());
0036     
0037     int plotnr = 0;
0038 
0039     for(int filter=1; filter < hf1->GetNbinsX() -2 ; filter++){
0040       name1 = hf1->GetXaxis()->GetBinLabel(filter);
0041       name2 = hf1->GetXaxis()->GetBinLabel(filter+1);
0042       std::cout << name1 << std::endl;   
0043       
0044       string numname = paths[path] + "DQM/"+ name2 + var;
0045       string denomname = paths[path] + "DQM/"+ name1 + var;
0046       
0047       std::cout << denomname << std::endl;  
0048 
0049       num1   =  new TH1F( *(TH1F*)file1->Get(numname.c_str()) );
0050       denom1 =  new TH1F( *(TH1F*)file1->Get(denomname.c_str()) );
0051       num2   =  new TH1F( *(TH1F*)file2->Get(numname.c_str()) );
0052       std::cout << name1 << std::endl;  
0053 
0054       //*********************************************************
0055       // DANGER: terrible clutch for differing filter names in 200 and 183
0056       if(!strcmp(name2,"hltL1seedSingle")){
0057     denomname = paths[path] + "DQM/"+ "hltL1seedSingleEgamma" + var;
0058       }
0059       if(!strcmp(name2,"hltL1seedRelaxedSingle")){
0060     denomname = paths[path] + "DQM/"+ "hltL1seedRelaxedSingleEgamma" + var;
0061       }
0062       if(!strcmp(name2,"hltL1seedDouble")){
0063     denomname = paths[path] + "DQM/"+ "hltL1seedDoubleEgamma" + var;
0064       }
0065       if(!strcmp(name2,"hltL1seedRelaxedDouble")){
0066     denomname = paths[path] + "DQM/"+ "hltL1seedRelaxedDoubleEgamma" + var;
0067       }
0068       // ********************************************************
0069       denom2 =  new TH1F( *(TH1F*)file2->Get(denomname.c_str() ));
0070       
0071       num1->Sumw2();
0072       denom1->Sumw2();
0073       num2->Sumw2();
0074       denom2->Sumw2();
0075 
0076       num1->Divide(num1,denom1,1.,1.,"b");
0077       num2->Divide(num2,denom2,1.,1.,"b");
0078    
0079       string title = paths[path] + " : " + name2 + ";" + var + " ;Efficiency";
0080       num1->SetTitle(title.c_str());
0081       num1->SetLineColor(2);
0082       num2->SetLineColor(4);
0083  
0084       TLegend *legend = new TLegend(0.4,0.2,0.55,0.4,"");
0085       TLegendEntry* l1 = legend->AddEntry(num1,label1,"l");
0086       l1->SetTextSize(0.1);
0087       l1 = legend->AddEntry(num2,label2,"l");
0088       l1->SetTextSize(0.1);
0089 
0090 
0091       //std::cout << plotnr%4 << std::endl;
0092       if(plotnr%4==0){
0093     c1->Clear("D");
0094       }
0095       c1->cd(plotnr%4 + 1);
0096 
0097       num1->Draw();
0098       num2->Draw("same");
0099       legend->Draw();      
0100 
0101       plotnr++;
0102    
0103       if(plotnr%4==0){
0104     c1->Print(fname.c_str());
0105       }   
0106     }
0107     
0108     if(plotnr%4!=0){
0109       c1->Print(fname.c_str());
0110     }
0111   }
0112   c1->Clear();
0113   fname=outname+")";
0114   c1->Print(fname.c_str());
0115 
0116 
0117 }
0118 
0119