示例#1
0
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)
示例#2
0
def Styling():
    # Center title
    gStyle.SetTitleAlign(22)
    gStyle.SetTitleX(.5)
    gStyle.SetTitleY(.95)
    gStyle.SetTitleBorderSize(0)
    # Remove stats box
    gStyle.SetOptStat(0)
    # Set background color to white
    gStyle.SetFillColor(10)
    gStyle.SetFrameFillColor(10)
    gStyle.SetCanvasColor(10)
    gStyle.SetPadColor(10)
    gStyle.SetTitleFillColor(0)
    gStyle.SetStatColor(10)
    # No colored frames around plots
    gStyle.SetFrameBorderMode(0)
    gStyle.SetCanvasBorderMode(0)
    gStyle.SetPadBorderMode(0)
    # Set the default line color for a fit function to be red
    gStyle.SetFuncColor(2)
    # Marker settings
    gStyle.SetMarkerStyle(20)
    # No border on legends
    gStyle.SetLegendBorderSize(0)
    # Disabled for violating NOvA style guidelines
    # Scientific notation on axes
    TGaxis.SetMaxDigits(3)
    # Axis titles
    gStyle.SetTitleSize(.055, "xyz")
    gStyle.SetTitleOffset(2.2, "xyz")
    gStyle.SetTitleOffset(2.2, "y")
    gStyle.SetTitleSize(.05, "")
    gStyle.SetTitleOffset(2.2, "")
    # Axis labels (numbering)
    gStyle.SetLabelSize(.05, "xyz")
    gStyle.SetLabelOffset(.005, "xyz")
    # Thicker lines
    gStyle.SetHistLineWidth(2)
    gStyle.SetFrameLineWidth(2)
    gStyle.SetFuncWidth(2)
    # Set the number of tick marks
    gStyle.SetNdivisions(506, "xyz")
    # Set tick marks on all sides
    gStyle.SetPadTickX(1)
    gStyle.SetPadTickY(1)
    # Fonts
    kNovaFont = 42
    gStyle.SetStatFont(kNovaFont)
    gStyle.SetLabelFont(kNovaFont, "xyz")
    gStyle.SetTitleFont(kNovaFont, "xyz")
    gStyle.SetTitleFont(kNovaFont, "")
    # Apply same settings to titles
    gStyle.SetTextFont(kNovaFont)
    gStyle.SetLegendFont(kNovaFont)
示例#3
0
文件: ITScanCore.py 项目: hxc0/test
def set_root_env():
    from ROOT import gStyle, gROOT
    gROOT.Reset()
    gROOT.SetStyle('Plain')
    gStyle.SetCanvasColor(10)
    gStyle.SetStatBorderSize(1)
    gStyle.SetFillColor(10)
    gStyle.SetOptStat(1)
    gStyle.SetStatX(0.46)
    gStyle.SetStatY(0.9)
    gStyle.SetTitleYOffset(1.4)
    gStyle.SetPalette(45)
    gStyle.SetMarkerSize(0.8)
    gStyle.SetLineColor(1)
    gStyle.SetLineWidth(1)
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)
示例#5
0
from os.path import join, getsize
from ROOT import TFile, TProfile, TF1, TMath, TH1F, TCanvas, TPostScript, TGraphErrors
from ROOT import gDirectory
from math import fabs
from os import path
import sys
from ROOT import *
from ROOT import gROOT, gRandom, gStyle
from ROOT import TCanvas, TF1, TH1F, TH2F, TGLabel
gROOT.Reset()

gROOT.SetStyle("Pub")
gStyle.SetPadColor(10)
gStyle.SetGridColor(16)
gStyle.SetFrameFillColor(10)
gStyle.SetFillColor(10)
gStyle.SetTitleFillColor(10)
gStyle.SetTitleBorderSize(0)
gStyle.SetCanvasColor(10)
gStyle.SetStatColor(10)
gStyle.SetLabelSize(0.08, "xyz")
gStyle.SetTitleSize(0.08, "xyz")
gStyle.SetFrameLineWidth(1)
gStyle.SetHistLineWidth(1)
gStyle.SetNdivisions(510, "x")
gStyle.SetNdivisions(508, "y")
gStyle.SetNdivisions(8, "z")
gStyle.SetTickLength(0.03, "x")
gStyle.SetTickLength(0.03, "y")
gStyle.SetTickLength(0.03, "z")
gStyle.SetFrameBorderSize(1)
示例#6
0
from ROOT import TLorentzVector, TCanvas, TH1F, TLegend, gStyle, TLatex

