Re: Drawing histograms from a root file with directories

From: Suvayu Ali <fatkasuvayu_at_gmail.com>
Date: Sun, 2 May 2010 08:44:33 -0700


On Sunday 02 May 2010 08:00 AM, Philippe Canal wrote:
> Hi,
>
> You can use:
>
> canvas->Print( TString::Format("%s.png",profilehisto->GetName()), "png");
>

Great! Thanks a lot. :)

> Cheers,
> Philippe.
>
> On 5/2/10 9:51 AM, Suvayu Ali wrote:
>> Hi Axel,
>>
>> On Sunday 02 May 2010 05:10 AM, Axel Naumann wrote:
>>> 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
>>>
>>
>> That was extremely silly of me. :-p
>>
>>> 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.
>>>
>>
>> Works like a charm! And thanks for the speed tip. :)
>>
>> One last question. while printing the canvas, I take the file name
>> from the name of the histogram like this,
>>
>> canvas->Print( profilehisto->GetName(), "png");
>>
>> Is it possible to include the png extension in the filename somehow?
>>
>> Thanks a lot again. :)
>>
>>> 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>
>>>>
>>>>
>>>
>>
>>

-- 
Suvayu

Open source is the future. It sets us free.
Received on Sun May 02 2010 - 17:44:45 CEST

This archive was generated by hypermail 2.2.0 : Mon May 03 2010 - 11:50:01 CEST