thepeg is hosted by Hepforge, IPPP Durham
ThePEG 2.3.0
UtilityBase.h
1// -*- C++ -*-
2//
3// UtilityBase.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_UtilityBase_H
10#define ThePEG_UtilityBase_H
11
13#include "ThePEG/EventRecord/ParticleTraits.h"
14#include "ThePEG/Utilities/Triplet.h"
15
16namespace ThePEG {
17
25
32 template <typename Cont>
33 static LorentzMomentum sumMomentum(const Cont & c) {
34 return sumMomentum(c.begin(), c.end());
35 }
36
43 template <typename Iterator>
44 static LorentzMomentum sumMomentum(Iterator first, Iterator last) {
46 typedef typename std::iterator_traits<Iterator>::value_type PType;
47 typedef ParticleTraits<PType> Traits;
48
49 while ( first != last ) sum += Traits::momentum(*first++);
50 return sum;
51 }
52
59 template <typename Iterator>
60 static void transform(Iterator first, Iterator last,
61 const LorentzRotation & boost) {
62 typedef typename std::iterator_traits<Iterator>::value_type PType;
63 typedef ParticleTraits<PType> Traits;
64
65 while ( first != last ) Traits::transform(*first++, boost);
66 }
67
74 template <typename Cont>
75 static void transform(Cont & cont, const LorentzRotation & boost) {
76 transform(cont.begin(), cont.end(), boost);
77 }
78
87 template <typename PType>
88 static LorentzRotation boostToCM(const pair<PType,PType> & pp);
89
98 template <typename PType>
100
108 template <typename PType>
109 static LorentzRotation getBoostToCM(const pair<PType,PType> & pp);
110
119 template <typename PType>
121
125 template <typename PType>
126 static LorentzRotation getBoostFromCM(const pair<PType,PType> & pp);
127
131 template <typename PType>
133
141 template <typename Iterator>
142 static LorentzRotation boostToCM(Iterator first, Iterator last) {
143 return boostToCM(first, last, last, last);
144 }
145
155 template <typename Iterator>
156 static LorentzRotation boostToCM(Iterator first, Iterator last, Iterator zAxis) {
157 return boostToCM(first, last, zAxis, last);
158 }
159
170 template <typename Iterator>
171 static LorentzRotation boostToCM(Iterator first, Iterator last,
172 Iterator zAxis, Iterator xzPlane);
173
182 template <typename PType>
183 static void setMomentum(PType & p, const Momentum3 & q);
184
193 template <typename PType>
194 static void setMomentumFromCMS(PType & p, const Momentum3 & q);
195
205 template <typename Iter>
206 static void setMomentum(Iter first, Iter last, const Momentum3 & q);
207
219 template <typename Iter>
220 static void setMomentum(Iter first, Iter last,
221 const Momentum3 & q, double eps);
222
236 template <typename Iter>
237 static void setMomentumFromCMS(Iter first, Iter last,
238 Energy2 m2, const Momentum3 & q);
239
251 template <typename PType>
252 static LorentzRotation transformToMomentum(const PType & p,
253 const Momentum3 & q) {
254 typedef ParticleTraits<PType> Traits;
255 LorentzMomentum q4(q, sqrt(q.mag2() + Traits::momentum(p).m2()));
256 return transformToMomentum(p, q4);
257 }
258
269 template <typename PType>
270 static LorentzRotation transformToMomentum(const PType & p,
271 const LorentzMomentum & q) {
272 return transformFromCMS(q)*transformToCMS(p);
273 }
274
280 template <typename PType>
282 const LorentzMomentum & q,
283 const LorentzMomentum & k) {
284 typedef ParticleTraits<PType> Traits;
285 LorentzMomentum k0 = Traits::momentum(p) - k;
286 LorentzMomentum k1 = Traits::momentum(q) - k;
287 return getBoostFromCM(make_pair(k1, k))*getBoostToCM(make_pair(k0, k));
288 }
289
295 template <typename PType>
297 const Momentum3 & q,
298 const LorentzMomentum & k) {
299 typedef ParticleTraits<PType> Traits;
300 LorentzMomentum q4(q, sqrt(q.mag2() + Traits::momentum(p).m2()));
301 return getTransformToMomentum(p, q4, k);
302 }
303
310 template <typename LV>
311 static LorentzRotation transformFromCMS(const LV & p);
312
320 template <typename LV>
321 static LorentzRotation transformFromCMS(const LV & sum, LV zAxis);
322
330 template <typename LV>
331 static LorentzRotation transformFromCMS(const LV & sum,
332 const LV & zAxis, LV xyPlane);
333
340 template <typename LV>
341 static LorentzRotation transformToCMS(const LV & sum, LV zAxis);
342
350 template <typename LV>
351 static LorentzRotation transformToCMS(const LV & p);
352
360 template <typename LV>
361 static LorentzRotation transformToCMS(const LV & sum,
362 const LV & zAxis, LV xyPlane);
363
368 template <typename Cont1, typename Cont2>
369 static void add(Cont1 & c1, const Cont2 & c2);
370
371};
372
374struct Utilities: public UtilityBase {};
375
376}
377
378#ifndef ThePEG_TEMPLATES_IN_CC_FILE
379#include "UtilityBase.tcc"
380#endif
381
382#endif /* ThePEG_UtilityBase_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
Value2 mag2() const
Squared magnitude .
Definition: ThreeVector.h:71
This is the main namespace within which all identifiers in ThePEG are declared.
Definition: FactoryBase.h:28
ParticleTraits is a templated class defining a general interface to any particle class.
The Triplet class represents a general triplet of objects completely analogous to std::pair.
Definition: Triplet.h:21
Concrete class with UtilityBase as base class.
Definition: UtilityBase.h:374
UtilityBase is a base class implementing a number of static utility functions.
Definition: UtilityBase.h:24
static void setMomentumFromCMS(PType &p, const Momentum3 &q)
Boost p along the z-axis and rotate it so that, if it was previously at rest, it ends up with momentu...
static LorentzRotation getBoostFromCM(const pair< PType, PType > &pp)
Get the inverse boost as compared to getBoostToCM.
static void add(Cont1 &c1, const Cont2 &c2)
Add the elements in Cont2 to Cont1, appending them to the end if possible.
static LorentzRotation boostToCM(Iterator first, Iterator last, Iterator zAxis)
Boost the entries between fisrt and last into their CM system.
Definition: UtilityBase.h:156
static LorentzRotation boostToCM(const pair< PType, PType > &pp)
Boost the two objects in the pair to their CM system.
static LorentzMomentum sumMomentum(Iterator first, Iterator last)
Sums the four-momentum of the entries between first and last.
Definition: UtilityBase.h:44
static LorentzRotation transformFromCMS(const LV &sum, const LV &zAxis, LV xyPlane)
Create a rotation corresponding to transforming sum to its current value from its CMS,...
static LorentzMomentum sumMomentum(const Cont &c)
Sums the four-momentum of given container.
Definition: UtilityBase.h:33
static void transform(Iterator first, Iterator last, const LorentzRotation &boost)
Transform the entries between first and last.
Definition: UtilityBase.h:60
static LorentzRotation getBoostToCM(const pair< PType, PType > &pp)
Obtain the LorentzRotation needed to boost the two objects in the pair to their CM system.
static LorentzRotation transformFromCMS(const LV &p)
Create a rotation corresponding to transforming p to its current value from its CMS by first boosting...
static LorentzRotation getTransformToMomentum(const PType &p, const Momentum3 &q, const LorentzMomentum &k)
Return a transformation appropriate for transforming p to have the momentum q.
Definition: UtilityBase.h:296
static void setMomentum(Iter first, Iter last, const Momentum3 &q, double eps)
Rotate the range of particles so their sum is along z-axis then boost them along the z-axis and rotat...
static LorentzRotation transformToCMS(const LV &p)
Create a rotation which would transform sum to its CMS frame first rotating it to the z-axis and then...
static LorentzRotation transformToMomentum(const PType &p, const Momentum3 &q)
Return the transformation needed to rotate p to the z-axis and boost it to its CMS,...
Definition: UtilityBase.h:252
static LorentzRotation transformToMomentum(const PType &p, const LorentzMomentum &q)
Return the transformation needed to rotate p to the z-axis and boost it to its CMS,...
Definition: UtilityBase.h:270
static void setMomentum(Iter first, Iter last, const Momentum3 &q)
Rotate the range of particles so their sum is along z-axis and boost them to their CMS,...
static LorentzRotation transformFromCMS(const LV &sum, LV zAxis)
Create a rotation corresponding to transforming sum to its current value from its CMS,...
static void transform(Cont &cont, const LorentzRotation &boost)
Transform the entries in a container cont.
Definition: UtilityBase.h:75
static void setMomentum(PType &p, const Momentum3 &q)
Rotate p to the z-axis and boost it to its CMS, then boost it along the z-axis and rotate it so that ...
static LorentzRotation transformToCMS(const LV &sum, LV zAxis)
Create a rotation which would transform sum to its CMS frame with zAxis along the z-axis in that fram...
static LorentzRotation boostToCM(Iterator first, Iterator last)
Boost the entries between fisrt and last into their CM system.
Definition: UtilityBase.h:142
static void setMomentumFromCMS(Iter first, Iter last, Energy2 m2, const Momentum3 &q)
Boost the range of particles along the z-axis and rotate them so that, if they were previously in the...
static LorentzRotation getBoostToCM(const Triplet< PType, PType, PType > &pt)
Obtain the LorentzRotation needed to boost the three objects in the Triplet to their CM system.
static LorentzRotation getTransformToMomentum(const PType &p, const LorentzMomentum &q, const LorentzMomentum &k)
Return a transformation appropriate for transforming p to have the momentum q.
Definition: UtilityBase.h:281
static LorentzRotation getBoostFromCM(const Triplet< PType, PType, PType > &pt)
Get the inverse boost as compared to getBoostToCM.
static LorentzRotation boostToCM(Iterator first, Iterator last, Iterator zAxis, Iterator xzPlane)
Boost the entries between fisrt and last into their CM system.
static LorentzRotation transformToCMS(const LV &sum, const LV &zAxis, LV xyPlane)
Create a rotation which would transform sum to its CMS frame with zAxis along the z-axis and xyPlane ...
static LorentzRotation boostToCM(const Triplet< PType, PType, PType > &pt)
Boost the three objects in the Triplet to their CM system.