tree1 = ET.parse('events.lhe')
root1 = tree1.getroot()
pt_phi1 = []
pt_b = []
pt_bbar = []
eta_b = []
eta_bbar = []
met = []
DR = []
gStyle.SetFrameLineWidth(3)
gStyle.SetOptTitle(0)
gStyle.SetOptStat(0)
#gStyle.SetLegendBorderSize(2)
gStyle.SetFillColor(2)
gStyle.SetLineWidth(1)
#gStyle.SetPadColor(1)
#legend=TLegend(.63,.69,.87,.89,"","brNDC")
#legend=TLegend(0.57, 0.5, 0.94,0.65,"","brNDC")
c = TCanvas()

cmsname = TLatex(0.15, 0.95, 'CMS Simulation Preliminary  ')
#cmsname=TLatex(0.15,1.85,"CMS #it{#bf{Preliminary}}")
cmsname.SetTextSize(0.036)
cmsname.SetTextAlign(12)
cmsname.SetNDC(1)
cmsname.SetTextFont(61)
#lhefdata=LHEFData(float(root.attrib['version']))
for child in root1:
    if (child.tag == 'event'):
示例#7
0
def create2DPlotsGeometryComparison(detector, plot, 
                                    geometryOld, geometryNew):

    setTDRStyle()

    print('Extracting plot: %s.'%(plot))
    goodToGo, theFiles = paramsGood_(detector,plot,
                                     geometryOld,geometryNew)

    if not goodToGo:
        return
    
    gStyle.SetOptStat(False)

    old2DHisto = get2DHisto_(detector,plots[plot].plotNumber,geometryOld)
    new2DHisto = get2DHisto_(detector,plots[plot].plotNumber,geometryNew)

    if plots[plot].iRebin:
        old2DHisto.Rebin2D()
        new2DHisto.Rebin2D()

    def setRanges(h):
        h.GetXaxis().SetRangeUser(plots[plot].xmin, plots[plot].xmax)
        h.GetYaxis().SetRangeUser(plots[plot].ymin, plots[plot].ymax)
        if plots[plot].histoMin != -1.:
            h.SetMinimum(plots[plot].histoMin)
        if plots[plot].histoMax != -1.:
            h.SetMaximum(plots[plot].histoMax)

    ratio2DHisto = copy.deepcopy(new2DHisto)
    ratio2DHisto.Divide(old2DHisto)
    # Ratio and Difference have the same call
    # But different 'Palette' range so we are
    # setting the range only for the Ratio
    ratio2DHisto.SetMinimum(0.2)
    ratio2DHisto.SetMaximum(1.8)
    setRanges(ratio2DHisto)

    diff2DHisto = copy.deepcopy(new2DHisto)
    diff2DHisto.Add(old2DHisto,-1.0)
    setRanges(diff2DHisto)


    def setPadStyle():
        gPad.SetLeftMargin(0.05)
        gPad.SetRightMargin(0.08)
        gPad.SetTopMargin(0.10)
        gPad.SetBottomMargin(0.10)
        gPad.SetLogz(plots[plot].zLog)
        gPad.SetFillColor(kWhite)
        gPad.SetBorderMode(0)

    can = TCanvas('can','can',
                  2724,1336)
    can.Divide(1,2)
    can.cd(1)
    setPadStyle()
    gPad.SetLogz(plots[plot].zLog)
    
    gStyle.SetOptStat(0)
    gStyle.SetFillColor(kWhite)
    gStyle.SetPalette(kTemperatureMap)

    ratio2DHisto.SetTitle("%s, Ratio: %s/%s;%s;%s"
                          %(plots[plot].quotaName,
                            geometryOld, geometryNew,
                            plots[plot].abscissa,
                            plots[plot].ordinate))
    ratio2DHisto.Draw('COLZ')

    can.Update()

    setUpPalette(ratio2DHisto,plot)

    etasTop = []
    if plots[plot].iDrawEta:
        etasTop.extend(drawEtaValues())

    can.cd(2)

    diff2DHisto.SetTitle('%s, Difference: %s - %s %s;%s;%s'
                         %(plots[plot].quotaName,geometryNew,geometryOld,detector,
                           plots[plot].abscissa,plots[plot].ordinate))
    setPadStyle()
    diff2DHisto.Draw("COLZ")
    can.Update()
    setUpPalette(diff2DHisto,plot)

    etasBottom = []
    if plots[plot].iDrawEta:
        etasBottom.extend(drawEtaValues())

    can.Modified()

    theDirname = "Images"

    if not checkFile_(theDirname):
        os.mkdir(theDirname)
        
    can.SaveAs( "%s/%s_Comparison_%s_%s_vs_%s.png"
                % (theDirname,detector,plot,geometryOld,geometryNew) )
    gStyle.SetStripDecimals(True)
