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 ShipGeoConfig
8import shipunit as u
9
10ship_geo = ShipGeoConfig.Config().loadpy("$FAIRSHIP/geometry/geometry_config.py")
11PDG = ROOT.TDatabasePDG.Instance()
12
13
14def printMCTrack(n: int, MCTrack) -> None:
15 mcp = MCTrack[n]
16 print(
17 " %6i %7i %6.3F %6.3F %7.3F %7.3F %7.3F %7.3F %6i "
18 % (
19 n,
20 mcp.GetPdgCode(),
21 mcp.GetPx() / u.GeV,
22 mcp.GetPy() / u.GeV,
23 mcp.GetPz() / u.GeV,
24 mcp.GetStartX() / u.m,
25 mcp.GetStartY() / u.m,
26 mcp.GetStartZ() / u.m,
27 mcp.GetMotherId(),
28 )
29 )
30
31
32def dump(i, pcut) -> None:
33 tree = ROOT.gROOT.FindObjectAny("cbmsim")
34 tree.GetEntry(i)
35 print(" # pid px py pz vx vy vz mid")
36 n = -1
37 for mcp in tree.MCTrack:
38 n += 1
39 if mcp.GetP() / u.GeV < pcut:
40 continue
41 printMCTrack(n, tree.MCTrack)
42
43
44def dumpStraw(i) -> None:
45 tree = ROOT.gROOT.FindObjectAny("cbmsim")
46 tree.GetEntry(i)
47 for aStraw in tree.strawtubesPoint:
48 trID = aStraw.GetTrackID()
49 if not trID < 0:
50 printMCTrack(trID, tree.MCTrack)
None dumpStraw(i)
Definition: dumpEvent.py:44
None printMCTrack(int n, MCTrack)
Definition: dumpEvent.py:14
None dump(i, pcut)
Definition: dumpEvent.py:32