# TChain and wildcard

**URL:** <https://root-forum.cern.ch/t/tchain-and-wildcard/36369>\
**Category:** Evolution Proposals, Apps & Ideas\
**Created:** [October 16, 2019, 10:24am UTC](https://root-forum.cern.ch/t/tchain-and-wildcard/36369 "2019-10-16T10:24:48Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![produit](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/produit/32/13765_2.png) [@produit](https://root-forum.cern.ch/u/produit)\
**Post date:** [October 16, 2019, 10:24am UTC](https://root-forum.cern.ch/t/tchain-and-wildcard/36369/1 "2019-10-16T10:24:48Z")

</div>

TChain.Add() should enable globbing so that we can easily chain  
TTrees that reside in different subdirectories.  
The code to do it is given in  
[Problem using wildcards in TChain-\>Add](https://root-forum.cern.ch/t/problem-using-wildcards-in-tchain-add/31474)  
but I think it will be of general interest to anybody that this is done by the method TChain.Add and not  
asking everybody to do it by hand each time.  
It also reduce the surprise factor and the puzzlement that  
TChain-\>Add(“a/_/_.root”) give no warnings but does not add all the intended file.

Thanks

---

<div class="post-metadata">

**Author:** ![etejedor](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/e/e79b87/32.png) [@etejedor](https://root-forum.cern.ch/u/etejedor)\
**Post date:** [October 22, 2019, 8:29am UTC](https://root-forum.cern.ch/t/tchain-and-wildcard/36369/3 "2019-10-22T08:29:09Z")

</div>

@pcanal would you like to comment on this proposal?

---

<div class="post-metadata">

**Author:** ![pcanal](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/pcanal/32/12439_2.png) [@pcanal](https://root-forum.cern.ch/u/pcanal)\
**Post date:** [October 22, 2019, 4:04pm UTC](https://root-forum.cern.ch/t/tchain-and-wildcard/36369/4 "2019-10-22T16:04:46Z")

</div>

This is a good idea. I opened [https://sft.its.cern.ch/jira/browse/ROOT-10371](https://sft.its.cern.ch/jira/browse/ROOT-10371) to keep track of the progress. Would you be interested in proposing a patch/implementation?

---

<div class="post-metadata">

**Author:** ![produit](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/produit/32/13765_2.png) [@produit](https://root-forum.cern.ch/u/produit)\
**Post date:** [October 23, 2019, 7:56am UTC](https://root-forum.cern.ch/t/tchain-and-wildcard/36369/5 "2019-10-23T07:56:15Z")

</div>

Hi,  
what I do is the following but I don’t know if this is portable to non unix systems:  
TString command = Form("/bin/bash -c ‘ls -1 %s 2\>/dev/null’",pattern.Data());  
FILE\* f=gSystem-\>OpenPipe(command,“r”);  
while (help.Gets(f)){  
fchain-\>Add(help)  
gSystem-\>ClosePipe(f);

But the solution using glob in the other discussion looks nicer.  
I think code is simple it is more a portability problem.
