コード例 #1
0
ファイル: helpers.py プロジェクト: sehwook/StopsDilepton
def getT2ttSignalWeight(sample, lumi):
    '''Get a dictionary for T2tt signal weights
    '''
    from StopsDilepton.tools.xSecSusy import xSecSusy
    xSecSusy_ = xSecSusy()
    channel = 'stop13TeV'
    signalWeight = {}
    mMax = 1500
    bStr = str(mMax) + ',' + str(mMax)
    sample.chain.Draw(
        "GenSusyMScan2:GenSusyMScan1>>hNEvents(" + ','.join([bStr, bStr]) +
        ")", "", "goff")
    hNEvents = ROOT.gDirectory.Get("hNEvents")
    for i in range(mMax):
        for j in range(mMax):
            n = hNEvents.GetBinContent(hNEvents.FindBin(i, j))
            if n > 0:
                signalWeight[(i, j)] = {
                    'weight':
                    lumi *
                    xSecSusy_.getXSec(channel=channel, mass=i, sigma=0) / n,
                    'xSecFacUp':
                    xSecSusy_.getXSec(channel=channel, mass=i, sigma=1) /
                    xSecSusy_.getXSec(channel=channel, mass=i, sigma=0),
                    'xSecFacDown':
                    xSecSusy_.getXSec(channel=channel, mass=i, sigma=-1) /
                    xSecSusy_.getXSec(channel=channel, mass=i, sigma=0)
                }
    #            logger.info( "Found mStop %5i mNeu %5i Number of events: %6i, xSec: %10.6f, weight: %6.6f (+1 sigma rel: %6.6f, -1 sigma rel: %6.6f)", i,j,n, xSecSusy_.getXSec(channel=channel,mass=i,sigma=0),  signalWeight[(i,j)]['weight'], signalWeight[(i,j)]['xSecFacUp'], signalWeight[(i,j)]['xSecFacDown'] )
    del hNEvents
    return signalWeight
コード例 #2
0
ファイル: helpers.py プロジェクト: schoef/StopsDilepton
def getT2ttSignalWeight(sample, lumi):
    """Get a dictionary for T2tt signal weights
    """
    from StopsDilepton.tools.xSecSusy import xSecSusy

    xSecSusy_ = xSecSusy()
    channel = "stop13TeV"
    signalWeight = {}
    mMax = 1500
    bStr = str(mMax) + "," + str(mMax)
    sample.chain.Draw("GenSusyMScan2:GenSusyMScan1>>hNEvents(" + ",".join([bStr, bStr]) + ")", "", "goff")
    hNEvents = ROOT.gDirectory.Get("hNEvents")
    for i in range(mMax):
        for j in range(mMax):
            n = hNEvents.GetBinContent(hNEvents.FindBin(i, j))
            if n > 0:
                signalWeight[(i, j)] = {
                    "weight": lumi * xSecSusy_.getXSec(channel=channel, mass=i, sigma=0) / n,
                    "xSecFacUp": xSecSusy_.getXSec(channel=channel, mass=i, sigma=1)
                    / xSecSusy_.getXSec(channel=channel, mass=i, sigma=0),
                    "xSecFacDown": xSecSusy_.getXSec(channel=channel, mass=i, sigma=-1)
                    / xSecSusy_.getXSec(channel=channel, mass=i, sigma=0),
                }
    #            logger.info( "Found mStop %5i mNeu %5i Number of events: %6i, xSec: %10.6f, weight: %6.6f (+1 sigma rel: %6.6f, -1 sigma rel: %6.6f)", i,j,n, xSecSusy_.getXSec(channel=channel,mass=i,sigma=0),  signalWeight[(i,j)]['weight'], signalWeight[(i,j)]['xSecFacUp'], signalWeight[(i,j)]['xSecFacDown'] )
    del hNEvents
    return signalWeight
コード例 #3
0
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)
    c.Draw("GenSusyMScan2:GenSusyMScan1>>hNEvents(" + ','.join([bStr, bStr]) +
           ")")
    hNEvents = ROOT.gDirectory.Get("hNEvents")
    for i in range(mMax):
        for j in range(mMax):
            n = hNEvents.GetBinContent(hNEvents.FindBin(i, j))
            if n > 0:
コード例 #4
0
if not os.path.exists(os.path.dirname(ofilename)):
    os.makedirs(os.path.dirname(ofilename))

T2tt_exp        = getObjFromFile(options.filename, "T2tt_exp")
T2tt_exp_up     = getObjFromFile(options.filename, "T2tt_exp_up")
T2tt_exp_down   = getObjFromFile(options.filename, "T2tt_exp_down")

T2tt_obs        = getObjFromFile(options.filename, "T2tt_exp").Clone('T2tt_obs') #FIXME!!! This is just for now...
T2tt_obs_UL     = T2tt_obs.Clone("T2tt_obs_UL")
#theory uncertainty on observed limit
T2tt_obs_up   = T2tt_obs.Clone("T2tt_obs_up")
T2tt_obs_down = T2tt_obs.Clone("T2tt_obs_down")
T2tt_obs_up  .Reset()
T2tt_obs_down.Reset()
from StopsDilepton.tools.xSecSusy import xSecSusy
xSecSusy_ = xSecSusy()
for ix in range(T2tt_obs.GetNbinsX()):
    for iy in range(T2tt_obs.GetNbinsY()):
        mStop = T2tt_obs.GetXaxis().GetBinLowEdge(ix)
        mNeu  = T2tt_obs.GetYaxis().GetBinLowEdge(iy)
        v = T2tt_obs.GetBinContent(T2tt_obs.FindBin(mStop, mNeu))
        if v>0:
            scaleup = xSecSusy_.getXSec(channel='stop13TeV',mass=mStop,sigma=1)/xSecSusy_.getXSec(channel='stop13TeV',mass=mStop,sigma=0)
            scaledown = xSecSusy_.getXSec(channel='stop13TeV',mass=mStop,sigma=-1)/xSecSusy_.getXSec(channel='stop13TeV',mass=mStop,sigma=0)
            T2tt_obs_UL.SetBinContent(T2tt_obs.FindBin(mStop, mNeu), v*xSecSusy_.getXSec(channel='stop13TeV',mass=mStop,sigma=0))
            T2tt_obs_up.SetBinContent(T2tt_obs.FindBin(mStop, mNeu), v*scaleup)
            T2tt_obs_down.SetBinContent(T2tt_obs.FindBin(mStop, mNeu), v*scaledown)

T2tt_obs_int = interpolate(T2tt_obs)
T2tt_obs_UL_int = interpolate(T2tt_obs_UL)
T2tt_obs_up_int = interpolate(T2tt_obs_up)