Beispiel #1
0
Plot.setDefaults(stack = stack, weight = weight, addOverFlowBin=None)

plots, fisherInfoVariables = process.getPlotList( args.scaleLumi, args.level )

plotting.fill(plots, read_variables = read_variables, sequence = sequence, max_events = -1 if args.small else -1)

if args.addFisherInformation:
    for i, plot in enumerate(plots):
        if fisherInfoVariables[i] is None: continue

        fiHistoListIndex = len(plot.histos)-3 if args.backgrounds else len(plot.histos)-1
        bins = plot.binning
        var = fisherInfoVariables[i] #replace with better solution than FI_plots!!

        hist = w.getFisherInformationHisto( ttXSample, var, bins, selectionString=cutInterpreter.cutString(args.selection), weightString=ttXWeightString, variables=args.variables, nEventsThresh = args.binThreshold, **fisherInfo_WC)
        plot.histos[fiHistoListIndex] = [plot.fromHisto( 'histo_%i'%i, hist ).histos]

        if args.backgrounds:
            #get list of contents of bg histo
            bgContentList = histo_to_list( plot.histos_added[-1][0] )
            #get list of contents of signal histo
            sigContentList = histo_to_list( plot.histos[fiHistoListIndex-1][0] )
            #calculate purity for each bin
            purityBinList = [ sig / ( sig + bgContentList[j] ) if (sig + bgContentList[j])!=0 else 0 for j, sig in enumerate( sigContentList ) ]
            # multiply ideal fisher info histo purity
            for l in range(bins[0]):
                plot.histos[fiHistoListIndex+1][0].SetBinContent(l+1, plot.histos[fiHistoListIndex][0].GetBinContent(l+1) * purityBinList[l])

drawPlots(plots)

Beispiel #2
0
        hist = w.getFisherInformationHisto(
            ttXSample,
            var,
            bins,
            selectionString=cutInterpreter.cutString(args.selection),
            weightString=ttXWeightString,
            variables=args.variables,
            nEventsThresh=args.binThreshold,
            **fisherInfo_WC)
        plot.histos[fiHistoListIndex] = [
            plot.fromHisto('histo_%i' % i, hist).histos
        ]

        if args.addFisherInformationBackground:
            #get list of contents of bg histo
            bgContentList = histo_to_list(plot.histos_added[len(params) +
                                                            1][0])
            #get list of contents of bg histo
            nonInfoContentList = histo_to_list(
                plot.histos_added[len(params)][0])
            #get list of contents of signal histo
            sigContentList = histo_to_list(plot.histos[len(params) - 1][0])
            #calculate purity for each bin
            purityBinList = [
                (sig + nonInfoContentList[j]) /
                (sig + nonInfoContentList[j] + bgContentList[j]) if
                (sig + nonInfoContentList[j] + bgContentList[j]) != 0 else 0
                for j, sig in enumerate(sigContentList)
            ]
            # multiply ideal fisher info histo purity
            for l in range(bins[0]):
                plot.histos[fiHistoListIndex + 1][0].SetBinContent(