#!/usr/bin/python -tt # ******************************** # Test script for the CalFits class # # written by Thomas Kraehenbuehl, ETH Zurich # tpk@phys.ethz.ch, +41 44 633 3973 # April 2012 # ******************************** # # modified and adapted py Patrick Vogler # # ################################ from ROOT import gSystem gSystem.Load("calfactfits_h.so") # according to new naming scheme from ROOT import * #define filenames # 2011 12 05 calibfilename = '/fact/raw/2011/12/05/20111205_011.drs.fits.gz' # NROI 300, pedestal datafilename = '/fact/raw/2011/12/05/20111205_022.fits.gz' # NROI 300, 5 minutes physics data with import numpy as np from scipy import weave from scipy.weave import converters from plotters import Plotter # ADC display # from plotters import CamPlotter # event display #from drs_spikes import DRSSpikes print "Testing object creation: " caltest = CalFactFits(datafilename, calibfilename) npcalevent = np.empty( caltest.npix * caltest.nroi, np.float64) #.reshape(caltest.npix ,caltest.nroi) caltest.SetNpcaldataPtr(npcalevent) numroi = np.int64(caltest.nroi) numpix = np.int64(caltest.npix) numevents = np.int64(caltest.nevents) num_LP_ev = 0 # number of ext Lightpulser events num_ped = 0 # number of pedestal events print "Common variables run information: " print "ROI: ", numroi print "#Pix: ", numpix print "Number of events: ", numevents print event = np.zeros((numpix, numroi)) # create an array to store an event in the format numpix * numroi (2-dim array) print "Array event created" run_average = np.zeros((numpix, numroi)) # create an array to store the "average event" of a run data_average_run = np.zeros(numroi) print "Arrays created " print "... looping..." while caltest.GetCalEvent(): # Loop ueber alle events # print npcalevent ## Daten, Array 1 dim Laenge caltest.npix * caltest.nroi 1 Event if (caltest.event_triggertype == 4): #ext LP event print 'event id:', caltest.event_id, ' Trigger Type:', caltest.event_triggertype num_LP_ev = num_LP_ev + 1 event = np.reshape(npcalevent, (numpix, -1)) # bring the event the shape numpix * numroi (2-dim array) run_average += event print "Looped ... " #for i in range (0, (numpix - 1) ): # data_average_run += run_average[i] #print "Looped second loop " del caltest print "caltest deleted " print "Common variables run information: " print "ROI: ", numroi print "#Pix: ", numpix print "Number of events: ", numevents print "Number of external Lightpulser events: ", num_LP_ev print "Number of pedestal: ", num_ped print ##################################################################################################################### print "creating plotters ..." #make a Plotter class ... this is an easy way for plotting ... but there are # many was to plot data ... without this class ... it was written for convenience, but there is no strong reason to use it... #myplotter = Plotter('titel of the plot', xlabel='time in slices', ylabel='amplitude calibrated data ... in mV') myplotter = Plotter('titel of the plot', xlabel='time in slices', ylabel='amplitude calibrated data ... in mV') myplotter2 = Plotter('titel of the plot', xlabel='time in slices', ylabel='amplitude calibrated data ... in mV') myplotter3 = Plotter('titel of the plot', xlabel='time in slices', ylabel='amplitude calibrated data ... in mV') myplotter4 = Plotter('titel of the plot', xlabel='time in slices', ylabel='amplitude calibrated data ... in mV') print "Plotters created " ################################################################################################################### myplotter((run_average[20]) / num_LP_ev, 'pix 20, average' ) myplotter2((run_average[21]) / num_LP_ev, 'pix 21, average' ) myplotter3((run_average[22]) / num_LP_ev, 'pix 22, average' ) myplotter4( data_average_run / (numpix * num_LP_ev) , 'average signal (all pixel) over the whole run' ) answer = raw_input('type "quit" to quit ') while not 'quit' in answer: answer = raw_input('type "quit" to quit ')