Belle II Software light-2609-luna
BasicParticleInformation.cc
1/**************************************************************************
2 * basf2 (Belle II Analysis Software Framework) *
3 * Author: The Belle II Collaboration *
4 * *
5 * See git log for contributors and copyright holders. *
6 * This file is licensed under LGPL-3.0, see LICENSE.md. *
7 **************************************************************************/
8
9// Own header.
10#include <analysis/variables/BasicParticleInformation.h>
11
12// include VariableManager
13#include <analysis/VariableManager/Manager.h>
14
15#include <analysis/dataobjects/Particle.h>
16
17namespace Belle2 {
22 namespace Variable {
23
24 bool particleIsFromECL(const Particle* part)
25 {
26 return (part->getParticleSource() == Particle::EParticleSourceObject::c_ECLCluster);
27 }
28
29 bool particleIsFromKLM(const Particle* part)
30 {
31 return (part->getParticleSource() == Particle::EParticleSourceObject::c_KLMCluster);
32 }
33
34 bool particleIsFromTrack(const Particle* part)
35 {
36 return (part->getParticleSource() == Particle::EParticleSourceObject::c_Track);
37 }
38
39 bool particleIsFromV0(const Particle* part)
40 {
41 return (part->getParticleSource() == Particle::EParticleSourceObject::c_V0);
42 }
43
44 int particleSource(const Particle* part)
45 {
46 return part->getParticleSource();
47 }
48
49 int particleMdstArrayIndex(const Particle* part)
50 {
51 return part->getMdstArrayIndex();
52 }
53
54 int uniqueParticleIdentifier(const Particle* part)
55 {
56 return part->getMdstSource();
57 }
58
59 bool particleIsUnspecified(const Particle* part)
60 {
61 int properties = part->getProperty();
62 return (properties & Particle::PropertyFlags::c_IsUnspecified) ? true : false;
63 }
64
65 double particlePvalue(const Particle* part)
66 {
67 return part->getPValue();
68 }
69
70 int particleNDaughters(const Particle* part)
71 {
72 return part->getNDaughters();
73 }
74
75 int particleFlavorType(const Particle* part)
76 {
77 return part->getFlavorType();
78 }
79
80 double particleCharge(const Particle* part)
81 {
82 return part->getCharge();
83 }
84
85 VARIABLE_GROUP("Basic particle information");
86 REGISTER_VARIABLE("isFromECL", particleIsFromECL,
87 "Returns 1.0 if this particle was created from an ``ECLCluster`` or 0.0 otherwise.");
88 REGISTER_VARIABLE("isFromKLM", particleIsFromKLM,
89 "Returns 1.0 if this particle was created from a ``KLMCluster`` or 0.0 otherwise.");
90 REGISTER_VARIABLE("isFromTrack", particleIsFromTrack, "Returns 1.0 if this particle was created from a track or 0.0 otherwise.");
91 REGISTER_VARIABLE("isFromV0", particleIsFromV0, R"DOC(
92Returns 1.0 if this particle was created from a V0 particle or 0.0 otherwise.
93
94)DOC");
95 REGISTER_VARIABLE("particleSource", particleSource, R"DOC(
96
97Returns the mDST source used to create the particle.
98
99The meaning of the values are:
100
101* 0: undefined
102* 1: created from track
103* 2: created from an ``ECLCluster``
104* 3: created from a ``KLMCluster``
105* 4: created from a V0 particle
106* 5: MC particle
107* 6: composite particle
108
109)DOC");
110 REGISTER_VARIABLE("mdstIndex", particleMdstArrayIndex, R"DOC(
111Returns the store array index (0 - based) of the mDST object from which the particle was created. For composite particles, this returns 0.0.
112
113.. caution::
114 Two particles of the same type can also have the same :b2:var:`mdstIndex`. This would mean that they are created from the same object.
115 For example, if pion and kaon have the same :b2:var:`mdstIndex` it means that they are created from the same track.
116
117.. warning::
118 This variable is not a unique identifier of the particle. For example, a pion and a photon can have the same `mdstIndex`; even though
119 pions are created from tracks and photons are created from ECL clusters, as tracks and
120 ECL clusters are kept in different store arrays they can return the same index.
121
122.. seealso::
123 If you are looking for unique identifier of the particle, please use :b2:var:`uniqueParticleIdentifier`.
124
125)DOC");
126 REGISTER_VARIABLE("uniqueParticleIdentifier", uniqueParticleIdentifier, R"DOC(
127Returns the unique identifier of a final state particle.
128Particles created from the same object (e.g. from the same track) have different :b2:var:`uniqueParticleIdentifier` values.
129
130)DOC");
131
132 REGISTER_VARIABLE("isUnspecified", particleIsUnspecified, R"DOC(
133Returns 1.0 if the particle is marked as an unspecified object (like B0 -> @Xsd e+ e-) or 0.0 otherwise.
134
135.. note:: You can read more about how to define such particles here: :ref:`Marker of unspecified particle <Marker_of_unspecified_particle>`.
136
137)DOC");
138 REGISTER_VARIABLE("chiProb", particlePvalue, R"DOC(
139Returns a context-dependent :math:`\chi^2` probability for 'the fit' related to this particle.
140
141The contexts are:
142
143* If this particle is track-based, then it returns the p-value of the track fit (identical to :b2:var:`pValue`).
144* If this particle is composite, and a vertex fit has been performed, then it returns the :math:`\chi^2` probability of the vertex fit result.
145* If this particle is cluster-based then this variable is currently unused.
146
147.. attention::
148 If multiple vertex fits have been performed then the last one sets the ``chiProb`` value and overwrites all the previous ones.
149
150)DOC");
151 REGISTER_VARIABLE("nDaughters", particleNDaughters, "Returns number of daughter particles or 0.0 otherwise for a particle with no daughters.");
152 REGISTER_VARIABLE("flavor", particleFlavorType, "Returns 1.0 if particle has flavour or 0.0 if it is unflavored.");
153 REGISTER_VARIABLE("charge", particleCharge, "Returns the electric charge of particle in units of :math:`e`.");
154 }
156}
@ c_IsUnspecified
Ordinary particles.
Definition Particle.h:120
Abstract base class for different kinds of events.