{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "Example program to analyse Landau data read from file" ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Welcome to JupyROOT 6.26/06\n" ] } ], "source": [ "from ROOT import TCanvas, TGraph, TH1D, TFile\n", "from ROOT import gROOT\n", "#gROOT.SetBatch(False) # no display in batch mode" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [], "source": [ "%jsroot on" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "read data from a text File " ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "shape of data: (27228,)\n", "datatype of data: float64\n" ] } ], "source": [ "import numpy as np\n", "data = np.loadtxt(\"./measuredLandau.txt\")\n", "print(\"shape of data:\",data.shape)\n", "print(\"datatype of data:\",data.dtype)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Create a new canvas, and customize it." ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [], "source": [ "c1 = TCanvas( 'c1', 'Landau Distribution', 200, 10, 700, 500 )" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Create Histogramm" ] }, { "cell_type": "code", "execution_count": 5, "metadata": {}, "outputs": [], "source": [ "landau = TH1D( 'landau', 'Landau distribution', 100, 0., 250.)" ] }, { "cell_type": "code", "execution_count": 6, "metadata": {}, "outputs": [], "source": [ "for l in data:\n", " landau.Fill(l)" ] }, { "cell_type": "code", "execution_count": 7, "metadata": {}, "outputs": [ { "data": { "text/html": [ "\n", "\n", "