Ignore:
Timestamp:
04/18/12 21:03:22 (13 years ago)
Author:
neise
Message:
DRS amplitude cal optimized. At least I don't see more potential
File:
1 edited

Legend:

Unmodified
Added
Removed
  • fact/tools/pyscripts/pyfact/pyfact.py

    r13383 r13384  
    167167        self.calib_file = calib_file
    168168       
    169         baseline_mean = calib_file.GetN('BaselineMean')
    170         gain_mean = calib_file.GetN('GainMean')
     169        baseline_mean       = calib_file.GetN('BaselineMean')
     170        gain_mean           = calib_file.GetN('GainMean')
    171171        trigger_offset_mean = calib_file.GetN('TriggerOffsetMean')
    172172
    173         self.blm = np.zeros(baseline_mean, np.float32).reshape(self.npix , baseline_mean/self.npix)
    174         self.gm  = np.zeros(gain_mean, np.float32).reshape(self.npix , gain_mean/self.npix)
    175         self.tom = np.zeros(trigger_offset_mean, np.float32).reshape(self.npix , trigger_offset_mean/self.npix)
    176 
    177         self.Nblm = baseline_mean / self.npix
    178         self.Ngm  = gain_mean / self.npix
     173        self.Nblm  = baseline_mean       / self.npix
     174        self.Ngm   = gain_mean           / self.npix
    179175        self.Ntom  = trigger_offset_mean / self.npix
     176
     177        self.blm = np.zeros(baseline_mean, np.float32).reshape(self.npix , self.Nblm)
     178        self.gm  = np.zeros(gain_mean, np.float32).reshape(self.npix , self.Ngm)
     179        self.tom = np.zeros(trigger_offset_mean, np.float32).reshape(self.npix , self.Ntom)
    180180
    181181        calib_file.SetPtrAddress('BaselineMean', self.blm)
     
    201201    def next(self):
    202202        """ used by __iter__ """
    203 
    204203        if self.data_file.GetNextRow() == False:
    205204            raise StopIteration
     
    211210        if self.return_dict:
    212211            return self.__dict__
    213             else:
     212        else:
    214213            return self.acal_data, self.start_cells, self.trigger_type.value
    215214
    216215    def next_event(self):
    217216        """ load the next event from disk and calibrate it
    218        
    219         """
    220 
     217        """
    221218        self.data_file.GetNextRow()
    222219        self.calibrate_drs_amplitude()
     
    226223       
    227224        """
     225        # shortcuts
    228226        blm = self.blm
    229         gm = self.gm
     227        gm  = self.gm
    230228        tom = self.tom
    231229       
     
    234232        acal_data = self.data * to_mV  # convert ADC counts to mV
    235233
    236         # make 2D arrays: row = pixel, col = drs_slice
    237         #acal_data = np.reshape(acal_data, (self.npix, self.nroi) )
    238         #blm = np.reshape(self.blm, (self.npix, self.Nblm) )
    239         #tom = np.reshape(self.tom, (self.npix, self.Ntom) )
    240         #gm  = np.reshape(self.gm,  (self.npix, self.Ngm) )
    241        
    242         # double the calibration constants
    243         blm = np.hstack((blm,blm))
    244         gm = np.hstack((gm,gm))
    245234       
    246235        for pixel in range( self.npix ):
     
    249238            roi = self.nroi
    250239            # rotate the pixel baseline mean to the Data startCell
    251             #blm_pixel = blm[pixel,sc:sc+roi]
    252             # rotate the pixel gain mean to the Data startCell
    253             #gm_pixel = gm[pixel,sc:sc+roi]
     240            acal_data[pixel,:] -= blm[pixel,sc:sc+roi]
    254241            # the 'trigger offset mean' does not need to be rolled
    255242            # on the contrary, it seems there is an offset in the DRS data,
    256243            # which is related to its distance to the startCell, not to its
    257244            # distance to the beginning of the physical pipeline in the DRS chip
    258             #tom_pixel = tom[pixel,0:roi]
    259            
    260             #acal_data[pixel,:] -= blm_pixel
    261             #acal_data[pixel,:] -= tom_pixel
    262             #acal_data[pixel,:] /= gm_pixel
    263             acal_data[pixel,:] -= blm[pixel,sc:sc+roi]
    264245            acal_data[pixel,:] -= tom[pixel,0:roi]
     246            # rotate the pixel gain mean to the Data startCell
    265247            acal_data[pixel,:] /= gm[pixel,sc:sc+roi]
    266248           
     249           
    267250        self.acal_data = acal_data * 1907.35
    268251       
    269         #print 'blm _pyfact', blm[0,0:20]
    270         #t = np.roll( blm[0,:], -self.start_cells[0] )
    271         #print 'blm _pyfact', t[0:20]
    272         #print 'start_pyfact: ', self.start_cells[0]
    273         #print 'acal _pyfact: ', self.acal_data[0,0:10]
    274         #t = np.roll( gm[0,:], -self.start_cells[0] )
    275         #print 'gm _pyfact: ', t[0:10]
    276         #self.user_action_calib( self.acal_data,
    277         #    np.reshape(self.data, (self.npix, self.nroi) ), blm, tom, gm, self.start_cells, self.nroi)
     252        self.user_action_calib( self.acal_data,
     253            np.reshape(self.data, (self.npix, self.nroi) ), blm, tom, gm, self.start_cells, self.nroi)
    278254
    279255       
Note: See TracChangeset for help on using the changeset viewer.