Logo ROOT  
Reference Guide
Loading...
Searching...
No Matches
df101_h1Analysis.py
Go to the documentation of this file.
1import ROOT
2
4
5
6# Declare filters on RVec objects and JIT with Numba
7@ROOT.Numba.Declare(["int", "int", "RVecI"], "bool")
9 return nhitrp[ik - 1] * nhitrp[ipi - 1] > 1
10
11
12@ROOT.Numba.Declare(["int", "RVecF", "RVecF"], "bool")
14 return rend[ik - 1] - rstart[ik - 1] > 22
15
16
17@ROOT.Numba.Declare(["int", "RVecF", "RVecF"], "bool")
19 return rend[ipi - 1] - rstart[ipi - 1] > 22
20
21
22@ROOT.Numba.Declare(["int", "RVecF"], "bool")
24 return nlhk[ik - 1] > 0.1
25
26
27@ROOT.Numba.Declare(["int", "RVecF"], "bool")
29 return nlhpi[ipi - 1] > 0.1
30
31
32@ROOT.Numba.Declare(["int", "RVecF"], "bool")
34 return nlhpi[ipis - 1] > 0.1
35
36
38 return (
39 rdf.Filter("TMath::Abs(md0_d - 1.8646) < 0.04")
40 .Filter("ptds_d > 2.5")
41 .Filter("TMath::Abs(etads_d) < 1.5")
42 .Filter("Numba::ik_ipi_nhitrp_cut(ik, ipi, nhitrp)")
43 .Filter("Numba::ik_rstart_rend_cut(ik, rstart, rend)")
44 .Filter("Numba::ipi_rstart_rend_cut(ipi, rstart, rend)")
45 .Filter("Numba::ik_nlhk_cut(ik, nlhk)")
46 .Filter("Numba::ipi_nlhpi_cut(ipi, nlhpi)")
47 .Filter("Numba::ipis_nlhpi_cut(ipis, nlhpi)")
48 )
49
50
51dxbin = (0.17 - 0.13) / 40
52condition = "x > 0.13957"
53xp3 = "(x - [3]) * (x - [3])"
54
55
57 ROOT.gStyle.SetOptFit()
58 c1 = ROOT.TCanvas("c1", "h1analysis analysis", 10, 10, 800, 600)
59
60 hdmd.GetXaxis().SetTitleOffset(1.4)
61
62 hdraw = hdmd.DrawClone()
63
64 # Fit histogram hdmd with function f5 using the loglikelihood option
65 formula = f"{dxbin} * ([0] * pow(x - 0.13957, [1]) + [2] / 2.5066 / [4] * exp(-{xp3} / 2 / [4] / [4]))"
66 f5 = ROOT.TF1("f5", f"{condition} ? {formula} : 0", 0.139, 0.17, 5)
67 f5.SetParameters(1000000, 0.25, 2000, 0.1454, 0.001)
68 hdraw.Fit(f5, "lr")
69
70 c1.Update()
71
72 return
73
74
76 # Create the canvas for tau d0
77 c2 = ROOT.TCanvas("c2", "tauD0", 100, 100, 800, 600)
78
79 c2.SetGrid()
80 c2.SetBottomMargin(0.15)
81
82 # Project slices of 2-d histogram h2 along X , then fit each slice
83 # with function f2 and make a histogram for each fit parameter
84 # Note that the generated histograms are added to the list of objects
85 # in the current directory.
86 sigma = 0.0012
87 formula = f"{dxbin} * ([0] * pow(x - 0.13957, 0.25) + [1] / 2.5066 / {sigma} * exp(-{xp3} / 2 / {sigma} / {sigma}))"
88 print(f"TWO: {condition} ? {formula} : 0")
89
90 f2 = ROOT.TF1("f2", f"{condition} ? {formula} : 0", 0.139, 0.17, 2)
91 f2.SetParameters(10000, 10)
92 h2.FitSlicesX(f2, 0, -1, 1, "qln")
93
94 # See TH2::FitSlicesX documentation why h2_1 name is used
95 h2_1 = ROOT.gDirectory.Get("h2_1")
96 h2_1.SetDirectory(ROOT.nullptr)
97 h2_1.GetXaxis().SetTitle("#tau [ps]")
98 h2_1.SetMarkerStyle(21)
99 h2_1.Draw()
100
101 c2.Update()
102
103 line = ROOT.TLine(0, 0, 0, c2.GetUymax())
104 line.Draw()
105
106 return
107
108
109chain = ROOT.TChain("h42")
110chain.Add("root://eospublic.cern.ch//eos/root-eos/h1/dstarmb.root")
111chain.Add("root://eospublic.cern.ch//eos/root-eos/h1/dstarp1a.root")
112chain.Add("root://eospublic.cern.ch//eos/root-eos/h1/dstarp1b.root")
113chain.Add("root://eospublic.cern.ch//eos/root-eos/h1/dstarp2.root")
114
116selected = select(df)
117# Note: The title syntax is "<Title>;<Label x axis>;<Label y axis>"
118hdmdARP = selected.Histo1D(("hdmd", "Dm_d;m_{K#pi#pi} - m_{K#pi}[GeV/c^{2}]", 40, 0.13, 0.17), "dm_d")
119selected_added_branch = selected.Define("h2_y", "rpd0_t / 0.029979f * 1.8646f / ptd0_d")
120h2ARP = selected_added_branch.Histo2D(("h2", "ptD0 vs Dm_d", 30, 0.135, 0.165, 30, -3, 6), "dm_d", "h2_y")
121
122FitAndPlotHdmd(hdmdARP)
123FitAndPlotH2(h2ARP)
ROOT's RDataFrame offers a modern, high-level interface for analysis of data stored in TTree ,...
void EnableImplicitMT(UInt_t numthreads=0)
Enable ROOT's implicit multi-threading for all objects and methods that provide an internal paralleli...
Definition TROOT.cxx:613
ipi_nlhpi_cut(ipi, nlhpi)
ipis_nlhpi_cut(ipis, nlhpi)
ipi_rstart_rend_cut(ipi, rstart, rend)
ik_ipi_nhitrp_cut(ik, ipi, nhitrp)
FitAndPlotHdmd(ROOT.TH1 hdmd)
ik_rstart_rend_cut(ik, rstart, rend)
FitAndPlotH2(ROOT.TH2 h2)