18def getMcEvents (aKey):
19 """Retrieve McEventCollection object from SG
20
21 :param aKey: key of the object
22
23 **examples**::
24
25 athena> mcc = PyTruthTools.getMcEvents('GEN_EVENT')
26 athena> len(mcc)
27 athena> mc = mcc[0]
28 athena> mc.alphaQCD()
29 athena> it = mc.particles_begin() # GenEvent::particles_begin() and _end() give ietrators
30 athena> itE = mc.particles_end()
31 athena> while (it != itE): # loop over all particles
32 ... p = it.next() # dereference and increment the ietrator
33 ... print p.pdg_id()
34 ... # just hit return key
35
36
37 **Note:** Some methods of GenEvent_/GenVertex_, e.g., particles_begin(), give an iterator. One may use it like as a python iterator. But don't try 'for i in iterator:'. It should cause a crash since an iterator of C++ doesn't know it's boundary.
38
39 .. _GenEvent: http://reserve02.usatlas.bnl.gov/lxr/source/atlas/Simulation/HepMC/HepMC/GenEvent.h
40 .. _GenVertex: http://reserve02.usatlas.bnl.gov/lxr/source/atlas/Simulation/HepMC/HepMC/GenVertex.h
41
42 """
43 return PyK.retrieve(PyK.GNS.McEventCollection,aKey)