{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"\n",
"# CMS Open Data Example #6: Fitting the J/$\\psi$ fit\n",
"\n",
"## Import required modules"
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"from ROOT import TFile, TCanvas, TH1F, TLorentzVector\n",
"%jsroot on"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Read in Data from Input File"
]
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"file = TFile(\"../data/Dimuons.root\",\"READ\");"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Declare Histograms"
]
},
{
"cell_type": "code",
"execution_count": 6,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"Jpsi = TH1F(\"Jpsi\",\"#mu#mu mass;#mu#mu mass [GeV];Events\", 1000, 2, 3.5)"
]
},
{
"cell_type": "markdown",
"metadata": {
"collapsed": true
},
"source": [
"# Compute Invariant Mass of J/$\\psi$"
]
},
{
"cell_type": "code",
"execution_count": 7,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"for dimu in file.Dimuons:\n",
"\n",
" if dimu.Muon1_Global and dimu.Muon2_Global: \n",
" \n",
" muon1 = TLorentzVector(dimu.Muon1_Px, dimu.Muon1_Py, dimu.Muon1_Pz, dimu.Muon1_Energy)\n",
" \n",
" muon2 = TLorentzVector(dimu.Muon2_Px, dimu.Muon2_Py, dimu.Muon2_Pz, dimu.Muon2_Energy)\n",
" \n",
" InvariantMass = (muon1 + muon2).M() \n",
" \n",
" if InvariantMass > 2.0 and InvariantMass < 4.0:\n",
"\n",
" Jpsi.Fill(InvariantMass)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Fitting the J/$\\psi$ Peak"
]
},
{
"cell_type": "code",
"execution_count": 8,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"from ROOT import TF1, kGreen, kRed\n",
"\n",
"Canvas = TCanvas()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Possible fitting options:
\n",
"\"gaus\" gaussian
\n",
"\"pol1\" 1st order polynomial
"
]
},
{
"cell_type": "code",
"execution_count": 9,
"metadata": {
"collapsed": false
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
" FCN=238.61 FROM MIGRAD STATUS=CONVERGED 71 CALLS 72 TOTAL\n",
" EDM=7.76303e-09 STRATEGY= 1 ERROR MATRIX ACCURATE \n",
" EXT PARAMETER STEP FIRST \n",
" NO. NAME VALUE ERROR SIZE DERIVATIVE \n",
" 1 Constant 5.82050e+02 4.65629e+00 2.59691e-02 -1.64617e-05\n",
" 2 Mean 3.09292e+00 2.01159e-04 1.51576e-06 9.89004e-02\n",
" 3 Sigma 3.05871e-02 2.03936e-04 1.30856e-05 2.50483e-02\n",
"\n",
"****************************************\n",
"Minimizer is Linear\n",
"Chi2 = 28549.5\n",
"NDf = 998\n",
"p0 = 65.9587 +/- 0.923571 \n",
"p1 = -15.3932 +/- 0.313802 \n"
]
},
{
"data": {
"text/html": [
"\n",
"