~reg-hugonweb/webhep/trunk

« back to all changes in this revision

Viewing changes to wwwsrc/WebHEP.py

  • Committer: Justin Hugon
  • Date: 2012-04-09 09:19:50 UTC
  • Revision ID: justin_hugon-20120409091950-vx5g5su8dyj4cwi0
added more hists and cosmetic improvements.  can't get FlowPanel to 'flow'

Show diffs side-by-side

added added

removed removed

Lines of Context:
12
12
from pyjamas.ui.CheckBox import CheckBox
13
13
from pyjamas.ui.TextBox import TextBox
14
14
from pyjamas.ui.FlexTable import FlexTable
 
15
from pyjamas.ui.FlowPanel import FlowPanel
15
16
 
16
17
from pyjamas.Timer import Timer
17
18
from pyjamas.chart.GChart import GChart
201
202
 
202
203
class Histo(GChart):
203
204
    def __init__(self,xBinLowEdges,binContents,xlabel):
 
205
        #log.writebr("Log: Histo.__init__: Starting")
 
206
 
 
207
        histNameDict = {
 
208
                "ptMu1":"Leading Muon Pt (GeV)",
 
209
                "ptEl1":"Leading Electron Pt (GeV)",
 
210
                "ptPh1":"Leading Photon Pt (GeV)",
 
211
                "ptJet1":"Leading Jet Pt (GeV)",
 
212
                "histMet":"Missing Transverse Momentum (MET) (GeV)",
 
213
                "histHt":"Scalar Jet Energy Sum (HT) (GeV)",
 
214
                "histSt":"Scalar Physics Object Energy Sum (ST) (GeV)",
 
215
                "histM":"Invariant Mass of Visible Objects (GeV)",
 
216
                "histSmin":"Sqrt(Smin) (GeV)",
 
217
                "histMDiEl":"Di-Electron Invariant Mass (GeV)",
 
218
                "histMDiMu":"Di-Muon Invariant Mass (GeV)",
 
219
                "histMDiJet":"Di-Jet Invariant Mass (GeV)",
 
220
                "histMDiPh":"Di-Photon Invariant Mass (GeV)",
 
221
                }
 
222
 
204
223
        if len(xBinLowEdges)!=len(binContents):
205
224
          log.writebr("Error: Histo.__init__: x and y have different lengths")
206
225
          assert(len(xBinLowEdges)==len(binContents))
216
235
        self.getCurve().getSymbol().setBackgroundColor("red")
217
236
        self.getCurve().getSymbol().setBorderColor("black")
218
237
        self.getCurve().getSymbol().setModelWidth(width)
219
 
        self.getXAxis().setAxisLabel("<b>"+str(xlabel)+"</b>")
220
 
        self.getYAxis().setAxisLabel("<b>Events</b>")
 
238
 
 
239
        xAxisLabel = HTML(histNameDict[xlabel],StyleName="xlabel")
 
240
        yAxisLabel = HTML("Events",StyleName="ylabel")
 
241
        self.getXAxis().setAxisLabel(xAxisLabel)
 
242
        self.getYAxis().setAxisLabel(yAxisLabel)
 
243
 
 
244
        thickness = self.getYAxis().getTickLabelThickness()
 
245
        #log.writebr("Log: Histo.__init__: tick Label thickness: "+str(thickness))
 
246
        self.getYAxis().setTickLabelThickness(thickness/3.)
 
247
 
221
248
        self.getXAxis().setTickLabelFormat("#")
222
249
        self.getYAxis().setTickLabelFormat("#")
223
 
        #self.getXAxis().setTickLabelCount("11") not a fn?
224
 
        #self.getYAxis().setTickLabelCount("11")  not a fn?
225
250
        self.getXAxis().setTickCount(7)
226
251
        self.getYAxis().setTickCount(7)
227
252
        self.update()
281
306
        self.panel.setText(3,0,str(self.json))
282
307
 
283
308
    def plotsPage(self,jsondata):
284
 
        self.panel.clear()
285
 
        self.panel.setText(0,0,"WebHEP Results")
 
309
        #log.writebr("Log: plotsPage: Starting")
 
310
        self.remove(self.panel)
 
311
        self.clear()
 
312
        self.panel = VerticalPanel()
 
313
        self.plotsTitle = Label("WebHEP Results",StyleName="title")
 
314
        self.panel.add(self.plotsTitle)
 
315
        self.flowPanel = FlowPanel(Width="90%",StyleName="flow-panel")
286
316
 
287
317
        #log.writebr("logMessage: "+str(jsondata))
288
318
 
289
319
        self.histos = []
290
320
        for key in jsondata:
291
 
          log.writebr("logMessage: "+str(key))
 
321
          #log.writebr("logMessage: "+str(key))
292
322
          histInfo = jsondata[key]
293
323
          y = histInfo["y"]
294
324
          x = histInfo["x"]
296
326
          self.histos.append(Histo(x,y,key))
297
327
        
298
328
        for iPlot in range(len(self.histos)):
299
 
          self.panel.setWidget(iPlot+1,0,self.histos[iPlot])
300
 
        self.panel.setText(len(self.histos)+1,0,self.json)
 
329
          self.flowPanel.add(self.histos[iPlot])
 
330
 
 
331
        configLabel = Label(self.json)
 
332
        resultsLabel = Label(str(jsondata))
 
333
 
 
334
        self.panel.add(self.flowPanel)
 
335
        self.panel.add(configLabel)
 
336
        self.panel.add(resultsLabel)
 
337
        self.add(self.panel)
 
338
        #log.writebr("Log: plotsPage: Done")
301
339
 
302
340
    def onRemoteResponse(self, response, request_info):
 
341
        #log.writebr("Log: onRemoteResponse: Starting")
303
342
        self.plotsPage(json.loads(response))
304
 
        #outLabel = Label(response)
305
 
        #RootPanel().add(outLabel)
306
343
 
307
344
    def onRemoteError(self, code, errobj, request_info):
308
345
        self.clear()