Changeset 13416 for fact/tools/pyscripts


Ignore:
Timestamp:
04/23/12 14:15:38 (13 years ago)
Author:
kraehenb
Message:
Pointer version of the CalFits class (faster data access).
Location:
fact/tools/pyscripts/sandbox/kraehenb
Files:
2 edited

Legend:

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

    r13401 r13416  
    1111calibfilename = '/fact/raw/2012/04/17/20120417_003.drs.fits.gz'
    1212
     13import numpy as np
     14
    1315from ROOT import gSystem
    1416gSystem.Load("calfits_h.so")
     
    1618print "Testing object creation: "
    1719caltest = CalFits(datafilename,calibfilename)
     20npcalevent  = np.empty( caltest.npix * caltest.nroi, np.float64) #.reshape(caltest.npix ,caltest.nroi)
     21caltest.SetNpcaldataPtr(npcalevent)
    1822
    1923print "Common variables:"
     
    4549
    4650#while caltest.GetCalEvent():
    47 #    print caltest.event_id, caltest.event_triggertype, caltest.event_caldata[0]
     51#    if caltest.event_id>10:
     52#        break
     53#    print caltest.event_id, caltest.event_triggertype, caltest.event_caldata[10]
    4854#print
    4955
  • fact/tools/pyscripts/sandbox/kraehenb/calfits.h

    r13400 r13416  
    7878        vector<int32_t> event_boardtimes;
    7979        vector<float> event_caldata; //Vector for calibrated event
     80        double* npcaldata;
    8081       
    8182        CalFits(const string &datafilename, const string &calibfilename) //Constructor with two filenames
    8283                : datafile(datafilename),
    83                         calibfile(calibfilename)
     84                        calibfile(calibfilename),
     85                        npcaldata(NULL)
    8486        {
    8587                //Read basic parameters of the two files
     
    124126                calibfile.GetRow(0);
    125127               
    126                 //Get the column sizes per pixel
    127                 //...
    128                
    129128                //Set the event pointers
    130129//              std::cout << "...Setting event pointers..." << std::endl;
     
    145144        bool GetCalEvent()
    146145        {
     146                if(!npcaldata) {
     147                        ostringstream str;
     148                        str << "Pointer to the calibrated data not initialized!";
     149#ifdef __EXCEPTIONS
     150                        throw runtime_error(str.str());
     151#else
     152                        gLog << ___err___ << "ERROR - " << str.str() << endl;
     153                        return false;
     154#endif
     155                }
    147156                if(datafile.GetNextRow() == false) {
    148157//                      std::cout << "Last event reached..." << std::endl;
     
    154163                                for(UInt_t slice=0;slice<data_nroi;slice++) {
    155164                                        drs_calib_offset = (slice+event_offset[pixel])%calib_blm_size;
    156                                         event_caldata[pixel*data_nroi+slice] = float((event_data[pixel*data_nroi+slice]*2000./4096.-calib_baselinemean[pixel*calib_blm_size+drs_calib_offset]-calib_triggeroffsetmean[pixel*data_nroi+slice])/calib_gainmean[pixel*calib_blm_size+drs_calib_offset]*1907.35);
     165                                        npcaldata[pixel*data_nroi+slice] = double((event_data[pixel*data_nroi+slice]*2000./4096.-calib_baselinemean[pixel*calib_blm_size+drs_calib_offset]-calib_triggeroffsetmean[pixel*data_nroi+slice])/calib_gainmean[pixel*calib_blm_size+drs_calib_offset]*1907.35);
     166//                                      event_caldata[pixel*data_nroi+slice] = float((event_data[pixel*data_nroi+slice]*2000./4096.-calib_baselinemean[pixel*calib_blm_size+drs_calib_offset]-calib_triggeroffsetmean[pixel*data_nroi+slice])/calib_gainmean[pixel*calib_blm_size+drs_calib_offset]*1907.35);
    157167                                        //Note: data_nroi=calib_nroi, calib_blm_size=calib_gm_size
    158168                                }
     
    161171                return true;
    162172        }
     173       
     174        void SetNpcaldataPtr(double *ptr)
     175        {
     176                npcaldata = ptr;
     177                return;
     178        }
    163179};
    164180#endif
Note: See TracChangeset for help on using the changeset viewer.