Hi,
I think you got it right. You can speed up the dynamic_cast, but here we are talking about 2nd order refinements, especially at this level, exploiting ROOT reflection (key->GetClassName() - see for example Finding all objects in a root file, regardless of directries)
Cheers,
D