Back to home page

EIC code displayed by LXR

 
 

    


Warning, file /snippets/PID/read_pid.py was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

0001 import os
0002 
0003 import dd4hep
0004 from podio.reading import get_reader
0005 
0006 desc = dd4hep.Detector.getInstance()
0007 desc.fromXML("{}/{}.xml".format(os.environ["DETECTOR_PATH"], os.environ["DETECTOR_CONFIG"]))
0008 name_lookup = {
0009     desc.constantAsLong("BackwardRICH_ID") : "pfRICH",
0010     desc.constantAsLong("BarrelDIRC_ID") : "hpDIRC",
0011     desc.constantAsLong("BarrelTOF_ID") : "TOF",
0012     desc.constantAsLong("ForwardRICH_ID") : "DRICH",
0013 }
0014 
0015 def read_pid(input_file="simu/podio_output.root"):
0016     reader = get_reader(input_file)
0017     for i, frame in enumerate(reader.get("events")):
0018         print(f"event {i}")
0019         for part in frame.get("ReconstructedChargedParticles"):
0020             print(f"particle energy {part.getEnergy()}")
0021             print(f"PID PDG {part.getPDG()}")
0022             for partid in part.getParticleIDs():
0023                 detector_name = name_lookup.get(partid.getType())
0024                 print(f"\tdetector {detector_name} PDG {partid.getPDG()} probability {partid.getLikelihood()}")
0025 
0026 read_pid()