def __init__(self, channel_type): ''' Initialize empty Channel Template with specific type ''' ChannelType.__init__(self, channel_type) ChannelStyle.__init__(self, channel_type) Template.__init__(self) self.__input_templates = [] # track added input templates self.__input_template_types = set() # track added input template types
def __init__(self, input_type, template): ''' Initialize object with input type and histogram. Histogram will be cloned and automatically scaled to x-section, luminosity and number of Monte-Carlo processed events ''' InputType.__init__(self, input_type) # cache scale factor for future fast access self.__scale = (self.xsection * self.luminosity() / self.events) if self.events else 1 # histogram will be scaled upon set and scale factor need to be set Template.__init__(self, template = template)
def __str__(self): ''' Add counter of templates to print ''' return ("<{Class} with {templates} input template(s) at 0x{ID:x}>\n" " + {ChannelTypeStr}\n" " + {TemplateStr}").format( Class = self.__class__.__name__, templates = len(self.input_templates), ChannelTypeStr = ChannelType.__str__(self), TemplateStr = Template.__str__(self), ID = id(self))
def __str__(self): ''' Add lumi and scale numbers to InputType pretty print ''' return ("<{Class} lumi {lumi:.1f} fb-1 scale {scale:.2f} at 0x{ID:x}>\n" " + {InputTypeStr}\n" " + {TemplateStr}").format( Class = self.__class__.__name__, lumi = self.luminosity() / 1000, scale = self.scale, InputTypeStr = InputType.__str__(self), TemplateStr = Template.__str__(self), ID = id(self))