Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:22:44

0001 #include <iostream>
0002 #include <TFile.h>
0003 #include <TDirectory.h>
0004 #include <TCanvas.h>
0005 #include <TH1D.h>
0006 #include <TProfile.h>
0007 
0008 void GetResol()
0009 {
0010   TFile * file = new TFile("redrawed_3.root", "READ");
0011   TFile * funcFile = new TFile("3_MuScleFit.root", "READ");
0012 
0013   TDirectory * dir = (TDirectory*) file->Get("hResolPtGenVSMu");
0014   TDirectory * funcDir = (TDirectory*) funcFile->Get("hFunctionResolPt");
0015 
0016   TH1D * histo = (TH1D*)dir->Get("hResolPtGenVSMu_ResoVSEta_resol");
0017   TProfile * funcProfile = (TProfile*) funcDir->Get("hFunctionResolPt_ResoVSEta_prof");
0018 
0019   TH1D * funcHisto = new TH1D(TString(funcProfile->GetName())+"histo", TString(funcProfile->GetTitle())+"histo", funcProfile->GetNbinsX(), histo->GetXaxis()->GetXmin(), histo->GetXaxis()->GetXmax());
0020   for( int i=1; i<=funcHisto->GetNbinsX(); ++i ) {
0021     funcHisto->SetBinContent(i, funcProfile->GetBinContent(i));
0022     // std::cout << "error["<<i<<"] = " << funcHisto->GetBinContent(i)*(1 - (0.7311228/0.781686)) << std::endl;
0023     funcHisto->SetBinError( i, funcHisto->GetBinContent(i)*(1 - (0.73391182/0.73723)) ); // (0.7648316/0.781686)) );
0024     // std::cout << "value["<<i<<"] = " << funcHisto->GetBinContent(i) << " +- " <<  funcHisto->GetBinError(i) << std::endl;
0025   }
0026 
0027   funcHisto->Draw("E5");
0028   // funcHisto->SetLineColor(kRed);
0029   // funcHisto->SetMarkerColor(kRed);
0030   funcHisto->SetFillColor(kGray);
0031   histo->Draw("SAME");
0032 
0033 }