Access multiple trees inside a branch

Dear support / users,

I’ve received an n-tuple, where I see the following structure.

  1. KEY: TDirectoryFile A;
  2. a TTree B; inside A
  3. TBranch C; inside B
  4. Trees inside C;

The result is that the MakeFile of the TTree B has all the trees listed, and the few branches.

The problem I have, is that I don’t know how to access the trees and loop over them… Any ideas/suggestions?

Many thanks!

Stefanos

Hi,

what do you mean by

?
Could you share the file?

D

Hello!

Certainly! I’m also pasting here the dump of the tree showing the variables nested within each branch


*Tree :zfinder_tree: zfinder_tree *
*Entries : 1149550 : Total = 1343943419 bytes File Size = 326877956 *

  •    :          : Tree compression factor =   4.11                       *
    

*Br 0 :reco_z : z_m/D:z_pt:z_y:z_phi:z_phistar:z_eta:z_vtx_prob: *

  •     | z_vtx_x:z_vtx_y:z_vtx_z:daughter0_pt:daughter0_eta:daughter0_phi:*
    
  •     | daughter1_pt:daughter1_eta:daughter1_phi:daughter0_charge/I:     *
    
  •     | daughter1_charge                                                 *
    

*Entries : 1149550 : Total Size= 156851482 bytes File Size = 11915556 *
*Baskets : 5056 : Basket Size= 32000 bytes Compression= 13.15 *

*Br 1 :reco_z_from_muons : z_m/D:z_pt:z_y:z_phi:z_phistar:z_eta: *

  •     | z_vtx_prob:z_vtx_x:z_vtx_y:z_vtx_z:daughter0_pt:daughter0_eta:   *
    
  •     | daughter0_phi:daughter1_pt:daughter1_eta:daughter1_phi:          *
    
  •     | daughter0_charge/I:daughter1_charge                              *
    

*Entries : 1149550 : Total Size= 156907109 bytes File Size = 120309718 *
*Baskets : 5056 : Basket Size= 32000 bytes Compression= 1.30 *

*Br 2 :reco_jpsi : jpsi_m/D:jpsi_pt:jpsi_y:jpsi_phi:jpsi_eta: *

  •     | jpsi_vtx_prob:jpsi_vtx_x:jpsi_vtx_y:jpsi_vtx_z:jpsi_tau_xy:      *
    
  •     | jpsi_tau_z:jpsi_distance_xy:jpsi_distance_z:jpsi_eff:            *
    
  •     | jpsi_acc_eff:jpsi_scale_factor:muon0_pt:muon0_eta:muon0_phi:     *
    
  •     | muon1_pt:muon1_eta:muon1_phi:muon0_charge/I:muon1_charge:        *
    
  •     | has_muons_in_eta_window:has_high_pt_muons                        *
    

*Entries : 1149550 : Total Size= 221452138 bytes File Size = 160051621 *
*Baskets : 7073 : Basket Size= 32000 bytes Compression= 1.38 *

*Br 3 :reco_jpsi_from_electrons : jpsi_m/D:jpsi_pt:jpsi_y:jpsi_phi: *

  •     | jpsi_eta:jpsi_vtx_prob:jpsi_vtx_x:jpsi_vtx_y:jpsi_vtx_z:         *
    
  •     | jpsi_tau_xy:jpsi_tau_z:jpsi_distance_xy:jpsi_distance_z:jpsi_eff:*
    
  •     | jpsi_acc_eff:jpsi_scale_factor:muon0_pt:muon0_eta:muon0_phi:     *
    
  •     | muon1_pt:muon1_eta:muon1_phi:muon0_charge/I:muon1_charge:        *
    
  •     | has_muons_in_eta_window:has_high_pt_muons                        *
    

*Entries : 1149550 : Total Size= 221558248 bytes File Size = 11183155 *
*Baskets : 7073 : Basket Size= 32000 bytes Compression= 19.80 *

*Br 4 :truth_z_muons : z_m/D:z_pt:z_y:z_phi:z_phistar:z_eta:z_vtx_prob: *

  •     | z_vtx_x:z_vtx_y:z_vtx_z:daughter0_pt:daughter0_eta:daughter0_phi:*
    
  •     | daughter1_pt:daughter1_eta:daughter1_phi:daughter0_charge/I:     *
    
  •     | daughter1_charge                                                 *
    

