Hi Suvayu,
I believe you are checking whether TKey derives from TProfile - and you find that it doesn't :-) What you might try instead is
TClass* objClass = TClass::GetClass(key->GetClassName()); if (objClass && objClass->InheritsFrom(TProfile::Class())) {...}
Same for the TDirectory check, of course. Passing a TClass* (from TProfile::Class()) to InheritsFrom() is a lot faster than the string version, by the way.
Cheers, Axel.
On 2010-05-02 02:43, Suvayu Ali wrote:
> Hi ROOT users,
>
> I am not very well versed with ROOT and I am stuck with something very
> basic. I have a root file with lots of directories with lots of
> histograms. I want to plot all the TProfiles with their name starting
> with a certain string in my own style and then save these plots in a png
> file.
>
> To achieve this I wrote the attached script. To navigate within the root
> file I took hints from $ROOTSYS/tutorials/io/readCode.C.
>
> But I still can't seem to recurse through the directories and find my
> histograms. I had to replace the "key->IsFolder()" check with
> "key->InheritsFrom("TDirectory")" as my file contains a TTree with
> metadata in each folder, and the script tries to recurse into it.
>
> Where am I going wrong?
>
> Thanks for any help.
>
>
> [1]<http://hep.phys.sfu.ca/~suvayu/mergedMonitor_collision_7TeV_153565_v3b.root>
>
Received on Sun May 02 2010 - 14:10:51 CEST
This archive was generated by hypermail 2.2.0 : Sun May 02 2010 - 17:50:01 CEST