ATLAS Offline Software
Classes | Functions
RPCRawDataMonUtils Namespace Reference

Classes

class  Panel
 

Functions

def creatGraph (xs, ys, x_errs, y_errs, g_name, g_title, g_Xtitle, g_Ytitle)
 
def linearFit (h_temp, opt="QNS+")
 return type values: 1 : normal 0 : fit fail or (Not exist this quantity of certain panel) -1 : number of points < 2 -2 : Chi2/NDF < 0.0001 -3 : NDF == 0 except the reason number of points <2 More...
 

Function Documentation

◆ creatGraph()

def RPCRawDataMonUtils.creatGraph (   xs,
  ys,
  x_errs,
  y_errs,
  g_name,
  g_title,
  g_Xtitle,
  g_Ytitle 
)

Definition at line 8 of file RPCRawDataMonUtils.py.

8 def creatGraph(xs, ys, x_errs, y_errs, g_name, g_title, g_Xtitle, g_Ytitle):
9  if len(xs) == 0:
10  return ROOT.TGraph()
11 
12  import array
13  x_arr = array.array("f",xs)
14  y_arr = array.array("f",ys)
15  x_err_arr = array.array("f",x_errs)
16  y_err_arr = array.array("f",y_errs)
17 
18  g1 = ROOT.TGraphErrors(len(x_arr),x_arr,y_arr, x_err_arr, y_err_arr)
19 
20  g1.SetNameTitle(g_name, g_title)
21  g1.SetMarkerSize(0.5)
22  g1.GetXaxis().SetTitle(g_Xtitle)
23  g1.GetYaxis().SetTitle(g_Ytitle)
24  g1.GetYaxis().SetRangeUser(0.8*min(y_arr),1.2*max(y_arr))
25 
26  return g1
27 

◆ linearFit()

def RPCRawDataMonUtils.linearFit (   h_temp,
  opt = "QNS+" 
)

return type values: 1 : normal 0 : fit fail or (Not exist this quantity of certain panel) -1 : number of points < 2 -2 : Chi2/NDF < 0.0001 -3 : NDF == 0 except the reason number of points <2

Definition at line 35 of file RPCRawDataMonUtils.py.

35 def linearFit(h_temp, opt="QNS+"):
36  default_dic = {"p0": 0., "p0_err":0., "p1": -1., "p1_err":-1., "chi2":-1., "mean":0., "mean_err":0.}
37  # Qtag, un-fit-able
38  # -1 -- null graph
39  # 0 -- normal
40  # 1 -- N points = 1
41  # 2 -- N points = 2
42  # 3 -- N points = 0
43 
44  Qtag = 0
45  if not h_temp:
46  Qtag = -1
47  return (Qtag, default_dic)
48 
49  if h_temp.GetN()< 2:
50  Qtag = 1
51  return (Qtag, default_dic)
52 
53  # fit_result = h_temp.Fit("pol1", opt, "", 0, 2.2)
54  fit_result = h_temp.Fit("pol1", opt)
55 
56  par_a = round(fit_result.Value(0), 2)
57  par_a_E = round(fit_result.ParError(0), 2)
58  par_b = round(fit_result.Value(1), 2)
59  par_b_E = round(fit_result.ParError(1), 2)
60 
61  if fit_result.Ndf() == 0:
62  Qtag = 2
63  chi2 = 0
64  else:
65  chi2 = round(fit_result.Chi2()/fit_result.Ndf(), 2)
66 
67  mean = round(h_temp.GetMean(2), 2)
68  mean_rms= round(h_temp.GetRMS(2), 2)
69 
70  dic = {"p0": par_a, "p0_err":par_a_E, "p1": par_b, "p1_err":par_b_E, "chi2":chi2, "mean":mean, "mean_err":mean_rms}
71  return (Qtag, dic)
72 
73 # ================================================================================================
max
#define max(a, b)
Definition: cfImp.cxx:41
MuonGM::round
float round(const float toRound, const unsigned int decimals)
Definition: Mdt.cxx:27
RPCRawDataMonUtils.creatGraph
def creatGraph(xs, ys, x_errs, y_errs, g_name, g_title, g_Xtitle, g_Ytitle)
Definition: RPCRawDataMonUtils.py:8
min
#define min(a, b)
Definition: cfImp.cxx:40
RPCRawDataMonUtils.linearFit
def linearFit(h_temp, opt="QNS+")
return type values: 1 : normal 0 : fit fail or (Not exist this quantity of certain panel) -1 : number...
Definition: RPCRawDataMonUtils.py:35