예제 #1
0
from Workspace.HEPHYPythonTools.nnAnalysisHelpers import getObjFromFile

# ifile = "/afs/hephy.at/user/s/schoefbeck/www/pngNN/nnValidation_RA4_test_T1tttt-madgraph_4j_met100_mt2w200_NormDeco_10000_sigmoid_BP_S03_SE08_mD_600_800_mN_500_600_mT_type1phiMet_mt2w_nbtags_njets_minDeltaPhi_htRatio_deltaPhi.root"
# ifile = "/afs/hephy.at/user/s/schoefbeck/www/pngNN/nnValidation_RA4_4j_met100_mt2w200_NormDeco_5000_sigmoid_mD_200_400_mN_500_600_mT_type1phiMet_mt2w_nbtags_njets_minDeltaPhi_htRatio_deltaPhi.root"
# ifile = "/afs/hephy.at/user/s/schoefbeck/www/pngNN/nnValidation_RA4_test_refWeight200_T1tttt-madgraph_4j_met100_mt2w200_NormDeco_10000_sigmoid_BP_S03_SE08_mgl_1400_mN_800_mT_type1phiMet_mt2w_nbtags_njets_minDeltaPhi_htRatio_deltaPhi.root"
# ifile ="/afs/hephy.at/user/s/schoefbeck/www/pngNN/nnValidation_RA4_test_refWeight200_T1tttt_4j_met100_mt2w200_NormDeco_10000_sigmoid_BP_S03_SE08_mgl_1200_mN_750_mT_type1phiMet_mt2w_nbtags_njets_minDeltaPhi_htRatio_deltaPhi.root"
ifile = "/afs/hephy.at/user/s/schoefbeck/www/pngNN/nnValidation_RA4_test_refWeight1000_T1tttt_4j_bt1_met100_mt2w0_NormDeco_10000_sigmoid_BP_S03_SE08_mgl_1300_mN_850_mT_type1phiMet_mt2w_nbtags_njets_minDeltaPhi_htRatio_deltaPhi.root"


def delErr(g):
    for i in range(g.GetN()):
        g.GetEX()[i] = 0
        g.GetEY()[i] = 0


canv = getObjFromFile(ifile, "mlpa_canvas")
myCut = canv.GetPrimitive("mlpa_canvas_1").GetListOfPrimitives().At(2)
pad = canv.GetPrimitive("mlpa_canvas_2")
l = pad.GetListOfPrimitives().At(1).Clone("l")
lp = pad.GetListOfPrimitives().At(2).Clone("lp")
lm = pad.GetListOfPrimitives().At(3).Clone("lm")
# lmT = pad.GetListOfPrimitives().At(5).Clone("lmT")
# lmet = pad.GetListOfPrimitives().At(8).Clone("lmet")

c = ROOT.TCanvas()

# res = smoother.Approx(l, "constant" )
if doSmooth:
    ls = smoother.SmoothLowess(l, "", 0.01, 30, 0).Clone()
    lsp = smoother.SmoothLowess(lp, "", 0.01, 30, 0).Clone()
    lsm = smoother.SmoothLowess(lm, "", 0.01, 3, 0).Clone()
예제 #2
0
import ROOT
#c = ROOT.TChain("MonteCarlo")
#c.Add("/data/schoef/MonoJetNNAnalysis/datasets/MonoJet_BDTvsMLP_stop300lsp270FastSim_refsel_None_softIsolatedMT_type1phiMet_deltaPhi_isrJetPt_htRatio.root")
#c.SetScanField(10**7)
#
#c.Scan("type:weight:weightForMVA:type1phiMet:softIsolatedMuPt:isrJetPt:softIsolatedMT:deltaPhi:htRatio:softIsolatedMuCharge", "","@colsize=20")

import ROOT, os, sys
from Workspace.HEPHYPythonTools.nnAnalysisHelpers import getObjFromFile
from array import array

if len(sys.argv)>2:
  ifile = sys.argv[2] 

