ATLAS Offline Software
Loading...
Searching...
No Matches
python.PyTruthTools Namespace Reference

Functions

 getMcEvents (aKey)

Variables

str __docformat__ = "restructuredtext en"

Detailed Description

module to access truth objects interactively

Example is in `PyAnalysisExamples/TruthTest.py`_

.. _PyAnalysisExamples/TruthTest.py: http://atlas-sw.cern.ch/cgi-bin/viewcvs-atlas.cgi/offline/PhysicsAnalysis/PyAnalysis/PyAnalysisExamples/share/TruthTest.py?rev=HEAD&content-type=text/vnd.viewcvs-markup


:author: Tadashi Maeno
:contact: Tadashi.Maeno@cern.ch

Function Documentation

◆ getMcEvents()

python.PyTruthTools.getMcEvents ( aKey)
Retrieve McEventCollection object from SG

:param aKey: key of the object

**examples**::

  athena> mcc = PyTruthTools.getMcEvents('GEN_EVENT')
  athena> len(mcc)
  athena> mc = mcc[0]
  athena> mc.alphaQCD()
  athena> it  = mc.particles_begin()       # GenEvent::particles_begin() and _end() give ietrators
  athena> itE = mc.particles_end()  
  athena> while (it != itE):               # loop over all particles
  ...  p = it.next()                       # dereference and increment the ietrator
  ...  print p.pdg_id()
  ...                                      # just hit return key


**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.

.. _GenEvent: http://reserve02.usatlas.bnl.gov/lxr/source/atlas/Simulation/HepMC/HepMC/GenEvent.h
.. _GenVertex: http://reserve02.usatlas.bnl.gov/lxr/source/atlas/Simulation/HepMC/HepMC/GenVertex.h

Definition at line 18 of file PyTruthTools.py.

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)

Variable Documentation

◆ __docformat__

str python.PyTruthTools.__docformat__ = "restructuredtext en"
private

Definition at line 14 of file PyTruthTools.py.