Repository navigation
Expand file tree
/
Copy pathsourceStabilityAnalysis.py
More file actions
65 lines (53 loc) · 1.99 KB
/
Copy pathsourceStabilityAnalysis.py
File metadata and controls
65 lines (53 loc) · 1.99 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
56
57
58
59
60
61
62
63
64
65
import ROOT as R
import math as m
import numpy as np
import time
import os
from array import array
def Map(tf):
"""
Maps objets as dict[obj_name][0] using a TFile (tf) and TObject to browse.
"""
m = {}
for k in tf.GetListOfKeys():
n = k.GetName()
m[n] = tf.Get(n)
return m
R.gROOT.SetBatch(1)
import argparse
parser = argparse.ArgumentParser()
parser.add_argument('--input',dest='input')
#parser.add_argument('--output',dest='output')
args = parser.parse_args()
import glob
files=glob.glob("SourceAnalysis/SourceAnalysis_"+args.input+"*.root")
from array import array
ly, ly_err, lyres, lyres_err = array('d'), array('d'), array('d'), array('d')
for file in files:
f=R.TFile(file)
his=Map(f)
for h in his:
if 'charge_' in h:
fTot=his[h].GetFunction("fTot")
# if (fTot.GetParameter(10)>20000):
# continue
ly.append(fTot.GetParameter(10))
ly_err.append(fTot.GetParError(10))
lyres.append(fTot.GetParameter(11)/fTot.GetParameter(10))
lyres_err.append(fTot.GetParError(11)/fTot.GetParameter(10))
lyArray=np.array(ly)
lyResArray=np.array(lyres)
histos={}
c=R.TCanvas("c","c",900,700)
histos['ly']=R.TH1F('ly_'+args.input,'ly_'+args.input,10,1-5*lyArray.std()/lyArray.mean(),1+5*lyArray.std()/lyArray.mean())
for val in lyArray:
histos['ly'].Fill(val/lyArray.mean())
histos['ly'].Draw()
for ext in ['png','pdf']:
c.SaveAs("SourceAnalysis/lyStability_"+ args.input +"."+ext)
histos['lyRes']=R.TH1F('lyRes_'+args.input,'lyRes_'+args.input,60,1-5*lyResArray.std()/lyResArray.mean(),1+5*lyResArray.std()/lyResArray.mean())
for val in lyResArray:
histos['lyRes'].Fill(val/lyResArray.mean())
histos['lyRes'].Draw()
for ext in ['png','pdf']:
c.SaveAs("SourceAnalysis/lyResStability_"+ args.input +"."+ext)