Skip to content
Snippets Groups Projects

Resolve "Add true decaying particle info onto event display"

Merged Jihee Kim requested to merge 43-add-true-decaying-particle-info-onto-event-display into master
@@ -149,19 +149,20 @@ if __name__ == '__main__':
@@ -149,19 +149,20 @@ if __name__ == '__main__':
# Read all mc particles
# Read all mc particles
dfallmcp = get_all_mcp(args.file, args.iev, 'mcparticles2')
dfallmcp = get_all_mcp(args.file, args.iev, 'mcparticles2')
 
pdgbase = ROOT.TDatabasePDG()
# Select decaying particles
# Select decaying particles
dftemp = dfallmcp[dfallmcp['g4Parent'] == 1.0]
dftemp = dfallmcp[dfallmcp['g4Parent'] == 1.0]
dfdecaymcp = dftemp.copy()
if len(dftemp) > 0:
pdgbase = ROOT.TDatabasePDG()
dfdecaymcp = dftemp.copy()
for iptl in [0, len(dfdecaymcp) - 1]:
for iptl in [0, len(dfdecaymcp) - 1]:
infoptl = pdgbase.GetParticle(int(dfdecaymcp['pid'].iloc[iptl]))
infoptl = pdgbase.GetParticle(int(dfdecaymcp['pid'].iloc[iptl]))
print("{} Decaying particle = {}, pdgcode = {}, charge = {}, mass = {}"\
print("{} Decaying particle = {}, pdgcode = {}, charge = {}, mass = {}"\
.format(iptl, infoptl.GetName(), infoptl.PdgCode(), infoptl.Charge(), infoptl.Mass()))
.format(iptl, infoptl.GetName(), infoptl.PdgCode(), infoptl.Charge(), infoptl.Mass()))
# Calculate geometric variables of decaying particles
# Calculate geometric variables of decaying particles
dfdecaymcp['r'] = np.sqrt(dfdecaymcp['vex'].values**2 + dfdecaymcp['vey'].values**2 + dfdecaymcp['vez'].values**2)
dfdecaymcp['r'] = np.sqrt(dfdecaymcp['vex'].values**2 + dfdecaymcp['vey'].values**2 + dfdecaymcp['vez'].values**2)
dfdecaymcp['phi'] = np.arctan2(dfdecaymcp['vey'].values, dfdecaymcp['vex'].values)*1000.
dfdecaymcp['phi'] = np.arctan2(dfdecaymcp['vey'].values, dfdecaymcp['vex'].values)*1000.
dfdecaymcp['theta'] = np.arccos(dfdecaymcp['vez'].values/dfdecaymcp['r'].values)*1000.
dfdecaymcp['theta'] = np.arccos(dfdecaymcp['vez'].values/dfdecaymcp['r'].values)*1000.
dfdecaymcp['eta'] = -np.log(np.tan(dfdecaymcp['theta'].values/1000./2.))
dfdecaymcp['eta'] = -np.log(np.tan(dfdecaymcp['theta'].values/1000./2.))
# truth
# truth
dfmcp = get_mcp_simple(args.file, args.iev, 'mcparticles2').iloc[0]
dfmcp = get_mcp_simple(args.file, args.iev, 'mcparticles2').iloc[0]
@@ -237,7 +238,8 @@ if __name__ == '__main__':
@@ -237,7 +238,8 @@ if __name__ == '__main__':
bins=(np.arange(*eta_rg, step=args.topo_size/1000.), np.arange(*phi_rg, step=args.topo_size)),
bins=(np.arange(*eta_rg, step=args.topo_size/1000.), np.arange(*phi_rg, step=args.topo_size)),
cmap=cmap, cmin=0., pc_kw=dict(alpha=0.8, edgecolor='k'))
cmap=cmap, cmin=0., pc_kw=dict(alpha=0.8, edgecolor='k'))
# draw true decaying particle position
# draw true decaying particle position
ax.scatter(dfdecaymcp['eta'].values, dfdecaymcp['phi'].values, marker='x', color='red', s=22**2, linewidth=5.0)
if len(dfdecaymcp) > 0:
 
ax.scatter(dfdecaymcp['eta'].values, dfdecaymcp['phi'].values, marker='x', color='red', s=22**2, linewidth=5.0)
ax.set_ylabel(r'$\phi$ (mrad)', fontsize=32)
ax.set_ylabel(r'$\phi$ (mrad)', fontsize=32)
ax.set_xlabel(r'$\eta$', fontsize=32)
ax.set_xlabel(r'$\eta$', fontsize=32)
Loading