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