Re: [ROOT] Chaining files together

From: Cheng Yunhua (chengyh@iopp.ccnu.edu.cn)
Date: Sat Sep 07 2002 - 15:55:45 MEST


Hi,Philip,
 You can also define a char array like this:

 const int nfile = 6;
 char *file[nfile] = { 
  
"/nfs/farm/babar/AWG11/Charmonium/Etac/ntp13/good_1999-b1-s0-r10B-on_all_1.root",
"/nfs/farm/babar/AWG11/Charmonium/Etac/ntp13/good_1999-b1-s0-r10B-on_all_2.root",
"/nfs/farm/babar/AWG11/Charmonium/Etac/ntp13/good_1999-b1-s0-r10B-on_all_3.root",
"/nfs/farm/babar/AWG11/Charmonium/Etac/ntp13/good_1999-b1-s0-r10B-on_all_4.root",
"/nfs/farm/babar/AWG11/Charmonium/Etac/ntp13/good_1999-b1-s0-r10B-on_all_5.root",
"/nfs/farm/babar/AWG11/Charmonium/Etac/ntp13/good_1999-b1-s0-r10B-on_all_6.root"

 }

//And then you open them as blow,
for(Int_t k = 0; k < nfile ; k++) { TFile *fp = new TFile(file[k]);
                                           { 
                                            
                                    
          
                                           }//end of your task task
                          delete fp;          
                         }//end of files open


Yunhua Cheng

On Sat, 7 Sep 2002, Rene Brun wrote:

> Hi Philip,
> 
> In addition to the solution to use the concatenation of TString, note that
> you can also use wilcarding to create a TChain, eg
>  TChain run1("h45");
>  run1.Add("/nfs/farm/babar/AWG11/Charmonium/Etac/ntp13/good_1999-b1-s0-r10B-on_all_*.root")
>  run1.Add("/nfs/farm/babar/AWG11/Charmonium/Etac/ntp13/good_2000-b1-s0-r10B-on_all_*.root")
> 
> Rene Brun
> 
> On Fri, 6 Sep 2002, Philip Clark wrote:
> 
> > 
> > Hi Everyone,
> > 
> > Currently, I am trying to loop over files and make chains. In PAW I would do:-
> > 
> >  MACRO run1
> >    do i=1,12
> >      chain run1 good_1999-b1-s0-r10B-on_all_[i].hbook
> >    enddo
> >    do i=1,57
> >      chain run1 good_2000-b1-s0-r10B-on_all_[i].hbook
> >    enddo
> > etc
> > 
> > I root I am trying to do something like 
> > 
> > TChain run1("h45");
> > for (Int_t i=1; i<13, i++) 
> > {
> >   run1.Add("/nfs/farm/babar/AWG11/Charmonium/Etac/ntp13/good_1999-b1-s0-r10B-on_all_[i].root");
> > }
> > for (Int_t i=1; i<58, i++) 
> > {
> >   run1.Add("/nfs/farm/babar/AWG11/Charmonium/Etac/ntp13/good_2000-b1-s0-r10B-on_all_[i].root");
> > }
> > 
> > Obviously [i] wont work here... Any ideas instead? I need to loop over
> > several thousand files in this manner. So a better solution would help a
> > lot.
> > 
> > Also a way to substitute the path
> > /nfs/farm/babar/AWG11/Charmonium/Etac/ntp13/ 
> > which is the same all the time would be good as well.
> > 
> > Thanks
> > 
> > -Phil
> > 
> > -- 
> > Philip J. Clark                    MS41 (Bristol), SLAC 
> > tel: 1-650-926-3761                Stanford University
> > fax: 1-650-926-3767                P.O. Box 20450
> > pclark@slac.stanford.edu           Stanford, California 94309
> > 
> 

-- 
**************************************************************************
* Name:      Cheng Yunhua Major: high energe experiment physics      ***
*--------------------------------------------------------------------**
* Department:Institute of particle physics,Huazhong Normal University***
*--------------------------------------------------------------------****
* Adress:    Institute of particle physics,CCNU,Wuhan,Hubei,PRC.     *****
*--------------------------------------------------------------------******
* ZIP code:  430079       Tel:  027-87673314(O)  027-87340256(D)     *****
*--------------------------------------------------------------------****
* E-mail:    chengyh@iopp.ccnu.edu.cn chengyunhua11@263.net          ***
**************************************************************************



This archive was generated by hypermail 2b29 : Sat Jan 04 2003 - 23:51:08 MET