Back to home page

Project CMSSW displayed by LXR

 
 

    


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

0001 #include "Settings.h"
0002 void DrawResponse()
0003 {
0004   gROOT->SetStyle("Plain");
0005   gStyle->SetOptStat(0000);
0006   gStyle->SetOptFit(111); 
0007   gStyle->SetPalette(1);
0008   TFile *f;
0009   TH1F *hResponse,*hMeanRefPt,*hMeanCaloPt;
0010   double yRefPt[NPtBins],eyRefPt[NPtBins],xRefPt[NPtBins],exRefPt[NPtBins];
0011   double yCaloPt[NPtBins],eyCaloPt[NPtBins],xCaloPt[NPtBins],exCaloPt[NPtBins];
0012   double x,y,ex,ey,x1,ex1;
0013   int i,N;
0014   f = new TFile(FitterFilename,"r");
0015   if (f->IsZombie()) break; 
0016   hResponse = (TH1F*)f->Get("Response");
0017   hMeanRefPt = (TH1F*)f->Get("MeanRefPt");
0018   hMeanCaloPt = (TH1F*)f->Get("MeanCaloPt");
0019   N = 0;
0020   for(i=0;i<NPtBins;i++)
0021     {
0022       y = hResponse->GetBinContent(i+1);
0023       ey = hResponse->GetBinError(i+1);
0024       x = hMeanRefPt->GetBinContent(i+1);
0025       ex = hMeanRefPt->GetBinError(i+1);
0026       x1 = hMeanCaloPt->GetBinContent(i+1);
0027       ex1 = hMeanCaloPt->GetBinError(i+1); 
0028       if (y>0 && x>0 && x1>0 && ey>0.000001 && ey<0.2)
0029     {
0030           yRefPt[N] = y;
0031           eyRefPt[N] = ey;
0032           xRefPt[N] = x;
0033           exRefPt[N] = ex;
0034           xCaloPt[N] = x1;
0035           exCaloPt[N] = ex1;
0036       N++;
0037     }  
0038     }
0039   TGraphErrors *gRespRefPt = new TGraphErrors(N,xRefPt,yRefPt,exRefPt,eyRefPt);
0040   TGraphErrors *gCorrelation = new TGraphErrors(N,xRefPt,xCaloPt,exRefPt,exCaloPt); 
0041   TF1 *func = new TF1("ideal","x",1,2000);
0042   /////////////////////////////////////////////////////////////////////////////////
0043   TCanvas *can = new TCanvas("CanResponse","CanResponse",900,600);
0044   gPad->SetLogx();
0045   gPad->SetGridy();
0046   gRespRefPt->SetTitle("");
0047   gRespRefPt->GetXaxis()->SetTitle("RefP_{T} (GeV)");
0048   gRespRefPt->GetYaxis()->SetTitle("Response");
0049   gRespRefPt->GetYaxis()->SetNdivisions(505);
0050   gRespRefPt->SetMarkerStyle(20);
0051   gRespRefPt->Draw("AP");
0052   /////////////////////////////////////////////////////////////////////////////////
0053   TCanvas *can1 = new TCanvas("Correlation","Correlation",900,600);
0054   gPad->SetLogx();
0055   gPad->SetLogy();
0056   gCorrelation->SetTitle("");
0057   gCorrelation->GetXaxis()->SetTitle("<RefP_{T}> (GeV)");
0058   gCorrelation->GetYaxis()->SetTitle("<CaloP_{T}> (GeV)");
0059   gCorrelation->GetYaxis()->SetNdivisions(505);
0060   gCorrelation->SetMarkerStyle(20);
0061   gCorrelation->Draw("AP");
0062   func->SetLineColor(2);
0063   func->Draw("same");
0064   TLegend *leg = new TLegend(0.65,0.15,0.85,0.35);
0065   leg->AddEntry(gCorrelation,"measurement","P");
0066   leg->AddEntry(func,"<CaloP_{T}> = <RefP_{T}>","L"); 
0067   leg->SetLineColor(0);
0068   leg->SetFillColor(0);
0069   leg->Draw();    
0070 }