FairShip
Loading...
Searching...
No Matches
dumpEvent.py
Go to the documentation of this file.
1# SPDX-License-Identifier: LGPL-3.0-or-later
2# SPDX-FileCopyrightText: Copyright CERN for the benefit of the SHiP Collaboration
3
4# example for dumping an MC event
5
6import ROOT
7import shipunit as u
8
9PDG = ROOT.TDatabasePDG.Instance()
10
11
12def printMCTrack(n: int, MCTrack) -> None:
13 mcp = MCTrack[n]
14 print(
15 " %6i %7i %6.3F %6.3F %7.3F %7.3F %7.3F %7.3F %6i "
16 % (
17 n,
18 mcp.GetPdgCode(),
19 mcp.GetPx() / u.GeV,
20 mcp.GetPy() / u.GeV,
21 mcp.GetPz() / u.GeV,
22 mcp.GetStartX() / u.m,
23 mcp.GetStartY() / u.m,
24 mcp.GetStartZ() / u.m,
25 mcp.GetMotherId(),
26 )
27 )
28
29
30def dump(i, pcut) -> None:
31 tree = ROOT.gROOT.FindObjectAny("cbmsim")
32 tree.GetEntry(i)
33 print(" # pid px py pz vx vy vz mid")
34 n = -1
35 for mcp in tree.MCTrack:
36 n += 1
37 if mcp.GetP() / u.GeV < pcut:
38 continue
39 printMCTrack(n, tree.MCTrack)
40
41
42def dumpStraw(i) -> None:
43 tree = ROOT.gROOT.FindObjectAny("cbmsim")
44 tree.GetEntry(i)
45 for aStraw in tree.strawtubesPoint:
46 trID = aStraw.GetTrackID()
47 if not trID < 0:
48 printMCTrack(trID, tree.MCTrack)
None dumpStraw(i)
Definition dumpEvent.py:42
None printMCTrack(int n, MCTrack)
Definition dumpEvent.py:12
None dump(i, pcut)
Definition dumpEvent.py:30