Loop over multiple ttree ( different names) in one root file at once

Dear ROOTers
I have a root file with multiple TTree (different names )with same structure. usually I use makeclass() to handle one tree
I want to know if there is a way to do the same for multipe TTree at once

the root files looks like

TFile*		mc16_5TeV.420254.HepMCAscii_Superchic3gammagamma2gammagamma_M3p6.recon.AOD.e7188_s3406_r11167.root	
  KEY: TTree	nominal;1	nominal
  KEY: TTree	EG_RESOLUTION_ALL__1down;1	EG_RESOLUTION_ALL__1down
  KEY: TTree	EG_RESOLUTION_ALL__1up;1	EG_RESOLUTION_ALL__1up
  KEY: TTree	EG_SCALE_AF2__1down;1	EG_SCALE_AF2__1down
  KEY: TTree	EG_SCALE_AF2__1up;1	EG_SCALE_AF2__1up
  KEY: TTree	EG_SCALE_ALL__1down;1	EG_SCALE_ALL__1down
  KEY: TTree	EG_SCALE_ALL__1up;1	EG_SCALE_ALL__1up

Best
Hassane

TChain ?

Will it work for different names ?

If they are exactly the same why not giving them the same name ? you can then differentiate them by file names.

they are stored in the same single file so I cant do that

May be @pcanal has an idea.

1 Like

Will it work for different names ?

Yes, use either:

chain.AddFile(filename, -1, treename);

or

chain.AddFile("mc16_5TeV....r11167.root#EG_SCALE_ALL__1up);

See ROOT: TChain Class Reference

Cheers,
Philippe.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.