From a9a57d6bff6402c3c59f07a450fa9cdc3d633ed1 Mon Sep 17 00:00:00 2001 From: Maria Ramos <mariayellowd@gmail.com> Date: Sun, 16 May 2021 16:26:16 +0200 Subject: [PATCH] Adding code --- ...hon-13-TeV-framework-script-analysis.ipynb | 174 ++++++++++-------- 1 file changed, 100 insertions(+), 74 deletions(-) diff --git a/ATLAS-Open-Data-Python-13-TeV-framework-script-analysis.ipynb b/ATLAS-Open-Data-Python-13-TeV-framework-script-analysis.ipynb index b613628..7a01e77 100644 --- a/ATLAS-Open-Data-Python-13-TeV-framework-script-analysis.ipynb +++ b/ATLAS-Open-Data-Python-13-TeV-framework-script-analysis.ipynb @@ -51,6 +51,17 @@ "</p>" ] }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# Sugerencia\n", + "# !pip install pandas\n", + "# !pip install matplotlib" + ] + }, { "cell_type": "code", "execution_count": null, @@ -61,7 +72,8 @@ "import datetime\n", "import ROOT\n", "from ROOT import TMath\n", - "import pandas as pd" + "import pandas as pd\n", + "import matplotlib.pyplot as plt" ] }, { @@ -121,8 +133,8 @@ "metadata": {}, "outputs": [], "source": [ - "directory = os.getcwd()\n", - "print(directory)" + "directory0 = os.getcwd()\n", + "print(directory0)" ] }, { @@ -144,7 +156,7 @@ "source": [ "folder_demo = 'atlas-data'\n", "\n", - "if os.path.exists(directory+\"/atlas-data\"):\n", + "if os.path.exists(directory0+\"/atlas-data\"):\n", " print(\"The folder exists\")\n", "else:\n", " command = 'mkdir '+folder_demo\n", @@ -243,8 +255,8 @@ "metadata": {}, "outputs": [], "source": [ - "directory = os.getcwd()\n", - "print(directory)" + "directory1 = os.getcwd()\n", + "print(directory1)" ] }, { @@ -264,7 +276,7 @@ "metadata": {}, "outputs": [], "source": [ - "if os.path.exists(directory+\"/atlas-outreach-cpp-framework-13tev\"):\n", + "if os.path.exists(directory1+\"/atlas-outreach-cpp-framework-13tev\"):\n", " print(\"The repository exists\")\n", "else:\n", " myCmd = os.popen('git clone https://github.com/atlas-outreach-data-tools/atlas-outreach-cpp-framework-13tev.git').read()\n", @@ -358,8 +370,8 @@ "metadata": {}, "outputs": [], "source": [ - "directory = os.getcwd()\n", - "print(directory)" + "directory2 = os.getcwd()\n", + "print(directory2)" ] }, { @@ -386,7 +398,7 @@ "metadata": {}, "outputs": [], "source": [ - "if os.path.exists(directory+\"/Analysis/ZBosonAnalysis/Output_ZBosonAnalysis\"):\n", + "if os.path.exists(directory2+\"/Analysis/ZBosonAnalysis/Output_ZBosonAnalysis\"):\n", " print(\"Folders exists\")\n", "else:\n", " command1 = \"echo \\\"1\\\" | ./welcome.sh\"\n", @@ -425,38 +437,18 @@ }, { "cell_type": "code", - "execution_count": 2, + "execution_count": null, "metadata": {}, "outputs": [], "source": [ - "analysis_df = pd.read_csv(\"notebooks-info/analysis_info.csv\", sep=\"_\").set_index(\"Analysis\")" + "analysis_df = pd.read_csv(f\"{directory0}/notebooks-info/analysis_info.csv\", sep=\"_\").set_index(\"Analysis\")" ] }, { "cell_type": "code", - "execution_count": 3, + "execution_count": null, "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "The options are:\n", - " WBosonAnalysis\n", - " ZBosonAnalysis\n", - " TTbarAnalysis\n", - " SingleTopAnalysis\n", - " WZDiBosonAnalysis\n", - " ZZDiBosonAnalysis\n", - " HZZAnalysis\n", - " HWWAnalysis\n", - " ZTauTauAnalysis\n", - " HyyAnalysis\n", - " SUSYAnalysis\n", - " ZPrimeBoostedAnalysis\n" - ] - } - ], + "outputs": [], "source": [ "print(\"The options are:\\n WBosonAnalysis\\n ZBosonAnalysis\\n TTbarAnalysis\\n SingleTopAnalysis\\n WZDiBosonAnalysis\\n ZZDiBosonAnalysis\\n HZZAnalysis\\n HWWAnalysis\\n ZTauTauAnalysis\\n HyyAnalysis\\n SUSYAnalysis\\n ZPrimeBoostedAnalysis\")" ] @@ -478,17 +470,9 @@ }, { "cell_type": "code", - "execution_count": 6, + "execution_count": null, "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Higgs boson decay in the two-photon final state.\n" - ] - } - ], + "outputs": [], "source": [ "print(analysis_df[\"Description\"].loc[f\"{analysis}\"])" ] @@ -550,6 +534,45 @@ "\n" ] }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "directory3 = os.getcwd()\n", + "print(directory3)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "homedirectory = os.path.expanduser(\"~\")\n", + "print(homedirectory)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "logPath = directory3.replace(f\"{homedirectory}/\", \"\")\n", + "print(logPath)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "print(f\"Copy all of this command:\\ntail -f {logPath}/log\")" + ] + }, { "cell_type": "code", "execution_count": null, @@ -560,6 +583,13 @@ "os.system(command4)" ] }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "If you want, you can paste the command that you just copied to your terminal and see the update of the analysis that you are running on live." + ] + }, { "cell_type": "markdown", "metadata": {}, @@ -697,28 +727,13 @@ "print(myCmd)" ] }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "Show explanation from the ATLAS Open Data 13 TeV Documentation." - ] - }, { "cell_type": "code", - "execution_count": 7, + "execution_count": null, "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "The H → yy decay mode provides a very clear and distinctive signature of two isolated and highly energetic photons, and is one of the main channels studied at the LHC. Despite the small branching ratio, a reasonably large signal yield can be obtained thanks to the high photon reconstruction and identification efficiency at the ATLAS experiment. Furthermore, due to the excellent photon energy resolution of the ATLAS calorimeter, the signal manifests itself as a narrow peak in the diphoton invariant mass spectrum on top of a smoothly falling irreducible background from QCD production of two photons.\n" - ] - } - ], + "outputs": [], "source": [ - "print(analysis_df[\"Explanation\"].loc[f\"{analysis}\"])" + "directory4 = os.getcwd()" ] }, { @@ -727,17 +742,21 @@ "metadata": {}, "outputs": [], "source": [ - "myCmd = os.popen('date').read()\n", - "print(myCmd)\n", - "endtime = datetime.datetime.now()\n", - "print(\"Analysis finished in % 2d min % 2d s\" %(((endtime - starttime).seconds)/60,((endtime - starttime).seconds)%60))" + "files = os.listdir(f\"{directory4}/histograms\")\n", + "for i in files:\n", + " path = f\"{directory4}/histograms/{i}\"\n", + " image = plt.imread(path)\n", + " plt.figure(figsize=(50,30))\n", + " plt.imshow(image)\n", + " plt.axis(\"off\")\n", + " plt.show()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ - "### Done!" + "Show explanation from the ATLAS Open Data 13 TeV Documentation." ] }, { @@ -745,21 +764,28 @@ "execution_count": null, "metadata": {}, "outputs": [], - "source": [] + "source": [ + "print(analysis_df[\"Explanation\"].loc[f\"{analysis}\"])" + ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], - "source": [] + "source": [ + "myCmd = os.popen('date').read()\n", + "print(myCmd)\n", + "endtime = datetime.datetime.now()\n", + "print(\"Analysis finished in % 2d min % 2d s\" %(((endtime - starttime).seconds)/60,((endtime - starttime).seconds)%60))" + ] }, { - "cell_type": "code", - "execution_count": null, + "cell_type": "markdown", "metadata": {}, - "outputs": [], - "source": [] + "source": [ + "### Done!" + ] } ], "metadata": { @@ -778,7 +804,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.7.3" + "version": "3.6.9" } }, "nbformat": 4, -- GitLab