def __init__(self, filename): self.file = open(os.path.expandvars(filename), 'r') # Read the card into a set of dictionaries self.card = parseCard(self.file, _options) # Create a dictionary of named systematics in the card. # Each one has an uncertainty centered at zero, with sigma=1 self.systematics = {} for syst in self.card.systs: self.systematics[syst[0]] = ufloat((0, 1), syst[0])
def load(path): """Loads a HiggsAnalysis.CombinedLimit.DataCard from the path of a txt file This is NOT the same as URA.Utilities.Datacard (the class defined in this same package) This one is the one used by the fit, the URA one is used to write the txt file only. They share the same package because of the obvious link they share""" dummy = OptionParser() addDatacardParserOptions(dummy) opts, args = dummy.parse_args(['--X-allow-no-background']) card = None with open(path) as txt: card = parseCard(txt, opts) return card
def read_card(filename): file = open(filename, 'r') datacard = parseCard(file, _options) return datacard
def read_card(filename): file = open(filename, 'r') datacard = parseCard(file, _options) return datacard
''' Stupid script to get the Higgs TT and WW yields from the ZH data cards. ''' from optparse import OptionParser import pprint import uncertainties from HiggsAnalysis.CombinedLimit.DatacardParser import parseCard, addDatacardParserOptions parser = OptionParser(usage="usage: %prog [options] datacard.txt -o output \nrun with --help to get list of options") addDatacardParserOptions(parser) (options, args) = parser.parse_args() dc = parseCard(open('hzz2l2t_120.txt'), options) print dc.exp total_htt = 0 total_hww = 0 for bin in dc.bins: total_htt += dc.exp[bin]['zh_tt120'] total_hww += dc.exp[bin]['zh_ww120'] print total_htt, total_hww
from optparse import OptionParser import pprint import uncertainties from HiggsAnalysis.CombinedLimit.DatacardParser import parseCard, addDatacardParserOptions parser = OptionParser(usage="usage: %prog [options] datacard.txt -o output \nrun with --help to get list of options") addDatacardParserOptions(parser) (options, args) = parser.parse_args() dc = parseCard(open('trilepton_cards/combined_120.txt'), options) analyses = { 'TT' : { 'channels' : [ 'TT_mmt_mumu_final_MuTauMass', 'TT_emt_emu_final_SubleadingMass', ], 'names' : { 'tt_signal' : 'VH120', 'ww_signal' : 'VH120WW', 'WZ' : 'WZ', 'ZZ' : 'ZZ', 'fakes' : 'fakes', }, }, 'WW' : { 'channels' : [ 'WWW'
ROOT.gErrorIgnoreLevel = ROOT.kWarning if real_out != "-" and os.path.dirname(real_out) and not os.path.isdir( os.path.dirname(real_out)): os.system("mkdir -p " + os.path.dirname(real_out)) ROOT.gSystem.Load("libHiggsAnalysisCombinedLimit") from HiggsAnalysis.CombinedLimit.ShapeTools import ShapeBuilder if options.fileName.endswith(".gz"): import gzip file = gzip.open(options.fileName, "rb") options.fileName = options.fileName[:-3] else: file = open(options.fileName, "r") DC = parseCard(file, options) if not DC.hasShapes: DC.hasShapes = True MB = ShapeBuilder(DC, options) if not options.noshape: MB.prepareAllShapes() def commonStems(list, sep="_"): hits = {} for item in list: base = "" for token in item.split(sep): base = base + sep + token if base else token if base not in hits: hits[base] = 0 hits[base] += 1 veto = {}
from optparse import OptionParser import pprint import uncertainties from HiggsAnalysis.CombinedLimit.DatacardParser import parseCard, addDatacardParserOptions parser = OptionParser(usage="usage: %prog [options] datacard.txt -o output \nrun with --help to get list of options") addDatacardParserOptions(parser) (options, args) = parser.parse_args() dc = parseCard(open('combo/leptons_120.txt'), options) def filter_dict(input): output = {} for k, v in input.iteritems(): if v: output[k] = v return output for syst in dc.systs: name, _, _, _, channel_dict = syst relevant_channels = [ (k, filter_dict(v)) for k, v in channel_dict.iteritems() if any(v.values()) ] print "%s: %s" % (name, relevant_channels)