SND@LHC Software
Loading...
Searching...
No Matches
muDIS_mergeFiles.py
Go to the documentation of this file.
1
import
ROOT,os
2
import
rootUtils
as
ut
3
h={}
4
def
merge
():
5
sTree = ROOT.TChain(
'DIS'
)
6
for
i
in
range(0,12):
7
fn =
"muonDis_"
+str(i)+
".root"
8
sTree.AddFile(fn)
9
fm = ROOT.TFile(
"test.root"
,
"recreate"
)
10
nTree = ROOT.TTree(
'DIS'
,
'muon DIS'
)
11
iMuon = ROOT.TClonesArray(
"TVectorD"
)
12
iMuonBranch = nTree.Branch(
"InMuon"
,iMuon,32000,-1)
13
dPart = ROOT.TClonesArray(
"TVectorD"
)
14
dPartBranch = nTree.Branch(
"Particles"
,dPart,32000,-1)
15
for
n
in
range(sTree.GetEntries()):
16
sTree.GetEvent(n)
17
dPart.Clear()
18
iMuon.Clear()
19
iMuon[0] = sTree.InMuon[0]
20
for
part
in
sTree.Particles:
21
nPart = dPart.GetEntries()
22
if
dPart.GetSize() == nPart: dPart.Expand(nPart+10)
23
dPart[nPart] = part
24
dPartBranch.Fill()
25
iMuonBranch.Fill()
26
nTree.Fill()
27
fm.cd()
28
nTree.Write()
29
fm.Close()
30
def
hadd
():
31
cmd =
'hadd -f muonDIS.root '
32
for
i
in
range(0,12):
33
cmd+=
" muonDis_"
+str(i)+
".root "
34
os.system(cmd)
35
def
makePlots
(sTree):
36
ut.bookHist(h,
'muP'
,
'muon mom'
,100,0.,400.)
37
ut.bookHist(h,
'nOut'
,
'outgoing part'
,100,-0.5,99.5)
38
ut.bookHist(h,
'pos'
,
'position'
,100,-25.,100.,100,-12.,12.,100,-13.,13.)
39
for
n
in
range(sTree.GetEntries()):
40
rc = sTree.GetEvent(n)
41
inMu = sTree.InMuon[0]
42
w = inMu[8]
43
P = ROOT.TMath.Sqrt(inMu[1]**2+inMu[2]**2+inMu[3]**2)
44
rc = h[
'muP'
].Fill(P,w)
45
rc = h[
'nOut'
].Fill(sTree.Particles.GetEntries() )
46
rc = h[
'pos'
].Fill(inMu[7],inMu[5],inMu[6] )
47
def
test
(fn = "test.root"):
48
fm = ROOT.TFile(fn)
49
sTree = fm.DIS
50
makePlots
(sTree)
51
52
muDIS_mergeFiles.hadd
hadd()
Definition
muDIS_mergeFiles.py:30
muDIS_mergeFiles.test
test(fn="test.root")
Definition
muDIS_mergeFiles.py:47
muDIS_mergeFiles.merge
merge()
Definition
muDIS_mergeFiles.py:4
muDIS_mergeFiles.makePlots
makePlots(sTree)
Definition
muDIS_mergeFiles.py:35
muonShieldOptimization
muDIS_mergeFiles.py
Generated by
1.9.8