#!/usr/bin/env python import ROOT ROOT.gROOT.Macro( '$ROOTCOREDIR/scripts/load_packages.C' ) ROOT.xAOD.Init() # Initialize the xAOD infrastructure fileName="AOD.01482225._000140.pool.root" # Set up the input files treeName = "CollectionTree" # default when making transient tree anyway f = ROOT.TFile.Open(fileName) t = ROOT.xAOD.MakeTransientTree( f, treeName) # Make the "transient tree" from ROOT import * h1=TH1D("eta","eta",20, -4,4) # Print some information: print( "Number of input events: %s" % t.GetEntries() ) for entry in xrange( t.GetEntries() ): t.GetEntry( entry ) print( "Processing run #%i, event #%i" % ( t.EventInfo.runNumber(), t.EventInfo.eventNumber() ) ) print( "Number of electrons: %i" % len( t.ElectronCollection ) ) for el in t.ElectronCollection: # loop over electron collection h1.Fill( el.trackParticle().eta() ) pass # end for loop over electron collection pass # end loop over entries hfile=TFile("test.root","RECREATE","ANL tutorial") h1.Write() f.Close() hfile.Close()