thepeg
is hosted by
Hepforge
,
IPPP Durham
ThePEG
2.3.0
EventRecord
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
13
#include "
ThePEG/Config/ThePEG.h
"
14
// #include "ParticleTraits.fh"
15
// #include "ParticleTraits.xh"
16
17
namespace
ThePEG
{
18
19
template
<
typename
PType>
33
struct
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
90
template
<>
91
struct
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
145
template
<>
146
struct
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
178
template
<>
179
struct
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
233
template
<>
234
struct
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
266
template
<
typename
T>
267
struct
ParticleTraits<T*>:
public
TraitsType {
268
272
static
Particle & ref(T * p) {
273
return
*p;
274
}
275
279
static
const
LorentzMomentum
& momentum(T * p) {
280
return
ParticleTraits<T>::momentum
(*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) {
294
ParticleTraits<T>::transform
(*p, r);
295
}
296
300
static
void
set5Momentum(T * p,
const
Lorentz5Momentum
& q) {
301
ParticleTraits<T>::set5Momentum
(*p, q);
302
}
303
308
static
void
set3Momentum(T * p,
const
Momentum3
& q) {
309
ParticleTraits<T>::set3Momentum
(*p, q);
310
}
311
315
static
int
iCharge(T * p) {
316
return
ParticleTraits<T>::iCharge
(*p);
317
}
318
};
319
322
template
<
typename
T>
323
struct
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) {
336
return
ParticleTraits<T>::momentum
(*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) {
350
return
ParticleTraits<T>::iCharge
(*p);
351
}
352
};
353
357
template
<>
358
struct
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
407
template
<>
408
struct
ParticleTraits<
Lorentz5Momentum
>:
public
TraitsType {
409
413
static
Lorentz5Momentum
&
ref
(
Lorentz5Momentum
& p) {
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
458
struct
Transformer
{
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) {
467
ParticleTraits<PType>::transform
(p,
r
);
468
}
470
const
LorentzRotation
&
r
;
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 */
ThePEG.h
This is the main config header file for ThePEG.
ThePEG::Lorentz5Vector< Energy >
ThePEG::LorentzRotation
The LorentzRotation class combine a SpinOneLorentzRotation and a spin SpinHalfLorentzRotation to prov...
Definition:
LorentzRotation.h:27
ThePEG::LorentzVector< Energy >
ThePEG::Qty< 0, 1, 0 >
ThePEG::ThreeVector
A 3-component vector.
Definition:
ThreeVector.h:35
ThePEG::Units::Energy
Qty< 0, 1, 0 > Energy
Energy.
Definition:
Unitsystem.h:42
ThePEG::Units::Momentum3
ThreeVector< Energy > Momentum3
A momentum in three-dimensional euclidean space.
Definition:
Unitsystem.h:136
ThePEG::Units::Lorentz5Momentum
Lorentz5Vector< Energy > Lorentz5Momentum
A momentum in four-dimensional space-time with an explicit invariant mass component.
Definition:
Unitsystem.h:156
ThePEG::Units::LorentzMomentum
LorentzVector< Energy > LorentzMomentum
A momentum in four-dimensional space-time.
Definition:
Unitsystem.h:152
ThePEG
This is the main namespace within which all identifiers in ThePEG are declared.
Definition:
FactoryBase.h:28
ThePEG::tPPtr
ThePEG::Ptr< Particle >::transient_pointer tPPtr
Alias for a transient pointer to Particle .
Definition:
Pointers.h:67
ThePEG::tcPPtr
ThePEG::Ptr< Particle >::transient_const_pointer tcPPtr
Alias for a transient pointer to a const Particle .
Definition:
Pointers.h:67
ThePEG::PPtr
ThePEG::Ptr< Particle >::pointer PPtr
Alias for a reference counted pointer to Particle .
Definition:
Pointers.h:67
ThePEG::cPPtr
ThePEG::Ptr< Particle >::const_pointer cPPtr
Alias for a reference counted pointer to a const Particle .
Definition:
Pointers.h:67
ThePEG::ParticleTraits
ParticleTraits is a templated class defining a general interface to any particle class.
Definition:
ParticleTraits.h:33
ThePEG::ParticleTraits::set3Momentum
static void set3Momentum(PType &p, const Momentum3 &q)
Set the 3-momentum of a particle.
Definition:
ParticleTraits.h:74
ThePEG::ParticleTraits::set5Momentum
static void set5Momentum(PType &p, const Lorentz5Momentum &q)
Set the momentum and mass of a particle.
Definition:
ParticleTraits.h:66
ThePEG::ParticleTraits::ref
static PType & ref(PType &p)
Return a reference to the particle.
Definition:
ParticleTraits.h:38
ThePEG::ParticleTraits::iCharge
static int iCharge(const PType &p)
Return charge of particle p in units of e/3.
Definition:
ParticleTraits.h:81
ThePEG::ParticleTraits::mass
static Energy mass(const PType &p)
Return the mass of particle p.
Definition:
ParticleTraits.h:52
ThePEG::ParticleTraits::transform
static void transform(PType &p, const LorentzRotation &r)
Perform a Lorentz transformation on particle p.
Definition:
ParticleTraits.h:59
ThePEG::ParticleTraits::momentum
static LorentzMomentum momentum(const PType &p)
Return the momentum of particle p.
Definition:
ParticleTraits.h:45
ThePEG::TraitsType
TraitsType is an empty, non-polymorphic, base class.
Definition:
ThePEG.h:94
ThePEG::Transformer
A helper class to be used in std:: algorithms to transform a range of particles.
Definition:
ParticleTraits.h:458
ThePEG::Transformer::r
const LorentzRotation & r
A reference to the Lorentz rotation to be performed.
Definition:
ParticleTraits.h:470
ThePEG::Transformer::Transformer
Transformer(const LorentzRotation &rin)
Constructor taking a reference to the Lorentz rotation to be performed.
Definition:
ParticleTraits.h:461
ThePEG::Transformer::Transformer
Transformer(const Transformer &t)
Copy constructor.
Definition:
ParticleTraits.h:463
ThePEG::Transformer::operator()
void operator()(const PType &p)
Perform the rotation on a given particle.
Definition:
ParticleTraits.h:466
Generated on Thu Jun 20 2024 14:47:00 for ThePEG by
1.9.6