{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "42d5da4a",
   "metadata": {},
   "source": [
    "Source: https://github.com/root-project/summer-student-course"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "7790c9ad",
   "metadata": {},
   "source": [
    "**Excercise1** : The file `example_file.root` contains a TTree dataset (called `dataset`) with two scalar columns `a` and `b`.\n",
    "\n",
    "There is a normal distribution hidden in there, but to display it you have to plot the natural logarithm of a only for entries in which `b <= 0.5`."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "6b06f94e",
   "metadata": {},
   "outputs": [],
   "source": [
    "import ROOT"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "357f0d9a",
   "metadata": {},
   "outputs": [],
   "source": [
    "treeName = 'dataset'\n",
    "fileName = 'example_file.root'"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "e6880587",
   "metadata": {},
   "outputs": [],
   "source": [
    "# create a dataframe object \n",
    "df = None"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "32f424ef",
   "metadata": {},
   "outputs": [],
   "source": [
    "#Apply the filter b <=0.5 \n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "d4d258be",
   "metadata": {},
   "outputs": [],
   "source": [
    "# define a variable loga , Hint: \"std::log(a)\" in the expression"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "32048d21",
   "metadata": {},
   "outputs": [],
   "source": [
    "# book the loga histogram\n",
    "h= df.Histo1D((\"h\", \"A normal histo\", 30, -5, 5), \"loga\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "68aa1da4",
   "metadata": {},
   "outputs": [],
   "source": [
    "#draw the histogram\n",
    "canvas = ROOT.TCanvas()\n",
    "h.Draw()\n",
    "canvas.Draw()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "35a74408",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "a7925fbb",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "@webio": {
   "lastCommId": null,
   "lastKernelId": null
  },
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.11.9"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
