AmpGen 2.1
Loading...
Searching...
No Matches
Particle.h
Go to the documentation of this file.
1#ifndef AMPGEN_PARTICLE_H
2#define AMPGEN_PARTICLE_H
3
4#include <complex>
5#include <vector>
6#include <memory>
7
8// hack to include optional from https://codereview.stackexchange.com/questions/136350/seamlessly-migrating-experimental-optional-to-optional
9#if __cplusplus >= 201703L
10#include <optional>
11namespace stdx {
12 using namespace ::std;
13}
14#elif __cplusplus >= 201402L
15#include <experimental/optional>
16namespace stdx {
17 using namespace ::std;
18 using namespace ::std::experimental;
19}
20#else
21#error "Require c++ std >=14"
22#endif
23
24#include "AmpGen/EventType.h"
25#include "AmpGen/Expression.h"
26#include "AmpGen/Tensor.h"
27#include "AmpGen/QuarkContent.h"
28#include "AmpGen/Property.h"
29#include "AmpGen/enum.h"
30#include "AmpGen/Units.h"
31#include "AmpGen/Configurable.h"
32
33namespace AmpGen {
99
100 declare_enum(spinFormalism, Covariant, Canonical);
101 declare_enum(spinBasis, Dirac, Weyl);
102
103 class Particle : public Configurable<Particle> {
104 public:
107
110 Particle(const std::string &name, const Particle &p1, const Particle &p2);
111
114 Particle(const int &pdg_id, const Particle &p1, const Particle &p2);
115
117 Particle(const std::string &name, const unsigned int &index);
118
120 Particle(const std::string &decayString, const std::vector<std::string> &finalStates = {}, const bool &orderDaughters = true);
121
123 Particle(const std::string &name, const std::vector<Particle> &particles);
124
127 Particle conj(bool invertHead = true, bool reorder = true);
128
129 virtual ~Particle() {}
131
132 void conjThis();
133
134 static bool isValidDecayDescriptor(const std::string &decayDescriptor);
136 void setOrbital(const unsigned int &orbital);
137
139 void setLineshape(const std::string &lineshape);
140
142 void setDaughter(const Particle &particle, const unsigned int &index);
143
145 void setParent(const Particle *particle);
146
148 void setIndex(const unsigned int &index, const bool &setOri = false);
149
152
154 void addModifier(const std::string &mod);
155
157 void parseModifier(const std::string &mod);
158
160 void setOrdering(const std::vector<size_t> &ordering);
161
163 void setName(const std::string &name);
164
166 void addDaughter(const std::shared_ptr<Particle> &particle);
167
169 void setPolarisationState(const int &state);
170 void setPolarisationState(const std::vector<int> &state);
171
173 std::pair<size_t, size_t> orbitalRange(const bool &converseParity = true) const;
174
176 std::vector<std::pair<double, double>> spinOrbitCouplings(const bool &conserveParity = true) const;
177
178 void setDaughters(const std::vector<Particle> &particles);
179
181 stdx::optional<std::string> attribute(const std::string &key) const;
182
184 const ParticleProperties *props() const;
185
187
189
190 int parity() const;
191 int finalStateParity() const;
192
193 int polState() const;
194 int CP() const;
195 int C() const;
196 double mass() const;
197 double spin() const;
198 double S() const;
199 unsigned L() const;
200
201 bool isHead() const;
202 bool isWeakDecay() const;
203 bool isStateGood() const;
204 bool isStable() const;
205 bool isQuasiStable() const;
206 bool conservesParity(unsigned int L = 0) const;
207
208 unsigned index() const;
209 unsigned originalIndex() const;
210 std::string name() const;
211 std::string lineshape() const;
212
213 std::string
214 uniqueString() const;
215 std::string
217
220 std::string topologicalString() const;
221
223 std::string orbitalString() const;
224
226 std::string texLabel(const bool &printHead = false, const bool &recurse = true) const;
227
230
232 const Particle *parent() const;
234 std::shared_ptr<Particle> daughter(const size_t &index);
235
237 std::shared_ptr<Particle> daughter(const size_t &index) const;
238
240 std::shared_ptr<Particle> daughter(const std::string &name, const int &maxDepth = -1) const;
241
243 std::vector<std::shared_ptr<Particle>> daughters() const;
244
246 std::vector<std::vector<size_t>> identicalDaughterOrderings() const;
247
249 std::vector<std::shared_ptr<Particle>> getFinalStateParticles(const bool &sort = true) const;
250
254
256 Tensor P() const;
257
259 Tensor Q() const;
260
262 Tensor spinTensor(DebugSymbols *db = nullptr) const;
263
265 Tensor externalSpinTensor(const int &polState, DebugSymbols *db = nullptr) const;
266
269
271 Expression propagator(DebugSymbols *db = nullptr) const;
272
274 Expression getExpression(DebugSymbols *db = nullptr, const std::vector<int> & = {});
275
277 bool lineshapeContains(const std::vector<std::string> &container) const {
278 for(auto &st : container)
279 if(m_lineshape.find(st) != std::string::npos) return true;
280 return false;
281 }
282
284 bool operator<(const Particle &other);
285 bool operator>(const Particle &other);
286
288 None = (1 << 0),
289 Exact = (1 << 1),
293 };
294
295 unsigned int matches(const Particle &other) const;
296 std::string makeUniqueString();
298 void setDaughter(const unsigned int &index, const Particle &p);
299
300 bool expand(const Particle &particle);
301
302 private:
303 std::string m_name = {""};
304 const ParticleProperties *m_props = {nullptr};
305 std::string m_lineshape = {"BW"};
306 std::string m_vertexName = {""};
307 std::string m_uniqueString = {""};
308 int m_parity = {0};
309 int m_polState = {0};
310 unsigned m_index = {999};
311 unsigned m_originalIndex = {999};
312 unsigned m_orbital = {0};
313 unsigned m_spinConfigurationNumber = {0};
314 unsigned m_minL = {0};
315 bool m_usesDefaultLineshape = {false};
316 bool m_isStateGood = {true};
317 std::vector<std::shared_ptr<Particle>> m_daughters;
318 std::vector<std::string> m_modifiers;
319 const Particle *m_parent = {nullptr};
320 void pdgLookup(bool quiet = false);
321 bool hasModifier(const std::string &modifier) const;
322 std::string modifierString() const;
323 void sortDaughters();
324
325 static constexpr std::string_view spin_basis_help = "Basis to use for calculating external polarisation tensors / spinors."
326 "\n\033[3m Dirac \033[0m: [default] Quantises along the z-axis"
327 "\n\033[3m Weyl \033[0m: Quantises along the direction of motion";
328
329 Property<spinFormalism> m_spinFormalism
330 = {this, "Particle::SpinFormalism", spinFormalism::Covariant,
332 "Formalism to use for spin calculations",
333 std::make_pair("Covariant", "[default] Covariant Tensor, based on Rarita-Schwinger constraints on the allowed covariant wavefunctions."),
334 std::make_pair(
335 "Canonical",
336 "Canonical formulation, based on rotational properties of wavefunctions, i.e. Wigner D-matrices and Clebsch-Gordan for (L,S) expansion."))};
337 Property<spinBasis> m_spinBasis = {this, "Particle::SpinBasis", spinBasis::Dirac, spin_basis_help};
338 Property<std::string> m_defaultModifier = {
339 this, "Particle::DefaultModifier", "", "Default modifier to use for lineshapes, for example to use normalised vs unnormalised Blatt-Weisskopf factors."};
340 Property<bool> m_movingHead
341 = {this, "Particle::MovingHead", true, "Assume the head of the decay chain is not at rest, only applies in canonical formulation."};
342 Property<bool> m_alignFrames
343 = {this, "Particle::AlignFrames", true, "Align the helicity definition of all particles to a common frame, that of the head of the decay chain."};
344 Property<double> m_stableThreshold = {this, "Particle::StableThreshold", KeV, "Lifetime threshold at which particle is considered stable (or quasistable)"};
345 };
346 std::ostream &operator<<(std::ostream &os, const Particle &particle);
347} // namespace AmpGen
348
349#endif
Deals with final state configuration of events, specifically dealing with the ordering of particles i...
Definition EventType.h:22
Wrapper class for shared_ptrs to virtual expressions for use in conjunction with operators to build e...
Definition Expression.h:135
Describes a particle, its decay process and subsequent decay products, which are also Particles.
Definition Particle.h:103
stdx::optional< std::string > attribute(const std::string &key) const
Return the additional optional attribute keyed by variable key.
Particle clone() const
unsigned int matches(const Particle &other) const
matches Check the matching between two decay chains, according to the MatchState enum.
std::string texLabel(const bool &printHead=false, const bool &recurse=true) const
Decay descriptor formatted as LaTeX for this decay.
void setName(const std::string &name)
Set the particle name.
void setIndex(const unsigned int &index, const bool &setOri=false)
Set the index of this particle, i.e. where it is positioned in the event data structure.
void setParent(const Particle *particle)
Set the parent particle for this particle.
void setOrbital(const unsigned int &orbital)
Set the orbital quantum number 'L' for this decay.
void setDaughter(const unsigned int &index, const Particle &p)
Particle(const std::string &name, const unsigned int &index)
Constructor by name and with an index to match to the event type.
int finalStateParity() const
Returns the parity of the final state of this particle.
void conjThis()
CP conjugate this particle //.
std::vector< std::vector< size_t > > identicalDaughterOrderings() const
Get orderings of the final state that are identical to each other, i.e. those that only differ by exc...
std::vector< std::shared_ptr< Particle > > daughters() const
Vector of decay products of this particle.
std::pair< size_t, size_t > orbitalRange(const bool &converseParity=true) const
Returns the range of orbital angular momentum between the decay products.
bool expand(const Particle &particle)
Tensor Q() const
Calculates the momentum difference between the decay products (only well defined for quasi two-body p...
std::vector< std::shared_ptr< Particle > > getFinalStateParticles(const bool &sort=true) const
Returns the final state particles for this decay process.
Particle(const int &pdg_id, const Particle &p1, const Particle &p2)
Constructor that takes a pair of other particles (i.e.
int C() const
Returns the C quantum number for this decay.
bool isHead() const
Returns whether if this particle is the head of the decay, i.e. has no parent.
bool isWeakDecay() const
Returns whether is this particle decays weakly or not.
std::string lineshape() const
Name of the propagator to use for the decay of this particle.
std::shared_ptr< Particle > daughter(const std::string &name, const int &maxDepth=-1) const
Returns in indexth decay product of this particle (as constant).
unsigned L() const
Returns the orbital angular.
Particle quasiStableTree() const
Calculate the particle tree only including quasi-stable processes, i.e.
const Particle * parent() const
Returns the parent of the particle.
int CP() const
Returns the CP of this decay.
int parity() const
Returns the parity of this particle.
Tensor spinTensor(DebugSymbols *db=nullptr) const
Calculates the spin tensor or generalised current for this particle.
unsigned index() const
Returns the current index of the particle in event data structure. Can differ from the original index...
void clearDecayProducts()
Remove all of the decay products of this particle.
void setPolarisationState(const int &state)
Set the polarisation state of this particle, which is twice the projection of the spin along the quan...
std::shared_ptr< Particle > daughter(const size_t &index)
Returns the indexth decay product of this particle.
Tensor externalSpinTensor(const int &polState, DebugSymbols *db=nullptr) const
Calculates the polarisation vector / spinor etc. of this particle, used for the initial/final state p...
bool conservesParity(unsigned int L=0) const
Check whether the decay of this particle with angular momentum L conserves parity or not.
Particle(const std::string &name, const std::vector< Particle > &particles)
Constructor that takes a set of particles.
unsigned originalIndex() const
Returns the original index of the particle.
void addModifier(const std::string &mod)
Add some modifier to the particle, such as a lineshape or a different spin state.
std::string orbitalString() const
The string that describes the spin/orbit configuration of this decay.
bool operator<(const Particle &other)
void setPolarisationState(const std::vector< int > &state)
std::string topologicalString() const
The string that describes the spin/orbital topology of this decay, i.e.
std::string makeUniqueString()
Generate the decay descriptor for this decay.
const ParticleProperties * props() const
Return the particleProperties object for this particle.
Particle()
Default Constructor.
QuarkContent daughterQuarks() const
Returns the quark content of the sum of the decay products of this particle.
Particle conj(bool invertHead=true, bool reorder=true)
(Quasi) Constructor that returns the (quasi)CP conjugated amplitude.
bool isQuasiStable() const
Check whether the particle is quasi-stable, i.e. may have some appreciable flight distance.
void setDaughters(const std::vector< Particle > &particles)
Expression propagator(DebugSymbols *db=nullptr) const
Calculates the lineshape / propagator for this particle.
bool lineshapeContains(const std::vector< std::string > &container) const
Check if lineshape contains a substring.
Definition Particle.h:277
Expression massSq() const
Calculates the invariant mass-squared of the mass of this particle.
void setLineshape(const std::string &lineshape)
Set the lineshape for the decay of this particle.
bool operator>(const Particle &other)
Tensor P() const
Calculates the momentum sum of the decay products.
QuarkContent quarks() const
Return the quarks of this particle.
std::shared_ptr< Particle > daughter(const size_t &index) const
Returns in indexth decay product of this particle (as constant).
void setOrdering(const std::vector< size_t > &ordering)
Set some particle ordering of the decay products of this particle, mostly used internally by the symm...
Expression getExpression(DebugSymbols *db=nullptr, const std::vector< int > &={})
Calculates the total expression for this particle, including symmetrisation and the current polarisat...
std::string name() const
Name of the decaying particle.
bool isStable() const
Check whether this particle is stable, has any decay products.
bool isStateGood() const
Returns whether this particle, and its decays have been configured correctly.
std::vector< std::pair< double, double > > spinOrbitCouplings(const bool &conserveParity=true) const
Returns the set of possible spin-orbit couplings allowed by conservation of angular momentum,...
int polState() const
Returns the polarisation state, i.e. twice the projection of the spin along the quantisation axis,...
void parseModifier(const std::string &mod)
Parse some set of modifiers, delimited with semicolons.
std::string decayDescriptor() const
Returns the unique string (i.e. decay descriptor) that identifies this decay, which can be parsed to ...
double mass() const
Returns the (PDG) mass of the particle.
EventType eventType() const
Return the eventType for this decay (i.e. the initial and final state particles).
double S() const
Returns the spin configuration of the decay products of the particle.
double spin() const
Returns the spin of the particle.
void setDaughter(const Particle &particle, const unsigned int &index)
Set the index'th daughter of this to particle.
Tensor transitionMatrix(DebugSymbols *db=nullptr)
Calculate the transition matrix for this decay.
Particle(const std::string &name, const Particle &p1, const Particle &p2)
Constructor that takes a pair of other particles (i.e.
Particle(const std::string &decayString, const std::vector< std::string > &finalStates={}, const bool &orderDaughters=true)
Constructor that takes a decay descriptor as an argument and a list of final state particles to match...
virtual ~Particle()
Definition Particle.h:129
std::string uniqueString() const
Returns the unique string (i.e. decay descriptor) that identifies this decay, which can be parsed to ...
void addDaughter(const std::shared_ptr< Particle > &particle)
Add a decay product.
static bool isValidDecayDescriptor(const std::string &decayDescriptor)
Class that contains the PDG properties (mass, width, charges, etc.) for a single particle species,...
#define declare_enum(name,...)
Definition enum.h:7
std::ostream & operator<<(std::ostream &os, const CompiledExpressionBase &expression)
std::string helpStringOptions(const std::string &header, const T &...args)
Definition Property.h:138
static const double KeV
Definition Units.h:9
std::vector< DebugSymbol > DebugSymbols
Definition Expression.h:111