Ignore:
Timestamp:
02/16/12 21:07:48 (13 years ago)
Author:
lusterma
Message:
corrections to pyfact coding style
File:
1 edited

Legend:

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

    r12895 r12896  
    113113        self.maxAmp = None
    114114
    115 
    116115    def next_event(self):
    117116        """ load the next event from disk and calibrate it
     
    122121        self.calibrate_drs_amplitude()
    123122
    124        
    125123    def calibrate_drs_amplitude(self):
    126124        """ perform the drs amplitude calibration of the event data
     
    137135        tom = np.reshape(self.tom, (self.npix, 1024) )
    138136        gm  = np.reshape(self.gm,  (self.npix, 1024) )
    139        
    140         # print 'acal Data ', acal_data.shape
    141         # print 'blm shape ', blm.shape
    142         # print 'gm shape  ', gm.shape
    143137       
    144138        for pixel in range( self.npix ):
     
    174168       
    175169    def filter_CFD(self, length=10, ratio=0.75):
    176         """ constant fraction filter
     170        """ constant fraction discriminator (implemented as FIR)
    177171       
    178172        using:
     
    184178       
    185179        if self.data_saverage_out == None:
    186             print ('error pyfact.filter_CFD was called without
    187             prior call to filter_sliding_average')
    188             print ' variable self.data_saverage_out is needed '
    189             pass
    190 
     180            print """error pyfact.filter_CFD was called without
     181            prior call to filter_sliding_average
     182            variable self.data_saverage_out is needed
     183            """
     184           
    191185        data_CFD_out = self.data_saverage_out.copy()
    192186        b = np.zeros(length)
     
    256250
    257251        try:
    258             f = TFile( file )
     252            f = TFile(file)
    259253        except:
    260254            print 'Baseline data file could not be read: ', file
    261255            return
    262256       
    263         h = f.Get( bsl_hist )
    264 
    265         for i in range( self.npix ):
    266             self.v_bsl[i] = h.GetBinContent( i+1 )
     257        h = f.Get(bsl_hist)
     258
     259        for i in range(self.npix):
     260            self.v_bsl[i] = h.GetBinContent(i+1)
    267261
    268262        f.Close()
    269 
    270263       
    271264    def baseline_correct(self):
     
    274267        """
    275268       
    276         for pixel in range( self.npix ):
     269        for pixel in range(self.npix):
    277270            self.acal_data[pixel,:] -= self.v_bsl[pixel]
    278            
    279        
     271                   
    280272    def info(self):
    281273        """ print run information
     
    296288    """
    297289   
    298     def __init__( self, specifier = ['012', '023', '2011', '11', '24'],
     290    def __init__(self, specifier = ['012', '023', '2011', '11', '24'],
    299291                 rpath = '/scratch_nfs/res/bsl/',
    300292                 zipped = True):
     
    305297        rpath     : directory path for the results; YYYYMMDD will be appended to rpath
    306298        zipped    : use zipped (True) or unzipped (Data)
    307         """
     299
     300        """
     301       
    308302        self.specifier = specifier
    309303        self.rpath     = rpath
     
    311305       
    312306        self.make( self.specifier, self.rpath, self.zipped )
    313     # end of def __init__
     307
    314308
    315309    def make( self, specifier, rpath, zipped ):
     
    352346        self.results = self.names['results']
    353347
    354     # end of make
    355 
    356348    def info( self ):
    357349        """ print complete filenames
     
    363355        print 'drs-cal: ', self.names['drscal']
    364356        print 'results: ', self.names['results']
    365     # end of def info
    366357
    367358# end of class definition: fnames( object )
    368359
    369 
    370 
    371 class histogramList( object ):
    372 
    373     def __init__( self, name ):
    374         """ set the name and create empty lists """
    375         self.name  = name         # name of the list
    376         self.list  = []           # list of the histograms
    377         self.dict  = {}           # dictionary of histograms
    378         self.hList = TObjArray()  # list a la ROOT of the histograms
    379 
    380     def add( self, tag, h ):
    381         self.list.append( h )
    382         self.dict[tag] = h
    383         self.hList.Add( h )
    384 
    385 
    386 class pixelHisto1d ( object ):
    387 
    388     def __init__( self, name, title, Nbin, first, last, xtitle, ytitle, npix ):
    389         """
    390         book one dimensional histograms for each pixel
    391         """
    392         self.name = name
    393 
    394         self.list = [ x for x in range( npix ) ]
    395         self.hList = TObjArray()
    396 
    397         for pixel in range( npix ):
    398 
    399             hname  = name + ' ' + str( pixel )
    400             htitle = title + ' ' + str( pixel )
    401             self.list[pixel] = TH1F( hname, htitle, Nbin, first, last )
    402 
    403             self.list[pixel].GetXaxis().SetTitle( xtitle )
    404             self.list[pixel].GetYaxis().SetTitle( ytitle )
    405             self.hList.Add( self.list[pixel] )
    406 
    407 # simple test method
    408360if __name__ == '__main__':
    409361    """
Note: See TracChangeset for help on using the changeset viewer.