Tags
#get all the external stuff
from cmstools import *
import ROOT
#convert C++ iterators into a python generator
def gen_from_iter(b,e):
   while( b != e ):
      yield b.__deref__() #*b
      b.__postinc__(0) #++b

#setup the data
f = ROOT.TFile("pythiaHZZ4mu.root")
events = f.Get("Events")
branch = events.GetBranch("edmHepMCProduct_source__PROD.obj")
mcprod = ROOT.edm.HepMCProduct()
branch.SetAddress(mcprod)
h2 = ROOT.TH1D( "Hist2muMass", "test 2-mu mass", 100,  60., 120. ) ;
h4 = ROOT.TH1D( "Hist4muMass", "test 4-mu mass", 100, 170., 210. ) ;

#process the data
for event in all(events):
   branch.GetEntry(event)
   mcev = mcprod.GetEvent()
   if 25 in (x.pdg_id() for x in gen_from_iter(mcev.particles_begin(), mcev.particles_end())):
     muons = [ x for x in gen_from_iter(mcev.particles_begin(), mcev.particles_end()) if ( abs(x.pdg_id()) == 13 and x.status() == 1 ) ]
     map( h2.Fill, ( (x.momentum()+y.momentum()).m() for x in muons   for y in muons if x.pdg_id()*y.pdg_id() < 0 ) )
     if 4 == len(muons):
        h4.Fill( sum( (x.momentum() for x in muons), ROOT.CLHEP.HepLorentzVector() ).m() )

-- ChrisDJones - 11 Aug 2006
Topic revision: r2 - 06 Nov 2006, ChrisDJones
This site is powered by FoswikiCopyright © by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding CLASSE Wiki? Send feedback