Belle II Software  release-05-01-25
MCGenTopo.py
1 #!/usr/bin/env python3
2 # -*- coding: utf-8 -*-
3 from variables.utils import create_aliases
4 from variables import variables
5 
6 
7 def mc_gen_topo(n=200):
8  """
9  Gets the list of variables containing the raw topology information of MC generated events.
10  To be specific, the list including the following variables:
11 
12  * ``nMCGen``: number of MC generated particles in a given event,
13  * ``MCGenPDG_i`` (i=0, 1, ... n-2, n-1):
14  PDG code of the :math:`{\\rm i}^{\\rm th}` MC generated particle in a given event,
15  * ``MCGenMothIndex_i`` (i=0, 1, ... n-2, n-1):
16  mother index of the :math:`{\\rm i}^{\\rm th}` MC generated particle in a given event.
17 
18  .. tip::
19 
20  * Internally, ``nMCGen``, ``MCGenPDG_i`` and ``MCGenMothIndex_i`` are just aliases of
21  ``nMCParticles``, ``genParticle(i, varForMCGen(PDG))``
22  and ``genParticle(i, varForMCGen(mcMother(mdstIndex)))``, respectively.
23  * For more details on the variables, please refer to the documentations of
24  :b2:var:`nMCParticles`, :b2:var:`genParticle`, :b2:var:`varForMCGen`,
25  :b2:var:`PDG`, :b2:var:`mcMother`, and :b2:var:`mdstIndex`.
26 
27  Parameters:
28  n (int): number of ``MCGenPDG_i``/``MCGenMothIndex_i`` variables. Its default value is 200.
29 
30  .. note::
31 
32  * To completely examine the topology information of the events in an MC sample,
33  the parameter ``n`` should be greater than or equal to the maximum of ``nMCGen`` in the sample.
34  * Normally, the maximum of ``nMCGen`` in the MC samples at Belle II is less than 200.
35  Hence, if you have no idea about the maximum of ``nMCGen`` in your own MC sample,
36  it is usually a safe choice to use the default parameter value 200.
37  * However, an overlarge parameter value leads to unncessary waste of disk space and
38  redundant variables with inelegant ``nan`` values.
39  Hence, if you know the maximum of ``nMCGen`` in your own MC sample,
40  it is a better choice to assign the parameter a proper value.
41  """
42  list_of_indexes = [str(i) for i in range(n)]
43  wrapper = 'genParticle({variable}, varForMCGen(PDG))'
44  prefix = 'MCGenPDG'
45  MCGenPDG = create_aliases(list_of_indexes, wrapper, prefix)
46  wrapper = 'genParticle({variable}, varForMCGen(mcMother(mdstIndex)))'
47  prefix = 'MCGenMothIndex'
48  MCGenMothIndex = create_aliases(list_of_indexes, wrapper, prefix)
49  variables.addAlias('nMCGen', 'nMCParticles')
50  list_of_variables = ['nMCGen']
51  for i in range(n):
52  list_of_variables.append(MCGenPDG[i])
53  list_of_variables.append(MCGenMothIndex[i])
54  return list_of_variables
variables.utils
Definition: utils.py:1