-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathMatPlotter.py
More file actions
61 lines (44 loc) · 1.86 KB
/
MatPlotter.py
File metadata and controls
61 lines (44 loc) · 1.86 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
import ROOT
import math
fIn=ROOT.TFile('MinBias3D_MC.root')
fOut=ROOT.TFile('RadLength.root', 'RECREATE')
ROOT.gStyle.SetOptStat(0)
ROOT.gROOT.SetBatch(ROOT.kTRUE)
# loop over histograms
for key in fIn.GetListOfKeys():
print key.GetName()
if not 'minus' in key.GetName(): continue
# take only the minus histograms fro the list
th3=ROOT.TH3
th3=fIn.Get(key.GetName())
triplet=[p for p in th3.GetName().split('_') if not 'minus' in p][0]
print triplet
#find the paired plus
th3pl=ROOT.TH3
th3pl=fIn.Get('sag3Dplus_'+triplet)
print th3.GetName(), th3pl.GetName()
# define TH1 to fill
slope=ROOT.TH1D("slope"+triplet, "slope"+triplet, 41, -4, 4)
radlength=ROOT.TH1D("radlength"+triplet, "radlength"+triplet, 41, -4, 4)
#loop over the x and y bins
for i in range(1, th3.GetNbinsX()+1):
rms=ROOT.TH1D("{i}".format(i=i), "{i}".format(i=i), 10, 0.5, 2.25);
for j in range(1, th3.GetNbinsY()+1):
th1=ROOT.TH1
th1pl=ROOT.TH1
th1=th3.ProjectionZ("binMinus_{i}_{j}".format(i=i,j=j), i, i, j, j)
th1pl=th3pl.ProjectionZ("binPlus_{i}_{j}".format(i=i,j=j), i, i, j, j)
mean=(1./2*(th1.GetRMS()+th1pl.GetRMS()))
mean_err=mean*math.sqrt(th1.GetRMSError()*th1.GetRMSError()+th1pl.GetRMSError()*th1pl.GetRMSError())
rms.SetBinContent(j, mean*mean)
rms.SetBinError(j, mean_err)
if(rms.GetEntries()<7): continue
fit=ROOT.TF1("fit", "pol1");
rms.Fit(fit, "Q");
slope.SetBinContent(i,fit.GetParameter(1))
slope.SetBinError(i, fit.GetParError(1))
radlength.SetBinContent(i,fit.GetParameter(0)/0.013/0.013)
radlength.SetBinError(i, fit.GetParError(0)/0.013/0.013)
radlength.GetXaxis().SetTitle("local #eta")
radlength.GetYaxis().SetTitle("x/X_{0}")
radlength.Write()