{ "cells": [ { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Welcome to JupyROOT 6.24/00\n" ] } ], "source": [ "import ROOT" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [], "source": [ "#ROOT.ROOT.DisableImplicitMT()\n", "#ROOT.ROOT.EnableImplicitMT(4)" ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "True" ] }, "execution_count": 3, "metadata": {}, "output_type": "execute_result" } ], "source": [ "ROOT.gInterpreter.Declare('#include \"df103_NanoAODHiggsAnalysis_python.h\"')" ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [], "source": [ "def selection_4mu(df):\n", " \"\"\"Select interesting events with four muons\"\"\"\n", " df_ge4m = df.Filter(\"nMuon==4\", \"Exactly four muons\")\n", " \n", " df_kin = df_ge4m.Filter(\"All(Muon_pt>5) && All(abs(Muon_eta)<2.4)\", \"Good muon kinematics\")\n", " df_2p2n = df_kin.Filter(\"Sum(Muon_charge)==0\",\n", " \"Two positive and two negative muons\")\n", " \n", " return df_2p2n\n", "\n", "def filter_z_candidates(df):\n", " \"\"\"Apply selection on reconstructed Z candidates\"\"\"\n", " df_z1_cut = df.Filter(\"Z_mass[0] > 40 && Z_mass[0] < 120\", \"Mass of first Z candidate in [40, 120]\")\n", " df_z2_cut = df_z1_cut.Filter(\"Z_mass[1] > 12 && Z_mass[1] < 120\", \"Mass of second Z candidate in [12, 120]\")\n", " return df_z2_cut\n", "\n", "def reco_higgs_to_4mu(df):\n", " \"\"\"Reconstruct Higgs from four muons\"\"\"\n", " # Filter interesting events\n", " df_base = selection_4mu(df)\n", " \n", " # Reconstruct Z systems\n", " df_z_idx = df_base.Define(\"Z_idx\", \"reco_zz_to_4l(Muon_pt, Muon_eta, Muon_phi, Muon_mass, Muon_charge)\")\n", " \n", " # Cut on distance between muons building Z systems\n", " df_z_dr = df_z_idx.Filter(\"filter_z_dr(Z_idx, Muon_eta, Muon_phi)\", \"Delta R separation of muons building Z system\")\n", " \n", " # Compute masses of Z systems\n", " df_z_mass = df_z_dr.Define(\"Z_mass\", \"compute_z_masses_4l(Z_idx, Muon_pt, Muon_eta, Muon_phi, Muon_mass)\")\n", " \n", " # Cut on mass of Z candidates\n", " df_z_cut = filter_z_candidates(df_z_mass)\n", " \n", " # Reconstruct H mass\n", " df_h_mass = df_z_cut.Define(\"H_mass\", \"compute_higgs_mass_4l(Z_idx, Muon_pt, Muon_eta, Muon_phi, Muon_mass)\")\n", " \n", " return df_h_mass" ] }, { "cell_type": "code", "execution_count": 5, "metadata": {}, "outputs": [], "source": [ "df_bkg_4mu = ROOT.RDataFrame(\"Events\", \"./Run2012BC_DoubleMuParked_Muons.root\")" ] }, { "cell_type": "code", "execution_count": 6, "metadata": {}, "outputs": [], "source": [ "df_bkg_4mu_reco = reco_higgs_to_4mu(df_bkg_4mu)\n", "\n", "df_h_bkg_4mu = df_bkg_4mu_reco.Histo1D((\"h_bkg_4mu\", \"\", 36, 70, 180), \"H_mass\")" ] }, { "cell_type": "code", "execution_count": 7, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "CPU times: user 37.2 s, sys: 502 ms, total: 37.7 s\n", "Wall time: 37.2 s\n" ] }, { "data": { "text/plain": [ "" ] }, "execution_count": 7, "metadata": {}, "output_type": "execute_result" } ], "source": [ "%time df_h_bkg_4mu.GetValue()" ] }, { "cell_type": "code", "execution_count": 8, "metadata": {}, "outputs": [ { "data": { "text/html": [ "\n", "\n", "
\n", "
\n", "\n" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "%jsroot on\n", "C1 = ROOT.TCanvas()\n", "df_h_bkg_4mu.Draw()\n", "C1.Draw()" ] } ], "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.8.6" } }, "nbformat": 4, "nbformat_minor": 5 }