source: fact/tools/pyscripts/sandbox/kraehenb/plotevents.py@ 15446

Last change on this file since 15446 was 14410, checked in by kraehenb, 12 years ago
plotevents.py is python script which really reads and plots the events. fileplotter is a class necessary for it.
  • Property svn:executable set to *
File size: 2.1 KB
Line 
1#!/usr/bin/python -tt
2# ********************************
3# Plot the calibrated events of a file
4#
5# written by Thomas Kraehenbuehl, ETH Zurich
6# tpk@phys.ethz.ch, +41 44 633 3973
7# September 2012
8# ********************************
9
10datafile = '/fact/raw/2012/06/08/20120608_009.fits.gz'
11calibfile = '/fact/raw/2012/06/08/20120608_007.drs.fits.gz'
12pixelnr = 0
13
14import numpy as np
15from fileplotter import FilePlotter
16import os
17
18datafilename = os.path.basename(datafile)
19calibfilename = os.path.basename(calibfile)
20
21from ROOT import gSystem
22gSystem.Load("calfactfits_h.so")
23from ROOT import *
24data = CalFactFits(datafile,calibfile)
25npcalevent = np.empty( data.npix * data.nroi, np.float64) #.reshape(data.npix ,data.nroi)
26data.SetNpcaldataPtr(npcalevent)
27nroi = data.data_nroi
28
29gROOT.SetStyle("Plain")
30#gStyle.SetOptTitle(0)
31gStyle.SetOptStat(0)
32
33#Create a canvas with automatic save-function
34#Note: most options of Fileplotter (legend, title etc. do not work here)
35fp = FilePlotter(out_name="EventDisplay")
36fp.canvas()
37
38title = "Data: %s, DRS: %s, Px %i Ev %i"%(datafile,calibfile,pixelnr,0)
39pixProfile = TProfile("pix", title, nroi, -0.5, nroi-0.5)
40pixProfile.GetXaxis().SetTitle("Slice @ 2 GHz")
41pixProfile.GetYaxis().SetTitle("Amplitude (mV)")
42
43print "\nPress"
44print "-ENTER to continue"
45print "-'a' to abort"
46print "-an integer to jump to this event"
47print "-'s' to save and continue.\n"
48
49nextEvent = 0
50
51while data.GetCalEvent():
52 if nextEvent>data.event_id:
53 continue
54
55 print data.event_id, hex(data.event_triggertype),
56
57 pixProfile.Reset()
58 title = "Data: %s, DRS: %s, ContHardID %i Ev %i"%(datafilename,calibfilename,pixelnr,data.event_id)
59 pixProfile.SetTitle(title)
60
61 for k in range(3,nroi):
62 pixProfile.Fill(k,npcalevent[pixelnr*nroi+k]);
63
64 pixProfile.Draw()
65 fp.canv.Modified()
66 fp.canv.Update()
67
68 try:
69 temp = raw_input()
70 except Exception, err:
71 print "Caught exception:", err
72 except KeyboardInterrupt, err:
73 print "Caught keyboard interrupt"
74
75 try:
76 nextEvent = int(temp)
77 except ValueError, err:
78 nextEvent = 0
79
80 if temp=='s':
81 fp.save()
82
83 if temp=='a': break
84
85del fp,data
Note: See TracBrowser for help on using the repository browser.