/usr/include/ThePEG/Utilities/UtilityBase.h is in libthepeg-dev 1.8.0-1.1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 | // -*- C++ -*-
//
// UtilityBase.h is a part of ThePEG - Toolkit for HEP Event Generation
// Copyright (C) 1999-2011 Leif Lonnblad
//
// ThePEG is licenced under version 2 of the GPL, see COPYING for details.
// Please respect the MCnet academic guidelines, see GUIDELINES for details.
//
#ifndef ThePEG_UtilityBase_H
#define ThePEG_UtilityBase_H
#include "ThePEG/Config/ThePEG.h"
#include "ThePEG/EventRecord/ParticleTraits.h"
#include "ThePEG/Utilities/Triplet.h"
namespace ThePEG {
/**
* UtilityBase is a base class implementing a number of static utility
* functions. It should be used as a base class to give acces to these
* functions to a class. A class can safely multiply inherit from this
* class as it only contains static functions.
*/
struct UtilityBase {
/**
* Sums the four-momentum of given container. The class
* <code>Cont::value_type</code> must be of a type <code>T</code>
* for which <code>ParticleTraits<T>::momentum(const T&)</code> is
* implemented correctly.
*/
template <typename Cont>
static LorentzMomentum sumMomentum(const Cont & c) {
return sumMomentum(c.begin(), c.end());
}
/**
* Sums the four-momentum of the entries between first and last. The
* class <code>Iterator::value_type</code> must be of a type
* <code>T</code> for which <code>ParticleTraits<T>::momentum(const
* T&)</code> is implemented correctly.
*/
template <typename Iterator>
static LorentzMomentum sumMomentum(Iterator first, Iterator last) {
LorentzMomentum sum;
typedef typename std::iterator_traits<Iterator>::value_type PType;
typedef ParticleTraits<PType> Traits;
while ( first != last ) sum += Traits::momentum(*first++);
return sum;
}
/**
* Transform the entries between \a first and \a last. The class
* <code>Iterator::value_type</code> must be of a type
* <code>T</code> for which <code>ParticleTraits<T>::momentum(const
* T&)</code> is implemented correctly.
*/
template <typename Iterator>
static void transform(Iterator first, Iterator last,
const LorentzRotation & boost) {
typedef typename std::iterator_traits<Iterator>::value_type PType;
typedef ParticleTraits<PType> Traits;
while ( first != last ) Traits::transform(*first++, boost);
}
/**
* Transform the entries in a container \a cont. The class
* <code>Cont::value_type</code> must be of a type <code>T</code>
* for which <code>ParticleTraits<T>::momentum(const T&)</code> is
* implemented correctly.
*/
template <typename Cont>
static void transform(Cont & cont, const LorentzRotation & boost) {
transform(cont.begin(), cont.end(), boost);
}
/**
* Boost the two objects in the pair to their CM system. Also rotate
* so that the first is along the z-axis. The class
* <code>PType</code> must have
* <code>ParticleTraits<PType>::momentum(const PType&)</code> and
* <code>ParticleTraits<PType>::transform(PType&, const
* LorentzRotation&)</code> implemented correctly.
*/
template <typename PType>
static LorentzRotation boostToCM(const pair<PType,PType> & pp);
/**
* Boost the three objects in the Triplet to their CM system. Also
* rotate so that the first is along the z-axis and the second is in
* the x-z plane with positive x. The class <code>PType</code> must
* have <code>ParticleTraits<PType>::momentum(const PType&)</code>
* and <code>ParticleTraits<PType>::transform(PType&, const
* LorentzRotation&)</code> implemented correctly.
*/
template <typename PType>
static LorentzRotation boostToCM(const Triplet<PType,PType,PType> & pt);
/**
* Obtain the LorentzRotation needed to boost the two objects in the
* pair to their CM system. Also rotate the LorentzRotation so that
* the first is along the z-axis. The class <code>PType</code> must
* have <code>ParticleTraits<PType>::momentum(const PType&)</code>
* implemented correctly.
*/
template <typename PType>
static LorentzRotation getBoostToCM(const pair<PType,PType> & pp);
/**
* Obtain the LorentzRotation needed to boost the three objects in
* the Triplet to their CM system. Also rotate the LorentzRotation
* so that the first is along the z-axis and the secons i in the x-z
* plane with positive x. The class <code>PType</code>
* must have <code>ParticleTraits<PType>::momentum(const
* PType&)</code> implemented correctly.
*/
template <typename PType>
static LorentzRotation getBoostToCM(const Triplet<PType,PType,PType> & pt);
/**
* Get the inverse boost as compared to getBoostToCM.
*/
template <typename PType>
static LorentzRotation getBoostFromCM(const pair<PType,PType> & pp);
/**
* Get the inverse boost as compared to getBoostToCM.
*/
template <typename PType>
static LorentzRotation getBoostFromCM(const Triplet<PType,PType,PType> & pt);
/**
* Boost the entries between fisrt and last into their CM system.
* The class <code>Iterator::value_type</code> must be of a type
* <code>T</code> for which <code>ParticleTraits<T>::momentum(const
* T&)</code> and <code>ParticleTraits<T>::transform(T&, const
* LorentzRotation&)</code> are implemented correctly.
*/
template <typename Iterator>
static LorentzRotation boostToCM(Iterator first, Iterator last) {
return boostToCM(first, last, last, last);
}
/**
* Boost the entries between fisrt and last into their CM system. If
* zAxis != last, also rotate the entries so that zAxis becomes
* paralell to the z-axis. The class
* <code>Iterator::value_type</code> must be of a type
* <code>T</code> for which <code>ParticleTraits<T>::momentum(const
* T&)</code> and <code>ParticleTraits<T>::transform(T&, const
* LorentzRotation&)</code> are implemented correctly.
*/
template <typename Iterator>
static LorentzRotation boostToCM(Iterator first, Iterator last, Iterator zAxis) {
return boostToCM(first, last, zAxis, last);
}
/**
* Boost the entries between fisrt and last into their CM system. If
* zAxis != last, also rotate the entries so that zAxis becomes
* paralell to the z-axis. Also, if xzPlane != last, rotate the
* entries so that xzPlane is placed in the xz-plane. The class
* <code>Iterator::value_type</code> must be of a type
* <code>T</code> for which <code>ParticleTraits<T>::momentum(const
* T&)</code> and <code>ParticleTraits<T>::transform(T&, const
* LorentzRotation&)</code> are implemented correctly.
*/
template <typename Iterator>
static LorentzRotation boostToCM(Iterator first, Iterator last,
Iterator zAxis, Iterator xzPlane);
/**
* Rotate p to the z-axis and boost it to its CMS, then boost it
* along the z-axis and rotate it so that it ends up with momentum
* q. If p is massless - simply set its momentum. The class
* <code>PType</code> must have
* <code>ParticleTraits<PType>::momentum(const PType&)</code>
* implemented correctly.
*/
template <typename PType>
static void setMomentum(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 momentum q. If p is massless
* - simply set its momentum to q. The class
* <code>PType</code> must have
* <code>ParticleTraits<PType>::momentum(const PType&)</code>
* implemented correctly.
*/
template <typename PType>
static void setMomentumFromCMS(PType & p, const Momentum3 & q);
/**
* Rotate the range of particles so their sum is along z-axis and
* boost them to their CMS, then boost them along the z-axis and
* rotate them so that they end up with total momentum q. The class
* <code>Iter::value_type</code> must be of a type <code>T</code>
* for which <code>ParticleTraits<T>::momentum(const T&)</code> and
* <code>ParticleTraits<T>::transform(T&, const
* LorentzRotation&)</code> are implemented correctly.
*/
template <typename Iter>
static void setMomentum(Iter first, Iter last, const Momentum3 & q);
/**
* Rotate the range of particles so their sum is along z-axis then
* boost them along the z-axis and rotate them so that they end up
* with total momentum q. If a single boost does not succeed to
* obtain the required precision within eps times the total energy,
* the boost is redone. The class <code>Iter::value_type</code> must
* be of a type <code>T</code> for which
* <code>ParticleTraits<T>::momentum(const T&)</code> and
* <code>ParticleTraits<T>::transform(T&, const
* LorentzRotation&)</code> are implemented correctly.
*/
template <typename Iter>
static void setMomentum(Iter first, Iter last,
const Momentum3 & q, double eps);
/**
* Boost the range of particles along the z-axis and rotate them so
* that, if they were previously in their rest frame, they end up
* with total momentum q. The class <code>Iter::value_type</code> must
* be of a type <code>T</code> for which
* <code>ParticleTraits<T>::momentum(const T&)</code> and
* <code>ParticleTraits<T>::transform(T&, const
* LorentzRotation&)</code> are implemented correctly.
* @param first iterator pointing to the first particle in the range.
* @param last iterator indicating the end of the range.
* @param m2 the invariant mass squared of the particles.
* @param q final summed momentum of the particles.
*/
template <typename Iter>
static void setMomentumFromCMS(Iter first, Iter last,
Energy2 m2, const Momentum3 & q);
/**
* Return the transformation needed to rotate \a p to the z-axis and
* boost it to its CMS, then boost it along the z-axis and rotate it
* so that it ends up with momentum \a q. The class
* <code>PType</code> must have
* <code>ParticleTraits<PType>::momentum(const PType&)</code>
* implemented correctly. <b>Warning</b> This function only works
* properly if \a p has a well defined direction in both polar and
* azimuth angles.
* \deprecated{Use getTransformToMomentum() instead.}
*/
template <typename PType>
static LorentzRotation transformToMomentum(const PType & p,
const Momentum3 & q) {
typedef ParticleTraits<PType> Traits;
LorentzMomentum q4(q, sqrt(q.mag2() + Traits::momentum(p).m2()));
return transformToMomentum(p, q4);
}
/**
* Return the transformation needed to rotate \a p to the z-axis and
* boost it to its CMS, then boost it along the z-axis and rotate it
* so that it ends up with momentum \a q. The class <code>PType</code>
* must have <code>ParticleTraits<PType>::momentum(const
* PType&)</code> implemented correctly. <b>Warning</b> This
* function only works properly if \a p has a well defined direction
* in both polar and azimuth angles.
* \deprecated{Use getTransformToMomentum() instead.}
*/
template <typename PType>
static LorentzRotation transformToMomentum(const PType & p,
const LorentzMomentum & q) {
return transformFromCMS(q)*transformToCMS(p);
}
/**
* Return a transformation appropriate for transforming \a p to have
* the momentum \a q. The transformation is done so that the
* auxiliary vector \a k is left unchanged.
*/
template <typename PType>
static LorentzRotation getTransformToMomentum(const PType & p,
const LorentzMomentum & q,
const LorentzMomentum & k) {
typedef ParticleTraits<PType> Traits;
LorentzMomentum k0 = Traits::momentum(p) - k;
LorentzMomentum k1 = Traits::momentum(q) - k;
return getBoostFromCM(make_pair(k1, k))*getBoostToCM(make_pair(k0, k));
}
/**
* Return a transformation appropriate for transforming \a p to have
* the momentum \a q. The transformation is done so that the
* auxiliary vector \a k is left unchanged.
*/
template <typename PType>
static LorentzRotation getTransformToMomentum(const PType & p,
const Momentum3 & q,
const LorentzMomentum & k) {
typedef ParticleTraits<PType> Traits;
LorentzMomentum q4(q, sqrt(q.mag2() + Traits::momentum(p).m2()));
return getTransformToMomentum(p, q4, k);
}
/**
* Create a rotation corresponding to transforming p to its current
* value from its CMS by first boosting along the z-axis and then
* rotating. The class <code>LV</code> must have methods
* <code>rho()</code> and <code>e()</code>.
*/
template <typename LV>
static LorentzRotation transformFromCMS(const LV & p);
/**
* Create a rotation corresponding to transforming sum to its
* current value from its CMS, with zAxis along the z-axis in that
* CMS frame. The class <code>LV</code> must have methods
* <code>rho()</code>, <code>phi()</code> <code>theta()</code> and
* <code>e()</code>.
*/
template <typename LV>
static LorentzRotation transformFromCMS(const LV & sum, LV zAxis);
/**
* Create a rotation corresponding to transforming sum to its
* current value from its CMS, with zAxis along the z-axis and
* xyPlane in the x-y plane in that CMS frame. The class
* <code>LV</code> must have methods <code>rho()</code>,
* <code>phi()</code> <code>theta()</code> and <code>e()</code>.
*/
template <typename LV>
static LorentzRotation transformFromCMS(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 in that frame. The class <code>LV</code>
* must have methods <code>rho()</code>, <code>phi()</code>
* <code>theta()</code> and <code>e()</code>.
*/
template <typename LV>
static LorentzRotation transformToCMS(const LV & sum, LV zAxis);
/**
* Create a rotation which would transform sum to its CMS frame
* first rotating it to the z-axis and then boost it along the
* z-axis. The class <code>LV</code> must have methods
* <code>rho()</code>, <code>phi()</code> <code>theta()</code> and
* <code>e()</code>.
*/
template <typename LV>
static LorentzRotation transformToCMS(const LV & p);
/**
* Create a rotation which would transform sum to its CMS frame with
* zAxis along the z-axis and xyPlane in the x-y plane in that
* frame. The class <code>LV</code> must have methods
* <code>rho()</code>, <code>phi()</code> <code>theta()</code> and
* <code>e()</code>.
*/
template <typename LV>
static LorentzRotation transformToCMS(const LV & sum,
const LV & zAxis, LV xyPlane);
/**
* Add the elements in Cont2 to Cont1, appending them to the end if
* possible.
*/
template <typename Cont1, typename Cont2>
static void add(Cont1 & c1, const Cont2 & c2);
};
/** Concrete class with UtilityBase as base class. */
struct Utilities: public UtilityBase {};
}
#ifndef ThePEG_TEMPLATES_IN_CC_FILE
#include "UtilityBase.tcc"
#endif
#endif /* ThePEG_UtilityBase_H */
|