TChain and rootd

Hi all,

I have a problem with TChain and rootd.
If I work in local I don’t have problem to chain several files, in general I use this way:

TChain *JetChain;
JetChain = new TChain("Jet");
  
for (int num=1; num<=75; num++)
  {
    ostringstream string_num;
    string_num << num;
    const char *num_st = string_num.str().c_str();
      
    JetChain->AddFile("mini-ntuple_bhhs1a."+num_st+".root", TChain::kBigNumber);
  }

But when I work in remote I can’t.
With rootd I tried different way but nothing.
I tried:

JetChain->AddFile("root://blabla.fnal.gov:5151//mini-ntuple_bhhs1a.*.root", TChain::kBigNumber);

JetChain->AddFile("root://blabla.fnal.gov:5151//mini-ntuple_bhhs1a.*", TChain::kBigNumber);

JetChain->AddFile("root://blabla.fnal.gov:5151//*.root", TChain::kBigNumber);

JetChain->AddFile("root://blabla.fnal.gov:5151//*.*", TChain::kBigNumber);

But nothing, it chains only the first file…
The only way I found is:

TChain *JetChain;
JetChain = new TChain("Jet");

JetChain->AddFile("root://blabla.fnal.gov:5151//mini-ntuple_bhhs1a.1.root", TChain::kBigNumber);
JetChain->AddFile("root://blabla.fnal.gov:5151//mini-ntuple_bhhs1a.2.root", TChain::kBigNumber);
...

but I have over 300 files…
Is not a way to simplify this work?
Thank you
Ciccio

Hi,

I recommend writing a subroutine that takes a text file containing all of the files you have as input and adds them to your TChain.

Cheers,
Charles

p.s. This question comes up enough that it might be a nice feature to add to the TChain class…

Hi,

Doesn’t:[code]TChain *JetChain;
JetChain = new TChain(“Jet”);

for (int num=1; num<=75; num++)
{
ostringstream string_num;
string_num << num;
const char *num_st = string_num.str().c_str();

JetChain->AddFile(TString::Format("root://blabla.fnal.gov:5151//mini-ntuple_bhhs1a.%d.root",num_st), TChain::kBigNumber);

}[/code]work?

Philippe.

Philippe.

Hi,

Doesn’t:[code]TChain *JetChain;
JetChain = new TChain(“Jet”);

for (int num=1; num<=75; num++)
{
JetChain->AddFile(TString::Format(“root://blabla.fnal.gov:5151//mini-ntuple_bhhs1a.%d.root”,num), TChain::kBigNumber);
}[/code]work?

Philippe.

Hi Charles and Philippe,

thank you very much for your answers, both methods work!
Thank you
Ciccio

[quote=“pcanal”]Hi,

Doesn’t:[code]TChain *JetChain;
JetChain = new TChain(“Jet”);

for (int num=1; num<=75; num++)
{
JetChain->AddFile(TString::Format(“root://blabla.fnal.gov:5151//mini-ntuple_bhhs1a.%d.root”,num), TChain::kBigNumber);
}[/code]work?

Philippe.[/quote]

It probably works in this case :smiley:

But a lot of experiments give their files non-sequential names and so this doesn’t work in general. [-X

Cheers,
Charles

Hi,

[quote]But a lot of experiments give their files non-sequential names and so this doesn’t work in general.[/quote]humm … well it works perfectly in this case :~) and for the general case you are indeed welcome to propose a patch implementing this feature. :stuck_out_tongue:

Cheers,
Philippe.

[quote=“pcanal”]Hi,

[quote]But a lot of experiments give their files non-sequential names and so this doesn’t work in general.[/quote]humm … well it works perfectly in this case :~) and for the general case you are indeed welcome to propose a patch implementing this feature. :stuck_out_tongue:

Cheers,
Philippe.[/quote]

I’m pretty much suggesting a member function that looks like this:

Cheers,
Charles