Changeset 13095


Ignore:
Timestamp:
03/14/12 09:07:34 (13 years ago)
Author:
lusterma
Message:
modified class hist for more compatibility with ROOT
File:
1 edited

Legend:

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

    r12814 r13095  
    1010
    1111class histogramList( object ):
    12     """ maintain a list of ROOT histograms
    13     """
     12    """ maintain a list of ROOT histograms """
     13
    1414    def __init__( self, name ):
    1515        """ set the name and create empty lists """
     
    2121        self.book()
    2222
     23    def __call__(self, tag, value):
     24        """ fill value in the correct histo """
     25
     26        self.dict[tag].Fill(value)
     27
    2328    def __del__(self):
    2429        for h in self.list:
     
    5459    Create ROOT histo
    5560    """
    56     def __init__( self, nbins, first, last, name = 'name', title = 'title',
     61    def __init__( self, name, title, nbins, first, last,
    5762                  xtitle = 'x', ytitle = 'y' ):
    5863
     
    6974       
    7075    def fill( self, x ):
    71         h, b = np.histogram( x, self.nbins, self.first, self.last,
    72                              new = True )
     76        h, b = np.histogram( x, self.nbins, (self.first,self.last) )
     77        self.b = b
    7378        self.y += h
     79
     80    def __call__(self, x):
     81        self.fill(x)
     82
    7483
    7584    def zero( self ):
     
    8190            self.rh = TH1F( self.name, self.title, self.nbins,
    8291                   self.first, self.last )
    83             self.rh.GetXaxis().SetTitle( xtitle );
    84             self.rh.GetYaxis().SetTitle( ytitle );
     92            self.rh.GetXaxis().SetTitle( self.xtitle );
     93            self.rh.GetYaxis().SetTitle( self.ytitle );
    8594
    8695        for i in range( self.nbins ):
Note: See TracChangeset for help on using the changeset viewer.