thepeg is hosted by Hepforge, IPPP Durham
ThePEG 2.3.0
ParticleTraits.h
1// -*- C++ -*-
2//
3// ParticleTraits.h is a part of ThePEG - Toolkit for HEP Event Generation
4// Copyright (C) 1999-2019 Leif Lonnblad
5//
6// ThePEG is licenced under version 3 of the GPL, see COPYING for details.
7// Please respect the MCnet academic guidelines, see GUIDELINES for details.
8//
9#ifndef ThePEG_ParticleTraits_H
10#define ThePEG_ParticleTraits_H
11// This is the declaration of the ParticleTraits class.
12
14// #include "ParticleTraits.fh"
15// #include "ParticleTraits.xh"
16
17namespace ThePEG {
18
19template <typename PType>
33struct ParticleTraits: public TraitsType {
34
38 static PType & ref(PType & p) {
39 return p;
40 }
41
45 static LorentzMomentum momentum(const PType & p) {
46 return p.momentum();
47 }
48
52 static Energy mass(const PType & p) {
53 return p.mass();
54 }
55
59 static void transform(PType & p, const LorentzRotation & r) {
60 p.transform(r);
61 }
62
66 static void set5Momentum(PType & p, const Lorentz5Momentum & q) {
67 p.set5Momentum(q);
68 }
69
74 static void set3Momentum(PType & p, const Momentum3 & q) {
75 p.set3Momentum(q);
76 }
77
81 static int iCharge(const PType & p) {
82 return p.data().iCharge();
83 }
84
85};
86
90template <>
91struct ParticleTraits<PPtr>: public TraitsType {
92
96 static Particle & ref(tPPtr p) {
97 return *p;
98 }
99
103 static const LorentzMomentum & momentum(tPPtr p) {
104 return p->momentum();
105 }
106
110 static Energy mass(tPPtr p) {
111 return p->mass();
112 }
113
117 static void transform(tPPtr p, const LorentzRotation & r) {
118 p->transform(r);
119 }
120
124 static void set5Momentum(tPPtr p, const Lorentz5Momentum & q) {
125 p->set5Momentum(q);
126 }
127
132 static void set3Momentum(tPPtr p, const Momentum3 & q) {
133 p->set3Momentum(q);
134 }
135
139 static int iCharge(tPPtr p) {
140 return p->data().iCharge();
141 }
142};
143
145template <>
146struct ParticleTraits<cPPtr>: public TraitsType {
147
151 static const Particle & ref(tcPPtr p) {
152 return *p;
153 }
154
158 static const LorentzMomentum & momentum(tcPPtr & p) {
159 return p->momentum();
160 }
161
165 static Energy mass(tcPPtr p) {
166 return p->mass();
167 }
168
172 static int iCharge(tcPPtr & p) {
173 return p->data().iCharge();
174 }
175};
176
178template <>
179struct ParticleTraits<tPPtr>: public TraitsType {
180
184 static Particle & ref(tPPtr p) {
185 return *p;
186 }
187
191 static const LorentzMomentum & momentum(tPPtr p) {
192 return p->momentum();
193 }
194
198 static Energy mass(tPPtr p) {
199 return p->mass();
200 }
201
205 static void transform(tPPtr p, const LorentzRotation & r) {
206 p->transform(r);
207 }
208
212 static void set5Momentum(tPPtr p, const Lorentz5Momentum & q) {
213 p->set5Momentum(q);
214 }
215
220 static void set3Momentum(tPPtr p, const Momentum3 & q) {
221 p->set3Momentum(q);
222 }
223
227 static int iCharge(tPPtr p) {
228 return p->data().iCharge();
229 }
230};
231
233template <>
234struct ParticleTraits<tcPPtr>: public TraitsType {
235
239 static const Particle & ref(tcPPtr p) {
240 return *p;
241 }
242
246 static const LorentzMomentum & momentum(tcPPtr p) {
247 return p->momentum();
248 }
249
253 static Energy mass(tcPPtr p) {
254 return p->mass();
255 }
256
260 static int iCharge(tcPPtr p) {
261 return p->data().iCharge();
262 }
263};
264
266template <typename T>
267struct ParticleTraits<T*>: public TraitsType {
268
272 static Particle & ref(T * p) {
273 return *p;
274 }
275
279 static const LorentzMomentum & momentum(T * p) {
281 }
282
286 static Energy mass(T * p) {
287 return ParticleTraits<T>::mass(*p);
288 }
289
293 static void transform(T * p, const LorentzRotation & r) {
295 }
296
300 static void set5Momentum(T * p, const Lorentz5Momentum & q) {
302 }
303
308 static void set3Momentum(T * p, const Momentum3 & q) {
310 }
311
315 static int iCharge(T * p) {
317 }
318};
319
322template <typename T>
323struct ParticleTraits<const T *>: public TraitsType {
324
328 static const Particle & ref(const T * p) {
329 return *p;
330 }
331
335 static const LorentzMomentum & momentum(const T * p) {
337 }
338
342 static Energy mass(const T * p) {
343 return ParticleTraits<T>::mass(*p);
344 }
345
349 static int iCharge(const T * p) {
351 }
352};
353
357template <>
358struct ParticleTraits<LorentzMomentum>: public TraitsType {
359
363 static LorentzMomentum & ref(LorentzMomentum & p) {
364 return p;
365 }
366
370 static const LorentzMomentum & momentum(const LorentzMomentum & p) {
371 return p;
372 }
373
377 static Energy mass(const LorentzMomentum & p) {
378 return p.m();
379 }
380
384 static void transform(LorentzMomentum & p, const LorentzRotation & r) {
385 p.transform(r);
386 }
387
391 static void set5Momentum(LorentzMomentum & p, const Lorentz5Momentum & q) {
392 p = q;
393 }
394
399 static void set3Momentum(LorentzMomentum & p, const Momentum3 & q) {
400 p = LorentzMomentum(q, sqrt(q.mag2() + p.m2()));
401 }
402};
403
407template <>
408struct ParticleTraits<Lorentz5Momentum>: public TraitsType {
409
414 return p;
415 }
416
420 static const LorentzMomentum & momentum(const Lorentz5Momentum & p) {
421 return p;
422 }
423
427 static Energy mass(const Lorentz5Momentum & p) {
428 return p.mass();
429 }
430
434 static void transform(Lorentz5Momentum & p, const LorentzRotation & r) {
435 p.transform(r);
436 }
437
441 static void set5Momentum(Lorentz5Momentum & p, const Lorentz5Momentum & q) {
442 p = q;
443 }
444
449 static void set3Momentum(Lorentz5Momentum & p, const Momentum3 & q) {
450 p = Lorentz5Momentum(p.mass(), q);
451 }
452};
453
461 Transformer(const LorentzRotation & rin) : r(rin) {}
463 Transformer(const Transformer & t) : r(t.r) {}
465 template <typename PType>
466 void operator()(const PType & p) {
468 }
471};
472
473}
474
475// #include "ParticleTraits.icc"
476#ifndef ThePEG_TEMPLATES_IN_CC_FILE
477// #include "ParticleTraits.tcc"
478#endif
479
480#endif /* ThePEG_ParticleTraits_H */
This is the main config header file for ThePEG.
The LorentzRotation class combine a SpinOneLorentzRotation and a spin SpinHalfLorentzRotation to prov...
A 3-component vector.
Definition: ThreeVector.h:35
Qty< 0, 1, 0 > Energy
Energy.
Definition: Unitsystem.h:42
ThreeVector< Energy > Momentum3
A momentum in three-dimensional euclidean space.
Definition: Unitsystem.h:136
Lorentz5Vector< Energy > Lorentz5Momentum
A momentum in four-dimensional space-time with an explicit invariant mass component.
Definition: Unitsystem.h:156
LorentzVector< Energy > LorentzMomentum
A momentum in four-dimensional space-time.
Definition: Unitsystem.h:152
This is the main namespace within which all identifiers in ThePEG are declared.
Definition: FactoryBase.h:28
ThePEG::Ptr< Particle >::transient_pointer tPPtr
Alias for a transient pointer to Particle .
Definition: Pointers.h:67
ThePEG::Ptr< Particle >::transient_const_pointer tcPPtr
Alias for a transient pointer to a const Particle .
Definition: Pointers.h:67
ThePEG::Ptr< Particle >::pointer PPtr
Alias for a reference counted pointer to Particle .
Definition: Pointers.h:67
ThePEG::Ptr< Particle >::const_pointer cPPtr
Alias for a reference counted pointer to a const Particle .
Definition: Pointers.h:67
ParticleTraits is a templated class defining a general interface to any particle class.
static void set3Momentum(PType &p, const Momentum3 &q)
Set the 3-momentum of a particle.
static void set5Momentum(PType &p, const Lorentz5Momentum &q)
Set the momentum and mass of a particle.
static PType & ref(PType &p)
Return a reference to the particle.
static int iCharge(const PType &p)
Return charge of particle p in units of e/3.
static Energy mass(const PType &p)
Return the mass of particle p.
static void transform(PType &p, const LorentzRotation &r)
Perform a Lorentz transformation on particle p.
static LorentzMomentum momentum(const PType &p)
Return the momentum of particle p.
TraitsType is an empty, non-polymorphic, base class.
Definition: ThePEG.h:94
A helper class to be used in std:: algorithms to transform a range of particles.
const LorentzRotation & r
A reference to the Lorentz rotation to be performed.
Transformer(const LorentzRotation &rin)
Constructor taking a reference to the Lorentz rotation to be performed.
Transformer(const Transformer &t)
Copy constructor.
void operator()(const PType &p)
Perform the rotation on a given particle.