(variables-root)= # Example experiment n-tuple **(10 minutes)** I've created a sample ROOT n-tuple for you. Quit ROOT. Copy the example file: > cp ~seligman/root-class/experiment.root $PWD Start ROOT again. Start a new browser with the command [] TBrowser b Click on the folder in the left-hand pane with the same name as your home directory. Double-click on {file}`experiment.root`. There's just one object inside: `tree1`, a ROOT TTree (or n-tuple) with 100,000 simulated physics events. :::{tip} There's no real physics associated with the contents of this n-tuple. I created it to illustrate ROOT concepts, not to demonstrate physics with a real detector. ::: Right-click on the {guilabel}`tree1` icon, and select {guilabel}`Scan`. You'll be presented with a dialog box; just hit `OK` for now. Select your ROOT window, even though the dialog box didn't go away. At first you'll notice that it's a lot of numbers. Take a look at near the top of the screen; you should see the names of the variables in this ROOT Tree.[^f37] You can hit Enter to see more numbers, but you probably won't learn much. Hit `q` to finish the scan. You may have to hit Enter a couple of times to see the ROOT prompt again. :::{admonition} What the variables mean :class: note Let's break down this simple example: - A particle is traveling in a positive direction along the z-axis with energy `ebeam`. - It hits a target at z=0, and travels a distance `zv` before it is deflected by the material of the target. - The particle's new trajectory is represented by `px`, `py`, and `pz`, the final momenta in the x-, y-, and z-directions respectively. - The variable `chi2` ($\chi^2$) represents a confidence level in the measurement of the particle's momentum after deflection. - The variable `event` is just the event number (0 for the first event, 1 for the second event, 2 for the third event\... 99999 for the 100,000th event). ::: :::{figure-md} experiment-fig :class: align-center experiment sketch Sketch of the experiment and variables. ::: :::{admonition} What's missing Did you notice what's missing from the above description? Answer: units. For example, I didn't tell you whether `zv` is in millimeters, inches, yards, furlongs, etc. Such information is not usually stored inside an n-tuple; you have to find out what it is and include the units in the labels of the plots you create.[^f38] For `tree1` in {file}`experiment.root`, assume that `zv` is in centimeters (*cm*), and all energies and momenta are in *GeV*. There's something else that's missing, but you wouldn't have noticed it unless you've performed a scientific analysis before: time. Any real experiment would have several variables relating to time (the time of the event, the time that the particle interacted in the detector, etc.) I haven't included any time-related variables in this n-tuple, with the possible exception of the event number, mainly because they wouldn't illustrate what I want to teach you in this tutorial. ::: :::{figure-md} dimensions-fig :class: align-center xkcd dimensions by Randall Munroe ::: [^f37]: If the names "stutter" (e.g., you see `px.px` instead of just `px`), don't be concerned. The name of the package is ROOT, an n-tuple is a type of Tree, and the individual variables are {dfn}`leaves` on the Tree. ROOT has {dfn}`branches` as well: if you remember that spreadsheet model I showed you during the lecture, branches correspond to entire columns. In the scan, ROOT displays both the name of the branch and the name of the leaf within the branch. For an n-tuple, each branch only has one leaf, but `TTree::Scan()` has no way of knowing that, so it displays everything. [^f38]: *Advanced note:* There is a way of storing comments about the contents of a ROOT tree, which can include information such as units. However, you can't do this with n-tuples; you have to create a C++ class that contains your information in the form of comments and use a ROOT "dictionary" to include the additional information. This is outside the scope of what you'll probably be asked to do this summer. If you're interested in the concept, it's described in Chapter 15 of the [ROOT User\'s Guide](https://root.cern/root/htmldoc/guides/users-guide/ROOTUsersGuide.html). There's an example in {ref}`expert exercises`.