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

Functions

None printMCTrack (int n, MCTrack)
None dump (event, float pcut=0, bool print_whole_event=True)

Variables

 pdg = r.TDatabasePDG.Instance()
 level
 parser = argparse.ArgumentParser(description=__doc__)
 dest
 help
 action
 default
 args = parser.parse_args()
 outputfile
str selectedmuons = "SelectedMuonsSBT_test.txt"
 path = args.path
 fsel = open(selectedmuons, "w")
 csvwriter = csv.writer(fsel)
 output_file = r.TFile.Open(args.outputfile, "recreate")
 output_tree = r.TTree("MuonAndSoftInteractions", "Muon information and soft interaction tracks")
 imuondata = r.TVectorD(10)
 track_array = r.TObjArray()
 muon_vetoPoints = r.TClonesArray("vetoPoint")
 muon_UpstreamTaggerPoints = r.TClonesArray("UpstreamTaggerPoint")
dict h = {}
int global_event_nr = 0
dict processed_events = {}
int P_threshold = 3
list headers
 f = None
 tree = f["cbmsim"]
list muon_table = []
dict nmu = {"mu+": 0, "mu-": 0}
list muon_ids = []
dict muon_hits = {}
 detID = hit.GetDetectorID()
 pid = hit.PdgCode()
 track_id = hit.GetTrackID()
 P = r.TMath.Sqrt(hit.GetPx() ** 2 + hit.GetPy() ** 2 + hit.GetPz() ** 2)
 _p = ut.get_particle(hit.PdgCode())
 particle_name = _p.GetName()
int ubt_index = 0
int index = 0
 Pt = r.TMath.Sqrt(hit.GetPx() ** 2 + hit.GetPy() ** 2)
 weight = event.MCTrack[track_id].GetWeight()
 total_muons = sum(len(values) for values in processed_events.values())
list event_data = []
 px = imuondata[1]
 py = imuondata[2]
 pz = imuondata[3]
 x = imuondata[4]
 y = imuondata[5]
 z = imuondata[6]
 time_hit = imuondata[8]
 nmuons = imuondata[9]
 num_tracks = len(event.tracks)
 num_muonhits = len(event.muon_vetoPoints)
 num_ubthits = len(event.muon_UpstreamTaggerPoints)

Detailed Description

Script to collect muons hitting the SBT (including soft interaction products) to a ROOT file.

Function Documentation

◆ dump()

None make_nTuple_SBT.dump ( event,
float pcut = 0,
bool print_whole_event = True )
Dump the whole event.

Definition at line 143 of file make_nTuple_SBT.py.

143def dump(event, pcut: float = 0, print_whole_event: bool = True) -> None:
144 """Dump the whole event."""
145 if print_whole_event:
146 print(
147 "\n %6s %-10s %10s %6s %6s %7s %7s %7s %7s %6s %10s %18s"
148 % (
149 "#",
150 "particle",
151 "pid",
152 "px",
153 "py",
154 "pz",
155 "vx",
156 "vy",
157 "vz",
158 "mid",
159 "w",
160 "Process",
161 )
162 )
163 print(
164 " %6s %10s %10s %6s %6s %7s %7s %7s %7s %6s %10s %18s\n "
165 % (
166 " ",
167 "--------",
168 "---",
169 "--",
170 "--",
171 "--",
172 "--",
173 "--",
174 "--",
175 "---",
176 "---",
177 "-------",
178 )
179 )
180 n = -1
181 for mcp in event.MCTrack:
182 n += 1
183 if mcp.GetP() / u.GeV < pcut:
184 continue
185 if print_whole_event:
186 printMCTrack(n, event.MCTrack)
187
188 return
189
190

◆ printMCTrack()

None make_nTuple_SBT.printMCTrack ( int n,
MCTrack )
Print MCTrack truth.

Definition at line 92 of file make_nTuple_SBT.py.

