Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:32:02

0001 import re, sys, os
0002 
0003 file = open("output", "r")
0004 
0005 lines = file.readlines()
0006 file.close()
0007 
0008 variable = []
0009 eta1 = []
0010 eta2 = []
0011 mean = []
0012 error= []
0013 effS = []
0014 
0015 for line in lines:
0016     elements = re.split("\t", line)
0017     variable += [elements[1],]
0018     
0019     eta1 += [re.split(">", re.split("&&", elements[2])[0])[1],]
0020     eta2 += [re.split("<", elements[2])[1],]
0021 
0022     mean += [elements[3],]
0023     error+= [elements[4],]
0024     effS += [elements[5][:-1],]
0025 
0026 header = """void plot_EffSigmaVsEta(){
0027    TCanvas *c1        = new TCanvas("c1","EffSigma vs Eta", 800, 1000);
0028    TH1F* h_emCorr_et  = new TH1F("h_emCorr_et","",150,0,1.5);
0029    TH1F* h_em_et      = new TH1F("h_em_et","",150,0,1.5);
0030    TH1F* add          = new TH1F("add","",150,0,1.5);
0031    TH1F* ratio        = new TH1F("ratio","",150,0,1.5);
0032 
0033    c1->Divide(1,2);
0034    c1->cd(1);
0035 """
0036 file = open("plot_EffSigmaVsEta.C", "w")
0037 file.write(header)
0038 
0039 for i in ("emCorr_et", "em_et"):
0040     for j in range(0, len(eta1)):
0041         if variable[j] != i:
0042             continue
0043         bin = str(int((float(eta1[j]) + float(eta2[j]))*50))
0044         file.write("  h_" + i + "->SetBinContent(" + bin + ", " + effS[j] + ");\n")
0045         file.write("  h_" + i + "->SetBinError  (" + bin + ", 1e-10);\n")
0046 
0047 file.write("  h_emCorr_et->SetMarkerStyle(23);\n")
0048 file.write("  h_em_et    ->SetMarkerStyle(20);\n")
0049 
0050 file.write("  h_emCorr_et->SetMarkerColor(4);\n")
0051 file.write("  h_em_et    ->SetMarkerColor(1);\n")
0052 
0053 file.write("  gStyle->SetOptStat(0);\n")
0054 
0055 file.write("  h_em_et    ->Draw();\n")
0056 file.write("  h_emCorr_et    ->Draw(\"SAME\");\n")
0057 
0058 header ="""  
0059 
0060   TAxis* ax = h_em_et->GetXaxis();
0061   ax->SetTitle("#eta");
0062   TAxis* ay = h_em_et->GetYaxis();
0063   ay->SetTitle("#sigma_{EFF}");
0064   
0065   TLegend *leg = new TLegend(0.2, 0.2, 0.4, 0.4);
0066   leg->AddEntry(h_em_et, "Before correction");
0067   leg->AddEntry(h_emCorr_et, "After correction  ");
0068   leg->Draw("");
0069 
0070   c1->cd(2);
0071   add->Add(h_emCorr_et, h_em_et, -1, 1);
0072   ratio->Divide(add, h_em_et);
0073   
0074   ratio->SetMarkerStyle(21);
0075   ratio->SetMarkerColor(4);
0076   ratio->GetYaxis()->SetTitle("Improvement in #sigma_{eff}");
0077   ratio->GetXaxis()->SetTitle("#eta");
0078   ratio->Draw();
0079   
0080   c1->Print("EffSigmaVsEta.ps");
0081   gROOT->ProcessLine(".q");
0082 """
0083 file.write(header)
0084 
0085 file.write("}\n")