Example #1
0
for i, s in enumerate(allSamples):
    tchunks, tsumWeight = getChunks(s, maxN=maxN)
    chunks += tchunks
    sumWeight += tsumWeight
    print "Now %i chunks from sample %s with sumWeight now %f" % (
        len(chunks), s.name, sumWeight)

sample = allSamples[0]
if len(allSamples) > 1:
    sample.name = sample.name + '_comb'

doTopPtReweighting = sample.name.startswith(
    "TTJets") or sample.name.startswith("TTLep")
if doTopPtReweighting:
    print "Sample %s will have top pt reweights!" % sample.name
topPtReweightingFunc = getUnscaledTopPairPtReweightungFunction(
) if doTopPtReweighting else None

if options.fastSim:
    leptonFastSimSF = leptonFastSimSF_()

if not options.skipVariations:
    from StopsDilepton.tools.btagEfficiency import btagEfficiency, getTagWeightDict
    btagEff_1d = btagEfficiency(method='1d')

    maxMultBTagWeight = 2
    btagEff_1b = btagEfficiency(method='1b', fastSim=options.fastSim)

if options.lheHTCut:
    try:
        float(options.lheHTCut)
    except:
Example #2
0
assert False not in [hasattr(s, 'path') for s in allSamples], "Not all samples have a path: "+", ".join([s.name for s in allSamples])

for i, s in enumerate(allSamples):
  tchunks, tsumWeight = getChunks(s, maxN=maxN)
  chunks+=tchunks; sumWeight += tsumWeight
  print "Now %i chunks from sample %s with sumWeight now %f"%(len(chunks), s.name, sumWeight)

sample=allSamples[0]
if len(allSamples)>1:
  sample.name=sample.name+'_comb'  

doTopPtReweighting = sample.name.startswith("TTJets") or sample.name.startswith("TTLep")
if doTopPtReweighting:
  print "Sample %s will have top pt reweights!"% sample.name
topPtReweightingFunc = getUnscaledTopPairPtReweightungFunction() if doTopPtReweighting else None

if options.fastSim:
  leptonFastSimSF = leptonFastSimSF_()
 
if not options.skipVariations:
  from StopsDilepton.tools.btagEfficiency import btagEfficiency, getTagWeightDict
  btagEff_1d = btagEfficiency(method='1d')

  maxMultBTagWeight = 2
  btagEff_1b = btagEfficiency(method='1b', fastSim = options.fastSim)

if options.lheHTCut:
  try:
    float(options.lheHTCut)
  except:
        puRW        = getReweightingFunction(data="PU_2100_XSecCentral", mc="Spring15")
        puRWDown    = getReweightingFunction(data="PU_2100_XSecDown", mc="Spring15")
        puRWUp      = getReweightingFunction(data="PU_2100_XSecUp", mc="Spring15")
    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)
        puRWDown = getReweightingFunction(data="PU_2100_XSecDown",
                                          mc="Spring15")
        puRWUp = getReweightingFunction(data="PU_2100_XSecUp", mc="Spring15")
    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_