0% found this document useful (0 votes)
23 views55 pages

Root Lecture

The ROOT framework is a data analysis tool developed for High Energy Physics, utilizing an object-oriented programming approach based on C++. It allows users to perform various data analysis tasks such as histogram plotting, fitting distributions, and applying advanced statistical methods. The document outlines the installation process, basic functionalities, and examples of using ROOT for data analysis.

Uploaded by

Jizel Ziadi
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
23 views55 pages

Root Lecture

The ROOT framework is a data analysis tool developed for High Energy Physics, utilizing an object-oriented programming approach based on C++. It allows users to perform various data analysis tasks such as histogram plotting, fitting distributions, and applying advanced statistical methods. The document outlines the installation process, basic functionalities, and examples of using ROOT for data analysis.

Uploaded by

Jizel Ziadi
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 55

Outline What is ROOT? Applications Data analysis Summary Ready?

The ROOT framework


– Lecture and Tutorial –

Andrea Knue
HASCO Summer School
Goettingen, July 2015

1/ 55 – The ROOT framework – Andrea Knue


Outline What is ROOT? Applications Data analysis Summary Ready?

Our job in a (very) simplefied way


– HEP Experiment – + – Process of interest –

= fancy plot?

http://arxiv.org/abs/1506.05629
2/ 55 – The ROOT framework – Andrea Knue
Outline What is ROOT? Applications Data analysis Summary Ready?

Not that simple!

Short Brainstorming:

1 What information do we have?

2 What information are we interested in?

3 How do we get there?

3/ 55 – The ROOT framework – Andrea Knue


Outline What is ROOT? Applications Data analysis Summary Ready?

What do you need for data analysis?

A lot of important steps before extracting the final quantity:

experiment → data taking!

detector calibration

event selection

but also: produce simulation (Monte Carlo generators) to compare


with!

run all steps over data and MC

write out ntuple for actual analysis

4/ 55 – The ROOT framework – Andrea Knue


Outline What is ROOT? Applications Data analysis Summary Ready?

What tools do we need (basic view)

plot histograms and measured values

fit distributions

add histograms

stack histograms and compare to data

make ratio plots, compare shapes

have proper labelling

extract values from data

➔ all this (and more) can be done with ROOT

5/ 55 – The ROOT framework – Andrea Knue


Outline What is ROOT? Applications Data analysis Summary Ready?

Disclaimer

info from https://root.cern.ch/

took a bit of orientation also from last year Link

some examples shown today: from $ROOTSYS/tutorials/

6/ 55 – The ROOT framework – Andrea Knue


Outline What is ROOT? Applications Data analysis Summary Ready?

Introduction: What is ROOT?

framework for data analysis (started 1994)


֒→ before: PAW, Fortran based
֒→ now: object oriented, based on C++

developed for High Energy Physics

new features implemented constantly

find latest version for download here

7/ 55 – The ROOT framework – Andrea Knue


Outline What is ROOT? Applications Data analysis Summary Ready?

Introduction: What is ROOT II

simple data analysis: read data, fill histogram, handle four-vectors

make fits, write out results

make fancy plots for your thesis, paper etc

includes also more advanced statistical methods:

֒→ Nuisance parameter fits: RooFit

֒→ Unfolding: RooUnfold

֒→ Multivariate Analyses: TMVA

8/ 55 – The ROOT framework – Andrea Knue


Outline What is ROOT? Applications Data analysis Summary Ready?

Why object-oriented programming language?

classes allow modular structure, decreased level of complexity

allows classes to inherit from other classes

֒→ makes development much easier

֒→ object can easily be extended

allows abstraction and polymorphism

9/ 55 – The ROOT framework – Andrea Knue


Outline What is ROOT? Applications Data analysis Summary Ready?

How to get ROOT?

a) If you are working at CERN (lxplus)

ssh -Y [email protected]

source /afs/cern.ch/sw/lcg/contrib/gcc/4.8/x86 64-slc6/setup.sh

source /afs/cern.ch/sw/lcg/app/releases/ROOT/6.02.05/x86 64-slc6-gcc48-opt/root/bin/thisroot.sh

b) on your laptop
to install locally Download here!

very easy to install on Linux

