FairShip
Loading...
Searching...
No Matches
muDIS_mergeFiles Namespace Reference

Functions

None merge ()
 
None hadd ()
 
None makePlots (sTree)
 
None test (str fn="test.root")
 

Variables

dict h = {}
 

Function Documentation

◆ hadd()

None muDIS_mergeFiles.hadd ( )

Definition at line 45 of file muDIS_mergeFiles.py.

45def hadd() -> None:
46 cmd = "hadd -f muonDIS.root "
47 for i in range(0, 12):
48 cmd += " muonDis_" + str(i) + ".root "
49 os.system(cmd)
50
51

◆ makePlots()

None muDIS_mergeFiles.makePlots (   sTree)

Definition at line 52 of file muDIS_mergeFiles.py.

52def makePlots(sTree) -> None:
53 ut.bookHist(h, "muP", "muon mom", 100, 0.0, 400.0)
54 ut.bookHist(h, "nOut", "outgoing part", 100, -0.5, 99.5)
55 ut.bookHist(h, "pos", "position", 100, -25.0, 100.0, 100, -12.0, 12.0, 100, -13.0, 13.0)
56 for n in range(sTree.GetEntries()):
57 sTree.GetEvent(n)
58 inMu = sTree.InMuon[0]
59 w = inMu[8]
60 P = ROOT.TMath.Sqrt(inMu[1] ** 2 + inMu[2] ** 2 + inMu[3] ** 2)
61 h["muP"].Fill(P, w)
62 h["nOut"].Fill(len(sTree.Particles))
63 h["pos"].Fill(inMu[7], inMu[5], inMu[6])
64
65

◆ merge()

None muDIS_mergeFiles.merge ( )

Definition at line 12 of file muDIS_mergeFiles.py.

12def merge() -> None:
13 sTree = ROOT.TChain("DIS")
14 for i in range(0, 12):
15 fn = "muonDis_" + str(i) + ".root"
16 sTree.AddFile(fn)
17 fm = ROOT.TFile("test.root", "recreate")
18 nTree = ROOT.TTree("DIS", "muon DIS")
19 iMuon = ROOT.TClonesArray("TVectorD")
20 iMuonBranch = nTree.Branch("InMuon", iMuon, 32000, -1)
21 dPart = ROOT.TClonesArray("TVectorD")
22 dPartBranch = nTree.Branch("Particles", dPart, 32000, -1)
23 for n in range(sTree.GetEntries()):
24 sTree.GetEvent(n)
25 dPart.Clear()
26 iMuon.Clear()
27 tca_vec = iMuon.ConstructedAt(0)
28 tca_vec.ResizeTo(sTree.InMuon[0])
29 ROOT.std.swap(tca_vec, sTree.InMuon[0])
30 for part in sTree.Particles:
31 nPart = len(dPart)
32 if dPart.GetSize() == nPart:
33 dPart.Expand(nPart + 10)
34 tca_vec = dPart.ConstructedAt(nPart)
35 tca_vec.ResizeTo(part)
36 ROOT.std.swap(tca_vec, part)
37 dPartBranch.Fill()
38 iMuonBranch.Fill()
39 nTree.Fill()
40 fm.cd()
41 nTree.Write()
42 fm.Close()
43
44

◆ test()

None muDIS_mergeFiles.test ( str   fn = "test.root")

Definition at line 66 of file muDIS_mergeFiles.py.

66def test(fn: str = "test.root") -> None:
67 fm = ROOT.TFile(fn)
68 sTree = fm.DIS
69 makePlots(sTree)

Variable Documentation

◆ h

dict muDIS_mergeFiles.h = {}

Definition at line 9 of file muDIS_mergeFiles.py.