def set_root_env():
    #//TStyle* genieStyle = new TStyle("genieStyle", "GENIE Style")
    #//set the background color to white
    gStyle.SetFillColor(10)
    gStyle.SetFrameFillColor(10)
    gStyle.SetCanvasColor(10)
    gStyle.SetPadColor(10)
    gStyle.SetTitleFillColor(0)
    gStyle.SetStatColor(10)

    #dont put a colored frame around the plots
    gStyle.SetFrameBorderMode(0)
    gStyle.SetCanvasBorderMode(0)
    gStyle.SetPadBorderMode(0)
    gStyle.SetLegendBorderSize(3)

    #use the primary color palette
    #gStyle.SetPalette(1,0)

    #set the default line color for a histogram to be black
    gStyle.SetHistLineColor(ROOT.kBlack)

    #set the default line color for a fit function to be red
    gStyle.SetFuncColor(ROOT.kRed)

    #make the axis labels black
    gStyle.SetLabelColor(ROOT.kBlack, "xyz")

    #set the default title color to be black
    gStyle.SetTitleColor(ROOT.kBlack)

    #set the margins
    gStyle.SetPadBottomMargin(0.18)
    gStyle.SetPadTopMargin(0.08)
    gStyle.SetPadRightMargin(0.08)
    gStyle.SetPadLeftMargin(0.17)

    #set axis label and title text sizes
    gStyle.SetLabelFont(42, "xyz")
    gStyle.SetLabelSize(0.04, "xyz")
    gStyle.SetLabelOffset(0.015, "xyz")
    gStyle.SetTitleFont(42, "xyz")
    gStyle.SetTitleSize(0.04, "xyz")
    gStyle.SetTitleOffset(1.4, "y")
    gStyle.SetTitleOffset(1.3, "x")
    gStyle.SetStatFont(42)
    gStyle.SetStatFontSize(0.07)
    gStyle.SetTitleBorderSize(1)
    gStyle.SetStatBorderSize(0)
    gStyle.SetTextFont(42)
    gStyle.SetTitleW(0.5)
    gStyle.SetTitleH(0.1)

    #set line widths
    gStyle.SetFrameLineWidth(2)
    gStyle.SetFuncWidth(2)
    gStyle.SetHistLineWidth(2)

    #set the number of divisions to show
    gStyle.SetNdivisions(506, "xy")
    #gStyle.SetPadTickX(-50202)

    #turn off xy grids
    gStyle.SetPadGridX(0)
    gStyle.SetPadGridY(0)

    #set the tick mark style
    gStyle.SetPadTickX(1)
    gStyle.SetPadTickY(1)

    #turn off stats
    gStyle.SetOptStat(0)
    gStyle.SetOptFit(0)

    #marker/line settings
    #gStyle.SetMarkerStyle(20)
    gStyle.SetMarkerSize(.95)  #0.7
    gStyle.SetLineWidth(2)
    gStyle.SetErrorX(0)
    gStyle.SetHistLineStyle(0)  #It was 3 for a dotted line

    #done
    gStyle.cd()
    gROOT.ForceStyle()
