Ignore:
Timestamp:
04/20/12 14:41:09 (13 years ago)
Author:
kraehenb
Message:
Completed the fast implementation to read calibrated data: calfits.h, CalFitsTest.py.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • fact/tools/pyscripts/sandbox/kraehenb/CalFitsTest.py

    r13397 r13400  
     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
    110datafilename = '/fact/raw/2012/04/17/20120417_004.fits.gz'
    211calibfilename = '/fact/raw/2012/04/17/20120417_003.drs.fits.gz'
    3 #data_filename =  '/fact/raw/2012/01/31/20120131_018.fits.gz'
    4 #calib_filename = '/fact/raw/2012/01/31/20120131_014.drs.fits.gz'
    512
    6 DoCalFits=True
     13from ROOT import gSystem
     14gSystem.Load("calfits_h.so")
     15from ROOT import *
     16print "Testing object creation: "
     17caltest = CalFits(datafilename,calibfilename)
    718
    8 if DoCalFits:
    9         from ROOT import gSystem
    10         gSystem.Load("CalFits_h.so")
    11         from ROOT import *
    12         print "Testing object creation: "
    13         caltest = CalFits(datafilename,calibfilename)
    14         print "Testing the python access to the function: "
    15         print caltest.data_npix
     19print "Common variables:"
     20print "ROI: ", caltest.nroi
     21print "#Pix: ", caltest.npix
     22print "Number of events: ", caltest.nevents
     23print
    1624
    17         print "Calibfile ROI: ", caltest.calib_nroi
    18         print "BaselineMean: ", caltest.calibfile.GetN("BaselineMean")
    19         print "GainMean: ", caltest.calibfile.GetN("GainMean")
    20         print "TriggerOffsetMean: ", caltest.calibfile.GetN("TriggerOffsetMean")
    21         print "Datafile ROI: ", caltest.data_nroi
    22         print "Data: ", caltest.datafile.GetN("Data")
    23         print "StartCellData: ", caltest.datafile.GetN("StartCellData")
    24         print "Direct datafile access: ", caltest.datafile.GetN("StartCellData")
     25print "Information per Event:"
     26caltest.GetCalEvent()
     27print "Event ID: ", caltest.event_id
     28print "Trigger type: ", caltest.event_triggertype
     29print "Uncalibrated data: ", caltest.event_data
     30print "Calibrated data: ", caltest.event_caldata
     31print "Board times: ", caltest.event_boardtimes
     32print "Trigger offsets: ", caltest.event_offset
     33print
    2534
    26 #       print caltest.GetCalEvent()
    27         for i in range(1000):
    28                 caltest.GetCalEvent()
    29                 print caltest.data_eventid
    30         print
     35print "Examples of other information"
     36print "Calibfile ROI: ", caltest.calib_nroi
     37print "Column size BaselineMean: ", caltest.calibfile.GetN("BaselineMean")
     38print "Datafile ROI: ", caltest.data_nroi
     39print "Data: ", caltest.datafile.GetN("Data")
     40print "StartCellData: ", caltest.datafile.GetN("StartCellData")
     41print "Direct datafile access: ", caltest.datafile.GetN("StartCellData")
     42print
     43print "Columns of the datafile: "
     44caltest.datafile.PrintColumns()
    3145
    32         del caltest
     46while caltest.GetCalEvent():
     47    print caltest.event_id, caltest.event_triggertype, caltest.event_caldata[0]
     48print
    3349
    34 else:
    35         from pyfact import RawData
    36         pyfacttest = RawData(datafilename, calibfilename, return_dict = True)
    37         for i,event in enumerate(pyfacttest):
    38                 if i>0:
    39                         break
    40                 print event['acal_data'][0][0:5]
     50del caltest
Note: See TracChangeset for help on using the changeset viewer.