ATLAS Offline Software
PyTruthTools.py
Go to the documentation of this file.
1 # Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
2 
3 """module to access truth objects interactively
4 
5 Example is in `PyAnalysisExamples/TruthTest.py`_
6 
7 .. _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
8 
9 
10 :author: Tadashi Maeno
11 :contact: Tadashi.Maeno@cern.ch
12 
13 """
14 __docformat__ = "restructuredtext en"
15 
16 from PyKernel import PyKernel as PyK
17 
18 def 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)
python.PyTruthTools.getMcEvents
def getMcEvents(aKey)
Definition: PyTruthTools.py:18