Exemplo n.º 1
0
    def __init__(self,bkgres,sbBinNames,sbBins,mbBinNames,mbBins,sigres,signal):

        self.name = "calc_single_limit"
        self.runLimit = False
        self.runBlind = False
        self.force = False
        self.dir = "."
        self.useBins = range(len(mbBinNames))
        self.corrSystSize = 1000.0
        self.corrSystPdf = "lnN"
        self.procNames = [ "W", "tt", "other", "QCD" ]

        self.bkgres = bkgres
        self.sbBinNames = sbBinNames
        self.sbBins = sbBins
        self.mbBinNames = mbBinNames
        self.mbBins = mbBins

        self.sigres = sigres
        self.signal = signal
        self.mglu = signal["mglu"]
        self.mlsp = signal["mlsp"]

        self.c = cardFileWriter()
        self.c.defWidth=10
        self.c.precision=3
        self.c.maxUncNameWidth = 17
        self.c.maxUncStrWidth = 15
Exemplo n.º 2
0
    def __init__(self,bkgres,sbBinNames,sbBins,mbBinNames,mbBins,sigres,signal):

        self.name = "calc_single_limit"
        self.runLimit = False
        self.runBlind = False
        self.force = False
        self.dir = "."
        self.useBins = range(len(mbBinNames))
        self.procNames = [ "W", "tt", "other", "QCD" ]

        self.bkgres = bkgres
        self.sbBinNames = sbBinNames
        self.sbBins = sbBins
        self.mbBinNames = mbBinNames
        self.mbBins = mbBins

        self.sigres = sigres
        self.signal = signal
        self.mglu = signal["mglu"]
        self.mlsp = signal["mlsp"]

        self.c = cardFileWriter()
        self.c.defWidth=10
        self.c.precision=3
        self.c.maxUncNameWidth = 17
        self.c.maxUncStrWidth = 15

        self.yieldsW = { }
        self.yieldstt = { }
        self.kappaVars = { }
        self.paramLines = [ ]
        self.rateParamLines = [ ]
        self.allRateParams = [ ]
        self.allRateParamValues = { }
        self.yWtts = { }
    def getExpExcl(thresh, retType=None): 
      bkg = lumiFac*getYield(data['simu'], setup, reader, allMethods[methodName]['config'], setup["preselection"]+"&&type==0", thresh, weight)
      sig = lumiFac*getYield(data['simu'], setup, reader, allMethods[methodName]['config'], setup["preselection"]+"&&type==1&&osetMgl=="+str(mgl)+"&&osetMN=="+str(mN), thresh, weight)

      c = cardFileWriter()
      c.addBin('Bin0', ['bkg'], 'Bin0')
      c.specifyObservation('Bin0', int(bkg))
      c.specifyExpectation('Bin0', 'bkg', bkg)
      c.specifyExpectation('Bin0', 'signal', sig)
      c.addUncertainty('globalUnc', 'lnN')
      c.specifyUncertainty('globalUnc', 'Bin0', 'bkg', 1.2)
      if bkg==0. or sig==0.:
        res={'0.500':float('nan')}
      else:
        res=  c.calcLimit('opt.txt',options=opt)
      print "#########################", methodName, "##################################"
      print "Now at thresh",thresh, "bkg/sig", bkg,"/", sig, 
      print "Results",res
      print "################################################################"
      if not retType:
        return res['0.500']
      else:
        return res
Exemplo n.º 4
0
from cardFileWriter import cardFileWriter
from math import exp

c = cardFileWriter()
#c.defWidth=12
#c.precision=6

for i in range(5):
    c.addBin('Bin' + str(i), ['bkg'], 'Bin' + str(i))
    #y = 1000*exp(-i/2.)*0.01**(i/4.)
    y = 100000 * exp(-i / 2.) * 0.01**(i / 4.)
    print "Bin" + str(i), y
    c.specifyObservation('Bin' + str(i), int(y))
    c.specifyExpectation('Bin' + str(i), 'bkg', y)
    c.specifyExpectation('Bin' + str(i), 'signal', 3.5 + i)

c.addUncertainty('Lumi', 'lnN')
c.specifyFlatUncertainty('Lumi', 1.044)

#pf=""

##correlated large uncertainty
#pf+="_corr100"
c.addUncertainty('JES', 'lnN')
for i in range(5):
    c.specifyUncertainty('JES', 'Bin' + str(i), 'bkg', 1.1)

##uncorrelated large uncertainty
#pf+="_uncorr100"
#for i in range(5):
#  c.addUncertainty('ratio'+str(i), 'lnN')
Exemplo n.º 5
0
                sbBinNames.append(sbName)
                sbBins[sbName] = ( njet, lt, ht )
            elif sb=="tt":
              sbName = "J4"  + ltBinToLabel(lt) + htBinToLabel(ht) + dphiLimit + r
              if not sbName in sbBinNames:
                sbBinNames.append(sbName)
                sbBins[sbName] = ( njet, lt, ht )            

  print mbBinNames
  print sbBinNames                

  for signal in signals[:]:
    print signal


    c = cardFileWriter()
    c.defWidth=10
    c.precision=3
    c.maxUncNameWidth = 17
    c.maxUncStrWidth = 15
    #
    # define bins
    #
    for sbname in sbBinNames:
      c.addBin(sbname,procNames,sbname)
      sbres = res[sbBins[sbname][0]][sbBins[sbname][1]][sbBins[sbname][2]]
      # low vs. high dphi
      r = sbname[-2:]
      rDPhi = "low" if r=="C" else "high"
      rDPhi += "DPhi"
      # calculate missing numbers
Exemplo n.º 6
0
                        allPars.append(rpa)
    if idxReg == len(allRegs) and idxPar == len(allPars):
        break
    idxReg = len(allRegs)
    idxPar = len(allPars)

allRegs.sort()
allPars.sort()
print " "
print "Regs:", allRegs
print "Pars:", allPars

#
# Start to build new card file
#
cfw = cardFileWriter()
cfw.defWidth = 15
cfw.maxUncNameWidth = 20
cfw.maxUncStrWidth = 10
cfw.precision = 6

#
# enter selected bins (all processes)
#
for b in dc.bins:
    if b in allRegs:
        cfw.addBin(b, [p for p in dc.processes if p != "signal"], b)
        cfw.specifyObservation(b, int(dc.obs[b] + 0.5))
        for p in dc.processes:
            cfw.specifyExpectation(b, p, dc.exp[b][p])
#