Hot-keys on this page
r m x p toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
#!/usr/bin/env python
Helper wrapper to handle the customized TObject template to be drawn.
"""
#===============================================================================
""" Translate the styling instruction from qhist to apply to given histogram h, at the given index. """ ## If COLOR explicitly True/False
## If FILL explicitly True/False h.fillStyle = utils.FILLS(index)
## If MARKER explicitly True/False h.markerStyle = utils.MARKERS(index)
## If LINE explicitly True/False h.lineStyle = 1 # plain line
#===============================================================================
""" Prepare the template instance to be cloned. Most of the time, there's no need to worry about style here, since it'll not be carried forward to be used in 3rd-pass anyway. """ else: return TProfile2D(qhist) else:
#===============================================================================
""" Abstract base class for making different histograms from same interface. """
"""Handle cloning, unique naming, ownership, in one go."""
def template(_): # pragma: no cover """ Implement this method to return a new instance of histogram. """ raise NotImplementedError
def apply_style(wrapper, h, index): # pragma: no cover raise NotImplementedError
# @abstractproperty # def legend_header(_): # raise NotImplementedError
# @abstractmethod # def legend_entry(_, h, index): # raise NotImplementedError
#===============================================================================
# STYLE#01: Data is 1st entry, showed as marker. The rest is MC, show as lines # e.g., Zmumu normalization plot # points else: # histogram
## STYLE#02: 1st entry is marker. The rest are stacked & filled. else:
# STANDARD style ## p0 to show empty bin
else: # pragma: no cover raise NotImplementedError
# @property # def legend_header(_): # return ('LHCb-Preliminary', 'Entries', 'Integral', 'Min', 'Max', 'Mean', 'RMS')
# def legend_entry(self, hc, index): # qh = self.qhist # nentries = int(hc.GetEntries())
# yield qh.legends[index] # yield nentries # yield utils.pretty_round(float(hc.Integral())) # yield utils.pretty_round(qh.stats[index].xmin) # yield utils.pretty_round(qh.stats[index].xmax) # yield utils.pretty_round(hc.GetMean()) if nentries else '---' # yield utils.pretty_round(hc.GetRMS()) if nentries else '---'
#==============================================================================
# @property # def legend_header(_): # return ('LHCb-preliminary', 'Entries', 'Y-mean')
# def legend_entry(self, hc, index): # qh = self.qhist # from array import array # arr = array('d', range(6)) # hc.GetStats(arr) # # print arr # ymean = arr[4]/arr[0] if arr[0]!=0 else '9999' # # yrms = (arr[5]/arr[1])**0.5
# yield qh.legends[index] # yield int(hc.GetEntries()) # yield utils.pretty_round(ymean) # # yield utils.pretty_round(yrms)
#==============================================================================
# h.fillStyle = 10
# @property # def legend_header(_): # return ('LHCb-preliminary', 'count', 'x-mean', 'x-RMS', 'y-mean', 'y-RMS' )
# def legend_entry(self, hc, index): # yield self.qhist.legends[index] # yield int(hc.GetEntries()) # yield utils.pretty_round(hc.GetMean(1)) # yield utils.pretty_round(hc.GetRMS(1)) # yield utils.pretty_round(hc.GetMean(2)) # yield utils.pretty_round(hc.GetRMS(2))
#==============================================================================
qh = self.qhist return ROOT.TProfile2D(qh.name+'_wrapper', qh.title, qh.xbin, qh.xarr, qh.ybin, qh.yarr)
#============================================================================== |