Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 11:56:35

0001 ##########################################################################
0002 ##
0003 # Set the style of the output
0004 ##
0005 
0006 import ROOT
0007 ROOT.PyConfig.IgnoreCommandLineOptions = True
0008 ROOT.gROOT.SetBatch()
0009 
0010 
0011 ######################################################################
0012 # creates the identification text in the top left corner
0013 #
0014 
0015 
0016 def identification(config):
0017     text = ROOT.TPaveText(0.0, 0.95, 1.0, 1.0, "blNDC")
0018     text.AddText(config.message)
0019     text.SetBorderSize(0)
0020     text.SetTextAlign(12)
0021     text.SetTextSizePixels(10)
0022     text.SetTextFont(82)
0023     text.SetFillColor(0)
0024     return text
0025 
0026 ######################################################################
0027 # statistics size
0028 #
0029 
0030 
0031 def setstatsize(canvas, plot, config):
0032     # statistics size
0033     ROOT.gStyle.SetStatW(0.3)
0034     ROOT.gStyle.SetStatH(0.3)
0035     plot.Draw()
0036     canvas.Update()
0037 
0038     # set the size of the statistics box
0039     stat = plot.FindObject("stats")
0040     stat.SetX1NDC(1 - config.statboxsize)
0041     stat.SetY1NDC(1 - config.statboxsize)
0042 
0043 
0044 ######################################################################
0045 # set gstyle
0046 # by https://github.com/mschrode/AwesomePlots/blob/master/Style.cc
0047 #
0048 
0049 
0050 def setgstyle():
0051     # Zero horizontal error bars
0052     ROOT.gStyle.SetErrorX(0)
0053 
0054     # For the canvas
0055     ROOT.gStyle.SetCanvasBorderMode(0)
0056     ROOT.gStyle.SetCanvasColor(0)
0057     ROOT.gStyle.SetCanvasDefH(800)  # Height of canvas
0058     ROOT.gStyle.SetCanvasDefW(800)  # Width of canvas
0059     ROOT.gStyle.SetCanvasDefX(0)  # Position on screen
0060     ROOT.gStyle.SetCanvasDefY(0)
0061 
0062     # For the frame
0063     ROOT.gStyle.SetFrameBorderMode(0)
0064     ROOT.gStyle.SetFrameBorderSize(1)
0065     ROOT.gStyle.SetFrameFillColor(1)
0066     ROOT.gStyle.SetFrameFillStyle(0)
0067     ROOT.gStyle.SetFrameLineColor(1)
0068     ROOT.gStyle.SetFrameLineStyle(0)
0069     ROOT.gStyle.SetFrameLineWidth(1)
0070 
0071     # For the Pad
0072     ROOT.gStyle.SetPadBorderMode(0)
0073     ROOT.gStyle.SetPadColor(0)
0074     ROOT.gStyle.SetPadGridX(False)
0075     ROOT.gStyle.SetPadGridY(False)
0076     ROOT.gStyle.SetGridColor(0)
0077     ROOT.gStyle.SetGridStyle(3)
0078     ROOT.gStyle.SetGridWidth(1)
0079 
0080     # Margins
0081     ROOT.gStyle.SetPadTopMargin(0.08)
0082     ROOT.gStyle.SetPadBottomMargin(0.19)
0083     ROOT.gStyle.SetPadLeftMargin(0.17)
0084     #ROOT.gStyle.SetPadRightMargin(0.07)
0085 
0086     # For the histo:
0087     ROOT.gStyle.SetHistLineColor(1)
0088     ROOT.gStyle.SetHistLineStyle(0)
0089     ROOT.gStyle.SetHistLineWidth(2)
0090     ROOT.gStyle.SetMarkerSize(1.4)
0091     ROOT.gStyle.SetEndErrorSize(4)
0092 
0093     # For the statistics box:
0094     ROOT.gStyle.SetOptStat(0)
0095 
0096     # For the axis
0097     ROOT.gStyle.SetAxisColor(1, "XYZ")
0098     ROOT.gStyle.SetTickLength(0.03, "XYZ")
0099     ROOT.gStyle.SetNdivisions(510, "XYZ")
0100     ROOT.gStyle.SetPadTickX(1)
0101     ROOT.gStyle.SetPadTickY(1)
0102     ROOT.gStyle.SetStripDecimals(False)
0103 
0104     # For the axis labels and titles
0105     ROOT.gStyle.SetTitleColor(1, "XYZ")
0106     ROOT.gStyle.SetLabelColor(1, "XYZ")
0107     ROOT.gStyle.SetLabelFont(42, "XYZ")
0108     ROOT.gStyle.SetLabelOffset(0.007, "XYZ")
0109     ROOT.gStyle.SetLabelSize(0.045, "XYZ")
0110     ROOT.gStyle.SetTitleFont(42, "XYZ")
0111     ROOT.gStyle.SetTitleSize(0.06, "XYZ")
0112 
0113     # For the legend
0114     ROOT.gStyle.SetLegendBorderSize(0)