{ "cells": [ { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Welcome to JupyROOT 6.10/02\n" ] } ], "source": [ "import ROOT\n", "\n", "in_file = ROOT.TFile(\"~/work/sti-profiling/inputs_joinTwo.root\")\n", "#in_file = ROOT.TFile(\"/home/smirnovd/my-tests-data/inputs_joinTwo.root\")\n", "\n", "t = in_file.Get(\"t\")\n", "\n", "ROOT.enableJSVis()\n", "ROOT.gStyle.SetPadRightMargin(0.3)" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [ { "data": { "text/html": [ "" ], "text/vnd.plotly.v1+html": [ "" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "import plotly\n", "import plotly.figure_factory as ff\n", "import plotly.graph_objs as go\n", "\n", "plotly.offline.init_notebook_mode(connected=True)" ] }, { "cell_type": "code", "execution_count": 3, "metadata": { "collapsed": true }, "outputs": [], "source": [ "# Define some functions\n", "\n", "g_h_counter = 1\n", "\n", "# Fill 1D histogram from the tree\n", "def project1D(expression, x_bins, x_first, x_last, h_title = \"\", selection = \"\"):\n", "\n", " global g_h_counter\n", "\n", " h_name = 'h_{:03d}'.format(g_h_counter)\n", " g_h_counter += 1\n", "\n", " if h_title == \"\":\n", " h_title = expression\n", "\n", " h1D = ROOT.TH1D(h_name, h_title, x_bins, x_first, x_last)\n", "\n", " t.Project(h_name, expression, selection)\n", "\n", " return h1D\n", "\n", "\n", "\n", "# Fill 2D histogram from the tree\n", "def project2D(expression, x_bins, x_first, x_last, y_bins, y_first, y_last,\n", " h_title = \"\", selection = \"\", draw_options = \"\"):\n", "\n", " global g_h_counter\n", "\n", " h_name = 'h_{:03d}'.format(g_h_counter)\n", " g_h_counter += 1\n", "\n", " if h_title == \"\":\n", " h_title = expression\n", "\n", " h2D = ROOT.TH2D(h_name, h_title, x_bins, x_first, x_last, y_bins, y_first, y_last)\n", " h2D.SetOption(draw_options)\n", "\n", " t.Project(h_name, expression, selection, draw_options)\n", "\n", " return h2D\n", "\n", "\n", "\n", "def drawOnCanvases(hists, width = 800, height = 600):\n", "\n", " canvases = []\n", "\n", " for hist in hists:\n", " canvas = ROOT.TCanvas(\"canvas_\" + hist.GetName(), \"ROOT Canvas\", width, height)\n", " hist.Draw( hist.GetOption() )\n", " canvas.Draw()\n", " canvases.append(canvas)\n", "\n", " return canvases\n", "\n", "\n", "\n", "def getCumulative(hists):\n", "\n", " hists_cumul = []\n", "\n", " for hist in hists:\n", " hist_cumul = hist\n", " hist_cumul.Scale( 1./hist_cumul.Integral() )\n", " hist_cumul = hist_cumul.GetCumulative()\n", " hists_cumul.append(hist_cumul)\n", "\n", " return hists_cumul\n", "\n", "\n", "\n", "def plotly1D(h1D):\n", "\n", " y_values_ptr = h1D.GetArray()\n", " y_values = []\n", " x_values = []\n", "\n", " for i_bin in range( 1, h1D.GetNbinsX() + 1 ):\n", " y_values.append( y_values_ptr[i_bin] )\n", " x_values.append( h1D.GetBinCenter(i_bin) )\n", "\n", " #return [ go.Bar(y = y_values) ]\n", " plotly.offline.iplot( [ go.Bar(y = y_values) ] )" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Distributions for each component of the input vectors" ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [ { "data": { "text/html": [ "\n", "