source: fact/tools/pyscripts/sandbox/vogler/DRS_End_Noise_RMS_4.py@ 17548

Last change on this file since 17548 was 14173, checked in by vogler, 13 years ago
inital filling of my sandbox
  • Property svn:executable set to *
File size: 4.4 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
18#define filenames
19
20# 2011 12 05
21calibfilename = '/fact/raw/2012/06/01/20120601_013.drs.fits.gz' # NROI 300, pedestal
22
23datafilename = '/fact/raw/2012/06/01/20120601_017.fits.gz' # NROI 300, 5 minutes physics data with
24
25
26import numpy as np
27from scipy import weave
28from scipy.weave import converters
29
30from plotters import Plotter # ADC display
31# from plotters import CamPlotter # event display
32#from drs_spikes import DRSSpikes
33
34
35caltest = CalFactFits(datafilename, calibfilename)
36npcalevent = np.empty( caltest.npix * caltest.nroi, np.float64) #.reshape(caltest.npix ,caltest.nroi)
37caltest.SetNpcaldataPtr(npcalevent)
38
39
40numroi = np.int64(caltest.nroi)
41numpix = np.int64(caltest.npix)
42numevents = np.int64(caltest.nevents)
43
44num_LP_ev = 0 # number of ext Lightpulser events
45
46
47print "Common variables run information: "
48print "ROI: ", numroi
49print "#Pix: ", numpix
50print "Number of events: ", numevents
51print
52
53
54event = np.zeros((numpix, numroi)) # create an array to store an event in the format numpix * numroi (2-dim array)
55
56data_average_run = np.zeros(numroi)
57over_thresh = np.zeros(numpix) # count for every pixel how many times first slice over 50mV
58
59run_rms = np.zeros((numpix, numroi)) # rms
60
61
62
63print "... looping..."
64
65while caltest.GetCalEvent(): # Loop ueber alle events
66
67
68 if (caltest.event_triggertype == 4): #ext LP event
69 print 'event id:', caltest.event_id, ' Trigger Type:', caltest.event_triggertype
70 num_LP_ev = num_LP_ev + 1
71 event = np.reshape(npcalevent, (numpix, -1)) # bring the event the shape numpix * numroi (2-dim array)
72
73 for j in range (0, (numpix - 1)):
74 if ((event[j,0] >50)and((j!=863)and(j!=297)and(j!=868))): #exclude crazy pixel (hard ID)
75 over_thresh[j]=over_thresh[j]+1
76 run_rms[j, : ]=run_rms[j, : ] + (event[j, : ])**2
77
78
79for k in range (0, (numpix - 1)):
80 run_rms[k, : ]=run_rms[k, : ]/over_thresh[k]
81run_rms = np.sqrt(run_rms)
82
83for i in range (0, (numpix - 1) ):
84 data_average_run = data_average_run + run_rms[i]**2
85
86data_average_run = data_average_run/numpix
87data_average_run = np.sqrt(data_average_run)
88
89maxindex = over_thresh.argmax()
90
91del caltest
92print "caltest deleted "
93
94print "Common variables run information: "
95print "ROI: ", numroi
96print "#Pix: ", numpix
97print "Number of events: ", numevents
98print "Number of external Lightpulser events: ", num_LP_ev
99print
100
101
102
103#####################################################################################################################
104print "creating plotters ..."
105
106#make a Plotter class ... this is an easy way for plotting ... but there are
107# many was to plot data ... without this class ... it was written for convenience, but there is no strong reason to use it...
108#myplotter = Plotter('titel of the plot', xlabel='time in slices', ylabel='amplitude calibrated data ... in mV')
109
110myplotter = Plotter('titel of the plot', xlabel='time in slices', ylabel='amplitude calibrated data ... in mV')
111myplotter2 = Plotter('titel of the plot', xlabel='time in slices', ylabel='amplitude calibrated data ... in mV')
112myplotter3 = Plotter('titel of the plot', xlabel='time in slices', ylabel='amplitude calibrated data ... in mV')
113myplotter4 = Plotter('titel of the plot', xlabel='time in slices', ylabel='amplitude calibrated data ... in mV')
114
115over_th_plotter = Plotter('first slice ofer 50mv', xlabel='pixel number', ylabel='number of times first slice over 50mV')
116
117print "Plotters created "
118###################################################################################################################
119
120myplotter(run_rms[20], 'pix 20 rms' )
121myplotter2(run_rms[21], 'pix 21 rms' )
122myplotter3(run_rms[maxindex], 'rms: pixel most times over 50mV')
123
124print "Pix number (HW ID) most times over 50mV ", maxindex
125
126over_th_plotter(over_thresh, 'run 20111205_022')
127
128
129myplotter4(data_average_run , 'RMS (all pixel) over the whole run' )
130
131
132answer = raw_input('type "quit" to quit ')
133while not 'quit' in answer:
134 answer = raw_input('type "quit" to quit ')
135
Note: See TracBrowser for help on using the repository browser.