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_MeanVsET(){
0027 TCanvas *c1 = new TCanvas("c1","Mean vs ET", 800, 600);
0028 TH1F* h_emCorr_et = new TH1F("h_emCorr_et","",300,0,300);
0029 TH1F* h_em_et = new TH1F("h_em_et","",300,0,300);
0030 c1->cd();
0031 """
0032 file = open("plot_MeanVsET.C", "w")
0033 file.write(header)
0034
0035 for i in ("emCorr_et", "em_et"):
0036 for j in range(0, len(eta1)):
0037 if variable[j] != i:
0038 continue
0039 bin = str(int((float(eta1[j]) + float(eta2[j]))/2))
0040 file.write(" h_" + i + "->SetBinContent(" + bin + ", " + mean[j] + ");\n")
0041 file.write(" h_" + i + "->SetBinError (" + bin + ", " + error[j] +");\n")
0042
0043 file.write(" h_emCorr_et->SetMarkerStyle(23);\n")
0044 file.write(" h_em_et ->SetMarkerStyle(20);\n")
0045
0046 file.write(" h_emCorr_et->SetMarkerColor(4);\n")
0047 file.write(" h_em_et ->SetMarkerColor(1);\n")
0048
0049 file.write(" gStyle->SetOptStat(0);\n")
0050
0051 file.write(" h_em_et ->Draw();\n")
0052 file.write(" h_emCorr_et->Draw(\"SAME\");\n")
0053 file.write(" TLine* line = new TLine(0,1,300,1);\n")
0054 file.write(" line->Draw();\n")
0055
0056 header ="""
0057
0058 TAxis* ax = h_em_et->GetXaxis();
0059 ax->SetTitle("Et (GeV)");
0060 TAxis* ay = h_em_et->GetYaxis();
0061 ay->SetTitle("E_{T}^{RECO}/E_{T}^{MC}");
0062 ay->SetRangeUser(0.9,1.05);
0063
0064 TLegend *leg = new TLegend(0.2, 0.2, 0.4, 0.4);
0065 leg->AddEntry(h_em_et, "Before correction");
0066 leg->AddEntry(h_emCorr_et, "After correction ");
0067 leg->Draw();
0068 TLine* line = new TLine(0,1,1.5,1);
0069 line->SetLineWidth(2);
0070 line->SetLineColor(2);
0071 line->Draw();
0072
0073 c1->Print("MeanVsET.ps");
0074 gROOT->ProcessLine(".q");
0075 """
0076 file.write(header)
0077
0078 file.write("}\n")