00001
00002
00003
00004
00005
00006
00007
00008
00009 #ifndef ThePEG_UtilityBase_H
00010 #define ThePEG_UtilityBase_H
00011
00012 #include "ThePEG/Config/ThePEG.h"
00013 #include "ThePEG/EventRecord/ParticleTraits.h"
00014 #include "ThePEG/Utilities/Triplet.h"
00015
00016 namespace ThePEG {
00017
00024 struct UtilityBase {
00025
00032 template <typename Cont>
00033 static LorentzMomentum sumMomentum(const Cont & c) {
00034 return sumMomentum(c.begin(), c.end());
00035 }
00036
00043 template <typename Iterator>
00044 static LorentzMomentum sumMomentum(Iterator first, Iterator last) {
00045 LorentzMomentum sum;
00046 typedef typename std::iterator_traits<Iterator>::value_type PType;
00047 typedef ParticleTraits<PType> Traits;
00048
00049 while ( first != last ) sum += Traits::momentum(*first++);
00050 return sum;
00051 }
00052
00059 template <typename Iterator>
00060 static void transform(Iterator first, Iterator last,
00061 const LorentzRotation & boost) {
00062 typedef typename std::iterator_traits<Iterator>::value_type PType;
00063 typedef ParticleTraits<PType> Traits;
00064
00065 while ( first != last ) Traits::transform(*first++, boost);
00066 }
00067
00074 template <typename Cont>
00075 static void transform(Cont & cont, const LorentzRotation & boost) {
00076 transform(cont.begin(), cont.end(), boost);
00077 }
00078
00087 template <typename PType>
00088 static LorentzRotation boostToCM(const pair<PType,PType> & pp);
00089
00098 template <typename PType>
00099 static LorentzRotation boostToCM(const Triplet<PType,PType,PType> & pt);
00100
00108 template <typename PType>
00109 static LorentzRotation getBoostToCM(const pair<PType,PType> & pp);
00110
00119 template <typename PType>
00120 static LorentzRotation getBoostToCM(const Triplet<PType,PType,PType> & pt);
00121
00125 template <typename PType>
00126 static LorentzRotation getBoostFromCM(const pair<PType,PType> & pp);
00127
00131 template <typename PType>
00132 static LorentzRotation getBoostFromCM(const Triplet<PType,PType,PType> & pt);
00133
00141 template <typename Iterator>
00142 static LorentzRotation boostToCM(Iterator first, Iterator last) {
00143 return boostToCM(first, last, last, last);
00144 }
00145
00155 template <typename Iterator>
00156 static LorentzRotation boostToCM(Iterator first, Iterator last, Iterator zAxis) {
00157 return boostToCM(first, last, zAxis, last);
00158 }
00159
00170 template <typename Iterator>
00171 static LorentzRotation boostToCM(Iterator first, Iterator last,
00172 Iterator zAxis, Iterator xzPlane);
00173
00182 template <typename PType>
00183 static void setMomentum(PType & p, const Momentum3 & q);
00184
00193 template <typename PType>
00194 static void setMomentumFromCMS(PType & p, const Momentum3 & q);
00195
00205 template <typename Iter>
00206 static void setMomentum(Iter first, Iter last, const Momentum3 & q);
00207
00219 template <typename Iter>
00220 static void setMomentum(Iter first, Iter last,
00221 const Momentum3 & q, double eps);
00222
00236 template <typename Iter>
00237 static void setMomentumFromCMS(Iter first, Iter last,
00238 Energy2 m2, const Momentum3 & q);
00239
00251 template <typename PType>
00252 static LorentzRotation transformToMomentum(const PType & p,
00253 const Momentum3 & q) {
00254 typedef ParticleTraits<PType> Traits;
00255 LorentzMomentum q4(q, sqrt(q.mag2() + Traits::momentum(p).m2()));
00256 return transformToMomentum(p, q4);
00257 }
00258
00269 template <typename PType>
00270 static LorentzRotation transformToMomentum(const PType & p,
00271 const LorentzMomentum & q) {
00272 return transformFromCMS(q)*transformToCMS(p);
00273 }
00274
00280 template <typename PType>
00281 static LorentzRotation getTransformToMomentum(const PType & p,
00282 const LorentzMomentum & q,
00283 const LorentzMomentum & k) {
00284 typedef ParticleTraits<PType> Traits;
00285 LorentzMomentum k0 = Traits::momentum(p) - k;
00286 LorentzMomentum k1 = Traits::momentum(q) - k;
00287 return getBoostFromCM(make_pair(k1, k))*getBoostToCM(make_pair(k0, k));
00288 }
00289
00295 template <typename PType>
00296 static LorentzRotation getTransformToMomentum(const PType & p,
00297 const Momentum3 & q,
00298 const LorentzMomentum & k) {
00299 typedef ParticleTraits<PType> Traits;
00300 LorentzMomentum q4(q, sqrt(q.mag2() + Traits::momentum(p).m2()));
00301 return getTransformToMomentum(p, q4, k);
00302 }
00303
00310 template <typename LV>
00311 static LorentzRotation transformFromCMS(const LV & p);
00312
00320 template <typename LV>
00321 static LorentzRotation transformFromCMS(const LV & sum, LV zAxis);
00322
00330 template <typename LV>
00331 static LorentzRotation transformFromCMS(const LV & sum,
00332 const LV & zAxis, LV xyPlane);
00333
00340 template <typename LV>
00341 static LorentzRotation transformToCMS(const LV & sum, LV zAxis);
00342
00350 template <typename LV>
00351 static LorentzRotation transformToCMS(const LV & p);
00352
00360 template <typename LV>
00361 static LorentzRotation transformToCMS(const LV & sum,
00362 const LV & zAxis, LV xyPlane);
00363
00368 template <typename Cont1, typename Cont2>
00369 static void add(Cont1 & c1, const Cont2 & c2);
00370
00371 };
00372
00374 struct Utilities: public UtilityBase {};
00375
00376 }
00377
00378 #ifndef ThePEG_TEMPLATES_IN_CC_FILE
00379 #include "UtilityBase.tcc"
00380 #endif
00381
00382 #endif