Ejemplo n.º 1
0
    def __init__(self):
        # event-level features included -- target '1' = leading top; '0' = leading antitop
        hpl_text_dicts = hpl.text_dicts()
        self.text_dicts = hpl_text_dicts['dnn']
        self.processlabel_args = hpl_text_dicts['samples']

        self.text_args = {
            'fontsize': 18,
            'ha': 'left',
            'va': 'top',
            'transform': None
        }
        self.verbose = True
        self.history = None
        self.date = datetime.date.today().strftime('%d%b%Y')
        self.hep_data = None
        self.dnn_data = None
        self.df = None  # set later
        self.model = None  # set later
        self.fpr = None  # set later
        self.tpr = None  # set later
        self.accuracy = {'mean': 0, 'std': 0}  # set later
        self.metadata = {}  # set later
        self.train_data = {}  # set later
        self.test_data = {}  # set later
        self.rejections = []  # set later
        self.rejection = {}  # set later
        self.percentile = 75
        self.output = 'data/DNN/'  # set later
        self.dnn_name = "ttbar_DNN"  # name to access in lwtnn ('variables.json')
        self.image_format = 'png'
        self.test_scores = []  # set later
        self.train_scores = []  # set later
        self.verbose_level = "INFO"

        ## NN parameters -- set by config file
        self.features = []
        self.batch_size = 32
        self.nb_epoch = 1
        self.loss = 'binary_crossentropy'  # preferred for binary classification
        self.optimizer = 'adam'  # old: 'sgd'; change to 'adam' per Riccardo di Sipio
        self.metrics = ['accuracy']
        self.init = 'normal'  #'uniform'
        self.input_dim = len(self.features)
        self.nHiddenLayers = 1
        self.nNodes = [5 for _ in range(self.nHiddenLayers)]
        self.activation = 'elu'
        self.elu_alpha = 1.0
        self.kfold_splits = 2
        self.earlystopping = {
            'monitor': 'loss',
            'min_delta': 0.0001,
            'patience': 5,
            'verbose': self.verbose,
            'mode': 'auto'
        }

        return
Ejemplo n.º 2
0
    def __init__(self):
        """Initialize class for each sample you want systematics"""
        self.sampleName = ''
        self.variable = ''
        self.outpath = "./"
        self.binning = 10
        self.rebin = 1
        self.x_labels = hpl.text_dicts()['variables']
        self.plotSystematics = True

        return
Ejemplo n.º 3
0
    def initialize(self):
        """Initialize some things."""
        HepPlotter.initialize(self)
        self.sampleTypes = {
            'background': [],
            'signal': [],
            'data': [],
            'systematic': []
        }  # systematic is for plotting single systematic uncertainties
        self.labels = hpl.text_dicts()
        self.systematics = OrderedDict()

        self.uncertainty_handles = []
        self.uncertainty_labels = []

        return
Ejemplo n.º 4
0
                    action='store',
                    dest='outpath',
                    default='examples/hepPlotter/',
                    help='Directory for storing output plots')
results = parser.parse_args()

listOfFiles = results.listOfFiles
listOfHists = results.listOfHists
outpath = results.outpath

files = open(listOfFiles, "r").readlines()
histograms = open(listOfHists, "r").readlines()

betterColors = hpt.betterColors()['linecolors']

x_labels = hpl.text_dicts()[
    'variables']  # labels based on histogram plotted (e.g., 'Jet pT')
labels = hpl.text_dicts()[
    'samples']  # labels based on filetype being plotted (e.g., 'ttbar')

numberOfHists = 0
# Access data -- assumes you are plotting histograms from multiple sources in one figure
for hi, histogram in enumerate(histograms):

    histogram = histogram.strip('\n')
    histogramName = histogram.split("h_")[1].split("_pre")[0]
    print "  :: Plotting " + histogram + "\n"

    ## setup histogram
    hist = HepPlotter("histogram", 1)

    hist.ratio_plot = False  # plot a ratio of things [Data/MC]
Ejemplo n.º 5
0
parser.add_argument('-o','--outpath', action='store',default='./',
                    dest='outpath',
                    help='Directory for storing output plots')
results = parser.parse_args()

listOfFiles = results.listOfFiles
listOfHists = results.listOfHists
listOfDetectorSysts = results.listOfSysts  # just detector systematics
outpath = results.outpath

files      = open(listOfFiles,"r").readlines()
histograms = open(listOfHists,"r").readlines()
detectorSystematics = open(listOfDetectorSysts,"r").readlines()

# setup for examples choices
x_labels = hpl.text_dicts()['variables']
rebins   = {"leptonicT_m":40,"ST":200}

# For DataMC plots, one histogram with each sample goes on a single plot
# so I have this structured to loop over the histograms, then the ROOT files
# with lots of histograms, it is probably better to open root files only once,
# load all the histograms, then do the plotting
for histogram in histograms:

    histogram = histogram.rstrip('\n')
    histogramName = histogram.replace("_nominal","").replace("h_","")
    print "  :: Plotting "+histogram+"\n"

    ## setup histogram
    hist = HepPlotterDataMC()