{"metadata":{"language_info":{"name":"python","version":"3.7.8","mimetype":"text/x-python","codemirror_mode":{"name":"ipython","version":3},"pygments_lexer":"ipython3","nbconvert_exporter":"python","file_extension":".py"},"kernelspec":{"name":"python3","display_name":"Python 3","language":"python"}},"nbformat_minor":4,"nbformat":4,"cells":[{"cell_type":"code","source":"# This notebook is for checking ZZ histograms.\n# Using python\nfrom ROOT import gStyle, TFile, TH1, TH1D, TH2D, TCanvas, TLegend, TColor","metadata":{"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# Let's start with setting some ROOT style parameters:\n# You do not need to know what they mean, but can directly use these settings\n\ngStyle.SetOptStat(0)\ngStyle.SetPalette(1)\n\ngStyle.SetTextFont(42)\n\ngStyle.SetTitleStyle(0000)\ngStyle.SetTitleBorderSize(0)\ngStyle.SetTitleFont(42)\ngStyle.SetTitleFontSize(0.055)\n\ngStyle.SetTitleFont(42, \"xyz\")\ngStyle.SetTitleSize(0.5, \"xyz\")\ngStyle.SetLabelFont(42, \"xyz\")\ngStyle.SetLabelSize(0.45, \"xyz\")","metadata":{"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# Open the files with signal and bg histograms given by CutLang: \nf = TFile(\"../runs/histoOut-VSOPZZ.root\")","metadata":{"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# Get the histograms\n# Overview region:\nhneinp = f.Get(\"overview/hneinp\")\nhnminp = f.Get(\"overview/hnminp\")\nhnesel = f.Get(\"overview/hnesel\")\nhnmsel = f.Get(\"overview/hnmsel\")\nhnenminp = f.Get(\"overview/hnenminp\")\nhnenmsel = f.Get(\"overview/hnenmsel\")\n\n# Zeeinp region\nhZeeinp = f.Get(\"Zeeinp/hZeeinp\")\n# Zeesel region\nhZeesel = f.Get(\"Zeesel/hZeesel\")\n# Zmminp region\nhZmminp = f.Get(\"Zmminp/hZmminp\")\n# Zmmsel region\nhZmmsel = f.Get(\"Zmmsel/hZmmsel\")\n# Zeemminp region\nhZeeinp2 = f.Get(\"Zeemminp/hZeeinp\")\nhZmminp2 = f.Get(\"Zeemminp/hZmminp\")\nhZeemminp = f.Get(\"Zeemminp/hZeemminp\")\n# Zeemmsel region\nhZeesel2 = f.Get(\"Zeemmsel/hZeesel\")\nhZmmsel2 = f.Get(\"Zeemmsel/hZmmsel\")\nhZeemmsel = f.Get(\"Zeemmsel/hZeemmsel\")","metadata":{"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# In order to be able to make many plots, let's define two generic histogrms to which we can \n# assign any of the histograms above:\nh1 = hnesel\nh2 = hnmsel\n\n# Our purpose in this exercise is to compare the shapes of signal and background distributions.\n# To do this comparison best, the area integral under histograms being compared should be the same.\n# Therefore we scale the hisgograms so that the area integral under the histograms equals 1. \n#h1.Scale(1./hmet1.Integral())\n#h2.Scale(1./hmet2.Integral())","metadata":{"trusted":true},"execution_count":15,"outputs":[]},{"cell_type":"code","source":"# Histogram style settings:\nh1.SetLineWidth(2)\nh2.SetLineWidth(2)\n\nh1.SetLineColor(600) # kBlue\nh2.SetLineColor(416+2) # kGreen + 2\n\n# Titles, labels.  \n# Remember that it is enough to set these variables ONLY FOR THE FIRST HISTOGRAM YOU WILL DRAW\n# i.e., the one you will call by .Draw().  The rest you will draw by .Draw(\"same\") will only \n# contribute with the historam curve.\n#h1.SetTitle()\n#h1.GetXaxis().SetTitle(\"x\")\ntitle = h1.GetTitle()\nprint(title)\nh1.GetXaxis().SetTitle(title)\nh1.GetXaxis().SetTitleOffset(1.25)\nh1.GetXaxis().SetTitleSize(0.05)\nh1.GetXaxis().SetLabelSize(0.045)\nh1.GetXaxis().SetNdivisions(8, 5, 0)\nh1.GetYaxis().SetTitle(\"number of events\")\nh1.GetYaxis().SetTitleOffset(1.4)\nh1.GetYaxis().SetTitleSize(0.05)\nh1.GetYaxis().SetLabelSize(0.045)\n","metadata":{"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# Make a generically usable legend\nl = TLegend(0.65, 0.75, 0.88, 0.87)\nl.SetBorderSize(0)\nl.SetFillStyle(0000)\n# You can change the legend titles from here based on what you are plotting\nl.AddEntry(h1,h1.GetName(), \"l\")\nl.AddEntry(h2,h2.GetName(), \"l\")","metadata":{"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# Plot and display MET\n# Make a dedicated canvas\nc = TCanvas(\"c\", \"c\", 620, 500)\nc.SetBottomMargin(0.15)\nc.SetLeftMargin(0.15)\nc.SetRightMargin(0.15)\n# Draw the histograms and the legend\n# Make sure you draw the background before the signal\nh1.Draw()\nh2.Draw(\"same\")\nl.Draw(\"same\")\nc.Draw()","metadata":{"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# We need a different canvas for the new histogram\nc2 = TCanvas(\"c2\", \"c2\", 620, 500)\nc2.SetBottomMargin(0.15)\nc2.SetLeftMargin(0.15)\nc2.SetRightMargin(0.15)\nhZeemmsel.Draw(\"colz\")\nc2.Draw()","metadata":{"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{},"execution_count":null,"outputs":[]}]}