{"metadata":{"kernelspec":{"language":"python","display_name":"Python 3","name":"python3"},"language_info":{"pygments_lexer":"ipython3","nbconvert_exporter":"python","version":"3.6.4","file_extension":".py","codemirror_mode":{"name":"ipython","version":3},"name":"python","mimetype":"text/x-python"},"kaggle":{"accelerator":"none","dataSources":[{"sourceId":81378,"databundleVersionId":8859157,"sourceType":"competition"}],"isInternetEnabled":true,"language":"python","sourceType":"notebook","isGpuEnabled":false}},"nbformat_minor":4,"nbformat":4,"cells":[{"cell_type":"code","source":"# This Python 3 environment comes with many helpful analytics libraries installed\n# It is defined by the kaggle/python Docker image: https://github.com/kaggle/docker-python\n# For example, here's several helpful packages to load\n\nimport numpy as np # linear algebra\nimport pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)\n\n# Input data files are available in the read-only \"../input/\" directory\n# For example, running this (by clicking run or pressing Shift+Enter) will list all files under the input directory\n\nimport os\nfor dirname, _, filenames in os.walk('/kaggle/input'):\n    for filename in filenames:\n        print(os.path.join(dirname, filename))\n\n# You can write up to 20GB to the current directory (/kaggle/working/) that gets preserved as output when you create a version using \"Save & Run All\" \n# You can also write temporary files to /kaggle/temp/, but they won't be saved outside of the current session","metadata":{"_uuid":"8f2839f25d086af736a60e9eeb907d3b93b6e0e5","_cell_guid":"b1076dfc-b9ad-4769-8c92-a6c4dae69d19","trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"import basf2 as b2\nimport modularAnalysis as ma\nfrom variables import variables as vm\nimport variables.collections as vc\nimport variables.utils as vu\nimport vertex as vx\n\nb2.B2INFO(f\"Appending analysis GT: {ma.getAnalysisGlobaltag()}\")\nb2.conditions.append_globaltag(ma.getAnalysisGlobaltag())\n\n# Define the path\nmain_path = b2.Path()\n\ninput_file = '/group/belle2/users2022/purwar/B2Dslnu/dataFiles/B2Dslnu_SM_100k_wBkg.root'\n#'/group/belle2/users2022/purwar/b2sw2024/B2Dsenu_SM_100k.root'\noutput_file = 'Dstellnu_fsp.root'\n\nma.inputMdstList(filelist=input_file, path=main_path)\n\n########## Tracks and Clusters ###########\n\n# remove very low momentum track with p>0.2\ngoodTrack = '[p>0.2] and [abs(dz)<4] and [dr<2] and thetaInCDCAcceptance and [nCDCHits>20]'\n\n\n########## Final State Particles ###########\nma.fillParticleList('pi+:AllGoodTracks', cut=goodTrack, path=main_path)\n\n\n########### MC Truth Matching ##########\nma.matchMCTruth('pi+:AllGoodTracks', path=main_path)\n\n\n########## Save Ntuples ##########\n\nlabel = ['mcPDG']\ntrackVars = ['dr','dz','theta','nCDCHits','chiProb']\nkinematicVars = ['M','dM','pt','E','p','px','py','pz']\n\nvm.addAlias('eID_CDC', 'pidProbabilityExpert(11,CDC)')\nvm.addAlias('eID_TOP', 'pidProbabilityExpert(11,TOP)')\nvm.addAlias('eID_ARICH', 'pidProbabilityExpert(11,ARICH)')\n\nvm.addAlias('muID_CDC', 'pidProbabilityExpert(13,CDC)')\nvm.addAlias('muID_TOP', 'pidProbabilityExpert(13,TOP)')\nvm.addAlias('muID_ARICH', 'pidProbabilityExpert(13,ARICH)')\nvm.addAlias('muID_KLM', 'pidProbabilityExpert(13,KLM)')\n\nPID_trainingVars = [\"clusterEoP\", \"clusterE1E9\", \"clusterE9E21\", \"clusterLAT\", \n                    \"clusterAbsZernikeMoment40\", \"clusterAbsZernikeMoment51\", \n                    \"clusterZernikeMVA\", \"clusterDeltaLTemp\", \n                    \"clusterPulseShapeDiscriminationMVA\", \n                    'eID_CDC', 'eID_TOP', 'eID_ARICH',\n                    'muID_CDC', 'muID_TOP', 'muID_ARICH', 'muID_KLM']\n\noutput_vars = label + ['Ecms'] + trackVars + kinematicVars + PID_trainingVars\n\nma.variablesToNtuple('pi+:AllGoodTracks', output_vars, useFloat=True,\n                     filename=output_file, treename='fsp', path=main_path)\n\nb2.process(path=main_path)\n","metadata":{},"execution_count":null,"outputs":[]}]}