Example #1
0
                "config": m,
            }

    # cSignal = ROOT.TChain("Events")
    # cSignal.Add("/data/schoef/monoJetTuples_v3/copy/stop300lsp270FastSim/histo_stop300lsp270FastSim.root")
    #
    # cBkg    = ROOT.TChain("Events")
    # cBkg.Add("/data/schoef/monoJetTuples_v3/copy/W1JetsToLNu/histo_W1JetsToLNu.root")
    # cBkg.Add("/data/schoef/monoJetTuples_v3/copy/W2JetsToLNu/histo_W2JetsToLNu.root")
    # cBkg.Add("/data/schoef/monoJetTuples_v3/copy/W3JetsToLNu/histo_W3JetsToLNu.root")
    # cBkg.Add("/data/schoef/monoJetTuples_v3/copy/W4JetsToLNu/histo_W4JetsToLNu.root")

    def getScaledWeight(c):
        return c.GetLeaf("weight").GetValue() * c.GetLeaf("testSampleScaleFac").GetValue()

    data = constructDataset(setup, None, None, False)
    # limits={}
    # resFile = "/data/schoef/nnAnalysis/MVA_Analyzer/limits/"+prefix+postfix+"_"+'limits.pkl'
    if overWrite or not os.path.isfile(resFile):
        import numpy as np
        from scipy import optimize

        classifier = "BDT_maxDepth1"

        def getFom(thresh, classifier, relSysErr=0.05, lepCharge=0, verbose=False, resType="fom"):
            cut = setup["preselection"]
            if lepCharge == -1:
                cut += "&&softIsolatedMuCharge==-1"
            if lepCharge == 1:
                cut += "&&softIsolatedMuCharge==+1"
            yieldStot = getYield(
ksres = {}
for seed in range(1):
  print 'y'
  prepreprefix = 'RA4NNAnalysis_T1tttt_'+str(mgl)+"_"+str(mN)+"_BkgMix_"+str(seed)
  preprefix = prepreprefix
  prefix = preprefix
  for mode in ["Ele", "Mu"]:
    signalModel = getT1ttttSample(mgl, mN, mode)
    backgroundModel = getBkgSample("TTJets-PowHeg", mode)

    if True:    
      setup['dataFile'] = '/data/'+nfsUser+'/RA4NNAnalysis/datasets/'+mode+"_"+prefix+'.root'

      if (not overWriteData and ( os.path.isfile(setup['dataFile']))) :
        print "File",setup['dataFile'],"found->do load!"
        data = constructDataset(setup, None, None, overWriteData)
      else: 

        weightForSampleComposition = "weight"
        signal      = ROOT.TChain('Events')
        for b in signalModel['bins']:
          fstring  = signalModel['dirname']+'/'+b+'/*.root'
          signal.Add(fstring)
          signalSampleSize = signal.GetEntries(setup['preselection'])
          signal.Draw(">>eList", setup['preselection'])
          signalModel['eListPreselection'] = ROOT.gDirectory.Get("eList").Clone('eListPreselectionSignal')
          print "Added bin ",b,"to signal, now",signal.GetEntries()," after preselection:",signalSampleSize,signalModel['eListPreselection'].GetN()

        background      = ROOT.TChain('Events')
        counter=0
        backgroundModel['rangeInChain'] = {}
Example #3
0
setup['TMVAFactoryOptions'] = ["!V","!Silent","Color","DrawProgressBar","Transformations=I;D;P;G,D","AnalysisType=Classification"]
setup['plotTransformations'] = ['Id', 'Deco', 'PCA', 'Gauss_Deco']
setup['makeCorrelationScatterPlots'] = False
setup['plotMVAEffs'] = False #needs active X-forwarding since a QT Object is involved

setup['plotMVAEffs'] = False #needs active X-forwarding since a QT Object is involved
setup['fomPlotZoomCoordinates'] = [0, 0.95, 0.2, 1.0]
setup['mvaInputVars'] = ["mT", "type1phiMet", "mt2w","nbtags","njets",'minDeltaPhi', 'deltaPhi']
prefix = '_'.join(setup['mvaInputVars'])
prefix = preprefix+prefix

setup['TMVAOutputFile'] = '/data/'+nfsUser+'/RA4NNAnalysis/MVA_Analyzer/'+prefix+'.root'
setup['weightDir'] ='/data/'+nfsUser+'/RA4NNAnalysis/MVA_Analyzer/'+prefix+'/'

data = constructDataset(setup, None, None, False)
if not data:
  print "Could not load dataset -> do nothing"
if data and (overWriteTMVAFrameWork or not os.path.isfile(setup['TMVAOutputFile'])):
  setup['fom_plot_vars'] = []#[['mT', [0,1000] , ROOT.kGreen], ['type1phiMet', [0,1000] , ROOT.kMagenta], ['mt2w',[0,1000],ROOT.kGreen+4],['nbtags',[0,1000],ROOT.kYellow]]

  setup['plotDir'] = '/afs/hephy.at/user/'+afsUser[0]+'/'+afsUser+'/www/'+localPlotDir
  setup['plotSubDir'] = prefix

  methodCutOpt['type']=ROOT.TMVA.Types.kCuts
  methodCutOpt['name']='myCut'
  methodCutOpt['lineColor']=ROOT.kRed
  methodCutOpt['niceName']='cutOptimized'
  methodCutOpt['options'] =('!H','!V','VarTransform=None','CreateMVAPdfs=True','FitMethod=GA','EffMethod=EffSel','VarProp=NotEnforced','CutRangeMin=-1','CutRangeMax=-1')

  addNeurons = [2,1]
Example #4
0
def getLSPMassFromFilename(c):
  return getMassesFromFilename(c)[1]

ksres = {}
for seed in range(1):
  prepreprefix = 'MonoJet_'+signalModel['name']+"_BkgMix_"+str(seed)

  if True:    
    preprefix = prepreprefix
    prefix = preprefix

    setup['dataFile'] = '/data/'+nfsUser+'/MonoJetNNAnalysis/datasets/'+prefix+'.root'

    if (not overWriteData and ( os.path.isfile(setup['dataFile']))) :
      print "File",setup['dataFile'],"found->do load!"
      data = constructDataset(setup, None, None, overWriteData)
    else: 
      setup['preselection'] = 'isrJetPt>110&&isrJetBTBVetoPassed&&softIsolatedMuPt>5&&nHardElectrons+nHardMuons==0&&njet60<=2&&type1phiMet>150'
      setup["sigMVAWeightFac"] = 1.#background.GetEntries(setup['preselection'])/float(signal.GetEntries(setup['preselection']))
      setup["bkgMVAWeightFac"] = 1.
  #    setup['weightForMVA'] = {'weight':1., 'sigFac':float(sigScale)/100., 'bkgFac':1}
      setup['weightForMVA'] = {'weight':1., 'sigFac':1., 'bkgFac':1}
      #If changing between met and type1phiMet the formula for deltaPhi (if used) has to be changed!
      setup['varsFromInputData'] = ['type1phiMet', 'isrJetPt', 'isrJetBTBVetoPassed', 'softIsolatedMuPt', 'softIsolatedMuEta','ht', 'nHardElectrons', 'nHardMuons', 'njet60/I','njet/I', 'weight', 'isrJetPt']
      setup['varsFromInputSignal'] = [\
            ['mstop/I', getStopMassFromFilename],\
            ['mlsp/I', getLSPMassFromFilename]] 

      from monoJetFuncs import cosDeltaPhiLepW, softIsolatedMT
      from math import acos
      setup['varsCalculated'] = [\