Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
testSigmaEff.py
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file testSigmaEff.py
1 from sigmaEff import *
2 import numpy as np
3 from ROOT import *
4 
5 # Path: analysis_INTT/plot/testSigmaEff.py
6 # test sigma eff
7 # generate 20000 random numbers according to Gaussian distribution with mean 0 and sigma 1
8 # and calculate the sigma eff with different threshold
9 
10 # generate 20000 random numbers according to Gaussian distribution with mean 0 and sigma 1
11 np.random.seed(0)
12 v = np.random.normal(0, 1, 20000)
13 print ('v: {}'.format(v))
14 
15 # calculate the sigma eff with different threshold
16 xmin, xmax = minimum_size_range(v, 68.5)
17 print (xmin, xmax)
18 
19 # Draw the histogram
20 c = TCanvas('c', 'c', 800, 600)
21 h = TH1F('h', 'h', 100, -5, 5)
22 for i in range(0, 20000):
23  h.Fill(v[i])
24 h.SetLineColor(kBlack)
25 h.SetLineWidth(2)
26 h.SetStats(0)
27 h.Draw('hist')
28 # Draw the sigma eff range
29 l1 = TLine(xmin, 0, xmin, 1000)
30 l1.SetLineColor(kRed)
31 l1.SetLineWidth(2)
32 l1.Draw()
33 l2 = TLine(xmax, 0, xmax, 1000)
34 l2.SetLineColor(kRed)
35 l2.SetLineWidth(2)
36 l2.Draw()
37 
38 c.SaveAs('testSigmaEff.png')
39 c.SaveAs('testSigmaEff.pdf')
40 
41