so i tried...
Int_t i_last=272;
for(Int_t i=1;i<=i_last;i++){
char fileName[70];
sprintf(fileName,"/nfs/data04/olivas/Stream16/B/BJpsiSkimFeb14%s_%d.root",name,i);
//if(!gSystem->AccessPathname(fileName)){
Long_t* id;
Long_t* size;
Long_t* flags;
Long_t* modtime;
if(!gSystem->GetPathInfo(fileName,id,size,flags,modtime)){
cout<<gSystem->GetPathInfo(fileName,id,size,flags,modtime)<<":";
cout<<fileName;
if(id) cout<<" id:"<<*id;
if(size) cout<<" size:"<<*size;
if(flags) cout<<" flags:"<<*flags;
if(modtime) cout<<" modtime:"<<*modtime;
cout<<endl;
TFile f(fileName);
ksMassNoCuts->Add((TH1F*)f.Get("h1d3"));
ksMassCuts->Add((TH1F*)f.Get("h1d5"));
jpsiMassNoCuts->Add((TH1F*)f.Get("h1d7"));
jpsiMassCuts->Add((TH1F*)f.Get("h1d9"));
}
}
GetPathInfo seems to work just fine for checking whether files exist or not,
but if the file does exist id, size, flags, and modtime are all "NULL."
i would like to have access to these, because i would also like to skip
files that are open and currently being written to by batch jobs.
thanks,
alex.
-----Original Message-----
From: Rene Brun
To: Sebastien Greder
Cc: Olivas, Alexander Raymond; 'roottalk@root.cern.ch'
Sent: 4/9/2003 2:39 AM
Subject: Re: [ROOT] Help with TFile
Sebastien,
Thanks for correcting my mistake.
Rene
Sebastien Greder wrote:
>
> Hi,
>
> sorry but the AccessPathname return value is the opposite, cf
classindex
> doc :
>
> Bool_t AccessPathName(const char *, EAccessMode)
>
> Returns FALSE if one can access a file using the specified access
mode.
> Attention, bizarre convention of return value!!
>
> seb.
>
> On Wed, 9 Apr 2003, Rene Brun wrote:
>
> > Hi Alex,
> >
> > I don't know that is the "g" object in your statement g.Open !
> >
> > To test if a file exist, you can use
> > gSystem->AccessPathname(fileName);
> > This will return kTRUE if the file can be accessed, kFALSE
otherwise.
> >
> > Rene Brun
> >
> > "Olivas, Alexander Raymond" wrote:
> > >
> > > I'm not sure if this is the correct place to post this question,
> > > but here it goes.
> > >
> > > I have many jobs currently creating quite a few root files.
> > > I have the files numbered so I can read them using a simple
> > > for loop. However, some jobs haven't started yet and some
> > > are still running. I would like to read only the files that
> > > exist and are closed.
> > >
> > > I've tried something like...
> > >
> > > Int_t i_last=272;
> > > for(Int_t i=1;i<=i_last;i++){
> > > char fileName[60];
> > >
sprintf(fileName,"$NTUPLE_DIR/B/BJpsiSkimFeb14%s_%d.root",name,i);
> > > if(g.Open(fileName)){
> > > TFile f(fileName);
> > > ksMassNoCuts->Add((TH1F*)f.Get("h1d3"));
> > > }
> > > }
> > >
> > > g.Open(fileName) still returns true if the file does not exist.
> > > I've searched through the root page and have had trouble finding
> > > anything that will allow me to assess the state of a file without
> > > explicity trying to open it.
> > >
> > > Any help would be greatly appreciated.
> > > Thanks,
> > > Alex.
> >
This archive was generated by hypermail 2b29 : Thu Jan 01 2004 - 17:50:10 MET