コード例 #1
0
def getEventCount(config,
                  sampleIdentifier,
                  cut="1",
                  sampleTree=None,
                  sample=None):
    if not sampleTree:
        sampleTree = SampleTree(
            {
                'name': sampleIdentifier,
                'folder': config.get('Directories', args.fromFolder).strip()
            },
            config=config)
    h1 = ROOT.TH1D("h1", "h1", 1, 0, 2)
    scaleToXs = sampleTree.getScale(sample)
    #nEvents = sampleTree.tree.Draw("1>>h1", "(" + cut + ")*genWeight*%1.6f"%scaleToXs, "goff")
    nEvents = sampleTree.tree.Draw("1>>h1", cut, "goff")
    nEventsWeighted = h1.GetBinContent(1)
    #print("DEBUG:", sampleIdentifier, cut, " MC events:", nEvents, " (weighted:", nEventsWeighted, ")")
    h1.Delete()
    return nEvents
コード例 #2
0
    #subsamples = sampleInfo.getSubsamples(sampleIdentifier)

    #print('subsample_pirmin', subsamples)
    #print('sample_pirmin', sample)
    #print("\x1b[41m\x1b[0m")

    sampleTree = SampleTree({
        'sample': sample,
        'folder': directory
    },
                            config=config)
    #raw_input()

    # since we load all trees, we can compute the factor to scale cross section to luminosity directly (otherwise write it to ntuples
    # first and then use it as branch, or compute it with full set of trees before)
    scaleXStoLumi = sampleTree.getScale(sample)

    # enable only used branches!
    # this will speed up processing a lot
    sampleTree.enableBranches(
        BranchList([
            signalRegionSelection, weightExpression_DeepCSV,
            weightExpression_DeepJet, taggerExpression_DeepCSV,
            taggerExpression_DeepJet
        ]).getListOfBranches() + ['Jet*'])

    # this will create the TTreeformula objects
    sampleTree.addFormula(signalRegionSelection)
    sampleTree.addFormula(signalRegionSelection_roc)
    sampleTree.addFormula(weightExpression_DeepCSV)
    sampleTree.addFormula(weightExpression_DeepJet)