shutil.rmtree(outDir) if not os.path.exists(outDir): os.makedirs(outDir) if not os.path.exists(tmpDir): os.makedirs(tmpDir) if options.signal: signalDir = os.path.join(options.targetDir, options.skim, "T2tt") if not os.path.exists(signalDir): os.makedirs(signalDir) if doTopPtReweighting: print "Computing top pt average weight...", c = ROOT.TChain("tree") for chunk in chunks: c.Add(chunk['file']) # print getTopPtDrawString() topScaleF = getYieldFromChain(c, cutString="(1)", weight=getTopPtDrawString()) topScaleF /= c.GetEntries() c.IsA().Destructor(c) del c print "found a top pt average correction factor of %f" % topScaleF if options.signal: from StopsDilepton.tools.xSecSusy import xSecSusy xSecSusy_ = xSecSusy() channel = 'stop13TeV' signalWeight = {} c = ROOT.TChain("tree") for chunk in chunks: c.Add(chunk['file']) print "Fetching signal weights..." mMax = 1500 bStr = str(mMax) + ',' + str(mMax)
else: puRW = getReweightingFunction(data="PU_2100_XSecCentral", mc="Fall15") puRWDown = getReweightingFunction(data="PU_2100_XSecDown", mc="Fall15") puRWUp = getReweightingFunction(data="PU_2100_XSecUp", mc="Fall15") # top pt reweighting from StopsDilepton.tools.topPtReweighting import getUnscaledTopPairPtReweightungFunction, getTopPtDrawString, getTopPtsForReweighting # Decision based on sample name -> whether TTJets or TTLep is in the sample name isTT = sample.name.startswith("TTJets") or sample.name.startswith("TTLep") doTopPtReweighting = isTT and not options.noTopPtReweighting if doTopPtReweighting: logger.info( "Sample will have top pt reweighting." ) topPtReweightingFunc = getUnscaledTopPairPtReweightungFunction(selection = "dilep") # Compute x-sec scale factor on unweighted events selectionString = "&&".join(skimConds) topScaleF = sample.getYieldFromDraw( selectionString = selectionString, weightString = getTopPtDrawString(selection = "dilep")) topScaleF = topScaleF['val']/float(sample.chain.GetEntries(selectionString)) logger.info( "Found topScaleF %f", topScaleF ) else: topScaleF = 1 logger.info( "Sample will NOT have top pt reweighting. topScaleF=%f",topScaleF ) if options.fastSim: from StopsDilepton.tools.leptonFastSimSF import leptonFastSimSF as leptonFastSimSF_ leptonFastSimSF = leptonFastSimSF_() # systematic variations addSystematicVariations = (not isData) and (not options.skipSystematicVariations) if addSystematicVariations: # B tagging SF from StopsDilepton.tools.btagEfficiency import btagEfficiency
puRWUp = getReweightingFunction(data="PU_2100_XSecUp", mc="Fall15") # top pt reweighting from StopsDilepton.tools.topPtReweighting import getUnscaledTopPairPtReweightungFunction, getTopPtDrawString, getTopPtsForReweighting # Decision based on sample name -> whether TTJets or TTLep is in the sample name isTT = sample.name.startswith("TTJets") or sample.name.startswith("TTLep") doTopPtReweighting = isTT and not options.noTopPtReweighting if doTopPtReweighting: logger.info("Sample will have top pt reweighting.") topPtReweightingFunc = getUnscaledTopPairPtReweightungFunction( selection="dilep") # Compute x-sec scale factor on unweighted events selectionString = "&&".join(skimConds) topScaleF = sample.getYieldFromDraw( selectionString=selectionString, weightString=getTopPtDrawString(selection="dilep")) topScaleF = topScaleF['val'] / float( sample.chain.GetEntries(selectionString)) logger.info("Found topScaleF %f", topScaleF) else: topScaleF = 1 logger.info("Sample will NOT have top pt reweighting. topScaleF=%f", topScaleF) if options.fastSim: from StopsDilepton.tools.leptonFastSimSF import leptonFastSimSF as leptonFastSimSF_ leptonFastSimSF = leptonFastSimSF_() # systematic variations addSystematicVariations = (not isData) and ( not options.skipSystematicVariations)
if os.path.exists(outDir) and options.overwrite: #not options.update: print "Directory %s exists. Delete it."%outDir shutil.rmtree(outDir) if not os.path.exists(outDir): os.makedirs(outDir) if not os.path.exists(tmpDir): os.makedirs(tmpDir) if options.signal: signalDir = os.path.join(options.targetDir, options.skim, "T2tt") if not os.path.exists(signalDir): os.makedirs(signalDir) if doTopPtReweighting: print "Computing top pt average weight...", c = ROOT.TChain("tree") for chunk in chunks: c.Add(chunk['file']) # print getTopPtDrawString() topScaleF = getYieldFromChain(c, cutString = "(1)", weight=getTopPtDrawString()) topScaleF/=c.GetEntries() c.IsA().Destructor(c) del c print "found a top pt average correction factor of %f"%topScaleF if options.signal: from StopsDilepton.tools.xSecSusy import xSecSusy xSecSusy_ = xSecSusy() channel='stop13TeV' signalWeight={} c = ROOT.TChain("tree") for chunk in chunks: c.Add(chunk['file']) print "Fetching signal weights..." mMax = 1500 bStr = str(mMax)+','+str(mMax)