diff --git a/benchmarks/imaging_ecal/scripts/draw_cluster.py b/benchmarks/imaging_ecal/scripts/draw_cluster.py index 6ad5c05a8a4de79cceda1b2ef032fb294188df85..02cc76832e35ee34230edb253f2720a4571ef311 100644 --- a/benchmarks/imaging_ecal/scripts/draw_cluster.py +++ b/benchmarks/imaging_ecal/scripts/draw_cluster.py @@ -156,8 +156,12 @@ if __name__ == '__main__': dfdecaymcp = dftemp.copy() for iptl in [0, len(dfdecaymcp) - 1]: infoptl = pdgbase.GetParticle(int(dfdecaymcp['pid'].iloc[iptl])) - print("{} Decaying particle = {}, pdgcode = {}, charge = {}, mass = {}"\ - .format(iptl, infoptl.GetName(), infoptl.PdgCode(), infoptl.Charge(), infoptl.Mass())) + if infoptl: + print("{} Decaying particle = {}, pdgcode = {}, charge = {}, mass = {}"\ + .format(iptl, infoptl.GetName(), infoptl.PdgCode(), infoptl.Charge(), infoptl.Mass())) + else: + print("{} Decaying particle unknown pdgcode {}"\ + .format(iptl, int(dfdecaymcp['pid'].iloc[iptl]))) # Calculate geometric variables of decaying particles 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. @@ -168,8 +172,12 @@ if __name__ == '__main__': dfmcp = get_mcp_simple(args.file, args.iev, 'mcparticles').iloc[0] #pdgbase = ROOT.TDatabasePDG() inpart = pdgbase.GetParticle(int(dfmcp['pid'])) - print("Incoming particle = {}, pdgcode = {}, charge = {}, mass = {}"\ - .format(inpart.GetName(), inpart.PdgCode(), inpart.Charge(), inpart.Mass())) + if inpart: + print("Incoming particle = {}, pdgcode = {}, charge = {}, mass = {}"\ + .format(inpart.GetName(), inpart.PdgCode(), inpart.Charge(), inpart.Mass())) + else: + print("Incoming particle unknown pdgcode {}"\ + .format(int(dfmcp['pid']))) # neutral particle, no need to consider magnetic field if np.isclose(inpart.Charge(), 0., rtol=1e-5): vec = dfmcp[['px', 'py', 'pz']].values