ATLAS Offline Software
TruthTest.py
Go to the documentation of this file.
1 
6 
7 # init application mgr
8 theApp.initialize()
9 
10 # run 1 event
11 theApp.nextEvent()
12 
13 # get MC Truth
14 mcc = PyTruthTools.getMcEvents('GEN_AOD')
15 
16 # get GenEvent
17 mc = mcc[0]
18 
19 # call a normal method
20 print (mc.alphaQCD())
21 
22 # get particle-iterators
23 # GenEvent::particles_begin() and _end() give ietrators
24 it = mc.particles_begin()
25 itE = mc.particles_end()
26 
27 # patch because HepMC::GenEvent::particle_const_iterator doesn't define end()
28 it.end = mc.particles_end
29 
30 # loop over all particles
31 while (it != itE):
32  # dereference and increment the iterator
33  # this corresponds to "p = *it++"
34  p = it.next()
35  print (p.pdg_id())
36 
37 # get vertex-iterator
38 it = mc.vertices_begin()
39 
40 it.end = mc.vertices_end
41 
42 # get GenVertex obj
43 v = it.next()
44 
45 # loop over all particles connected via a graph
46 itp = v.particles_begin()
47 itpE = v.particles_end(0)
48 
49 itp.end = v.particles_end
50 
51 while (itp != itpE):
52  print (itp.next().pdg_id())
53