# 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) sampleTree.addFormula(weightExpression_DeepCSV_nosf) sampleTree.addFormula(weightExpression_DeepJet_nosf) sampleTree.addFormula(taggerExpression_DeepCSV) sampleTree.addFormula(taggerExpression_DeepJet) isSignal = 1 if sample.name in signalNames else 0 for event in sampleTree: #bselection = VHbbSelection(channels=["Zll"]) #sortb = bselection.HighestTaggerValueBJets(event, 20, 20, 'Jet_btagDeepFlavB')
from __future__ import print_function import ROOT ROOT.gROOT.SetBatch(True) from myutils.XbbConfig import XbbConfigReader, XbbConfigTools from myutils.sampleTree import SampleTree as SampleTree from myutils.BranchList import BranchList config = XbbConfigTools(XbbConfigReader.read("Zvv2017")) sampleTree = SampleTree( { 'name': 'MET', 'folder': config.get('Directories', 'dcSamples') }, config=config) variables = ["H_pt", "MET_Pt", "H_pt/MET_Pt"] # enable only explicitly used branches sampleTree.enableBranches(BranchList(variables).getListOfBranches()) # create TTReeFormula's for variable in variables: sampleTree.addFormula(variable) # loop over events for event in sampleTree: print( sampleTree.tree.GetReadEntry(), ", ".join([x + "=%1.4f" % sampleTree.evaluate(x) for x in variables])) if sampleTree.tree.GetReadEntry() > 98: break