source: fact/tools/pyscripts/sandbox/vogler/CalFitsPerformanceWeave_5.py@ 14473

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