MaxPullClassifier

Histogram classification based on maximum pull between test histogram and reference histogram.

Specifically intended for 2D histograms, but should in principle work for 1D as well.
Ssee static function 'pull' for definition of bin-per-bin pull and other notes.


pull

full signature:

def pull( testhist, refhist )  

comments:

calculate bin-per-bin pull between two histograms  
bin-per-bin pull is defined here preliminarily as (testhist(bin)-refhist(bin))/sqrt(refhist(bin))  
notes:   
- bins in the denominator where refhist is < 1 are set to one! This is for histograms with absolute counts, and they should not be normalized!  
- instead another normalization is applied: the test histogram is multiplied by sum(refhist)/sum(testhist) before computing the pulls  
input arguments:  
- testhist, refhist: numpy arrays of the same shape  
output:  
numpy array of same shape as testhist and refhist  

maxabspull

full signature:

def maxabspull( testhist, refhist, n=1 )  

comments:

calculate maximum of bin-per-bin pulls (in absolute value) between two histograms  
see definition of bin-per-bin pull in function pull (above)  
input arguments:  
- testhist, refhist: numpy arrays of the same shape  
- n: nubmer of largest pull values to average over (default: 1, just take single maximum)  
output:  
a float  

[class] MaxPullClassifier

comments:

histogram classification based on maximum pull between test histogram and reference histogram.  
specifically intended for 2D histograms, but should in principle work for 1D as well.  
see static function pull (above) for definition of bin-per-bin pull and other notes.  

⤷ __init__

full signature:

def __init__( self, nmaxpulls=1 )  

comments:

initializer  
input arguments:  
- nmaxpulls: number of largest pull values to average over   
  (default: 1, just take single maximum)  

⤷ set_nmaxpulls

full signature:

def set_nmaxpulls( self, nmaxpulls )  

comments:

set the nmaxpulls parameter (see also initializer)  

⤷ train

full signature:

def train( self, refhist )  

comments:

'train' the classifier, i.e. set the reference histogram.  
input arguments:  
- refhist: a numpy array of shape (1,nbins) or (1,nybins,nxbins)  

⤷ evaluate

full signature:

def evaluate( self, histograms )  

comments:

classify the histograms based on their max bin-per-bin pull (in absolute value) with respect to a reference histogram  

⤷ getpull

full signature:

def getpull( self, histogram )  

comments:

get the pull histogram for a given test histogram  
input arguments:  
histogram: a single histogram, i.e. numpy array of shape (nbins) for 1D or (nybins,nxbins) for 2D.  
output:  
numpy array of same shape as histogram containing bin-per-bin pull w.r.t. reference histogram