Belle II Software light-2406-ragdoll
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, "Returns true if this particle was created from an ECLCluster, false otherwise.");
87 REGISTER_VARIABLE("isFromKLM", particleIsFromKLM, "Returns true if this particle was created from a KLMCluster, false otherwise.");
88 REGISTER_VARIABLE("isFromTrack", particleIsFromTrack, "Returns true if this particle was created from a track, false otherwise.");
89 REGISTER_VARIABLE("isFromV0", particleIsFromV0, "Returns true if this particle was created from a V0, false otherwise.");
90 REGISTER_VARIABLE("particleSource", particleSource, R"DOC(
91 Returns mdst source used to create the particle. The meaning of the values are
92
93 * 0: undefined
94 * 1: created from track
95 * 2: created from ECL cluster
96 * 3: created from KLM cluster
97 * 4: created from V0
98 * 5: MC particle
99 * 6: composite particle
100
101 )DOC");
102 REGISTER_VARIABLE("mdstIndex", particleMdstArrayIndex, R"DOC(
103Store array index (0 - based) of the MDST object from which the Particle was created.
104It's 0 for composite particles.
105
106.. tip::
107 It is not a unique identifier of particle. For example, a pion and a gamma can have the same `mdstIndex`:
108 pions are created from tracks whereas gammas are created from ECL clusters; tracks and
109 ECL clusters are stored in different arrays. A photon may be created from ECL cluster with index 0 and a
110 pion may be created from track with index 0 will both have :b2:var:`mdstIndex` equal to 0, but they will be different particles.
111
112.. tip::
113 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.
114 For example, if pion and kaon have the same :b2:var:`mdstIndex` it means that they are created from the same track.
115
116.. tip::
117 If you are looking for unique identifier of the particle, please use :b2:var:`uniqueParticleIdentifier`.
118 )DOC");
119 REGISTER_VARIABLE("uniqueParticleIdentifier", uniqueParticleIdentifier, R"DOC(
120Returns unique identifier of final state particle.
121Particles created from the same object (e.g. from the same track) have different :b2:var:`uniqueParticleIdentifier` value.)DOC");
122
123 REGISTER_VARIABLE("isUnspecified", particleIsUnspecified,
124 "Returns true if the particle is marked as an unspecified object (like B0 -> @Xsd e+ e-), false otherwise");
125 REGISTER_VARIABLE("chiProb", particlePvalue, R"DOC(
126A context-dependent :math:`\chi^2` probability for 'the fit' related to this particle.
127
128* If this particle is track-based, then this is the pvalue of the track fit (identical to :b2:var:`pValue`).
129* If this particle is cluster-based then this variable is currently unused.
130* If this particle is composite and a vertex fit has been performed, then this is the :math:`\chi^2` probability of the vertex fit result.
131
132.. tip::
133 If multiple vertex fits are performed then the last one sets the ``chiProb`` overwriting all previous.
134
135.. seealso:: :b2:var:`pValue` for tracks
136 )DOC");
137 REGISTER_VARIABLE("nDaughters", particleNDaughters,
138 "Returns number of daughter particles");
139 REGISTER_VARIABLE("flavor", particleFlavorType,
140 "Returns 1 if particle is flavored type, 0 if it is unflavored.");
141 REGISTER_VARIABLE("charge", particleCharge, "Returns electric charge of particle in units of :math:`e`.");
142 }
144}
@ c_IsUnspecified
Ordinary particles.
Definition: Particle.h:118
Abstract base class for different kinds of events.
Definition: ClusterUtils.h:24