Belle II Software  release-06-02-00
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 #include <analysis/variables/BasicParticleInformation.h>
10 #include <analysis/VariableManager/Manager.h>
11 #include <analysis/dataobjects/Particle.h>
12 
13 namespace Belle2 {
18  namespace Variable {
19 
20  double particleIsFromECL(const Particle* part)
21  {
22  return (part->getParticleSource() == Particle::EParticleSourceObject::c_ECLCluster);
23  }
24 
25  double particleIsFromKLM(const Particle* part)
26  {
27  return (part->getParticleSource() == Particle::EParticleSourceObject::c_KLMCluster);
28  }
29 
30  double particleIsFromTrack(const Particle* part)
31  {
32  return (part->getParticleSource() == Particle::EParticleSourceObject::c_Track);
33  }
34 
35  double particleIsFromV0(const Particle* part)
36  {
37  return (part->getParticleSource() == Particle::EParticleSourceObject::c_V0);
38  }
39 
40  double particleSource(const Particle* part)
41  {
42  return part->getParticleSource();
43  }
44 
45  double particleMdstArrayIndex(const Particle* part)
46  {
47  return part->getMdstArrayIndex();
48  }
49 
50  double uniqueParticleIdentifier(const Particle* part)
51  {
52  return part->getMdstSource();
53  }
54 
55  double particleIsUnspecified(const Particle* part)
56  {
57  int properties = part->getProperty();
58  return (properties & Particle::PropertyFlags::c_IsUnspecified) ? 1.0 : 0.0;
59  }
60 
61  double particlePvalue(const Particle* part)
62  {
63  return part->getPValue();
64  }
65 
66  double particleNDaughters(const Particle* part)
67  {
68  return part->getNDaughters();
69  }
70 
71  double particleFlavorType(const Particle* part)
72  {
73  return part->getFlavorType();
74  }
75 
76  double particleCharge(const Particle* part)
77  {
78  return part->getCharge();
79  }
80 
81  VARIABLE_GROUP("Basic particle information");
82  REGISTER_VARIABLE("isFromECL", particleIsFromECL, "Returns 1.0 if this particle was created from an ECLCluster, 0 otherwise.");
83  REGISTER_VARIABLE("isFromKLM", particleIsFromKLM, "Returns 1.0 if this particle was created from a KLMCluster, 0 otherwise.");
84  REGISTER_VARIABLE("isFromTrack", particleIsFromTrack, "Returns 1.0 if this particle was created from a track, 0 otherwise.");
85  REGISTER_VARIABLE("isFromV0", particleIsFromV0, "Returns 1.0 if this particle was created from a V0, 0 otherwise.");
86  REGISTER_VARIABLE("particleSource", particleSource, R"DOC(
87  Returns mdst source used to create the particle. The meaning of the values are
88 
89  * 0: undefined
90  * 1: created from track
91  * 2: created from ECL cluster
92  * 3: created from KLM cluster
93  * 4: created from V0
94  * 5: MC particle
95  * 6: composite particle
96 
97  )DOC");
98  REGISTER_VARIABLE("mdstIndex", particleMdstArrayIndex, R"DOC(
99 Store array index (0 - based) of the MDST object from which the Particle was created.
100 It's 0 for composite particles.
101 
102 .. tip::
103  It is not a unique identifier of particle. For example, a pion and a gamma can have the same `mdstIndex`:
104  pions are created from tracks whereas gammas are created from ECL clusters; tracks and
105  ECL clusters are stored in different arrays. A photon may be created from ECL cluster with index 0 and a
106  pion may be created from track with index 0 will both have :b2:var:`mdstIndex` equal to 0, but they will be different particles.
107 
108 .. tip::
109  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.
110  For example, if pion and kaon have the same :b2:var:`mdstIndex` it means that they are created from the same track.
111 
112 
113  .. tip::
114  If you are looking for unique identifier of the particle, please use :b2:var:`uniqueParticleIdentifier`.
115  )DOC");
116  REGISTER_VARIABLE("uniqueParticleIdentifier", uniqueParticleIdentifier, R"DOC(
117 Returns unique identifier of final state particle.
118 Particles created from the same object (e.g. from the same track) have different :b2:var:`uniqueParticleIdentifier` value.)DOC");
119 
120  REGISTER_VARIABLE("isUnspecified", particleIsUnspecified,
121  "Returns 1 if the particle is marked as an unspecified object (like B0 -> @Xsd e+ e-), 0 otherwise");
122  REGISTER_VARIABLE("chiProb", particlePvalue, R"DOC(
123 A context-dependent :math:`\chi^2` probability for 'the fit' related to this particle.
124 
125 * If this particle is track-based, then this is the pvalue of the track fit (identical to :b2:var:`pValue`).
126 * If this particle is cluster-based then this variable is currently unused.
127 * 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.
128 
129 .. tip::
130  If multiple vertex fits are performed then the last one sets the ``chiProb`` overwriting all previous.
131 
132 .. seealso:: :b2:var:`pValue` for tracks
133  )DOC");
134  REGISTER_VARIABLE("nDaughters", particleNDaughters,
135  "Returns number of daughter particles");
136  REGISTER_VARIABLE("flavor", particleFlavorType,
137  "Returns 1.0 if particle is flavored type, 0.0 if it is unflavored.");
138  REGISTER_VARIABLE("charge", particleCharge, "Returns electric charge of particle in units of :math:`e`.");
139  }
141 }
Abstract base class for different kinds of events.