if len(sys.argv)>1:
  if sys.argv[1].lower()=="test":
    tree = getObjFromFile(ifile, "TestTree")
  if sys.argv[1].lower()=="train":
    tree = getObjFromFile(ifile, "TrainTree")

  tree.SetScanField(10**7)
  tree.Scan("classID:weight:type1phiMet:softIsolatedMT:deltaPhi:MLP33_nCyc500", "","@colsize=20")

  setup=pickle.load(file('/data/'+nfsUser+'/MonoJetNNAnalysis/MVA_Analyzer/'+prefix+'.pkl'))

  reader = ROOT.TMVA.Reader()  
  for var in setup['mvaInputVars']:
    var_i  = array('f',[0])
  #  vars[var] = var_i
    reader.AddVariable(var,var_i)

  allMethods = {}
  for m in setup['methodConfigs']:
    if m['type']!=ROOT.TMVA.Types.kCuts: 
      allMethods[m['name']] = {'reader':reader.BookMVA(m['name'],setup['weightDir']+'/TMVAClassification_'+m['name']+'.weights.xml'), 'config':m}
    else:
      allMethods[m['name']] = {'reader':reader.BookMVA(m['name'],setup['weightDir']+'/TMVAClassification_'+m['name']+'.weights.xml'), 'config':m}
  for mD in [1,2,3,4,10]:
    trainTree = getObjFromFile(setup['TMVAOutputFile'], 'TrainTree')
    varListBkgTrain = getVarValList(trainTree, 'BDT_maxDepth'+str(mD), "classID==0")
    varListSigTrain = getVarValList(trainTree, 'BDT_maxDepth'+str(mD), "classID==1")

    testTree = getObjFromFile(setup['TMVAOutputFile'], 'TestTree')
    varListBkgTest = getVarValList(testTree, 'BDT_maxDepth'+str(mD), "classID==0")
    varListSigTest = getVarValList(testTree, 'BDT_maxDepth'+str(mD), "classID==1")


    #Binned version
    plotBkgTest = getPlot(testTree,"classID==0", 'BDT_maxDepth'+str(mD))
    plotSigTest = getPlot(testTree,"classID==1", 'BDT_maxDepth'+str(mD))
    plotBkgTrain = getPlot(trainTree,"classID==0", 'BDT_maxDepth'+str(mD))
    plotSigTrain = getPlot(trainTree,"classID==1", 'BDT_maxDepth'+str(mD))
    print "maxDepth",mD,"test/train",len(varListBkgTest),len(varListBkgTrain),"unbinned, Bkg", KolmogorovProbability(varListBkgTrain, varListBkgTest), 'binned', plotBkgTest.KolmogorovTest(plotBkgTrain),"X", plotBkgTest.KolmogorovTest(plotBkgTrain, "X") 
    print "maxDepth",mD,"test/train",len(varListSigTest),len(varListSigTrain),"unbinned, Sig", KolmogorovProbability(varListSigTrain, varListSigTest), 'binned', plotSigTest.KolmogorovTest(plotSigTrain),"X", plotSigTest.KolmogorovTest(plotSigTrain, "X")
예제 #4
0
    {
        "name": "MLP21, 10000",
        "color": ROOT.kBlue,
        "fname": "/afs/hephy.at/user/s/schoefbeck/www/pngMJNN/nnValidation_MonoJet_MLP21_stop300lsp270FastSim_refsel_NormDeco_10000_sigmoid_BP_S03_SE08_softIsolatedMT_type1phiMet_deltaPhi.root",
    },
    {
        "name": "MLP21, 20000",
        "color": ROOT.kMagenta,
        "fname": "/afs/hephy.at/user/s/schoefbeck/www/pngMJNN/nnValidation_MonoJet_MLP21_stop300lsp270FastSim_refsel_NormDeco_20000_sigmoid_BP_S03_SE08_softIsolatedMT_type1phiMet_deltaPhi.root",
    },
]
xRange = [0.10, 1.0]
yRange = [0.1, 0.30]

for f in foms:
    canv = getObjFromFile(f["fname"], "mlpa_canvas")
    pad = canv.GetPrimitive("mlpa_canvas_2")
    l = pad.GetListOfPrimitives().At(1).Clone("l")
    lp = pad.GetListOfPrimitives().At(2).Clone("lp")
    lm = pad.GetListOfPrimitives().At(3).Clone("lm")
    if doSmooth:
        ls = smoother.SmoothLowess(l, "", 0.01, 30, 0).Clone()
        lsp = smoother.SmoothLowess(lp, "", 0.01, 30, 0).Clone()
        lsm = smoother.SmoothLowess(lm, "", 0.01, 3, 0).Clone()
        delErr(ls)
        delErr(lsp)
        delErr(lsm)
    else:
        ls = l
        lsp = lp
        lsm = lm
예제 #5
0




    {"name":"MLP21, 100",   "color":ROOT.kBlack,   "fname":"/afs/hephy.at/user/s/schoefbeck/www/pngMJNN/nnValidation_MonoJet_MLP21_stop300lsp270FastSim_refsel_NormDeco_100_sigmoid_BP_S03_SE08_softIsolatedMT_type1phiMet_deltaPhi.root"},
    {"name":"MLP21, 1000",  "color":ROOT.kGreen,   "fname":"/afs/hephy.at/user/s/schoefbeck/www/pngMJNN/nnValidation_MonoJet_MLP21_stop300lsp270FastSim_refsel_NormDeco_1000_sigmoid_BP_S03_SE08_softIsolatedMT_type1phiMet_deltaPhi.root"},
    {"name":"MLP21, 5000",  "color":ROOT.kRed,     "fname":"/afs/hephy.at/user/s/schoefbeck/www/pngMJNN/nnValidation_MonoJet_MLP21_stop300lsp270FastSim_refsel_NormDeco_5000_sigmoid_BP_S03_SE08_softIsolatedMT_type1phiMet_deltaPhi.root"},
    {"name":"MLP21, 10000", "color":ROOT.kBlue,    "fname":"/afs/hephy.at/user/s/schoefbeck/www/pngMJNN/nnValidation_MonoJet_MLP21_stop300lsp270FastSim_refsel_NormDeco_10000_sigmoid_BP_S03_SE08_softIsolatedMT_type1phiMet_deltaPhi.root"},
    {"name":"MLP21, 20000", "color":ROOT.kMagenta, "fname":"/afs/hephy.at/user/s/schoefbeck/www/pngMJNN/nnValidation_MonoJet_MLP21_stop300lsp270FastSim_refsel_NormDeco_20000_sigmoid_BP_S03_SE08_softIsolatedMT_type1phiMet_deltaPhi.root"},
        ]
