Re: copy folders from root file to another root file

From: suvayu ali <fatkasuvayu_at_gmail.com>
Date: Tue, 17 Aug 2010 11:46:06 -0700


Hi Nadeesha,

On 17 August 2010 10:31, Nadeesha Manohari Wickramage <nadeesha.manohari.wickramage_at_cern.ch> wrote:
>
> Dear Suvayu,
>
> thanks for the reply.
>
> but I need to it other way around. In this macro I can recreate one root
> file coping with many root files.
>
> Do you have any suggestions?
>

I am not a ROOT expert, but I think you can just use the CopyDir method to copy the directories for your file. Just adapt the macro to your needs. If you want finer control of what you want to copy, try looking in the following macro for hints on how to navigate through ROOT files.

$ROOTSYS/tutorials/io/readCode.C

For example, after you get the key names for your ROOT file you can check whether its a histogram you need like this,

TKey *key;
TIter next(myFile->GetListOfKeys());

while ((key = (TKey*)next()))

    {
      TClass *objClass = TClass::GetClass(key->GetClassName());

      if (strstr(key->GetName(), "NameOfhistogram") && objClass->InheritsFrom(TH1::Class()))

         {
            // do stuff here
         }

    }

> thanks
> Nadeesha

Good luck

PS: please use reply all, otherwise your message comes only to me. If it goes to the list, everyone else can follow the discussion and respond if they have a suggestion.

>
> -----Original Message-----
> From: suvayu ali [mailto:fatkasuvayu_at_gmail.com]
> Sent: Tue 8/17/2010 6:46 PM
> To: Nadeesha Manohari Wickramage
> Cc: roottalk (Mailing list discussing all aspects of the ROOT system.)
> Subject: Re: [ROOT] copy folders from root file to another root file
>
> Hi Nadeesha,
>
> On 17 August 2010 09:34, Nadeesha Manohari Wickramage
> <nadeesha.manohari.wickramage_at_cern.ch> wrote:
>>
>> I have a root file with several sub directories. I need to recreate a new
>> root file but only with one sub directory.
>>
>> As an example. in my root file : plots.root
>> I have folders like this." PLOTS/Analyzer/Muon", then histograms.
>>
>> I need only get Muon folder to my new root file.
>>
>> Could anyone can help me for this,
>>
>
> This might help,
>
> $ROOTSYS/tutorials/io/copyFiles.C
>
>> Thanks a lot
>> with regards
>> Nadeesha
>
> GL
> --
> Suvayu
>
> Open source is the future. It sets us free.
>
>

-- 
Suvayu

Open source is the future. It sets us free.
Received on Tue Aug 17 2010 - 20:46:33 CEST

This archive was generated by hypermail 2.2.0 : Tue Aug 17 2010 - 23:50:01 CEST