source: fact/tools/pyscripts/sandbox/vogler/CalFitsPerformanceWeave_4.py@ 14962

Last change on this file since 14962 was 14173, checked in by vogler, 12 years ago
inital filling of my sandbox
  • Property svn:executable set to *
File size: 6.1 KB
Line 
1#!/usr/bin/python -tt
2# ********************************
3# Test script for the CalFits class
4#
5# written by Thomas Kraehenbuehl, ETH Zurich
6# tpk@phys.ethz.ch, +41 44 633 3973
7# April 2012
8# ********************************
9#
10# modified and adapted py Patrick Vogler
11#
12# ################################
13from ROOT import gSystem
14gSystem.Load("calfactfits_h.so") # according to new naming scheme
15from ROOT import *
16
17#define filenames
18
19# 2012 04 17
20#calibfilename = '/fact/raw/2012/04/17/20120417_003.drs.fits.gz' # NROI 300, pedestal
21calibfilename = '/fact/raw/2012/04/17/20120417_033.drs.fits.gz' # NROI 300, pedestal
22
23#datafilename = '/fact/raw/2012/04/17/20120417_015.fits.gz' # NROI 300, LP_ext
24#datafilename = '/fact/raw/2012/04/17/20120417_021.fits.gz' # NROI 300, LP_ext
25#datafilename = '/fact/raw/2012/04/17/20120417_036.fits.gz' # NROI 300, LP_ext
26datafilename = '/fact/raw/2012/04/17/20120417_042.fits.gz' # NROI 300, LP_ext
27
28
29
30
31# 2012 01 25
32#datafilename = '/fact/raw/2012/01/25/20120125_042.fits.gz' # light-pulser-ext
33# = '/fact/raw/2012/01/25/20120125_095.fits.gz' # pedestal
34# = '/fact/raw/2012/01/25/20120125_094.fits.gz' # pedestal
35# = '/fact/raw/2012/01/25/20120125_093.fits.gz' # pedestal
36#datafilename = '/fact/raw/2012/01/25/20120125_075.fits.gz'
37#calibfilename = '/fact/raw/2012/01/25/20120125_088.drs.fits.gz'
38
39
40import numpy as np
41from scipy import weave
42from scipy.weave import converters
43
44from plotters import Plotter # ADC display
45from plotters import CamPlotter # event display
46#from drs_spikes import DRSSpikes
47
48
49print "Testing object creation: "
50caltest = CalFactFits(datafilename, calibfilename)
51npcalevent = np.empty( caltest.npix * caltest.nroi, np.float64) #.reshape(caltest.npix ,caltest.nroi)
52caltest.SetNpcaldataPtr(npcalevent)
53
54
55numroi = np.int64(caltest.nroi)
56numpix = np.int64(caltest.npix)
57numevents = np.int64(caltest.nevents)
58
59
60
61print "Common variables run information: "
62print "ROI: ", numroi
63print "#Pix: ", numpix
64print "Number of events: ", numevents
65print
66
67
68event = np.zeros((numpix, numroi)) # create an array to store an event in the format numpix * numroi (2-dim array)
69print "Array event created"
70run_average = np.zeros((numpix, numroi)) # create an array to store the "average event" of a run
71print "Array run_average created"
72extracted_average = np.zeros(numpix)
73print "Array extracted_average created "
74data_average_run = np.zeros(numroi)
75print "Arrays created "
76
77
78
79#####################################################################################################################
80#print "creating plotters ..."
81
82#make a Plotter class ... this is an easy way for plotting ... but there are
83# many was to plot data ... without this class ... it was written for convenience, but there is no strong reason to use it...
84#myplotter = Plotter('titel of the plot', xlabel='time in slices', ylabel='amplitude calibrated data ... in mV')
85
86#myplotter2 = Plotter('titel of the plot', xlabel='time in slices', ylabel='amplitude calibrated data ... in mV')
87
88# make a CamPlotter class
89#mycamplotter = CamPlotter('titel of the plot', map_file_path = '../map_dn.txt', vmin=0, vmax=350) # for Lightpulser data
90#mycamplotter = CamPlotter('titel of the plot', map_file_path = '../map_dn.txt', vmin=-1.2, vmax=1.2) # for pedestal data
91
92#print "Plotters created "
93###################################################################################################################
94
95print "... looping..."
96
97while caltest.GetCalEvent(): # Loop ueber alle events
98 #print npcalevent ## Daten, Array 1 dim Laenge caltest.npix * caltest.nroi 1 Event
99 event = np.reshape(npcalevent, (numpix, -1)) # bring the event the shape numpix * numroi (2-dim array)
100
101 run_average += event
102
103 # A first test of Adrians idea of primitive signal extractor
104 # signal and background
105 extracted_signal = np.zeros(numpix)
106 for signalslice in range(90, 100):
107 extracted_signal += event[0:(numpix), signalslice]
108 # background subtraction
109 for backgroundslice in range(15, 25):
110 extracted_signal -= event[0:(numpix), backgroundslice]
111 extracted_average += extracted_signal
112
113print "Looped ... "
114
115for i in range (0, (numpix - 1) ):
116 data_average_run += run_average[i]
117
118
119print "Looped second loop "
120
121del caltest
122print "caltest deleted "
123
124
125
126print "Common variables run information: "
127print "ROI: ", numroi
128print "#Pix: ", numpix
129print "Number of events: ", numevents
130print
131
132
133
134#####################################################################################################################
135print "creating plotters ..."
136
137#make a Plotter class ... this is an easy way for plotting ... but there are
138# many was to plot data ... without this class ... it was written for convenience, but there is no strong reason to use it...
139myplotter = Plotter('titel of the plot', xlabel='time in slices', ylabel='amplitude calibrated data ... in mV')
140
141myplotter2 = Plotter('titel of the plot', xlabel='time in slices', ylabel='amplitude calibrated data ... in mV')
142
143# make a CamPlotter class
144mycamplotter = CamPlotter('titel of the plot', map_file_path = 'map_dn.txt', vmin=0, vmax=350) # for Lightpulser data
145#mycamplotter = CamPlotter('titel of the plot', map_file_path = '../map_dn.txt', vmin=0, vmax=350) # for Lightpulser data
146#mycamplotter = CamPlotter('titel of the plot', map_file_path = '../map_dn.txt', vmin=-1.2, vmax=1.2) # for pedestal data
147#mycamplotter = CamPlotter('titel of the plot', map_file_path = 'map_dn.txt', vmin=-2, vmax=2) # for pedestal data
148
149
150print "Plotters created "
151###################################################################################################################
152
153
154
155
156
157
158myplotter((run_average[22]) / numevents, 'pix 22, average' )
159
160myplotter2( data_average_run / (numpix * numevents) , 'average signal (all pixel) over the whole run' )
161
162
163#mycamplotter( data[0:1443, 100] ) # plot slice 100 of all pixel
164mycamplotter( extracted_average / (10 * numevents) ) # plot the extracted signal of all pixel
165
166answer = raw_input('type "quit" to quit ')
167while not 'quit' in answer:
168 answer = raw_input('type "quit" to quit ')
169
170
171
172
173del caltest
174print "caltest deleted "
Note: See TracBrowser for help on using the repository browser.