diff --git a/codigo/Conversion_de_CSV_a_ROOT.ipynb b/codigo/Conversion_de_CSV_a_ROOT.ipynb new file mode 100644 index 0000000000000000000000000000000000000000..d84d565f364ac8f02bc7f377d917dadd3d2f8008 --- /dev/null +++ b/codigo/Conversion_de_CSV_a_ROOT.ipynb @@ -0,0 +1,107 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + " Carlos Andres Pinzon Osorio\n", + " Maestria en Ingenieria Fisica\n", + " UAN\n", + " Bogota-Colombia" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Proyecto ciencia de datos\n", + "\n", + "Conversion de archivo con extension .CSV a .ROOT" + ] + }, + { + "cell_type": "code", + "execution_count": 8, + "metadata": {}, + "outputs": [], + "source": [ + "%jsroot on\n" + ] + }, + { + "cell_type": "code", + "execution_count": 9, + "metadata": {}, + "outputs": [], + "source": [ + "#include \"Riostream.h\"\n", + "#include \"TString.h\"\n", + "#include \"TFile.h\"\n", + "#include \"TTree.h\"\n", + "#include \"TSystem.h\"\n", + "#include <stdio.h>\n", + "#include <stdlib.h>" + ] + }, + { + "cell_type": "code", + "execution_count": 10, + "metadata": {}, + "outputs": [], + "source": [ + "TString dir = gSystem->UnixPathName(__FILE__);\n", + "dir.ReplaceAll(\"analisiss.C\",\"\");\n", + "dir.ReplaceAll(\"/./\",\"/\");" + ] + }, + { + "cell_type": "code", + "execution_count": 11, + "metadata": {}, + "outputs": [], + "source": [ + "TFile *f = new TFile(\"analisiss.root\",\"RECREATE\");" + ] + }, + { + "cell_type": "code", + "execution_count": 13, + "metadata": {}, + "outputs": [ + { + "name": "stderr", + "output_type": "stream", + "text": [ + "input_line_41:2:9: error: redefinition of 'tree'\n", + " TTree *tree = new TTree(\"ntuple\",\"data from csv file\");\n", + " ^\n", + "input_line_32:2:9: note: previous definition is here\n", + " TTree *tree = new TTree(\"Data\",\"data from csv file\");\n", + " ^\n" + ] + } + ], + "source": [ + "TTree *tree = new TTree(\"ntuple\",\"data from csv file\");\n", + "// The file inside has ----> type, Channel, NJets, MET, Mll, LepDeltaPhi, METLLDeltaPhi, SumLepPt, BTags, weight\n", + "tree->ReadFile(\"analisiss.csv\", \"individuo/C:origen/C:peso/C:tamano/C\",';');\n", + "f->Write();" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "ROOT C++", + "language": "c++", + "name": "root" + }, + "language_info": { + "codemirror_mode": "text/x-c++src", + "file_extension": ".C", + "mimetype": " text/x-c++src", + "name": "c++" + } + }, + "nbformat": 4, + "nbformat_minor": 2 +}