-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrootFuncs.py
More file actions
55 lines (41 loc) · 1.48 KB
/
rootFuncs.py
File metadata and controls
55 lines (41 loc) · 1.48 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#!/usr/bin/python3
import ROOT
import mathFuncs
def getExpGaussExpTf1(rangeMin, rangeMax, name=""):
func = ROOT.TF1(name, mathFuncs.expGaussExpForTf1, rangeMin, rangeMax, 5)
func.SetParName(0, "Norm")
func.SetParName(1, "Peak")
func.SetParName(2, "Sigma")
func.SetParName(3, "Tail_low")
func.SetParName(4, "Tail_high")
return func
def getExpGaussExp_poln_Tf1(n, rangeMin, rangeMax, name=""):
func = ROOT.TF1(name, mathFuncs.expGausExp_poln, rangeMin, rangeMax, 5 + n + 1)
# ExpGaussExp params
func.SetParName(0, "Norm")
func.SetParName(1, "Peak")
func.SetParName(2, "Sigma")
func.SetParName(3, "Tail_low")
func.SetParName(4, "Tail_high")
# set poln parameters
for i in range(n + 1):
func.SetParName(5 + i, f'p{i}')
return func
def isFitValid(tf1, fitResult):
if not fitResult.IsValid():
print(f'FitResult IsValid == {fitResult.IsValid()}')
print(fitResult.Status())
return False
if ROOT.gMinuit:
if ROOT.gMinuit.fStatus != 0:
print(f'ROOT.gMinuit.fStatus = {ROOT.gMinuit.fStatus}')
return False
if ROOT.gMinuit.fCstatu.rstrip() != 'CONVERGED' and ROOT.gMinuit.fCstatu.rstrip() != 'SUCCESSFUL':
print(f'ROOT.gMinuit.fCstatu = {ROOT.gMinuit.fCstatu}')
return False
return True
def getTf1Range(tf1):
minRange = ROOT.Double(0)
maxRange = ROOT.Double(0)
tf1.GetRange(minRange, maxRange)
return [minRange, maxRange]