ThePEG  1.8.0
UtilityBase.h
1 // -*- C++ -*-
2 //
3 // UtilityBase.h is a part of ThePEG - Toolkit for HEP Event Generation
4 // Copyright (C) 1999-2011 Leif Lonnblad
5 //
6 // ThePEG is licenced under version 2 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 
12 #include "ThePEG/Config/ThePEG.h"
13 #include "ThePEG/EventRecord/ParticleTraits.h"
14 #include "ThePEG/Utilities/Triplet.h"
15 
16 namespace ThePEG {
17 
24 struct UtilityBase {
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) {
45  LorentzMomentum sum;
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>
281  static LorentzRotation getTransformToMomentum(const PType & p,
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>
296  static LorentzRotation getTransformToMomentum(const PType & p,
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 
374 struct 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 */