*Entries : 1149550 : Total Size= 156886881 bytes File Size = 3237619 *
*Baskets : 5056 : Basket Size= 32000 bytes Compression= 48.43 *

*Br 5 :truth_z_electrons : z_m/D:z_pt:z_y:z_phi:z_phistar:z_eta: *

  •     | z_vtx_prob:z_vtx_x:z_vtx_y:z_vtx_z:daughter0_pt:daughter0_eta:   *
    
  •     | daughter0_phi:daughter1_pt:daughter1_eta:daughter1_phi:          *
    
  •     | daughter0_charge/I:daughter1_charge                              *
    

*Entries : 1149550 : Total Size= 156907109 bytes File Size = 3257843 *
*Baskets : 5056 : Basket Size= 32000 bytes Compression= 48.13 *

*Br 6 :truth_jpsi : jpsi_m/D:jpsi_pt:jpsi_y:jpsi_phi:jpsi_eta: *

  •     | jpsi_vtx_prob:jpsi_vtx_x:jpsi_vtx_y:jpsi_vtx_z:jpsi_tau_xy:      *
    
  •     | jpsi_tau_z:jpsi_distance_xy:jpsi_distance_z:jpsi_eff:            *
    
  •     | jpsi_acc_eff:jpsi_scale_factor:muon0_pt:muon0_eta:muon0_phi:     *
    
  •     | muon1_pt:muon1_eta:muon1_phi:muon0_charge/I:muon1_charge:        *
    
  •     | has_muons_in_eta_window:has_high_pt_muons                        *
    

*Entries : 1149550 : Total Size= 221459212 bytes File Size = 2831615 *
*Baskets : 7073 : Basket Size= 32000 bytes Compression= 78.16 *

*Br 7 :event_info : event_weight/D:event_number/I:run_number:n_verts: *

  •     | truth_n_verts:is_mc/O:found_high_pt_muons_from_z:                *
    
  •     | found_good_muons_from_z:found_dimuon_z_compatible_vertex:        *
    
  •     | found_z_to_muons_mass:found_high_pt_electrons_from_z:            *
    
  •     | found_good_electrons_from_z:found_dielectron_z_compatible_vertex:*
    
  •     | found_z_to_electrons_mass:                                       *
    
  •     | found_dimuon_jpsi_with_muons_in_eta_window:                      *
    
  •     | found_dimuon_jpsi_with_high_pt_muons:                            *
    
  •     | found_dimuon_jpsi_with_soft_id_and_high_pt_muons:                *
    
  •     | found_dimuon_jpsi_with_good_muons_and_compatible_muon_vertex:    *
    
  •     | found_good_dimuon_jpsi_compatible_with_primary_vertex:found_jpsi:*
    
  •     | found_dimuon_jpsi_from_electrons_with_muons_in_eta_window:       *
    
  •     | found_dimuon_jpsi_from_electrons_with_high_pt_muons:             *
    
  •     | found_dimuon_jpsi_from_electrons_with_soft_id_and_high_pt_muons: *
    
  •     | found_dimuon_jpsi_from_electrons_with_good_muons_and_compatible_muon_vertex:*
    
  •     | found_good_dimuon_jpsi_from_electrons_compatible_with_primary_vertex:*
    
  •     | found_jpsi_from_electrons                                        *
    

*Entries : 1149550 : Total Size= 51920224 bytes File Size = 13712051 *
*Baskets : 1772 : Basket Size= 32000 bytes Compression= 3.78 *

Thanks a lot!
dumpOfMakefile.h (12.9 KB)

Hi Stefanos,

could you put me in condition of reproducing the issue with
o The input file
o The instruction to reproduce the attempt to read it

Cheers,
Danilo

Hi Danilo!

I’m terribly sorry for that… Actually, but calling the names of the variables from the header files in the script seems to work… What isn’t straightforward to do, is to plot a variable just by loading it and use command line, but I’ll settle with the first…

Thanks again!

Stefanos