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 |
|
---|
10 | datafile = '/fact/raw/2012/06/08/20120608_009.fits.gz'
|
---|
11 | calibfile = '/fact/raw/2012/06/08/20120608_007.drs.fits.gz'
|
---|
12 | pixelnr = 0
|
---|
13 |
|
---|
14 | import numpy as np
|
---|
15 | from fileplotter import FilePlotter
|
---|
16 | import os
|
---|
17 |
|
---|
18 | datafilename = os.path.basename(datafile)
|
---|
19 | calibfilename = os.path.basename(calibfile)
|
---|
20 |
|
---|
21 | from ROOT import gSystem
|
---|
22 | gSystem.Load("calfactfits_h.so")
|
---|
23 | from ROOT import *
|
---|
24 | data = CalFactFits(datafile,calibfile)
|
---|
25 | npcalevent = np.empty( data.npix * data.nroi, np.float64) #.reshape(data.npix ,data.nroi)
|
---|
26 | data.SetNpcaldataPtr(npcalevent)
|
---|
27 | nroi = data.data_nroi
|
---|
28 |
|
---|
29 | gROOT.SetStyle("Plain")
|
---|
30 | #gStyle.SetOptTitle(0)
|
---|
31 | gStyle.SetOptStat(0)
|
---|
32 |
|
---|
33 | #Create a canvas with automatic save-function
|
---|
34 | #Note: most options of Fileplotter (legend, title etc. do not work here)
|
---|
35 | fp = FilePlotter(out_name="EventDisplay")
|
---|
36 | fp.canvas()
|
---|
37 |
|
---|
38 | title = "Data: %s, DRS: %s, Px %i Ev %i"%(datafile,calibfile,pixelnr,0)
|
---|
39 | pixProfile = TProfile("pix", title, nroi, -0.5, nroi-0.5)
|
---|
40 | pixProfile.GetXaxis().SetTitle("Slice @ 2 GHz")
|
---|
41 | pixProfile.GetYaxis().SetTitle("Amplitude (mV)")
|
---|
42 |
|
---|
43 | print "\nPress"
|
---|
44 | print "-ENTER to continue"
|
---|
45 | print "-'a' to abort"
|
---|
46 | print "-an integer to jump to this event"
|
---|
47 | print "-'s' to save and continue.\n"
|
---|
48 |
|
---|
49 | nextEvent = 0
|
---|
50 |
|
---|
51 | while 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 |
|
---|
85 | del fp,data
|
---|