示例#9
0
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()
示例#10
0
def initialization(batch=True, font=default_font):
    '''-- ROOT initialization --'''

    print "Initializing ROOT ..."

    # general
    gROOT.Reset()
    gROOT.SetBatch(batch)
    gROOT.SetStyle("Plain")

    # gStyle
    gStyle.SetFillColor(0)
    gStyle.SetCanvasColor(10)
    gStyle.SetLineWidth(1)
    gStyle.SetPalette(8)
    gStyle.SetTextFont(font)
    #gStyle.SetTextSize(30)

    # Frame
    gStyle.SetFrameBorderMode(0)
    gStyle.SetFrameFillColor(0)

    # Pad
    gStyle.SetPadBorderMode(0)
    gStyle.SetPadColor(0)
    gStyle.SetPadBottomMargin(0.1)
    gStyle.SetPadTopMargin(0.01)
    gStyle.SetPadLeftMargin(0.1)
    gStyle.SetPadRightMargin(0.01)
    gStyle.SetPadTickX(1)  # make ticks be on all 4 sides.
    gStyle.SetPadTickY(1)
    gStyle.SetPadGridX(0)
    gStyle.SetPadGridY(0)

    # histogram
    gStyle.SetHistFillStyle(0)
    gStyle.SetOptTitle(0)
    gStyle.SetTitleSize(0.22)
    gStyle.SetTitleFontSize(10)
    gStyle.SetTitleFont(font)
    gStyle.SetTitleFont(font, "xyz")
    gStyle.SetTitleYOffset(1.0)
    gStyle.SetTitleXOffset(1.0)
    gStyle.SetTitleXSize(0.04)
    gStyle.SetTitleYSize(0.04)
    gStyle.SetTitleX(.15)
    gStyle.SetTitleY(.98)
    gStyle.SetTitleW(.70)
    gStyle.SetTitleH(.05)

    # statistics box
    gStyle.SetOptStat(0)
    gStyle.SetStatFont(font)
    gStyle.SetStatFontSize(10)
    gStyle.SetStatX(.91)
    gStyle.SetStatY(.90)
    gStyle.SetStatW(.15)
    gStyle.SetStatH(.15)

    # axis labels
    gStyle.SetLabelFont(font)
    gStyle.SetLabelFont(font, "xyz")
    gStyle.SetLabelSize(10, "xyz")
    # gStyle.SetGridColor(1)
    gStyle.SetLegendBorderSize(1)
示例#11
0
import ElementTree2 as ET
from ROOT import TLorentzVector, TCanvas, TH1F,TLegend,gStyle, TPaveLabel

tree1 = ET.parse('/Users/chep/Documents/MG5_aMC_v2_6_5/mywork/pp_zp_a0h_bb_292600_scan/Events/run_01/unweighted_events.lhe')
root1=tree1.getroot()
phi_A0=[]
eta_A0=[]
pt_A0=[]
m_A0=[]
gStyle.SetFrameLineWidth(3)
gStyle.SetOptTitle(0)
gStyle.SetOptStat(0)
#gStyle.SetLegendBorderSize(2)
gStyle.SetFillColor(4)
gStyle.SetLineWidth(1)
#gStyle.SetPadColor(1)
#legend=TLegend(.63,.69,.87,.89,"","brNDC")
#legend=TLegend(0.57, 0.5, 0.94,0.65,"","run_01")
c = TCanvas()

#lhefdata=LHEFData(float(root.attrib['version']))
for child in root1:
    if(child.tag=='event'):
       lines=child.text.strip().split('\n')
       event_header=lines[0].strip()
       num_part=int(event_header.split()[0].strip())




       b=[s for s in lines if s.split()[0]=='5' and ((s.split()[2]=='5' and lines[5].split()[0]=='28') or (s.split()[2]=='4' and lines[4].split()[0]=='28'))]