source: fact/tools/pyscripts/sandbox/vogler/CalFitsPerformanceWeave_2.py@ 17893

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