{ "cells": [ { "cell_type": "code", "execution_count": 1, "id": "432e48eb", "metadata": {}, "outputs": [], "source": [ "!pip install awkward pyarrow datasets\n", "import awkward as ak\n", "import pyarrow as pa\n", "# import os\n", "# IF RUNNING LOCALLY AND DEFAULT CACHE IS EXCEEDING STORAGE:\n", "# SPECIFY HERE A VALID CACHE DIRECTORY WITH ENOUGH STORAGE FOR THE DATASETS\n", "# os.environ[\"HF_HOME\"] = \"/path/to/cache\"\n", "from datasets import load_dataset\n" ] }, { "cell_type": "markdown", "id": "2e31fb7f", "metadata": {}, "source": [ "One can download the whole dataset or parts of it using the `load_dataset` function. \n", "Specify the process folder to be inspected using `data_dir` or specify single parquet files using the `data_files` argument.\n", "Without these arguments the whole dataset will be accessible. \n", "Since the dataset is huge, streaming will be necessary to access it." ] }, { "cell_type": "code", "execution_count": 2, "id": "a938312a", "metadata": {}, "outputs": [], "source": [ "# load dataset of one process folder\n", "# if one wants to load the entire dataset, skip the data_dir or data_files argument\n", "dataset = load_dataset(\"fastmachinelearning/collide-1m\", \n", " data_dir=\"WJetsToLNu_13TeV-madgraphMLM-pythia8\",\n", " streaming=True)\n", "dataset = dataset[\"train\"]" ] }, { "cell_type": "markdown", "id": "743e1cbb", "metadata": {}, "source": [ " Here are the different columns that are available in the dataset: " ] }, { "cell_type": "code", "execution_count": 3, "id": "14412cb7", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "FullReco_PFCand_PT\n", "FullReco_PFCand_Eta\n", "FullReco_PFCand_Phi\n", "FullReco_PFCand_PID\n", "FullReco_PFCand_Charge\n", "FullReco_PFCand_Mass\n", "FullReco_PFCand_D0\n", "FullReco_PFCand_DZ\n", "FullReco_PFCand_ErrorD0\n", "FullReco_PFCand_ErrorDZ\n", "FullReco_PFCand_fUniqueID\n", "FullReco_PFCand_PuppiW\n", "FullReco_PUPPIPart_PT\n", "FullReco_PUPPIPart_Eta\n", "FullReco_PUPPIPart_Phi\n", "FullReco_PUPPIPart_Charge\n", "FullReco_PUPPIPart_Mass\n", "FullReco_PUPPIPart_PID\n", "FullReco_PUPPIPart_D0\n", "FullReco_PUPPIPart_DZ\n", "FullReco_PUPPIPart_ErrorD0\n", "FullReco_PUPPIPart_ErrorDZ\n", "FullReco_PUPPIPart_fUniqueID\n", "FullReco_PUPPIPart_PuppiW\n", "FullReco_Electron_PT\n", "FullReco_Electron_Eta\n", "FullReco_Electron_Phi\n", "FullReco_Electron_EhadOverEem\n", "FullReco_Electron_IsolationVarRhoCorr\n", "FullReco_MuonTight_PT\n", "FullReco_MuonTight_Eta\n", "FullReco_MuonTight_Phi\n", "FullReco_MuonTight_IsolationVarRhoCorr\n", "FullReco_PhotonTight_PT\n", "FullReco_PhotonTight_Eta\n", "FullReco_PhotonTight_Phi\n", "FullReco_JetAK4_PT\n", "FullReco_JetAK4_Eta\n", "FullReco_JetAK4_Phi\n", "FullReco_JetAK4_Mass\n", "FullReco_JetAK4_BTag\n", "FullReco_JetAK4_BTagPhys\n", "FullReco_JetAK4_Charge\n", "FullReco_JetAK4_Constituents\n", "FullReco_JetAK8_PT\n", "FullReco_JetAK8_Eta\n", "FullReco_JetAK8_Phi\n", "FullReco_JetAK8_Mass\n", "FullReco_JetAK8_BTag\n", "FullReco_JetAK8_BTagPhys\n", "FullReco_JetAK8_Charge\n", "FullReco_JetPuppiAK4_PT\n", "FullReco_JetPuppiAK4_Eta\n", "FullReco_JetPuppiAK4_Phi\n", "FullReco_JetPuppiAK4_Mass\n", "FullReco_JetPuppiAK4_BTag\n", "FullReco_JetPuppiAK4_BTagPhys\n", "FullReco_JetPuppiAK4_Charge\n", "FullReco_JetPuppiAK4_Constituents\n", "FullReco_JetPuppiAK8_PT\n", "FullReco_JetPuppiAK8_Eta\n", "FullReco_JetPuppiAK8_Phi\n", "FullReco_JetPuppiAK8_Mass\n", "FullReco_JetPuppiAK8_BTag\n", "FullReco_JetPuppiAK8_BTagPhys\n", "FullReco_JetPuppiAK8_Charge\n", "FullReco_MET_MET\n", "FullReco_MET_Phi\n", "FullReco_MET_Eta\n", "FullReco_PUPPIMET_MET\n", "FullReco_PUPPIMET_Phi\n", "FullReco_PUPPIMET_Eta\n", "FullReco_GenMissingET_MET\n", "FullReco_GenMissingET_Eta\n", "FullReco_GenMissingET_Phi\n", "FullReco_GenPart_PT\n", "FullReco_GenPart_Eta\n", "FullReco_GenPart_Phi\n", "FullReco_GenPart_PID\n", "FullReco_GenPart_M1\n", "FullReco_GenPart_M2\n", "FullReco_GenPart_D1\n", "FullReco_GenPart_D2\n", "FullReco_GenPart_Status\n", "FullReco_GenPart_IsPU\n", "FullReco_GenJetAK4_PT\n", "FullReco_GenJetAK4_Eta\n", "FullReco_GenJetAK4_Phi\n", "FullReco_GenJetAK4_Mass\n", "FullReco_GenJetAK8_PT\n", "FullReco_GenJetAK8_Eta\n", "FullReco_GenJetAK8_Phi\n", "FullReco_GenJetAK8_Mass\n", "FullReco_PrimaryVertex_X\n", "FullReco_PrimaryVertex_Y\n", "FullReco_PrimaryVertex_Z\n", "FullReco_PrimaryVertex_T\n", "FullReco_PrimaryVertex_SumPT2\n", "L1T_PFCand_PT\n", "L1T_PFCand_Eta\n", "L1T_PFCand_Phi\n", "L1T_PFCand_PID\n", "L1T_PFCand_Charge\n", "L1T_PFCand_Mass\n", "L1T_PFCand_D0\n", "L1T_PFCand_DZ\n", "L1T_PFCand_ErrorD0\n", "L1T_PFCand_ErrorDZ\n", "L1T_PFCand_fUniqueID\n", "L1T_PFCand_PuppiW\n", "L1T_PUPPIPart_PT\n", "L1T_PUPPIPart_Eta\n", "L1T_PUPPIPart_Phi\n", "L1T_PUPPIPart_Charge\n", "L1T_PUPPIPart_Mass\n", "L1T_PUPPIPart_PID\n", "L1T_PUPPIPart_D0\n", "L1T_PUPPIPart_DZ\n", "L1T_PUPPIPart_ErrorD0\n", "L1T_PUPPIPart_ErrorDZ\n", "L1T_PUPPIPart_fUniqueID\n", "L1T_PUPPIPart_PuppiW\n", "L1T_Electron_PT\n", "L1T_Electron_Eta\n", "L1T_Electron_Phi\n", "L1T_Electron_EhadOverEem\n", "L1T_Electron_IsolationVarRhoCorr\n", "L1T_MuonTight_PT\n", "L1T_MuonTight_Eta\n", "L1T_MuonTight_Phi\n", "L1T_MuonTight_IsolationVarRhoCorr\n", "L1T_PhotonTight_PT\n", "L1T_PhotonTight_Eta\n", "L1T_PhotonTight_Phi\n", "L1T_JetAK4_PT\n", "L1T_JetAK4_Eta\n", "L1T_JetAK4_Phi\n", "L1T_JetAK4_Mass\n", "L1T_JetAK4_BTag\n", "L1T_JetAK4_BTagPhys\n", "L1T_JetAK4_Charge\n", "L1T_JetAK4_Constituents\n", "L1T_JetAK8_PT\n", "L1T_JetAK8_Eta\n", "L1T_JetAK8_Phi\n", "L1T_JetAK8_Mass\n", "L1T_JetAK8_BTag\n", "L1T_JetAK8_BTagPhys\n", "L1T_JetAK8_Charge\n", "L1T_JetPuppiAK4_PT\n", "L1T_JetPuppiAK4_Eta\n", "L1T_JetPuppiAK4_Phi\n", "L1T_JetPuppiAK4_Mass\n", "L1T_JetPuppiAK4_BTag\n", "L1T_JetPuppiAK4_BTagPhys\n", "L1T_JetPuppiAK4_Charge\n", "L1T_JetPuppiAK4_Constituents\n", "L1T_JetPuppiAK8_PT\n", "L1T_JetPuppiAK8_Eta\n", "L1T_JetPuppiAK8_Phi\n", "L1T_JetPuppiAK8_Mass\n", "L1T_JetPuppiAK8_BTag\n", "L1T_JetPuppiAK8_BTagPhys\n", "L1T_JetPuppiAK8_Charge\n", "L1T_MET_MET\n", "L1T_MET_Phi\n", "L1T_MET_Eta\n", "L1T_PUPPIMET_MET\n", "L1T_PUPPIMET_Phi\n", "L1T_PUPPIMET_Eta\n" ] } ], "source": [ "cols = list(dataset.features.keys())\n", "for c in cols:\n", " print(c)" ] }, { "cell_type": "markdown", "id": "3f48be1e", "metadata": {}, "source": [ " The dataset will have one row for each event, one can access the respective next row by calling `row=next(iter(dataset))`. Once a row is loaded, one can easily access the respective features using `row['feature']`, where 'feature' is any of the above listed columns. Loading multiple rows at once might lead to memory issues. " ] }, { "cell_type": "code", "execution_count": 4, "id": "adb5ae4d", "metadata": {}, "outputs": [], "source": [ "row1 = next(iter(dataset))" ] }, { "cell_type": "code", "execution_count": 16, "id": "869dccac", "metadata": {}, "outputs": [ { "data": { "text/html": [ "
[0.291,\n",
       " 0.226,\n",
       " 0.454,\n",
       " 0.468,\n",
       " 0.412,\n",
       " 0.22,\n",
       " 0.755,\n",
       " 0.963,\n",
       " 0.484,\n",
       " 0.814,\n",
       " ...,\n",
       " 5.42,\n",
       " 0.735,\n",
       " 2.6,\n",
       " 1.99,\n",
       " 2.98,\n",
       " 2.21,\n",
       " 3.04,\n",
       " 1.14,\n",
       " 3.48]\n",
       "--------------------\n",
       "backend: cpu\n",
       "nbytes: 34.5 kB\n",
       "type: 4318 * float64
" ], "text/plain": [ "" ] }, "execution_count": 16, "metadata": {}, "output_type": "execute_result" } ], "source": [ "example_arr = ak.Array(row1['FullReco_PFCand_PT'])\n", "example_arr" ] }, { "cell_type": "code", "execution_count": 17, "id": "9efa96de", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "ArrayType(NumpyType('float64'), 4318, None)" ] }, "execution_count": 17, "metadata": {}, "output_type": "execute_result" } ], "source": [ "example_arr.type" ] }, { "cell_type": "markdown", "id": "7e6369c9", "metadata": {}, "source": [ " Once the data is saved in an array in this way, all the usual awkward array operations can be applied. " ] }, { "cell_type": "markdown", "id": "29f6f3d6", "metadata": {}, "source": [ " To access a specific row, one can use the following `get_row_by_index` function. " ] }, { "cell_type": "code", "execution_count": 18, "id": "64a97872", "metadata": {}, "outputs": [], "source": [ "def get_row_by_index(dataset, target_index):\n", " for i, row in enumerate(dataset):\n", " if i == target_index:\n", " return row\n", " return None" ] }, { "cell_type": "code", "execution_count": 19, "id": "0b5da1cc", "metadata": {}, "outputs": [], "source": [ "row100 = get_row_by_index(dataset, 100)" ] }, { "cell_type": "code", "execution_count": 22, "id": "30afc6bc", "metadata": {}, "outputs": [ { "data": { "text/html": [ "
[1.47,\n",
       " 1.01,\n",
       " 1.14,\n",
       " 0.894,\n",
       " 0.905,\n",
       " 0.647,\n",
       " 1.15,\n",
       " 0.616,\n",
       " 0.736,\n",
       " 0.521,\n",
       " ...,\n",
       " 1.26,\n",
       " 2.95,\n",
       " 6.43,\n",
       " 1.82,\n",
       " 1.76,\n",
       " 2.72,\n",
       " 2.86,\n",
       " 1.29,\n",
       " 0.773]\n",
       "--------------------\n",
       "backend: cpu\n",
       "nbytes: 29.7 kB\n",
       "type: 3709 * float64
" ], "text/plain": [ "" ] }, "execution_count": 22, "metadata": {}, "output_type": "execute_result" } ], "source": [ "example_arr100 = ak.Array(row100['FullReco_PFCand_PT'])\n", "example_arr100" ] }, { "cell_type": "code", "execution_count": 23, "id": "8ffdc8ed", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "ArrayType(NumpyType('float64'), 3709, None)" ] }, "execution_count": 23, "metadata": {}, "output_type": "execute_result" } ], "source": [ "example_arr100.type" ] }, { "cell_type": "markdown", "id": "b7002061", "metadata": {}, "source": [ " We hope you enjoy looking through this preliminary dataset and aim to have the full dataset uploaded soon. If you have any questions or suggestions please let us know at emoreno@mit.edu or plonerp@ethz.ch ." ] } ], "metadata": { "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.9.21" } }, "nbformat": 4, "nbformat_minor": 5 }