Check if branch exists from terminal

Hi all,

I have a silly question, but I could not find the solution anywhere. I want to check from the terminal if my tree, called “Entries” has branches which start with “Electron” in its name and I want them listed.
As I remember from past, I was able to check it in a following way:
Events->Print("Electron*") but now it just gives me the full list of the branches as an output. So I guess, I remember wrongly :slight_smile:
P.S. I know for sure that there are various variables stored in the tree, like Electron_pt, Electron_eta, etc.

Thanks in advance!

Newbie

It should work.

Hi @beg1nner,

Using Print seems to work in my case, it is a bit verbose but it is giving only the branches that pass respect the wildcard I use:

root [0] TFile f{"Run2012BC_DoubleMuParked_Muons.root"};
root [1] std::unique_ptr<TTree> t{f.Get<TTree>("Events")};
root [2] t
(std::unique_ptr<TTree> &) std::unique_ptr -> 0x55ec47750410
root [3] t->Print("Muon*")
******************************************************************************
*Tree    :Events    : Events                                                 *
*Entries : 61540413 : Total =      4463735053 bytes  File  Size = 2243340472 *
*        :          : Tree compression factor =   1.99                       *
******************************************************************************
*Br    0 :Muon_pt   : Muon_pt[nMuon]/F                                       *
*Entries : 61540413 : Total  Size=  843506272 bytes  File Size  =  634763632 *
*Baskets :      523 : Basket Size=   25600000 bytes  Compression=   1.33     *
*............................................................................*
*Br    1 :Muon_eta  : Muon_eta[nMuon]/F                                      *
*Entries : 61540413 : Total  Size=  843506799 bytes  File Size  =  653064868 *
*Baskets :      523 : Basket Size=   25600000 bytes  Compression=   1.29     *
*............................................................................*
*Br    2 :Muon_phi  : Muon_phi[nMuon]/F                                      *
*Entries : 61540413 : Total  Size=  843506799 bytes  File Size  =  652361580 *
*Baskets :      523 : Basket Size=   25600000 bytes  Compression=   1.29     *
*............................................................................*
*Br    3 :Muon_mass : Muon_mass[nMuon]/F                                     *
*Entries : 61540413 : Total  Size=  843507326 bytes  File Size  =  102175256 *
*Baskets :      523 : Basket Size=   25600000 bytes  Compression=   8.26     *
*............................................................................*
*Br    4 :Muon_charge : Muon_charge[nMuon]/I                                 *
*Entries : 61540413 : Total  Size=  843508481 bytes  File Size  =  162126603 *
*Baskets :      524 : Basket Size=   25600000 bytes  Compression=   5.20     *
*............................................................................*

What do you see in your case?
Cheers,
Vincenzo

From both posts here … a physics hypothesis can be derived … it only works for “muons” but doesn’t work for “electrons”. :mrgreen:
How about you try “taus”? :thinking:

Haha, true :smiley: :smiley: After a restart of the machine, it worked. Still a mystery why it was giving the whole list of the branches inside the ntuple… @vpadulan thank you for trying :slight_smile: