Beispiel #1
0
cut1.setCutRange (  80., 100., 'x' )

#
# Create a another cut and set its range
#
cut2 = Cut ( events, ( 'energy', ) )
canvas.addDisplay ( cut2 )
cut2.setCutRange ( 1e3, 1e4, 'x' )
cut2.setLog ( 'x', True )
cut2.setLog ( 'y', True )

cuts = ( cut1, cut2 )
#
# Add the list of cuts to display
#
datarep = hist.getDataRep()
datarep.applyCuts ( cuts )
hist.applyCuts ( cuts )

#
# If applying only one cut one would do
# datarep.applyCut ( cut1 )
#
print "Added multiple cuts to one display"


#
# Now we use nummary's boolean arrays to create cut
#
hist2 = Display ( "Histogram", events, ('GLON', ) )
canvas.addDisplay ( hist2 )
mean = 45
sigma = 10
gauss = random.gauss

# Generate some data,  fill the static histograms and NTuple.
for i in range(10000):
    x = gauss( mean, sigma )
    sthist.addValues ( (x, ) )
    ntuple.addRow ( (x, ) )
    if i < 1000 :
        sthists.addValues ( (x, ) )  # only fill with first 1000


# Print some statistics from static histogram
# Could do same for dynamic
datarep = sthist.getDataRep()

print "Histogram :"
print "  Title : " + sthist.getTitle()
print "  Entries : %i" % sthist.numberOfEntries()
print "  Mean = %f" % datarep.getMean ( 'x' )
print "  Rms  = %f" % datarep.getRMS ( 'x' )

# Print the average X value on the display
canvas.selectDisplay ( sthist)
canvas.addTextRep ( sthist, 'averagex' )
canvas.selectDisplay ( dyhist)
canvas.addTextRep ( dyhist, 'averagex' )

# Get the contents of the bins as a DataArray
high = sthist.createDataArray()