def set2DStyle(self, opt="BasicRainBow"): gStyle.SetPadRightMargin( 0.2 ) # Leave more space to the right side of the current Pad to show the histogram scale if opt == "FancyRainBow": icol = 0 gStyle.SetFrameBorderMode(icol) gStyle.SetFrameFillColor(icol) gStyle.SetCanvasBorderMode(icol) gStyle.SetCanvasColor(icol) gStyle.SetPadBorderMode(icol) gStyle.SetPadColor(icol) gStyle.SetStatColor(icol) gStyle.SetOptTitle(0) gStyle.SetOptStat(0) gStyle.SetOptFit(0) ncontours = 999 s = array.array('d', [0.00, 0.34, 0.61, 0.84, 1.00]) r = array.array('d', [0.00, 0.00, 0.87, 1.00, 0.51]) g = array.array('d', [0.00, 0.81, 1.00, 0.20, 0.00]) b = array.array('d', [0.51, 1.00, 0.12, 0.00, 0.00]) npoints = len(s) TColor.CreateGradientColorTable(npoints, s, r, g, b, ncontours) gStyle.SetNumberContours(ncontours) if opt == "BasicRainBow": gStyle.SetPalette( 1 ) # This resets the color palette to a simple Rainbow Color Map w/ 50 colors. See https://root.cern.ch/doc/master/classTColor.html
def rootSetup(): from ROOT import gStyle gStyle.SetStatColor(0) gStyle.SetFillColor(38) gStyle.SetCanvasColor(0) gStyle.SetPadColor(0) gStyle.SetPadBorderMode(0) gStyle.SetCanvasBorderMode(0) gStyle.SetFrameBorderMode(0) gStyle.SetOptStat(1110) gStyle.SetStatH(0.3) gStyle.SetStatW(0.3) gStyle.SetTitleFillColor(0) #gStyle.SetTitleY(1.) #gStyle.SetTitleX(.1) gStyle.SetTitleBorderSize(0) gStyle.SetHistLineWidth(2) gStyle.SetFrameFillColor(0) #gStyle.SetLineWidth(2) #gStyle.SetTitleColor(0) #gStyle.SetTitleColor(1) gStyle.SetLabelSize(0.05, "x") gStyle.SetLabelSize(0.05, "y") gStyle.SetLabelOffset(0.02, "y") gStyle.SetTitleOffset(1.8, "y") gStyle.SetTitleSize(0.04, "y") gStyle.SetPadRightMargin(0.02) gStyle.SetPadLeftMargin(0.14) # Used to be 0.20 --> Salva gStyle.SetPadBottomMargin(0.14)
def create_canvas(self): self._canvas = TCanvas(self._name, self._name) gStyle.SetCanvasBorderMode(0) gStyle.SetPadBorderMode(0) self._canvas.cd()
def set_pub_style(): from ROOT import gStyle # No Canvas Border gStyle.SetCanvasBorderMode(0) gStyle.SetCanvasBorderSize(0) # White BG gStyle.SetCanvasColor(10) # Format for axes gStyle.SetLabelFont(42, 'xyz') gStyle.SetLabelSize(0.05, 'xyz') gStyle.SetLabelOffset(0.01, 'xyz') # gStyle->SetNdivisions(510, 'xyz') gStyle.SetTitleFont(42, 'xyz') gStyle.SetTitleColor(1, 'xyz') gStyle.SetTitleSize(0.06, 'xyz') gStyle.SetTitleOffset(1.25, 'xyz') # No pad borders gStyle.SetPadBorderMode(0) gStyle.SetPadBorderSize(0) # White BG gStyle.SetPadColor(10) # Margins for labels etc. gStyle.SetPadLeftMargin(0.155) gStyle.SetPadBottomMargin(0.155) gStyle.SetPadRightMargin(0.15) gStyle.SetPadTopMargin(0.1) # No error bars in x direction gStyle.SetErrorX(0) # Format legend gStyle.SetLegendBorderSize(0)
def setstyle(self): # Delete previous PostScript plots and set Canvas options gSystem.Exec('rm -f ' + 'D0.pdf') gSystem.Exec('rm -f ' + 'Fit.pdf') gStyle.SetCanvasBorderMode(0) gStyle.SetCanvasColor(0) gStyle.SetStatBorderSize(1) gStyle.SetStatColor(0)
def Init(): from ROOT import gStyle from ROOT import gROOT gROOT.ProcessLine("gErrorIgnoreLevel = 2000;") gStyle.SetCanvasColor(0); gStyle.SetCanvasBorderMode(0); gStyle.SetCanvasBorderSize(3); gStyle.SetPadLeftMargin(0.125); gStyle.SetPadBottomMargin(0.12); gStyle.SetPadColor(0); gStyle.SetPadBorderMode(0); gStyle.SetFrameBorderMode(0); gStyle.SetFrameBorderSize(0); gStyle.SetFrameFillColor(0); gStyle.SetOptStat(0); gStyle.SetLabelOffset(0.005,"X"); gStyle.SetLabelSize(0.03,"X"); gStyle.SetLabelFont(42,"X"); gStyle.SetTitleOffset(.85,"X"); gStyle.SetTitleSize(0.04,"X"); gStyle.SetTitleFont(42,"X"); gStyle.SetLabelOffset(0.005,"Y"); gStyle.SetLabelSize(0.03,"Y"); gStyle.SetLabelFont(42,"Y"); gStyle.SetTitleOffset(.98,"Y"); gStyle.SetTitleSize(0.04,"Y"); gStyle.SetTitleFont(42,"Y"); gStyle.SetStatColor(0); gStyle.SetStatBorderSize(0); gStyle.SetTextFont(2); gStyle.SetTextSize(.05); gStyle.SetLegendBorderSize(1); gStyle.SetHistLineWidth(2); gStyle.SetTitleFillColor(0); gStyle.SetTitleFontSize(0.06); gStyle.SetTitleBorderSize(0); gStyle.SetTitleAlign(13); gStyle.SetTextAlign(22); #RJ gStyle.SetPadTickX(1); gStyle.SetPadTickY(1); gStyle.SetPadTopMargin(0.05); gStyle.SetPadBottomMargin(0.13); gStyle.SetPadLeftMargin(0.16); gStyle.SetPadRightMargin(0.03);
def Styling(): # Center title gStyle.SetTitleAlign(22) gStyle.SetTitleX(.5) gStyle.SetTitleY(.95) gStyle.SetTitleBorderSize(0) # Remove stats box gStyle.SetOptStat(0) # Set background color to white gStyle.SetFillColor(10) gStyle.SetFrameFillColor(10) gStyle.SetCanvasColor(10) gStyle.SetPadColor(10) gStyle.SetTitleFillColor(0) gStyle.SetStatColor(10) # No colored frames around plots gStyle.SetFrameBorderMode(0) gStyle.SetCanvasBorderMode(0) gStyle.SetPadBorderMode(0) # Set the default line color for a fit function to be red gStyle.SetFuncColor(2) # Marker settings gStyle.SetMarkerStyle(20) # No border on legends gStyle.SetLegendBorderSize(0) # Disabled for violating NOvA style guidelines # Scientific notation on axes TGaxis.SetMaxDigits(3) # Axis titles gStyle.SetTitleSize(.055, "xyz") gStyle.SetTitleOffset(2.2, "xyz") gStyle.SetTitleOffset(2.2, "y") gStyle.SetTitleSize(.05, "") gStyle.SetTitleOffset(2.2, "") # Axis labels (numbering) gStyle.SetLabelSize(.05, "xyz") gStyle.SetLabelOffset(.005, "xyz") # Thicker lines gStyle.SetHistLineWidth(2) gStyle.SetFrameLineWidth(2) gStyle.SetFuncWidth(2) # Set the number of tick marks gStyle.SetNdivisions(506, "xyz") # Set tick marks on all sides gStyle.SetPadTickX(1) gStyle.SetPadTickY(1) # Fonts kNovaFont = 42 gStyle.SetStatFont(kNovaFont) gStyle.SetLabelFont(kNovaFont, "xyz") gStyle.SetTitleFont(kNovaFont, "xyz") gStyle.SetTitleFont(kNovaFont, "") # Apply same settings to titles gStyle.SetTextFont(kNovaFont) gStyle.SetLegendFont(kNovaFont)
def looks(): gROOT.ProcessLine('TGaxis::SetMaxDigits(3)') gStyle.SetFrameBorderMode(0) gStyle.SetFrameFillColor(0) gStyle.SetCanvasBorderMode(0) gStyle.SetCanvasColor(0) gStyle.SetPadBorderMode(0) gStyle.SetPadColor(0) gStyle.SetStatColor(0) gStyle.SetTitleFont(42, '') gStyle.SetLabelFont(42, 'x') gStyle.SetTitleFont(42, 'x') gStyle.SetLabelFont(42, 'y') gStyle.SetTitleFont(42, 'y') gStyle.SetLabelFont(42, 'z') gStyle.SetTitleFont(42, 'z') gStyle.SetLabelSize(0.048, 'x') gStyle.SetTitleSize(0.048, 'x') gStyle.SetLabelSize(0.048, 'y') gStyle.SetTitleSize(0.048, 'y') gStyle.SetLabelSize(0.048, 'z') gStyle.SetTitleSize(0.048, 'z') gStyle.SetTitleSize(0.048, '') gStyle.SetTitleAlign(23) gStyle.SetTitleX(0.5) gStyle.SetTitleBorderSize(0) gStyle.SetTitleFillColor(0) gStyle.SetTitleStyle(0) gStyle.SetOptStat('emr') gStyle.SetOptStat(0) gStyle.SetStatBorderSize(0) gStyle.SetStatFont(42) gStyle.SetStatFontSize(0.048) gStyle.SetStatY(0.9) gStyle.SetStatX(0.86) gStyle.SetHistLineColor(ROOT.kBlue + 2) gStyle.SetLegendBorderSize(0) gStyle.SetLegendFillColor(0) gStyle.SetFuncWidth(2) gStyle.SetFuncColor(2) gStyle.SetPadTopMargin(0.08) gStyle.SetPadBottomMargin(0.12) gStyle.SetPadLeftMargin(0.12) gStyle.SetPadRightMargin(0.06) gStyle.SetCanvasDefX(400) gStyle.SetCanvasDefY(20) gStyle.SetCanvasDefH(420) gStyle.SetCanvasDefW(610) gStyle.SetFrameBorderMode(0) gStyle.SetFrameLineWidth(2) gStyle.SetHistLineWidth(2) gStyle.SetTitleOffset(1.16, 'y') gStyle.SetTitleOffset(1.20, 'x')
def create_canvas(self): self._canvas = TCanvas(self._name, self._name) if self._stats: self._canvas.SetRightMargin(0.183908) self._canvas.SetTopMargin(0.06991526) gStyle.SetOptStat("mreou") gStyle.SetCanvasBorderMode(0) gStyle.SetPadBorderMode(0) self._canvas.cd()
def set_root_style(stat=1110, grid=0, PadTopMargin=0.08, PadLeftMargin=0.10, TitleOffsetY=1.2): # must be used in the beginning from ROOT import gROOT, gStyle gROOT.SetBatch(1) gROOT.Reset() gStyle.SetOptTitle(1) gStyle.SetTitleFillColor(0) gStyle.SetTitleBorderSize(0) # gStyle.SetTitleFont(22) # gStyle.SetStatFont(22) # gStyle.SetStatColor(1) # gStyle.SetLabelFont(22,"X") # gStyle.SetLabelFont(22,"Y") gStyle.SetCanvasBorderMode(0) gStyle.SetCanvasColor(0) gStyle.SetCanvasDefX(0) gStyle.SetCanvasDefY(0) gStyle.SetFrameBorderMode(0) gStyle.SetFrameBorderSize(1) gStyle.SetFrameFillColor(0) gStyle.SetFrameFillStyle(0) gStyle.SetFrameLineColor(1) gStyle.SetFrameLineStyle(1) gStyle.SetFrameLineWidth(1) gStyle.SetPadTopMargin(PadTopMargin) gStyle.SetPadLeftMargin(PadLeftMargin) gStyle.SetPadRightMargin(0.05) gStyle.SetLabelSize(0.03, "XYZ") gStyle.SetTitleSize(0.04, "XYZ") gStyle.SetTitleOffset(TitleOffsetY, "Y") gStyle.SetPadBorderMode(0) gStyle.SetPadColor(0) gStyle.SetPadTickX(1) gStyle.SetPadTickY(1) gStyle.SetPadGridX(grid) gStyle.SetPadGridY(grid) gStyle.SetOptStat(stat) gStyle.SetStatColor(0) gStyle.SetStatBorderSize(1)
def setStyle(): gROOT.Reset() icol = 0 # WHITE font = 42 # Helvetica tsize = 0.05 gStyle.SetFrameBorderMode(icol) gStyle.SetFrameFillColor(icol) gStyle.SetCanvasBorderMode(icol) gStyle.SetCanvasColor(icol) gStyle.SetPadBorderMode(icol) gStyle.SetPadColor(icol) gStyle.SetStatColor(icol) gStyle.SetPaperSize(20, 26) gStyle.SetPadTopMargin(0.05) gStyle.SetPadRightMargin(0.08) gStyle.SetPadBottomMargin(0.15) gStyle.SetPadLeftMargin(0.12) gStyle.SetTitleXOffset(1.05) gStyle.SetTitleYOffset(0.95) gStyle.SetTextFont(font) gStyle.SetTextSize(tsize) gStyle.SetLabelFont(font, "x") gStyle.SetTitleFont(font, "x") gStyle.SetLabelFont(font, "y") gStyle.SetTitleFont(font, "y") gStyle.SetLabelFont(font, "z") gStyle.SetTitleFont(font, "z") gStyle.SetLabelSize(tsize * 0.85, "x") gStyle.SetTitleSize(tsize * 1.10, "x") gStyle.SetLabelSize(tsize * 0.85, "y") gStyle.SetTitleSize(tsize * 1.10, "y") gStyle.SetLabelSize(tsize * 0.85, "z") gStyle.SetTitleSize(tsize * 1.10, "z") gStyle.SetMarkerStyle(20) gStyle.SetMarkerSize(1.) gStyle.SetHistLineWidth(2) gStyle.SetLineStyleString(2, "[12 12]") # postscript dashes gStyle.SetEndErrorSize(0.) # gStyle.SetOptTitle(0); gStyle.SetOptStat(0) gStyle.SetOptFit(0) gStyle.SetPadTickX(1) gStyle.SetPadTickY(1) gStyle.SetPaintTextFormat("4.1f")
def set_fancy_2D_style(): icol = 0 gStyle.SetFrameBorderMode(icol) gStyle.SetFrameFillColor(icol) gStyle.SetCanvasBorderMode(icol) gStyle.SetCanvasColor(icol) gStyle.SetPadBorderMode(icol) gStyle.SetPadColor(icol) gStyle.SetStatColor(icol) gStyle.SetOptTitle(0) gStyle.SetOptStat(0) gStyle.SetOptFit(0) ncontours = 999 s = array('d', [0.00, 0.34, 0.61, 0.84, 1.00]) r = array('d', [0.00, 0.00, 0.87, 1.00, 0.51]) g = array('d', [0.00, 0.81, 1.00, 0.20, 0.00]) b = array('d', [0.51, 1.00, 0.12, 0.00, 0.00]) npoints = len(s) TColor.CreateGradientColorTable(npoints, s, r, g, b, ncontours) gStyle.SetNumberContours(ncontours)
def tdrstyle(): gROOT.SetStyle("Plain") gStyle.SetAxisColor(1, "XYZ") gStyle.SetCanvasColor(0) #gStyle.SetCanvasBorderSize(10) gStyle.SetCanvasBorderMode(0) gStyle.SetCanvasDefH(700) gStyle.SetCanvasDefW(700) gStyle.SetCanvasDefX(0) gStyle.SetCanvasDefY(0) gStyle.SetFitFormat("5.4g") gStyle.SetFuncColor(2) gStyle.SetFuncStyle(1) gStyle.SetFuncWidth(1) gStyle.SetFrameBorderMode(0) gStyle.SetFrameBorderSize(1) gStyle.SetFrameFillStyle(0) gStyle.SetFrameFillColor(0) gStyle.SetFrameLineColor(1) gStyle.SetFrameLineStyle(1) # 0? gStyle.SetFrameLineWidth(1) # 1? gStyle.SetGridColor(0) gStyle.SetGridStyle(3) gStyle.SetGridWidth(1) #gStyle.SetHistFillColor(1) #gStyle.SetHistFillStyle(0) gStyle.SetHistLineColor(1) gStyle.SetHistLineStyle(0) gStyle.SetHistLineWidth(1) gStyle.SetLabelColor(1, "XYZ") gStyle.SetLabelFont(42,"XYZ") gStyle.SetLabelOffset(0.007,"XYZ") # 0.010? gStyle.SetLabelSize(0.05,"XYZ") # 0.04? gStyle.SetLegendBorderSize(0) gStyle.SetLegendFillColor(0) gStyle.SetLegendFont(42) gStyle.SetMarkerSize(1.0) gStyle.SetMarkerStyle(20) gStyle.SetLineColor(1) gStyle.SetLineWidth(2) #gStyle.SetLineScalePS(2) gStyle.SetOptDate(0) gStyle.SetOptFile(0) gStyle.SetOptFit(1) gStyle.SetOptStat(0) gStyle.SetOptTitle(0) #gStyle.SetOptLogx(0) #gStyle.SetOptLogy(0) #gStyle.SetOptLogz(0) gStyle.SetPadColor(0) gStyle.SetPadBorderMode(0) gStyle.SetPadBorderSize(10) gStyle.SetPadTopMargin(0.05) # 0.08? gStyle.SetPadBottomMargin(0.13) gStyle.SetPadLeftMargin(0.16) gStyle.SetPadRightMargin(0.03) # 0.05? gStyle.SetPadGridX(0) gStyle.SetPadGridY(0) gStyle.SetPadTickX(1) gStyle.SetPadTickY(1) gStyle.SetStatColor(0) gStyle.SetStatFont(42) gStyle.SetStatFontSize(0.025) gStyle.SetStatTextColor(1) gStyle.SetStatFormat("6.4g") gStyle.SetStatBorderSize(1) gStyle.SetStatH(0.1) gStyle.SetStatW(0.15) #gStyle.SetStatX(0) #gStyle.SetStatY(0) #gStyle.SetTextSize(0.055) gStyle.SetTextFont(42) gStyle.SetTitleBorderSize(0) gStyle.SetTitleColor(1) gStyle.SetTitleFont(42) gStyle.SetTitleColor(1,"XYZ") gStyle.SetTitleFont(42,"XYZ") gStyle.SetTitleSize(0.06,"XYZ") # 0.05? #gStyle.SetTitleOffset(1.4,"XYZ") gStyle.SetTitleOffset(0.9,"X") gStyle.SetTitleOffset(1.20,"Y") gStyle.SetTitleFillColor(10) gStyle.SetTitleFontSize(0.05) gStyle.SetTitleTextColor(1) #gStyle.SetTitleH(0) #gStyle.SetTitleW(0) #gStyle.SetTitleX(0) #gStyle.SetTitleY(0.985) #gStyle.SetTitleStyle(1001) gStyle.SetPalette(1) #gStyle.SetNdivisions(510, "XYZ") # 505? gStyle.SetNdivisions(505, "XYZ") gStyle.SetEndErrorSize(2) # 2? #gStyle.SetErrorMarker(20) #gStyle.SetErrorX(0.) #gStyle.SetPaperSize(20.,20.) gStyle.SetStripDecimals(1) gStyle.SetTickLength(0.03, "XYZ") return 1
def setStyle(): gStyle.SetCanvasColor(0) gStyle.SetCanvasBorderSize(10) gStyle.SetCanvasBorderMode(0) gStyle.SetCanvasDefH(700) gStyle.SetCanvasDefW(700) gStyle.SetPadColor(0) gStyle.SetPadBorderSize(10) gStyle.SetPadBorderMode(0) gStyle.SetPadBottomMargin(0.13) gStyle.SetPadTopMargin(0.08) gStyle.SetPadLeftMargin(0.15) gStyle.SetPadRightMargin(0.05) gStyle.SetPadGridX(0) gStyle.SetPadGridY(0) gStyle.SetPadTickX(1) gStyle.SetPadTickY(1) gStyle.SetFrameFillStyle(0) gStyle.SetFrameFillColor(0) gStyle.SetFrameLineColor(1) gStyle.SetFrameLineStyle(0) gStyle.SetFrameLineWidth(1) gStyle.SetFrameBorderSize(10) gStyle.SetFrameBorderMode(0) gStyle.SetNdivisions(505) gStyle.SetLineWidth(2) gStyle.SetHistLineWidth(2) gStyle.SetFrameLineWidth(2) gStyle.SetLegendFillColor(root.kWhite) gStyle.SetLegendFont(42) gStyle.SetMarkerSize(1.2) gStyle.SetMarkerStyle(20) gStyle.SetLabelSize(0.040, "X") gStyle.SetLabelSize(0.040, "Y") gStyle.SetLabelOffset(0.010, "X") gStyle.SetLabelOffset(0.010, "Y") gStyle.SetLabelFont(42, "X") gStyle.SetLabelFont(42, "Y") gStyle.SetTitleBorderSize(0) gStyle.SetTitleFont(42) gStyle.SetTitleFont(42, "X") gStyle.SetTitleFont(42, "Y") gStyle.SetTitleSize(0.045, "X") gStyle.SetTitleSize(0.045, "Y") gStyle.SetTitleOffset(1.4, "X") gStyle.SetTitleOffset(1.4, "Y") gStyle.SetTextSize(0.055) gStyle.SetTextFont(42) gStyle.SetOptStat(0)
def initialize(fitresults=True, grid=False): gROOT.SetStyle("Plain") gStyle.SetOptFit() gStyle.SetOptStat(0) # For the canvas: gStyle.SetCanvasBorderMode(0) gStyle.SetCanvasColor(kWhite) gStyle.SetCanvasDefH(600) #Height of canvas gStyle.SetCanvasDefW(600) #Width of canvas gStyle.SetCanvasDefX(0) #POsition on screen gStyle.SetCanvasDefY(0) # For the Pad: gStyle.SetPadBorderMode(0) gStyle.SetPadColor(kWhite) gStyle.SetPadGridX(False) gStyle.SetPadGridY(False) gStyle.SetGridColor(0) gStyle.SetGridStyle(3) gStyle.SetGridWidth(1) # For the frame: gStyle.SetFrameBorderMode(0) gStyle.SetFrameBorderSize(1) gStyle.SetFrameFillColor(kWhite) gStyle.SetFrameFillStyle(1000) gStyle.SetFrameLineColor(1) gStyle.SetFrameLineStyle(1) gStyle.SetFrameLineWidth(1) # For the histo: gStyle.SetHistLineColor(1) gStyle.SetHistLineStyle(0) gStyle.SetHistLineWidth(2) gStyle.SetEndErrorSize(2) gStyle.SetErrorX(0.) gStyle.SetMarkerStyle(20) #For the fit/function: gStyle.SetOptFit(1) gStyle.SetFitFormat("5.4g") gStyle.SetFuncColor(2) gStyle.SetFuncStyle(1) gStyle.SetFuncWidth(1) #For the date: gStyle.SetOptDate(0) # For the statistics box: gStyle.SetOptFile(0) gStyle.SetOptStat(0) # To display the mean and RMS: SetOptStat("mr") gStyle.SetStatColor(kWhite) gStyle.SetStatFont(42) gStyle.SetStatFontSize(0.025) gStyle.SetStatTextColor(1) gStyle.SetStatFormat("6.4g") gStyle.SetStatBorderSize(1) gStyle.SetStatH(0.1) gStyle.SetStatW(0.15) # Margins: gStyle.SetPadTopMargin(0.05) gStyle.SetPadLeftMargin(0.16) gStyle.SetPadRightMargin(0.04) # top group adaption, original is 0.02 gStyle.SetPadBottomMargin(0.13) # For the Global title: gStyle.SetOptTitle(0) gStyle.SetTitleFont(42) gStyle.SetTitleColor(1) gStyle.SetTitleTextColor(1) gStyle.SetTitleFillColor(10) gStyle.SetTitleFontSize(0.05) # For the axis titles: gStyle.SetTitleColor(1, "XYZ") gStyle.SetTitleFont(42, "XYZ") gStyle.SetTitleSize(0.06, "XYZ") gStyle.SetTitleXOffset(0.9) gStyle.SetTitleYOffset(1.25) # For the axis labels: gStyle.SetLabelColor(1, "XYZ") gStyle.SetLabelFont(42, "XYZ") gStyle.SetLabelOffset(0.007, "XYZ") gStyle.SetLabelSize(0.05, "XYZ") #gStyle.SetLabelSize(0.04, "XYZ") # For the axis: gStyle.SetAxisColor(1, "XYZ") gStyle.SetStripDecimals(True) gStyle.SetTickLength(0.03, "XYZ") gStyle.SetNdivisions(510, "XYZ") gStyle.SetPadTickX(1) # To get tick marks on the opposite side of the frame gStyle.SetPadTickY(1) # Change for log plots: gStyle.SetOptLogx(0) gStyle.SetOptLogy(0) gStyle.SetOptLogz(0) gStyle.SetPalette(1) #(1,0) # another top group addition gStyle.SetHatchesSpacing(1.0) # Postscript options: gStyle.SetPaperSize(20., 20.) # For graphs gStyle.SetErrorX(0) # suppress error along x if grid: gStyle.SetPadGridX(gridOn) gStyle.SetPadGridY(gridOn) gStyle.SetGridColor(kGray)
print "You have requested both ratio and difference plots. Will make just ratio plots instead" arguments.makeRatioPlots = False if arguments.makeRatioPlots and arguments.noStack: print "You have asked to make a ratio plot and to not stack the backgrounds. This is a very strange request. Will skip making the ratio plot." arguments.makeRatioPlots = False if arguments.makeDiffPlots and arguments.noStack: print "You have asked to make a difference plot and to not stack the backgrounds. This is a very strange request. Will skip making the difference plot." arguments.makeDiffPlots = False from ROOT import TFile, gROOT, gStyle, gDirectory, TStyle, THStack, TH1F, TCanvas, TString, TLegend, TLegendEntry, THStack, TIter, TKey, TPaveLabel, TPaveText, TF1, gPad ### setting ROOT options so our plots will look awesome and everyone will love us gROOT.SetBatch() gStyle.SetOptStat(0) gStyle.SetCanvasBorderMode(0) gStyle.SetPadBorderMode(0) gStyle.SetPadColor(0) gStyle.SetCanvasColor(0) gStyle.SetTextFont(42) gStyle.SetCanvasDefH(600) gStyle.SetCanvasDefW(600) gStyle.SetCanvasDefX(0) gStyle.SetCanvasDefY(0) gStyle.SetPadTopMargin(0.07) gStyle.SetPadBottomMargin(0.13) gStyle.SetPadLeftMargin(0.15) gStyle.SetPadRightMargin(0.05) gStyle.SetTitleColor(1, "XYZ") gStyle.SetTitleFont(42, "XYZ") gStyle.SetTitleSize(0.04, "XYZ")
def applyRootStyle(): from ROOT import gROOT, gStyle, kWhite, kBlack, TColor # Start from a plain default gROOT.SetStyle("Plain") lhcbMarkerType = 8 lhcbMarkerSize = 0.8 lhcbFont = 62 lhcbStatFontSize = 0.02 lhcbStatBoxWidth = 0.12 lhcbStatBoxHeight = 0.12 lhcbWidth = 1 lhcbTextSize = 0.05 lhcbLabelSize = 0.035 lhcbAxisLabelSize = 0.035 lhcbForeColour = kBlack gStyle.SetFrameBorderMode(0) gStyle.SetPadBorderMode(0) # canvas options gStyle.SetCanvasBorderSize(0) gStyle.SetCanvasBorderMode(0) # fonts gStyle.SetTextFont(lhcbFont) gStyle.SetTextSize(lhcbTextSize) gStyle.SetLabelFont(lhcbFont, "x") gStyle.SetLabelFont(lhcbFont, "y") gStyle.SetLabelFont(lhcbFont, "z") gStyle.SetLabelSize(lhcbLabelSize, "x") gStyle.SetLabelSize(lhcbLabelSize, "y") gStyle.SetLabelSize(lhcbLabelSize, "z") gStyle.SetTitleFont(lhcbFont) gStyle.SetTitleSize(lhcbAxisLabelSize, "x") gStyle.SetTitleSize(lhcbAxisLabelSize, "y") gStyle.SetTitleSize(lhcbAxisLabelSize, "z") gStyle.SetTitleColor(kWhite) gStyle.SetTitleFillColor(kWhite) gStyle.SetTitleColor(kBlack) gStyle.SetTitleBorderSize(0) gStyle.SetTitleTextColor(kBlack) # set title position gStyle.SetTitleX(0.15) gStyle.SetTitleY(0.97) # turn off Title box gStyle.SetTitleBorderSize(0) gStyle.SetTitleTextColor(lhcbForeColour) gStyle.SetTitleColor(lhcbForeColour) # use bold lines and markers gStyle.SetLineWidth(lhcbWidth) gStyle.SetFrameLineWidth(lhcbWidth) gStyle.SetHistLineWidth(lhcbWidth) gStyle.SetFuncWidth(lhcbWidth) gStyle.SetGridWidth(lhcbWidth) gStyle.SetLineStyleString(2, "[12 12]") gStyle.SetMarkerStyle(lhcbMarkerType) gStyle.SetMarkerSize(lhcbMarkerSize) # Grid # gStyle.SetGridStyle(3) # label offsets gStyle.SetLabelOffset(0.015) # by default, do not display histogram decorations: gStyle.SetOptStat(1111) # show probability, parameters and errors gStyle.SetOptFit(1011) # look of the statistics box: gStyle.SetStatBorderSize(1) gStyle.SetStatFont(lhcbFont) gStyle.SetStatFontSize(lhcbStatFontSize) gStyle.SetStatX(0.9) gStyle.SetStatY(0.9) gStyle.SetStatW(lhcbStatBoxWidth) gStyle.SetStatH(lhcbStatBoxHeight) # put tick marks on top and RHS of plots gStyle.SetPadTickX(1) gStyle.SetPadTickY(1) # histogram divisions gStyle.SetNdivisions(505, "x") gStyle.SetNdivisions(510, "y") # Style for 2D zcol plots NRGBs = 5 NCont = 255 from array import array stops = array('d', [0.00, 0.34, 0.61, 0.84, 1.00]) red = array('d', [0.00, 0.00, 0.87, 1.00, 0.51]) green = array('d', [0.00, 0.81, 1.00, 0.20, 0.00]) blue = array('d', [0.51, 1.00, 0.12, 0.00, 0.00]) TColor().CreateGradientColorTable(NRGBs, stops, red, green, blue, NCont) gStyle.SetNumberContours(NCont) # Force the style gROOT.ForceStyle()
def setStyle(): TColor.InitializeColors() stops = array('d', [ 0.0000, 0.1250, 0.2500, 0.3750, 0.5000, 0.6250, 0.7500, 0.8750, 1.0000 ]) red = array('d', [ 0.9764, 0.9956, 0.8186, 0.5301, 0.1802, 0.0232, 0.0780, 0.0592, 0.2082 ]) green = array('d', [ 0.9832, 0.7862, 0.7328, 0.7492, 0.7178, 0.6419, 0.5041, 0.3599, 0.1664 ]) blue = array('d', [ 0.0539, 0.1968, 0.3499, 0.4662, 0.6425, 0.7914, 0.8385, 0.8684, 0.5293 ]) TColor.CreateGradientColorTable(9, stops, red, green, blue, 255, 1.0) gStyle.SetHatchesLineWidth(1) gStyle.SetNumberContours(255) gStyle.SetNdivisions(505, "xyz") gStyle.SetTitleBorderSize(0) gStyle.SetTitleColor(1) gStyle.SetTitleStyle(3013) gStyle.SetTitleFillColor(0) gStyle.SetTitleX(0.05) gStyle.SetTitleW(0.4) gStyle.SetTitleY(0.965) gStyle.SetTitleH(0.065) gStyle.SetCanvasBorderMode(0) gStyle.SetCanvasBorderSize(3) gStyle.SetCanvasColor(0) gStyle.SetPadColor(0) gStyle.SetPadBorderMode(0) gStyle.SetFuncWidth(3) gStyle.SetPadGridY(False) gStyle.SetPadGridX(False) gStyle.SetFrameLineWidth(1) gStyle.SetMarkerSize(5) gStyle.SetPadTickX(True) gStyle.SetPadTickY(True) #gStyle.SetPalette(1) gStyle.SetHistLineWidth(3) gStyle.SetHistLineColor(1) gStyle.SetOptStat(0) gStyle.SetOptFit(0) gStyle.SetStatW(0.25) gStyle.SetStatH(0.25) gStyle.SetStatX(0.9) gStyle.SetStatY(0.9) gStyle.SetStatColor(0) gStyle.SetStatFormat("6.4g") gStyle.SetPadTopMargin(0.05) gStyle.SetPadRightMargin(0.05) gStyle.SetPadBottomMargin(0.16) gStyle.SetPadLeftMargin(0.12) font = 42 gStyle.SetTextSize(.055) gStyle.SetTextFont(font) gStyle.SetLabelFont(font, "x") gStyle.SetTitleFont(font, "x") gStyle.SetLabelFont(font, "y") gStyle.SetTitleFont(font, "y") gStyle.SetLabelFont(font, "z") gStyle.SetTitleFont(font, "z") gStyle.SetTitleSize(.055, "x") gStyle.SetTitleSize(.055, "y") gStyle.SetTitleSize(.05, "z") gStyle.SetLabelSize(.05, "x") gStyle.SetLabelSize(.05, "y") gStyle.SetLabelSize(.05, "z") gStyle.SetLabelOffset(0.014, "x") gStyle.SetLabelOffset(0.006, "y") gStyle.SetLabelOffset(0.008, "z") gStyle.SetTitleOffset(1, "y") gStyle.SetTitleXOffset(1.2) # use bold lines and markers gStyle.SetMarkerStyle(20) gStyle.SetMarkerColor(1) gStyle.SetMarkerSize(1.2) gStyle.SetLineStyleString(2, "[12 12]") # postscript dashes gStyle.SetPadTickX(1) gStyle.SetPadTickY(1)
def main(): # usage description usage = "Example: ./scripts/plotSignificance.py -l logs -f qq --massrange 1200 6000 100" # input parameters parser = ArgumentParser(description='Script that plots significance for specified mass points',epilog=usage) parser.add_argument("-M", "--method", dest="method", choices=['MaxLikelihoodFit'], default='MaxLikelihoodFit', help="Method to calculate upper limits", metavar="METHOD") results_group = parser.add_mutually_exclusive_group(required=True) results_group.add_argument("-l", "--logs_path", dest="logs_path", help="Path to log files", metavar="LOGS_PATH") results_group.add_argument("-r", "--results_file", dest="results_file", help="Path to a file containing results", metavar="RESULTS_FILE") parser.add_argument("-f", "--final_state", dest="final_state", required=True, help="Final state (e.g. qq, qg, gg)", metavar="FINAL_STATE") parser.add_argument("--postfix", dest="postfix", default='', help="Postfix for the output plot name (default: %(default)s)") parser.add_argument("--fileFormat", dest="fileFormat", default='pdf', help="Format of the output plot (default: %(default)s)") parser.add_argument("--extraText", dest="extraText", default='Simulation Preliminary', help="Extra text on the plot (default: %(default)s)") parser.add_argument("--lumi_sqrtS", dest="lumi_sqrtS", default='1 fb^{-1} (13 TeV)', help="Integrated luminosity and center-of-mass energy (default: %(default)s)") parser.add_argument("--printResults", dest="printResults", default=False, action="store_true", help="Print results to the screen") mass_group = parser.add_mutually_exclusive_group(required=True) mass_group.add_argument("--mass", type=int, nargs = '*', default = 1000, help="Mass can be specified as a single value or a whitespace separated list (default: %(default)i)" ) mass_group.add_argument("--massrange", type=int, nargs = 3, help="Define a range of masses to be produced. Format: min max step", metavar = ('MIN', 'MAX', 'STEP') ) mass_group.add_argument("--masslist", help = "List containing mass information" ) args = parser.parse_args() # mass points for which resonance shapes will be produced input_masses = [] if args.massrange != None: MIN, MAX, STEP = args.massrange input_masses = range(MIN, MAX+STEP, STEP) elif args.masslist != None: # A mass list was provided print "Will create mass list according to", args.masslist masslist = __import__(args.masslist.replace(".py","")) input_masses = masslist.masses else: input_masses = args.mass # sort masses input_masses.sort() # arrays holding results masses = array('d') sig = array('d') sig_ex = array('d') sig_eyl = array('d') sig_eyh = array('d') if args.logs_path != None: logs_path = os.path.join(os.getcwd(),args.logs_path) for mass in input_masses: print ">> Reading results for %s resonance with m = %i GeV..."%(args.final_state, int(mass)) masses.append(mass) logName = 'signal_xs_%s_%s_m%i.log'%(args.method,args.final_state,int(mass)) log_file = open(os.path.join(logs_path,logName),'r') # read the log file for line in log_file: if re.search("^Best fit r:", line): sig.append(float(line.split()[3])) sig_eyl.append(float(line.split()[4].split('/')[0].lstrip('-'))) sig_eyh.append(float(line.split()[4].split('/')[1].lstrip('+'))) sig_ex.append(0.) if len(masses) != len(sig): print "** WARNING: ** Fit failed for m =", int(mass), "GeV. Setting signal cross section to 0." sig.append(0.) sig_eyl.append(0.) sig_eyh.append(0.) else: print ">> Importing results..." sys.path.insert(0, os.path.dirname(args.results_file)) results = __import__(os.path.basename(args.results_file).replace(".py","")) all_masses = np.array(results.masses) indices = [] # search for indices of input_masses for mass in input_masses: where = np.where(all_masses==mass)[0] if len(where) == 0: print "** WARNING: ** Cannot find results for m =", int(mass), "GeV in the provided results file. Skipping this mass point." indices.extend( where ) # sort indices indices.sort() for i in indices: masses.append( results.masses[i] ) sig.append( results.sig[i] ) sig_ex.append( results.sig_ex[i] ) sig_eyl.append( results.sig_eyl[i] ) sig_eyh.append( results.sig_eyh[i] ) if args.printResults: print "masses =", masses.tolist() print "sig =", sig.tolist() print "sig_ex =", sig_ex.tolist() print "sig_eyl =", sig_eyl.tolist() print "sig_eyh =", sig_eyh.tolist() # create final arrays sig_pos = array('d') sig_exl = array('d') sig_exh = array('d') # fill final arrays for i in range(0,len(masses)): sig_pos.append(sig[i] if sig[i]>0. else 0.) sig_exl.append(sig_ex[i]) sig_exh.append(sig_ex[i]) sig_eyl.append(sig_eyl[i] if sig[i]>0. else 0.) sig_eyh.append(sig_eyh[i]) # import ROOT stuff from ROOT import kTRUE, kFALSE, gROOT, gStyle, gPad, TGraphAsymmErrors, TCanvas, TLegend from ROOT import kGreen, kYellow, kWhite, kRed, kBlue gROOT.SetBatch(kTRUE); gStyle.SetOptStat(0) gStyle.SetOptTitle(0) gStyle.SetTitleFont(42, "XYZ") gStyle.SetTitleSize(0.06, "XYZ") gStyle.SetLabelFont(42, "XYZ") gStyle.SetLabelSize(0.05, "XYZ") gStyle.SetCanvasBorderMode(0) gStyle.SetFrameBorderMode(0) gStyle.SetCanvasColor(kWhite) gStyle.SetPadTickX(1) gStyle.SetPadTickY(1) gStyle.SetPadLeftMargin(0.15) gStyle.SetPadRightMargin(0.05) gStyle.SetPadTopMargin(0.05) gStyle.SetPadBottomMargin(0.15) gROOT.ForceStyle() graph_sig = TGraphAsymmErrors(len(masses),masses,sig_pos,sig_exl,sig_exh,sig_eyl,sig_eyh) graph_sig.GetXaxis().SetTitle("%s resonance mass [GeV]"%(args.final_state)) graph_sig.GetYaxis().SetTitle("Signal cross section [pb]") graph_sig.GetYaxis().SetTitleOffset(1.2) graph_sig.GetYaxis().SetRangeUser(1e-4,2e2) graph_sig.SetMarkerStyle(20) graph_sig.SetMarkerColor(1) graph_sig.SetLineWidth(2) graph_sig.SetLineStyle(1) graph_sig.SetLineColor(1) c = TCanvas("c", "",800,800) c.cd() graph_sig.Draw("AP") # draw the lumi text on the canvas CMS_lumi.extraText = args.extraText CMS_lumi.lumi_sqrtS = args.lumi_sqrtS # used with iPeriod = 0 (free form) iPos = 11 iPeriod = 0 CMS_lumi.CMS_lumi(c, iPeriod, iPos) gPad.RedrawAxis() c.SetLogy() c.SetGridx() c.SetGridy() fileName = 'signal_xs_%s_%s.%s'%(args.method,args.final_state + ( ('_' + args.postfix) if args.postfix != '' else '' ), args.fileFormat.lower()) c.SaveAs(fileName) print "Plot saved to '%s'"%(fileName)
def main(): # usage description usage = "Example: ./scripts/plotLimits.py -M Asymptotic -l logs -f qq --massrange 1200 7000 100" # input parameters parser = ArgumentParser( description='Script that plots limits for specified mass points', epilog=usage) parser.add_argument("-M", "--method", dest="method", required=True, choices=[ 'ProfileLikelihood', 'HybridNew', 'Asymptotic', 'MarkovChainMC', 'theta' ], help="Method to calculate upper limits", metavar="METHOD") results_group = parser.add_mutually_exclusive_group(required=True) results_group.add_argument("-l", "--logs_path", dest="logs_path", help="Path to log files", metavar="LOGS_PATH") results_group.add_argument("-r", "--results_file", dest="results_file", help="Path to a file containing results", metavar="RESULTS_FILE") parser.add_argument("-f", "--final_state", dest="final_state", required=True, help="Final state (e.g. qq, qg, gg)", metavar="FINAL_STATE") parser.add_argument( "--postfix", dest="postfix", default='', help="Postfix for the output plot name (default: %(default)s)") parser.add_argument( "--fileFormat", dest="fileFormat", default='pdf', help="Format of the output plot (default: %(default)s)") parser.add_argument("--extraText", dest="extraText", default='Simulation Preliminary', help="Extra text on the plot (default: %(default)s)") parser.add_argument( "--lumi_sqrtS", dest="lumi_sqrtS", default='1 fb^{-1} (13 TeV)', help= "Integrated luminosity and center-of-mass energy (default: %(default)s)" ) parser.add_argument("--printResults", dest="printResults", default=False, action="store_true", help="Print results to the screen") mass_group = parser.add_mutually_exclusive_group(required=True) mass_group.add_argument( "--mass", type=int, nargs='*', default=1000, help= "Mass can be specified as a single value or a whitespace separated list (default: %(default)i)" ) mass_group.add_argument( "--massrange", type=int, nargs=3, help="Define a range of masses to be produced. Format: min max step", metavar=('MIN', 'MAX', 'STEP')) mass_group.add_argument("--masslist", help="List containing mass information") args = parser.parse_args() # mass points for which resonance shapes will be produced input_masses = [] if args.massrange != None: MIN, MAX, STEP = args.massrange input_masses = range(MIN, MAX + STEP, STEP) elif args.masslist != None: # A mass list was provided print "Will create mass list according to", args.masslist masslist = __import__(args.masslist.replace(".py", "")) input_masses = masslist.masses else: input_masses = args.mass # sort masses input_masses.sort() # arrays holding results masses = array('d') xs_obs_limits = array('d') xs_exp_limits = array('d') masses_exp = array('d') xs_exp_limits_1sigma = array('d') xs_exp_limits_1sigma_up = array('d') xs_exp_limits_2sigma = array('d') xs_exp_limits_2sigma_up = array('d') if args.logs_path != None: logs_path = os.path.join(os.getcwd(), args.logs_path) for mass in input_masses: print ">> Reading results for %s resonance with m = %i GeV..." % ( args.final_state, int(mass)) masses.append(mass) if args.method == 'Asymptotic': masses_exp.append(mass) logName = 'limits_%s_%s_m%i.log' % (args.method, args.final_state, int(mass)) if args.method == 'theta': logName = logName.replace('limits_', '') log_file = open(os.path.join(logs_path, logName), 'r') foundMethod = False # read the log file for line in log_file: if args.method == 'Asymptotic': if re.search("^Observed Limit: r", line): xs_obs_limits.append(float(line.split()[-1])) if re.search("^Expected 50.0%: r", line): xs_exp_limits.append(float(line.split()[-1])) if re.search("^Expected 16.0%: r", line): xs_exp_limits_1sigma.append(float(line.split()[-1])) if re.search("^Expected 84.0%: r", line): xs_exp_limits_1sigma_up.append(float(line.split()[-1])) if re.search("^Expected 2.5%: r", line): xs_exp_limits_2sigma.append(float(line.split()[-1])) if re.search("^Expected 97.5%: r", line): xs_exp_limits_2sigma_up.append(float(line.split()[-1])) elif args.method == 'theta': if re.search('^# x; y; yerror', line): foundMethod = True if line.split()[0] == '0' and foundMethod: xs_obs_limits.append(float(line.split()[1])) else: if re.search(' -- ' + args.method, line): foundMethod = True if re.search("^Limit: r", line) and foundMethod: xs_obs_limits.append(float(line.split()[3])) if len(masses) != len(xs_obs_limits): print "** ERROR: ** Could not find observed limit for m =", int( mass), "GeV. Aborting." sys.exit(1) if args.method == 'Asymptotic': if len(masses) != len(xs_exp_limits): print "** ERROR: ** Could not find expected limit for m =", int( mass), "GeV. Aborting." sys.exit(1) if len(masses) != len(xs_exp_limits_1sigma): print "** ERROR: ** Could not find expected 1 sigma down limit for m =", int( mass), "GeV. Aborting." sys.exit(1) if len(masses) != len(xs_exp_limits_1sigma_up): print "** ERROR: ** Could not find expected 1 sigma up limit for m =", int( mass), "GeV. Aborting." sys.exit(1) if len(masses) != len(xs_exp_limits_2sigma): print "** ERROR: ** Could not find expected 2 sigma down limit for m =", int( mass), "GeV. Aborting." sys.exit(1) if len(masses) != len(xs_exp_limits_2sigma_up): print "** ERROR: ** Could not find expected 2 sigma up limit for m =", int( mass), "GeV. Aborting." sys.exit(1) if args.method == 'Asymptotic': # complete the expected limit arrays for i in range(0, len(masses)): masses_exp.append(masses[len(masses) - i - 1]) xs_exp_limits_1sigma.append( xs_exp_limits_1sigma_up[len(masses) - i - 1]) xs_exp_limits_2sigma.append( xs_exp_limits_2sigma_up[len(masses) - i - 1]) else: print ">> Importing results..." sys.path.insert(0, os.path.dirname(args.results_file)) results = __import__( os.path.basename(args.results_file).replace(".py", "")) all_masses = np.array(results.masses) all_masses_exp = np.array(results.masses_exp) indices = [] indices_exp = [] # search for indices of input_masses for mass in input_masses: where = np.where(all_masses == mass)[0] if len(where) == 0: print "** WARNING: ** Cannot find results for m =", int( mass ), "GeV in the provided results file. Skipping this mass point." indices.extend(where) if len(all_masses_exp) > 0: where = np.where(all_masses_exp == mass)[0] if len(where) == 0: print "** WARNING: ** Cannot find results for m =", int( mass ), "GeV in the provided results file. Skipping this mass point." indices_exp.extend(where) # sort indices indices.sort() indices_exp.sort() for i in indices: masses.append(results.masses[i]) xs_obs_limits.append(results.xs_obs_limits[i]) if len(all_masses_exp) > 0: xs_exp_limits.append(results.xs_exp_limits[i]) for i in indices_exp: masses_exp.append(results.masses_exp[i]) xs_exp_limits_1sigma.append(results.xs_exp_limits_1sigma[i]) xs_exp_limits_2sigma.append(results.xs_exp_limits_2sigma[i]) if args.printResults: print "masses =", masses.tolist() print "xs_obs_limits =", xs_obs_limits.tolist() print "xs_exp_limits =", xs_exp_limits.tolist() print "" print "masses_exp =", masses_exp.tolist() print "xs_exp_limits_1sigma =", xs_exp_limits_1sigma.tolist() print "xs_exp_limits_2sigma =", xs_exp_limits_2sigma.tolist() # import ROOT stuff from ROOT import kTRUE, kFALSE, gROOT, gStyle, gPad, TGraph, TCanvas, TLegend from ROOT import kGreen, kYellow, kWhite gROOT.SetBatch(kTRUE) gStyle.SetOptStat(0) gStyle.SetOptTitle(0) gStyle.SetTitleFont(42, "XYZ") gStyle.SetTitleSize(0.06, "XYZ") gStyle.SetLabelFont(42, "XYZ") gStyle.SetLabelSize(0.05, "XYZ") gStyle.SetCanvasBorderMode(0) gStyle.SetFrameBorderMode(0) gStyle.SetCanvasColor(kWhite) gStyle.SetPadTickX(1) gStyle.SetPadTickY(1) gStyle.SetPadLeftMargin(0.15) gStyle.SetPadRightMargin(0.05) gStyle.SetPadTopMargin(0.05) gStyle.SetPadBottomMargin(0.15) gROOT.ForceStyle() # theory curves: gg massesS8 = array('d', [ 1000.0, 1100.0, 1200.0, 1300.0, 1400.0, 1500.0, 1600.0, 1700.0, 1800.0, 1900.0, 2000.0, 2100.0, 2200.0, 2300.0, 2400.0, 2500.0, 2600.0, 2700.0, 2800.0, 2900.0, 3000.0, 3100.0, 3200.0, 3300.0, 3400.0, 3500.0, 3600.0, 3700.0, 3800.0, 3900.0, 4000.0, 4100.0, 4200.0, 4300.0, 4400.0, 4500.0, 4600.0, 4700.0, 4800.0, 4900.0, 5000.0, 5100.0, 5200.0, 5300.0, 5400.0, 5500.0, 5600.0, 5700.0, 5800.0, 5900.0, 6000.0 ]) xsS8 = array('d', [ 5.46E+02, 3.12E+02, 1.85E+02, 1.12E+02, 7.19E+01, 4.59E+01, 3.02E+01, 2.01E+01, 1.37E+01, 9.46E+00, 6.55E+00, 4.64E+00, 3.27E+00, 2.36E+00, 1.70E+00, 1.24E+00, 9.11E-01, 6.69E-01, 4.97E-01, 3.71E-01, 2.78E-01, 2.07E-01, 1.55E-01, 1.19E-01, 9.26E-02, 7.08E-02, 5.43E-02, 4.15E-02, 3.22E-02, 2.50E-02, 1.92E-02, 1.51E-02, 1.19E-02, 9.25E-03, 7.35E-03, 5.86E-03, 4.53E-03, 3.66E-03, 2.91E-03, 2.33E-03, 1.86E-03, 1.45E-03, 1.12E-03, 8.75E-04, 6.90E-04, 5.55E-04, 4.47E-04, 3.63E-04, 2.92E-04, 2.37E-04, 1.97E-04 ]) graph_xsS8 = TGraph(len(massesS8), massesS8, xsS8) graph_xsS8.SetLineWidth(3) graph_xsS8.SetLineStyle(8) graph_xsS8.SetLineColor(6) # theory curves: qg massesString = array('d', [ 1000.0, 1100.0, 1200.0, 1300.0, 1400.0, 1500.0, 1600.0, 1700.0, 1800.0, 1900.0, 2000.0, 2100.0, 2200.0, 2300.0, 2400.0, 2500.0, 2600.0, 2700.0, 2800.0, 2900.0, 3000.0, 3100.0, 3200.0, 3300.0, 3400.0, 3500.0, 3600.0, 3700.0, 3800.0, 3900.0, 4000.0, 4100.0, 4200.0, 4300.0, 4400.0, 4500.0, 4600.0, 4700.0, 4800.0, 4900.0, 5000.0, 5100.0, 5200.0, 5300.0, 5400.0, 5500.0, 5600.0, 5700.0, 5800.0, 5900.0, 6000.0, 6100.0, 6200.0, 6300.0, 6400.0, 6500.0, 6600.0, 6700.0, 6800.0, 6900.0, 7000.0, 7100.0, 7200.0, 7300.0, 7400.0, 7500.0, 7600.0, 7700.0, 7800.0, 7900.0, 8000.0, 8100.0, 8200.0, 8300.0, 8400.0, 8500.0, 8600.0, 8700.0, 8800.0, 8900.0, 9000.0, 9100., 9200., 9300., 9400., 9500., 9600., 9700., 9800., 9900., 10000. ]) xsString = array('d', [ 8316.184311558545, 5312.93137758767, 3435.0309937336524, 2304.4139502741305, 1569.8115447896687, 1090.9516635659693, 770.901859690924, 551.9206062572061, 399.69535383507633, 293.77957451762086, 218.15126842827823, 162.87634729465125, 123.17685479653694, 93.63530805932386, 71.53697229809124, 55.37491301647483, 42.75271508357369, 33.36378355470234, 26.06619302090876, 20.311817606835643, 16.1180931789545, 12.768644973921226, 10.142660425967444, 8.057990848043234, 6.400465846290908, 5.115134438331436, 4.132099789492928, 3.3193854239538734, 2.6581204529344302, 2.157554604919995, 1.7505176068913348, 1.4049155245498584, 1.140055677916783, 0.9253251132104159, 0.7522038169131606, 0.6119747371392215, 0.49612321727328523, 0.40492020959456737, 0.33091999402250655, 0.27017917021492555, 0.2201693919322846, 0.17830700070267996, 0.14564253802358157, 0.11940534430331146, 0.09694948234356839, 0.0793065371847468, 0.06446186373361917, 0.05282660618352478, 0.0428516302310620888, 0.0348997638039910363, 0.0283334766442618227, 0.0231416918363592127, 0.0187417921340763783, 0.0153501307395115115, 0.0124396534127133717, 0.0100542205744949455, 0.0081744954858627415, 0.0066338099362915941, 0.0053365711503318145, 0.00430912459914657443, 0.00346381039244064343, 0.00278602671711227174, 0.00225154342228859257, 0.0018082930150063248, 0.00143929440338502119, 0.0011581373956044489, 0.00091869589873893118, 0.00073410823691329855, 0.00058669382997948734, 0.0004661568745858897, 0.000368716655469570365, 0.000293168485206959169, 0.000230224535021638668, 0.000182317101888465142, 0.000143263359883433282, 0.000112630538527214965, 0.000088189175598406759, 0.000068708474367442343, 0.000053931726669273556, 0.0000416417855733682702, 0.0000326529676755488658, 0.0000254365480426201587, 0.0000198410151166864761, 0.0000154034425617473576, 0.0000119095554601641413, 9.2537574320108232e-6, 7.2155417437856749e-6, 5.6130924422251982e-6, 4.36634755605624901e-6, 3.39717456406994868e-6, 2.6766018046173896e-6 ]) massesQstar = array('d', [ 1000.0, 1100.0, 1200.0, 1300.0, 1400.0, 1500.0, 1600.0, 1700.0, 1800.0, 1900.0, 2000.0, 2100.0, 2200.0, 2300.0, 2400.0, 2500.0, 2600.0, 2700.0, 2800.0, 2900.0, 3000.0, 3100.0, 3200.0, 3300.0, 3400.0, 3500.0, 3600.0, 3700.0, 3800.0, 3900.0, 4000.0, 4100.0, 4200.0, 4300.0, 4400.0, 4500.0, 4600.0, 4700.0, 4800.0, 4900.0, 5000.0, 5100.0, 5200.0, 5300.0, 5400.0, 5500.0, 5600.0, 5700.0, 5800.0, 5900.0, 6000.0, 6100.0, 6200.0, 6300.0, 6400.0, 6500.0, 6600.0, 6700.0, 6800.0, 6900.0, 7000.0, 7100.0, 7200.0, 7300.0, 7400.0, 7500.0, 7600.0, 7700.0, 7800.0, 7900.0, 8000.0, 8100.0, 8200.0, 8300.0, 8400.0, 8500.0, 8600.0, 8700.0, 8800.0, 8900.0, 9000.0 ]) xsQstar = array('d', [ 0.4101E+03, 0.2620E+03, 0.1721E+03, 0.1157E+03, 0.7934E+02, 0.5540E+02, 0.3928E+02, 0.2823E+02, 0.2054E+02, 0.1510E+02, 0.1121E+02, 0.8390E+01, 0.6328E+01, 0.4807E+01, 0.3674E+01, 0.2824E+01, 0.2182E+01, 0.1694E+01, 0.1320E+01, 0.1033E+01, 0.8116E+00, 0.6395E+00, 0.5054E+00, 0.4006E+00, 0.3182E+00, 0.2534E+00, 0.2022E+00, 0.1616E+00, 0.1294E+00, 0.1038E+00, 0.8333E-01, 0.6700E-01, 0.5392E-01, 0.4344E-01, 0.3503E-01, 0.2827E-01, 0.2283E-01, 0.1844E-01, 0.1490E-01, 0.1205E-01, 0.9743E-02, 0.7880E-02, 0.6373E-02, 0.5155E-02, 0.4169E-02, 0.3371E-02, 0.2725E-02, 0.2202E-02, 0.1779E-02, 0.1437E-02, 0.1159E-02, 0.9353E-03, 0.7541E-03, 0.6076E-03, 0.4891E-03, 0.3935E-03, 0.3164E-03, 0.2541E-03, 0.2039E-03, 0.1635E-03, 0.1310E-03, 0.1049E-03, 0.8385E-04, 0.6699E-04, 0.5347E-04, 0.4264E-04, 0.3397E-04, 0.2704E-04, 0.2151E-04, 0.1709E-04, 0.1357E-04, 0.1077E-04, 0.8544E-05, 0.6773E-05, 0.5367E-05, 0.4251E-05, 0.3367E-05, 0.2666E-05, 0.2112E-05, 0.1673E-05, 0.1326E-05 ]) graph_xsString = TGraph(len(massesString), massesString, xsString) graph_xsString.SetLineWidth(3) graph_xsString.SetLineStyle(8) graph_xsString.SetLineColor(9) graph_xsQstar = TGraph(len(massesQstar), massesQstar, xsQstar) graph_xsQstar.SetLineWidth(3) graph_xsQstar.SetLineStyle(2) graph_xsQstar.SetLineColor(1) # theory curves: qq massesTh = array('d', [ 1000.0, 1100.0, 1200.0, 1300.0, 1400.0, 1500.0, 1600.0, 1700.0, 1800.0, 1900.0, 2000.0, 2100.0, 2200.0, 2300.0, 2400.0, 2500.0, 2600.0, 2700.0, 2800.0, 2900.0, 3000.0, 3100.0, 3200.0, 3300.0, 3400.0, 3500.0, 3600.0, 3700.0, 3800.0, 3900.0, 4000.0, 4100.0, 4200.0, 4300.0, 4400.0, 4500.0, 4600.0, 4700.0, 4800.0, 4900.0, 5000.0, 5100.0, 5200.0, 5300.0, 5400.0, 5500.0, 5600.0, 5700.0, 5800.0, 5900.0, 6000.0, 6100.0, 6200.0, 6300.0, 6400.0, 6500.0, 6600.0, 6700.0, 6800.0, 6900.0, 7000.0, 7100.0, 7200.0, 7300.0, 7400.0, 7500.0, 7600.0, 7700.0, 7800.0, 7900.0, 8000.0, 8100.0, 8200.0, 8300.0, 8400.0, 8500.0, 8600.0, 8700.0, 8800.0, 8900.0, 9000.0 ]) xsAxi = array('d', [ 0.1849E+03, 0.1236E+03, 0.8473E+02, 0.5937E+02, 0.4235E+02, 0.3069E+02, 0.2257E+02, 0.1680E+02, 0.1263E+02, 0.9577E+01, 0.7317E+01, 0.5641E+01, 0.4374E+01, 0.3411E+01, 0.2672E+01, 0.2103E+01, 0.1658E+01, 0.1312E+01, 0.1041E+01, 0.8284E+00, 0.6610E+00, 0.5294E+00, 0.4250E+00, 0.3417E+00, 0.2752E+00, 0.2220E+00, 0.1792E+00, 0.1449E+00, 0.1172E+00, 0.9487E-01, 0.7686E-01, 0.6219E-01, 0.5033E-01, 0.4074E-01, 0.3298E-01, 0.2671E-01, 0.2165E-01, 0.1755E-01, 0.1422E-01, 0.1152E-01, 0.9322E-02, 0.7539E-02, 0.6092E-02, 0.4917E-02, 0.3965E-02, 0.3193E-02, 0.2568E-02, 0.2062E-02, 0.1653E-02, 0.1323E-02, 0.1057E-02, 0.8442E-03, 0.6728E-03, 0.5349E-03, 0.4242E-03, 0.3357E-03, 0.2644E-03, 0.2077E-03, 0.1627E-03, 0.1271E-03, 0.9891E-04, 0.7686E-04, 0.5951E-04, 0.4592E-04, 0.3530E-04, 0.2704E-04, 0.2059E-04, 0.1562E-04, 0.1180E-04, 0.8882E-05, 0.6657E-05, 0.4968E-05, 0.3693E-05, 0.2734E-05, 0.2016E-05, 0.1481E-05, 0.1084E-05, 0.7903E-06, 0.5744E-06, 0.4160E-06, 0.3007E-06 ]) xsDiquark = array('d', [ 0.5824E+02, 0.4250E+02, 0.3172E+02, 0.2411E+02, 0.1862E+02, 0.1457E+02, 0.1153E+02, 0.9211E+01, 0.7419E+01, 0.6019E+01, 0.4912E+01, 0.4031E+01, 0.3323E+01, 0.2750E+01, 0.2284E+01, 0.1903E+01, 0.1590E+01, 0.1331E+01, 0.1117E+01, 0.9386E+00, 0.7900E+00, 0.6658E+00, 0.5618E+00, 0.4745E+00, 0.4010E+00, 0.3391E+00, 0.2869E+00, 0.2428E+00, 0.2055E+00, 0.1740E+00, 0.1473E+00, 0.1246E+00, 0.1055E+00, 0.8922E-01, 0.7544E-01, 0.6376E-01, 0.5385E-01, 0.4546E-01, 0.3834E-01, 0.3231E-01, 0.2720E-01, 0.2288E-01, 0.1922E-01, 0.1613E-01, 0.1352E-01, 0.1132E-01, 0.9463E-02, 0.7900E-02, 0.6584E-02, 0.5479E-02, 0.4551E-02, 0.3774E-02, 0.3124E-02, 0.2581E-02, 0.2128E-02, 0.1750E-02, 0.1437E-02, 0.1177E-02, 0.9612E-03, 0.7833E-03, 0.6366E-03, 0.5160E-03, 0.4170E-03, 0.3360E-03, 0.2700E-03, 0.2162E-03, 0.1725E-03, 0.1372E-03, 0.1087E-03, 0.8577E-04, 0.6742E-04, 0.5278E-04, 0.4114E-04, 0.3192E-04, 0.2465E-04, 0.1894E-04, 0.1448E-04, 0.1101E-04, 0.8322E-05, 0.6253E-05, 0.4670E-05 ]) xsWprime = array('d', [ 0.8811E+01, 0.6024E+01, 0.4216E+01, 0.3010E+01, 0.2185E+01, 0.1610E+01, 0.1200E+01, 0.9043E+00, 0.6875E+00, 0.5271E+00, 0.4067E+00, 0.3158E+00, 0.2464E+00, 0.1932E+00, 0.1521E+00, 0.1201E+00, 0.9512E-01, 0.7554E-01, 0.6012E-01, 0.4792E-01, 0.3827E-01, 0.3059E-01, 0.2448E-01, 0.1960E-01, 0.1571E-01, 0.1259E-01, 0.1009E-01, 0.8090E-02, 0.6483E-02, 0.5193E-02, 0.4158E-02, 0.3327E-02, 0.2660E-02, 0.2125E-02, 0.1695E-02, 0.1351E-02, 0.1075E-02, 0.8546E-03, 0.6781E-03, 0.5372E-03, 0.4248E-03, 0.3353E-03, 0.2642E-03, 0.2077E-03, 0.1629E-03, 0.1275E-03, 0.9957E-04, 0.7757E-04, 0.6027E-04, 0.4670E-04, 0.3610E-04, 0.2783E-04, 0.2140E-04, 0.1641E-04, 0.1254E-04, 0.9561E-05, 0.7269E-05, 0.5510E-05, 0.4167E-05, 0.3143E-05, 0.2364E-05, 0.1774E-05, 0.1329E-05, 0.9931E-06, 0.7411E-06, 0.5523E-06, 0.4108E-06, 0.3055E-06, 0.2271E-06, 0.1687E-06, 0.1254E-06, 0.9327E-07, 0.6945E-07, 0.5177E-07, 0.3863E-07, 0.2888E-07, 0.2162E-07, 0.1622E-07, 0.1218E-07, 0.9156E-08, 0.6893E-08 ]) xsZprime = array('d', [ 0.5027E+01, 0.3398E+01, 0.2353E+01, 0.1663E+01, 0.1196E+01, 0.8729E+00, 0.6450E+00, 0.4822E+00, 0.3638E+00, 0.2769E+00, 0.2123E+00, 0.1639E+00, 0.1272E+00, 0.9933E-01, 0.7789E-01, 0.6134E-01, 0.4848E-01, 0.3845E-01, 0.3059E-01, 0.2440E-01, 0.1952E-01, 0.1564E-01, 0.1256E-01, 0.1010E-01, 0.8142E-02, 0.6570E-02, 0.5307E-02, 0.4292E-02, 0.3473E-02, 0.2813E-02, 0.2280E-02, 0.1848E-02, 0.1499E-02, 0.1216E-02, 0.9864E-03, 0.8002E-03, 0.6490E-03, 0.5262E-03, 0.4264E-03, 0.3453E-03, 0.2795E-03, 0.2260E-03, 0.1826E-03, 0.1474E-03, 0.1188E-03, 0.9566E-04, 0.7690E-04, 0.6173E-04, 0.4947E-04, 0.3957E-04, 0.3159E-04, 0.2516E-04, 0.2001E-04, 0.1587E-04, 0.1255E-04, 0.9906E-05, 0.7795E-05, 0.6116E-05, 0.4785E-05, 0.3731E-05, 0.2900E-05, 0.2247E-05, 0.1734E-05, 0.1334E-05, 0.1022E-05, 0.7804E-06, 0.5932E-06, 0.4492E-06, 0.3388E-06, 0.2544E-06, 0.1903E-06, 0.1417E-06, 0.1051E-06, 0.7764E-07, 0.5711E-07, 0.4186E-07, 0.3055E-07, 0.2223E-07, 0.1612E-07, 0.1164E-07, 0.8394E-08 ]) graph_xsAxi = TGraph(len(massesTh), massesTh, xsAxi) graph_xsAxi.SetLineWidth(3) graph_xsAxi.SetLineStyle(3) graph_xsAxi.SetLineColor(63) graph_xsDiquark = TGraph(len(massesTh), massesTh, xsDiquark) graph_xsDiquark.SetLineWidth(3) graph_xsDiquark.SetLineStyle(9) graph_xsDiquark.SetLineColor(8) graph_xsWprime = TGraph(len(massesTh), massesTh, xsWprime) graph_xsWprime.SetLineWidth(3) graph_xsWprime.SetLineStyle(7) graph_xsWprime.SetLineColor(46) graph_xsZprime = TGraph(len(massesTh), massesTh, xsZprime) graph_xsZprime.SetLineWidth(3) graph_xsZprime.SetLineStyle(5) graph_xsZprime.SetLineColor(38) # limits graph_exp_2sigma = (TGraph(len(masses_exp), masses_exp, xs_exp_limits_2sigma) if len(xs_exp_limits_2sigma) > 0 else TGraph(0)) graph_exp_2sigma.SetFillColor(kYellow) graph_exp_1sigma = (TGraph(len(masses_exp), masses_exp, xs_exp_limits_1sigma) if len(xs_exp_limits_2sigma) > 0 else TGraph(0)) graph_exp_1sigma.SetFillColor(kGreen + 1) graph_exp = (TGraph(len(masses), masses, xs_exp_limits) if len(xs_exp_limits_2sigma) > 0 else TGraph(0)) #graph_exp.SetMarkerStyle(24) graph_exp.SetLineWidth(3) graph_exp.SetLineStyle(2) graph_exp.SetLineColor(4) graph_obs = TGraph(len(masses), masses, xs_obs_limits) graph_obs.SetMarkerStyle(20) graph_obs.SetLineWidth(3) #graph_obs.SetLineStyle(1) graph_obs.SetLineColor(1) c = TCanvas("c", "", 800, 800) c.cd() legend = TLegend(.60, .55, .90, .70) legend.SetBorderSize(0) legend.SetFillColor(0) legend.SetFillStyle(0) legend.SetTextFont(42) legend.SetTextSize(0.03) legend.SetHeader('95% CL upper limits') if len(xs_exp_limits_2sigma) > 0: graph_exp_2sigma.GetXaxis().SetTitle("%s resonance mass [GeV]" % (args.final_state)) graph_exp_2sigma.GetYaxis().SetTitle( "#sigma #times #it{B} #times #it{A} [pb]") graph_exp_2sigma.GetYaxis().SetTitleOffset(1.1) graph_exp_2sigma.GetYaxis().SetRangeUser(1e-02, 1e+03) #graph_exp_2sigma.GetXaxis().SetNdivisions(1005) graph_exp_2sigma.Draw("AF") graph_exp_1sigma.Draw("F") graph_exp.Draw("L") graph_obs.Draw("LP") legend.AddEntry(graph_obs, "Observed", "lp") legend.AddEntry(graph_exp, "Expected", "lp") legend.AddEntry(graph_exp_1sigma, "#pm 1#sigma", "F") legend.AddEntry(graph_exp_2sigma, "#pm 2#sigma", "F") else: graph_obs.GetXaxis().SetTitle("%s resonance mass [GeV]" % (args.final_state)) graph_obs.GetYaxis().SetTitle( "#sigma #times #it{B} #times #it{A} [pb]") graph_obs.GetYaxis().SetTitleOffset(1.1) graph_obs.GetYaxis().SetRangeUser(1e-02, 1e+03) #graph_obs.GetXaxis().SetNdivisions(1005) graph_obs.Draw("ALP") legend.AddEntry(graph_obs, "Observed", "lp") if args.final_state == 'gg': graph_xsS8.Draw("L") elif args.final_state == 'qg': graph_xsQstar.Draw("L") graph_xsString.Draw("L") elif args.final_state == 'qq': graph_xsAxi.Draw("L") graph_xsDiquark.Draw("L") graph_xsWprime.Draw("L") graph_xsZprime.Draw("L") legend.Draw() if args.final_state == 'gg': legendTh = TLegend(.60, .80, .90, .84) legendTh.SetBorderSize(0) legendTh.SetFillColor(0) legendTh.SetFillStyle(0) legendTh.SetTextFont(42) legendTh.SetTextSize(0.03) legendTh.AddEntry(graph_xsS8, "S8", "l") legendTh.Draw() elif args.final_state == 'qg': legendTh = TLegend(.60, .80, .90, .88) legendTh.SetBorderSize(0) legendTh.SetFillColor(0) legendTh.SetFillStyle(0) legendTh.SetTextFont(42) legendTh.SetTextSize(0.03) legendTh.AddEntry(graph_xsString, "String", "l") legendTh.AddEntry(graph_xsQstar, "Excited quark", "l") legendTh.Draw() elif args.final_state == 'qq': legendTh = TLegend(.60, .72, .90, .88) legendTh.SetBorderSize(0) legendTh.SetFillColor(0) legendTh.SetFillStyle(0) legendTh.SetTextFont(42) legendTh.SetTextSize(0.03) legendTh.AddEntry(graph_xsAxi, "Axigluon/coloron", "l") legendTh.AddEntry(graph_xsDiquark, "Scalar diquark", "l") legendTh.AddEntry(graph_xsWprime, "W' SSM", "l") legendTh.AddEntry(graph_xsZprime, "Z' SSM", "l") legendTh.Draw() # draw the lumi text on the canvas CMS_lumi.extraText = args.extraText CMS_lumi.lumi_sqrtS = args.lumi_sqrtS # used with iPeriod = 0 (free form) iPos = 11 iPeriod = 0 CMS_lumi.CMS_lumi(c, iPeriod, iPos) gPad.RedrawAxis() c.SetLogy() fileName = 'xs_limit_%s_%s.%s' % (args.method, args.final_state + ( ('_' + args.postfix) if args.postfix != '' else ''), args.fileFormat.lower()) c.SaveAs(fileName) print "Plot saved to '%s'" % (fileName)
def rootStyle(batchMode=True): from ROOT import gROOT, gStyle, kWhite, kBlack # No info messages gROOT.ProcessLine("gErrorIgnoreLevel = kWarning;") # Batch mode (no TCanvas) gROOT.SetBatch(batchMode) # Start from a plain default gROOT.SetStyle("Plain") lhcbMarkerType = 8 lhcbMarkerSize = 0.8 lhcbFont = 62 lhcbStatFontSize = 0.02 lhcbStatBoxWidth = 0.12 lhcbStatBoxHeight = 0.12 lhcbWidth = 1 lhcbTextSize = 0.05 lhcbLabelSize = 0.035 lhcbAxisLabelSize = 0.035 lhcbForeColour = kBlack gStyle.SetFrameBorderMode(0) gStyle.SetPadBorderMode(0) # canvas options gStyle.SetCanvasBorderSize(0) gStyle.SetCanvasBorderMode(0) # fonts gStyle.SetTextFont(lhcbFont) gStyle.SetTextSize(lhcbTextSize) gStyle.SetLabelFont(lhcbFont, "x") gStyle.SetLabelFont(lhcbFont, "y") gStyle.SetLabelFont(lhcbFont, "z") gStyle.SetLabelSize(lhcbLabelSize, "x") gStyle.SetLabelSize(lhcbLabelSize, "y") gStyle.SetLabelSize(lhcbLabelSize, "z") gStyle.SetTitleFont(lhcbFont) gStyle.SetTitleSize(lhcbAxisLabelSize, "x") gStyle.SetTitleSize(lhcbAxisLabelSize, "y") gStyle.SetTitleSize(lhcbAxisLabelSize, "z") gStyle.SetTitleColor(kWhite) gStyle.SetTitleFillColor(kWhite) gStyle.SetTitleColor(kBlack) gStyle.SetTitleBorderSize(0) gStyle.SetTitleTextColor(kBlack) # set title position gStyle.SetTitleX(0.15) gStyle.SetTitleY(0.97) # turn off Title box gStyle.SetTitleBorderSize(0) gStyle.SetTitleTextColor(lhcbForeColour) gStyle.SetTitleColor(lhcbForeColour) # use bold lines and markers gStyle.SetLineWidth(lhcbWidth) gStyle.SetFrameLineWidth(lhcbWidth) gStyle.SetHistLineWidth(lhcbWidth) gStyle.SetFuncWidth(lhcbWidth) gStyle.SetGridWidth(lhcbWidth) gStyle.SetLineStyleString(2, "[12 12]") gStyle.SetMarkerStyle(lhcbMarkerType) gStyle.SetMarkerSize(lhcbMarkerSize) # label offsets gStyle.SetLabelOffset(0.015) # by default, do not display histogram decorations: gStyle.SetOptStat(1111) # show probability, parameters and errors gStyle.SetOptFit(1011) # look of the statistics box: gStyle.SetStatBorderSize(1) gStyle.SetStatFont(lhcbFont) gStyle.SetStatFontSize(lhcbStatFontSize) gStyle.SetStatX(0.9) gStyle.SetStatY(0.9) gStyle.SetStatW(lhcbStatBoxWidth) gStyle.SetStatH(lhcbStatBoxHeight) # put tick marks on top and RHS of plots gStyle.SetPadTickX(1) gStyle.SetPadTickY(1) # histogram divisions gStyle.SetNdivisions(505, "x") gStyle.SetNdivisions(510, "y") # Force the style gROOT.ForceStyle()
def set_root_env(): #//TStyle* genieStyle = new TStyle("genieStyle", "GENIE Style") #//set the background color to white gStyle.SetFillColor(10) gStyle.SetFrameFillColor(10) gStyle.SetCanvasColor(10) gStyle.SetPadColor(10) gStyle.SetTitleFillColor(0) gStyle.SetStatColor(10) #dont put a colored frame around the plots gStyle.SetFrameBorderMode(0) gStyle.SetCanvasBorderMode(0) gStyle.SetPadBorderMode(0) gStyle.SetLegendBorderSize(3) #use the primary color palette #gStyle.SetPalette(1,0) #set the default line color for a histogram to be black gStyle.SetHistLineColor(ROOT.kBlack) #set the default line color for a fit function to be red gStyle.SetFuncColor(ROOT.kRed) #make the axis labels black gStyle.SetLabelColor(ROOT.kBlack, "xyz") #set the default title color to be black gStyle.SetTitleColor(ROOT.kBlack) #set the margins gStyle.SetPadBottomMargin(0.18) gStyle.SetPadTopMargin(0.08) gStyle.SetPadRightMargin(0.08) gStyle.SetPadLeftMargin(0.17) #set axis label and title text sizes gStyle.SetLabelFont(42, "xyz") gStyle.SetLabelSize(0.04, "xyz") gStyle.SetLabelOffset(0.015, "xyz") gStyle.SetTitleFont(42, "xyz") gStyle.SetTitleSize(0.04, "xyz") gStyle.SetTitleOffset(1.4, "y") gStyle.SetTitleOffset(1.3, "x") gStyle.SetStatFont(42) gStyle.SetStatFontSize(0.07) gStyle.SetTitleBorderSize(1) gStyle.SetStatBorderSize(0) gStyle.SetTextFont(42) gStyle.SetTitleW(0.5) gStyle.SetTitleH(0.1) #set line widths gStyle.SetFrameLineWidth(2) gStyle.SetFuncWidth(2) gStyle.SetHistLineWidth(2) #set the number of divisions to show gStyle.SetNdivisions(506, "xy") #gStyle.SetPadTickX(-50202) #turn off xy grids gStyle.SetPadGridX(0) gStyle.SetPadGridY(0) #set the tick mark style gStyle.SetPadTickX(1) gStyle.SetPadTickY(1) #turn off stats gStyle.SetOptStat(0) gStyle.SetOptFit(0) #marker/line settings #gStyle.SetMarkerStyle(20) gStyle.SetMarkerSize(.95) #0.7 gStyle.SetLineWidth(2) gStyle.SetErrorX(0) gStyle.SetHistLineStyle(0) #It was 3 for a dotted line #done gStyle.cd() gROOT.ForceStyle()
def main(): # usage description usage = "Example: ./scripts/plotLimits.py -M Asymptotic -l logs -f qq --massrange 1200 7000 100" # input parameters parser = ArgumentParser(description='Script that plots limits for specified mass points',epilog=usage) parser.add_argument('analysis', type=str, help='Analysis name') parser.add_argument('model', type=str, help='Model name') parser.add_argument("-M", "--method", dest="method", required=True, choices=['ProfileLikelihood', 'HybridNew', 'Asymptotic', 'MarkovChainMC', 'theta', 'HybridNewGrid'], help="Method to calculate upper limits", metavar="METHOD") parser.add_argument('--fit_function', type=str, default="f4", help="Name of fit function used for background estimate") parser.add_argument('--timesAE', action='store_true', help="Set y-axis to sigma*BR*A*e, instead of sigma*BR") parser.add_argument('--fitTrigger', action='store_true', help="Use trigger fit") parser.add_argument('--correctTrigger', action='store_true', help="Use trigger correction") parser.add_argument('--useMCTrigger', action='store_true', help="Use MC trigger emulation") #results_group = parser.add_mutually_exclusive_group(required=True) #results_group.add_argument("-l", "--logs_path", dest="logs_path", # help="Path to log files", # metavar="LOGS_PATH") #results_group.add_argument("-r", "--results_file", dest="results_file", # help="Path to a file containing results", # metavar="RESULTS_FILE") #parser.add_argument("-f", "--final_state", dest="final_state", required=True, # help="Final state (e.g. qq, qg, gg)", # metavar="FINAL_STATE") #parser.add_argument("-f2", "--finalstate2", dest="final_state2", required=True, help="hG,lG,hR, or lR", metavar="FINAL_STATE2") parser.add_argument("--noSyst", action="store_true", help="Make plots for limits without systematics") parser.add_argument("--freezeNuisances", type=str, help="Make plots for limits with frozen nuisance parameters") parser.add_argument("--postfix", dest="postfix", default='', help="Postfix for the output plot name (default: %(default)s)") parser.add_argument("--fileFormat", dest="fileFormat", default='pdf', help="Format of the output plot (default: %(default)s)") parser.add_argument("--saveObjects", type=str, help="Save plot objects") parser.add_argument("--extraText", dest="extraText", default='', help="Extra text on the plot (default: %(default)s)") parser.add_argument("--lumi_sqrtS", dest="lumi_sqrtS", default='19.7 fb^{-1} (8 TeV)', help="Integrated luminosity and center-of-mass energy (default: %(default)s)") parser.add_argument("--printResults", dest="printResults", default=False, action="store_true", help="Print results to the screen") mass_group = parser.add_mutually_exclusive_group(required=True) mass_group.add_argument("--mass", type=int, nargs = '*', default = 1000, help="Mass can be specified as a single value or a whitespace separated list (default: %(default)i)" ) mass_group.add_argument("--massrange", type=int, nargs = 3, help="Define a range of masses to be produced. Format: min max step", metavar = ('MIN', 'MAX', 'STEP') ) mass_group.add_argument("--masslist", help = "List containing mass information" ) args = parser.parse_args() if args.method == 'HybridNew': searchmethod = 'Hybrid New' # mass points for which resonance shapes will be produced input_masses = [] if args.massrange != None: MIN, MAX, STEP = args.massrange input_masses = range(MIN, MAX+STEP, STEP) elif args.masslist != None: # A mass list was provided print "Will create mass list according to", args.masslist masslist = __import__(args.masslist.replace(".py","")) input_masses = masslist.masses else: input_masses = args.mass # sort masses input_masses.sort() from ROOT import kTRUE, kFALSE, gROOT, gStyle, gPad, TGraph, TCanvas, TLegend, TF1, TFile from ROOT import kGreen, kYellow, kWhite # Make acc*eff TGraph ae_x = array('d',[325, 350, 400, 500, 600, 750, 900, 1200]) if args.timesAE: ae_y = np.ones(len(ae_x)) else: ae_y = array('d', []) for mass in ae_x: ae_y.append(analysis_config.simulation.get_signal_AE(args.analysis, args.model, int(mass))) acceptance_times_efficiency = TGraph(len(ae_x), ae_x, ae_y) #xs = array('d',[250,300,400,500,600,750,900,1200]) #trigger_correctionl = TF1("trigbbl_efficiency", "(1. / (1. + TMath::Exp(-1. * (x - [0]) / [1])))**[2]", 175, 400) #trigger_correctionl.SetParameter(0, 1.82469e+02) #trigger_correctionl.SetParameter(1, 2.87768e+01) #trigger_correctionl.SetParameter(2, 9.11659e-01) #trigger_correctionh = TF1("trigbbh_efficiency", "(1. / (1. + TMath::Exp(-1. * (x - [0]) / [1])))**[2]", 300, 600) #trigger_correctionh.SetParameter(0, 3.61785e+02) #trigger_correctionh.SetParameter(1, 3.16523e+01) #trigger_correctionh.SetParameter(2, 4.84357e-01) #if args.timesAE: # ys = np.ones(len(xs)) #else: # if args.analysis == "trigbbh_CSVTM" and args.model == "Hbb": # #ys = array('d',[188./19751.,1304./19993.,2697./49494.,881./19999.,534./19598.]) # ys = array('d',[24./19737.,188./19751.,1171./19984.,1419./19992.,1304./19993.,2697./49494.,881./19999.,534./19598.]) # #graphMod = trigger_correctionh # elif args.analysis == "trigbbl_CSVTM" and args.model == "Hbb": # #ys = array('d',[30./2797.,1583./19995.,1295./19996.,999./19996.,528./19999.]) # ys = array('d',[574./19737.,763./39502.,651./19984.,583./19992.,984./39986.,1905./98988.,656./39998.,369./39196.]) # #graphMod = trigger_correctionh # elif args.analysis == "trigbbh_CSVTM" and args.model == "RSG": # #ys = array('d',[109./19751.,488./19993.,954./49494.,328./19999.,182./19598.]) # ys = array('d',[40./19977.,30./2797.,1522./19991.,1640./19396.,1583./19995.,1295./19996.,999./19996.,528./19999.]) # #graphMod = trigger_correctionl # elif args.analysis == "trigbbl_CSVTM" and args.model == "RSG": # #ys = array('d',[23./2797.,599./19995.,448./19996.,338./19996.,190./19999.]) # ys = array('d',[696./19977.,137./5594.,797./19991.,652./19396.,1206./39990.,891./39992.,675./39992.,379./39998.]) # #graphMod = trigger_correctionl ##ys = array('d',[1,1,1,1,1,1,1,1,]) #acceptance_times_efficiency = TGraph(len(xs),xs,ys) # arrays holding results masses = array('d') xs_obs_limits = array('d') xs_exp_limits = array('d') masses_exp = array('d') xs_exp_limits_1sigma = array('d') xs_exp_limits_1sigma_up = array('d') xs_exp_limits_2sigma = array('d') xs_exp_limits_2sigma_up = array('d') for mass in input_masses: print ">> Reading results for %s %s resonance with m = %i GeV..."%(args.analysis, args.model, int(mass)) masses.append(mass) masses_exp.append(mass) # For masses above 1100, you scaled down the signal by 10 by hand, to help the limit setting. #if args.analysis == "trigbbh_CSVTM" and mass >= 1100: input_xs = 1./100. #else: # input_xs = 1. if args.method == "HybridNewGrid": found_limit = {"obs":False, "exp0":False, "exp1":False, "exp2":False, "exp-1":False, "exp-2":False} for what in found_limit.keys(): log_file_path = limit_config.get_combine_log_path_grid(args.analysis, args.model, mass, args.fit_function, what, systematics=(not args.noSyst), frozen_nps=args.freezeNuisances, fitTrigger=args.fitTrigger, correctTrigger=args.correctTrigger, useMCTrigger=args.useMCTrigger) print "Reading log file from " + log_file_path log_file = open(log_file_path, 'r') for line in log_file: if re.search("^Limit: r <", line) and re.search("95%", line): found_limit[what] = True this_limit = float(line.split()[3])/acceptance_times_efficiency.Eval(mass) print "Found limit for " + what + " = " + str(this_limit) if what == "obs": xs_obs_limits.append(this_limit * input_xs) elif what == "exp0": xs_exp_limits.append(this_limit * input_xs) elif what == "exp1": xs_exp_limits_1sigma_up.append(this_limit * input_xs) elif what == "exp2": xs_exp_limits_2sigma_up.append(this_limit * input_xs) elif what == "exp-1": xs_exp_limits_1sigma.append(this_limit * input_xs) elif what == "exp-2": xs_exp_limits_2sigma.append(this_limit * input_xs) if not found_limit["obs"]: xs_obs_limits.append(0) if not found_limit["exp0"]: xs_exp_limits.append(0) if not found_limit["exp1"]: xs_exp_limits_1sigma.append(0) if not found_limit["exp2"]: xs_exp_limits_1sigma_up.append(0) if not found_limit["exp-1"]: xs_exp_limits_2sigma.append(0) if not found_limit["exp-2"]: xs_exp_limits_2sigma_up.append(0) if len(masses) != len(xs_obs_limits): print "** ERROR: ** Could not find observed limit for m =", int(mass), "GeV. Aborting." sys.exit(1) else: print "Reading log file from " + limit_config.get_combine_log_path(args.analysis, args.model, mass, args.fit_function, args.method, systematics=(not args.noSyst), frozen_nps=args.freezeNuisances, fitTrigger=args.fitTrigger, correctTrigger=args.correctTrigger, useMCTrigger=args.useMCTrigger) if not os.path.exists((limit_config.get_combine_log_path(args.analysis, args.model, mass, args.fit_function, args.method, systematics=(not args.noSyst), frozen_nps=args.freezeNuisances, fitTrigger=args.fitTrigger, correctTrigger=args.correctTrigger, useMCTrigger=args.useMCTrigger))): print "[plot_limits] WARNING : Log file not found! Setting limits to zero and skipping this point." print "[plot_limits] WARNING : \t{}".format(limit_config.get_combine_log_path(args.analysis, args.model, mass, args.fit_function, args.method, systematics=(not args.noSyst), frozen_nps=args.freezeNuisances, fitTrigger=args.fitTrigger, correctTrigger=args.correctTrigger, useMCTrigger=args.useMCTrigger)) xs_obs_limits.append(0) xs_exp_limits.append(0) xs_exp_limits_1sigma.append(0) xs_exp_limits_1sigma_up.append(0) xs_exp_limits_2sigma.append(0) xs_exp_limits_2sigma_up.append(0) continue log_file = open(limit_config.get_combine_log_path(args.analysis, args.model, mass, args.fit_function, args.method, systematics=(not args.noSyst), frozen_nps=args.freezeNuisances, fitTrigger=args.fitTrigger, correctTrigger=args.correctTrigger, useMCTrigger=args.useMCTrigger)) foundMethod = False middle = 0 # read the log file found_limit = {"obs":False, "exp":False, "exp+1":False, "exp+2":False, "exp-1":False, "exp-2":False} for line in log_file: if args.method == 'Asymptotic': if re.search("^Observed Limit: r", line): xs_obs_limits.append(float(line.split()[-1])/acceptance_times_efficiency.Eval(mass) * input_xs) found_limit["obs"] = True if mass == 325 and args.model == "ZPrime": print "[debug] ZPrime 325 GeV limit = {}".format(xs_obs_limits[-1]) print "[debug] \tA*e={}, input_xs={}".format(acceptance_times_efficiency.Eval(mass), input_xs) if re.search("^Expected 50.0%: r", line): middle = float(line.split()[-1]) found_limit["exp"] = True xs_exp_limits.append(middle/acceptance_times_efficiency.Eval(mass) * input_xs) if re.search("^Expected 16.0%: r", line): xs_exp_limits_1sigma.append((float(line.split()[-1]))/acceptance_times_efficiency.Eval(mass) * input_xs) found_limit["exp-1"] = True if re.search("^Expected 84.0%: r", line): xs_exp_limits_1sigma_up.append(float(line.split()[-1])/acceptance_times_efficiency.Eval(mass) * input_xs) found_limit["exp+1"] = True if re.search("^Expected 2.5%: r", line): xs_exp_limits_2sigma.append(float(line.split()[-1])/acceptance_times_efficiency.Eval(mass) * input_xs) found_limit["exp-2"] = True if re.search("^Expected 97.5%: r", line): xs_exp_limits_2sigma_up.append(float(line.split()[-1])/acceptance_times_efficiency.Eval(mass) * input_xs) found_limit["exp+2"] = True elif args.method == 'theta': if re.search('^# x; y; yerror', line): foundMethod = True if line.split()[0] == '0' and foundMethod: xs_obs_limits.append(float(line.split()[1])/acceptance_times_efficiency.Eval(mass) * input_xs) else: searchmethod = "Hybrid New" if re.search(' -- ' + searchmethod, line): foundMethod = True if re.search("^Limit: r", line) and foundMethod: xs_obs_limits.append(float(line.split()[3])/acceptance_times_efficiency.Eval(mass) * input_xs) found_limit["obs"] = True print "[debug] Found limit " + str(xs_obs_limits[-1]) if not found_limit["obs"]: xs_obs_limits.append(0) if not found_limit["exp"]: xs_exp_limits.append(0) if not found_limit["exp+1"]: xs_exp_limits_1sigma.append(0) if not found_limit["exp+2"]: xs_exp_limits_1sigma_up.append(0) if not found_limit["exp-1"]: xs_exp_limits_2sigma.append(0) if not found_limit["exp-2"]: xs_exp_limits_2sigma_up.append(0) if len(masses) != len(xs_obs_limits): print "** ERROR: ** Could not find observed limit for m =", int(mass), "GeV. Aborting." sys.exit(1) if args.method == 'Asymptotic' or args.method == 'HybridNewGrid': if len(masses) != len(xs_exp_limits): print "** ERROR: ** Could not find expected limit for m =", int(mass), "GeV. Aborting." print "masses = ", print masses print "xs_exp_limits = ", print xs_exp_limits sys.exit(1) if len(masses) != len(xs_exp_limits_1sigma): print "** ERROR: ** Could not find expected 1 sigma down limit for m =", int(mass), "GeV. Aborting." print "masses = ", print masses print "xs_exp_limits_1sigma = ", print xs_exp_limits_1sigma sys.exit(1) if len(masses) != len(xs_exp_limits_1sigma_up): print "** ERROR: ** Could not find expected 1 sigma up limit for m =", int(mass), "GeV. Aborting." print "masses = ", print masses print "xs_exp_limits_1sigma_up = ", print xs_exp_limits_1sigma_up sys.exit(1) if len(masses) != len(xs_exp_limits_2sigma): print "** ERROR: ** Could not find expected 2 sigma down limit for m =", int(mass), "GeV. Aborting." sys.exit(1) if len(masses) != len(xs_exp_limits_2sigma_up): print "** ERROR: ** Could not find expected 2 sigma up limit for m =", int(mass), "GeV. Aborting." sys.exit(1) if args.method == 'Asymptotic' or args.method == 'HybridNewGrid': # complete the expected limit arrays for i in range(0,len(masses)): masses_exp.append( masses[len(masses)-i-1] ) xs_exp_limits_1sigma.append( xs_exp_limits_1sigma_up[len(masses)-i-1] ) xs_exp_limits_2sigma.append( xs_exp_limits_2sigma_up[len(masses)-i-1] ) if args.printResults: print "masses =", masses.tolist() print "xs_obs_limits =", xs_obs_limits.tolist() print "xs_exp_limits =", xs_exp_limits.tolist() print "" print "masses_exp =", masses_exp.tolist() print "xs_exp_limits_1sigma =", xs_exp_limits_1sigma.tolist() print "xs_exp_limits_2sigma =", xs_exp_limits_2sigma.tolist() gROOT.SetBatch(kTRUE); gStyle.SetOptStat(0) gStyle.SetOptTitle(0) gStyle.SetTitleFont(42, "XYZ") gStyle.SetTitleSize(0.05, "XYZ") gStyle.SetLabelFont(42, "XYZ") gStyle.SetLabelSize(0.05, "XYZ") gStyle.SetCanvasBorderMode(0) gStyle.SetFrameBorderMode(0) gStyle.SetCanvasColor(kWhite) gStyle.SetPadTickX(1) gStyle.SetPadTickY(1) gStyle.SetPadLeftMargin(0.15) gStyle.SetPadRightMargin(0.05) gStyle.SetPadTopMargin(0.05) gStyle.SetPadBottomMargin(0.15) gROOT.ForceStyle() # theory curves: gg massesS8 = array('d', [1000.0,1100.0,1200.0,1300.0,1400.0,1500.0,1600.0,1700.0,1800.0,1900.0,2000.0,2100.0,2200.0,2300.0,2400.0,2500.0,2600.0,2700.0,2800.0,2900.0,3000.0,3100.0,3200.0,3300.0,3400.0,3500.0,3600.0,3700.0,3800.0,3900.0,4000.0,4100.0,4200.0,4300.0,4400.0,4500.0,4600.0,4700.0,4800.0,4900.0,5000.0,5100.0,5200.0,5300.0,5400.0,5500.0,5600.0,5700.0,5800.0,5900.0,6000.0]) xsS8 = array('d', [5.46E+02,3.12E+02,1.85E+02,1.12E+02,7.19E+01,4.59E+01,3.02E+01,2.01E+01,1.37E+01,9.46E+00,6.55E+00,4.64E+00,3.27E+00,2.36E+00,1.70E+00,1.24E+00,9.11E-01,6.69E-01,4.97E-01,3.71E-01,2.78E-01,2.07E-01,1.55E-01,1.19E-01,9.26E-02,7.08E-02,5.43E-02,4.15E-02,3.22E-02,2.50E-02,1.92E-02,1.51E-02,1.19E-02,9.25E-03,7.35E-03,5.86E-03,4.53E-03,3.66E-03,2.91E-03,2.33E-03,1.86E-03,1.45E-03,1.12E-03,8.75E-04,6.90E-04,5.55E-04,4.47E-04,3.63E-04,2.92E-04,2.37E-04,1.97E-04]) graph_xsS8 = TGraph(len(massesS8),massesS8,xsS8) graph_xsS8.SetLineWidth(3) graph_xsS8.SetLineStyle(8) graph_xsS8.SetLineColor(6) # theory curves: qg massesString = array('d', [1000.0,1100.0,1200.0,1300.0,1400.0,1500.0,1600.0,1700.0,1800.0,1900.0,2000.0,2100.0,2200.0,2300.0,2400.0,2500.0,2600.0,2700.0,2800.0,2900.0,3000.0,3100.0,3200.0,3300.0,3400.0,3500.0,3600.0,3700.0,3800.0,3900.0,4000.0,4100.0,4200.0,4300.0,4400.0,4500.0,4600.0,4700.0,4800.0,4900.0,5000.0,5100.0,5200.0,5300.0,5400.0,5500.0,5600.0,5700.0,5800.0,5900.0,6000.0,6100.0,6200.0,6300.0,6400.0,6500.0,6600.0,6700.0,6800.0,6900.0,7000.0,7100.0,7200.0,7300.0,7400.0,7500.0,7600.0,7700.0,7800.0,7900.0,8000.0,8100.0,8200.0,8300.0,8400.0,8500.0,8600.0,8700.0,8800.0,8900.0,9000.0,9100.,9200.,9300.,9400.,9500.,9600.,9700.,9800.,9900.,10000.]) xsString = array('d', [8316.184311558545,5312.93137758767,3435.0309937336524,2304.4139502741305,1569.8115447896687,1090.9516635659693,770.901859690924,551.9206062572061,399.69535383507633,293.77957451762086,218.15126842827823,162.87634729465125,123.17685479653694,93.63530805932386,71.53697229809124,55.37491301647483,42.75271508357369,33.36378355470234,26.06619302090876,20.311817606835643,16.1180931789545,12.768644973921226,10.142660425967444,8.057990848043234,6.400465846290908,5.115134438331436,4.132099789492928,3.3193854239538734,2.6581204529344302,2.157554604919995,1.7505176068913348,1.4049155245498584,1.140055677916783,0.9253251132104159,0.7522038169131606,0.6119747371392215,0.49612321727328523,0.40492020959456737,0.33091999402250655,0.27017917021492555,0.2201693919322846,0.17830700070267996,0.14564253802358157,0.11940534430331146,0.09694948234356839,0.0793065371847468,0.06446186373361917,0.05282660618352478, 0.0428516302310620888,0.0348997638039910363,0.0283334766442618227,0.0231416918363592127,0.0187417921340763783,0.0153501307395115115,0.0124396534127133717,0.0100542205744949455,0.0081744954858627415,0.0066338099362915941,0.0053365711503318145,0.00430912459914657443,0.00346381039244064343,0.00278602671711227174,0.00225154342228859257,0.0018082930150063248,0.00143929440338502119,0.0011581373956044489,0.00091869589873893118,0.00073410823691329855,0.00058669382997948734,0.0004661568745858897,0.000368716655469570365,0.000293168485206959169,0.000230224535021638668,0.000182317101888465142,0.000143263359883433282,0.000112630538527214965,0.000088189175598406759,0.000068708474367442343,0.000053931726669273556,0.0000416417855733682702,0.0000326529676755488658,0.0000254365480426201587,0.0000198410151166864761,0.0000154034425617473576,0.0000119095554601641413,9.2537574320108232e-6,7.2155417437856749e-6,5.6130924422251982e-6,4.36634755605624901e-6,3.39717456406994868e-6,2.6766018046173896e-6]) massesQstar = array('d', [1000.0,1100.0,1200.0,1300.0,1400.0,1500.0,1600.0,1700.0,1800.0,1900.0,2000.0,2100.0,2200.0,2300.0,2400.0,2500.0,2600.0,2700.0,2800.0,2900.0,3000.0,3100.0,3200.0,3300.0,3400.0,3500.0,3600.0,3700.0,3800.0,3900.0,4000.0,4100.0,4200.0,4300.0,4400.0,4500.0,4600.0,4700.0,4800.0,4900.0,5000.0,5100.0,5200.0,5300.0,5400.0,5500.0,5600.0,5700.0,5800.0,5900.0,6000.0,6100.0,6200.0,6300.0,6400.0,6500.0,6600.0,6700.0,6800.0,6900.0,7000.0,7100.0,7200.0,7300.0,7400.0,7500.0,7600.0,7700.0,7800.0,7900.0,8000.0,8100.0,8200.0,8300.0,8400.0,8500.0,8600.0,8700.0,8800.0,8900.0,9000.0]) xsQstar = array('d', [0.4101E+03,0.2620E+03,0.1721E+03,0.1157E+03,0.7934E+02,0.5540E+02,0.3928E+02,0.2823E+02,0.2054E+02,0.1510E+02,0.1121E+02,0.8390E+01,0.6328E+01,0.4807E+01,0.3674E+01,0.2824E+01,0.2182E+01,0.1694E+01,0.1320E+01,0.1033E+01,0.8116E+00,0.6395E+00,0.5054E+00,0.4006E+00,0.3182E+00,0.2534E+00,0.2022E+00,0.1616E+00,0.1294E+00,0.1038E+00,0.8333E-01,0.6700E-01,0.5392E-01,0.4344E-01,0.3503E-01,0.2827E-01,0.2283E-01,0.1844E-01,0.1490E-01,0.1205E-01,0.9743E-02,0.7880E-02,0.6373E-02,0.5155E-02,0.4169E-02,0.3371E-02,0.2725E-02,0.2202E-02,0.1779E-02,0.1437E-02,0.1159E-02,0.9353E-03,0.7541E-03,0.6076E-03,0.4891E-03,0.3935E-03,0.3164E-03,0.2541E-03,0.2039E-03,0.1635E-03,0.1310E-03,0.1049E-03,0.8385E-04,0.6699E-04,0.5347E-04,0.4264E-04,0.3397E-04,0.2704E-04,0.2151E-04,0.1709E-04,0.1357E-04,0.1077E-04,0.8544E-05,0.6773E-05,0.5367E-05,0.4251E-05,0.3367E-05,0.2666E-05,0.2112E-05,0.1673E-05,0.1326E-05]) graph_xsString = TGraph(len(massesString),massesString,xsString) graph_xsString.SetLineWidth(3) graph_xsString.SetLineStyle(8) graph_xsString.SetLineColor(9) graph_xsQstar = TGraph(len(massesQstar),massesQstar,xsQstar) graph_xsQstar.SetLineWidth(3) graph_xsQstar.SetLineStyle(2) graph_xsQstar.SetLineColor(1) # theory curves: qq massesTh = array('d', [1000.0,1100.0,1200.0,1300.0,1400.0,1500.0,1600.0,1700.0,1800.0,1900.0,2000.0,2100.0,2200.0,2300.0,2400.0,2500.0,2600.0,2700.0,2800.0,2900.0,3000.0,3100.0,3200.0,3300.0,3400.0,3500.0,3600.0,3700.0,3800.0,3900.0,4000.0,4100.0,4200.0,4300.0,4400.0,4500.0,4600.0,4700.0,4800.0,4900.0,5000.0,5100.0,5200.0,5300.0,5400.0,5500.0,5600.0,5700.0,5800.0,5900.0,6000.0,6100.0,6200.0,6300.0,6400.0,6500.0,6600.0,6700.0,6800.0,6900.0,7000.0,7100.0,7200.0,7300.0,7400.0,7500.0,7600.0,7700.0,7800.0,7900.0,8000.0,8100.0,8200.0,8300.0,8400.0,8500.0,8600.0,8700.0,8800.0,8900.0,9000.0]) xsAxi = array('d', [0.1849E+03,0.1236E+03,0.8473E+02,0.5937E+02,0.4235E+02,0.3069E+02,0.2257E+02,0.1680E+02,0.1263E+02,0.9577E+01,0.7317E+01,0.5641E+01,0.4374E+01,0.3411E+01,0.2672E+01,0.2103E+01,0.1658E+01,0.1312E+01,0.1041E+01,0.8284E+00,0.6610E+00,0.5294E+00,0.4250E+00,0.3417E+00,0.2752E+00,0.2220E+00,0.1792E+00,0.1449E+00,0.1172E+00,0.9487E-01,0.7686E-01,0.6219E-01,0.5033E-01,0.4074E-01,0.3298E-01,0.2671E-01,0.2165E-01,0.1755E-01,0.1422E-01,0.1152E-01,0.9322E-02,0.7539E-02,0.6092E-02,0.4917E-02,0.3965E-02,0.3193E-02,0.2568E-02,0.2062E-02,0.1653E-02,0.1323E-02,0.1057E-02,0.8442E-03,0.6728E-03,0.5349E-03,0.4242E-03,0.3357E-03,0.2644E-03,0.2077E-03,0.1627E-03,0.1271E-03,0.9891E-04,0.7686E-04,0.5951E-04,0.4592E-04,0.3530E-04,0.2704E-04,0.2059E-04,0.1562E-04,0.1180E-04,0.8882E-05,0.6657E-05,0.4968E-05,0.3693E-05,0.2734E-05,0.2016E-05,0.1481E-05,0.1084E-05,0.7903E-06,0.5744E-06,0.4160E-06,0.3007E-06]) xsDiquark = array('d', [0.5824E+02,0.4250E+02,0.3172E+02,0.2411E+02,0.1862E+02,0.1457E+02,0.1153E+02,0.9211E+01,0.7419E+01,0.6019E+01,0.4912E+01,0.4031E+01,0.3323E+01,0.2750E+01,0.2284E+01,0.1903E+01,0.1590E+01,0.1331E+01,0.1117E+01,0.9386E+00,0.7900E+00,0.6658E+00,0.5618E+00,0.4745E+00,0.4010E+00,0.3391E+00,0.2869E+00,0.2428E+00,0.2055E+00,0.1740E+00,0.1473E+00,0.1246E+00,0.1055E+00,0.8922E-01,0.7544E-01,0.6376E-01,0.5385E-01,0.4546E-01,0.3834E-01,0.3231E-01,0.2720E-01,0.2288E-01,0.1922E-01,0.1613E-01,0.1352E-01,0.1132E-01,0.9463E-02,0.7900E-02,0.6584E-02,0.5479E-02,0.4551E-02,0.3774E-02,0.3124E-02,0.2581E-02,0.2128E-02,0.1750E-02,0.1437E-02,0.1177E-02,0.9612E-03,0.7833E-03,0.6366E-03,0.5160E-03,0.4170E-03,0.3360E-03,0.2700E-03,0.2162E-03,0.1725E-03,0.1372E-03,0.1087E-03,0.8577E-04,0.6742E-04,0.5278E-04,0.4114E-04,0.3192E-04,0.2465E-04,0.1894E-04,0.1448E-04,0.1101E-04,0.8322E-05,0.6253E-05,0.4670E-05]) xsWprime = array('d', [0.8811E+01,0.6024E+01,0.4216E+01,0.3010E+01,0.2185E+01,0.1610E+01,0.1200E+01,0.9043E+00,0.6875E+00,0.5271E+00,0.4067E+00,0.3158E+00,0.2464E+00,0.1932E+00,0.1521E+00,0.1201E+00,0.9512E-01,0.7554E-01,0.6012E-01,0.4792E-01,0.3827E-01,0.3059E-01,0.2448E-01,0.1960E-01,0.1571E-01,0.1259E-01,0.1009E-01,0.8090E-02,0.6483E-02,0.5193E-02,0.4158E-02,0.3327E-02,0.2660E-02,0.2125E-02,0.1695E-02,0.1351E-02,0.1075E-02,0.8546E-03,0.6781E-03,0.5372E-03,0.4248E-03,0.3353E-03,0.2642E-03,0.2077E-03,0.1629E-03,0.1275E-03,0.9957E-04,0.7757E-04,0.6027E-04,0.4670E-04,0.3610E-04,0.2783E-04,0.2140E-04,0.1641E-04,0.1254E-04,0.9561E-05,0.7269E-05,0.5510E-05,0.4167E-05,0.3143E-05,0.2364E-05,0.1774E-05,0.1329E-05,0.9931E-06,0.7411E-06,0.5523E-06,0.4108E-06,0.3055E-06,0.2271E-06,0.1687E-06,0.1254E-06,0.9327E-07,0.6945E-07,0.5177E-07,0.3863E-07,0.2888E-07,0.2162E-07,0.1622E-07,0.1218E-07,0.9156E-08,0.6893E-08]) xsZprime = array('d', [0.5027E+01,0.3398E+01,0.2353E+01,0.1663E+01,0.1196E+01,0.8729E+00,0.6450E+00,0.4822E+00,0.3638E+00,0.2769E+00,0.2123E+00,0.1639E+00,0.1272E+00,0.9933E-01,0.7789E-01,0.6134E-01,0.4848E-01,0.3845E-01,0.3059E-01,0.2440E-01,0.1952E-01,0.1564E-01,0.1256E-01,0.1010E-01,0.8142E-02,0.6570E-02,0.5307E-02,0.4292E-02,0.3473E-02,0.2813E-02,0.2280E-02,0.1848E-02,0.1499E-02,0.1216E-02,0.9864E-03,0.8002E-03,0.6490E-03,0.5262E-03,0.4264E-03,0.3453E-03,0.2795E-03,0.2260E-03,0.1826E-03,0.1474E-03,0.1188E-03,0.9566E-04,0.7690E-04,0.6173E-04,0.4947E-04,0.3957E-04,0.3159E-04,0.2516E-04,0.2001E-04,0.1587E-04,0.1255E-04,0.9906E-05,0.7795E-05,0.6116E-05,0.4785E-05,0.3731E-05,0.2900E-05,0.2247E-05,0.1734E-05,0.1334E-05,0.1022E-05,0.7804E-06,0.5932E-06,0.4492E-06,0.3388E-06,0.2544E-06,0.1903E-06,0.1417E-06,0.1051E-06,0.7764E-07,0.5711E-07,0.4186E-07,0.3055E-07,0.2223E-07,0.1612E-07,0.1164E-07,0.8394E-08]) graph_xsAxi = TGraph(len(massesTh),massesTh,xsAxi) graph_xsAxi.SetLineWidth(3) graph_xsAxi.SetLineStyle(3) graph_xsAxi.SetLineColor(63) graph_xsDiquark = TGraph(len(massesTh),massesTh,xsDiquark) graph_xsDiquark.SetLineWidth(3) graph_xsDiquark.SetLineStyle(9) graph_xsDiquark.SetLineColor(8) graph_xsWprime = TGraph(len(massesTh),massesTh,xsWprime) graph_xsWprime.SetLineWidth(3) graph_xsWprime.SetLineStyle(7) graph_xsWprime.SetLineColor(46) graph_xsZprime = TGraph(len(massesTh),massesTh,xsZprime) graph_xsZprime.SetLineWidth(3) graph_xsZprime.SetLineStyle(5) graph_xsZprime.SetLineColor(38) # limits if args.method == "Asymptotic" or args.method == "HybridNewGrid": graph_exp_2sigma = ( TGraph(len(masses_exp),masses_exp,xs_exp_limits_2sigma) if len(xs_exp_limits_2sigma) > 0 else TGraph(0) ) graph_exp_2sigma.SetFillColor(kYellow) graph_exp_1sigma = ( TGraph(len(masses_exp),masses_exp,xs_exp_limits_1sigma) if len(xs_exp_limits_2sigma) > 0 else TGraph(0) ) graph_exp_1sigma.SetFillColor(kGreen+1) graph_exp = ( TGraph(len(masses),masses,xs_exp_limits) if len(xs_exp_limits_2sigma) > 0 else TGraph(0) ) #graph_exp.SetMarkerStyle(24) graph_exp.SetLineWidth(3) graph_exp.SetLineStyle(2) graph_exp.SetLineColor(4) graph_obs = TGraph(len(masses),masses,xs_obs_limits) graph_obs.SetMarkerStyle(20) graph_obs.SetLineWidth(3) #graph_obs.SetLineStyle(1) graph_obs.SetLineColor(1) c = TCanvas("c", "",800,800) c.cd() legend = TLegend(.58,.72,.90,.90) legend.SetBorderSize(0) legend.SetFillColor(0) legend.SetFillStyle(0) legend.SetTextFont(42) legend.SetTextSize(0.03) legend.SetHeader('95% CL upper limits') if len(xs_exp_limits_2sigma) > 0 and (args.method == "Asymptotic" or args.method == "HybridNewGrid"): frame = graph_exp_2sigma.GetHistogram().Clone() else: frame = graph_obs.GetHistogram().Clone() frame.Reset() frame.GetXaxis().SetTitle("Resonance mass [GeV]") frame.GetXaxis().SetTitleOffset(1.05) if args.timesAE: #if args.model == "ZPrime": # frame.GetYaxis().SetTitle("#sigma #times BR(c#bar{c},b#bar{b}) #times #it{A} #times #epsilon [pb]") #else: frame.GetYaxis().SetTitle("#sigma #times BR(b#bar{b}) #times #it{A} #times #epsilon [pb]") else: #if args.model == "ZPrime": # frame.GetYaxis().SetTitle("#sigma #times BR(c#bar{c},b#bar{b}) [pb]") #else: frame.GetYaxis().SetTitle("#sigma #times BR(b#bar{b}) [pb]") frame.GetYaxis().SetTitleOffset(1.2) if args.timesAE: frame.GetYaxis().SetRangeUser(1e-03,1e+01) else: frame.GetYaxis().SetRangeUser(1e-01,5e+02) frame.Draw("axis") if len(xs_exp_limits_2sigma) > 0 and (args.method == "Asymptotic" or args.method == "HybridNewGrid"): graph_exp_2sigma.GetXaxis().SetTitle("Resonance mass [GeV]") graph_exp_2sigma.GetXaxis().SetTitleOffset(1.1) graph_exp_2sigma.GetYaxis().SetTitle("#sigma #times #it{B} [pb]") graph_exp_2sigma.GetYaxis().SetTitleOffset(1.1) #graph_exp_2sigma.GetYaxis().SetRangeUser(1e-03,1e+02) #graph_exp_2sigma.GetXaxis().SetNdivisions(1005) graph_exp_2sigma.Draw("F") graph_exp_1sigma.Draw("F") graph_exp.Draw("L") graph_obs.Draw("LP") legend.AddEntry(graph_obs,"Observed","lp") legend.AddEntry(graph_exp,"Expected","lp") legend.AddEntry(graph_exp_1sigma,"#pm 1#sigma","F") legend.AddEntry(graph_exp_2sigma,"#pm 2#sigma","F") else: graph_obs.GetXaxis().SetTitle("Resonance mass [GeV]") graph_obs.GetYaxis().SetTitle("#sigma #times #it{B} [pb]") graph_obs.GetYaxis().SetTitleOffset(1.1) graph_obs.GetYaxis().SetRangeUser(1e-02,1e+03) #graph_obs.GetXaxis().SetNdivisions(1005) graph_obs.Draw("LP") legend.AddEntry(graph_obs,"Observed","lp") #if args.final_state == 'gg' : # graph_xsS8.Draw("L") #elif args.final_state == 'qg' : # graph_xsQstar.Draw("L") # graph_xsString.Draw("L") #elif args.final_state == 'qq' : # graph_xsAxi.Draw("L") # graph_xsDiquark.Draw("L") # graph_xsWprime.Draw("L") # graph_xsZprime.Draw("L") legend.Draw() #legendTh = TLegend(.60,.72,.90,.88) #legendTh.SetBorderSize(0) #legendTh.SetFillColor(0) #legendTh.SetFillStyle(0) #legendTh.SetTextFont(42) #legendTh.SetTextSize(0.03) #legendTh.AddEntry(graph_xsAxi,"Axigluon/coloron","l") #legendTh.AddEntry(graph_xsDiquark,"Scalar diquark","l") #legendTh.AddEntry(graph_xsWprime,"W' SSM","l") #legendTh.AddEntry(graph_xsZprime,"Z' SSM","l") #legendTh.Draw() # draw the lumi text on the canvas CMS_lumi.extraText = args.extraText CMS_lumi.lumi_sqrtS = args.lumi_sqrtS # used with iPeriod = 0 (free form) iPos = 11 iPeriod = 0 CMS_lumi.CMS_lumi(c, iPeriod, iPos) gPad.RedrawAxis() c.SetLogy() postfix = ( ('_' + args.postfix) if args.postfix != '' else '' ) if args.noSyst: postfix += "_noSyst" if args.freezeNuisances: postfix += "_" + args.freezeNuisances.replace(",", "_") if args.fitTrigger: postfix += "_fitTrigger" elif args.correctTrigger: postfix += "_correctTrigger" if args.useMCTrigger: postfix += "_useMCTrigger" fileName = limit_config.paths["limit_plots"] + '/xs_limit_%s_%s_%s_%s.%s'%(args.method,args.analysis, args.model + postfix, args.fit_function, args.fileFormat.lower()) if args.timesAE: fileName = fileName.replace("xs_limit", "xsAE_limit") c.SaveAs(fileName) print "Plot saved to '%s'"%(fileName) graph_obs.Print("all") if args.saveObjects: output_file = args.saveObjects if args.timesAE: output_file = output_file.replace(".root", "_timesAE.root") f = TFile(output_file, "RECREATE") if args.method == "Asymptotic" or args.method == "HybridNewGrid": graph_exp_2sigma.SetName("graph_exp_2sigma") graph_exp_2sigma.Write() graph_exp_1sigma.SetName("graph_exp_1sigma") graph_exp_1sigma.Write() graph_exp.SetName("graph_exp") graph_exp.Write() graph_obs.SetName("graph_obs") graph_obs.Write() f.Close()
def initialize2(self): # For the canvas: gStyle.SetCanvasBorderMode(0) gStyle.SetCanvasColor(kWhite) gStyle.SetCanvasDefH(600) #Height of canvas gStyle.SetCanvasDefW(600) #Width of canvas gStyle.SetCanvasDefX(0) #POsition on screen gStyle.SetCanvasDefY(0) # For the Pad: gStyle.SetPadBorderMode(0) # gStyle.SetPadBorderSize(Width_t size = 1) gStyle.SetPadColor(kWhite) gStyle.SetPadGridX(False) gStyle.SetPadGridY(False) gStyle.SetGridColor(0) gStyle.SetGridStyle(3) gStyle.SetGridWidth(1) # For the frame: gStyle.SetFrameBorderMode(0) gStyle.SetFrameBorderSize(1) gStyle.SetFrameFillStyle(1000) gStyle.SetFrameFillColor(0) gStyle.SetFrameFillStyle(0) gStyle.SetFrameLineColor(1) gStyle.SetFrameLineStyle(1) gStyle.SetFrameLineWidth(1) # For the histo: # gStyle.SetHistFillColor(1) # gStyle.SetHistFillStyle(0) gStyle.SetHistLineColor(1) gStyle.SetHistLineStyle(0) gStyle.SetHistLineWidth(1) # gStyle.SetLegoInnerR(Float_t rad = 0.5) # gStyle.SetNumberContours(Int_t number = 20) gStyle.SetEndErrorSize(2) # gStyle.SetErrorMarker(20) gStyle.SetErrorX(0.) gStyle.SetMarkerStyle(20) #For the fit/function: gStyle.SetOptFit(1) gStyle.SetFitFormat("5.4g") gStyle.SetFuncColor(2) gStyle.SetFuncStyle(1) gStyle.SetFuncWidth(1) #For the date: gStyle.SetOptDate(0) # gStyle.SetDateX(Float_t x = 0.01) # gStyle.SetDateY(Float_t y = 0.01) # For the statistics box: gStyle.SetOptFile(0) gStyle.SetOptStat( 0) # To display the mean and RMS: SetOptStat("mr") gStyle.SetStatColor(kWhite) gStyle.SetStatFont(42) gStyle.SetStatFontSize(0.025) gStyle.SetStatTextColor(1) gStyle.SetStatFormat("6.4g") gStyle.SetStatBorderSize(1) gStyle.SetStatH(0.1) gStyle.SetStatW(0.15) # gStyle.SetStatStyle(Style_t style = 1001) # gStyle.SetStatX(Float_t x = 0) # gStyle.SetStatY(Float_t y = 0) # Margins: gStyle.SetPadTopMargin(0.05) gStyle.SetPadBottomMargin(0.13) gStyle.SetPadLeftMargin(0.16) gStyle.SetPadRightMargin(0.02) # For the Global title: gStyle.SetOptTitle(0) gStyle.SetTitleFont(42) gStyle.SetTitleColor(1) gStyle.SetTitleTextColor(1) gStyle.SetTitleFillColor(10) gStyle.SetTitleFontSize(0.05) # gStyle.SetTitleH(0) # Set the height of the title box # gStyle.SetTitleW(0) # Set the width of the title box # gStyle.SetTitleX(0) # Set the position of the title box # gStyle.SetTitleY(0.985) # Set the position of the title box # gStyle.SetTitleStyle(Style_t style = 1001) # gStyle.SetTitleBorderSize(2) # For the axis titles: gStyle.SetTitleColor(1, "XYZ") gStyle.SetTitleFont(42, "XYZ") gStyle.SetTitleSize(0.06, "XYZ") # gStyle.SetTitleXSize(Float_t size = 0.02) # Another way to set the size? # gStyle.SetTitleYSize(Float_t size = 0.02) gStyle.SetTitleXOffset(0.9) gStyle.SetTitleYOffset(1.25) # gStyle.SetTitleOffset(1.1, "Y") # Another way to set the Offset # For the axis labels: gStyle.SetLabelColor(1, "XYZ") gStyle.SetLabelFont(42, "XYZ") gStyle.SetLabelOffset(0.007, "XYZ") gStyle.SetLabelSize(0.05, "XYZ") # For the axis: gStyle.SetAxisColor(1, "XYZ") gStyle.SetStripDecimals(True) gStyle.SetTickLength(0.03, "XYZ") gStyle.SetNdivisions(510, "XYZ") gStyle.SetPadTickX( 1) # To get tick marks on the opposite side of the frame gStyle.SetPadTickY(1) # Change for log plots: gStyle.SetOptLogx(0) gStyle.SetOptLogy(0) gStyle.SetOptLogz(0) # Postscript options: gStyle.SetPaperSize(20., 20.)
def setTDRStyle(force): gStyle.SetCanvasBorderMode(0) gStyle.SetCanvasColor(kWhite) gStyle.SetCanvasDefH(600) gStyle.SetCanvasDefW(600) gStyle.SetCanvasDefX(0) gStyle.SetCanvasDefY(0) gStyle.SetPadBorderMode(0) gStyle.SetPadColor(kWhite) gStyle.SetPadGridX(False) gStyle.SetPadGridY(False) gStyle.SetGridColor(0) gStyle.SetGridStyle(3) gStyle.SetGridWidth(1) gStyle.SetFrameBorderMode(0) gStyle.SetFrameBorderSize(1) gStyle.SetFrameFillColor(0) gStyle.SetFrameFillStyle(0) gStyle.SetFrameLineColor(1) gStyle.SetFrameLineStyle(1) gStyle.SetFrameLineWidth(1) if force: gStyle.SetHistLineColor(1) gStyle.SetHistLineStyle(0) gStyle.SetHistLineWidth(1) gStyle.SetEndErrorSize(2) gStyle.SetErrorX(0.) gStyle.SetMarkerStyle(20) gStyle.SetOptFit(1) gStyle.SetFitFormat("5.4g") gStyle.SetFuncColor(2) gStyle.SetFuncStyle(1) gStyle.SetFuncWidth(1) gStyle.SetOptDate(0) gStyle.SetOptFile(0) gStyle.SetOptStat(0) gStyle.SetStatColor(kWhite) gStyle.SetStatFont(42) gStyle.SetStatFontSize(0.04) gStyle.SetStatTextColor(1) gStyle.SetStatFormat("6.4g") gStyle.SetStatBorderSize(1) gStyle.SetStatH(0.1) gStyle.SetStatW(0.2) gStyle.SetPadTopMargin(0.05) gStyle.SetPadBottomMargin(0.13) gStyle.SetPadLeftMargin(0.16) gStyle.SetPadRightMargin(0.04) gStyle.SetOptTitle(0) gStyle.SetTitleFont(42) gStyle.SetTitleColor(1) gStyle.SetTitleTextColor(1) gStyle.SetTitleFillColor(10) gStyle.SetTitleFontSize(0.05) gStyle.SetTitleColor(1, "XYZ") gStyle.SetTitleFont(42, "XYZ") gStyle.SetTitleSize(0.06, "XYZ") gStyle.SetTitleXOffset(0.9) gStyle.SetTitleYOffset(1.25) gStyle.SetLabelColor(1, "XYZ") gStyle.SetLabelFont(42, "XYZ") gStyle.SetLabelOffset(0.007, "XYZ") gStyle.SetLabelSize(0.05, "XYZ") gStyle.SetAxisColor(1, "XYZ") gStyle.SetStripDecimals(True) gStyle.SetTickLength(0.03, "XYZ") gStyle.SetNdivisions(510, "XYZ") gStyle.SetPadTickX(1) gStyle.SetPadTickY(1) gStyle.SetOptLogx(0) gStyle.SetOptLogy(0) gStyle.SetOptLogz(0) gStyle.SetPaperSize(20.,20.) gROOT.ForceStyle()
def initStyle(): gROOT.SetStyle("Plain") # For the canvas: gStyle.SetCanvasBorderMode(0) gStyle.SetCanvasColor(kWhite) gStyle.SetCanvasDefH(700) #Height of canvas gStyle.SetCanvasDefW(700) #Width of canvas gStyle.SetCanvasDefX(0) #Position on screen gStyle.SetCanvasDefY(0) # For the line: gStyle.SetLineWidth(2) # For the Pad: gStyle.SetPadBorderMode(0) # gStyle.SetPadBorderSize(Width_t size = 1) gStyle.SetPadColor(kWhite) gStyle.SetPadGridX(True) gStyle.SetPadGridY(True) gStyle.SetGridColor(0) gStyle.SetGridStyle(3) gStyle.SetGridWidth(1) # For the frame: gStyle.SetFrameBorderMode(0) gStyle.SetFrameBorderSize(1) gStyle.SetFrameFillColor(0) gStyle.SetFrameFillStyle(0) gStyle.SetFrameLineColor(1) gStyle.SetFrameLineStyle(1) gStyle.SetFrameLineWidth(1) # For the histo: # gStyle.SetHistFillColor(1) # gStyle.SetHistFillStyle(0) gStyle.SetHistLineColor(1) gStyle.SetHistLineStyle(0) gStyle.SetHistLineWidth(2) # gStyle.SetLegoInnerR(Float_t rad = 0.5) # gStyle.SetNumberContours(Int_t number = 20) gStyle.SetEndErrorSize(2) #gStyle.SetErrorMarker(20) gStyle.SetErrorX(0.) gStyle.SetMarkerStyle(8) gStyle.SetMarkerSize(1) #For the fit/function: gStyle.SetOptFit(0) gStyle.SetFitFormat("5.4g") gStyle.SetFuncColor(2) gStyle.SetFuncStyle(1) gStyle.SetFuncWidth(1) #For the date: gStyle.SetOptDate(0) # gStyle.SetDateX(Float_t x = 0.01) # gStyle.SetDateY(Float_t y = 0.01) # For the statistics box: gStyle.SetOptFile(0) gStyle.SetOptStat(0) # To display the mean and RMS: SetOptStat("mr") gStyle.SetStatColor(kWhite) gStyle.SetStatFont(42) gStyle.SetStatFontSize(0.025) gStyle.SetStatTextColor(1) gStyle.SetStatFormat("6.4g") gStyle.SetStatBorderSize(1) gStyle.SetStatH(0.1) gStyle.SetStatW(0.15) # gStyle.SetStatStyle(Style_t style = 1001) # gStyle.SetStatX(Float_t x = 0) # gStyle.SetStatY(Float_t y = 0) # Margins: gStyle.SetPadTopMargin(0.11) gStyle.SetPadBottomMargin(0.13) gStyle.SetPadLeftMargin(0.17) gStyle.SetPadRightMargin(0.07) # For the Global title: gStyle.SetOptTitle(0) gStyle.SetTitleFont(42) gStyle.SetTitleColor(1) gStyle.SetTitleTextColor(1) gStyle.SetTitleFillColor(10) gStyle.SetTitleFontSize(0.04) # gStyle.SetTitleH(0) # Set the height of the title box # gStyle.SetTitleW(0) # Set the width of the title box #gStyle.SetTitleX(0.35) # Set the position of the title box #gStyle.SetTitleY(0.986) # Set the position of the title box # gStyle.SetTitleStyle(Style_t style = 1001) #gStyle.SetTitleBorderSize(0) # For the axis titles: gStyle.SetTitleColor(1, "XYZ") gStyle.SetTitleFont(42, "XYZ") gStyle.SetTitleSize(0.05, "XYZ") # gStyle.SetTitleXSize(Float_t size = 0.02) # Another way to set the size? # gStyle.SetTitleYSize(Float_t size = 0.02) gStyle.SetTitleXOffset(1.) gStyle.SetTitleYOffset(1.3) #gStyle.SetTitleOffset(1.1, "Y") # Another way to set the Offset # For the axis labels: gStyle.SetLabelColor(1, "XYZ") gStyle.SetLabelFont(42, "XYZ") gStyle.SetLabelOffset(0.007, "XYZ") gStyle.SetLabelSize(0.035, "XYZ") # For the axis: gStyle.SetAxisColor(1, "XYZ") gStyle.SetStripDecimals(True) gStyle.SetTickLength(0.03, "XYZ") gStyle.SetNdivisions(510, "XYZ") gStyle.SetPadTickX( 1) # To get tick marks on the opposite side of the frame gStyle.SetPadTickY(1) # Change for log plots: gStyle.SetOptLogx(0) gStyle.SetOptLogy(0) gStyle.SetOptLogz(0) gStyle.SetPalette(1) #(1,0) # another top group addition gStyle.SetHatchesSpacing(1.0) # Postscript options: gStyle.SetPaperSize(20., 20.) #gStyle.SetPaperSize(TStyle.kA4) #gStyle.SetPaperSize(27., 29.7) #TGaxis.SetMaxDigits(3) # gStyle.SetLineScalePS(Float_t scale = 3) # gStyle.SetLineStyleString(Int_t i, const char* text) # gStyle.SetHeaderPS(const char* header) # gStyle.SetTitlePS(const char* pstitle) #gStyle.SetColorModelPS(1) # gStyle.SetBarOffset(Float_t baroff = 0.5) # gStyle.SetBarWidth(Float_t barwidth = 0.5) # gStyle.SetPaintTextFormat(const char* format = "g") # gStyle.SetPalette(Int_t ncolors = 0, Int_t* colors = 0) # gStyle.SetTimeOffset(Double_t toffset) # gStyle.SetHistMinimumZero(kTRUE) #gStyle.cd() print "TDR Style initialized"
def CLICdpStyle(): gROOT.SetStyle("Plain") gStyle.SetCanvasColor(root.kWhite) gStyle.SetFrameFillColor(root.kWhite) gStyle.SetStatColor(root.kWhite) gStyle.SetPadColor(root.kWhite) gStyle.SetFillColor(10) gStyle.SetTitleFillColor(root.kWhite) gStyle.SetPaperSize(20, 26) gStyle.SetDrawBorder(0) gStyle.SetCanvasBorderMode(0) gStyle.SetPadBorderMode(0) gStyle.SetFrameBorderMode(0) gStyle.SetLegendBorderSize(0) gStyle.SetTextSize(0.05) gStyle.SetTitleSize(0.06, "xyz") gStyle.SetLabelSize(0.06, "xyz") gStyle.SetLabelOffset(0.015, "xyz") gStyle.SetTitleOffset(1.2, "yz") gStyle.SetTitleOffset(1.17, "x") font = 42 gStyle.SetTitleFont(font) gStyle.SetTitleFontSize(0.06) gStyle.SetStatFont(font) gStyle.SetStatFontSize(0.07) gStyle.SetTextFont(font) gStyle.SetLabelFont(font, "xyz") gStyle.SetTitleFont(font, "xyz") gStyle.SetTitleBorderSize(0) gStyle.SetStatBorderSize(1) gStyle.SetMarkerStyle(1) gStyle.SetLineWidth(2) gStyle.SetMarkerSize(1.2) gStyle.SetPalette(1) gStyle.SetOptTitle(0) gStyle.SetOptStat(0) gStyle.SetOptFit(0) gStyle.SetEndErrorSize(5) gStyle.SetHistLineWidth(2) gStyle.SetFrameLineWidth(2) gStyle.SetFuncWidth(2) gStyle.SetHistLineColor(root.kBlack) gStyle.SetFuncColor(root.kBlack) gStyle.SetLabelColor(root.kBlack, "xyz") gStyle.SetPadBottomMargin(0.18) gStyle.SetPadTopMargin(0.11) gStyle.SetPadRightMargin(0.08) gStyle.SetPadLeftMargin(0.17) gStyle.SetNdivisions(506, "xy") gStyle.SetPadGridX(0) gStyle.SetPadGridY(0) gStyle.SetPadTickX(1) gStyle.SetPadTickY(1) gStyle.SetCanvasDefW(800) gStyle.SetCanvasDefH(700) gROOT.ForceStyle()
def main(): # usage description usage = "Example: ./scripts/plotSignificance.py -l logs -f qq --massrange 1200 6000 100" # input parameters parser = ArgumentParser( description='Script that plots significance for specified mass points', epilog=usage) parser.add_argument('analysis', type=str, help='Analysis name') parser.add_argument('model', type=str, help='Model name') parser.add_argument("-M", "--method", dest="method", choices=['ProfileLikelihood', 'HybridNew', 'theta'], default='ProfileLikelihood', help="Method to calculate upper limits", metavar="METHOD") parser.add_argument( '--fit_function', type=str, default="dijet4", help="Name of fit function used for background estimate") parser.add_argument( "--sigRange", dest="sigRange", type=float, default=2.5, help="Significance range to plot (default: %(default)f)") parser.add_argument( "--postfix", dest="postfix", default='', help="Postfix for the output plot name (default: %(default)s)") parser.add_argument( "--fileFormat", dest="fileFormat", default='pdf', help="Format of the output plot (default: %(default)s)") parser.add_argument("--extraText", dest="extraText", default='Preliminary', help="Extra text on the plot (default: %(default)s)") parser.add_argument( "--lumi_sqrtS", dest="lumi_sqrtS", default='19.7 fb^{-1} (13 TeV)', help= "Integrated luminosity and center-of-mass energy (default: %(default)s)" ) parser.add_argument("--printResults", dest="printResults", default=False, action="store_true", help="Print results to the screen") parser.add_argument('--fitTrigger', action='store_true', help="Use trigger fit") parser.add_argument('--correctTrigger', action='store_true', help="Use trigger correction") parser.add_argument('--useMCTrigger', action='store_true', help="Use MC trigger emulation") parser.add_argument("--noSyst", action="store_true", help="Make plots for limits without systematics") parser.add_argument( "--freezeNuisances", type=str, help="Make plots for limits with frozen nuisance parameters") mass_group = parser.add_mutually_exclusive_group(required=True) mass_group.add_argument( "--mass", type=int, nargs='*', default=1000, help= "Mass can be specified as a single value or a whitespace separated list (default: %(default)i)" ) mass_group.add_argument( "--massrange", type=int, nargs=3, help="Define a range of masses to be produced. Format: min max step", metavar=('MIN', 'MAX', 'STEP')) mass_group.add_argument("--masslist", help="List containing mass information") args = parser.parse_args() # mass points for which resonance shapes will be produced input_masses = [] if args.massrange != None: MIN, MAX, STEP = args.massrange input_masses = range(MIN, MAX + STEP, STEP) elif args.masslist != None: # A mass list was provided print "Will create mass list according to", args.masslist masslist = __import__(args.masslist.replace(".py", "")) input_masses = masslist.masses else: input_masses = args.mass # sort masses input_masses.sort() # arrays holding results masses = array('d') significances = array('d') p0_values = array('d') for mass in input_masses: masses.append(mass) #print ">> Reading results for resonance with m = %i GeV..."%(int(mass)) log_file = open( limit_config.get_combine_log_path( args.analysis, args.model, mass, args.fit_function, args.method, what="significance", systematics=(not args.noSyst), frozen_nps=args.freezeNuisances, fitTrigger=args.fitTrigger, correctTrigger=args.correctTrigger, useMCTrigger=args.useMCTrigger), 'r') if args.method == 'theta': logName = logName.replace('significance_', '') # read the log file for line in log_file: if args.method == 'theta': if re.search("^{'signal': {'Z':", line): significances.append( float(line.split()[-1].lstrip('[').rstrip('}').rstrip( ']'))) else: if re.search("^Significance:", line): significances.append(float(line.split()[1])) elif re.search("^Null p-value:", line): p0_values.append(float(line.split()[2])) if len(masses) != len(significances): print "** ERROR: ** Could not find significance for m =", int( mass), "GeV. Aborting." sys.exit(1) if len(masses) != len(p0_values): print "** ERROR: ** Could not find p0 value for m =", int( mass), "GeV. Aborting." sys.exit(1) # Allow only positive fluctuations if significances[-1] < 0: significances[-1] = 0. if args.printResults: print "masses =", masses.tolist() print "significances =", significances.tolist() print "p0_values =", p0_values.tolist() # import ROOT stuff from ROOT import kTRUE, kFALSE, gROOT, gStyle, gPad, TGraph, TCanvas, TLegend from ROOT import kGreen, kYellow, kWhite, kRed, kBlue gROOT.SetBatch(kTRUE) gStyle.SetOptStat(0) gStyle.SetOptTitle(0) gStyle.SetTitleFont(42, "XYZ") gStyle.SetTitleSize(0.06, "XYZ") gStyle.SetLabelFont(42, "XYZ") gStyle.SetLabelSize(0.05, "XYZ") gStyle.SetCanvasBorderMode(0) gStyle.SetFrameBorderMode(0) gStyle.SetCanvasColor(kWhite) gStyle.SetPadTickX(1) gStyle.SetPadTickY(1) gStyle.SetPadLeftMargin(0.15) gStyle.SetPadRightMargin(0.05) gStyle.SetPadTopMargin(0.05) gStyle.SetPadBottomMargin(0.15) gROOT.ForceStyle() graph_sig = TGraph(len(masses), masses, significances) graph_sig.GetXaxis().SetTitle("Resonance mass [GeV]") graph_sig.GetYaxis().SetTitle("p_0") graph_sig.GetYaxis().SetTitleOffset(1.2) graph_sig.GetYaxis().SetRangeUser(0., args.sigRange) graph_sig.SetLineWidth(2) graph_sig.SetLineColor(kRed) graph_sig.SetMarkerStyle(21) graph_sig.SetMarkerSize(1) graph_sig.SetMarkerColor(kBlue) c = TCanvas("c", "", 800, 800) c.cd() graph_sig.Draw("ALP") # draw the lumi text on the canvas CMS_lumi.extraText = args.extraText CMS_lumi.lumi_sqrtS = args.lumi_sqrtS # used with iPeriod = 0 (free form) iPos = 11 iPeriod = 0 CMS_lumi.CMS_lumi(c, iPeriod, iPos) gPad.RedrawAxis() c.SetGridx() c.SetGridy() fileName = limit_config.paths[ "limit_plots"] + '/significance_%s_%s_%s_%s.%s' % ( args.method, args.analysis, args.model + args.postfix, args.fit_function, args.fileFormat.lower()) c.SaveAs(fileName) #print "Significance plot saved to '%s'"%(fileName) graph_p0 = TGraph(len(masses), masses, p0_values) graph_p0.GetXaxis().SetTitle("Resonance mass [GeV]") graph_p0.GetYaxis().SetTitle("p_{0} (local)") graph_p0.GetYaxis().SetTitleOffset(1.2) graph_p0.GetYaxis().SetRangeUser(1.e-3, 1.) graph_p0.SetLineWidth(2) graph_p0.SetLineColor(kRed) graph_p0.SetMarkerStyle(21) graph_p0.SetMarkerSize(1) graph_p0.SetMarkerColor(kBlue) c_p0 = TCanvas("c_p0", "", 800, 800) c_p0.SetLogy() c_p0.cd() graph_p0.Draw("ALP") # draw the lumi text on the canvas # draw the lumi text on the canvas CMS_lumi.extraText = args.extraText CMS_lumi.lumi_sqrtS = args.lumi_sqrtS # used with iPeriod = 0 (free form) iPos = 11 iPeriod = 0 CMS_lumi.CMS_lumi(c, iPeriod, iPos) #Root.CMSLabel(0.2, 0.2, "Internal", 1, 0.65) gPad.RedrawAxis() c_p0.SetGridx() c_p0.SetGridy() fileName = limit_config.paths["limit_plots"] + '/p0_%s_%s_%s_%s.%s' % ( args.method, args.analysis, args.model + args.postfix, args.fit_function, args.fileFormat.lower()) c_p0.SaveAs(fileName) print "p0 plot saved to '%s'" % (fileName)
def setgstyle(): # Zero horizontal error bars gStyle.SetErrorX(0) # For the canvas gStyle.SetCanvasBorderMode(0) gStyle.SetCanvasColor(0) gStyle.SetCanvasDefH(800) # Height of canvas gStyle.SetCanvasDefW(800) # Width of canvas gStyle.SetCanvasDefX(0) # Position on screen gStyle.SetCanvasDefY(0) # For the frame gStyle.SetFrameBorderMode(0) gStyle.SetFrameBorderSize(1) gStyle.SetFrameFillColor(1) gStyle.SetFrameFillStyle(0) gStyle.SetFrameLineColor(1) gStyle.SetFrameLineStyle(0) gStyle.SetFrameLineWidth(1) # For the Pad gStyle.SetPadBorderMode(0) gStyle.SetPadColor(0) gStyle.SetPadGridX(False) gStyle.SetPadGridY(False) gStyle.SetGridColor(0) gStyle.SetGridStyle(3) gStyle.SetGridWidth(1) # Margins gStyle.SetPadTopMargin(0.08) gStyle.SetPadBottomMargin(0.19) gStyle.SetPadLeftMargin(0.17) #gStyle.SetPadRightMargin(0.07) # For the histo: gStyle.SetHistLineColor(1) gStyle.SetHistLineStyle(0) gStyle.SetHistLineWidth(2) gStyle.SetMarkerSize(1.4) gStyle.SetEndErrorSize(4) # For the statistics box: gStyle.SetOptStat(0) # For the axis gStyle.SetAxisColor(1, "XYZ") gStyle.SetTickLength(0.03, "XYZ") gStyle.SetNdivisions(510, "XYZ") gStyle.SetPadTickX(1) gStyle.SetPadTickY(1) gStyle.SetStripDecimals(False) # For the axis labels and titles gStyle.SetTitleColor(1, "XYZ") gStyle.SetLabelColor(1, "XYZ") gStyle.SetLabelFont(42, "XYZ") gStyle.SetLabelOffset(0.007, "XYZ") gStyle.SetLabelSize(0.045, "XYZ") gStyle.SetTitleFont(42, "XYZ") gStyle.SetTitleSize(0.06, "XYZ") # For the legend gStyle.SetLegendBorderSize(0)