miranov25 / RootInteractive

5 stars 12 forks source link

Error handling in case of undefined categories #238

Open miranov25 opened 2 years ago

miranov25 commented 2 years ago

The error message for invalid category entries in the RootInteractive variables does not provide hint about the reason. In the realistic case of the efficiency tree mapping PDGcode - > the particle name sometimes did not work - the name was undefined The bokehDrawSA failed without explanation - only standard error with "invalid JSON".

miranov25 commented 2 years ago

In the use case above I had to define "None" category

pdgMap={}
for i, pdg0 in enumerate(dfResol["pdgCode"].unique()):
    if pdgTable.GetParticle(int(pdg0)) : pdgMap[pdg0]=pdgTable.GetParticle(int(pdg0)).GetName()
    else:
         pdgMap[pdg0]="None"
for i, pdg0 in enumerate(dfResol["pdgCodeM"].unique()):
    if pdgTable.GetParticle(int(pdg0)) : pdgMap[pdg0]=pdgTable.GetParticle(int(pdg0)).GetName()
    else:
        pdgMap[pdg0]="None"
for i, pdg0 in enumerate(dfResol["pdgCodeGM"].unique()): 
    if pdgTable.GetParticle(int(pdg0)) : pdgMap[pdg0]=pdgTable.GetParticle(int(pdg0)).GetName()
    else:
        pdgMap[pdg0]="None"