works on Windows or MacOS too Link to versions

10/ 55 – The ROOT framework – Andrea Knue


Outline What is ROOT? Applications Data analysis Summary Ready?

First steps

If root is properly installed on your computer, just type: root

➔ if you want to avoid the logo to open, just type root -l instead of root .

11/ 55 – The ROOT framework – Andrea Knue


Outline What is ROOT? Applications Data analysis Summary Ready?

Random generators

➔ computers: not truly random but pseudo random


➔ good enough for a lot of applications

Where do we need them?


emulate detector conditions: smear simulated data (Monte Carlo) to
model resolution of detector

apply object calibrations (electron, muon jets) to match MC to data

What do we need from them?


long period → should not repeat themselves too quickly

fast algorithm: → have to do this quite often!

12/ 55 – The ROOT framework – Andrea Knue


Outline What is ROOT? Applications Data analysis Summary Ready?

Random generators: how random is random?

ROOT comes with several random generators:

1 TRandom: periodicity: 109 , 34 ns/call (no NOT use!)

2 TRandom1: periodicity: 1014 , 242 ns/call

3 TRandom2: periodicity: 1026 , 37 ns/call

4 TRandom3: default, use only this one!


֒→ Mersenne-Twister generator
֒→ very long periodicity: 10600
֒→ resonably fast: 42 ns/call

13/ 55 – The ROOT framework – Andrea Knue


Outline What is ROOT? Applications Data analysis Summary Ready?

Random generators II

Choice of seed
need to choose starting point (seed)

choose specific value (for example 1234)


֒→ then the simulation can be reproduced (code debugging)

choose seed=0:
֒→ take system time of the computer,

14/ 55 – The ROOT framework – Andrea Knue


Outline What is ROOT? Applications Data analysis Summary Ready?

Examples for functions in TRandom3

Uniform(x1)

→ calls random number uniformly distributed between 0 and x1

Gauss(mean, sigma)

→ calls random number in gaussian distribution around mean with


width sigma

exp(tau)

→ calls random number in exp distribution with exp(-t/tau)

also have landau, poisson, binomial...

15/ 55 – The ROOT framework – Andrea Knue


Outline What is ROOT? Applications Data analysis Summary Ready?

Two distributions: gaussians with seed 0

jet eta jet eta


hist hist
80 Entries 1000 90 Entries 1000
Mean 0.03218 Mean -0.01133
RMS 0.9669 80 RMS 0.948
70

70
60
60
50
50
40
40
30
30
20
20

10 10

0 0
-2.5 -2 -1.5 -1 -0.5 0 0.5 1 1.5 2 2.5 -2.5 -2 -1.5 -1 -0.5 0 0.5 1 1.5 2 2.5

➔ run same code twice with seed 0: different distributions

16/ 55 – The ROOT framework – Andrea Knue


Outline What is ROOT? Applications Data analysis Summary Ready?

Two distributions: gaussians with seed 1234

jet eta jet eta


hist hist
Entries 1000 Entries 1000
80 80
Mean -0.01415 Mean -0.01415
RMS 0.9517 RMS 0.9517
70 70

60 60

50 50

40 40

30 30

20 20

10 10

0 0
-2.5 -2 -1.5 -1 -0.5 0 0.5 1 1.5 2 2.5 -2.5 -2 -1.5 -1 -0.5 0 0.5 1 1.5 2 2.5

➔ run same code twice with seed 1234: same distributions !

17/ 55 – The ROOT framework – Andrea Knue


Outline What is ROOT? Applications Data analysis Summary Ready?

How do we get this simple plot?

jet eta
hist
80 Entries 1000
Mean 0.03218
RMS 0.9669
70

60

50

40

30

20

10

0
-2.5 -2 -1.5 -1 -0.5 0 0.5 1 1.5 2 2.5

➔ write this into file TestCode.C

➔ now call in command line: root TestCode.C

18/ 55 – The ROOT framework – Andrea Knue


Outline What is ROOT? Applications Data analysis Summary Ready?

Example code for 2D plot

19/ 55 – The ROOT framework – Andrea Knue


Outline What is ROOT? Applications Data analysis Summary Ready?

Plot output: no correlation

jet etas
2.5 hist2D
Entries 70
10000
Mean x -0.01167
2
Mean y -0.0002396

RMS x 60
0.9493
1.5
RMS y 0.9573

1 50

0.5
40
0

-0.5 30

-1 20
-1.5
10
-2

-2.5 0
-2.5 -2 -1.5 -1 -0.5 0 0.5 1 1.5 2 2.5

20/ 55 – The ROOT framework – Andrea Knue


Outline What is ROOT? Applications Data analysis Summary Ready?

Now put 2 Histograms in one plot

jet eta
hist1
Entries 10000
800 Mean -0.005804
RMS 0.9521

700

600

500

400

300

200

100

-2.5 -2 -1.5 -1 -0.5 0 0.5 1 1.5 2 2.5

➔ have to specify Draw(“SAME”) when drawing the second histogram

21/ 55 – The ROOT framework – Andrea Knue


Outline What is ROOT? Applications Data analysis Summary Ready?

Now want to compare the two shapes: h1 → Divide(h2)

jet eta
hist1
800 Entries 10000
Mean -0.002649
RMS 0.9557
700

600

500

400

300

200

100

-2.5 -2 -1.5 -1 -0.5 0 0.5 1 1.5 2 2.5

jet eta
hist1
1.25 Entries 25
Mean -0.02952
1.2 RMS 1.448

1.15

1.1

1.05

0.95

0.9

0.85

-2.5 -2 -1.5 -1 -0.5 0 0.5 1 1.5 2 2.5

22/ 55 – The ROOT framework – Andrea Knue


Outline What is ROOT? Applications Data analysis Summary Ready?

Look at our simple plot: good enough?

jet eta
hist1
800 Entries 10000
Mean -0.002649
RMS 0.9557
700

600

500

400

300

200

100

-2.5 -2 -1.5 -1 -0.5 0 0.5 1 1.5 2 2.5

jet eta
hist1
1.25 Entries 25
Mean -0.02952
1.2 RMS 1.448

1.15

1.1

1.05

0.95

0.9

0.85

-2.5 -2 -1.5 -1 -0.5 0 0.5 1 1.5 2 2.5

➔ No! See at least 8 things that are unclear/missing!


23/ 55 – The ROOT framework – Andrea Knue
Outline What is ROOT? Applications Data analysis Summary Ready?

How to make now a good plot?

has to be informative

not too crowded, but complete!

good, unambiguous colour code

labels, titles, legend: good text size!

good axis labels and titles: do not forget units!

which analysis channel? how many jets/btags?

which experiment, which luminosity?

24/ 55 – The ROOT framework – Andrea Knue


Outline What is ROOT? Applications Data analysis Summary Ready?

Now want to show statistical uncertainty

jet eta
hist1
Entries 10000
800 Mean -0.01313
RMS 0.9492
700

600

500

400

300

200

100

0
-2.5 -2 -1.5 -1 -0.5 0 0.5 1 1.5 2 2.5

jet eta
hist1
Entries 2210
1.3 Mean -0.05011
RMS 1.429
1.2

1.1

0.9

0.8

0.7

0.6
-2.5 -2 -1.5 -1 -0.5 0 0.5 1 1.5 2 2.5

25/ 55 – The ROOT framework – Andrea Knue


Outline What is ROOT? Applications Data analysis Summary Ready?

Now want to remove statistics box

jet eta

800

700

600

500

400

300

200

100

-2.5 -2 -1.5 -1 -0.5 0 0.5 1 1.5 2 2.5

jet eta

1.6

1.4

1.2

0.8

-2.5 -2 -1.5 -1 -0.5 0 0.5 1 1.5 2 2.5

26/ 55 – The ROOT framework – Andrea Knue


Outline What is ROOT? Applications Data analysis Summary Ready?

Now want proper colour code

jet eta
hist1
900 Entries 10000
Mean 0.006211
800 RMS 0.9511

700

600

500

400

300

200

100

0
-2.5 -2 -1.5 -1 -0.5 0 0.5 1 1.5 2 2.5

jet eta
hist1
Entries 2217
Mean 0.03989
1.2 RMS 1.433

1.1

0.9

0.8

0.7
-2.5 -2 -1.5 -1 -0.5 0 0.5 1 1.5 2 2.5

27/ 55 – The ROOT framework – Andrea Knue


Outline What is ROOT? Applications Data analysis Summary Ready?

Now want better ratio plot

800

700

600

500

400

300

200

100

0
-2.5 -2 -1.5 -1 -0.5 0 0.5 1 1.5 2 2.5

1.4

1.2

0.8

0.6
-2.5 -2 -1.5 -1 -0.5 0 0.5 1 1.5 2 2.5

28/ 55 – The ROOT framework – Andrea Knue


Outline What is ROOT? Applications Data analysis Summary Ready?

Add more information to plot

fixed now:
add axis title
adjust label and title sizes
add line at y = 1 to ratio plot
add Legend
add label for experiment and
sample stats
➔ all of this will be in tomorrows tutorial

29/ 55 – The ROOT framework – Andrea Knue


Outline What is ROOT? Applications Data analysis Summary Ready?

What is a flat ntuple?

store all info we have in ROOT Tree

have a branch for each variable

a branch can contain an integer, float, double, vector of floats,


vector of vector...

“flat” ntuple: easily browsable

simplest object if you want to do your final analysis

contains object kinematics (four vectors, scale factors, event


weights...)

30/ 55 – The ROOT framework – Andrea Knue


Outline What is ROOT? Applications Data analysis Summary Ready?

A pretty HEP event

31/ 55 – The ROOT framework – Andrea Knue


Outline What is ROOT? Applications Data analysis Summary Ready?

... but it does not always look that clean!

32/ 55 – The ROOT framework – Andrea Knue


Outline What is ROOT? Applications Data analysis Summary Ready?

Dominant Background Processes (l+jets)

W +jets: Misidentified leptons:


b ”e”
q′ q


νl
q̄ Single top:
W
l q̄’ b̄
Smaller
q̄ contributions:

W+ q Z +jets
q t Diboson

➔ Need a lot of variables in a handy format


33/ 55 – The ROOT framework – Andrea Knue
Outline What is ROOT? Applications Data analysis Summary Ready?

Event selection: lepton+jets

Electrons: Muons:

Missing ET : - ET > 25 GeV - combined Muons


- |η| < 2.47 (tracker+spectrometer)
Miss. ET > 20 GeV - isolated - pT > 20 GeV
- exclude crack region - |η| < 2.50
- isolated

