def test_configs(self): for configTag in self.configTags: config = XbbConfigTools(config=XbbConfigReader.read('../' + configTag)) xcc = XbbConfigChecker(config) xcc.checkAll() xcc.printErrors() status = xcc.getStatus() print("STATUS:", configTag, "=>", status) self.assertEqual(status, 0) self.statusDict[configTag] = status
parser.add_option("-R", "--regions", dest="regions", default="", help="regions") parser.add_option("-r", "--run", dest="run", default="", help="run") parser.add_option("-e", "--event", dest="event", default="", help="event") parser.add_option("-x", "--expressions", dest="expressions", default="", help="colon separated") (opts, args) = parser.parse_args(argv) config = XbbConfigTools(XbbConfigReader.read(opts.tag)) inputFolder = config.get('Directories', 'dcSamples') logFolder = config.get('Directories', 'tagDir') config.loadNamespaces() regions = config.getDatacardRegions() if len( opts.regions) < 1 else config.parseCommaSeparatedList(opts.regions) for region in regions: dataSamples = eval(config.get('dc:' + region, 'data')) for dataSample in dataSamples: sampleTree = SampleTree({ 'name': dataSample, 'folder': inputFolder },
from ROOT import TAxis from ROOT import TColor from ROOT import TAxis from ROOT import TLorentzVector from ROOT import TMath from ROOT import TLegend #from ROOT import cmath from ROOT import gStyle from ROOT import gPad from ROOT import TCanvas, TColor, TGaxis, TH1F, TPad from ROOT import kBlack, kBlue, kRed, kViolet # load configuration and list of used samples config = XbbConfigReader.read('Zll2018') path = "Zll2018config/samples_nosplit.ini" sampleInfo = ParseInfo(config, path, config=config) usedSamples = sampleInfo.get_samples(XbbConfigTools(config).getMC()) #usedSamples = sampleInfo.get_samples(['ZJetsHT100', 'ZH_Znunu']) usedSampleIdentifiers = list(set([x.identifier for x in usedSamples])) print('usedSampleIdentifiers', usedSampleIdentifiers) # some samples come from same set of ROOT trees (=have same identifier) # -> find list of unique identifiers to avoid to process same tree file twice #sampleIdentifiers = sampleInfo.getSampleIdentifiers() #usedSampleIdentifiers = ParseInfo.filterIdentifiers(sampleIdentifiers, usedSamples) # from which step to take the root trees
'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 # load config config = XbbConfigReader.read(args.tag) sampleInfo = ParseInfo(samples_path=config.get('Directories', args.fromFolder), config=config) mcSamples = sampleInfo.get_samples(XbbConfigTools(config).getMC()) pruneThreshold = float(args.prune) sampleGroups = [] for x in args.samples.split(','): sampleGroups.append(x.split('+')) sampleCuts = args.cuts.strip().split(',') if args.fc != '': cutGroups = [ x.strip(',').split(',') for x in args.fc.strip(';').split(';') ]
#! /usr/bin/env python 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