{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "### Make the fake data for the Minuit class final example.\n", "\n", "For more on what's going in this code (\"What the heck is a 'data frame'?) see: \n", "[Data Frame class reference](https://root.cern/doc/master/classROOT_1_1RDataFrame.html) \n", "[Data Frame tutorials](https://root.cern.ch/doc/master/group__tutorial__dataframe.html)\n", "\n", "This is a ROOT C++ notebook, because it's easier to create lambda functions in C++ than it is in Python.\n", "\n", "**Warning:** If you're searching for physics in the following code, there isn't any. Really!" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [], "source": [ "#include \"ROOT/RDataFrame.hxx\"\n", "const int nevents = 100000;\n", "ROOT::RDataFrame dataframe(nevents);\n", "\n", "auto fileName = \"~seligman/root-class/datafile.root\";\n", "auto treeName = \"datatree\";\n", "\n", "TF1 elepton(\"elepton\",\"TMath::Landau(x,10,10)\",0,150);\n", "TF1 ehadron(\"ehadron\",\"TMath::Gaus(x,10,10)\",0,150);\n", "\n", "int event=0;\n", "// For each row in the ntuple (data frame), increment an\n", "// event number, fetch random numbers from the elepton and\n", "// ehadron functions, and write the row to a TTree 'treeName'\n", "// in file 'filename'. \n", "dataframe.Define(\"event\", [&event]() { ++event; return (double)event; })\n", " .Define(\"elepton\", [&elepton]() { return elepton.GetRandom(); })\n", " .Define(\"ehadron\", [&ehadron]() { return ehadron.GetRandom(); })\n", " .Snapshot(treeName, fileName);" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "ROOT C++", "language": "c++", "name": "python3-jupyroot" }, "language_info": { "codemirror_mode": "text/x-c++src", "file_extension": ".C", "mimetype": " text/x-c++src", "name": "c++" } }, "nbformat": 4, "nbformat_minor": 4 }