/usr/include/ThePEG/ACDC/ACDCGenCell.icc 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 | // -*- C++ -*-
//
// ACDCGenCell.icc 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 ACDCGenerator {
inline ACDCGenCell::ACDCGenCell(double newG)
: theG(newG), theV(1.0), theUpper(0), theLower(0),
theDivision(-1.0), theSplitDimension(-1) {}
inline ACDCGenCell::
ACDCGenCell(double newG, double newV)
: theG(newG), theV(newV), theUpper(0), theLower(0),
theDivision(-1.0), theSplitDimension(-1) {}
inline ACDCGenCell::~ACDCGenCell() {
if ( isSplit() ) {
delete theUpper;
delete theLower;
}
}
template <typename RndType>
inline ACDCGenCell * ACDCGenCell::
generate(DVector & lo, DVector & up, RndType * rnd) {
if ( isSplit() ) {
if ( ACDCRandomTraits<RndType>::
rndBool(rnd, upper()->maxInt(), lower()->maxInt()) ) {
lo[dim()] = div();
return upper()->generate(lo, up, rnd);
} else {
up[dim()] = div();
return lower()->generate(lo, up, rnd);
}
}
return this;
}
inline ACDCGenCell * ACDCGenCell::
generate(DVector & lo, DVector & up, DVector & rndv) {
if ( isSplit() ) {
double r = lower()->maxInt()/maxInt();
if ( rndv[dim()] > r ) {
lo[dim()] = div();
rndv[dim()] = (rndv[dim()] - r)/(1.0 - r);
return upper()->generate(lo, up, rndv);
} else {
up[dim()] = div();
rndv[dim()] = rndv[dim()]/r;
return lower()->generate(lo, up, rndv);
}
}
return this;
}
inline ACDCGenCell * ACDCGenCell::
getCell(DVector & lo, const DVector & x, DVector & up) {
if ( isSplit() ) {
if ( x[dim()] > div() ) {
lo[dim()] = div();
return upper()->getCell(lo, x, up);
} else {
up[dim()] = div();
return lower()->getCell(lo, x, up);
}
} else
return this;
}
inline void ACDCGenCell::
splitme(double lo, double newDiv, double up, DimType newDim) {
theSplitDimension = newDim;
theDivision = newDiv;
double frac = (up - div())/(up - lo);
theUpper = new ACDCGenCell(g(), v()*frac);
frac = (div() - lo)/(up - lo);
theLower = new ACDCGenCell(g(), v()*frac);
}
inline bool ACDCGenCell::isSplit() const {
return upper();
}
inline double ACDCGenCell::doMaxInt(double scale) {
if ( isSplit() ) theG = (upper()->doMaxInt() + lower()->doMaxInt())/v();
else theG *= scale;
return maxInt();
}
inline void ACDCGenCell::smooth(double frac) {
if ( !isSplit() ) return;
upper()->smooth(frac);
lower()->smooth(frac);
if ( upper()->maxInt() < lower()->maxInt()*frac &&
upper()->maxInt() > 0.0 )
upper()->doMaxInt(lower()->maxInt()*frac/upper()->maxInt());
else if ( lower()->maxInt() < upper()->maxInt()*frac &&
lower()->maxInt() > 0.0 )
lower()->doMaxInt(upper()->maxInt()*frac/lower()->maxInt());
doMaxInt();
}
inline double ACDCGenCell::maxInt() const {
return g()*v();
}
inline void ACDCGenCell::g(double newG) {
theG = newG;
}
inline int ACDCGenCell::nBins() const {
return isSplit()? upper()->nBins() + lower()->nBins(): 1;
}
inline int ACDCGenCell::depth() const {
return isSplit()? std::max(upper()->depth(), lower()->depth()) + 1: 1;
}
inline double ACDCGenCell::g() const {
return theG;
}
inline double ACDCGenCell::v() const {
return theV;
}
inline double ACDCGenCell::div() const {
return theDivision;
}
inline DimType ACDCGenCell::dim() const {
return theSplitDimension;
}
inline ACDCGenCell * ACDCGenCell::upper() const {
return theUpper;
}
inline ACDCGenCell * ACDCGenCell::lower() const {
return theLower;
}
inline void ACDCGenCell::
extract(DVector & lo, DVector & up, vector<ACDCGenCellInfo> & out) const {
// First add this cell which gets index isave.
ACDCGenCellInfo::Index isave = out.size();
out.push_back(ACDCGenCellInfo());
out.back().g = g();
out.back().v = v();
out.back().up = up;
out.back().lo = lo;
out.back().iup = 0;
out.back().ilo = 0;
if ( isSplit() ) {
// If split add the upper cell.
out[isave].iup = out.size();
double save = lo[dim()];
lo[dim()] = div();
upper()->extract(lo, up, out);
lo[dim()] = save;
// Then add the lower cell.
out[isave].ilo = out.size();
save = up[dim()];
up[dim()] = div();
lower()->extract(lo, up, out);
up[dim()] = save;
}
}
template <typename OStream>
inline OStream & operator<<(OStream & os, const ACDCGenCell & c) {
os << c.dim() << c.div() << c.g() << c.v();
if ( c.dim() < 0 ) return os;
return os << *c.upper() << *c.lower();
}
template <typename IStream>
inline IStream & operator>>(IStream & is, ACDCGenCell & c) {
is >> c.theSplitDimension >> c.theDivision >> c.theG >> c.theV;
if ( c.dim() < 0 ) return is;
c.theUpper = new ACDCGenCell(0.0);
c.theLower = new ACDCGenCell(0.0);
return is >> *c.theUpper >> *c.theLower;
}
inline long ACDCGenCell::getIndex(const ACDCGenCell * c) const {
long indx = -1;
return getIndex(c, indx);
}
inline long ACDCGenCell::getIndex(const ACDCGenCell * c, long & indx) const {
++indx;
if ( c == this ) return indx;
if ( isSplit() ) {
long i = upper()->getIndex(c, indx);
if ( i >= 0 ) return i;
return lower()->getIndex(c, indx);
}
return -1;
}
inline ACDCGenCell * ACDCGenCell::getCell(long i) {
long indx = -1;
return getCell(i, indx);
}
inline ACDCGenCell * ACDCGenCell::getCell(long i, long & indx) {
++indx;
if ( i == indx ) return this;
if ( isSplit() ) {
ACDCGenCell * tmp = upper()->getCell(i, indx);
if ( tmp ) return tmp;
return lower()->getCell(i, indx);
}
return 0;
}
}
|