Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2025-08-05 08:11:20

0001 from sigmaEff import *
0002 import numpy as np
0003 from ROOT import *
0004 
0005 # Path: analysis_INTT/plot/testSigmaEff.py
0006 # test sigma eff 
0007 # generate 20000 random numbers according to Gaussian distribution with mean 0 and sigma 1 
0008 # and calculate the sigma eff with different threshold
0009 
0010 # generate 20000 random numbers according to Gaussian distribution with mean 0 and sigma 1
0011 np.random.seed(0)
0012 v = np.random.normal(0, 1, 20000)
0013 print ('v: {}'.format(v))
0014 
0015 # calculate the sigma eff with different threshold
0016 xmin, xmax = minimum_size_range(v, 68.5)
0017 print (xmin, xmax) 
0018 
0019 # Draw the histogram
0020 c = TCanvas('c', 'c', 800, 600)
0021 h = TH1F('h', 'h', 100, -5, 5)
0022 for i in range(0, 20000):
0023     h.Fill(v[i])
0024 h.SetLineColor(kBlack)
0025 h.SetLineWidth(2)
0026 h.SetStats(0)
0027 h.Draw('hist')
0028 # Draw the sigma eff range
0029 l1 = TLine(xmin, 0, xmin, 1000)
0030 l1.SetLineColor(kRed)
0031 l1.SetLineWidth(2)
0032 l1.Draw()
0033 l2 = TLine(xmax, 0, xmax, 1000)
0034 l2.SetLineColor(kRed)
0035 l2.SetLineWidth(2)
0036 l2.Draw()
0037 
0038 c.SaveAs('testSigmaEff.png')
0039 c.SaveAs('testSigmaEff.pdf')
0040 
0041