Skip to content

ROOT Tutorial for 2023 EIEIO Workshop

Notifications You must be signed in to change notification settings

m-moring/rootTute

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

32 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ROOTTute

ROOT Tutorial for 2023 EIEIO Workshop

Examples

All the macros shown in the slides are in the examples directory. These can be run as:

root -l macro_name.C

and should produce the outputs shown in the slides.

Exercise and Project Solutions

Example solutions to the five exercises can be found in the exercises directory. There's always a lot of different ways you can go about any of these problems, so try them out yourself and check these solutions if you get stuck. The first two exercises are fairly basic and open ended, so don't have solutions. A solution to the project can be found in the project directory.
The solution scripts can be run like the examples:

root -l exercises_solution.C

Exercises

Exercise 1

Getting used to the ROOT command line
  • Open ROOT
  • Declare some variables and do some calculations
  • Draw a TCanvas
  • Open the TBrowser and explore!

Exercise 2

Writing and running a basic macro
  • In a macro, declare a histogram
  • Fill it with some values, in any way you choose
  • Declare a new TFile, and save the histogram
  • Open the new ROOT file and draw the histogram
  • Play with the aesthetics of the plot via the GUI

Exercise 3

Plotting the Gaussian approximation to the Poisson distribution
  • Plot the Poisson distribution for λ = 5, 10, 25, 50, 100
  • For each, also plot the Gaussian distribution with μ = λ, σ = √λ
  • Use a different colour for each λ, and different line styles for Poisson and Gaussian
  • Save the canvas to a PDF file

Exercise 4

Recreate the data - Monte Carlo comparison plot from the slides (also in exercises/exercise4Canvas.pdf) exactly (or as close as you can!)
  • You will have to judge the bin contents of the two histograms

Exercise 5

Collecting real data and plotting correlations
This is a bonus exercise in case we run out of material. The idea is to collect numerical data of some sort, and then make some plots.
  • Ask your friends >= 5 questions about themselves with numeric answers (eg, birthdate, age, height, shoe size, favourite number, number of pets/pairs of shoes/hammocks they own). Get creative!
  • Record each answer in a text file, separated by a space, with a new line for a new friend
  • Read this into a TTree, and save the TTree to file
  • Open the file and plot different variables against each other. You can cut on variables (including ones your not plotting)
  • See if you can pull out any amusing correlations!
      - But remember this does not necessarily imply causation!!!

Project

Simulating a dataset from a particle detector

Part A:

  • Imagine you have a 5m radius spherical target mass, surrounded by PMTs
  • Generate x, y, z and energy for 1000 events
     - Assume this signal is uniformly distributed in position
     - Assume an energy of, say, 2.5 MeV
     - You can use ROOT's TRandom3 class to generate random numbers
  • Now generate x, y, z and energy for 1000 background events
     - Let’s say it has the same energy as our signal
     - But radially drops off as 1/r^2 away from the edge of the detector. Maybe there’s some external radiation that leaches into the target mass but only penetrates so far
  • Now let’s generate some reconstructed values
     - Assume a position resolution of 100 mm in each coordinate
     - Assume an energy resolution of 3 %
     - What if the resolution is a weak function of the radius?
     - This smearing of the true values with the width of the resolution is a common way to account for detector effects in simulation
  • Now repeat for 100,000 events and save these values in a TTree in a file

Part B:

  • Check the radial distributions look as expected
  • Plot True vs Reconstructed R for all events
  • Plot the bias in energy [(Reconstructed E - True E) / True E] as a function of True R

Part C:

  • We are now going to try and reject those background events by cutting on radius
  • Make a ROC curve (purity against sacrifice) for different values for a radial cut

Part D:

  • Now repeat this whole process but for a background rate reduced by a factor of 10. How does the ROC curve change?

About

ROOT Tutorial for 2023 EIEIO Workshop

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C 100.0%