canvas.setPlotMatrix ( 2, 3 ) from hippo import Display hist = Display ( "Histogram", nt1, ("Cost", ) ) canvas.addDisplay( hist ) # Get the data representation so we can add function to it. datarep1 = hist.getDataRep() from hippo import Function gauss = Function ( "Gaussian", datarep1 ) gauss.addTo ( hist ) # Get the function parameters and display them. print "Before fitting" parmnames = gauss.parmNames ( ) print parmnames parms = gauss.parameters ( ) print parms # Now do the fitting. gauss.fit ( ) print "After fitting" parms = gauss.parameters ( ) print parms # Add another function. gauss1 = Function ( "Gaussian", datarep1 ) gauss1.addTo ( hist )
hits_cut.setCutRange ( 4, 110, 'x' ) # Change the range of the displayed data hist.setRange ( 'x', 40, 700 ) # fit a function to the histogram from hippo import Function datarep = hist.getDataRep () exp1 = Function ( "Exponential", datarep ) exp1.addTo ( hist ) exp1.fit () # Print the results of the fit pnames = exp1.parmNames () print pnames parms = exp1.parameters () print parms # add another function to the histogram and fit the linear sum exp2 = Function ( "Exponential", datarep ) exp2.addTo ( hist ) exp1.fit() # always fit to linear sum # Build an array which is the sum of two columns and add it to the ntuple label = "Raw sum" ntuple [ label ] = ntuple [ 'TkrEnergy' ] + ntuple [ 'CalEnergyCorr' ]