I want to include a conditional in the above for loop that has a set of instructions if the object is a TH1 and a different set of instructions if it is a TH2. I was wondering what the best way to do this check was? I know I can check the names of the objects, but I was wondering if there was something better? Thanks in advance.
Thanks for your response. I am not at all familiar with ROOT RTTI, so my apologies if this question seems ignorant. I get the following error and am not sure what to do about it:
error: invalid range expression of type 'TList'; no viable 'begin' function available
for(auto&& keyAsTObj : *keysPtr){
^ ~
what version of ROOT are you using?
That syntax is only possible with recent 5.34 or a 6 ROOT version. If you can not move to a more recent version, a non-range based loop shall be used.