def TopMassStyle(): """Set the style plot in order to create fancier plots!""" gStyle.SetPadTickX(1); gStyle.SetPadTickY(1); gStyle.SetHistLineWidth(3); gStyle.SetMarkerStyle(1); gStyle.SetTextSize(0.065); gStyle.SetOptFit(1111); gStyle.SetTitleSize(.05,"X");#.055 gStyle.SetTitleOffset(1.1,"X");#1.2,0.9 gStyle.SetLabelSize(.05,"X"); gStyle.SetTitleSize(.05,"Y");#.055 gStyle.SetTitleOffset(1.1,"Y"); gStyle.SetLabelSize(.05,"Y"); gStyle.SetPadLeftMargin(.16); gStyle.SetPadBottomMargin(.12); gStyle.SetTitleSize(.05,"Z"); gStyle.SetTitleOffset(1.8,"Z"); gStyle.SetLabelSize(0.06,"Z"); gStyle.SetLegendTextSize(0.04); gStyle.SetOptStat(112210); gStyle.SetPadLeftMargin(.12); gStyle.SetPadRightMargin(.02); gStyle.SetPadBottomMargin(.12); gStyle.SetPadTopMargin(.07); gStyle.SetPadGridX(1); gStyle.SetPadGridY(1);
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 SetStyle(): gROOT.SetStyle('Plain') gROOT.ForceStyle() gStyle.SetTextFont(42) gStyle.SetOptTitle(0) gStyle.SetOptFit(1112) gStyle.SetOptStat(1110) gStyle.SetPadRightMargin(0.08) gStyle.SetPadTopMargin(0.11) gStyle.SetPadBottomMargin(0.12) gStyle.SetTitleFont(42, 'x') gStyle.SetTitleFont(42, 'y') gStyle.SetTitleFont(42, 'z') gStyle.SetTitleOffset(1.05, 'x') gStyle.SetTitleOffset(1.00, 'y') gStyle.SetTitleSize(0.05, 'x') gStyle.SetTitleSize(0.05, 'y') gStyle.SetTitleSize(0.05, 'z') gStyle.SetLabelFont(42, 'x') gStyle.SetLabelFont(42, 'y') gStyle.SetLabelFont(42, 'z') gStyle.SetLabelSize(0.05, 'x') gStyle.SetLabelSize(0.05, 'y') gStyle.SetLabelSize(0.05, 'z') TGaxis.SetMaxDigits(3) gStyle.SetStatY(0.9)
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 load_joeys_style(): from ROOT import gStyle, gROOT font_id = 12 gStyle.SetOptStat(0) gStyle.SetTitleFont(font_id, "X") # LaTeX typeface gStyle.SetTitleFont(font_id, "Y") gStyle.SetTitleFont(font_id, "Z") gStyle.SetTitleFont(font_id, "T") gStyle.SetLabelFont(font_id, "X") # LaTeX typeface gStyle.SetLabelFont(font_id, "Y") gStyle.SetLabelFont(font_id, "Z") gStyle.SetPadTickX(1) gStyle.SetPadTickY(1) gStyle.SetPadTopMargin(0.13) gStyle.SetPadBottomMargin(0.25) gStyle.SetPadLeftMargin(0.17) gStyle.SetPadRightMargin(0.25) gStyle.SetCanvasDefW(1500) gStyle.SetCanvasDefH(900) gStyle.SetTitleSize(0.06,"X") gStyle.SetTitleSize(0.06,"Y") gStyle.SetTitleSize(0.06,"Z") gStyle.SetTitleSize(0.06,"T") # for title gStyle.SetLabelSize(0.04,"X") gStyle.SetLabelSize(0.04,"Y") gStyle.SetLabelSize(0.04,"Z") gStyle.SetTitleOffset(1.5,"X") gStyle.SetTitleOffset(1.1,"Y") gStyle.SetTitleOffset(1.3,"Z") gROOT.ForceStyle()
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 setStyle(): gStyle.SetOptStat(0) gStyle.SetPadRightMargin(0.18) gStyle.SetPadLeftMargin(0.15) gStyle.SetPadBottomMargin(0.1) gStyle.SetPadTopMargin(0.06) gStyle.SetOptTitle(0) gStyle.SetPalette(55)
def DefaultPlotStyle(self): gStyle.SetPalette(55) # 55 is kRainBow. 53 is kDarkBodyRadiator gStyle.SetOptStat(self.optStat1D) gStyle.SetOptFit(11111) gStyle.SetStatH(0.12) gStyle.SetStatW(0.15) gStyle.SetPadBottomMargin(0.15) gStyle.SetPadTopMargin(0.15)
def _initDefaultStyle(self): gROOT.Reset() gROOT.SetStyle("Plain") gStyle.SetOptStat(0) gStyle.SetOptFit(1111) gStyle.SetPadLeftMargin(0.12) gStyle.SetPadBottomMargin(0.12) gStyle.SetMarkerSize(1.) gStyle.SetHistLineWidth(1)
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 rootlogon(): from ROOT import gStyle gStyle.SetOptStat(0) gStyle.SetPadTopMargin(0.07) gStyle.SetPadRightMargin(0.05) gStyle.SetPadBottomMargin(0.13) gStyle.SetPadLeftMargin(0.19) gStyle.SetTitleOffset(1.2, 'x') gStyle.SetTitleOffset(1.8, 'y') gStyle.SetTextSize(0.05) gStyle.SetLabelSize(0.05, 'xyz') gStyle.SetTitleSize(0.05, 'xyz') gStyle.SetTitleSize(0.05, 't') gStyle.SetPadTickX(1) gStyle.SetPadTickY(1)
def _initDefaultStyle(self): gROOT.Reset() gROOT.SetStyle("Plain") #gStyle.SetOptStat(0) gStyle.SetOptFit(1111) gStyle.SetPadLeftMargin(0.1) gStyle.SetPadBottomMargin(0.1) gStyle.SetMarkerSize(1.5) gStyle.SetHistLineWidth(1) gStyle.SetStatFontSize(0.025) gStyle.SetTitleFontSize(0.05) gStyle.SetTitle( 'CMS Preliminary tH, H#to#tau#tau, 19.7 fb^{-1} at 8 TeV') gStyle.SetTitleSize(0.06, "XYZ") gStyle.SetLabelSize(0.05, "XYZ") gStyle.SetNdivisions(510, "XYZ")
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 plot_ROC_curve(ROC_curve, file_name_portion): gStyle.SetOptStat(0) gStyle.SetLabelSize(0.03, "xy") gStyle.SetTitleSize(0.03, "xy") gStyle.SetTitleOffset(1.2, "xy") gStyle.SetPadLeftMargin(0.15) gStyle.SetPadRightMargin(0.1) gStyle.SetPadTopMargin(0.1) gStyle.SetPadBottomMargin(0.15) canvas = TCanvas("c1", "c1", 800, 800) canvas.SetTickx() canvas.SetTicky() ROC_curve.GetYaxis().SetTitle('Background rejection') ROC_curve.GetXaxis().SetTitle('Signal efficiency') ROC_curve.SetLineColor(TColor.kAzure) ROC_curve.SetFillColor(TColor.kAzure - 2) ROC_curve.SetLineWidth(2) ROC_curve.SetFillStyle(0) from array import array x, y = array('d'), array('d') x.append(EFF_SIGNAL_DIRECT_CUT) y.append(1 - EFF_BACKGROUND_DIRECT_CUT) dot = TGraph(1, x, y) dot.SetMarkerColor(8) dot.SetMarkerSize(3) dot.SetMarkerStyle(21) legend = TLegend(0.2, 0.2, 0.4, 0.4) legend.SetTextSize(0.04) legend.SetTextFont(42) legend.SetFillColor(10) legend.SetLineColor(10) legend.SetBorderSize(0) legend.AddEntry(ROC_curve, "BDT 500 trees", "l") legend.AddEntry(dot, "m_{jj} > 500 GeV and |#Delta#eta_{jj}| > 3 cut", "P") ROC_curve.Draw("HIST") legend.Draw("same") dot.Draw("LPsame") canvas.RedrawAxis() canvas.Print(file_name_portion + "_ROC" + ".png")
def __init__(self): ''' Set up PlotStyle, set gStyle for things we always want no matter what. ''' # CMS-approved everything tdrstyle.setTDRStyle() ### Differences from TDR standard: # Big canvas (can always shrink later) gStyle.SetCanvasDefH(1200) gStyle.SetCanvasDefW(1200) # Tick marks on all sides gStyle.SetPadTickX(1) gStyle.SetPadTickY(1) # Everything has white backgrounds gStyle.SetLegendFillColor(0) # Colors that don't suck gStyle.SetPalette(1) # Make axis title and labels just a little smaller and (for Y) closer to the axis gStyle.SetTitleSize(0.044, "XYZ") gStyle.SetLabelSize(0.033, "XYZ") gStyle.SetTitleYOffset(1.15) gStyle.SetTitleXOffset(0.95) gStyle.SetPadLeftMargin(0.1) gStyle.SetPadRightMargin(0.025) gStyle.SetPadBottomMargin(0.095) gStyle.SetTitleAlign(12) # Apply changes gROOT.ForceStyle() # Force exponentials when axes are over 3 digits TGaxis.SetMaxDigits(3) TGaxis.SetExponentOffset(-0.060, 0.008, "y") TGaxis.SetExponentOffset( -0.055, -0.062, "x") # will overlap with title unless title is centered
def my_style(): gStyle.SetLabelSize(fontsize, "x") gStyle.SetLabelSize(fontsize, "y") gStyle.SetLabelSize(fontsize, "z") gStyle.SetTitleFontSize(1.5 * fontsize) gStyle.SetTitleSize(fontsize, "x") gStyle.SetTitleSize(fontsize, "y") gStyle.SetTitleSize(fontsize, "z") gStyle.SetTickLength(0, "Y") gStyle.SetTitleOffset(1.5, "xy") gStyle.SetTitleFont(62, "bla") gStyle.SetPadBottomMargin(0.15) gStyle.SetPadTopMargin(0.10) gStyle.SetPadLeftMargin(0.32) gStyle.SetPadRightMargin(0.05) gStyle.SetStatX(0.88) gStyle.SetStatY(0.87) gStyle.SetNdivisions(505) gStyle.SetCanvasColor(-1) gStyle.SetPadColor(-1) gStyle.SetFrameFillColor(-1) gStyle.SetTitleFillColor(-1) gStyle.SetFillColor(-1) gStyle.SetFillStyle(4000) gStyle.SetStatStyle(0) gStyle.SetTitleStyle(0) gStyle.SetCanvasBorderSize(0) gStyle.SetFrameBorderSize(0) gStyle.SetLegendBorderSize(0) gStyle.SetStatBorderSize(0) gStyle.SetTitleBorderSize(0)
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 SetGlobalStyle(**kwargs): ''' Method to set global style. Parameters ---------- - padrightmargin (float), default = 0.035 - padleftmargin (float), default = 0.12 - padtopmargin (float), default = 0.035 - padbottommargin (float), default = 0.12 - titlesize (float), default = 0.050 - titlesizex (float), default = 0.050 - titlesizey (float), default = 0.050 - titlesizez (float), default = 0.050 - labelsize (float), default = 0.045 - labelsizex (float), default = 0.045 - labelsizey (float), default = 0.045 - labelsizez (float), default = 0.045 - titleoffset (float), default = 1.2 - titleoffsetx (float), default = 1.2 - titleoffsey (float), default = 1.2 - titleoffsetz (float), default = 1.2 - opttitle (int), default = 0 - optstat (int), default = 0 - padtickx (int), default = 1 - padticky (int), default = 1 - maxdigits (int), default no max value - palette (int), default kBird ''' # pad margins if 'padrightmargin' in kwargs: gStyle.SetPadRightMargin(kwargs['padrightmargin']) else: gStyle.SetPadRightMargin(0.035) if 'padleftmargin' in kwargs: gStyle.SetPadLeftMargin(kwargs['padleftmargin']) else: gStyle.SetPadLeftMargin(0.12) if 'padtopmargin' in kwargs: gStyle.SetPadTopMargin(kwargs['padtopmargin']) else: gStyle.SetPadTopMargin(0.035) if 'padbottommargin' in kwargs: gStyle.SetPadBottomMargin(kwargs['padbottommargin']) else: gStyle.SetPadBottomMargin(0.1) # title sizes if 'titlesize' in kwargs: gStyle.SetTitleSize(kwargs['titlesize'], 'xyz') else: gStyle.SetTitleSize(0.050, 'xyz') if 'titlesizex' in kwargs: gStyle.SetTitleSize(kwargs['titlesizex'], 'x') if 'titlesizey' in kwargs: gStyle.SetTitleSize(kwargs['titlesizex'], 'y') if 'titlesizez' in kwargs: gStyle.SetTitleSize(kwargs['titlesizex'], 'z') # label sizes if 'labelsize' in kwargs: gStyle.SetLabelSize(kwargs['labelsize'], 'xyz') else: gStyle.SetLabelSize(0.045, 'xyz') if 'labelsizex' in kwargs: gStyle.SetLabelSize(kwargs['labelsizex'], 'x') if 'labelsizey' in kwargs: gStyle.SetLabelSize(kwargs['labelsizex'], 'y') if 'labelsizez' in kwargs: gStyle.SetLabelSize(kwargs['labelsizex'], 'z') # title offsets if 'titleoffset' in kwargs: gStyle.SetTitleOffset(kwargs['titleoffset'], 'xyz') else: gStyle.SetTitleOffset(1.2, 'xyz') if 'titleoffsetx' in kwargs: gStyle.SetTitleOffset(kwargs['titleoffsetx'], 'x') if 'titleoffsety' in kwargs: gStyle.SetTitleOffset(kwargs['titleoffsety'], 'y') if 'titleoffsetz' in kwargs: gStyle.SetTitleOffset(kwargs['titleoffsetz'], 'z') # other options if 'opttitle' in kwargs: gStyle.SetOptTitle(kwargs['opttitle']) else: gStyle.SetOptTitle(0) if 'optstat' in kwargs: gStyle.SetOptStat(kwargs['optstat']) else: gStyle.SetOptStat(0) if 'padtickx' in kwargs: gStyle.SetPadTickX(kwargs['padtickx']) else: gStyle.SetPadTickX(1) if 'padticky' in kwargs: gStyle.SetPadTickY(kwargs['padticky']) else: gStyle.SetPadTickY(1) gStyle.SetLegendBorderSize(0) if 'maxdigits' in kwargs: TGaxis.SetMaxDigits(kwargs['maxdigits']) if 'palette' in kwargs: gStyle.SetPalette(kwargs['palette']) gROOT.ForceStyle()
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 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 main(options, args): from ROOT import gSystem, gROOT, gStyle gROOT.SetBatch() gSystem.Load("libRooFitCore") if options.doWebPage: from lip.Tools.rootutils import loadToolsLib, apply_modifs loadToolsLib() from ROOT import TFile, RooFit, RooArgSet, RooDataHist, RooKeysPdf, RooHistPdf, TCanvas, TLegend, TLatex, TArrow, TPaveText, RooAddPdf, RooArgList from ROOT import kWhite, kBlue, kOpenSquare if options.doWebPage: from ROOT import HtmlHelper, HtmlTag, HtmlTable, HtmlPlot rootglobestyle.setTDRStyle() gStyle.SetMarkerSize(1.5) gStyle.SetTitleYOffset(1.5) gStyle.SetPadLeftMargin(0.16) gStyle.SetPadRightMargin(0.05) gStyle.SetPadTopMargin(0.05) gStyle.SetPadBottomMargin(0.13) gStyle.SetLabelFont(42, "XYZ") gStyle.SetLabelOffset(0.007, "XYZ") gStyle.SetLabelSize(0.05, "XYZ") gStyle.SetTitleSize(0.06, "XYZ") gStyle.SetTitleXOffset(0.9) gStyle.SetTitleYOffset(1.24) gStyle.SetTitleFont(42, "XYZ") ## ## Read files ## options.outdir = "%s_m%1.0f" % (options.outdir, options.mH) if options.fp: options.outdir += "_fp" ncat = options.ncat cats = options.cats if cats is "": categories = ["_cat%d" % i for i in range(0, ncat)] else: categories = ["_cat%s" % i for i in cats.split(",")] if options.mva: clables = { "_cat0": ("MVA > 0.89", ""), "_cat1": ("0.74 #leq MVA", "MVA < 0.89"), "_cat2": ("0.545 #leq MVA", "MVA < 0.74"), "_cat3": ("0.05 #leq MVA", "MVA < 0.545"), "_cat4": ("Di-jet", "Tagged"), "_cat5": ("Di-jet", "Tagged"), "_combcat": ("All Classes", "Combined") } else: clables = { "_cat0": ("max(|#eta|<1.5", "min(R_{9})>0.94"), "_cat1": ("max(|#eta|<1.5", "min(R_{9})<0.94"), "_cat2": ("max(|#eta|>1.5", "min(R_{9})>0.94"), "_cat3": ("max(|#eta|>1.5", "min(R_{9})<0.94"), "_cat4": ("Di-jet", "Tagged"), "_cat5": ("Di-jet", "Tagged"), "_combcat": ("All Classes", "Combined") } helper = Helper() fin = TFile.Open(options.infile) helper.files.append(fin) ws = fin.Get("cms_hgg_workspace") mass = ws.var("CMS_hgg_mass") mass.SetTitle("m_{#gamma#gamma}") mass.setUnit("GeV") mass.setRange(100., 150.) mass.setBins(100, "plot") mass.setBins(5000) print ws aset = RooArgSet(mass) helper.objs.append(mass) helper.objs.append(aset) fitopt = (RooFit.Minimizer("Minuit2", ""), RooFit.Minos(False), RooFit.SumW2Error(False), RooFit.NumCPU(8)) if not options.binned and not options.refit: finpdf = TFile.Open(options.infilepdf) helper.files.append(finpdf) wspdf = finpdf.Get("wsig") else: wspdf = ws for c in categories: processes = ["ggh", "vbf", "wzh"] if options.fp: processes = ["vbf", "wzh"] ### elif clables[c][0] == "Di-jet": ### processes = [ "vbf", "ggh" ] dsname = "sig_mass_m%1.0f%s" % (options.mH, c) print dsname print ws ds = ws.data("sig_%s_mass_m%1.0f%s" % (processes[0], options.mH, c)).Clone(dsname) for proc in processes[1:]: ds.append(ws.data("sig_%s_mass_m%1.0f%s" % (proc, options.mH, c))) helper.dsets.append(ds) if options.binned: binned_ds = RooDataHist("binned_%s" % dsname, "binned_%s" % dsname, aset, ds) pdf = RooKeysPdf("pdf_%s_%s" % (dsname, f), "pdf_%s" % dsname, mass, ds) plot_pdf = RooHistPdf("pdf_%s" % dsname, "pdf_%s" % dsname, aset, plot_ds) helper.add(binned_ds, binned_ds.GetName()) else: if options.refit: if options.refitall and clables[c][0] != "Di-jet": rpdfs = [] for proc in processes: for ngaus in range(1, 4): pp = build_pdf(ws, "%s_%s" % (c, proc), ngaus, ngaus == 3) pp.fitTo( ws.data("sig_%s_mass_m%1.0f%s" % (proc, options.mH, c)), RooFit.Strategy(0), *fitopt) rpdfs.append(pp) pdf = RooAddPdf("hggpdfrel%s" % c, "hggpdfrel%s" % c, RooArgList(*tuple(rpdfs))) else: if options.refitall and clables[c][0] == "Di-jet": for ngaus in range(1, 5): pdf = build_pdf(ws, c, ngaus, ngaus == 5) pdf.fitTo(ds, RooFit.Strategy(0), *fitopt) else: for ngaus in range(1, 4): pdf = build_pdf(ws, c, ngaus, ngaus == 3) pdf.fitTo(ds, RooFit.Strategy(0), *fitopt) else: pdfs = (wspdf.pdf("hggpdfrel%s_%s" % (c, p)) for p in processes) pdf = RooAddPdf("hggpdfrel%s" % c, "hggpdfrel%s" % c, RooArgList(*pdfs)) helper.add(pdf, pdf.GetName()) plot_pdf = pdf.Clone("pdf_%s" % dsname) plot_ds = RooDataHist("plot_%s" % dsname, "plot_%s" % dsname, aset, "plot") plot_ds.add(ds) cdf = pdf.createCdf(aset) hmin, hmax, hm = get_FWHM(mass, pdf, cdf, options.mH - 10., options.mH + 10.) wmin, wmax = get_eff_sigma(mass, pdf, cdf, options.mH - 10., options.mH + 10.) ### hmin, hmax, hm = get_FWHM( points ) helper.add(plot_ds, plot_ds.GetName()) helper.add(plot_pdf, plot_pdf.GetName()) helper.add((wmin, wmax), "eff_sigma%s" % c) helper.add((hmin, hmax, hm), "FWHM%s" % c) helper.add(ds.sumEntries(), "sumEntries%s" % c) # signal model integral # data integral for PAS tables data = ws.data("data_mass%s" % c) helper.add( data.sumEntries("CMS_hgg_mass>=%1.4f && CMS_hgg_mass<=%1.4f" % (options.mH - 10., options.mH + 10.)), "data_sumEntries%s" % c) del cdf del pdf dsname = "sig_mass_m%1.0f_combcat" % options.mH print dsname combined_ds = helper.dsets[0].Clone(dsname) for d in helper.dsets[1:]: combined_ds.append(d) if options.binned: binned_ds = RooDataHist("binned_%s" % dsname, "binned_%s" % dsname, aset, combined_ds) pdf = RooKeysPdf("pdf_%s" % (dsname), "pdf_%s" % dsname, mass, combined_ds) plot_pdf = RooHistPdf("pdf_%s" % dsname, "pdf_%s" % dsname, aset, plot_ds) helper.add(binned_ds, binned_ds.GetName()) else: #### pdf = build_pdf(ws,"_combcat") #### pdf.fitTo(combined_ds, RooFit.Strategy(0), *fitopt ) #### plot_pdf = pdf.Clone( "pdf_%s" % dsname ) pdf = RooAddPdf( "pdf_%s" % dsname, "pdf_%s" % dsname, RooArgList(*(helper.histos["hggpdfrel%s" % c] for c in categories))) plot_pdf = pdf cdf = pdf.createCdf(aset) plot_ds = RooDataHist("plot_%s" % dsname, "plot_%s" % dsname, aset, "plot") plot_ds.add(combined_ds) wmin, wmax = get_eff_sigma(mass, pdf, cdf, options.mH - 10., options.mH + 10.) hmin, hmax, hm = get_FWHM(mass, pdf, cdf, options.mH - 10., options.mH + 10.) helper.add(plot_ds, plot_ds.GetName()) helper.add(plot_pdf, plot_pdf.GetName()) helper.add((wmin, wmax), "eff_sigma_combcat") helper.add((hmin, hmax, hm), "FWHM_combcat") helper.add(plot_ds.sumEntries(), "sumEntries_combcat") mass.setRange("higgsrange", options.mH - 25., options.mH + 15.) del cdf del pdf del helper.dsets ### label = TLatex(0.1812081,0.8618881,"#scale[0.8]{#splitline{CMS preliminary}{Simulation}}") label = TLatex(0.7, 0.86, "#scale[0.65]{#splitline{CMS preliminary}{Simulation}}") label.SetNDC(1) ## ## Make web page with plots ## if options.doWebPage: hth = HtmlHelper(options.outdir) hth.navbar().cell(HtmlTag("a")).firstChild().txt("..").set( "href", "../?C=M;O=D") hth.navbar().cell(HtmlTag("a")).firstChild().txt("home").set( "href", "./") tab = hth.body().add(HtmlTable()) ip = 0 for c in ["_combcat"] + categories: ### for c in categories: if options.doWebPage and ip % 4 == 0: row = tab.row() ip = ip + 1 dsname = "sig_mass_m%1.0f%s" % (options.mH, c) canv = TCanvas(dsname, dsname, 600, 600) helper.objs.append(canv) ### leg = TLegend(0.4345638,0.6835664,0.9362416,0.9178322) leg = TLegend(0.2, 0.96, 0.5, 0.55) #apply_modifs( leg, [("SetLineColor",kWhite),("SetFillColor",kWhite),("SetFillStyle",0),("SetLineStyle",0)] ) hplotcompint = mass.frame(RooFit.Bins(250), RooFit.Range("higgsrange")) helper.objs.append(hplotcompint) helper.objs.append(leg) plot_ds = helper.histos["plot_%s" % dsname] plot_pdf = helper.histos["pdf_%s" % dsname] wmin, wmax = helper.histos["eff_sigma%s" % c] hmin, hmax, hm = helper.histos["FWHM%s" % c] print hmin, hmax, hm style = (RooFit.LineColor(kBlue), RooFit.LineWidth(2), RooFit.FillStyle(0)) style_seff = ( RooFit.LineWidth(2), RooFit.FillStyle(1001), RooFit.VLines(), RooFit.LineColor(15), ) style_ds = (RooFit.MarkerStyle(kOpenSquare), ) plot_ds.plotOn(hplotcompint, RooFit.Invisible()) plot_pdf.plotOn(hplotcompint, RooFit.NormRange("higgsrange"), RooFit.Range(wmin, wmax), RooFit.FillColor(19), RooFit.DrawOption("F"), *style_seff) seffleg = hplotcompint.getObject(int(hplotcompint.numItems() - 1)) plot_pdf.plotOn(hplotcompint, RooFit.NormRange("higgsrange"), RooFit.Range(wmin, wmax), RooFit.LineColor(15), *style_seff) plot_pdf.plotOn(hplotcompint, RooFit.NormRange("higgsrange"), RooFit.Range("higgsrange"), *style) pdfleg = hplotcompint.getObject(int(hplotcompint.numItems() - 1)) plot_ds.plotOn(hplotcompint, *style_ds) pointsleg = hplotcompint.getObject(int(hplotcompint.numItems() - 1)) iob = int(hplotcompint.numItems() - 1) leg.AddEntry(pointsleg, "Simulation", "pe") leg.AddEntry(pdfleg, "Parametric model", "l") leg.AddEntry(seffleg, "#sigma_{eff} = %1.2f GeV " % (0.5 * (wmax - wmin)), "fl") clabel = TLatex(0.74, 0.65, "#scale[0.65]{#splitline{%s}{%s}}" % clables[c]) clabel.SetNDC(1) helper.objs.append(clabel) hm = hplotcompint.GetMaximum() * 0.5 * 0.9 ### hm = pdfleg.GetMaximum()*0.5 fwhmarrow = TArrow(hmin, hm, hmax, hm) fwhmarrow.SetArrowSize(0.03) helper.objs.append(fwhmarrow) fwhmlabel = TPaveText(0.20, 0.58, 0.56, 0.48, "brNDC") fwhmlabel.SetFillStyle(0) fwhmlabel.SetLineColor(kWhite) reducedFWHM = (hmax - hmin) / 2.3548200 fwhmlabel.AddText("FWHM/2.35 = %1.2f GeV" % reducedFWHM) helper.objs.append(fwhmlabel) hplotcompint.SetTitle("") hplotcompint.GetXaxis().SetNoExponent(True) hplotcompint.GetXaxis().SetTitle("m_{#gamma#gamma} (GeV)") hplotcompint.GetXaxis().SetNdivisions(509) ## hplotcompint.GetYaxis().SetTitle("A.U."); ## hplotcompint.GetYaxis().SetRangeUser(0.,hplotcompint.GetMaximum()*1.4); hplotcompint.Draw() leg.Draw("same") label.Draw("same") clabel.Draw("same") fwhmarrow.Draw("<>") fwhmlabel.Draw("same") plot_ds.sumEntries() if options.doWebPage: hpl = HtmlPlot(canv, False, "", True, True, True) hpl.caption("<i>%s</i>" % canv.GetTitle()) row.cell(hpl) else: if os.path.isdir(options.outdir) is False: os.mkdir(options.outdir) for ext in "C", "png", "pdf": canv.SaveAs( os.path.join(options.outdir, "%s.%s" % (canv.GetName(), ext))) if "comb" in c: ip = 0 if options.doWebPage: print "Creating pages..." hth.dump() for f in helper.files: f.Close() gROOT.Reset() from pprint import pprint pprint(helper) print 'Summary statistics per event class' print 'Cat\tSignal\t\tData/GeV (in %3.1f+/-10)\tsigEff\tFWHM/2.35' % options.mH sigTotal = 0. dataTotal = 0. for c in categories: sigVal = helper.histos["sumEntries%s" % c] datVal = helper.histos["data_sumEntries%s" % c] sigTotal += sigVal dataTotal += datVal for c in categories: sigVal = helper.histos["sumEntries%s" % c] datVal = helper.histos["data_sumEntries%s" % c] effSig = 0.5 * (helper.histos["eff_sigma%s" % c][1] - helper.histos["eff_sigma%s" % c][0]) fwhm = (helper.histos["FWHM%s" % c][1] - helper.histos["FWHM%s" % c][0]) / 2.3548200 print c, '\t%3.1f (%3.1f%%)\t%3.1f (%3.1f%%)\t\t\t%2.2f\t%2.2f' % ( sigVal, 100. * sigVal / sigTotal, datVal / (10. + 10.), 100. * datVal / dataTotal, effSig, fwhm) print "Done."
def makeLimitPlot(output, obs, exp, chan, printStats=False, obs2="", ratioLabel=""): #fileForHEPData = TFile("plots/"+output+"_forHEPData.root","RECREATE") fileObs = open(obs, 'r') fileExp = open(exp, 'r') observedx = [] observedy = [] obsLimits = {} for entry in fileObs: massPoint = float(entry.split()[0]) limitEntry = float(entry.split()[1]) if massPoint not in obsLimits: obsLimits[massPoint] = [] obsLimits[massPoint].append(limitEntry) if printStats: print "len obsLimits:", len(obsLimits) for massPoint in sorted(obsLimits): observedx.append(massPoint) observedy.append(numpy.mean(obsLimits[massPoint])) if (numpy.std(obsLimits[massPoint]) / numpy.mean(obsLimits[massPoint]) > 0.05): print massPoint, " mean: ", numpy.mean( obsLimits[massPoint]), " std dev: ", numpy.std( obsLimits[massPoint]), " from: ", obsLimits[massPoint] if not obs2 == "": fileObs2 = open(obs2, 'r') observedx2 = [] observedy2 = [] obsLimits2 = {} for entry in fileObs2: massPoint = float(entry.split()[0]) limitEntry = float(entry.split()[1]) if massPoint not in obsLimits2: obsLimits2[massPoint] = [] obsLimits2[massPoint].append(limitEntry) if printStats: print "len obsLimits:", len(obsLimits2) for massPoint in sorted(obsLimits2): observedx2.append(massPoint) observedy2.append(numpy.mean(obsLimits2[massPoint])) if (numpy.std(obsLimits2[massPoint]) / numpy.mean(obsLimits2[massPoint]) > 0.05): print massPoint, " mean: ", numpy.mean( obsLimits2[massPoint]), " std dev: ", numpy.std( obsLimits2[massPoint] ), " from: ", obsLimits2[massPoint] limits = {} expectedx = [] expectedy = [] expected1SigLow = [] expected1SigHigh = [] expected2SigLow = [] expected2SigHigh = [] for entry in fileExp: massPoint = float(entry.split()[0]) limitEntry = float(entry.split()[1]) if massPoint not in limits: limits[massPoint] = [] limits[massPoint].append(limitEntry) if printStats: print "len limits:", len(limits) for massPoint in sorted(limits): limits[massPoint].sort() numLimits = len(limits[massPoint]) nrExpts = len(limits[massPoint]) medianNr = int(nrExpts * 0.5) #get indexes: upper1Sig = int(nrExpts * (1 - (1 - 0.68) * 0.5)) lower1Sig = int(nrExpts * (1 - 0.68) * 0.5) upper2Sig = int(nrExpts * (1 - (1 - 0.95) * 0.5)) lower2Sig = int(nrExpts * (1 - 0.95) * 0.5) if printStats: print massPoint, ":", limits[massPoint][lower2Sig], limits[ massPoint][lower1Sig], limits[massPoint][medianNr], limits[ massPoint][upper1Sig], limits[massPoint][upper2Sig] #fill lists: expectedx.append(massPoint) print massPoint, limits[massPoint][medianNr] expectedy.append(limits[massPoint][medianNr]) expected1SigLow.append(limits[massPoint][lower1Sig]) expected1SigHigh.append(limits[massPoint][upper1Sig]) expected2SigLow.append(limits[massPoint][lower2Sig]) expected2SigHigh.append(limits[massPoint][upper2Sig]) expX = numpy.array(expectedx) expY = numpy.array(expectedy) values2 = [] xPointsForValues2 = [] values = [] xPointsForValues = [] xPointsForErrors = [] if printStats: print "length of expectedx: ", len(expectedx) if printStats: print "length of expected1SigLow: ", len(expected1SigLow) if printStats: print "length of expected1SigHigh: ", len(expected1SigHigh) #Here is some Voodoo via Sam: for x in range(0, len(expectedx)): values2.append(expected2SigLow[x]) xPointsForValues2.append(expectedx[x]) xPointsForErrors.append(0) for x in range(len(expectedx) - 1, 0 - 1, -1): values2.append(expected2SigHigh[x]) xPointsForValues2.append(expectedx[x]) if printStats: print "length of values2: ", len(values2) for x in range(0, len(expectedx)): values.append(expected1SigLow[x]) xPointsForValues.append(expectedx[x]) for x in range(len(expectedx) - 1, 0 - 1, -1): values.append(expected1SigHigh[x]) xPointsForValues.append(expectedx[x]) if printStats: print "length of values: ", len(values) exp2Sig = numpy.array(values2) xPoints2 = numpy.array(xPointsForValues2) exp1Sig = numpy.array(values) xPoints = numpy.array(xPointsForValues) xPointsErrors = numpy.array(xPointsForErrors) if printStats: print "xPoints2: ", xPoints2 if printStats: print "exp2Sig: ", exp2Sig if printStats: print "xPoints: ", xPoints if printStats: print "exp1Sig: ", exp1Sig GraphErr2SigForHEPData = TGraphAsymmErrors(len(expX), expX, expY, numpy.array(xPointsErrors), numpy.array(xPointsErrors), numpy.array(expected2SigLow), numpy.array(expected2SigHigh)) GraphErr1SigForHEPData = TGraphAsymmErrors(len(expX), expX, expY, numpy.array(xPointsErrors), numpy.array(xPointsErrors), numpy.array(expected1SigLow), numpy.array(expected1SigHigh)) GraphErr2Sig = TGraphAsymmErrors(len(xPoints), xPoints2, exp2Sig) GraphErr2Sig.SetFillColor(ROOT.kOrange) GraphErr1Sig = TGraphAsymmErrors(len(xPoints), xPoints, exp1Sig) GraphErr1Sig.SetFillColor(ROOT.kGreen + 1) #cCL=TCanvas("cCL", "cCL",0,0,567,384) cCL = TCanvas("cCL", "cCL", 0, 0, 600, 450) gStyle.SetOptStat(0) gStyle.SetPadRightMargin(0.063) gStyle.SetPadLeftMargin(0.14) gStyle.SetPadBottomMargin(0.12) if not obs2 == "": plotPad = ROOT.TPad("plotPad", "plotPad", 0, 0.3, 1, 1) ratioPad = ROOT.TPad("ratioPad", "ratioPad", 0, 0., 1, 0.3) plotPad.Draw() ratioPad.Draw() plotPad.cd() else: plotPad = ROOT.TPad("plotPad", "plotPad", 0, 0, 1, 1) plotPad.Draw() plotPad.cd() expX = numpy.array(expectedx) expY = numpy.array(expectedy) GraphExp = TGraph(len(expX), expX, expY) GraphExp.SetLineWidth(3) GraphExp.SetLineStyle(2) GraphExp.SetLineColor(ROOT.kBlue) obsX = numpy.array(observedx) obsY = numpy.array(observedy) if printStats: print "obsX: ", obsX if printStats: print "obsY: ", obsY if SMOOTH: smooth_obs = TGraphSmooth("normal") GraphObs_nonSmooth = TGraph(len(obsX), obsX, obsY) GraphObs = smooth_obs.SmoothSuper(GraphObs_nonSmooth, "linear", 0, 0.005) else: GraphObs = TGraph(len(obsX), obsX, obsY) GraphObs.SetLineWidth(3) if not obs2 == "": ratio = [] ratiox = [] for index, val in enumerate(observedy): mass = observedx[index] foundIndex = -1 for index2, mass2 in enumerate(observedx2): if mass == mass2: foundIndex = index2 if foundIndex > 0: ratio.append(observedy2[foundIndex] / val) ratiox.append(mass) ratioA = numpy.array(ratio) ratioX = numpy.array(ratiox) obsX2 = numpy.array(observedx2) obsY2 = numpy.array(observedy2) ratioGraph = TGraph(len(ratioX), ratioX, ratioA) if printStats: print "obsX2: ", obsX2 if printStats: print "obsY2: ", obsY2 if SMOOTH: smooth_obs2 = TGraphSmooth("normal") GraphObs2_nonSmooth = TGraph(len(obsX2), obsX2, obsY2) GraphObs2 = smooth_obs2.SmoothSuper(GraphObs2_nonSmooth, "linear", 0, 0.005) else: GraphObs2 = TGraph(len(obsX2), obsX2, obsY2) GraphObs2.SetLineWidth(3) if SPIN2: signals = ["RS_kMpl01", "RS_kMpl005", "RS_kMpl001"] elif GUT: signals = ["ssm", "psi", "kai", "eta", "I", "S", "N"] else: signals = ["ssm", "psi"] xSecCurves = [] for signal in signals: xSecCurves.append(getXSecCurve(signal, kFacs[signal])) #xSecCurves.append(getXSecCurve(signal,kFacs[signal],massDependent=True)) #Draw the graphs: plotPad.SetLogy() DummyGraph = TH1F("DummyGraph", "", 100, 200, 5500) DummyGraph.GetXaxis().SetTitle("M [GeV]") if SPIN2: DummyGraph.GetYaxis().SetTitle( "[#sigma#upoint#font[12]{B}] G_{KK} / [#sigma#upoint#font[12]{B}] Z" ) else: DummyGraph.GetYaxis().SetTitle( "[#sigma#upoint#font[12]{B}] Z' / [#sigma#upoint#font[12]{B}] Z") # if SPIN2: # if chan=="mumu": # DummyGraph.GetYaxis().SetTitle("#sigma(pp#rightarrowG_{KK}+X#rightarrow#mu^{+}#mu^{-}+X) / #sigma(pp#rightarrowZ+X#rightarrow#mu^{+}#mu^{-}+X)") # elif chan=="elel": # DummyGraph.GetYaxis().SetTitle("#sigma(pp#rightarrowG_{KK}+X#rightarrowee+X) / #sigma(pp#rightarrowZ+X#rightarrowee+X)") # elif chan=="elmu": # DummyGraph.GetYaxis().SetTitle("#sigma(pp#rightarrowG_{KK}+X#rightarrow#font[12]{ll}+X) / #sigma(pp#rightarrowZ+X#rightarrow#font[12]{ll}+X)") # else: # if chan=="mumu": # DummyGraph.GetYaxis().SetTitle("#sigma(pp#rightarrowZ'+X#rightarrow#mu^{+}#mu^{-}+X) / #sigma(pp#rightarrowZ+X#rightarrow#mu^{+}#mu^{-}+X)") # elif chan=="elel": # DummyGraph.GetYaxis().SetTitle("#sigma(pp#rightarrowZ'+X#rightarrowee+X) / #sigma(pp#rightarrowZ+X#rightarrowee+X)") # elif chan=="elmu": # DummyGraph.GetYaxis().SetTitle("#sigma(pp#rightarrowZ'+X#rightarrow#font[12]{ll}+X) / #sigma(pp#rightarrowZ+X#rightarrow#font[12]{ll}+X)") gStyle.SetOptStat(0) DummyGraph.GetXaxis().SetRangeUser(200, 5500) DummyGraph.SetMinimum(1e-8) DummyGraph.SetMaximum(1e-4) DummyGraph.GetXaxis().SetLabelSize(0.055) DummyGraph.GetXaxis().SetTitleSize(0.055) DummyGraph.GetXaxis().SetTitleOffset(1.05) DummyGraph.GetYaxis().SetLabelSize(0.055) DummyGraph.GetYaxis().SetTitleSize(0.055) DummyGraph.GetYaxis().SetTitleOffset(1.3) DummyGraph.Draw() if (FULL): GraphErr2Sig.Draw("F") GraphErr1Sig.Draw("F") GraphExp.Draw("lpsame") else: if obs2 == "": GraphExp.Draw("lp") if not EXPONLY: GraphObs.Draw("plsame") if not obs2 == "": GraphObs2.SetLineColor(ROOT.kRed) GraphObs2.SetLineStyle(ROOT.kDashed) GraphObs2.Draw("plsame") for curve in xSecCurves: curve.Draw("lsame") plCMS = TPaveLabel(.16, .81, .27, .88, "CMS", "NBNDC") #plCMS.SetTextSize(0.8) plCMS.SetTextAlign(12) plCMS.SetTextFont(62) plCMS.SetFillColor(0) plCMS.SetFillStyle(0) plCMS.SetBorderSize(0) plCMS.Draw() plPrelim = TPaveLabel(.16, .76, .27, .82, "Preliminary", "NBNDC") plPrelim.SetTextSize(0.6) plPrelim.SetTextAlign(12) plPrelim.SetTextFont(52) plPrelim.SetFillColor(0) plPrelim.SetFillStyle(0) plPrelim.SetBorderSize(0) if "2017" in output or "Combination" in output: plPrelim.Draw() cCL.SetTickx(1) cCL.SetTicky(1) cCL.RedrawAxis() cCL.Update() #leg=TLegend(0.65,0.65,0.87,0.87,"","brNDC") #leg=TLegend(0.540517,0.623051,0.834885,0.878644,"","brNDC") Default leg = TLegend(0.5, 0.58, 0.834885, 0.878644, "", "brNDC") if SPIN2: leg = TLegend(0.5, 0.58, 0.834885, 0.878644, "", "brNDC") # leg=TLegend(0.55,0.55,0.87,0.87,"","brNDC") leg.SetTextSize(0.0425) if not obs2 == "": if ratioLabel == "": ratioLabel = "Variant/Default" ratioLabels = ratioLabel.split("/") print ratioLabels leg.AddEntry(GraphObs, "%s Obs. 95%% CL limit" % ratioLabels[1], "l") leg.AddEntry(GraphObs2, "%s Obs. 95%% CL limit" % ratioLabels[0], "l") else: if not EXPONLY: leg.AddEntry(GraphObs, "Obs. 95% CL limit", "l") leg.AddEntry(GraphExp, "Exp. 95% CL limit, median", "l") if (FULL): leg.AddEntry(GraphErr1Sig, "Exp. (68%)", "f") leg.AddEntry(GraphErr2Sig, "Exp. (95%)", "f") leg1 = TLegend(0.7, 0.4, 0.9, 0.55, "", "brNDC") leg1.SetTextSize(0.05) if GUT: leg1 = TLegend(0.6, 0.35, 0.75, 0.623051, "", "brNDC") if SPIN2: leg1 = TLegend(0.7, 0.35, 0.9, 0.58, "G_{KK} (LO x 1.6)", "brNDC") leg1.SetTextSize(0.045) for index, signal in enumerate(signals): xSecCurves[index].SetName(labels[signal]) xSecCurves[index].Write(labels[signal]) leg1.AddEntry(xSecCurves[index], labels[signal], "l") leg1.SetBorderSize(0) leg.SetLineWidth(0) leg.SetLineStyle(0) leg.SetFillStyle(0) leg.SetLineColor(0) leg.Draw("hist") leg1.SetLineWidth(0) leg1.SetLineStyle(0) leg1.SetFillStyle(0) leg1.SetLineColor(0) leg1.Draw("hist") if "Moriond" in output: if (chan == "mumu"): plLumi = TPaveLabel(.65, .885, .9, .99, "36.3 fb^{-1} (13 TeV, #mu^{+}#mu^{-})", "NBNDC") elif (chan == "elel"): plLumi = TPaveLabel(.65, .885, .9, .99, "35.9 fb^{-1} (13 TeV, ee)", "NBNDC") elif (chan == "elmu"): plLumi = TPaveLabel( .27, .885, .9, .99, "35.9 fb^{-1} (13 TeV, ee) + 36.3 fb^{-1} (13 TeV, #mu^{+}#mu^{-})", "NBNDC") elif "2017" in output or "Combination" in output: if (chan == "mumu"): plLumi = TPaveLabel(.65, .885, .9, .99, "42.4 fb^{-1} (13 TeV, #mu^{+}#mu^{-})", "NBNDC") elif (chan == "elel"): plLumi = TPaveLabel(.65, .885, .9, .99, "41.4 fb^{-1} (13 TeV, ee)", "NBNDC") elif (chan == "elmu"): plLumi = TPaveLabel( .27, .885, .9, .99, "77.3 fb^{-1} (13 TeV, ee) + 78.7 fb^{-1} (13 TeV, #mu^{+}#mu^{-})", "NBNDC") else: if (chan == "mumu"): plLumi = TPaveLabel(.65, .905, .9, .99, "13.0 fb^{-1} (13 TeV, #mu#mu)", "NBNDC") elif (chan == "elel"): plLumi = TPaveLabel(.65, .905, .9, .99, "2.7 fb^{-1} (13 TeV, ee)", "NBNDC") elif (chan == "elmu"): plLumi = TPaveLabel( .4, .905, .9, .99, "12.4 fb^{-1} (13 TeV, ee) + 13.0 fb^{-1} (13 TeV, #mu#mu)", "NBNDC") plLumi.SetTextSize(0.5) plLumi.SetTextFont(42) plLumi.SetFillColor(0) plLumi.SetBorderSize(0) plLumi.Draw() plotPad.SetTicks(1, 1) plotPad.RedrawAxis() if not obs2 == "": ratioPad.cd() line = ROOT.TLine(200, 1, 5500, 1) line.SetLineStyle(ROOT.kDashed) ROOT.gStyle.SetTitleSize(0.12, "Y") ROOT.gStyle.SetTitleYOffset(0.35) ROOT.gStyle.SetNdivisions(000, "Y") ROOT.gStyle.SetNdivisions(408, "Y") ratioPad.DrawFrame(200, 0.8, 5500, 1.2, "; ; %s" % ratioLabel) line.Draw("same") ratioGraph.Draw("sameP") #GraphErr2SigForHEPData.SetName("graph2Sig") #GraphErr2SigForHEPData.Write("graph2Sig") #GraphErr1SigForHEPData.SetName("graph1Sig") #GraphErr1SigForHEPData.Write("graph1Sig") #GraphExp.SetName("graphExp") #GraphExp.Write("graphExp") #GraphObs.SetName("graphObs") #GraphObs.Write("graphObs") #fileForHEPData.Write() #fileForHEPData.Close() cCL.Update() printPlots(cCL, output)
def plot_map(out_file_path, hist): map_name = out_file_path if '/' not in out_file_path else out_file_path.split( '/')[-1] map_name = map_name.replace('.pdf', '') rho_min = -6.0 rho_max = -2.6 pt_min = 500. pt_max = 1200. # rho_min = -10 # rho_max = 0 # pt_min = 200 # pt_max = 5000 disc_min = 0.12 disc_max = 0.3 left_margin = 0.14 right_margin = 0.16 top_margin = 0.08 bottom_margin = 0.12 gStyle.SetPadTickY(1) gStyle.SetPadTickX(1) gStyle.SetLegendBorderSize(0) gROOT.SetBatch(True) gStyle.SetOptStat(0) gStyle.SetOptFit(0) gStyle.SetTitleOffset(0.86, "X") gStyle.SetTitleOffset(1.6, "Y") gStyle.SetPadLeftMargin(left_margin) gStyle.SetPadBottomMargin(bottom_margin) gStyle.SetPadTopMargin(top_margin) gStyle.SetPadRightMargin(right_margin) gStyle.SetMarkerSize(0.5) gStyle.SetHistLineWidth(1) gStyle.SetTitleSize(0.05, "XYZ") gStyle.SetLabelSize(0.04, "XYZ") gStyle.SetNdivisions(506, "XYZ") gStyle.SetNumberContours(25) gStyle.SetLegendBorderSize(0) hist.GetXaxis().SetTitle("#rho") hist.GetYaxis().SetTitle("p_{T} [GeV]") if ('n2' in map_name.lower()): hist.GetZaxis().SetTitle("N2^{DDT} X% quantile") else: hist.GetZaxis().SetTitle("DeepBoosted WvsQCD X% quantile") disc_max = 1 hist.GetXaxis().SetRangeUser(rho_min, rho_max) hist.GetYaxis().SetRangeUser(pt_min, pt_max) # if(disc_max>hist.GetMaximum()): # hist.GetZaxis().SetRangeUser(disc_min, disc_max) Font = 43 TitleSize = 24.0 TitleOffset = 1.3 LabelSize = 18.0 hist.GetYaxis().SetTitleFont(Font) hist.GetYaxis().SetTitleSize(TitleSize) hist.GetYaxis().SetTitleOffset(TitleOffset) hist.GetYaxis().SetLabelFont(Font) hist.GetYaxis().SetLabelSize(LabelSize) hist.GetXaxis().SetTitleFont(Font) hist.GetXaxis().SetTitleSize(TitleSize) hist.GetXaxis().SetTitleOffset(TitleOffset) hist.GetXaxis().SetLabelFont(Font) hist.GetXaxis().SetLabelSize(LabelSize) hist.GetZaxis().SetTitleFont(Font) hist.GetZaxis().SetTitleSize(TitleSize) hist.GetZaxis().SetTitleOffset(TitleOffset) hist.GetZaxis().SetLabelFont(Font) hist.GetZaxis().SetLabelSize(LabelSize) # hist.GetZaxis().SetNdivisions(20) hist.SetTitle(map_name.replace('_', ' ')) hist.SetTitleFont(43) hist.SetTitleSize(18.0) # isomasses = [20,55,80,120,200] # isomasses = [20,65,80,125,200] # isomasses = range(40,200,20) isomasses = [40, 80, 110, 120, 200] str_isomass = "%.2f*TMath::Exp(-x/2)" tf1_isomasses = [] for i in range(len(isomasses)): msd = isomasses[i] new_isomass = TF1('isomass_%i' % int(msd), str_isomass % msd, rho_min, rho_max) # new_isomass.SetLineColor(920+i) new_isomass.SetLineColorAlpha(1, 0.4) tf1_isomasses.append(new_isomass) c1 = TCanvas("c1", "c1", 700, 600) c1.cd() hist.Draw("colz") latex_border = TLatex() latex_border.SetNDC(1) latex_border.SetTextColor(1) latex_border.SetTextFont(43) latex_border.SetTextSize(15.5) latex_border.SetTextAngle(297) latex = TLatex() latex.SetNDC(1) latex.SetTextColor(920) latex.SetTextFont(43) latex.SetTextSize(15) # latex.SetTextAngle(297) for i in range(len(isomasses)): x_pitch = (1 - left_margin - right_margin) / (rho_max - rho_min) y_pitch = (1 - bottom_margin - top_margin) / (pt_max - pt_min) msd = isomasses[i] pt = msd * np.exp(-rho_min / 2) pt = 800 if pt > pt_max else pt angle = ((180 / np.pi) * np.arctan(2 * x_pitch / (pt * y_pitch))) + 272 latex.SetTextAngle(angle) latex_border.SetTextAngle(angle) tf1_isomass = tf1_isomasses[i] tf1_isomass.Draw('SAME') x_pos = left_margin + ( (2 * np.log(msd / pt) - rho_min)) * x_pitch + 0.01 y_pos = bottom_margin + (pt - pt_min) * y_pitch + 0.01 latex_border.DrawLatex(x_pos, y_pos, 'm_{SD} = %.1f GeV' % msd) # latex.DrawLatex(x_pos,y_pos,'m_{SD} = %.1f GeV'%msd) c1.SaveAs(out_file_path + ".pdf") c1.SaveAs(out_file_path + ".png") c1.SaveAs(out_file_path + ".C") del c1
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 setStyle(): gStyle.SetPadBorderMode(0) gStyle.SetFrameBorderMode(0) gStyle.SetPadBottomMargin(0.12) gStyle.SetPadLeftMargin(0.12) gStyle.SetCanvasColor(ROOT.kWhite) gStyle.SetCanvasDefH(600) #Height of canvas gStyle.SetCanvasDefW(600) #Width of canvas gStyle.SetCanvasDefX(0) #POsition on screen gStyle.SetCanvasDefY(0) gStyle.SetPadTopMargin(0.05) gStyle.SetPadBottomMargin(0.15) #0.13); gStyle.SetPadLeftMargin(0.11) #0.16); gStyle.SetPadRightMargin(0.05) #0.02); # For the Pad: gStyle.SetPadBorderMode(0) gStyle.SetPadColor(ROOT.kWhite) gStyle.SetPadGridX(ROOT.kFALSE) gStyle.SetPadGridY(ROOT.kFALSE) 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) gStyle.SetAxisColor(1, "XYZ") gStyle.SetStripDecimals(ROOT.kTRUE) gStyle.SetTickLength(0.03, "XYZ") gStyle.SetNdivisions(505, "XYZ") gStyle.SetPadTickX(1) # To get tick marks on the opposite side of the frame gStyle.SetPadTickY(1) gStyle.SetGridColor(0) gStyle.SetGridStyle(3) gStyle.SetGridWidth(1) gStyle.SetTitleColor(1, "XYZ") gStyle.SetTitleFont(42, "XYZ") gStyle.SetTitleSize(0.05, "XYZ") gStyle.SetTitleXOffset(1.15) #0.9); gStyle.SetTitleYOffset(1.3) # => 1.15 if exponents gStyle.SetLabelColor(1, "XYZ") gStyle.SetLabelFont(42, "XYZ") gStyle.SetLabelOffset(0.007, "XYZ") gStyle.SetLabelSize(0.045, "XYZ") gStyle.SetPadBorderMode(0) gStyle.SetFrameBorderMode(0) gStyle.SetTitleTextColor(1) gStyle.SetTitleFillColor(10) gStyle.SetTitleFontSize(0.05) gStyle.SetOptStat(0) gStyle.SetOptTitle(0) gStyle.SetOptFit(1) NRGBs = 5 NCont = 255 stops = [0.00, 0.34, 0.61, 0.84, 1.00] red = [0.00, 0.00, 0.87, 1.00, 0.51] green = [0.00, 0.81, 1.00, 0.20, 0.00] blue = [0.51, 1.00, 0.12, 0.00, 0.00] stopsArray = array('d', stops) redArray = array('d', red) greenArray = array('d', green) blueArray = array('d', blue) TColor.CreateGradientColorTable(NRGBs, stopsArray, redArray, greenArray, blueArray, NCont) gStyle.SetNumberContours(NCont)
def fit(infile="", label="", output=""): tfout = TFile.Open("%s.root" % output, "RECREATE") ## read data and fill a histogram hist = read_data(infile) xoffset = 0.5 xmin = 0 + xoffset xmax = 45 + xoffset ymin = 0 ymax = hist.GetMaximum() ## do fit fun1 = TF1("fun1", "expo", xmin, xmax) fun1.SetLineColor(ROOT.kRed) hist.Fit("fun1") fun2 = TF1("fun2", "[0]*exp([1]*x+[2]*1./x)", xmin, xmax) #fun2=TF1("fun2", "[0]*exp([1]*x+[2]*1./x+[3]*x*x)", xmin, xmax) fun2.SetLineColor(ROOT.kBlue) fun2.SetParameter(0, fun1.GetParameter(0)) fun2.SetParameter(1, fun1.GetParameter(1)) hist.Fit("fun2") fun2.SetParameter(0, fun2.GetParameter(0)) fun2.SetParameter(1, fun2.GetParameter(1)) fun2.SetParameter(2, fun2.GetParameter(2)) #fun2.SetParameter(3, fun2.GetParameter(3)) hist.Fit("fun2") prob = fun2.GetProb() chi2 = fun2.GetChisquare() print "prob:", prob print "chi2:", chi2 gROOT.SetStyle("ATLAS") yscale = 2.5 doRatio = 1 # compare and plot the observed and predicted ## plot canvas_w, canvas_h = 800, 600 fraction = 1. ratio = 0.2 if doRatio: canvas_w, canvas_h = 800, int(600 * (1 + ratio)) fraction = ratio + 0.2 gStyle.SetPadLeftMargin(0.15) gStyle.SetPadRightMargin(0.10) gStyle.SetPadTopMargin(0.05) gStyle.SetPadBottomMargin(0.15) MyC = TCanvas('MyC', 'MyC', canvas_w, canvas_h) MyC.SetTicks(1, 1) ymax *= yscale if doRatio: Pad1 = TPad("p1", "p1", 0, fraction * 1.0 / (fraction + 1), 1, 1, 0, 0) # x1,y1,x2,y2 Pad1.SetMargin(0.15, 0.10, 0.03, 0.05) Pad2 = TPad("p2", "p2", 0, 0, 1, fraction * 1.0 / (fraction + 1), 0, 0) Pad2.SetMargin(0.15, 0.10, 0.15 / fraction, 0.08) Pad1.Draw() Pad2.Draw() ## draw data and fitted lines hist.SetMarkerStyle(20) hist.SetMarkerSize(1.8) hist.SetLineWidth(2) hist.GetXaxis().SetTitle("Days") hist.GetYaxis().SetTitle("Cases") hist.GetYaxis().SetTitleOffset(1.1 * hist.GetYaxis().GetTitleOffset()) hist.GetXaxis().SetTitleOffset(1.1 * hist.GetXaxis().GetTitleOffset()) hist.GetXaxis().SetRangeUser(xmin, xmax) hist.SetMaximum(ymax) if doRatio: Pad1.cd() else: MyC.cd() gStyle.SetPaintTextFormat(" g") hist.Draw("petext") fun1.Draw("same") fun2.Draw("same") ## plot predictions hpred = get_pred(hist, fun2) hpred.SetMarkerColor(ROOT.kBlue) hpred.Draw("petextsame") hist.Draw("petextsame") ## Legend l = TLegend(0.20, 0.67, 0.35, 0.92) l.SetFillColor(10) l.SetBorderSize(0) l.SetTextSize(0.04) l.AddEntry(hist, label, "p") l.AddEntry(hpred, "Predicted", "p") flabel1 = "Fit: %.2fexp( %.2f*t)" % (fun1.GetParameter(0), fun1.GetParameter(1)) l.AddEntry(fun1, flabel1, "l") flabel2 = "Fit: %.2fexp( %.2f*t + %.2f/t)" % ( fun2.GetParameter(0), fun2.GetParameter(1), fun2.GetParameter(2)) #flabel2="Fit: %.2fexp( %.2f*t + %.2f/t + %.2f/t^{2})" % (fun2.GetParameter(0), fun2.GetParameter(1), fun2.GetParameter(2), fun2.GetParameter(3)) l.AddEntry(fun2, flabel2, "l") l.Draw() ## show fit quality """ tl=TPaveText(0.30, 0.57, 0.50, 0.62, "NDC") tl.SetFillColor(10) tl.SetBorderSize(0) tl.SetTextSize(0.04) tl.AddText("p-value: %.3f" % prob) tl.Draw() """ ## compare predicted and observed if doRatio: hres = get_diff(hist, fun2) hres.GetXaxis().SetTitle(hist.GetXaxis().GetTitle()) hres.GetYaxis().SetTitle("Data-Pred.") hres.GetXaxis().SetTitleOffset(1.0) hres.GetYaxis().SetTitleOffset(0.4) hres.GetXaxis().SetLabelOffset(hres.GetXaxis().GetLabelOffset() * 2.0) hres.GetXaxis().SetTitleSize(hist.GetXaxis().GetTitleSize() * 2.5) hres.GetYaxis().SetTitleSize(hist.GetYaxis().GetTitleSize() * 2.5) hres.GetXaxis().SetLabelSize(hist.GetXaxis().GetLabelSize() * 2.5) hres.GetYaxis().SetLabelSize(hist.GetYaxis().GetLabelSize() * 2) hres.GetXaxis().SetTitleOffset(2. * hist.GetXaxis().GetTitleOffset()) hist.GetXaxis().SetTitle("") hist.GetXaxis().SetLabelSize(0) Pad2.cd() hres.GetFunction("fun2").SetBit(ROOT.TF1.kNotDraw) dymin = hres.GetMinimum() dymax = hres.GetMaximum() dy = max(fabs(dymin), fabs(dymax)) * 1.1 dy = min(dy, 2000) hres.GetYaxis().SetRangeUser(-dy, dy) hres.Draw() MyC.SaveAs("%s_linear.png" % output) hist.SetMinimum(11) hist.SetMaximum(hist.GetMaximum() * 2.) if doRatio: Pad1.SetLogy(1) else: MyC.SetLogy(1) MyC.SaveAs("%s_log.png" % output) tfout.cd() hist.Write() fun1.Write() fun2.Write() tfout.Close()
__author__ = "Maoqiang JING <*****@*****.**>" __copyright__ = "Copyright (c) Maoqiang JING" __created__ = "[2020-10-20 Tue 20:13]" import ROOT from ROOT import TCanvas, gStyle from ROOT import TFile, TH2F, TPaveText, TArrow import sys, os import logging from math import * logging.basicConfig(level=logging.DEBUG, format=' %(asctime)s - %(levelname)s- %(message)s') gStyle.SetPaperSize(20, 30) gStyle.SetPadTopMargin(0.05) gStyle.SetPadRightMargin(0.08) gStyle.SetPadBottomMargin(0.18) gStyle.SetPadLeftMargin(0.16) gStyle.SetOptTitle(0) gStyle.SetOptTitle(0) def usage(): sys.stdout.write(''' NAME opt_2D.py SYNOPSIS ./opt_2D.py [ecms] AUTHOR Maoqiang JING <*****@*****.**>
def create_image(rootfiledir): rootfile = rootfiledir.split('/')[-1] base = rootfiledir.split('/')[6] rootfilename = rootfile.split('.') rootfilename = rootfilename[0] + "." + rootfilename[ 1] + "." + rootfilename[2] print rootfilename #break #rootfile=root+"/"+rootfile #print rootfile f = TFile.Open(rootfiledir) tree = f.Get("evtdata_cont") ro = [] phi = [] for index in range(tree.GetEntries()): tree.GetEntry(index) bcalro = getattr(tree, "BeamCal_contro") bcalphi = getattr(tree, "BeamCal_contphi") for i in range(len(bcalro)): ro.append(bcalro[i]) phi.append(bcalphi[i]) # #print max(ro) #print min(ro) # #print max(phi) #print min(phi) #hrophi = TH2D("hrophi","BeamCal_contro vs BeamCal_contphi",1000,-3.2,3.2,1000,8.6,152) hrophi = TH2D("hrophi", "BeamCal_contro vs BeamCal_contphi", 1000, min(phi), max(phi), 1000, min(ro), max(ro)) #c = TCanvas("c1","",64,64) c = TCanvas("c1", "", 800, 600) for index in range(tree.GetEntries()): tree.GetEntry(index) bcalro = getattr(tree, "BeamCal_contro") bcalphi = getattr(tree, "BeamCal_contphi") bcale = getattr(tree, "BeamCal_energycont") for i in range(len(bcalro)): hrophi.Fill(bcalphi[i], bcalro[i], bcale[i]) c.SetFillColor(1) c.SetBorderMode(0) c.SetBorderSize(2) c.SetFrameBorderMode(0) c.SetFrameFillColor(0) c.SetFrameLineColor(1) gStyle.SetOptStat(0) gPad.SetLogz() gStyle.SetPalette(52) gStyle.SetPadTopMargin(0) gStyle.SetPadBottomMargin(0) gStyle.SetPadRightMargin(0) gStyle.SetPadLeftMargin(0) gStyle.SetPalette(52) #gStyle.SetPalette(kGreyScale); #remove title hrophi.SetTitle("") hrophi.GetXaxis().SetTitle("") hrophi.GetXaxis().SetLabelOffset(999) hrophi.GetXaxis().SetLabelSize(0) hrophi.GetYaxis().SetTitle("") hrophi.GetYaxis().SetLabelOffset(999) hrophi.GetYaxis().SetLabelSize(0) hrophi.GetZaxis().SetTitle("") hrophi.GetZaxis().SetLabelOffset(999) hrophi.GetZaxis().SetLabelSize(0) hrophi.Draw("COL AH") imdir = base + "/images" if not os.path.exists(imdir): os.makedirs(imdir) imagename = imdir + "/" + rootfilename c.Print(imagename + ".png")
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 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)