92def printMCTrack(n: int, MCTrack) -> None:
93 """Print MCTrack truth."""
94 mcp = MCTrack[n]
95
96 RED = "\033[91m" # ANSI code Red
97 RESET = "\033[0m" # ANSI code Reset to default
98
99 try:
100 _p = ut.get_particle(mcp.GetPdgCode())
101 particle_name = _p.GetName()
102
103 if particle_name == "mu+" or particle_name == "mu-":
104 particle_name = f"{RED}{particle_name}{RESET} " # Highlight muons in red
105
106 print(
107 " %6s %-10s %10i %6.3F %6.3F %7.3F %7.3F %7.3F %7.3F %6s %10.3F %28s"
108 % (
109 n,
110 particle_name,
111 mcp.GetPdgCode(),
112 mcp.GetPx() / u.GeV,
113 mcp.GetPy() / u.GeV,
114 mcp.GetPz() / u.GeV,
115 mcp.GetStartX() / u.m,
116 mcp.GetStartY() / u.m,
117 mcp.GetStartZ() / u.m,
118 mcp.GetMotherId(),
119 mcp.GetWeight(),
120 mcp.GetProcName().Data(),
121 )
122 )
123 except Exception:
124 print(
125 " %6s %-10s %10i %6.3F %6.3F %7.3F %7.3F %7.3F %7.3F %6s %10.3F %28s"
126 % (
127 n,
128 "----",
129 mcp.GetPdgCode(),
130 mcp.GetPx() / u.GeV,
131 mcp.GetPy() / u.GeV,
132 mcp.GetPz() / u.GeV,
133 mcp.GetStartX() / u.m,
134 mcp.GetStartY() / u.m,
135 mcp.GetStartZ() / u.m,
136 mcp.GetMotherId(),
137 mcp.GetWeight(),
138 mcp.GetProcName().Data(),
139 )
140 )
141
142

Variable Documentation

◆ _p

make_nTuple_SBT._p = ut.get_particle(hit.PdgCode())
protected

Definition at line 251 of file make_nTuple_SBT.py.

◆ action

make_nTuple_SBT.action

Definition at line 24 of file make_nTuple_SBT.py.

◆ args

make_nTuple_SBT.args = parser.parse_args()

Definition at line 37 of file make_nTuple_SBT.py.

◆ csvwriter

make_nTuple_SBT.csvwriter = csv.writer(fsel)

Definition at line 50 of file make_nTuple_SBT.py.

◆ default

make_nTuple_SBT.default

Definition at line 28 of file make_nTuple_SBT.py.

◆ dest

make_nTuple_SBT.dest

Definition at line 24 of file make_nTuple_SBT.py.

◆ detID

make_nTuple_SBT.detID = hit.GetDetectorID()

Definition at line 245 of file make_nTuple_SBT.py.

◆ event_data

list make_nTuple_SBT.event_data = []

Definition at line 379 of file make_nTuple_SBT.py.

◆ f

make_nTuple_SBT.f = None

Definition at line 220 of file make_nTuple_SBT.py.

◆ fsel

make_nTuple_SBT.fsel = open(selectedmuons, "w")

Definition at line 49 of file make_nTuple_SBT.py.

◆ global_event_nr

int make_nTuple_SBT.global_event_nr = 0

Definition at line 191 of file make_nTuple_SBT.py.

◆ h

dict make_nTuple_SBT.h = {}

Definition at line 67 of file make_nTuple_SBT.py.

◆ headers

list make_nTuple_SBT.headers
Initial value:
1= [
2 f"nMuons in event>{P_threshold}GeV",
3 "Muon PID",
4 "Momentum[GeV/c]",
5 "x[m]",
6 "y[m]",
7 "z[m]",
8 "t_muon [ns]",
9 "nSoft Tracks",
10 "nSBT Hits(muon)",
11 "nUBT Hits(muon)",
12 "Weight_muon",
13]

Definition at line 195 of file make_nTuple_SBT.py.

◆ help

make_nTuple_SBT.help

Definition at line 24 of file make_nTuple_SBT.py.

◆ imuondata

make_nTuple_SBT.imuondata = r.TVectorD(10)

Definition at line 55 of file make_nTuple_SBT.py.

◆ index

int make_nTuple_SBT.index = 0

Definition at line 291 of file make_nTuple_SBT.py.

◆ level

make_nTuple_SBT.level

Definition at line 20 of file make_nTuple_SBT.py.

◆ muon_hits

dict make_nTuple_SBT.muon_hits = {}

Definition at line 242 of file make_nTuple_SBT.py.

◆ muon_ids

list make_nTuple_SBT.muon_ids = []

Definition at line 241 of file make_nTuple_SBT.py.

◆ muon_table

list make_nTuple_SBT.muon_table = []

Definition at line 237 of file make_nTuple_SBT.py.

◆ muon_UpstreamTaggerPoints

make_nTuple_SBT.muon_UpstreamTaggerPoints = r.TClonesArray("UpstreamTaggerPoint")

Definition at line 64 of file make_nTuple_SBT.py.

◆ muon_vetoPoints

make_nTuple_SBT.muon_vetoPoints = r.TClonesArray("vetoPoint")

Definition at line 61 of file make_nTuple_SBT.py.

◆ nmu

dict make_nTuple_SBT.nmu = {"mu+": 0, "mu-": 0}

