From e734256a67136b442ba4b9ac43479d06662a3243 Mon Sep 17 00:00:00 2001 From: cetin Date: Mon, 25 Sep 2023 10:22:31 +0200 Subject: [PATCH] K pi tasks --- B_Kpi_tasks.ipynb | 292 ++++++++++++++++++++++++++++++++++++++++++++++ B_tasks.ipynb | 292 +++++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 580 insertions(+), 4 deletions(-) create mode 100644 B_Kpi_tasks.ipynb diff --git a/B_Kpi_tasks.ipynb b/B_Kpi_tasks.ipynb new file mode 100644 index 0000000..485f449 --- /dev/null +++ b/B_Kpi_tasks.ipynb @@ -0,0 +1,292 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": 1, + "metadata": {}, + "outputs": [], + "source": [ + "import uproot\n", + "import numpy as np\n", + "import sys\n", + "import os\n", + "import matplotlib\n", + "import matplotlib.pyplot as plt\n", + "from mpl_toolkits import mplot3d\n", + "import itertools\n", + "import awkward as ak\n", + "from scipy.optimize import curve_fit\n", + "%matplotlib inline" + ] + }, + { + "cell_type": "code", + "execution_count": 5, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "9389" + ] + }, + "execution_count": 5, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "file = uproot.open(\"tracking_losses_ntuple_Bd2KstEE.root:PrDebugTrackingLosses.PrDebugTrackingTool/Tuple;1\")\n", + "\n", + "\n", + "\n", + "#selektiere Kaonen und Pionen aus K*->Kpi - B->K*ee - und nur solche mit einem momentum von ueber 5 GeV \n", + "allcolumns = file.arrays()\n", + "found = allcolumns[((allcolumns.isKaon) | (allcolumns.isPion)) & (~allcolumns.lost) & (allcolumns.fromSignal)] #B:\n", + "lost = allcolumns[((allcolumns.isKaon) | (allcolumns.isPion)) & (allcolumns.lost) & (allcolumns.fromSignal)] #B:\n", + "\n", + "ak.num(found, axis=0)\n", + "#ak.count(found, axis=None)\n" + ] + }, + { + "cell_type": "code", + "execution_count": 6, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "0.9191385217816936" + ] + }, + "execution_count": 6, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "def t_eff(found, lost):\n", + " sel = found[\"energy\"]\n", + " des = lost[\"energy\"]\n", + " return ak.count(sel,axis=None)/(ak.count(sel,axis=None)+ak.count(des,axis=None))\n", + "\n", + "t_eff(found, lost)" + ] + }, + { + "cell_type": "code", + "execution_count": 7, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "{'all_endvtx_types_length': 2,\n", + " 'all_endvtx_types': [104.0, 100.0],\n", + " 'all_endvtx_x_length': 2,\n", + " 'all_endvtx_x': [-122.56659698486328, -262.1983947753906],\n", + " 'all_endvtx_y_length': 2,\n", + " 'all_endvtx_y': [-369.7253112792969, -555.62890625],\n", + " 'all_endvtx_z_length': 2,\n", + " 'all_endvtx_z': [7985.064453125, 11955.3134765625],\n", + " 'brem_photons_pe_length': 0,\n", + " 'brem_photons_pe': [],\n", + " 'brem_photons_px_length': 0,\n", + " 'brem_photons_px': [],\n", + " 'brem_photons_py_length': 0,\n", + " 'brem_photons_py': [],\n", + " 'brem_photons_pz_length': 0,\n", + " 'brem_photons_pz': [],\n", + " 'brem_vtx_x_length': 0,\n", + " 'brem_vtx_x': [],\n", + " 'brem_vtx_y_length': 0,\n", + " 'brem_vtx_y': [],\n", + " 'brem_vtx_z_length': 0,\n", + " 'brem_vtx_z': [],\n", + " 'endvtx_type': 0,\n", + " 'endvtx_x': nan,\n", + " 'endvtx_y': nan,\n", + " 'endvtx_z': nan,\n", + " 'energy': 41648.0685636534,\n", + " 'eta': 3.7532544452852883,\n", + " 'event_count': 0,\n", + " 'fromB': True,\n", + " 'fromD': False,\n", + " 'fromDecay': True,\n", + " 'fromHadInt': False,\n", + " 'fromPV': False,\n", + " 'fromPairProd': False,\n", + " 'fromSignal': True,\n", + " 'fromStrange': False,\n", + " 'isElectron': False,\n", + " 'isKaon': True,\n", + " 'isMuon': False,\n", + " 'isPion': False,\n", + " 'isProton': False,\n", + " 'lost': False,\n", + " 'lost_in_track_fit': False,\n", + " 'match_fraction': 1.0,\n", + " 'mcp_idx': 2236,\n", + " 'mother_id': 313,\n", + " 'mother_key': 226,\n", + " 'originvtx_type': 2,\n", + " 'originvtx_x': -0.1652,\n", + " 'originvtx_y': -0.2848,\n", + " 'originvtx_z': 81.7996,\n", + " 'p': 41645.1425510635,\n", + " 'phi': -1.6798078520364383,\n", + " 'pid': 321,\n", + " 'pt': 1951.3630462832896,\n", + " 'px': -212.3,\n", + " 'py': -1939.78,\n", + " 'pz': 41599.4,\n", + " 'scifi_hit_pos_x_length': 12,\n", + " 'scifi_hit_pos_x': [-117.21600341796875,\n", + " -119.53988647460938,\n", + " -121.886474609375,\n", + " -124.23180389404297,\n", + " -140.34219360351562,\n", + " -142.7511749267578,\n", + " -145.18153381347656,\n", + " -147.6049041748047,\n", + " -164.2061004638672,\n", + " -166.65792846679688,\n", + " -169.12484741210938,\n", + " -171.5793914794922],\n", + " 'scifi_hit_pos_y_length': 12,\n", + " 'scifi_hit_pos_y': [-362.2366638183594,\n", + " -365.4982604980469,\n", + " -368.7768859863281,\n", + " -372.0390930175781,\n", + " -394.123291015625,\n", + " -397.38812255859375,\n", + " -400.67279052734375,\n", + " -403.93994140625,\n", + " -426.20166015625,\n", + " -429.4697265625,\n", + " -432.75665283203125,\n", + " -436.0249328613281],\n", + " 'scifi_hit_pos_z_length': 12,\n", + " 'scifi_hit_pos_z': [7824.794921875,\n", + " 7894.58349609375,\n", + " 7964.7724609375,\n", + " 8034.56103515625,\n", + " 8506.6796875,\n", + " 8576.46875,\n", + " 8646.6572265625,\n", + " 8716.4462890625,\n", + " 9191.564453125,\n", + " 9261.353515625,\n", + " 9331.5419921875,\n", + " 9401.3310546875],\n", + " 'track_p': 41440.5786745683,\n", + " 'track_pt': 1942.8720147111794,\n", + " 'tx': -0.005103438991908537,\n", + " 'ty': -0.04662999947114622,\n", + " 'ut_hit_pos_x_length': 4,\n", + " 'ut_hit_pos_x': [-12.01840877532959,\n", + " -12.332009315490723,\n", + " -13.623125076293945,\n", + " -13.947733879089355],\n", + " 'ut_hit_pos_y_length': 4,\n", + " 'ut_hit_pos_y': [-104.15756225585938,\n", + " -106.72476959228516,\n", + " -117.23506927490234,\n", + " -119.80697631835938],\n", + " 'ut_hit_pos_z_length': 4,\n", + " 'ut_hit_pos_z': [2306.846435546875,\n", + " 2361.846435546875,\n", + " 2586.846435546875,\n", + " 2641.846435546875],\n", + " 'velo_hit_pos_x_length': 11,\n", + " 'velo_hit_pos_x': [-0.8300145268440247,\n", + " -0.9588174819946289,\n", + " -1.0876154899597168,\n", + " -1.345718502998352,\n", + " -1.7327179908752441,\n", + " -2.252721071243286,\n", + " -2.775723934173584,\n", + " -2.782417058944702,\n", + " -3.040213108062744,\n", + " -3.2965149879455566,\n", + " -3.554213047027588],\n", + " 'velo_hit_pos_y_length': 11,\n", + " 'velo_hit_pos_y': [-6.3489580154418945,\n", + " -7.5135650634765625,\n", + " -8.679963111877441,\n", + " -11.012066841125488,\n", + " -14.511466026306152,\n", + " -19.179668426513672,\n", + " -23.845666885375977,\n", + " -23.90557098388672,\n", + " -26.240373611450195,\n", + " -28.577774047851562,\n", + " -30.914676666259766],\n", + " 'velo_hit_pos_z_length': 11,\n", + " 'velo_hit_pos_z': [211.85899353027344,\n", + " 236.85899353027344,\n", + " 261.8590087890625,\n", + " 311.8590087890625,\n", + " 386.8590087890625,\n", + " 486.8590087890625,\n", + " 586.8590087890625,\n", + " 588.1409912109375,\n", + " 638.1409912109375,\n", + " 688.1409912109375,\n", + " 738.1409912109375],\n", + " 'velo_track_idx': 37,\n", + " 'velo_track_tx': -0.005120465997606516,\n", + " 'velo_track_ty': -0.04670485854148865,\n", + " 'velo_track_x': -3.7022032737731934,\n", + " 'velo_track_y': -32.40621566772461,\n", + " 'velo_track_z': 770.0}" + ] + }, + "execution_count": 7, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "found[0].tolist()" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] + } + ], + "metadata": { + "kernelspec": { + "display_name": "env1", + "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.11.5" + }, + "orig_nbformat": 4 + }, + "nbformat": 4, + "nbformat_minor": 2 +} diff --git a/B_tasks.ipynb b/B_tasks.ipynb index 74025b8..a798041 100644 --- a/B_tasks.ipynb +++ b/B_tasks.ipynb @@ -154,7 +154,7 @@ }, { "cell_type": "code", - "execution_count": 17, + "execution_count": 7, "metadata": {}, "outputs": [ { @@ -481,10 +481,294 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 25, "metadata": {}, - "outputs": [], - "source": [] + "outputs": [ + { + "data": { + "text/plain": [ + "{'all_endvtx_types_length': 12,\n", + " 'all_endvtx_types': [101.0,\n", + " 101.0,\n", + " 101.0,\n", + " 101.0,\n", + " 104.0,\n", + " 101.0,\n", + " 101.0,\n", + " 101.0,\n", + " 101.0,\n", + " 101.0,\n", + " 101.0,\n", + " 110.0],\n", + " 'all_endvtx_x_length': 12,\n", + " 'all_endvtx_x': [-3.31820011138916,\n", + " -3.4500999450683594,\n", + " -20.166799545288086,\n", + " -120.83049774169922,\n", + " -150.31619262695312,\n", + " -155.7082977294922,\n", + " -187.58470153808594,\n", + " -195.8394012451172,\n", + " -196.60830688476562,\n", + " -196.72889709472656,\n", + " -197.48280334472656,\n", + " -202.9868927001953],\n", + " 'all_endvtx_y_length': 12,\n", + " 'all_endvtx_y': [-4.850500106811523,\n", + " -5.047299861907959,\n", + " -29.993200302124023,\n", + " -196.2998046875,\n", + " -270.5392150878906,\n", + " -285.7712097167969,\n", + " -380.3049011230469,\n", + " -405.302490234375,\n", + " -407.66009521484375,\n", + " -408.0318908691406,\n", + " -410.36138916015625,\n", + " -434.51611328125],\n", + " 'all_endvtx_z_length': 12,\n", + " 'all_endvtx_z': [184.35940551757812,\n", + " 190.19970703125,\n", + " 929.2517700195312,\n", + " 5855.25390625,\n", + " 8055.12451171875,\n", + " 8506.958984375,\n", + " 11310.3232421875,\n", + " 12051.8232421875,\n", + " 12121.9033203125,\n", + " 12132.9287109375,\n", + " 12201.8427734375,\n", + " 12703.953125],\n", + " 'brem_photons_pe_length': 10,\n", + " 'brem_photons_pe': [1881.1756591796875,\n", + " 17914.712890625,\n", + " 479.9449768066406,\n", + " 3987.47119140625,\n", + " 4792.82421875,\n", + " 19725.302734375,\n", + " 2376.974853515625,\n", + " 6870.6201171875,\n", + " 19237.05859375,\n", + " 3409.642822265625],\n", + " 'brem_photons_px_length': 10,\n", + " 'brem_photons_px': [-42.470001220703125,\n", + " -404.0400085449219,\n", + " -10.8100004196167,\n", + " -61.459999084472656,\n", + " -56.58000183105469,\n", + " -220.60000610351562,\n", + " -26.079999923706055,\n", + " -75.06999969482422,\n", + " -210.25999450683594,\n", + " -37.400001525878906],\n", + " 'brem_photons_py_length': 10,\n", + " 'brem_photons_py': [-63.31999969482422,\n", + " -603.0599975585938,\n", + " -16.190000534057617,\n", + " -134.4499969482422,\n", + " -161.4499969482422,\n", + " -664.5800170898438,\n", + " -79.8499984741211,\n", + " -231.4499969482422,\n", + " -648.0399780273438,\n", + " -115.2300033569336],\n", + " 'brem_photons_pz_length': 10,\n", + " 'brem_photons_pz': [1879.6300048828125,\n", + " 17900.0,\n", + " 479.54998779296875,\n", + " 3984.72998046875,\n", + " 4789.77001953125,\n", + " 19712.869140625,\n", + " 2375.489990234375,\n", + " 6866.31005859375,\n", + " 19224.990234375,\n", + " 3407.489990234375],\n", + " 'brem_vtx_x_length': 10,\n", + " 'brem_vtx_x': [-3.31820011138916,\n", + " -3.4500999450683594,\n", + " -20.166799545288086,\n", + " -120.83049774169922,\n", + " -155.7082977294922,\n", + " -187.58470153808594,\n", + " -195.8394012451172,\n", + " -196.60830688476562,\n", + " -196.72889709472656,\n", + " -197.48280334472656],\n", + " 'brem_vtx_y_length': 10,\n", + " 'brem_vtx_y': [-4.850500106811523,\n", + " -5.047299861907959,\n", + " -29.993200302124023,\n", + " -196.2998046875,\n", + " -285.7712097167969,\n", + " -380.3049011230469,\n", + " -405.302490234375,\n", + " -407.66009521484375,\n", + " -408.0318908691406,\n", + " -410.36138916015625],\n", + " 'brem_vtx_z_length': 10,\n", + " 'brem_vtx_z': [184.35940551757812,\n", + " 190.19970703125,\n", + " 929.2517700195312,\n", + " 5855.25390625,\n", + " 8506.958984375,\n", + " 11310.3232421875,\n", + " 12051.8232421875,\n", + " 12121.9033203125,\n", + " 12132.9287109375,\n", + " 12201.8427734375],\n", + " 'endvtx_type': 0,\n", + " 'endvtx_x': nan,\n", + " 'endvtx_y': nan,\n", + " 'endvtx_z': nan,\n", + " 'energy': 134321.90632702777,\n", + " 'eta': 3.8988255511590677,\n", + " 'event_count': 2,\n", + " 'fromB': True,\n", + " 'fromD': False,\n", + " 'fromDecay': True,\n", + " 'fromHadInt': False,\n", + " 'fromPV': False,\n", + " 'fromPairProd': False,\n", + " 'fromSignal': True,\n", + " 'fromStrange': False,\n", + " 'isElectron': True,\n", + " 'isKaon': False,\n", + " 'isMuon': False,\n", + " 'isPion': False,\n", + " 'isProton': False,\n", + " 'lost': False,\n", + " 'lost_in_track_fit': False,\n", + " 'match_fraction': 1.0,\n", + " 'mcp_idx': 5524,\n", + " 'mother_id': 511,\n", + " 'mother_key': 5479,\n", + " 'originvtx_type': 2,\n", + " 'originvtx_x': -0.0663,\n", + " 'originvtx_y': -0.0023,\n", + " 'originvtx_z': 40.3966,\n", + " 'p': 134321.90632605576,\n", + " 'phi': -2.1616595746843887,\n", + " 'pid': 11,\n", + " 'pt': 5442.019481892728,\n", + " 'px': -3031.63,\n", + " 'py': -4519.38,\n", + " 'pz': 134211.62,\n", + " 'scifi_hit_pos_x_length': 13,\n", + " 'scifi_hit_pos_x': [-147.52284240722656,\n", + " -148.3743133544922,\n", + " -149.227783203125,\n", + " -150.07235717773438,\n", + " -155.70518493652344,\n", + " -155.71279907226562,\n", + " -156.53173828125,\n", + " -157.3567352294922,\n", + " -158.170166015625,\n", + " -163.65866088867188,\n", + " -164.45834350585938,\n", + " -165.2606201171875,\n", + " -166.0580291748047],\n", + " 'scifi_hit_pos_y_length': 13,\n", + " 'scifi_hit_pos_y': [-262.7794494628906,\n", + " -265.13543701171875,\n", + " -267.5039367675781,\n", + " -269.8581237792969,\n", + " -285.7621765136719,\n", + " -285.7840270996094,\n", + " -288.1278991699219,\n", + " -290.49371337890625,\n", + " -292.84771728515625,\n", + " -308.8764343261719,\n", + " -311.22991943359375,\n", + " -313.5960998535156,\n", + " -315.9485168457031],\n", + " 'scifi_hit_pos_z_length': 13,\n", + " 'scifi_hit_pos_z': [7825.15283203125,\n", + " 7894.94482421875,\n", + " 7965.13671875,\n", + " 8034.9287109375,\n", + " 8506.689453125,\n", + " 8507.3388671875,\n", + " 8576.8623046875,\n", + " 8647.0537109375,\n", + " 8716.845703125,\n", + " 9191.9873046875,\n", + " 9261.779296875,\n", + " 9331.970703125,\n", + " 9401.7626953125],\n", + " 'track_p': 111183.03747794438,\n", + " 'track_pt': 4503.0812830108725,\n", + " 'tx': -0.022588431612702388,\n", + " 'ty': -0.03367353735838968,\n", + " 'ut_hit_pos_x_length': 4,\n", + " 'ut_hit_pos_x': [-51.275360107421875,\n", + " -52.504058837890625,\n", + " -57.51994705200195,\n", + " -58.743045806884766],\n", + " 'ut_hit_pos_y_length': 4,\n", + " 'ut_hit_pos_y': [-76.70736694335938,\n", + " -78.56417083740234,\n", + " -86.16027069091797,\n", + " -88.01727294921875],\n", + " 'ut_hit_pos_z_length': 4,\n", + " 'ut_hit_pos_z': [2313.153564453125,\n", + " 2368.153564453125,\n", + " 2593.153564453125,\n", + " 2648.153564453125],\n", + " 'velo_hit_pos_x_length': 12,\n", + " 'velo_hit_pos_x': [-2.809859037399292,\n", + " -3.374659538269043,\n", + " -3.9390575885772705,\n", + " -4.503256320953369,\n", + " -5.067859172821045,\n", + " -6.197760581970215,\n", + " -7.8953633308410645,\n", + " -10.159163475036621,\n", + " -12.452364921569824,\n", + " -13.584664344787598,\n", + " -14.716963768005371,\n", + " -15.848661422729492],\n", + " 'velo_hit_pos_y_length': 12,\n", + " 'velo_hit_pos_y': [-4.092668056488037,\n", + " -4.934769153594971,\n", + " -5.776969909667969,\n", + " -6.6197710037231445,\n", + " -7.463074207305908,\n", + " -9.150375366210938,\n", + " -11.682275772094727,\n", + " -15.058876037597656,\n", + " -18.47857666015625,\n", + " -20.166975021362305,\n", + " -21.85477638244629,\n", + " -23.543376922607422],\n", + " 'velo_hit_pos_z_length': 12,\n", + " 'velo_hit_pos_z': [161.85899353027344,\n", + " 186.85899353027344,\n", + " 211.85899353027344,\n", + " 236.85899353027344,\n", + " 261.8590087890625,\n", + " 311.8590087890625,\n", + " 386.8590087890625,\n", + " 486.8590087890625,\n", + " 588.1409912109375,\n", + " 638.1409912109375,\n", + " 688.1409912109375,\n", + " 738.1409912109375],\n", + " 'velo_track_idx': 90,\n", + " 'velo_track_tx': -0.022649554535746574,\n", + " 'velo_track_ty': -0.033734168857336044,\n", + " 'velo_track_x': -16.569623947143555,\n", + " 'velo_track_y': -24.62316131591797,\n", + " 'velo_track_z': 770.0}" + ] + }, + "execution_count": 25, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "\n" + ] }, { "cell_type": "code",