def main(): # Override pullPlotUtils' default colours (which are all black) pullPlotUtils.getRegionColor = getRegionColor pullPlotUtils.getSampleColor = getSampleColor # Where's the background file? filename = os.getenv("HISTFITTER")+"/macros/Examples/pulls/0lepton_bkgFit_example.root" # Run blinded? doBlind = True # Used as plot title region = "SRAm" # Samples to stack on top of eachother in each region samples = "Diboson,GAMMAjets,Multijets,Top,Wjets,Zjets" # Which regions do we use? regionList = makeRegionList() # Regions for which the label gets changed renamedRegions = renameRegions() if not os.path.exists(filename): print "filename %s does not exist" % filename return # Run YieldsTable.py with all regions and samples requested cmd = "YieldsTable.py -c %s -s %s -w %s -o yield_%s_all.tex -t %sall" % (",".join(regionList), samples, filename, region, region) print cmd subprocess.call(cmd, shell=True) # Open the pickle pickleFilename = "yield_%s_all.pickle" % (region) makePullPlot(pickleFilename, regionList, samples, renamedRegions, region, doBlind)
def main(zlFitterConfig): doBlind = False #unfortunately blinds everything.......LL useVRWTM = False useChargeAsymmetry = False parser = OptionParser() parser.add_option("--PrintOnly", default=False, action="store_true", help="do not execute the command") parser.add_option("--doVR", default=False, action="store_true", help="include tables with VRs that are not the _all.tex version")#ATT: remove parser.add_option("-s", "--shape", default=False, action="store_true", help="workspace has shape fits")#ATT: remove parser.add_option("-o", "--output-dir", default="results/", help="output dir under which files can be found", metavar="DIR") (options, args) = parser.parse_args() options.output_dir += "/" #to be sure print options ############################################################################### #samples = "Diboson,GAMMAjets,Multijets,Top,Wjets,Zjets" samples = ",".join(zlFitterConfig.sampleNameList) renamedRegions = renameRegions(useChargeAsymmetry, useVRWTM) myAnaList = finalChannelsDict.keys() for anaName in myAnaList: # regionList = zlFitterConfig.allRegionsList( excludeRegions = ["VRQ", "CRQ"]) regionList = zlFitterConfig.allRegionsList( excludeRegions = ["VRQ"]) # Filename containing workspace filename = os.path.join(options.output_dir, "ZL_%s_Background/Fit__Background_combined_NormalMeasurement_model_afterFit.root" % anaName) if not os.path.exists(filename): print "filename %s does not exist - continuing" % filename continue #Systematics makeSystematicsTables(anaName, filename, doPrintOnly=options.PrintOnly) #Yields makeYieldTables(anaName, filename, regionList, samples, renamedRegions, options.shape, options.doVR, doBlind,doPrintOnly=options.PrintOnly) #pull if not options.PrintOnly: pickleFilename = "plots/yield_%s_all.pickle" % (anaName) # makePullPlot(pickleFilename, regionList, samples, renamedRegions, anaName, doBlind) makePullPlot(pickleFilename, regionList, samples, renamedRegions, anaName, True)#ATT Nikola makeSummaryPlots(options.PrintOnly)
def main(): # Override pullPlotUtils' default colours (which are all black) pullPlotUtils.getRegionColor = getRegionColor pullPlotUtils.getSampleColor = getSampleColor # Where's the workspace file? wsfilename = os.getenv("HISTFITTER")+"/results/MyConfigExample/BkgOnly_combined_NormalMeasurement_model_afterFit.root" # # Where's the pickle file? pickleFilename = os.getenv("HISTFITTER")+"/MyYieldsTable.pickle" # Run blinded? doBlind = True # Used as plot title region = "SS_metmeff2Jet" # Samples to stack on top of eachother in each region samples = "Top,WZ,BG,QCD" # Which regions do we use? regionList = makeRegionList() # Regions for which the label gets changed renamedRegions = renameRegions() if not os.path.exists(pickleFilename): print "pickle filename %s does not exist" % pickleFilename print "will proceed to run yieldstable again" # Run YieldsTable.py with all regions and samples requested cmd = "YieldsTable.py -c %s -s %s -w %s -o MyYieldsTable.tex" % (",".join(regionList), samples, wsfilename) print cmd subprocess.call(cmd, shell=True) if not os.path.exists(pickleFilename): print "pickle filename %s still does not exist" % pickleFilename return # Open the pickle and make the pull plot makePullPlot(pickleFilename, regionList, samples, renamedRegions, region, doBlind)
def main(zlFitterConfig): doBlind = False #unfortunately blinds everything.......LL useVRWTM = False useChargeAsymmetry = False parser = OptionParser() parser.add_option("--PrintOnly", default=False, action="store_true", help="do not execute the command") parser.add_option( "--doVR", default=False, action="store_true", help="include tables with VRs that are not the _all.tex version" ) #ATT: remove parser.add_option("-s", "--shape", default=False, action="store_true", help="workspace has shape fits") #ATT: remove parser.add_option("-o", "--output-dir", default="results/", help="output dir under which files can be found", metavar="DIR") (options, args) = parser.parse_args() options.output_dir += "/" #to be sure print options ############################################################################### #samples = "Diboson,GAMMAjets,Multijets,Top,Wjets,Zjets" samples = ",".join(zlFitterConfig.sampleNameList) renamedRegions = renameRegions(useChargeAsymmetry, useVRWTM) myAnaList = finalChannelsDict.keys() for anaName in myAnaList: # regionList = zlFitterConfig.allRegionsList( excludeRegions = ["VRQ", "CRQ"]) regionList = zlFitterConfig.allRegionsList(excludeRegions=["VRQ"]) # Filename containing workspace filename = os.path.join( options.output_dir, "ZL_%s_Background/Fit__Background_combined_NormalMeasurement_model_afterFit.root" % anaName) if not os.path.exists(filename): print "filename %s does not exist - continuing" % filename continue #Systematics makeSystematicsTables(anaName, filename, doPrintOnly=options.PrintOnly) #Yields makeYieldTables(anaName, filename, regionList, samples, renamedRegions, options.shape, options.doVR, doBlind, doPrintOnly=options.PrintOnly) #pull if not options.PrintOnly: pickleFilename = "plots/yield_%s_all.pickle" % (anaName) # makePullPlot(pickleFilename, regionList, samples, renamedRegions, anaName, doBlind) makePullPlot(pickleFilename, regionList, samples, renamedRegions, anaName, True) #ATT Nikola makeSummaryPlots(options.PrintOnly)
def main(zlFitterConfig): useVRWTM = False useChargeAsymmetry = False parser = OptionParser() parser.add_option("--blind" , default=False, action="store_true", help="") parser.add_option("--signal", default="", help="Give a signal point that you want to get the syst table for") parser.add_option("--PrintOnly", default=False, action="store_true", help="do not execute the command") parser.add_option("--doVR", default=False, action="store_true", help="include tables with VRs that are not the _all.tex version")#ATT: remove parser.add_option("-s", "--shape", default=False, action="store_true", help="workspace has shape fits")#ATT: remove parser.add_option("-o", "--output-dir", default="results/", help="output dir under which files can be found", metavar="DIR") (options, args) = parser.parse_args() options.output_dir += "/" #to be sure print options ############################################################################### #samples = "Diboson,GAMMAjets,Multijets,Top,Wjets,Zjets" samples = ",".join(zlFitterConfig.sampleNameList) renamedRegions = renameRegions(useChargeAsymmetry, useVRWTM) myAnaList = finalChannelsDict.keys() for anaName in myAnaList: regionList = zlFitterConfig.allRegionsList() print "Printing regionList" print regionList regionList.remove("VRQ")#don't plot VRQ for now if "SRC" in anaName : regionList.remove("VRQa") regionList.remove("VRQb") regionList.remove("VRTb") regionList.remove("VRWb") regionList.remove("VRZb") if ("SRG" in anaName) or ("SRS" in anaName) : regionList.remove("VRQc") regionList.remove("VRZc") regionList.remove("VRZca") print "Printing regionList" print regionList # Filename containing workspace filenames = [os.path.join(options.output_dir, "ZL_%s_Background/Fit__Background_combined_NormalMeasurement_model_afterFit.root" % anaName)] if options.signal : filenames = [] for root, dirs, files in os.walk("results/", topdown=False): for name in files: if "combined_NormalMeasurement_model_afterFit.root" in name : # print(os.path.join(root, name)) if options.signal in name : filenames.append(os.path.join(root,name)) print filenames if not filenames : print "Failed to find any fit results in this directory" if options.signal : print "You ran looking for signal fits. you either ran in the wrong directory, or you gave a signal point which is not a fit result. Printing the list of afterFit workspaces : " filenames = [] for root, dirs, files in os.walk("results/", topdown=False): for name in files: if "combined_NormalMeasurement_model_afterFit.root" in name : print(os.path.join(root, name)) else : print "For background fits, you probably just ran in the wrong directory" print "exiting" exit() for filename in filenames : if not os.path.isfile(filename): print "filename %s does not exist - continuing" % filename continue #Systematics makeSystematicsTables(anaName, filename, doPrintOnly=options.PrintOnly) #makeSystematicsTables(anaName, filename, doPrintOnly=options.PrintOnly,region="VRWMf") if zlFitterConfig.datadriven: makeSystematicsTablesInCR(anaName, filename, zlFitterConfig.datadrivenRegionsList,doPrintOnly=options.PrintOnly) #Yields makeYieldTables(anaName, filename, regionList, samples, renamedRegions, options.shape, options.doVR, options.blind,doPrintOnly=options.PrintOnly) #pull if not options.PrintOnly: pickleFilename = "yield_%s_all.pickle" % (anaName) # scaleRegions = {"VRZ_cuts" : 1.55/2., # "VRZa_cuts" : 1.55/2., # "VRZb_cuts" : 1.55/2. # }#scale the VRZ by the jigsaw kappa factor scaleRegions = {}#scale the VRZ by the jigsaw kappa factor results1=makePullPlot(pickleFilename, regionList, samples, renamedRegions, anaName, options.blind, scaleRegions) results2=makePullPlot(pickleFilename, regionList, samples, renamedRegions, anaName, options.blind, scaleRegions, doLogScale = True) if results1!=None: pullMap={} for r in results1: pullMap[r[0].replace("_cuts","")]=r[1:5] pullFileName = "pull_%s.pkl" % (anaName) pickle.dump( pullMap, open( pullFileName, "wb" ) ) makeSummaryPlots(options.PrintOnly)
def main(zlFitterConfig): useVRWTM = False useChargeAsymmetry = False parser = OptionParser() parser.add_option("--blind", default=False, action="store_true", help="") parser.add_option( "--signal", default="", help="Give a signal point that you want to get the syst table for") parser.add_option("--PrintOnly", default=False, action="store_true", help="do not execute the command") parser.add_option( "--doVR", default=False, action="store_true", help="include tables with VRs that are not the _all.tex version" ) #ATT: remove parser.add_option("-s", "--shape", default=False, action="store_true", help="workspace has shape fits") #ATT: remove parser.add_option("-o", "--output-dir", default="results/", help="output dir under which files can be found", metavar="DIR") (options, args) = parser.parse_args() options.output_dir += "/" #to be sure print options ############################################################################### #samples = "Diboson,GAMMAjets,Multijets,Top,Wjets,Zjets" samples = ",".join(zlFitterConfig.sampleNameList) renamedRegions = renameRegions(useChargeAsymmetry, useVRWTM) myAnaList = finalChannelsDict.keys() for anaName in myAnaList: regionList = zlFitterConfig.allRegionsList() print "Printing regionList" print regionList regionList.remove("VRQ") #don't plot VRQ for now if "SRC" in anaName: regionList.remove("VRQa") regionList.remove("VRQb") regionList.remove("VRTb") regionList.remove("VRWb") regionList.remove("VRZb") regionList.remove("VRZa") if ("SRG" in anaName) or ("SRS" in anaName): regionList.remove("VRQc") regionList.remove("VRZc") regionList.remove("VRZca") # if ("SRS" in anaName): # regionList.remove("VRT") print "Printing regionList" print regionList # Filename containing workspace filenames = [ os.path.join( options.output_dir, "ZL_%s_Background/Fit__Background_combined_NormalMeasurement_model_afterFit.root" % anaName) ] if options.signal: filenames = [] for root, dirs, files in os.walk("results/", topdown=False): for name in files: if "combined_NormalMeasurement_model_afterFit.root" in name: # print(os.path.join(root, name)) if options.signal in name: filenames.append(os.path.join(root, name)) print filenames if not filenames: print "Failed to find any fit results in this directory" if options.signal: print "You ran looking for signal fits. you either ran in the wrong directory, or you gave a signal point which is not a fit result. Printing the list of afterFit workspaces : " filenames = [] for root, dirs, files in os.walk("results/", topdown=False): for name in files: if "combined_NormalMeasurement_model_afterFit.root" in name: print(os.path.join(root, name)) else: print "For background fits, you probably just ran in the wrong directory" print "exiting" exit() for filename in filenames: if not os.path.isfile(filename): print "filename %s does not exist - continuing" % filename continue #Systematics makeSystematicsTables(anaName, filename, doPrintOnly=options.PrintOnly) #makeSystematicsTables(anaName, filename, doPrintOnly=options.PrintOnly,region="VRWMf") if zlFitterConfig.datadriven: makeSystematicsTablesInCR(anaName, filename, zlFitterConfig.datadrivenRegionsList, doPrintOnly=options.PrintOnly) #Yields makeYieldTables(anaName, filename, regionList, samples, renamedRegions, options.shape, options.doVR, options.blind, doPrintOnly=options.PrintOnly) #pull if not options.PrintOnly: pickleFilename = "yield_%s_all.pickle" % (anaName) # scaleRegions = {"VRZ_cuts" : 1.55/2., # "VRZa_cuts" : 1.55/2., # "VRZb_cuts" : 1.55/2. # }#scale the VRZ by the jigsaw kappa factor scaleRegions = {} #scale the VRZ by the jigsaw kappa factor results1 = makePullPlot(pickleFilename, regionList, samples, renamedRegions, anaName, options.blind, scaleRegions) results2 = makePullPlot(pickleFilename, regionList, samples, renamedRegions, anaName, options.blind, scaleRegions, doLogScale=True) if results1 != None: pullMap = {} for r in results1: pullMap[r[0].replace("_cuts", "")] = r[1:5] pullFileName = "pull_%s.pkl" % (anaName) pickle.dump(pullMap, open(pullFileName, "wb")) makeSummaryPlots(options.PrintOnly)
def renamePulls(tag): for extension in ['png', 'eps', 'pdf']: shutil.move( 'histpull_.%s' % extension , 'histpull_%s.%s' % (tag, extension) ) # ------------------------------------------------------------------------------ # make the basic pull plot! print 'making basic pull plot' pullPlotUtils.makePullPlot( pickleFilename = 'YieldTable/MyYieldTable.CR_VR_SR.pickle' , regionList = [ 'CR_top_all_mbl_0' , 'CR_Z_all_mbl_0' , 'VR_top_1_all_mbl_0' , 'VR_top_2_all_mbl_0' , 'VR_top_3_all_mbl_0' , 'VR_Z_all_mbl_0' ] , samples = sample_string , renamedRegions = rename_dict , outputPrefix = '' , doBlind = True ) renamePulls('CR_VR') # ------------------------------------------------------------------------------ # make the CR detailed pull plot! print 'making detailed CR pull plot' pullPlotUtils.makePullPlot( pickleFilename = 'YieldTable/MyYieldTable.CR_detail.pickle' , regionList = [ 'CR_top_all_mbl_0' , 'CR_top_ee_mbl_0'