Hi Philip, The [i] doesn't work because ROOT expects a string argument in the method run1.Add(), and in contrast to all the shell languages it doesn't have a parser to make substitutions before it handles the string to the Add method. So you have to construct the string outside the method call using C++ commands, and then hand it to Add(). Try the following: TChain run1("h45"); char name[200]; for (Int_t i=1; i<13, i++) { sprintf(name,"/nfs/farm/babar/AWG11/Charmonium/Etac/ntp13/good_1999-b1-s0-r10B-on_all_[%i].root",i); run1.Add(name); } for (Int_t i=1; i<58, i++) { sprintf(name, "/nfs/farm/babar/AWG11/Charmonium/Etac/ntp13/good_2000-b1-s0-r10B-on_all_[%i].root",i); run1.Add(name); } Stelios. ----- Original Message ----- From: "Philip Clark" <pclark@SLAC.stanford.edu> To: <roottalk@pcroot.cern.ch> Sent: Friday, September 06, 2002 6:26 PM Subject: [ROOT] Chaining files together > > 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 >
This archive was generated by hypermail 2b29 : Sat Jan 04 2003 - 23:51:08 MET