Re: Checking that a file is already open

From: Rene Brun <Rene.Brun_at_cern.ch>
Date: Tue, 17 Feb 2009 09:52:01 +0100


You can test if your file is in teh list of filse with   if (gROOT->GetListOfFiles()->FindObject(filename) ) {

       do not open the file
  }

Rene Brun

Alberto Pulvirenti wrote:
> Dear all,
>
> usually, in the analysis macros I create to view histograms or any
> data from a ROOT file, it can happen that I put the instructions to
> open that file inside the macro. Then, if I run the macro many times
> (it happens if I tune parameters, for example), this file is opened
> several times.
>
> If I want to avoid this, is there a way to check that a file is
> already opened, and "cd()" to it, instead of opening again many times?
>
> Thanks, cheers
>
> Alberto
>
Received on Tue Feb 17 2009 - 09:52:23 CET

This archive was generated by hypermail 2.2.0 : Thu Feb 19 2009 - 05:50:02 CET