Пример #1
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
Пример #2
0
Author: Evan K. Friis, UW Madison

'''

from HiggsAnalysis.CombinedLimit.DatacardParser import \
        parseCard, addDatacardParserOptions
import fnmatch
import math
from optparse import OptionParser
import os
from HiggsAnalysis.HiggsToTauTau.uncertainties import ufloat
import sys

# The DatacardParser takes some wacky arguments
_parser = OptionParser()
addDatacardParserOptions(_parser)
(_options, _args) = _parser.parse_args([])
_options.bin = True # fake that is a binary output, so that we parse shape lines

def quad(*xs):
    return math.sqrt(sum(x*x for x in xs))

class DataCard(object):
    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 = {}