filterCutData = getFilterCut( 2016, isData=True, skipBadChargedCandidate=True ) data2016.setSelectionString( [filterCutData, "reweightHEM>0", cutInterpreter.cutString( args.mode )] ) data2016.setWeightString( "weight" ) filterCutData = getFilterCut( 2017, isData=True, skipBadChargedCandidate=True ) data2017.setSelectionString( [filterCutData, "reweightHEM>0", cutInterpreter.cutString( args.mode )] ) data2017.setWeightString( "weight" ) filterCutData = getFilterCut( 2018, isData=True, skipBadChargedCandidate=True ) data2018.setSelectionString( [filterCutData, "reweightHEM>0", cutInterpreter.cutString( args.mode )] ) data2018.setWeightString( "weight" ) setup = Setup( year=2016, photonSelection=False, checkOnly=False, runOnLxPlus=False ) #photonselection always false for qcd estimate setup = setup.sysClone( parameters=allRegions[args.selection]["parameters"] ) selection = setup.selection( "MC", channel="all", **setup.defaultParameters() )["prefix"] selection = cutInterpreter.cutString( selection ) selection += "&&triggered==1" print selection if args.addCut: selection += "&&" + cutInterpreter.cutString( args.addCut ) print( "Using selection string: %s"%selection ) key = (data2018.name, "18", args.variable, "_".join(map(str,args.binning)), data2018.weightString, data2018.selectionString, selection) if dirDB.contains(key) and not args.overwrite: dataHist2018 = dirDB.get(key).Clone("edataAR18") else: dataHist2018 = data2018.get1DHistoFromDraw( args.variable, binning=args.binning, selectionString=selection ) dirDB.add(key, dataHist2018.Clone("edataAR18"), overwrite=True)
mc_e.setSelectionString( [filterCutMC, "reweightHEM>0", cutInterpreter.cutString("e")]) mc_e.setWeightString(weightStringAR) print "e", mc_e.selectionString print print "mu", mc_mu.selectionString setup = Setup( year=args.year, photonSelection=False, checkOnly=False, runOnLxPlus=False) #photonselection always false for qcd estimate setup = setup.sysClone(parameters=allRegions[args.selection]["parameters"]) selection = setup.selection("MC", channel="all", **setup.defaultParameters())["prefix"] selection = cutInterpreter.cutString(selection) selection += "&&pTStitching==1&&triggered==1" print selection if args.addCut: selection += "&&" + cutInterpreter.cutString(args.addCut) print("Using selection string: %s" % selection) key = (mc_e.name, "AR", args.variable, "_".join(map(str, args.binning)), mc_e.weightString, mc_e.selectionString, selection) if dirDB.contains(key) and not args.overwrite: mcHist_e = dirDB.get(key.Clone("e")) else: mcHist_e = mc_e.get1DHistoFromDraw(args.variable, binning=args.binning, selectionString=selection)
"JetGood1": "JetGoodInvLepIso1", } if len(args.selection.split("-")) == 1 and args.selection in allRegions.keys(): print("Plotting region from SetupHelpers: %s" % args.selection) setup = Setup( year=args.year, photonSelection=False, checkOnly=False, runOnLxPlus=False) #photonselection always false for qcd estimate setup = setup.sysClone(parameters=allRegions[args.selection]["parameters"]) selection = setup.selection("MC", channel=args.mode, **setup.defaultParameters())["prefix"] selection = cutInterpreter.cutString(selection) selection += "&&triggered==1" if args.addCut: selection += "&&" + cutInterpreter.cutString(args.addCut) print("Using selection string: %s" % args.selection) preSelection = setup.selection( "MC", channel=args.mode, **setup.defaultParameters(update=QCD_updates))["prefix"] preSelection = cutInterpreter.cutString(preSelection) preSelection += "&&triggeredInvIso==1" if args.addCut: addSel = cutInterpreter.cutString(args.addCut) for iso, invIso in replaceSelection.iteritems(): addSel = addSel.replace(iso, invIso)
if args.small: args.plot_directory += "_small" if args.noData: args.plot_directory += "_noData" if args.normalize: args.plot_directory += "_normalized" if args.ttgSingleLep: args.plot_directory += "_singleLep" # get reco selection criteria lambda function selection = signalRegions[args.recoSelection]["lambda"] setup = Setup( year=args.year, photonSelection=False, checkOnly=True, runOnLxPlus=False) #photonselection always false for qcd estimate setup = setup.sysClone(parameters=allRegions[args.recoSelection]["parameters"]) recoselection = setup.selection("MC", channel="all", **setup.defaultParameters()) recoSelection = recoselection["prefix"] nGen, xminGen, xmaxGen = args.genBinning nReco, xminReco, xmaxReco = args.recoBinning cache_dir = os.path.join(cache_directory, "unfolding", str(args.year), "matrix") dirDB = MergingDirDB(cache_dir) if args.year == 2016: lumi_scale = 35.92 elif args.year == 2017: lumi_scale = 41.53 elif args.year == 2018: lumi_scale = 59.74 elif args.year == "RunII": lumi_scale = 35.92 + 41.53 + 59.74 if args.normalize:
photonRegion = not allRegions[args.selection]["noPhotonCR"] bjetRegion = setup.parameters["nBTag"][0] > 0 njets = setup.parameters["nJet"][0] selection = setup.selection( "DataMC", channel=args.mode )["prefix"] # selection = allSelection + "-" + args.mode selection = cutInterpreter.cutString( selection ) selection += "&&triggered==1" print selection if args.addCut: print cutInterpreter.cutString( args.addCut ) selection += "&&" + cutInterpreter.cutString( args.addCut ) print( "Using selection string: %s"%args.selection ) print selection preSelection = setup.selection("DataMC", channel=args.mode, **setup.defaultParameters( update=QCD_updates ))["prefix"] print preSelection preSelection = cutInterpreter.cutString( preSelection ) preSelection += "&&triggeredInvIso==1" print preSelection print args.addCut if args.year == 2016 and args.mode == "e" and not "etal0" in args.addCut: preSelection += "&&abs(LeptonTightInvIso0_eta)<1.479" if args.addCut: # addSel = args.addCut #"-".join([ item for item in args.addCut.split("-") if not item.startswith("etal")]) if args.year == 2016 and args.mode == "e": addSel = "-".join([ item for item in args.addCut.split("-") if not item.startswith("etal") or "etal0" in item ]) else: addSel = args.addCut
s.setSelectionString( [ filterCutMc, "pTStitching==1","PhotonGood0_photonCatMagic==0" ] ) s.read_variables = read_variables_MC sampleWeight = "1" if args.small: s.normalization = 1. s.reduceFiles( factor=100 ) sampleWeight = "%f"%(1./s.normalization) if len(args.selection.split("-")) == 1 and args.selection in allRegions.keys(): print( "Plotting region from SetupHelpers: %s"%args.selection ) setup = Setup( year=args.year, photonSelection=False, checkOnly=False, runOnLxPlus=False ) #photonselection always false for qcd estimate setup = setup.sysClone( parameters=allRegions[args.selection]["parameters"] ) selection = setup.selection( "MC", channel=args.mode, **setup.defaultParameters() )["prefix"] selection = cutInterpreter.cutString( selection ) selection += "&&triggered==1" if args.addCut: print cutInterpreter.cutString( args.addCut ) selection += "&&" + cutInterpreter.cutString( args.addCut ) print( "Using selection string: %s"%args.selection ) else: raise Exception("Region not implemented") if args.year == 2016: lumi_scale = 35.92 elif args.year == 2017: lumi_scale = 41.53 elif args.year == 2018:
isData=True, skipBadChargedCandidate=True) mc_high = copy.deepcopy(mc) mc_low = copy.deepcopy(mc) data_high = copy.deepcopy(data_sample) data_low = copy.deepcopy(data_sample) setup = Setup( year=args.year, photonSelection=False, checkOnly=False, runOnLxPlus=False) #photonselection always false for qcd estimate setup = setup.sysClone(parameters=allRegions[args.selection]["parameters"]) selection = setup.selection("MC", channel="all", **setup.defaultParameters())["cut"] selection += "&&pTStitching==1&&triggered==1" if args.addCut: selection += "&&" + cutInterpreter.cutString(args.addCut) dataselection = setup.selection("Data", channel="all", **setup.defaultParameters())["cut"] dataselection += "&&triggered==1" if args.addCut: dataselection += "&&" + cutInterpreter.cutString(args.addCut) print("Using selection string: %s" % selection) if "2" in args.selection and not "2p" in args.selection: misIDSF_val = misID2SF_val elif "3" in args.selection and not "3p" in args.selection: