In this notebook you can find an easy set of commands that show some basic computing techniques commonly used in High Energy Physics (HEP) analyzes.
It also shows how to create an histogram, fill it and draw it. Moreover it is an introduction to ROOT too. The final output is a plot with the number of leptons.
Check the description of the varibles inside the dataset at the end of this notebook
All done with less that 15 lines of code!
This is a notebook using the ROOT Prompt kernel that using c++ language, is intended to show the internal content and the way to call and interact with the datasets released by the ATLAS experiment with focus in Education and Training activities:
where physics objects can be represented as below
First of all ROOT is imported to read the files in the _.root_ data format. A _.root_ file consists of a tree having branches and leaves.
At this point you could also import further programs that contain other formulas that you maybe use more often. But here we don't import other programs to keep it simple.
Welcome to JupyROOT 6.08/04
In order to activate the interactive visualisation of the histogram that is later created we can use the JSROOT magic:
Next we have to open the data that we want to analyze. It is stored in a _*.root_ file that consists of a tree having branches and leaves.
As you can see, we are reading the data directly from the source! but you can read the file locally too.
f = ROOT.TFile.Open("http://opendata.atlas.cern/release/samples/MC/mc_147770.Zee.root") ## f = ROOT.TFile.Open("mc_105986.ZZ.root")
The next step is to define a tree named (we called _tree_) to get the data out of the _*.root_ file, that is into a tree called _mini_:
tree = f.Get("mini")
After the data is opened we create a canvas on which we can draw a histogram. If we do not have a canvas we cannot see our histogram at the end. Its name is _Canvas_ and its header is _a first way to plot a variable_. The two following arguments define the width and the height of the canvas.
canvas = ROOT.TCanvas("Canvas","a first way to plot a variable",800,600)
Now we define a histogram that will later be placed on this canvas. Its name is _variable_ and the header of the histogram is _Example plot: Number of leptons_. The three following arguments indicate that this histogram contains 4 so called bins which have a range from 0 to 4.
hist = ROOT.TH1F("variable","Example plot: Number of leptons",4,0,4)
The following lines are a loop that goes over the data that is stored in the tree and fills the histogram _h_ that we already defined. In this first notebook we don't do any cuts to keep it simple. Accordingly the loop fills the histogram for each event stored in the tree. After the program has looped over all the data it prints the wordDone!.
for event in tree: hist.Fill(tree.lep_n) print "Done!"
After filling the histogram we want to see the results of the analysis. First we draw the histogram on the canvas and then the canvas on which the histogram lies:
scale = hist.Integral() hist.Scale(1/scale)
|05||rndRunNumber||int||randomized run number mimicking run number distribution in data|
|06||mu||float||average interactions per bunch crossing|
|07||mcWeight||float||weight of an MC event|
|08||pvxp_n||int||number of primary vertices|
|09||isGoodEvent||int||summary of diverse quality flags like hfor|
|10||scaleFactor||float||overall scale factor for the preselected event|
|11||trigE||bool||boolean whether a standard trigger has fired in the egamma stream|
|12||trigM||bool||boolean whether a standard trigger has fired in the muon stream|
|13||passGRL||bool||signifies whether event passes the GRL may be put in isGoodEvent|
|14||hasGoodVertex||bool||signifies whether the event has at least one good vertex|
|15||lep_n||int||number of preselected leptons|
||boolean indicating whether the lepton is matched to a truth lepton|
||boolean signifying whether the lepton is the one triggering the event|
||transverse momentum of the lepton|
||pseudo-rapidity of the lepton|
||azimuthal angle of the lepton|
||energy of the lepton|
||z-coordinate of the track associated to the lepton wrt. the primary vertex|
||charge of the lepton|
||boolean indicating whether the lepton is of tight quality|
||bitmask implementing object cuts of the top group|
||number signifying the lepton type (e, mu, tau) of the lepton|
||ptcone30 isolation for the lepton|
||etcone20 isolation for the lepton|
||d0 of the track associated to the lepton at the point of closest approach (p.o.a.)|
||d0 signifcance of the track associated to the lepton at the p.o.a.|
|30||met_et||float||Transverse energy of the missing momentum vector|
|31||met_phi||float||Azimuthal angle of the missing momentum vector|
|32||jet_n||int||number of selected jets|
||transverse momentum of the jet|
||pseudorapidity of the jet|
||azimuthal angle of the jet|
||energy of the jet|
||invariant mass of the jet|
||JetVertexFraction of the jet|
||bitmask implementing object cuts of the top group|
||true flavor of the jet|
||information whether the jet matches a jet on truth level|
||SV0 weight of the jet|
||MV1 weight of the jet|
|44||scaleFactor_BTAG||float||scalefactor for btagging|
|45||scaleFactor_ELE||float||scalefactor for electron efficiency|
|46||scaleFactor_JVFSF||float||scalefactor for jet vertex fraction|
|47||scaleFactor_MUON||float||scalefactor for muon efficiency|
|48||scaleFactor_PILEUP||float||scalefactor for pileup reweighting|
|49||scaleFactor_TRIGGER||float||scalefactor for trigger|
|50||scaleFactor_ZVERTEX||float||scalefactor for z-vertex reweighting|