00021 :
00022
00023 import time
00024 import sys
00025 import ROOT
00026
00027
00028
00029 data=[]
00030
00031
00032 logfile=open(logfile_name,'r')
00033 logfile_lines=logfile.readlines()
00034 logfile.close()
00035
00036
00037 i=0
00038 while i < len(logfile_lines):
00039 line=logfile_lines[i]
00040 if 'TimeEvent>' in line:
00041 line=line[:-1]
00042 line_content_list=line.split(' ')
00043 event_number=int(line_content_list[1])
00044 seconds=float(line_content_list[3])
00045 data.append((event_number,seconds))
00046 i+=1
00047
00048
00049
00050
00051 __argv=sys.argv
00052 sys.argv=sys.argv[:1]
00053 ROOT.gROOT.SetStyle("Plain")
00054 sys.argv=__argv
00055
00056
00057
00058 ROOT.gROOT.SetBatch(1)
00059
00060
00061 rootfilename='%s/graphs.root' %outdir
00062 myfile=ROOT.TFile(rootfilename,'RECREATE')
00063
00064
00065
00066 min_val=get_min(data,1)
00067 max_val=get_max(data,1)
00068 interval=max_val-min_val
00069
00070 min_val=min_val-interval*0.2
00071 max_val=max_val+interval*0.2
00072 interval=max_val-min_val
00073
00074 nbins=int(interval/secsperbin)
00075
00076 print 'Minval=',min_val,' maxval=',max_val, ' interval=',interval
00077
00078 histo=ROOT.TH1F('Seconds per event','Seconds per event',nbins,min_val,max_val)
00079 histo.GetXaxis().SetTitle("s")
00080
00081 npoints=len(data)
00082
00083 graph=ROOT.TGraph(npoints)
00084 graph.SetMarkerStyle(8)
00085 graph.SetMarkerSize(.7)
00086 graph.SetMarkerColor(1)
00087 graph.SetLineWidth(3)
00088 graph.SetLineColor(2)
00089 graph.SetTitle('Seconds per event')
00090 graph.SetName('SecondsPerEvent')
00091 graph.GetXaxis().SetTitle("Event")
00092
00093 last_event=data[-1][0]
00094 print 'last event =',last_event
00095 graph.GetXaxis().SetLimits(0,last_event)
00096
00097 graph.GetYaxis().SetTitleOffset(1.3)
00098 graph.GetYaxis().SetTitle("s")
00099 graph.GetYaxis().SetRangeUser(0,max_val)
00100
00101
00102
00103
00104
00105 evt_counter=0
00106 total=0
00107 for evt_num,secs in data:
00108 graph.SetPoint(evt_counter,evt_num,secs)
00109 histo.Fill(secs)
00110 total+=secs
00111 evt_counter+=1
00112
00113 print 'Total Time=', total
00114
00115
00116 avg=histo.GetMean()
00117 avg_line=ROOT.TLine(1,avg,last_event,avg)
00118 avg_line.SetLineColor(4)
00119 avg_line.SetLineWidth(2)
00120
00121
00122 graph_canvas=ROOT.TCanvas('graph_canvas')
00123 graph_canvas.cd()
00124 graph.Draw("ALP")
00125 avg_line.Draw("Same")
00126
00127 graph_canvas.Print("%s/graph.gif" %outdir,"gif")
00128
00129
00130 graph.Write()
00131 graph_canvas.Write()
00132
00133 histo_canvas=ROOT.TCanvas('histo_canvas')
00134 histo_canvas.cd()
00135 histo.Draw('')
00136
00137 histo_canvas.Print("%s/histo.gif" %outdir,"gif")
00138
00139
00140 histo.Write()
00141 histo_canvas.Write()
00142
00143 myfile.Close()
00144
00145
00146
00147 titlestring='<b>Report executed with release %s on %s.</b>\n<br>\n<hr>\n'\
00148 %(os.environ['CMSSW_VERSION'],time.asctime())
00149
00150 html_file_name='%s/%s.html' %(outdir,logfile_name[:-4])
00151 html_file=open(html_file_name,'w')
00152 html_file.write('<html>\n<body>\n'+\
00153 titlestring)
00154 html_file.write('<table>\n'+\
00155 '<tr><td><img src=graph.gif></img></td></tr>'+\
00156 '<tr><td><img src=histo.gif></img></td></tr>'+\
00157 '</table>\n')
00158 html_file.write('\n</body>\n</html>')
00159 html_file.close()
00160