Commit 3b707c17 authored by Paul Schütze's avatar Paul Schütze
Browse files

Python analysis: Add check on existence of selected detector

parent 89c153d2
Loading
Loading
Loading
Loading
+9 −0
Original line number Diff line number Diff line
@@ -108,6 +108,15 @@ gSystem.Load(lib_file_name)
rootfile = ROOT.TFile(root_file_name)
gDirectory.ls()

# Check on detector existence
if not rootfile.GetDirectory("detectors/" + detector_name):
    print("\nDetector does not exist. Please choose one of the following detectors:")
    gDirectory.cd("detectors")
    list_of_keys = gDirectory.GetListOfKeys()
    for key in list_of_keys:
        print(key.GetName())
    exit(1)

McParticle = rootfile.Get('MCParticle')
PixelCharge = rootfile.Get('PixelCharge')
PropCharge = rootfile.Get('PropagatedCharge')