source: fact/tools/pyscripts/sandbox/vogler/CalFitsPerformanceWeave_3.py@ 17409

Last change on this file since 17409 was 14173, checked in by vogler, 12 years ago
inital filling of my sandbox
File size: 6.0 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
14#define filenames
15
16# 2012 04 17
17#calibfilename = '/fact/raw/2012/04/17/20120417_003.drs.fits.gz' # NROI 300, pedestal
18calibfilename = '/fact/raw/2012/04/17/20120417_033.drs.fits.gz' # NROI 300, pedestal
19
20#datafilename = '/fact/raw/2012/04/17/20120417_015.fits.gz' # NROI 300, LP_ext
21#datafilename = '/fact/raw/2012/04/17/20120417_021.fits.gz' # NROI 300, LP_ext
22#datafilename = '/fact/raw/2012/04/17/20120417_036.fits.gz' # NROI 300, LP_ext
23datafilename = '/fact/raw/2012/04/17/20120417_042.fits.gz' # NROI 300, LP_ext
24
25
26
27
28# 2012 01 25
29#datafilename = '/fact/raw/2012/01/25/20120125_042.fits.gz' # light-pulser-ext
30# = '/fact/raw/2012/01/25/20120125_095.fits.gz' # pedestal
31# = '/fact/raw/2012/01/25/20120125_094.fits.gz' # pedestal
32# = '/fact/raw/2012/01/25/20120125_093.fits.gz' # pedestal
33#datafilename = '/fact/raw/2012/01/25/20120125_075.fits.gz'
34#calibfilename = '/fact/raw/2012/01/25/20120125_088.drs.fits.gz'
35
36
37import numpy as np
38from scipy import weave
39from scipy.weave import converters
40
41from plotters import Plotter # ADC display
42#from plotters import CamPlotter # event display
43#from drs_spikes import DRSSpikes
44
45
46from ROOT import gSystem
47## gSystem.Load("calfits_h.so") # according to old naming scheme
48
49gSystem.Load("calfactfits_h.so") # according to new naming scheme
50
51from ROOT import *
52print "Testing object creation: "
53caltest = CalFactFits(datafilename, calibfilename)
54npcalevent = np.empty( caltest.npix * caltest.nroi, np.float64) #.reshape(caltest.npix ,caltest.nroi)
55caltest.SetNpcaldataPtr(npcalevent)
56
57
58numroi = np.int64(caltest.nroi)
59numpix = np.int64(caltest.npix)
60numevents = np.int64(caltest.nevents)
61
62
63
64print "Common variables run information: "
65print "ROI: ", numroi
66print "#Pix: ", numpix
67print "Number of events: ", numevents
68print
69
70
71event = np.zeros((numpix, numroi)) # create an array to store an event in the format numpix * numroi (2-dim array)
72print "Array event created"
73run_average = np.zeros((numpix, numroi)) # create an array to store the "average event" of a run
74print "Array run_average created"
75extracted_average = np.zeros(numpix)
76print "Array extracted_average created "
77data_average_run = np.zeros(numroi)
78print "Arrays created "
79
80
81
82#####################################################################################################################
83#print "creating plotters ..."
84
85#make a Plotter class ... this is an easy way for plotting ... but there are
86# many was to plot data ... without this class ... it was written for convenience, but there is no strong reason to use it...
87#myplotter = Plotter('titel of the plot', xlabel='time in slices', ylabel='amplitude calibrated data ... in mV')
88
89#myplotter2 = Plotter('titel of the plot', xlabel='time in slices', ylabel='amplitude calibrated data ... in mV')
90
91# make a CamPlotter class
92#mycamplotter = CamPlotter('titel of the plot', map_file_path = '../map_dn.txt', vmin=0, vmax=350) # for Lightpulser data
93#mycamplotter = CamPlotter('titel of the plot', map_file_path = '../map_dn.txt', vmin=-1.2, vmax=1.2) # for pedestal data
94
95#print "Plotters created "
96###################################################################################################################
97
98print "... looping..."
99
100while caltest.GetCalEvent(): # Loop ueber alle events
101 #print npcalevent ## Daten, Array 1 dim Laenge caltest.npix * caltest.nroi 1 Event
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
128
129print "Common variables run information: "
130print "ROI: ", numroi
131print "#Pix: ", numpix
132print "Number of events: ", numevents
133print
134
135
136
137#####################################################################################################################
138print "creating plotters ..."
139
140#make a Plotter class ... this is an easy way for plotting ... but there are
141# many was to plot data ... without this class ... it was written for convenience, but there is no strong reason to use it...
142myplotter = Plotter('titel of the plot', xlabel='time in slices', ylabel='amplitude calibrated data ... in mV')
143
144#myplotter2 = Plotter('titel of the plot', xlabel='time in slices', ylabel='amplitude calibrated data ... in mV')
145
146# make a CamPlotter class
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
150print "Plotters created "
151###################################################################################################################
152
153
154
155
156
157
158myplotter((run_average[22]) / numevents, 'pix 22, average' )
159
160#myplotter2( 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
164#mycamplotter( 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.