Definition at line 239 of file make_nTuple_SBT.py.

◆ nmuons

make_nTuple_SBT.nmuons = imuondata[9]

Definition at line 402 of file make_nTuple_SBT.py.

◆ num_muonhits

make_nTuple_SBT.num_muonhits = len(event.muon_vetoPoints)

Definition at line 405 of file make_nTuple_SBT.py.

◆ num_tracks

make_nTuple_SBT.num_tracks = len(event.tracks)

Definition at line 404 of file make_nTuple_SBT.py.

◆ num_ubthits

make_nTuple_SBT.num_ubthits = len(event.muon_UpstreamTaggerPoints)

Definition at line 406 of file make_nTuple_SBT.py.

◆ output_file

make_nTuple_SBT.output_file = r.TFile.Open(args.outputfile, "recreate")

Definition at line 52 of file make_nTuple_SBT.py.

◆ output_tree

make_nTuple_SBT.output_tree = r.TTree("MuonAndSoftInteractions", "Muon information and soft interaction tracks")

Definition at line 53 of file make_nTuple_SBT.py.

◆ outputfile

make_nTuple_SBT.outputfile

Definition at line 41 of file make_nTuple_SBT.py.

◆ P

make_nTuple_SBT.P = r.TMath.Sqrt(hit.GetPx() ** 2 + hit.GetPy() ** 2 + hit.GetPz() ** 2)

Definition at line 248 of file make_nTuple_SBT.py.

◆ P_threshold

int make_nTuple_SBT.P_threshold = 3

Definition at line 193 of file make_nTuple_SBT.py.

◆ parser

make_nTuple_SBT.parser = argparse.ArgumentParser(description=__doc__)

Definition at line 23 of file make_nTuple_SBT.py.

◆ particle_name

make_nTuple_SBT.particle_name = _p.GetName()

Definition at line 252 of file make_nTuple_SBT.py.

◆ path

make_nTuple_SBT.path = args.path

Definition at line 46 of file make_nTuple_SBT.py.

◆ pdg

make_nTuple_SBT.pdg = r.TDatabasePDG.Instance()

Definition at line 17 of file make_nTuple_SBT.py.

◆ pid

make_nTuple_SBT.pid = hit.PdgCode()

Definition at line 246 of file make_nTuple_SBT.py.

◆ processed_events

dict make_nTuple_SBT.processed_events = {}

Definition at line 192 of file make_nTuple_SBT.py.

◆ Pt

make_nTuple_SBT.Pt = r.TMath.Sqrt(hit.GetPx() ** 2 + hit.GetPy() ** 2)

Definition at line 301 of file make_nTuple_SBT.py.

◆ px

make_nTuple_SBT.px = imuondata[1]

Definition at line 393 of file make_nTuple_SBT.py.

◆ py

make_nTuple_SBT.py = imuondata[2]

Definition at line 394 of file make_nTuple_SBT.py.

◆ pz

make_nTuple_SBT.pz = imuondata[3]

Definition at line 395 of file make_nTuple_SBT.py.

◆ selectedmuons

str make_nTuple_SBT.selectedmuons = "SelectedMuonsSBT_test.txt"

Definition at line 42 of file make_nTuple_SBT.py.

◆ time_hit

make_nTuple_SBT.time_hit = imuondata[8]

Definition at line 401 of file make_nTuple_SBT.py.

◆ total_muons

make_nTuple_SBT.total_muons = sum(len(values) for values in processed_events.values())

Definition at line 363 of file make_nTuple_SBT.py.

◆ track_array

make_nTuple_SBT.track_array = r.TObjArray()

Definition at line 58 of file make_nTuple_SBT.py.

◆ track_id

make_nTuple_SBT.track_id = hit.GetTrackID()

Definition at line 247 of file make_nTuple_SBT.py.

◆ tree

make_nTuple_SBT.tree = f["cbmsim"]

Definition at line 226 of file make_nTuple_SBT.py.

◆ ubt_index

int make_nTuple_SBT.ubt_index = 0

Definition at line 279 of file make_nTuple_SBT.py.

◆ weight

make_nTuple_SBT.weight = event.MCTrack[track_id].GetWeight()

Definition at line 311 of file make_nTuple_SBT.py.

◆ x

make_nTuple_SBT.x = imuondata[4]

Definition at line 396 of file make_nTuple_SBT.py.

◆ y

make_nTuple_SBT.y = imuondata[5]

Definition at line 397 of file make_nTuple_SBT.py.

◆ z

make_nTuple_SBT.z = imuondata[6]

Definition at line 398 of file make_nTuple_SBT.py.