File indexing completed on 2024-04-06 12:23:59
0001 #include <algorithm>
0002 #include <iostream>
0003 #include <string>
0004 #include <vector>
0005
0006 #include "TF1.h"
0007 #include "TH1F.h"
0008 #include "TFile.h"
0009 #include "TStyle.h"
0010 #include "TCanvas.h"
0011 #include "TLegend.h"
0012
0013
0014
0015 static const unsigned int MAXBIN=8;
0016
0017
0018
0019 static const float BINS[]={30., 40., 50., 60., 70., 80., 100., 125., 150.};
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032 void monitorJetEnergyScale()
0033 {
0034 gStyle->SetOptStat( 0);
0035 gStyle->SetOptFit (1111);
0036
0037
0038 std::vector<std::string> corrLevels_;
0039 corrLevels_.push_back("Uncorrected");
0040 corrLevels_.push_back("L2Relative" );
0041 corrLevels_.push_back("L3Absolute" );
0042
0043
0044 TFile* file = new TFile("analyzeJetEnergyScale.root");
0045
0046
0047 std::vector<TH1F*> jes;
0048 for(unsigned int idx=0; idx<corrLevels_.size(); ++idx){
0049 jes.push_back(new TH1F(std::string("jes").append(corrLevels_[idx]).c_str(), "Jet Response", MAXBIN, BINS));
0050 }
0051
0052
0053 std::vector<std::vector<TH1F*> > hists;
0054 for(unsigned int idx=0; idx<corrLevels_.size(); ++idx){
0055 std::vector<TH1F*> buffer;
0056 for(unsigned int jdx=0; jdx<MAXBIN; ++jdx){
0057 char path[50]; sprintf (path, "%s/jes_%i", corrLevels_[idx].c_str(), jdx);
0058 buffer.push_back((TH1F*)file->Get(path));
0059 }
0060 hists.push_back(buffer);
0061 }
0062
0063
0064 for(unsigned int idx=0; idx<corrLevels_.size(); ++idx){
0065 for(unsigned int jdx=0; jdx<MAXBIN; ++jdx){
0066 hists[idx][jdx]->Fit("gaus");
0067 jes[idx]->SetBinContent(jdx+1, hists[idx][jdx]->GetFunction("gaus")->GetParameter(1));
0068 jes[idx]->SetBinError (jdx+1, hists[idx][jdx]->GetFunction("gaus")->GetParError (1));
0069 }
0070 }
0071
0072
0073 TCanvas* canv0 = new TCanvas("canv0", "canv0", 600, 600);
0074 canv0->cd(0);
0075 canv0->SetGridx(1);
0076 canv0->SetGridy(1);
0077 jes[2]->SetMinimum(0.);
0078 jes[2]->SetMaximum(2.);
0079 jes[2]->SetLineColor(kRed);
0080 jes[2]->SetLineWidth(3.);
0081 jes[2]->SetMarkerStyle(20.);
0082 jes[2]->SetMarkerColor(kRed);
0083 jes[2]->GetXaxis()->SetTitle("p_{T}^{gen} [GeV]");
0084 jes[2]->Draw();
0085 jes[1]->SetLineColor(kBlue);
0086 jes[1]->SetLineWidth(3.);
0087 jes[1]->SetMarkerStyle(21.);
0088 jes[1]->SetMarkerColor(kBlue);
0089 jes[1]->Draw("same");
0090 jes[0]->SetLineColor(kBlack);
0091 jes[0]->SetLineWidth(3.);
0092 jes[0]->SetMarkerStyle(22.);
0093 jes[0]->SetMarkerColor(kBlack);
0094 jes[0]->Draw("same");
0095
0096 TLegend* leg = new TLegend(0.4,0.6,0.90,0.90);
0097 leg->SetFillStyle (0);
0098 leg->SetFillColor (0);
0099 leg->SetBorderSize(0);
0100 leg->AddEntry( jes[2], "L3Absolute" , "LP");
0101 leg->AddEntry( jes[1], "L2Relative" , "LP");
0102 leg->AddEntry( jes[0], "Uncorrected", "LP");
0103 leg->Draw("same");
0104 }
0105
0106