# can make a special "global toy" set of datacards toymaker = 0 if options.throwGlobalToy: if not options.throwAsimov: toymaker = CombinedToyMaker(options.inputmassfacws) else: toymaker = CombinedToyMaker( "") # Dont need mass-fact workspace for asimov cards if not options.inputpdfworkspace: toymaker.createPdfs(options.treefilename, options.outputpdfworkspace, options.expSig) else: toymaker.loadPdfs(options.inputpdfworkspace, options.expSig) if not options.throwAsimov: toymaker.plotData(cardOutDir, 160, 200) toymaker.genData(cardOutDir + "/" + options.outputmassfactoy, options.expSig) toymaker.plotToy(cardOutDir, 160, 95, options.expSig) toymaker.saveToyWorkspace(cardOutDir + "/testToyWS.root") ROOT.gROOT.ProcessLine(".L python/tmvaLoader.C+") from ROOT import tmvaLoader g_tmva = tmvaLoader( options.tmvaweightsfolder + "/TMVAClassification_BDT%sMIT.weights.xml" % options.bdtType, options.bdtType) # Now we can write the cards tfile = ROOT.TFile(options.tfileName) if options.singleMass > 0: evalMasses = [float(options.singleMass)] for m in evalMasses:
if not options.includeVBF: nBind_vbf=0 if not options.includeVH: nBind_vh=0 # can make a special "global toy" set of datacards toymaker=0 if options.throwGlobalToy: if not options.throwAsimov: toymaker = CombinedToyMaker(options.inputmassfacws) else: toymaker = CombinedToyMaker("") # Dont need mass-fact workspace for asimov cards if not options.inputpdfworkspace: toymaker.createPdfs(options.treefilename,options.outputpdfworkspace,options.expSig) else: toymaker.loadPdfs(options.inputpdfworkspace,options.expSig) if not options.throwAsimov: toymaker.plotData(cardOutDir,160,200) toymaker.genData(cardOutDir+"/"+options.outputmassfactoy,options.expSig) toymaker.plotToy(cardOutDir,160,95,options.expSig) toymaker.saveToyWorkspace(cardOutDir+"/testToyWS.root") ROOT.gROOT.ProcessLine(".L python/tmvaLoader.C+") from ROOT import tmvaLoader g_tmva = tmvaLoader(options.tmvaweightsfolder+"/TMVAClassification_BDT%sMIT.weights.xml"%options.bdtType,options.bdtType) # Now we can write the cards tfile = ROOT.TFile(options.tfileName) if options.singleMass>0: evalMasses=[float(options.singleMass)] for m in evalMasses: if options.throwGlobalToy: #g_toydatalist=toymaker.returnWindowData(float(m),g_SIDEBANDWIDTH) if not options.throwAsimov: g_toydatalist=toymaker.returnWindowToyData(float(m),g_SIDEBANDWIDTH) if options.throwAsimov:
if not os.path.isfile(options.inputpdfworkspace): sys.exit("No file named %s, generate it first (remove option)"%options.inputpdfworkspace) toymaker.loadKeysPdf(options.inputpdfworkspace) #if options.expSig>0: toymaker.loadKeysPdf(backgroundpdfws,1) #else: toymaker.loadKeysPdf(backgroundpdfws,0) else: backgrounddiphotonmvahist=backgrounddiphotonmvafile.Get(options.diphotonmvahisttreename) print 'Creating keys pdf from ', backgrounddiphotonmvahist.GetName(), ' with ', backgrounddiphotonmvahist.GetEntries(), ' entries ' toymaker.createKeysPdf(backgrounddiphotonmvahist) #if options.expSig>0: # signaldiphotonmvahist=signaldiphotonmvafile.Get(options.signaltreename) # print 'Creating keys pdf from ', signaldiphotonmvahist.GetName(), ' with ', signaldiphotonmvahist.GetEntries(), ' entries ' # toymaker.createSigHistPdf(signaldiphotonmvahist) toymaker.savePdfWorkspace(options.bdtworkspacename) toymaker.plotData(160,180) toymaker.genData(cardOutDir+"/"+options.outputmassfactoy) toymaker.plotToy(160,200) toymaker.saveToyWorkspace("testToyWS.root") #toymaker.genData(options.expSig) #if options.expSig>0: toymaker.plotSigData(160) ROOT.gROOT.ProcessLine(".L tmvaLoader.C+") from ROOT import tmvaLoader g_tmva = tmvaLoader(options.tmvaweightsfolder+"/TMVAClassification_BDT%sMIT.weights.xml"%options.bdtType,options.bdtType) # Now we can write the cards tfile = ROOT.TFile(options.tfileName) if options.singleMass>0: evalMasses=[float(options.singleMass)] for m in evalMasses: if options.throwGlobalToy:
#treefilename #randomizeBackground #datatreename="dataTree" #signatreename="sigTree" import ROOT from CombinedToyMaker import CombinedToyMaker inputmassfac = "/vols/cms02/h2g/latest_workspace/CMS-HGG_massfacmva-13-04-2012.root" inputfullmva = "/vols/cms02/h2g/latest_workspace/CMS-HGG_jan16reload_fullmva.root_interpolated.root" inputtrees = "/vols/cms02/h2g/latest_workspace/Tree_CMS-HGG_jan16reload_treesV2.root" outputPdfWs = "combToyWS.root" outputmassfacws = "massfactoy.root" expSig = 0. toymaker = CombinedToyMaker(inputmassfac) #toymaker.createPdfs(inputtrees,outputPdfWs,expSig) toymaker.loadPdfs(outputPdfWs, expSig) toymaker.plotData("./", 160, 200) toymaker.genData(outputmassfacws, expSig) toymaker.plotToy("./", 160, 95, expSig) flist = toymaker.returnWindowToyData(125, 0.02) outTest = open("outTest.txt", 'w') print 'elements in list: ', len(flist) for el in flist: outTest.write("%1.4f %+0.5f \n" % (el[0], el[1]))
#randomizeBackground #datatreename="dataTree" #signatreename="sigTree" import ROOT from CombinedToyMaker import CombinedToyMaker inputmassfac = "/vols/cms02/h2g/latest_workspace/CMS-HGG_massfacmva-13-04-2012.root" inputfullmva = "/vols/cms02/h2g/latest_workspace/CMS-HGG_jan16reload_fullmva.root_interpolated.root" inputtrees = "/vols/cms02/h2g/latest_workspace/Tree_CMS-HGG_jan16reload_treesV2.root" outputPdfWs = "combToyWS.root" outputmassfacws = "massfactoy.root" expSig=0. toymaker = CombinedToyMaker(inputmassfac) #toymaker.createPdfs(inputtrees,outputPdfWs,expSig) toymaker.loadPdfs(outputPdfWs,expSig) toymaker.plotData("./",160,200) toymaker.genData(outputmassfacws,expSig) toymaker.plotToy("./",160,95,expSig) flist = toymaker.returnWindowToyData(125,0.02) outTest = open("outTest.txt",'w') print 'elements in list: ', len(flist) for el in flist: outTest.write("%1.4f %+0.5f \n"%(el[0],el[1]))