{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "## Event file Header information ##\n", "\n", "Header information is stored internally in aanet, in a class called Head,\n", "in a way that derives directly from the ascii (.evt) event files. The EventFile \n", "class loads the header automatically from the event file:" ] }, { "cell_type": "code", "execution_count": 7, "metadata": { "collapsed": false }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "\n", "start_run: 1\n", "PDF: 4 58\n", "XSecFile: \n", "can: -479.9 545.21 1327.95\n", "coord_origin: 0 0 479.9 \n", "cut_in: 0 0 0 0\n", "cut_nu: 100 1e+07 -1 1\n", "cut_primary: 0 0 0 0\n", "cut_seamuon: 0 0 0 0\n", "detector: /pi1/data/shanidze/km3net/TDR/DETECTORS/km3net_wpd_V2.det\n", "drawing: Volume\n", "genhencut: 3000 0\n", "genvol: -22772.9 3161.5 26837.2 5.868e+13 2e+08\n", "kcut: 2\n", "livetime: 0 0\n", "model: 1 2 1 1 10\n", "muon_desc_file: \n", "norma: 0 0\n", "nuflux: 0 2 0 0.500E+00 0.000E+00 0.200E+01 0.800E+01\n", "physics: GENHEN 5.02-280602 110117 1754\n", "seed: GENHEN 3 1000 309408948 0\n", "simul: \n", "spectrum: -1.4\n", "target: isoscalar\n", "end_event:\n", "\n", "ttt 0x9bb1890\r\n", " EventFile io / wall time = 0.095469 / 68553.3 (0.000139262 % spent on io.)\r\n" ] } ], "source": [ "import ROOT\n", "import aa\n", "f = EventFile(\"../evtfiles/numu_jgandalf.root\")\n", "print type(f.header)\n", "print f.header \n", " " ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "You can access each line, like so (the result is always a string)" ] }, { "cell_type": "code", "execution_count": 3, "metadata": { "collapsed": false, "scrolled": true }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ " /pi1/data/shanidze/km3net/TDR/DETECTORS/km3net_wpd_V2.det\n" ] } ], "source": [ "print f.header.get_line(\"detector\")" ] }, { "cell_type": "markdown", "metadata": { "collapsed": true }, "source": [ "Some lines in the header have multiple, space separated, fields. For example, the genvol tag lists four \n", "numbers:\n", "(see http://pi1241.physik.uni-erlangen.de:8080/job/aanet_trunk/doxygen/Head_8hh_source.html#l00189\n", "for a list of field names that aanet knows about). You get the line genvol and parse the full line, or use the get_field method to get the number you need by name. In both cases, converting to a float is up to you." ] }, { "cell_type": "code", "execution_count": 9, "metadata": { "collapsed": false }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ " -22772.9 3161.5 26837.2 5.868e+13 2e+08\n", "200000000.0\n", "200000000.0\n" ] } ], "source": [ "print f.header.get_line(\"genvol\")\n", "\n", "print float( f.header.get_line(\"genvol\").split()[4] ) # numberofEvents is 4th number\n", "\n", "print float( f.header.get_field(\"genvol\",\"numberOfEvents\") )" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true }, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "Python 2", "language": "python", "name": "python2" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 2 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython2", "version": "2.7.6" } }, "nbformat": 4, "nbformat_minor": 0 }