/usr/include/ThePEG/Utilities/UtilityBase.tcc is in libthepeg-dev 1.8.0-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 | // -*- C++ -*-
//
// UtilityBase.tcc 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.
//
namespace ThePEG {
template <typename PType>
LorentzRotation UtilityBase::boostToCM(const pair<PType,PType> & pp) {
typedef ParticleTraits<PType> Traits;
LorentzRotation boost(-(Traits::momentum(pp.first) +
Traits::momentum(pp.second)).boostVector());
Traits::transform(pp.first, boost);
Traits::transform(pp.second, boost);
LorentzRotation rot;
rot.rotateZ(-Traits::momentum(pp.first).phi());
rot.rotateY(-Traits::momentum(pp.first).theta());
rot.rotateZ(Traits::momentum(pp.first).phi());
Traits::transform(pp.first, rot);
Traits::transform(pp.second, rot);
return rot*boost;
}
template <typename PType>
LorentzRotation UtilityBase::boostToCM(const Triplet<PType,PType,PType> & pt) {
typedef ParticleTraits<PType> Traits;
LorentzRotation rot = getBoostToCM(pt);
Traits::transform(pt.first, rot);
Traits::transform(pt.second, rot);
Traits::transform(pt.third, rot);
return rot;
}
template <typename PType>
LorentzRotation UtilityBase::getBoostToCM(const pair<PType,PType> & pp) {
typedef ParticleTraits<PType> Traits;
LorentzMomentum p1 = Traits::momentum(pp.first);
Boost b = (p1 + Traits::momentum(pp.second)).boostVector();
p1.boost(-b);
LorentzRotation rot(-b);
rot.rotateZ(-p1.phi());
rot.rotateY(-p1.theta());
rot.rotateZ(p1.phi());
return rot;
}
template <typename PType>
LorentzRotation UtilityBase::
getBoostToCM(const Triplet<PType,PType,PType> & pt) {
typedef ParticleTraits<PType> Traits;
LorentzMomentum p1 = Traits::momentum(pt.first);
LorentzMomentum p2 = Traits::momentum(pt.second);
Boost b = (p1 + p2 + Traits::momentum(pt.third)).boostVector();
p1.boost(-b);
LorentzRotation rot(-b);
rot.rotateZ(-p1.phi());
rot.rotateY(-p1.theta());
p2.transform(rot);
rot.rotateZ(-p2.phi());
return rot;
}
template <typename PType>
LorentzRotation UtilityBase::
getBoostFromCM(const Triplet<PType,PType,PType> & pt) {
return getBoostToCM(pt).inverse();
}
template <typename PType>
LorentzRotation UtilityBase::getBoostFromCM(const pair<PType,PType> & pp) {
typedef ParticleTraits<PType> Traits;
LorentzMomentum p1 = Traits::momentum(pp.first);
Boost b = (p1 + Traits::momentum(pp.second)).boostVector();
p1.boost(-b);
LorentzRotation rot;
rot.rotateZ(-p1.phi());
rot.rotateY(p1.theta());
rot.rotateZ(p1.phi());
rot.boost(b);
return rot;
}
template <typename Iterator>
LorentzRotation UtilityBase::boostToCM(Iterator first, Iterator last,
Iterator zAxis, Iterator xzPlane) {
if ( first == last ) return LorentzRotation();
LorentzRotation boost(-sumMomentum(first, last).boostVector());
typedef typename std::iterator_traits<Iterator>::value_type PType;
typedef ParticleTraits<PType> Traits;
transform(first, last, boost);
if ( zAxis != last ) {
LorentzRotation rot;
rot.rotateZ(-Traits::momentum(*zAxis).phi());
rot.rotateY(-Traits::momentum(*zAxis).theta());
if ( xzPlane == last ) rot.rotateZ(Traits::momentum(*zAxis).phi());
transform(first, last, rot);
boost = rot*boost;
}
if ( xzPlane != last ) {
LorentzRotation rot;
rot.rotateZ(-Traits::momentum(*xzPlane).phi());
transform(first, last, rot);
boost = rot*boost;
}
return boost;
}
template <typename LV>
LorentzRotation UtilityBase::
transformFromCMS(const LV & p) {
if(p.rho()/p.e()>=1.)
throw Exception() << "Boost >=1. in "
<< "UtilityBase::transformFromCMS()"
<< Exception::eventerror;
LorentzRotation r(0.0, 0.0, p.rho()/p.e());
r.rotateZ(-p.phi());
r.rotateY(p.theta());
r.rotateZ(p.phi());
return r;
}
template <typename LV>
LorentzRotation UtilityBase::
transformFromCMS(const LV & sum, LV zAxis) {
LorentzRotation r;
Boost bz(sum.boostVector());
zAxis.boost(-bz);
r.rotateZ(-zAxis.phi());
r.rotateY(zAxis.theta());
r.rotateZ(zAxis.phi());
r.boost(bz);
return r;
}
template <typename LV>
LorentzRotation UtilityBase::
transformFromCMS(const LV & sum, const LV & zAxis, LV xyPlane) {
LorentzRotation r;
LorentzRotation r1 = transformFromCMS(sum, zAxis);
xyPlane.transform(r1.inverse());
r.rotateZ(xyPlane.phi());
r.transform(r1);
return r;
}
template <typename LV>
LorentzRotation UtilityBase::
transformToCMS(const LV & p) {
LorentzRotation r;
r.rotateZ(-p.phi());
r.rotateY(-p.theta());
r.rotateZ(p.phi());
if(p.rho()/p.e()>1.) throw Exception() << "Boost >=1. in "
<< "UtilityBase::transformToCMS "
<< Exception::eventerror;
r.boostZ(-p.rho()/p.e());
return r;
}
template <typename LV>
LorentzRotation UtilityBase::
transformToCMS(const LV & sum, LV zAxis) {
LorentzRotation r(-sum.boostVector());
zAxis.transform(r);
r.rotateZ(-zAxis.phi());
r.rotateY(-zAxis.theta());
r.rotateZ(zAxis.phi());
return r;
}
template <typename LV>
LorentzRotation UtilityBase::
transformToCMS(const LV & sum, const LV & zAxis, LV xyPlane) {
LorentzRotation r(transformToCMS(sum, zAxis));
xyPlane.transform(r);
r.rotateZ(-xyPlane.phi());
return r;
}
template <typename PType>
void UtilityBase::setMomentum(PType & p, const Momentum3 & q) {
typedef ParticleTraits<PType> Traits;
if ( Traits::momentum(p).m2() <= ZERO ||
Traits::mass(p) <= ZERO ) {
Traits::set3Momentum(p, q);
} else {
Traits::transform(p, transformToCMS(Traits::momentum(p)));
setMomentumFromCMS(p, q);
}
}
template <typename PType>
void UtilityBase::setMomentumFromCMS(PType & p, const Momentum3 & q) {
typedef ParticleTraits<PType> Traits;
LorentzMomentum q4(q, sqrt(q.mag2() + sqr(Traits::mass(p))));
if ( Traits::momentum(p) == LorentzMomentum() )
Traits::set5Momentum(p, q4);
else
Traits::transform(p, transformFromCMS(q4));
return;
}
template <typename Iter>
void UtilityBase::setMomentum(Iter first, Iter last, const Momentum3 & q) {
if ( first == last ) return;
typedef typename std::iterator_traits<Iter>::value_type PType;
typedef ParticleTraits<PType> Traits;
Iter second = first;
if ( ++second == last ) return setMomentum(Traits::ref(*first), q);
LorentzMomentum sum = sumMomentum(first, last);
transform(first, last, transformToCMS(sum));
setMomentumFromCMS(first, last, sum.m2(), q);
}
template <typename Iter>
void UtilityBase::
setMomentum(Iter first, Iter last, const Momentum3 & q, double eps) {
if ( first == last ) return;
typedef typename std::iterator_traits<Iter>::value_type PType;
typedef ParticleTraits<PType> Traits;
Iter second = first;
if ( ++second == last ) return setMomentum(Traits::ref(*first), q);
LorentzRotation r;
LorentzMomentum sum = sumMomentum(first, last);
if ( sum.rho2() > 1.0e-12*MeV2 ) {
r.rotateZ(-sum.phi());
r.rotateY(-sum.theta());
r.rotateZ(sum.phi());
}
if((sum.vect()-q).mag2()< 1.0e-12*MeV2) return;
Energy2 ppo = sqr(sum.rho() + sum.e());
Energy2 ppn = sqr(q.mag() + sqrt(q.mag2() + sum.m2()));
r.boost(0.0, 0.0, (ppn - ppo)/(ppn + ppo));
r.rotateZ(-q.phi());
r.rotateY(q.theta());
r.rotateZ(q.phi());
transform(first, last, r);
sum = sumMomentum(first, last);
if ( abs(sum.x() - q.x()) > eps*sum.e() ||
abs(sum.y() - q.y()) > eps*sum.e() ||
abs(sum.z() - q.z()) > eps*sum.e() ) setMomentum(first, last, q, eps);
}
template <typename Iter>
void UtilityBase::
setMomentumFromCMS(Iter first, Iter last, Energy2 m2, const Momentum3 & q) {
if ( first == last ) return;
typedef typename std::iterator_traits<Iter>::value_type PType;
typedef ParticleTraits<PType> Traits;
Iter second = first;
if ( ++second == last ) return setMomentumFromCMS(Traits::ref(*first), q);
transform(first, last,
transformFromCMS(LorentzMomentum(q, sqrt(q.mag2() + m2))));
}
template <typename Cont1, typename Cont2>
void UtilityBase::add(Cont1 & c1, const Cont2 & c2) {
typename Cont2::const_iterator i = c2.begin();
while ( i != c2.end() ) c1.insert(c1.end(), *i++);
}
}
|