Back to home page

EIC code displayed by LXR

 
 

    


Warning, /tutorial-analysis/episodes/02-reconstruction-output.md is written in an unsupported language. File is not indexed.

0001 ---
0002 title: "The Reconstruction Output Tree"
0003 teaching: 20
0004 exercises: 20
0005 ---
0006 
0007 ::::::::::::::::::::::::::::::::::::::::::::: questions
0008 
0009 - What information is stored in the reconstruction output and how can we access it?
0010 
0011 :::::::::::::::::::::::::::::::::::::::::::::
0012 
0013 ::::::::::::::::::::::::::::::::::::::::::::: objectives
0014 
0015 - Become familiar with the tree branches.
0016 
0017 :::::::::::::::::::::::::::::::::::::::::::::
0018 
0019 What we generally call the simulation output are root trees generated by the reconstruction software, [EICrecon](https://github.com/eic/EICrecon/tree/main). The branches which appear in the output trees and their content are determined by which EICrecon factories and algorithms are run.
0020 
0021 - If you're trying to open interactive windows such as a TBrowser via X-forwarding, it's likely to be very slow. You may wish to just copy the file to your local machine and open it there. 
0022   - The [webviewer](https://eic.phy.anl.gov/geoviewer/) may also be quicker (just keep in mind that it's less usable and you will struggle to do more than just browsing the tree). 
0023     - You can't do much more than view the files with this either. Ultimately, for the final part of the tutorial, you'll need to be able to execute a ROOT macro/script it some way.
0024 
0025 ## EICrecon Output Tree Structure
0026 
0027 The output tree contains various branches appropriate for the individual detector subsystems. For example, the calorimeter subsystems will have branches for reconstructed hits and clusters. In addition to individual subsystem information, there are also branches for reconstructed quantities (e.g. reconstructed particles, inclusive kinematics, and jets) which may combine information from several subsystems. There are also branches encoding relationships between different reconstructed quantities as well as reconstructed and truth quantities. 
0028 
0029 ::::::::::::::::::::::::::::::::::::::::::::: challenge
0030 
0031 ## Exercise
0032 
0033 - Stream a simulation output tree from within root (see previous lesson) and browse the structure by calling `new TBrowser()`
0034 - Take some time to explore the branches of the tree. What information is included for various subsystems? What are some of the reconstructed quantities?
0035 - Try plotting some basic quantities. Plot the cluster energy of the negative endcap ECal - do you see the peak from the scattered electron?
0036 
0037 :::::::::::::::  solution
0038 
0039 Opening the file and calling `new TBrowser()` shows the full list of branches. Double-clicking
0040 `EcalEndcapNClusters.energy` draws the cluster energy distribution for the negative endcap ECal, in
0041 which you should be able to identify the peak from the scattered electron. Take your time exploring
0042 the subsystem branches (hits, clusters) and reconstructed quantities (reconstructed particles,
0043 inclusive kinematics, jets).
0044 
0045 :::::::::::::::
0046 
0047 :::::::::::::::::::::::::::::::::::::::::::::
0048 
0049 For the last part, some extra tips are included below.
0050 
0051 ## Browsing the file - ROOT Tips
0052 
0053 We can navigate around the TBrowser and get it to draw quantities by simply double clicking them. However, sometimes the auto binning can be off or we might want to look at a specific range. We can do this to some extent directly from the TBrowser.
0054 
0055 Alternatively, we can also plot variables to histograms of our own choosing on the fly. We can do this via -
0056 
0057 ```c++
0058 root $FILE
0059 events->Draw("QUANTITY")
0060 ```
0061 where $FILE is the file we want to open and "QUANTITY" is the thing we want to draw. For example -
0062 
0063 ```c++
0064 events->Draw("MCParticles.momentum.z")
0065 ```
0066 will draw the MCParticles.momentum.z branch. So far, so much like just double clicking the TBrowser. However, we could define a new histogram and fill this variable to it -
0067 
0068 ```c++
0069 events->Draw("MCParticles.momentum.z>>h1(100,0,100)")
0070 ```
0071 where h1 is our new histogram. This has 100 bins from 0 to 100. We can also apply selection criteria (i.e. cuts) on the fly. These do not need to be on the same variable we are drawing! For example -
0072 
0073 ```c++
0074 events->Draw("MCParticles.momentum.z>>h1(360,-60,300)", "MCParticles.charge<0")
0075 ```
0076 will fill our histogram only with negatively charged particles. We can add more conditions if we want -
0077 
0078 ```c++
0079 events->Draw("MCParticles.momentum.z>>h1(360,-60,300)", "MCParticles.charge<0 && MCParticles.mass>1")
0080 ```
0081 where we now also require that the particle mass is >1.
0082 
0083 We can also add drawing options -
0084 
0085 ```c++
0086 events->Draw("MCParticles.momentum.z>>h1(360,-60,300)", "MCParticles.charge<0", "HISTERR")
0087 ```
0088 such as adding error bars. We can also make 2D histograms in the same way -
0089 
0090 ```c++
0091 events->Draw("MCParticles.momentum.z:MCParticles.charge>>h2(40,-2,2, 360,-60,300)", "", "COLZ")
0092 ```
0093 note the order of defining the binning. It's not what you might expect. Also, to interpret the result (as is often the case with 2D histograms), you might want to set a log Z scale -
0094 
0095 ```c++
0096 gPad->SetLogz()
0097 ```
0098 
0099 ## Which branches do I need?
0100 
0101 As you have probably seen by now, the tree in our file contains a lot of information!
0102 
0103 For the rest of the tutorial, we will be focusing on a relatively small subset. This is generally true with most analyses, it's rare we'll be retaining and looking at every branch. A brief (and incomplete!) dictionary of commonly used branches, including those we'll need in this tutorial, is included in the "Extras" section. See the tab at the top of the page or follow the [branch dictionary](../learners/branch-dictionary.md).
0104 
0105 To find out more about a particular collection, you could also take a look at the [edm4eic datamodel](https://github.com/eic/EDM4eic/blob/main/edm4eic.yaml). For some definitions and explanations, you may need to refer to the [edm4hep datamodel](https://github.com/key4hep/EDM4hep/blob/main/edm4hep.yaml).
0106 
0107 ## The MCParticles Record
0108 
0109 In the last section, the example quantities we were plotting involved the MCparticles branch. Nearly every analysis will include some comparison to the truth level, so it is important to understand how to access generator level information. Particles produced by the Monte Carlo Event Generator and during the interaction of these primary particles with the detector material as modelled by GEANT are stored in the MCParticles branch, this structure is defined by the datatype [edm4hep::MCParticle](https://github.com/key4hep/EDM4hep/blob/main/edm4hep.yaml#L140). The particle's [PDG](https://pdg.lbl.gov/2020/reviews/rpp2020-rev-monte-carlo-numbering.pdf) code, charge, production time, mass, production vertex, endpoint, momentum at the production vertex, and momentum at the endpoint are all available. In addition, the status of the particle as defined by the event generator and the detector simulation are stored. For example, if one wanted to look at stable particles from the event generator, they would require `MCParticles.generatorStatus == 1`. The field `MCParticles.simulatorStatus` is a bit-field which encodes some information on how the particle propagated through the detector. The detailed definition of the bit assignments can be found in the [edm4hep yaml file](https://github.com/key4hep/EDM4hep/blob/main/edm4hep.yaml#234).
0110 
0111 ## How is the tree populated?
0112 
0113 You may wonder how the specific branches of the tree have actually been populated. As this is the output after EICrecon, the trees in the file are those specified as EICrecon was run by the algorithms and factories that were enabled at run time.
0114 
0115 This is covered in more detail in the [Understanding the Simulation Output](https://eic.github.io/tutorial-understanding-sim-output/) tutorial. In particular, [Episode 3](https://eic.github.io/tutorial-understanding-sim-output/02-eicrecon.html) of that tutorial details how you can identify the sequence of algorithms utilised to generate a specific output branch. In the case of the example in this tutorial, the track reconstruction is detailed.
0116 
0117 ::::::::::::::::::::::::::::::::::::::::::::: callout
0118 
0119 Work through the algorithms and factories tutorial. Afterwards, take a closer look at this file.
0120 See if you can figure out which algorithm or factory was responsible for creating some of the included branches in this file.
0121 
0122 :::::::::::::::::::::::::::::::::::::::::::::
0123 
0124 ::::::::::::::::::::::::::::::::::::::::::::: keypoints
0125 
0126 - Output trees contain a lot of information. Take time to explore what is available, identify what you want to try and do, find the relevant branches.
0127 - The MCParticles branch holds information on generator level particles, critical for use in comparing to what we actually detect!
0128 
0129 :::::::::::::::::::::::::::::::::::::::::::::