xRange = [0.10, 1.0]
yRange = [0.1, 0.30]

for f in foms:
    canv = getObjFromFile(f['fname'], "mlpa_canvas")
    pad = canv.GetPrimitive("mlpa_canvas_2")
    l = pad.GetListOfPrimitives().At(1).Clone("l")
    lp = pad.GetListOfPrimitives().At(2).Clone("lp")
    lm = pad.GetListOfPrimitives().At(3).Clone("lm")
    if doSmooth:
        ls = smoother.SmoothLowess(l, "", 0.01, 30, 0).Clone()
        lsp = smoother.SmoothLowess(lp, "", 0.01, 30, 0).Clone()
        lsm = smoother.SmoothLowess(lm, "", 0.01, 3, 0).Clone()
        delErr(ls)
        delErr(lsp)
        delErr(lsm)
    else:
        ls = l
        lsp = lp
        lsm = lm
예제 #6
0
                    m['name'], setup['weightDir'] + '/TMVAClassification_' +
                    m['name'] + '.weights.xml'),
                'config':
                m
            }
        else:
            allMethods[m['name']] = {
                'reader':
                reader.BookMVA(
                    m['name'], setup['weightDir'] + '/TMVAClassification_' +
                    m['name'] + '.weights.xml'),
                'config':
                m
            }
    for mD in [1, 2, 3, 4, 10]:
        trainTree = getObjFromFile(setup['TMVAOutputFile'], 'TrainTree')
        varListBkgTrain = getVarValList(trainTree, 'BDT_maxDepth' + str(mD),
                                        "classID==0")
        varListSigTrain = getVarValList(trainTree, 'BDT_maxDepth' + str(mD),
                                        "classID==1")

        testTree = getObjFromFile(setup['TMVAOutputFile'], 'TestTree')
        varListBkgTest = getVarValList(testTree, 'BDT_maxDepth' + str(mD),
                                       "classID==0")
        varListSigTest = getVarValList(testTree, 'BDT_maxDepth' + str(mD),
                                       "classID==1")

        #Binned version
        plotBkgTest = getPlot(testTree, "classID==0", 'BDT_maxDepth' + str(mD))
        plotSigTest = getPlot(testTree, "classID==1", 'BDT_maxDepth' + str(mD))
        plotBkgTrain = getPlot(trainTree, "classID==0",
예제 #7
0
if not path in sys.path:
    sys.path.insert(1, path)

from Workspace.HEPHYPythonTools.nnAnalysisHelpers import getObjFromFile
ifile = "/afs/hephy.at/user/s/schoefbeck/www/pngNN/nnValidation_RA4_test_refWeight1000_T1tttt_4j_bt1_met100_mt2w0_NormDeco_10000_sigmoid_BP_S03_SE08_mgl_1300_mN_850_mT_type1phiMet_mt2w_nbtags_njets_minDeltaPhi_htRatio_deltaPhi.root"

ROOT.TH1F().SetDefaultSumw2()


def delErr(g):
    for i in range(g.GetN()):
        g.GetEX()[i] = 0
        g.GetEY()[i] = 0


canv = getObjFromFile(ifile, "mlpa_canvas")
#myCut = canv.GetPrimitive("mlpa_canvas_1").GetListOfPrimitives().At(2)
pad = canv.GetPrimitive("mlpa_canvas_3")
hbgTest = canv.GetPrimitive("mlpa_canvas_3").GetListOfPrimitives().FindObject(
    "hbgTest")
hsigTest = canv.GetPrimitive("mlpa_canvas_3").GetListOfPrimitives().FindObject(
    "hsigTest")
hbgTrain = canv.GetPrimitive("mlpa_canvas_4").GetListOfPrimitives().FindObject(
    "hbgTrain")
hsigTrain = canv.GetPrimitive(
    "mlpa_canvas_4").GetListOfPrimitives().FindObject("hsigTrain")

hbgTest.SetLineColor(ROOT.kBlue)
hbgTrain.SetLineColor(ROOT.kBlue)
hsigTest.SetLineColor(ROOT.kRed)
hsigTrain.SetLineColor(ROOT.kRed)