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 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 __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
#! /usr/bin/env python from ROOT import gROOT, TFile, TCanvas, TF1, TGraph, TPaveText, TLatex, TH1F, TLegend, TLine, TColor, TIter, gStyle from ROOT import TGaxis from array import array import ROOT gROOT.SetStyle("Plain") gStyle.SetOptStat(1110) gStyle.SetOptFit(1) gStyle.SetOptStat(0) gStyle.SetStatW(0.25) gStyle.SetStatH(0.15) gStyle.SetCanvasDefH(150) gStyle.SetCanvasDefW(150) gStyle.SetAxisColor(1, "XYZ") gStyle.SetStripDecimals(1) gStyle.SetTickLength(0.03, "XYZ") gStyle.SetNdivisions(510, "XYZ") gStyle.SetPadTickX(1) gStyle.SetPadTickY(1) gStyle.SetPadTopMargin(0.1) gStyle.SetPadBottomMargin(0.13) gStyle.SetPadLeftMargin(0.13) gStyle.SetPadRightMargin(0.1) gStyle.SetTitleColor(1, "XYZ") gStyle.SetTitleFont(42, "XYZ")
from ROOT import TChain, TCanvas, gStyle, TGraph, gROOT, TH2I import numpy as np import sys, re, time gROOT.SetBatch(False) chainSN = TChain("tpcfifo_tpcfifo_tree") chainSN.AddFile(sys.argv[1]) print 'SN stream file ', chainSN.GetFile().GetName() # Show title for histograms gStyle.SetOptTitle(1) gStyle.SetPadRightMargin(0.15) gStyle.SetCanvasDefW(800) maxUInt = 4294967295 # Hardcoded # Get crate and run number from file name crate = int(re.findall("\d+", sys.argv[1])[0]) print 'Crate ', crate run = int(re.findall("\d+", sys.argv[1])[-2]) print 'Run ', run chY = TCanvas() chU = TCanvas() chV = TCanvas() # Loop over SN events ( = one frame for each of the 64 channels ) #for ientrySN in xrange( 0, chainSN.GetEntries() ): # Loop from last to first to view first events with a higher chance of having baseline established
atexit.register(save_history) ## macroPath = gROOT.GetMacroPath() ## macroPath += os.environ['CMSSW_BASE'] + '/src/ElectroWeakAnalysis/VPlusJets/test:' ## gROOT.SetMacroPath(macroPath) del atexit, readline, rlcompleter, save_history, historyPath gROOT.SetStyle('Plain') gStyle.SetPadTickX(1) gStyle.SetPadTickY(1) gStyle.SetOptStat("iouRMe") gStyle.SetPalette(1) gStyle.SetOptFit(1112) gStyle.SetOptTitle(0) gStyle.SetCanvasDefH(600) ## Height of canvas gStyle.SetCanvasDefW(600) ## Width of canvas gStyle.SetErrorX(0.) gStyle.SetMarkerStyle(20) ## For the fit/function: gStyle.SetFuncColor(2) gStyle.SetFuncStyle(1) gStyle.SetFuncWidth(1) ## Margins: gStyle.SetPadTopMargin(0.06) gStyle.SetPadBottomMargin(0.15) gStyle.SetPadLeftMargin(0.20) ## was 0.16 gStyle.SetPadRightMargin(0.06) ## was 0.02
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 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.15) #0.16); gStyle.SetPadRightMargin(0.05) #0.02); # For the Pad: gStyle.SetPadBorderMode(0) # gStyle.SetPadBorderSize(Width_t size = 1); 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.SetTitleXSize(Float_t size = 0.02); # Another way to set the size? # gStyle.SetTitleYSize(Float_t size = 0.02); 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)
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 CLICdpStyle(): gROOT.SetStyle("Plain") gStyle.SetCanvasColor(root.kWhite) gStyle.SetFrameFillColor(root.kWhite) gStyle.SetStatColor(root.kWhite) gStyle.SetPadColor(root.kWhite) gStyle.SetFillColor(10) gStyle.SetTitleFillColor(root.kWhite) gStyle.SetPaperSize(20, 26) gStyle.SetDrawBorder(0) gStyle.SetCanvasBorderMode(0) gStyle.SetPadBorderMode(0) gStyle.SetFrameBorderMode(0) gStyle.SetLegendBorderSize(0) gStyle.SetTextSize(0.05) gStyle.SetTitleSize(0.06, "xyz") gStyle.SetLabelSize(0.06, "xyz") gStyle.SetLabelOffset(0.015, "xyz") gStyle.SetTitleOffset(1.2, "yz") gStyle.SetTitleOffset(1.17, "x") font = 42 gStyle.SetTitleFont(font) gStyle.SetTitleFontSize(0.06) gStyle.SetStatFont(font) gStyle.SetStatFontSize(0.07) gStyle.SetTextFont(font) gStyle.SetLabelFont(font, "xyz") gStyle.SetTitleFont(font, "xyz") gStyle.SetTitleBorderSize(0) gStyle.SetStatBorderSize(1) gStyle.SetMarkerStyle(1) gStyle.SetLineWidth(2) gStyle.SetMarkerSize(1.2) gStyle.SetPalette(1) gStyle.SetOptTitle(0) gStyle.SetOptStat(0) gStyle.SetOptFit(0) gStyle.SetEndErrorSize(5) gStyle.SetHistLineWidth(2) gStyle.SetFrameLineWidth(2) gStyle.SetFuncWidth(2) gStyle.SetHistLineColor(root.kBlack) gStyle.SetFuncColor(root.kBlack) gStyle.SetLabelColor(root.kBlack, "xyz") gStyle.SetPadBottomMargin(0.18) gStyle.SetPadTopMargin(0.11) gStyle.SetPadRightMargin(0.08) gStyle.SetPadLeftMargin(0.17) gStyle.SetNdivisions(506, "xy") gStyle.SetPadGridX(0) gStyle.SetPadGridY(0) gStyle.SetPadTickX(1) gStyle.SetPadTickY(1) gStyle.SetCanvasDefW(800) gStyle.SetCanvasDefH(700) gROOT.ForceStyle()
def initStyle(): gROOT.SetStyle("Plain") # For the canvas: gStyle.SetCanvasBorderMode(0) gStyle.SetCanvasColor(kWhite) gStyle.SetCanvasDefH(700) #Height of canvas gStyle.SetCanvasDefW(700) #Width of canvas gStyle.SetCanvasDefX(0) #Position on screen gStyle.SetCanvasDefY(0) # For the line: gStyle.SetLineWidth(2) # For the Pad: gStyle.SetPadBorderMode(0) # gStyle.SetPadBorderSize(Width_t size = 1) gStyle.SetPadColor(kWhite) gStyle.SetPadGridX(True) gStyle.SetPadGridY(True) gStyle.SetGridColor(0) gStyle.SetGridStyle(3) gStyle.SetGridWidth(1) # For the frame: gStyle.SetFrameBorderMode(0) gStyle.SetFrameBorderSize(1) gStyle.SetFrameFillColor(0) gStyle.SetFrameFillStyle(0) gStyle.SetFrameLineColor(1) gStyle.SetFrameLineStyle(1) gStyle.SetFrameLineWidth(1) # For the histo: # gStyle.SetHistFillColor(1) # gStyle.SetHistFillStyle(0) gStyle.SetHistLineColor(1) gStyle.SetHistLineStyle(0) gStyle.SetHistLineWidth(2) # gStyle.SetLegoInnerR(Float_t rad = 0.5) # gStyle.SetNumberContours(Int_t number = 20) gStyle.SetEndErrorSize(2) #gStyle.SetErrorMarker(20) gStyle.SetErrorX(0.) gStyle.SetMarkerStyle(8) gStyle.SetMarkerSize(1) #For the fit/function: gStyle.SetOptFit(0) gStyle.SetFitFormat("5.4g") gStyle.SetFuncColor(2) gStyle.SetFuncStyle(1) gStyle.SetFuncWidth(1) #For the date: gStyle.SetOptDate(0) # gStyle.SetDateX(Float_t x = 0.01) # gStyle.SetDateY(Float_t y = 0.01) # For the statistics box: gStyle.SetOptFile(0) gStyle.SetOptStat(0) # To display the mean and RMS: SetOptStat("mr") gStyle.SetStatColor(kWhite) gStyle.SetStatFont(42) gStyle.SetStatFontSize(0.025) gStyle.SetStatTextColor(1) gStyle.SetStatFormat("6.4g") gStyle.SetStatBorderSize(1) gStyle.SetStatH(0.1) gStyle.SetStatW(0.15) # gStyle.SetStatStyle(Style_t style = 1001) # gStyle.SetStatX(Float_t x = 0) # gStyle.SetStatY(Float_t y = 0) # Margins: gStyle.SetPadTopMargin(0.11) gStyle.SetPadBottomMargin(0.13) gStyle.SetPadLeftMargin(0.17) gStyle.SetPadRightMargin(0.07) # For the Global title: gStyle.SetOptTitle(0) gStyle.SetTitleFont(42) gStyle.SetTitleColor(1) gStyle.SetTitleTextColor(1) gStyle.SetTitleFillColor(10) gStyle.SetTitleFontSize(0.04) # gStyle.SetTitleH(0) # Set the height of the title box # gStyle.SetTitleW(0) # Set the width of the title box #gStyle.SetTitleX(0.35) # Set the position of the title box #gStyle.SetTitleY(0.986) # Set the position of the title box # gStyle.SetTitleStyle(Style_t style = 1001) #gStyle.SetTitleBorderSize(0) # For the axis titles: gStyle.SetTitleColor(1, "XYZ") gStyle.SetTitleFont(42, "XYZ") gStyle.SetTitleSize(0.05, "XYZ") # gStyle.SetTitleXSize(Float_t size = 0.02) # Another way to set the size? # gStyle.SetTitleYSize(Float_t size = 0.02) gStyle.SetTitleXOffset(1.) gStyle.SetTitleYOffset(1.3) #gStyle.SetTitleOffset(1.1, "Y") # Another way to set the Offset # For the axis labels: gStyle.SetLabelColor(1, "XYZ") gStyle.SetLabelFont(42, "XYZ") gStyle.SetLabelOffset(0.007, "XYZ") gStyle.SetLabelSize(0.035, "XYZ") # For the axis: gStyle.SetAxisColor(1, "XYZ") gStyle.SetStripDecimals(True) gStyle.SetTickLength(0.03, "XYZ") gStyle.SetNdivisions(510, "XYZ") gStyle.SetPadTickX( 1) # To get tick marks on the opposite side of the frame gStyle.SetPadTickY(1) # Change for log plots: gStyle.SetOptLogx(0) gStyle.SetOptLogy(0) gStyle.SetOptLogz(0) gStyle.SetPalette(1) #(1,0) # another top group addition gStyle.SetHatchesSpacing(1.0) # Postscript options: gStyle.SetPaperSize(20., 20.) #gStyle.SetPaperSize(TStyle.kA4) #gStyle.SetPaperSize(27., 29.7) #TGaxis.SetMaxDigits(3) # gStyle.SetLineScalePS(Float_t scale = 3) # gStyle.SetLineStyleString(Int_t i, const char* text) # gStyle.SetHeaderPS(const char* header) # gStyle.SetTitlePS(const char* pstitle) #gStyle.SetColorModelPS(1) # gStyle.SetBarOffset(Float_t baroff = 0.5) # gStyle.SetBarWidth(Float_t barwidth = 0.5) # gStyle.SetPaintTextFormat(const char* format = "g") # gStyle.SetPalette(Int_t ncolors = 0, Int_t* colors = 0) # gStyle.SetTimeOffset(Double_t toffset) # gStyle.SetHistMinimumZero(kTRUE) #gStyle.cd() print "TDR Style initialized"
def initialize(fitresults=True, grid=False): gROOT.SetStyle("Plain") gStyle.SetOptFit() gStyle.SetOptStat(0) # For the canvas: gStyle.SetCanvasBorderMode(0) gStyle.SetCanvasColor(kWhite) gStyle.SetCanvasDefH(600) #Height of canvas gStyle.SetCanvasDefW(600) #Width of canvas gStyle.SetCanvasDefX(0) #POsition on screen gStyle.SetCanvasDefY(0) # For the Pad: gStyle.SetPadBorderMode(0) gStyle.SetPadColor(kWhite) gStyle.SetPadGridX(False) gStyle.SetPadGridY(False) gStyle.SetGridColor(0) gStyle.SetGridStyle(3) gStyle.SetGridWidth(1) # For the frame: gStyle.SetFrameBorderMode(0) gStyle.SetFrameBorderSize(1) gStyle.SetFrameFillColor(kWhite) gStyle.SetFrameFillStyle(1000) gStyle.SetFrameLineColor(1) gStyle.SetFrameLineStyle(1) gStyle.SetFrameLineWidth(1) # For the histo: gStyle.SetHistLineColor(1) gStyle.SetHistLineStyle(0) gStyle.SetHistLineWidth(2) gStyle.SetEndErrorSize(2) gStyle.SetErrorX(0.) gStyle.SetMarkerStyle(20) #For the fit/function: gStyle.SetOptFit(1) gStyle.SetFitFormat("5.4g") gStyle.SetFuncColor(2) gStyle.SetFuncStyle(1) gStyle.SetFuncWidth(1) #For the date: gStyle.SetOptDate(0) # For the statistics box: gStyle.SetOptFile(0) gStyle.SetOptStat(0) # To display the mean and RMS: SetOptStat("mr") gStyle.SetStatColor(kWhite) gStyle.SetStatFont(42) gStyle.SetStatFontSize(0.025) gStyle.SetStatTextColor(1) gStyle.SetStatFormat("6.4g") gStyle.SetStatBorderSize(1) gStyle.SetStatH(0.1) gStyle.SetStatW(0.15) # Margins: gStyle.SetPadTopMargin(0.05) gStyle.SetPadLeftMargin(0.16) gStyle.SetPadRightMargin(0.04) # top group adaption, original is 0.02 gStyle.SetPadBottomMargin(0.13) # For the Global title: gStyle.SetOptTitle(0) gStyle.SetTitleFont(42) gStyle.SetTitleColor(1) gStyle.SetTitleTextColor(1) gStyle.SetTitleFillColor(10) gStyle.SetTitleFontSize(0.05) # For the axis titles: gStyle.SetTitleColor(1, "XYZ") gStyle.SetTitleFont(42, "XYZ") gStyle.SetTitleSize(0.06, "XYZ") gStyle.SetTitleXOffset(0.9) gStyle.SetTitleYOffset(1.25) # For the axis labels: gStyle.SetLabelColor(1, "XYZ") gStyle.SetLabelFont(42, "XYZ") gStyle.SetLabelOffset(0.007, "XYZ") gStyle.SetLabelSize(0.05, "XYZ") #gStyle.SetLabelSize(0.04, "XYZ") # For the axis: gStyle.SetAxisColor(1, "XYZ") gStyle.SetStripDecimals(True) gStyle.SetTickLength(0.03, "XYZ") gStyle.SetNdivisions(510, "XYZ") gStyle.SetPadTickX(1) # To get tick marks on the opposite side of the frame gStyle.SetPadTickY(1) # Change for log plots: gStyle.SetOptLogx(0) gStyle.SetOptLogy(0) gStyle.SetOptLogz(0) gStyle.SetPalette(1) #(1,0) # another top group addition gStyle.SetHatchesSpacing(1.0) # Postscript options: gStyle.SetPaperSize(20., 20.) # For graphs gStyle.SetErrorX(0) # suppress error along x if grid: gStyle.SetPadGridX(gridOn) gStyle.SetPadGridY(gridOn) gStyle.SetGridColor(kGray)
def tdrstyle(): gROOT.SetStyle("Plain") gStyle.SetAxisColor(1, "XYZ") gStyle.SetCanvasColor(0) #gStyle.SetCanvasBorderSize(10) gStyle.SetCanvasBorderMode(0) gStyle.SetCanvasDefH(700) gStyle.SetCanvasDefW(700) gStyle.SetCanvasDefX(0) gStyle.SetCanvasDefY(0) gStyle.SetFitFormat("5.4g") gStyle.SetFuncColor(2) gStyle.SetFuncStyle(1) gStyle.SetFuncWidth(1) gStyle.SetFrameBorderMode(0) gStyle.SetFrameBorderSize(1) gStyle.SetFrameFillStyle(0) gStyle.SetFrameFillColor(0) gStyle.SetFrameLineColor(1) gStyle.SetFrameLineStyle(1) # 0? gStyle.SetFrameLineWidth(1) # 1? gStyle.SetGridColor(0) gStyle.SetGridStyle(3) gStyle.SetGridWidth(1) #gStyle.SetHistFillColor(1) #gStyle.SetHistFillStyle(0) gStyle.SetHistLineColor(1) gStyle.SetHistLineStyle(0) gStyle.SetHistLineWidth(1) gStyle.SetLabelColor(1, "XYZ") gStyle.SetLabelFont(42,"XYZ") gStyle.SetLabelOffset(0.007,"XYZ") # 0.010? gStyle.SetLabelSize(0.05,"XYZ") # 0.04? gStyle.SetLegendBorderSize(0) gStyle.SetLegendFillColor(0) gStyle.SetLegendFont(42) gStyle.SetMarkerSize(1.0) gStyle.SetMarkerStyle(20) gStyle.SetLineColor(1) gStyle.SetLineWidth(2) #gStyle.SetLineScalePS(2) gStyle.SetOptDate(0) gStyle.SetOptFile(0) gStyle.SetOptFit(1) gStyle.SetOptStat(0) gStyle.SetOptTitle(0) #gStyle.SetOptLogx(0) #gStyle.SetOptLogy(0) #gStyle.SetOptLogz(0) gStyle.SetPadColor(0) gStyle.SetPadBorderMode(0) gStyle.SetPadBorderSize(10) gStyle.SetPadTopMargin(0.05) # 0.08? gStyle.SetPadBottomMargin(0.13) gStyle.SetPadLeftMargin(0.16) gStyle.SetPadRightMargin(0.03) # 0.05? gStyle.SetPadGridX(0) gStyle.SetPadGridY(0) gStyle.SetPadTickX(1) gStyle.SetPadTickY(1) gStyle.SetStatColor(0) gStyle.SetStatFont(42) gStyle.SetStatFontSize(0.025) gStyle.SetStatTextColor(1) gStyle.SetStatFormat("6.4g") gStyle.SetStatBorderSize(1) gStyle.SetStatH(0.1) gStyle.SetStatW(0.15) #gStyle.SetStatX(0) #gStyle.SetStatY(0) #gStyle.SetTextSize(0.055) gStyle.SetTextFont(42) gStyle.SetTitleBorderSize(0) gStyle.SetTitleColor(1) gStyle.SetTitleFont(42) gStyle.SetTitleColor(1,"XYZ") gStyle.SetTitleFont(42,"XYZ") gStyle.SetTitleSize(0.06,"XYZ") # 0.05? #gStyle.SetTitleOffset(1.4,"XYZ") gStyle.SetTitleOffset(0.9,"X") gStyle.SetTitleOffset(1.20,"Y") gStyle.SetTitleFillColor(10) gStyle.SetTitleFontSize(0.05) gStyle.SetTitleTextColor(1) #gStyle.SetTitleH(0) #gStyle.SetTitleW(0) #gStyle.SetTitleX(0) #gStyle.SetTitleY(0.985) #gStyle.SetTitleStyle(1001) gStyle.SetPalette(1) #gStyle.SetNdivisions(510, "XYZ") # 505? gStyle.SetNdivisions(505, "XYZ") gStyle.SetEndErrorSize(2) # 2? #gStyle.SetErrorMarker(20) #gStyle.SetErrorX(0.) #gStyle.SetPaperSize(20.,20.) gStyle.SetStripDecimals(1) gStyle.SetTickLength(0.03, "XYZ") return 1
def main(): #gROOT.SetBatch(True) gROOT.SetBatch(False) gStyle.SetOptTitle(1) # Title for histograms gStyle.SetPadRightMargin(0.15) gStyle.SetCanvasDefW(800) gStyle.SetTickLength(0, "X") gStyle.SetTickLength(0, "Y") maxUInt = 4294967295 # Maximum integer to be used. Default value when the decoder cannot decode anything #maxTime = 12800 maxTime = 3200 # Maximum time to be displayed: ignore for now the four-frames # MicroBooNE channel map ChMap = ubmap.ChannelMap( "/home/jcrespo/MicroBooNE/ubelec01/MicroBooNEChannelMap/MicroBooNEChannelMap.txt" ) crateChain = [] # List holding the TChain from each crate for f in xrange(1, len(sys.argv)): crateChain.append(TChain("tpcfifo_tpcfifo_tree")) crateChain[-1].AddFile(sys.argv[f]) print 'SN stream file ', crateChain[-1].GetFile().GetName() # Get crate number from file name crate = int(re.findall("\d+", sys.argv[f])[0]) print 'Crate ', crate if f != crate: print 'ERROR: Expected crate {} but got crate {}'.format(f, crate) sys.exit() # Get run number from file name run = int(re.findall("\d+", sys.argv[f])[-2]) print 'Run ', run # Add check so all files have same run number # Canvas for event display. It will be renamed later canvas = TCanvas("c", "c") canvas.Divide(1, 3) # 2-D histograms depicting planes hU = TH2I("hU", "hU", 2400, 0, 2400, maxTime, 0, maxTime) hV = TH2I("hV", "hV", 2400, 0, 2400, maxTime, 0, maxTime) hY = TH2I("hY", "hY", 3456, 0, 3456, maxTime, 0, maxTime) # Color scale maxima and minima. Roughly based on typical baseline +/- 100 ADC hU.SetMaximum(2148) hU.SetMinimum(1948) hV.SetMaximum(2148) hV.SetMinimum(1948) hY.SetMaximum(575) hY.SetMinimum(375) # List holding the current entry index for each crate crateEntry = [0] * len(crateChain) # Align all crates to show this frame first frameReference = 0 # While TChains have entries while WithinLimits(crateEntry, crateChain): hU.Reset() hV.Reset() hY.Reset() for crate, chain in enumerate(crateChain): frame = -1 frameMissing = False while frame != frameReference: chain.GetEntry(crateEntry[crate]) fifo = chain.tpcfifo_tpcfifo_branch frame = fifo.event_frame_number() event = fifo.event_number() if ((frame < frameReference) or (event == maxUInt) or (frame == maxUInt)): crateEntry[crate] += 1 if frame > frameReference: frameMissing = True break if frameMissing: continue crate += 1 # enumerate starts from 0 print 'SN stream crate {} event {} frame {}'.format( crate, event, frame) last_ch = 0 # last channel used xmitAddr = 3 # XMIT address # First and last TPC crates have the XMIT in a different slot if crate == 1: xmitAddr = 7 elif crate == 9: xmitAddr = 4 modId = xmitAddr + 1 # placeholder until decoder is able to handle this modAddr = xmitAddr + 1 # placeholder until decoder is able to handle this # tpcfifo is a vector of ROIs without channel separation for roi in fifo: # roi is a fifo object (defined at core/DataFormat) ch = roi.channel_number() # Hack: detect module change when there is a negative difference between channel numbers if ch - last_ch < 0: # Not completely safe modId += 1 modAddr += 1 last_ch = ch t0SN = roi.readout_sample_number_RAW() #modId = roi.module_id() # decoder does not decode this yet #modAddr = roi.module_address() # decoder does not decode this yet # print 'ROI found in crate {}, module {}/slot {}, channel {} at time {} with {} samples'.format( # crate, modId, modAddr, ch, t0SN, roi.size() # ) plane, larch = ChMap.CrateFEMCh2PlaneWire(crate, modAddr, ch) # Correct for offset due to presamples + lost ADC in NU stream due to channel header? presamples = 7 # Hardcoded t0SN = t0SN - presamples - 1 for s in xrange(roi.size()): tdc = t0SN + s adc = roi[s] if plane == "Y": hY.Fill(larch, tdc, adc) elif plane == "U": hU.Fill(larch, tdc, adc) elif plane == "V": hV.Fill(larch, tdc, adc) #if crate != 9: # continue # If crate counter did not reach 9, it means one or more crates were bad. canvasNameTitle = "canvas_run%d_frame%d" % (run, frame) canvas.SetName(canvasNameTitle) canvas.SetTitle(canvasNameTitle) canvas.cd(1) hU.SetTitle( "Plane U Run %d Frame %d; Channel; Time (#times 0.5 #mus)" % (run, frame)) hU.Draw("colz") canvas.Update() canvas.cd(2) hV.SetTitle( "Plane V Run %d Frame %d; Channel; Time (#times 0.5 #mus)" % (run, frame)) hV.Draw("colz") canvas.Update() canvas.cd(3) hY.SetTitle( "Plane Y Run %d Frame %d; Channel; Time (#times 0.5 #mus)" % (run, frame)) hY.Draw("colz") canvas.Update() print "Enter any key to go to next frame" dummy = sys.stdin.readline() frameReference += 1 # End of loop over SN events sys.exit()
print "You have asked to make a difference plot and to not stack the backgrounds. This is a very strange request. Will skip making the difference plot." arguments.makeDiffPlots = False from ROOT import TFile, gROOT, gStyle, gDirectory, TStyle, THStack, TH1F, TCanvas, TString, TLegend, TLegendEntry, THStack, TIter, TKey, TPaveLabel, TPaveText, TF1, gPad ### setting ROOT options so our plots will look awesome and everyone will love us gROOT.SetBatch() gStyle.SetOptStat(0) gStyle.SetCanvasBorderMode(0) gStyle.SetPadBorderMode(0) gStyle.SetPadColor(0) gStyle.SetCanvasColor(0) gStyle.SetTextFont(42) gStyle.SetCanvasDefH(600) gStyle.SetCanvasDefW(600) gStyle.SetCanvasDefX(0) gStyle.SetCanvasDefY(0) gStyle.SetPadTopMargin(0.07) gStyle.SetPadBottomMargin(0.13) gStyle.SetPadLeftMargin(0.15) gStyle.SetPadRightMargin(0.05) gStyle.SetTitleColor(1, "XYZ") gStyle.SetTitleFont(42, "XYZ") gStyle.SetTitleSize(0.04, "XYZ") gStyle.SetTitleXOffset(1.1) gStyle.SetTitleYOffset(2) gStyle.SetTextAlign(12) gStyle.SetLabelColor(1, "XYZ") gStyle.SetLabelFont(42, "XYZ") gStyle.SetLabelOffset(0.007, "XYZ")
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)
######################################################################################## # root includes must come after the option parser configuration from ROOT import gROOT, gStyle, gDirectory, gPad, TFile, TGraphErrors, TColor, TCanvas, TLegend, TPaveText, TLine # setting ROOT options so our plots will look awesome and everyone will love us gROOT.SetBatch() gStyle.SetOptStat(0) gStyle.SetCanvasBorderMode(0) gStyle.SetPadBorderMode(0) gStyle.SetPadColor(0) gStyle.SetCanvasColor(0) gStyle.SetCanvasColor(0) gStyle.SetCanvasDefH(300) gStyle.SetCanvasDefW(400) gStyle.SetCanvasDefX(0) gStyle.SetCanvasDefY(0) gStyle.SetGridStyle(3) gStyle.SetNdivisions(510) gROOT.ForceStyle() ######################################################################################## REBIN_FACTOR = 32 # defining color palette black_ = 1 red_ = 633 orange_ = 801 green_ = 417
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 setgstyle(): # Zero horizontal error bars gStyle.SetErrorX(0) # For the canvas gStyle.SetCanvasBorderMode(0) gStyle.SetCanvasColor(0) gStyle.SetCanvasDefH(800) # Height of canvas gStyle.SetCanvasDefW(800) # Width of canvas gStyle.SetCanvasDefX(0) # Position on screen gStyle.SetCanvasDefY(0) # For the frame gStyle.SetFrameBorderMode(0) gStyle.SetFrameBorderSize(1) gStyle.SetFrameFillColor(1) gStyle.SetFrameFillStyle(0) gStyle.SetFrameLineColor(1) gStyle.SetFrameLineStyle(0) gStyle.SetFrameLineWidth(1) # For the Pad gStyle.SetPadBorderMode(0) gStyle.SetPadColor(0) gStyle.SetPadGridX(False) gStyle.SetPadGridY(False) gStyle.SetGridColor(0) gStyle.SetGridStyle(3) gStyle.SetGridWidth(1) # Margins gStyle.SetPadTopMargin(0.08) gStyle.SetPadBottomMargin(0.19) gStyle.SetPadLeftMargin(0.17) #gStyle.SetPadRightMargin(0.07) # For the histo: gStyle.SetHistLineColor(1) gStyle.SetHistLineStyle(0) gStyle.SetHistLineWidth(2) gStyle.SetMarkerSize(1.4) gStyle.SetEndErrorSize(4) # For the statistics box: gStyle.SetOptStat(0) # For the axis gStyle.SetAxisColor(1, "XYZ") gStyle.SetTickLength(0.03, "XYZ") gStyle.SetNdivisions(510, "XYZ") gStyle.SetPadTickX(1) gStyle.SetPadTickY(1) gStyle.SetStripDecimals(False) # For the axis labels and titles gStyle.SetTitleColor(1, "XYZ") gStyle.SetLabelColor(1, "XYZ") gStyle.SetLabelFont(42, "XYZ") gStyle.SetLabelOffset(0.007, "XYZ") gStyle.SetLabelSize(0.045, "XYZ") gStyle.SetTitleFont(42, "XYZ") gStyle.SetTitleSize(0.06, "XYZ") # For the legend gStyle.SetLegendBorderSize(0)