transverse W mass:
At least 4 Jets:
q
mT ,W = 2p l p ν (1 − cos(∆φ):
T T - anti-kt jets (∆R = 0.4)
- pT > 25 GeV
mT ,W + ETmiss > 60 GeV - |η| < 2.5
- cut on Jet Vertex Tagger
to reduce pile-up influence

b-Jets:
➔ identify b-Jets via its secondary vertex
➔ require at least one tagged jet
➔ use MV2 @ 77 % WP

34/ 55 – The ROOT framework – Andrea Knue


Outline What is ROOT? Applications Data analysis Summary Ready?

Open tree in browser

➔ do: root -l FileName.root


➔ and then: new TBrowser
35/ 55 – The ROOT framework – Andrea Knue
Outline What is ROOT? Applications Data analysis Summary Ready?

I was given a large ROOT Tree to analyse, what now?

Make structure to read it


➔ magical command: MakeClass

Example:
filename: example.root, tree name: TreeS

type: root example.root

then type: TreeS→MakeClass(”TestTree”)

you get: TestTree.h and TestTree.C

36/ 55 – The ROOT framework – Andrea Knue


Outline What is ROOT? Applications Data analysis Summary Ready?

Output header file: TestTree.h

37/ 55 – The ROOT framework – Andrea Knue


Outline What is ROOT? Applications Data analysis Summary Ready?

Output macro: TestTree.C

38/ 55 – The ROOT framework – Andrea Knue


Outline What is ROOT? Applications Data analysis Summary Ready?

Root Macro vs compiled code

up to now:
only showed how to run a root macro with root MacroName.C

fine for small tests, very slow for larger statistics

How to compile a root macro (using CINT, ACLIC)


open root in command line, then do: .L TestScript.C++

have to make sure all neccessary non-root libraries (like iostream,


string etc) are included

but: better include the libraries in a proper C++ class and use
a Makefile!

39/ 55 – The ROOT framework – Andrea Knue


Outline What is ROOT? Applications Data analysis Summary Ready?

The Root browser/editor

want to work with a histogram that has been stored in a .root file
open it with root: root HistoFile.root
then click on histogram in the file

40/ 55 – The ROOT framework – Andrea Knue


Outline What is ROOT? Applications Data analysis Summary Ready?

The Root browser/editor

open histogram in TBrowser


click on: View → Editor
then: Tools → FitPanel
choose fit function
press ”Fit” button
get fit parameters in terminal

41/ 55 – The ROOT framework – Andrea Knue


Outline What is ROOT? Applications Data analysis Summary Ready?

The Root browser/editor

➔ Now one gets the function from the fit result on top of the histogram.

42/ 55 – The ROOT framework – Andrea Knue


Outline What is ROOT? Applications Data analysis Summary Ready?

The Root browser/editor

➔ can choose in panel on left side which results should be shown in stats
box.
43/ 55 – The ROOT framework – Andrea Knue
Outline What is ROOT? Applications Data analysis Summary Ready?

Run Multivariate Analysis

available in ROOT in TMVA package

what is a multivariate analysis?

want to distinguish signal from background, one variable not


powerful enough

not too many, but enough variables (balance between separation


power and running time)

check for overtraining

start with example!

44/ 55 – The ROOT framework – Andrea Knue


Outline What is ROOT? Applications Data analysis Summary Ready?

Example: ttH analysis with H → b b̄ Paper

➔ but: if a gluon is radiated instead of a Higgs, the final state is


identical!
➔ large irreducible background, need to find variables to distinguish the
two processes

45/ 55 – The ROOT framework – Andrea Knue


Outline What is ROOT? Applications Data analysis Summary Ready?

Signal region: 6 jets with 4 b-tags Paper

➔ some separation in each distribution: take all this info and make new variable!
46/ 55 – The ROOT framework – Andrea Knue
Outline What is ROOT? Applications Data analysis Summary Ready?

Final analysis discriminant

➔ use information of 10 different variables: much better separation

47/ 55 – The ROOT framework – Andrea Knue


Outline What is ROOT? Applications Data analysis Summary Ready?

Neural networks

➔ input layer: as many nodes as input variables

➔ next layer: combine variables, NN can ”learn”

48/ 55 – The ROOT framework – Andrea Knue


Outline What is ROOT? Applications Data analysis Summary Ready?

Example: Boosted decision trees Plot from here

➔ but many more methods can be tested, lots implemented in TMVA

49/ 55 – The ROOT framework – Andrea Knue


Outline What is ROOT? Applications Data analysis Summary Ready?

Compare different methods directly Plot from here

50/ 55 – The ROOT framework – Andrea Knue


Outline What is ROOT? Applications Data analysis Summary Ready?

Check for overtraining!

➔ overtraining: NN takes statistical fluctuations into account

➔ use only half of sample for training, then use other half to test
51/ 55 – The ROOT framework – Andrea Knue
Outline What is ROOT? Applications Data analysis Summary Ready?

Pyroot: use ROOT in python script

➔ this will be covered in one of the excercises tomorrow

➔ more documentation here

52/ 55 – The ROOT framework – Andrea Knue


Outline What is ROOT? Applications Data analysis Summary Ready?

Summary

need to store a lot of information

info has to be easily accessible/modifyable

need to be able to make pretty plots

this and much more provided by ROOT

Warning: has some annoying functionalities that you might


experience soon!

(not fortran, sorry PAW fans!)

53/ 55 – The ROOT framework – Andrea Knue


Outline What is ROOT? Applications Data analysis Summary Ready?

Ready for some actual work?

➔ See you for the tutorial tomorrow!

54/ 55 – The ROOT framework – Andrea Knue


Outline What is ROOT? Applications Data analysis Summary Ready?

Exercises

1 Find Higgs boson in gg → H → γγ channel and make money plot.

2 Read trees and make correlation plots with pyROOT.

3 Train different MVA and compare the performance.

55/ 55 – The ROOT framework – Andrea Knue

You might also like