FairShip
Loading...
Searching...
No Matches
make_nTuple_Tr 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 = "SelectedMuonsTr_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 = {}
dict events_ = {"Tr": {}, "Tr_SBT": {}, "Tr_noSBT": {}}
int global_event_nr = 0
dict processed_events = {}
int P_threshold = 3
list headers
 f = None
 tree = f["cbmsim"]
dict nmu = {"mu+": 0, "mu-": 0}
list muon_table = []
list muon_ids = []
 trackingstation_id = hit.GetStationNumber()
 pid = hit.PdgCode()
 P = r.TMath.Sqrt(hit.GetPx() ** 2 + hit.GetPy() ** 2 + hit.GetPz() ** 2)
 track_id = hit.GetTrackID()
 _p = ut.get_particle(hit.PdgCode())
 particle_name = _p.GetName()
 detID = hit.GetDetectorID()
int ubt_index = 0
 Pt = r.TMath.Sqrt(hit.GetPx() ** 2 + hit.GetPy() ** 2)
 weight = event.MCTrack[track_id].GetWeight()
 total_muons = sum(len(muons) for muons in events_[type_].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 1st Tracking Station (including soft interaction products) to a ROOT file.

Function Documentation

◆ dump()

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

Definition at line 142 of file make_nTuple_Tr.py.

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

◆ printMCTrack()

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

Definition at line 91 of file make_nTuple_Tr.py.

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

Variable Documentation

◆ _p

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

Definition at line 248 of file make_nTuple_Tr.py.

◆ action

make_nTuple_Tr.action

Definition at line 24 of file make_nTuple_Tr.py.

◆ args

make_nTuple_Tr.args = parser.parse_args()

Definition at line 37 of file make_nTuple_Tr.py.

◆ csvwriter

make_nTuple_Tr.csvwriter = csv.writer(fsel)

Definition at line 50 of file make_nTuple_Tr.py.

◆ default

make_nTuple_Tr.default

Definition at line 28 of file make_nTuple_Tr.py.

◆ dest

make_nTuple_Tr.dest

Definition at line 24 of file make_nTuple_Tr.py.

◆ detID

make_nTuple_Tr.detID = hit.GetDetectorID()

Definition at line 269 of file make_nTuple_Tr.py.

◆ event_data

list make_nTuple_Tr.event_data = []

Definition at line 388 of file make_nTuple_Tr.py.

◆ events_

dict make_nTuple_Tr.events_ = {"Tr": {}, "Tr_SBT": {}, "Tr_noSBT": {}}

Definition at line 190 of file make_nTuple_Tr.py.

◆ f

make_nTuple_Tr.f = None

Definition at line 219 of file make_nTuple_Tr.py.

◆ fsel

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

Definition at line 49 of file make_nTuple_Tr.py.

◆ global_event_nr

int make_nTuple_Tr.global_event_nr = 0

Definition at line 191 of file make_nTuple_Tr.py.

◆ h

dict make_nTuple_Tr.h = {}

Definition at line 67 of file make_nTuple_Tr.py.

◆ headers

list make_nTuple_Tr.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 196 of file make_nTuple_Tr.py.

◆ help

make_nTuple_Tr.help

Definition at line 24 of file make_nTuple_Tr.py.

◆ imuondata

make_nTuple_Tr.imuondata = r.TVectorD(10)

Definition at line 55 of file make_nTuple_Tr.py.

◆ level

make_nTuple_Tr.level

Definition at line 20 of file make_nTuple_Tr.py.

◆ muon_ids

list make_nTuple_Tr.muon_ids = []

Definition at line 239 of file make_nTuple_Tr.py.

◆ muon_table

list make_nTuple_Tr.muon_table = []

Definition at line 236 of file make_nTuple_Tr.py.

◆ muon_UpstreamTaggerPoints

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

Definition at line 64 of file make_nTuple_Tr.py.

◆ muon_vetoPoints

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

Definition at line 61 of file make_nTuple_Tr.py.

◆ nmu

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

Definition at line 234 of file make_nTuple_Tr.py.

◆ nmuons

make_nTuple_Tr.nmuons = imuondata[9]

Definition at line 411 of file make_nTuple_Tr.py.

◆ num_muonhits

make_nTuple_Tr.num_muonhits = len(event.muon_vetoPoints)

Definition at line 414 of file make_nTuple_Tr.py.

◆ num_tracks

make_nTuple_Tr.num_tracks = len(event.tracks)

Definition at line 413 of file make_nTuple_Tr.py.

◆ num_ubthits

make_nTuple_Tr.num_ubthits = len(event.muon_UpstreamTaggerPoints)

Definition at line 415 of file make_nTuple_Tr.py.

◆ output_file

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

Definition at line 52 of file make_nTuple_Tr.py.

◆ output_tree

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

Definition at line 53 of file make_nTuple_Tr.py.

◆ outputfile

make_nTuple_Tr.outputfile

Definition at line 41 of file make_nTuple_Tr.py.

◆ P

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

Definition at line 245 of file make_nTuple_Tr.py.

◆ P_threshold

int make_nTuple_Tr.P_threshold = 3

Definition at line 194 of file make_nTuple_Tr.py.

◆ parser

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

Definition at line 23 of file make_nTuple_Tr.py.

◆ particle_name

make_nTuple_Tr.particle_name = _p.GetName()

Definition at line 249 of file make_nTuple_Tr.py.

◆ path

make_nTuple_Tr.path = args.path

Definition at line 46 of file make_nTuple_Tr.py.

◆ pdg

make_nTuple_Tr.pdg = r.TDatabasePDG.Instance()

Definition at line 17 of file make_nTuple_Tr.py.

◆ pid

make_nTuple_Tr.pid = hit.PdgCode()

Definition at line 244 of file make_nTuple_Tr.py.

◆ processed_events

dict make_nTuple_Tr.processed_events = {}

Definition at line 192 of file make_nTuple_Tr.py.

◆ Pt

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

Definition at line 305 of file make_nTuple_Tr.py.

◆ px

make_nTuple_Tr.px = imuondata[1]

Definition at line 402 of file make_nTuple_Tr.py.

◆ py

make_nTuple_Tr.py = imuondata[2]

Definition at line 403 of file make_nTuple_Tr.py.

◆ pz

make_nTuple_Tr.pz = imuondata[3]

Definition at line 404 of file make_nTuple_Tr.py.

◆ selectedmuons

str make_nTuple_Tr.selectedmuons = "SelectedMuonsTr_test.txt"

Definition at line 42 of file make_nTuple_Tr.py.

◆ time_hit

make_nTuple_Tr.time_hit = imuondata[8]

Definition at line 410 of file make_nTuple_Tr.py.

◆ total_muons

make_nTuple_Tr.total_muons = sum(len(muons) for muons in events_[type_].values())

Definition at line 373 of file make_nTuple_Tr.py.

◆ track_array

make_nTuple_Tr.track_array = r.TObjArray()

Definition at line 58 of file make_nTuple_Tr.py.

◆ track_id

make_nTuple_Tr.track_id = hit.GetTrackID()

Definition at line 247 of file make_nTuple_Tr.py.

◆ trackingstation_id

make_nTuple_Tr.trackingstation_id = hit.GetStationNumber()

Definition at line 243 of file make_nTuple_Tr.py.

◆ tree

make_nTuple_Tr.tree = f["cbmsim"]

Definition at line 225 of file make_nTuple_Tr.py.

◆ ubt_index

int make_nTuple_Tr.ubt_index = 0

Definition at line 288 of file make_nTuple_Tr.py.

◆ weight

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

Definition at line 331 of file make_nTuple_Tr.py.

◆ x

make_nTuple_Tr.x = imuondata[4]

Definition at line 405 of file make_nTuple_Tr.py.

◆ y

make_nTuple_Tr.y = imuondata[5]

Definition at line 406 of file make_nTuple_Tr.py.

◆ z

make_nTuple_Tr.z = imuondata[6]

Definition at line 407 of file make_nTuple_Tr.py.