Page MenuHomeHEPForge

No OneTemporary

diff --git a/.hgignore b/.hgignore
--- a/.hgignore
+++ b/.hgignore
@@ -1,68 +1,72 @@
Makefile$
Makefile\.in$
\.deps$
\.libs$
\.l[ao]$
\.so$
\.so\.
\.o$
~$
\.orig$
^include/.done-all-links$
^lib/.done-all-links$
^src/.*\.(run|tex|out|log|rpo|spc|top|dump|dot|aux|pdf|ps|png|svg|hepmc)$
^src/.done-all-links$
^autom4te.cache$
^config.thepeg$
^config.log$
^config.status$
^configure$
^Config/config.h$
^Config/config.h.in$
^Config/config.sub$
^Config/depcomp$
^Config/install-sh$
^Config/compile$
^Config/missing$
^Config/stamp-h.$
^Config/ar-lib$
^Config/ThePEG_Qty.h$
^Config/config.guess$
^Config/test-driver$
^Doc/fixinterfaces.pl$
^include/ThePEG$
^Doc/MakeDocs.in$
^Doc/refman.conf$
^Doc/refman.h$
+^Doc/refman-html$
+^Doc/AllInterfaces.h$
+^Doc/MoreInterfaces.h$
+^Doc/ThePEG-refman.tag$
^java/.*\.(java|class)$
^java/ThePEG$
^java/ThePEG.jar$
^java/thepeg.sh$
^java/thepeg$
^PDF/.done-all-links$
^lib/ThePEGDefaults.rpo$
^lib/Makefile.common
^lib/Makefile.dist$
^src/runThePEG$
^src/setupThePEG$
^aclocal.m4$
^libtool$
^INSTALL$
^src/TestDecayMode.in$
^ThePEG.*\.tar\.(bz2|gz)$
^src/runThePEG.bin$
^src/setupThePEG.bin$
^ThePEG-default.kdev4$
^src/SimpleLEP.cmp$
^Repository/versionstamp.inc$
^Repository/repository_test(.log|.trs)?$
^Repository/test-suite.log$
^Repository/tests/.dirstamp$
# added by aHg on Wed Jan 13 13:27:00 2016
syntax: glob
Config/LWH.h
PDF/done-all-links
include/done-all-links
lib/done-all-links
src/done-all-links
diff --git a/Cuts/FuzzyTheta.h b/Cuts/FuzzyTheta.h
--- a/Cuts/FuzzyTheta.h
+++ b/Cuts/FuzzyTheta.h
@@ -1,341 +1,342 @@
// -*- C++ -*-
//
// FuzzyTheta.h is a part of ThePEG - Toolkit for HEP Event Generation
// Copyright (C) 1999-2011 Leif Lonnblad
// Copyright (C) 2009-2012 Simon Platzer
//
// 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_FuzzyTheta_H
#define ThePEG_FuzzyTheta_H
//
// This is the declaration of the FuzzyTheta class.
//
#include "ThePEG/Interface/Interfaced.h"
#include "ThePEG/Repository/EventGenerator.h"
#include <cassert>
namespace ThePEG {
namespace CutTypes {
/**
* Identify an energy-type cut
*/
struct Energy {};
/**
* Identify a momentum-type cut
*/
struct Momentum {};
/**
* Identify a rapidity-type cut
*/
struct Rapidity {};
/**
* Identify an azimuth-type cut
*/
struct Azimuth {};
/**
* Identify an polar-angle-type cut
*/
struct Polar {};
}
/**
* FuzzyTheta implements fuzzy cut prescriptions
*
* @see \ref FuzzyThetaInterfaces "The interfaces"
* defined for FuzzyTheta.
*/
class FuzzyTheta: public Interfaced {
public:
/** @name Standard constructors and destructors. */
//@{
/**
* The default constructor.
*/
FuzzyTheta();
/**
* The destructor.
*/
virtual ~FuzzyTheta();
//@}
public:
/**
* Return the (compact) support of the delta approximation
* considered, given its center value. This default version assumes
* a box approximation. All values are assumed to be in units of the
* width considered.
*/
virtual pair<double,double> support(double x) const {
return make_pair(x-0.5,x+0.5);
}
/**
* Return the overlap integral of the delta approximation with the
* given box and center. This default version assumes
* a box approximation. All values are assumed to be in units of the
* width considered.
*/
virtual double overlap(double x, const pair<double,double>& box) const {
if ( x - 0.5 >= box.first && x + 0.5 <= box.second )
return 1.;
if ( x - 0.5 > box.second || x + 0.5 < box.first )
return 0.;
return min(box.second,x+0.5) - max(box.first,x-0.5);
}
/**
* Return the overlap, optionally considering absolute lower and
* upper bounds.
*/
double overlap(double x,
pair<double,double> box,
const pair<double,double>& support) const {
box.first = max(box.first,support.first);
box.second = min(box.second,support.second);
assert(x >= support.first && x <= support.second);
assert(support.second - support.first >= 1.);
if ( x - 0.5 < support.first )
x = support.first + 0.5;
if ( x + 0.5 > support.second )
x = support.second - 0.5;
return overlap(x,box);
}
/**
* Return the bounds for an energy-type cut
*/
pair<double,double> bounds(const CutTypes::Energy&) const {
return make_pair(0.,generator()->maximumCMEnergy()/theEnergyWidth);
}
/**
* Return the width for an energy-type cut
*/
Energy width(const CutTypes::Energy&) const {
return theEnergyWidth;
}
/**
* Return the bounds for a momentum-type cut
*/
pair<double,double> bounds(const CutTypes::Momentum&) const {
return make_pair(0.,0.5*generator()->maximumCMEnergy()/theEnergyWidth);
}
/**
* Return the width for a momentum-type cut
*/
Energy width(const CutTypes::Momentum&) const {
return theEnergyWidth;
}
/**
* Return the bounds for a rapidity-type cut
*/
pair<double,double> bounds(const CutTypes::Rapidity&) const {
- return make_pair(-Constants::MaxRapidity,Constants::MaxRapidity);
+ return make_pair(-Constants::MaxRapidity/theRapidityWidth,
+ Constants::MaxRapidity/theRapidityWidth);
}
/**
* Return the width for a rapidity-type cut
*/
double width(const CutTypes::Rapidity&) const {
return theRapidityWidth;
}
/**
* Return the bounds for a azimuth-type cut
*/
pair<double,double> bounds(const CutTypes::Azimuth&) const {
return make_pair(0.0,2.*Constants::pi/theAngularWidth);
}
/**
* Return the width for a azimuth-type cut
*/
double width(const CutTypes::Azimuth&) const {
return theAngularWidth;
}
/**
* Return the bounds for a polar-angle-type cut
*/
pair<double,double> bounds(const CutTypes::Polar&) const {
return make_pair(0.0,Constants::pi/theAngularWidth);
}
/**
* Return the width for a polar-type cut
*/
double width(const CutTypes::Polar&) const {
return theAngularWidth;
}
/**
* Check for value inside the given bounds and update the weight
*/
template<class CutType, class Value>
bool isInside(const Value& v, const Value& lower, const Value& upper, double& weight) const {
CutType type;
Value w = width(type);
weight *=
overlap(v/w,pair<double,double>(lower/w,upper/w),bounds(type));
if ( weight == 0.0 )
return false;
return true;
}
/**
* Check for value inside the given bounds and update the weight
*/
template<class CutType, class Value>
bool isLessThan(const Value& v, const Value& upper, double& weight) const {
CutType type;
Value w = width(type);
pair<double,double> b = bounds(type);
weight *=
overlap(v/w,pair<double,double>(b.first,upper/w),b);
if ( weight == 0.0 )
return false;
return true;
}
/**
* Check for value inside the given bounds and update the weight
*/
template<class CutType, class Value>
bool isLargerThan(const Value& v, const Value& lower, double& weight) const {
CutType type;
Value w = width(type);
pair<double,double> b = bounds(type);
weight *=
overlap(v/w,pair<double,double>(lower/w,b.first),b);
if ( weight == 0.0 )
return false;
return true;
}
public:
/** @name Functions used by the persistent I/O system. */
//@{
/**
* Function used to write out object persistently.
* @param os the persistent output stream written to.
*/
void persistentOutput(PersistentOStream & os) const;
/**
* Function used to read in object persistently.
* @param is the persistent input stream read from.
* @param version the version number of the object when written.
*/
void persistentInput(PersistentIStream & is, int version);
//@}
/**
* The standard Init function used to initialize the interfaces.
* Called exactly once for each class by the class description system
* before the main function starts or
* when this class is dynamically loaded.
*/
static void Init();
protected:
/** @name Clone Methods. */
//@{
/**
* Make a simple clone of this object.
* @return a pointer to the new object.
*/
virtual IBPtr clone() const;
/** Make a clone of this object, possibly modifying the cloned object
* to make it sane.
* @return a pointer to the new object.
*/
virtual IBPtr fullclone() const;
//@}
// If needed, insert declarations of virtual function defined in the
// InterfacedBase class here (using ThePEG-interfaced-decl in Emacs).
private:
/**
* The width to be considered for momenta
*/
Energy theEnergyWidth;
/**
* The width to be considered for rapidity quantities
*/
double theRapidityWidth;
/**
* The width to be considered for angular quantities
*/
double theAngularWidth;
private:
/**
* The static object used to initialize the description of this class.
* Indicates that this is a concrete class with persistent data.
*/
static ClassDescription<FuzzyTheta> initFuzzyTheta;
/**
* The assignment operator is private and must never be called.
* In fact, it should not even be implemented.
*/
FuzzyTheta & operator=(const FuzzyTheta &);
};
}
#include "ThePEG/Utilities/ClassTraits.h"
namespace ThePEG {
/** @cond TRAITSPECIALIZATIONS */
/** This template specialization informs ThePEG about the
* base classes of FuzzyTheta. */
template <>
struct BaseClassTrait<FuzzyTheta,1> {
/** Typedef of the first base class of FuzzyTheta. */
typedef Interfaced NthBase;
};
/** This template specialization informs ThePEG about the name of
* the FuzzyTheta class and the shared object where it is defined. */
template <>
struct ClassTraits<FuzzyTheta>
: public ClassTraitsBase<FuzzyTheta> {
/** Return a platform-independent class name */
static string className() { return "ThePEG::FuzzyTheta"; }
};
/** @endcond */
}
#endif /* ThePEG_FuzzyTheta_H */
diff --git a/Handlers/StandardXComb.cc b/Handlers/StandardXComb.cc
--- a/Handlers/StandardXComb.cc
+++ b/Handlers/StandardXComb.cc
@@ -1,810 +1,818 @@
// -*- C++ -*-
//
// StandardXComb.cc is a part of ThePEG - Toolkit for HEP Event Generation
// Copyright (C) 1999-2011 Leif Lonnblad
// Copyright (C) 2009-2011 Simon Platzer
//
// ThePEG is licenced under version 2 of the GPL, see COPYING for details.
// Please respect the MCnet academic guidelines, see GUIDELINES for details.
//
//
// This is the implementation of the non-inlined, non-templated member
// functions of the StandardXComb class.
//
#include "StandardXComb.h"
#include "StdXCombGroup.h"
#include "ThePEG/Handlers/StandardEventHandler.h"
#include "ThePEG/Handlers/SubProcessHandler.h"
#include "ThePEG/Cuts/Cuts.h"
#include "ThePEG/PDF/PartonExtractor.h"
#include "ThePEG/Utilities/Debug.h"
#include "ThePEG/Utilities/Maths.h"
#include "ThePEG/PDT/ParticleData.h"
#include "ThePEG/Persistency/PersistentOStream.h"
#include "ThePEG/Persistency/PersistentIStream.h"
#include "ThePEG/Utilities/SimplePhaseSpace.h"
#include "ThePEG/Utilities/UtilityBase.h"
#include "ThePEG/EventRecord/Particle.h"
#include "ThePEG/EventRecord/SubProcessGroup.h"
#include "ThePEG/Vectors/LorentzRotation.h"
#include "ThePEG/MatrixElement/MEBase.h"
#include "ThePEG/MatrixElement/ColourLines.h"
#include "ThePEG/Handlers/LuminosityFunction.h"
#include "ThePEG/Handlers/CascadeHandler.h"
#include "ThePEG/Repository/EventGenerator.h"
#include "ThePEG/EventRecord/TmpTransform.h"
#ifdef ThePEG_TEMPLATES_IN_CC_FILE
#include "StandardXComb.tcc"
#endif
using namespace ThePEG;
StandardXComb::StandardXComb()
: XComb(), isMirror(false), theNDim(0),
partonDims(make_pair(0, 0)), theKinematicsGenerated(false),
theLastDiagramIndex(0), theLastPDFWeight(0.0),
theLastCrossSection(ZERO), theLastJacobian(1.0), theLastME2(-1.0), theLastPreweight(1.0),
theLastMECrossSection(ZERO), theLastMEPDFWeight(1.0), theLastMECouplings(1.0),
checkedCuts(false), passedCuts(false), theCutWeight(1.0), theNeedsReshuffling(false) {}
StandardXComb::
StandardXComb(Energy newMaxEnergy, const cPDPair & inc,
tEHPtr newEventHandler, tSubHdlPtr newSubProcessHandler,
tPExtrPtr newExtractor, tCascHdlPtr newCKKW,
const PBPair & newPartonBins, tCutsPtr newCuts,
tMEPtr newME, const DiagramVector & newDiagrams, bool mir,
tStdXCombPtr newHead)
: XComb(newMaxEnergy, inc, newEventHandler,
newExtractor, newCKKW, newPartonBins, newCuts),
theSubProcessHandler(newSubProcessHandler), theME(newME),
theDiagrams(newDiagrams), isMirror(mir), theNDim(0), partonDims(0,0),
theKinematicsGenerated(false), theLastDiagramIndex(0), theLastPDFWeight(0.0),
theLastCrossSection(ZERO), theLastJacobian(0.0), theLastME2(-1.0),
theLastPreweight(1.0), theLastMECrossSection(ZERO),
theLastMEPDFWeight(1.0), theLastMECouplings(1.0), theHead(newHead),
checkedCuts(false), passedCuts(false), theCutWeight(1.0), theNeedsReshuffling(false) {
partonDims = pExtractor()->nDims(partonBins());
if ( matrixElement()->haveX1X2() ) {
partonDims.first = 0;
partonDims.second = 0;
}
theNDim = matrixElement()->nDim() + partonDims.first + partonDims.second;
mePartonData() = lastDiagram()->partons();
checkReshufflingNeeds();
}
StandardXComb::StandardXComb(tMEPtr me, const tPVector & parts,
DiagramIndex indx)
: theME(me), isMirror(false), theNDim(0), partonDims(make_pair(0, 0)),
theKinematicsGenerated(false),
theLastDiagramIndex(0), theLastPDFWeight(0.0), theLastCrossSection(ZERO),
theLastME2(-1.0), theLastPreweight(1.0), theLastMECrossSection(ZERO), theLastMEPDFWeight(1.0),
theLastMECouplings(1.0),
checkedCuts(false), passedCuts(false), theCutWeight(1.0), theNeedsReshuffling(false) {
subProcess(new_ptr(SubProcess(make_pair(parts[0], parts[1]),
tCollPtr(), me)));
for ( int i = 0, N = parts.size(); i < N; ++i ) {
subProcess()->addOutgoing(parts[i], false);
theMEPartonData.push_back(parts[i]->dataPtr());
theMEMomenta.push_back(parts[i]->momentum());
}
lastSHat((meMomenta()[0] + meMomenta()[1]).m2());
string tag = me->diagrams()[indx]->getTag();
for ( int i = 0, N = me->diagrams().size(); i < N; ++i )
if ( me->diagrams()[i]->getTag() == tag )
theDiagrams.push_back(me->diagrams()[i]);
checkReshufflingNeeds();
}
StandardXComb::StandardXComb(tStdXCombPtr newHead,
const PBPair & newPartonBins, tMEPtr newME,
const DiagramVector & newDiagrams)
: XComb(newHead->maxEnergy(), newHead->particles(),
newHead->eventHandlerPtr(), newHead->pExtractor(),
newHead->CKKWHandler(), newPartonBins, newHead->cuts()),
theSubProcessHandler(const_ptr_cast<tSubHdlPtr>(newHead->subProcessHandler())),
theME(newME), theDiagrams(newDiagrams), isMirror(newHead->mirror()), theNDim(0),
partonDims(0,0), theKinematicsGenerated(false), theLastDiagramIndex(0), theLastPDFWeight(0.0),
theLastCrossSection(ZERO), theLastJacobian(0.0), theLastME2(-1.0),
theLastPreweight(1.0), theLastMECrossSection(ZERO),
theLastMEPDFWeight(1.0), theLastMECouplings(1.0), theHead(newHead),
checkedCuts(false), passedCuts(false), theCutWeight(1.0), theNeedsReshuffling(false) {
partonDims = pExtractor()->nDims(partonBins());
if ( matrixElement()->haveX1X2() ) {
partonDims.first = 0;
partonDims.second = 0;
}
theNDim = matrixElement()->nDim() + partonDims.first + partonDims.second;
mePartonData() = lastDiagram()->partons();
checkReshufflingNeeds();
/* // wait for C++11
StandardXComb(newHead->maxEnergy(),newHead->particles(),
newHead->eventHandlerPtr(),
const_ptr_cast<tSubHdlPtr>(newHead->subProcessHandler()),
newHead->pExtractor(),newHead->CKKWHandler(),
newPartonBins,newHead->cuts(),newME,newDiagrams,newHead->mirror(),
newHead);
*/
}
StandardXComb::~StandardXComb() {}
void StandardXComb::recreatePartonBinInstances(Energy2 scale) {
PBIPair newBins;
Direction<0> dir(true);
newBins.first =
new_ptr(PartonBinInstance(lastPartons().first,partonBins().first,scale));
dir.reverse();
newBins.second =
new_ptr(PartonBinInstance(lastPartons().second,partonBins().second,scale));
resetPartonBinInstances(newBins);
setPartonBinInfo();
lastPartons().first->scale(partonBinInstances().first->scale());
lastPartons().second->scale(partonBinInstances().second->scale());
}
void StandardXComb::refillPartonBinInstances(const double* r) {
pExtractor()->select(this);
pExtractor()->updatePartonBinInstances(partonBinInstances());
pExtractor()->generateSHat(lastS(), partonBinInstances(),
r, r + nDim() - partonDims.second,true);
}
bool StandardXComb::setIncomingPartons(tStdXCombPtr labHead) {
if ( lastPartons().first )
return true;
if ( !labHead )
labHead = head();
createPartonBinInstances();
lastParticles(labHead->lastParticles());
setPartonBinInfo();
lastPartons(make_pair(mePartonData()[0]->produceParticle(Lorentz5Momentum()),
mePartonData()[1]->produceParticle(Lorentz5Momentum())));
Lorentz5Momentum pFirst = meMomenta()[0];
Lorentz5Momentum pSecond = meMomenta()[1];
if ( labHead->matrixElement()->wantCMS() ) {
Boost toLab = (labHead->lastPartons().first->momentum() +
labHead->lastPartons().second->momentum()).boostVector();
if ( toLab.mag2() > Constants::epsilon ) {
pFirst.boost(toLab);
pSecond.boost(toLab);
}
}
lastPartons().first->set5Momentum(pFirst);
lastPartons().second->set5Momentum(pSecond);
partonBinInstances().first->parton(lastPartons().first);
partonBinInstances().second->parton(lastPartons().second);
lastS((lastParticles().first->momentum() +
lastParticles().second->momentum()).m2());
lastSHat((lastPartons().first->momentum() +
lastPartons().second->momentum()).m2());
lastP1P2(make_pair(labHead->lastP1(),labHead->lastP2()));
double x1 =
lastPartons().first->momentum().plus()/
lastParticles().first->momentum().plus();
double x2 =
lastPartons().second->momentum().minus()/
lastParticles().second->momentum().minus();
if(x1<=0. || x2 <= 0. ) return false;
lastX1X2(make_pair(x1,x2));
lastY((lastPartons().first->momentum()+
lastPartons().second->momentum()).rapidity());
return true;
}
void StandardXComb::fill(const PPair& newParticles,
const PPair& newPartons,
const vector<Lorentz5Momentum>& newMEMomenta,
const DVector& newLastRandomNumbers) {
lastParticles(newParticles);
lastP1P2(make_pair(0.0, 0.0));
lastS((lastParticles().first->momentum() +
lastParticles().second->momentum()).m2());
lastPartons(newPartons);
lastSHat((lastPartons().first->momentum() +
lastPartons().second->momentum()).m2());
lastX1X2(make_pair(lastPartons().first->momentum().plus()/
lastParticles().first->momentum().plus(),
lastPartons().second->momentum().minus()/
lastParticles().second->momentum().minus()));
lastY((lastPartons().first->momentum() +
lastPartons().second->momentum()).rapidity());
meMomenta().resize(newMEMomenta.size());
copy(newMEMomenta.begin(),newMEMomenta.end(),
meMomenta().begin());
lastRandomNumbers().resize(newLastRandomNumbers.size());
copy(newLastRandomNumbers.begin(),newLastRandomNumbers.end(),
lastRandomNumbers().begin());
}
bool StandardXComb::checkInit() {
Energy summin = ZERO;
for ( int i = 2, N = mePartonData().size(); i < N; ++i ) {
summin += mePartonData()[i]->massMin();
}
return ( summin < min(maxEnergy(), cuts()->mHatMax()) );
}
bool StandardXComb::willPassCuts() {
if ( checkedCuts )
return passedCuts;
checkedCuts = true;
if ( !head() ) {
if ( !cuts()->initSubProcess(lastSHat(), lastY(), mirror()) ) {
passedCuts = false;
theCutWeight = 0.0;
return false;
}
} else {
cuts()->initSubProcess(lastSHat(), lastY(), mirror());
}
// check for exceptional configurations which may happen in NLO
// dijets subtraction with an extremely soft incoming parton giving
// rise to about lightlike CM momentum
if ( (meMomenta()[0]+meMomenta()[1]).m2() <= ZERO ) {
passedCuts = false;
return false;
}
tcPDVector outdata(mePartonData().begin()+2,mePartonData().end());
vector<LorentzMomentum> outmomenta(meMomenta().begin()+2,meMomenta().end());
Boost tocm = (meMomenta()[0]+meMomenta()[1]).findBoostToCM();
if ( tocm.mag2() > Constants::epsilon ) {
for ( vector<LorentzMomentum>::iterator p = outmomenta.begin();
p != outmomenta.end(); ++p ) {
p->boost(tocm);
}
}
+ for ( vector<LorentzMomentum>::iterator p = outmomenta.begin();
+ p != outmomenta.end(); ++p )
+ if ( !std::isfinite(double(p->x()/GeV)) || !std::isfinite(double(p->y()/GeV)) ||
+ !std::isfinite(double(p->z()/GeV)) || !std::isfinite(double(p->t()/GeV)) )
+ throw Exception()
+ << "Event momenta contain an invalid entry: " << (*p)/GeV
+ << Exception::eventerror;
+
if ( !cuts()->passCuts(outdata,outmomenta,mePartonData()[0],mePartonData()[1]) ) {
theCutWeight = cuts()->cutWeight();
passedCuts = false;
return false;
}
theCutWeight = cuts()->cutWeight();
passedCuts = true;
return true;
}
void StandardXComb::clean() {
XComb::clean();
theLastPDFWeight = 0.0;
theLastCrossSection = ZERO;
theLastJacobian = 0.0;
theLastME2 = 0.0;
theLastPreweight = 1.0;
theLastMECrossSection = ZERO;
theLastMEPDFWeight = 0.0;
theLastMECouplings = 0.0;
theProjectors.clear();
theProjector = StdXCombPtr();
theKinematicsGenerated = false;
checkedCuts = false;
passedCuts = false;
theCutWeight = 1.0;
theExternalDiagram = tcDiagPtr();
matrixElement()->flushCaches();
}
CrossSection StandardXComb::dSigDR(const double * r) {
matrixElement()->setXComb(this);
if ( !matrixElement()->apply() ) {
subProcess(SubProPtr());
lastCrossSection(ZERO);
return ZERO;
}
meMomenta().resize(mePartonData().size());
if ( !matrixElement()->generateKinematics(r) ) {
subProcess(SubProPtr());
lastCrossSection(ZERO);
return ZERO;
}
setIncomingPartons();
lastScale(matrixElement()->scale());
lastAlphaS(matrixElement()->alphaS());
lastAlphaEM(matrixElement()->alphaEM());
if ( (!willPassCuts() &&
!matrixElement()->headCuts() &&
!matrixElement()->ignoreCuts()) ||
!matrixElement()->apply() ) {
subProcess(SubProPtr());
lastCrossSection(ZERO);
return ZERO;
}
lastPDFWeight(head()->lastPDFWeight());
matrixElement()->setKinematics();
CrossSection xsec = matrixElement()->dSigHatDR() * lastPDFWeight();
xsec *= cutWeight();
subProcess(SubProPtr());
lastCrossSection(xsec);
return xsec;
}
CrossSection StandardXComb::
dSigDR(const pair<double,double> ll, int nr, const double * r) {
if ( matrixElement()->keepRandomNumbers() ) {
lastRandomNumbers().resize(nDim());
copy(r,r+nDim(),lastRandomNumbers().begin());
}
pExtractor()->select(this);
setPartonBinInfo();
lastP1P2(ll);
lastS(sqr(maxEnergy())/exp(lastP1() + lastP2()));
meMomenta().resize(mePartonData().size());
matrixElement()->setXComb(this);
PPair partons;
if ( !matrixElement()->haveX1X2() ) {
if ( !pExtractor()->generateL(partonBinInstances(),
r, r + nr - partonDims.second) ) {
lastCrossSection(ZERO);
return ZERO;
}
partons = make_pair(partonBinInstances().first->parton(),
partonBinInstances().second->parton());
lastSHat(lastS()/exp(partonBinInstances().first->l() +
partonBinInstances().second->l()));
meMomenta()[0] = partons.first->momentum();
meMomenta()[1] = partons.second->momentum();
} else {
if ( !matrixElement()->generateKinematics(r + partonDims.first) ) {
lastCrossSection(ZERO);
return ZERO;
}
lastSHat((meMomenta()[0]+meMomenta()[1]).m2());
matrixElement()->setKinematics();
lastScale(matrixElement()->scale());
partons.first = mePartonData()[0]->produceParticle(meMomenta()[0]);
partons.second = mePartonData()[1]->produceParticle(meMomenta()[1]);
Direction<0> dir(true);
partonBinInstances().first =
new_ptr(PartonBinInstance(lastParticles().first,partons.first,
partonBins().first,lastScale()));
dir.reverse();
partonBinInstances().second =
new_ptr(PartonBinInstance(lastParticles().second,partons.second,
partonBins().second,lastScale()));
}
lastPartons(partons);
if ( lastSHat() < cuts()->sHatMin() ) {
lastCrossSection(ZERO);
return ZERO;
}
lastY(0.5*(partonBinInstances().second->l() -
partonBinInstances().first->l()));
if ( !cuts()->initSubProcess(lastSHat(), lastY(), mirror()) ) {
lastCrossSection(ZERO);
return ZERO;
}
if ( mirror() ) swap(meMomenta()[0], meMomenta()[1]);
if ( matrixElement()->wantCMS() &&
!matrixElement()->haveX1X2() )
SimplePhaseSpace::CMS(meMomenta()[0], meMomenta()[1], lastSHat());
Energy summ = ZERO;
if ( meMomenta().size() == 3 ) {
if ( !matrixElement()->haveX1X2() )
meMomenta()[2] = Lorentz5Momentum(sqrt(lastSHat()));
} else {
for ( int i = 2, N = meMomenta().size(); i < N; ++i ) {
if ( !matrixElement()->haveX1X2() )
meMomenta()[i] = Lorentz5Momentum(mePartonData()[i]->mass());
summ += mePartonData()[i]->massMin();
}
if ( sqr(summ) >= lastSHat() ) {
lastCrossSection(ZERO);
return ZERO;
}
}
if ( !matrixElement()->haveX1X2() )
lastScale(max(lastSHat()/4.0, cuts()->scaleMin()));
lastSHat(pExtractor()->generateSHat(lastS(), partonBinInstances(),
r, r + nr - partonDims.second,
matrixElement()->haveX1X2()));
if ( !cuts()->sHat(lastSHat()) ) {
lastCrossSection(ZERO);
return ZERO;
}
r += partonDims.first;
lastX1X2(make_pair(lastPartons().first->momentum().plus()/
lastParticles().first->momentum().plus(),
lastPartons().second->momentum().minus()/
lastParticles().second->momentum().minus()));
if ( !cuts()->x1(lastX1()) || !cuts()->x2(lastX2()) ) {
lastCrossSection(ZERO);
return ZERO;
}
lastY((lastPartons().first->momentum() +
lastPartons().second->momentum()).rapidity());
if ( !cuts()->yHat(lastY()) ) {
lastCrossSection(ZERO);
return ZERO;
}
if ( !cuts()->initSubProcess(lastSHat(), lastY(), mirror()) ) {
lastCrossSection(ZERO);
return ZERO;
}
meMomenta()[0] = lastPartons().first->momentum();
meMomenta()[1] = lastPartons().second->momentum();
if ( mirror() ) swap(meMomenta()[0], meMomenta()[1]);
if ( matrixElement()->wantCMS() &&
!matrixElement()->haveX1X2() )
SimplePhaseSpace::CMS(meMomenta()[0], meMomenta()[1], lastSHat());
if ( meMomenta().size() == 3 ) {
if ( !matrixElement()->haveX1X2() )
meMomenta()[2] = Lorentz5Momentum(sqrt(lastSHat()));
} else {
if ( sqr(summ) >= lastSHat() ) {
lastCrossSection(ZERO);
return ZERO;
}
}
if ( !matrixElement()->haveX1X2() ) {
if ( !matrixElement()->generateKinematics(r) ) {
lastCrossSection(ZERO);
return ZERO;
}
}
lastScale(matrixElement()->scale());
if ( !cuts()->scale(lastScale()) ) {
lastCrossSection(ZERO);
return ZERO;
}
// get information on cuts; we don't take this into account here for
// reasons of backward compatibility but this will change eventually
willPassCuts();
pair<bool,bool> evalPDFS =
make_pair(matrixElement()->havePDFWeight1(),
matrixElement()->havePDFWeight2());
if ( mirror() )
swap(evalPDFS.first,evalPDFS.second);
lastPDFWeight(pExtractor()->fullFn(partonBinInstances(), lastScale(),
evalPDFS));
if ( lastPDFWeight() == 0.0 ) {
lastCrossSection(ZERO);
return ZERO;
}
matrixElement()->setKinematics();
CrossSection xsec = matrixElement()->dSigHatDR() * lastPDFWeight();
if ( xsec == ZERO ) {
lastCrossSection(ZERO);
return ZERO;
}
xsec *= cutWeight();
lastAlphaS (matrixElement()->orderInAlphaS () >0 ?
matrixElement()->alphaS() : -1.);
lastAlphaEM(matrixElement()->orderInAlphaEW() >0 ?
matrixElement()->alphaEM() : -1.);
matrixElement()->fillProjectors();
if ( !projectors().empty() ) {
lastProjector(projectors().select(UseRandom::rnd()));
}
subProcess(SubProPtr());
if ( CKKWHandler() && matrixElement()->maxMultCKKW() > 0 &&
matrixElement()->maxMultCKKW() > matrixElement()->minMultCKKW() ) {
newSubProcess();
CKKWHandler()->setXComb(this);
xsec *= CKKWHandler()->reweightCKKW(matrixElement()->minMultCKKW(),
matrixElement()->maxMultCKKW());
}
if ( matrixElement()->reweighted() ) {
newSubProcess();
xsec *= matrixElement()->reWeight() * matrixElement()->preWeight();
}
lastCrossSection(xsec);
return xsec;
}
void StandardXComb::newSubProcess(bool group) {
if ( subProcess() ) return;
if ( head() && matrixElement()->wantCMS() ) {
// first get the meMomenta in their CMS, as this may
// not be the case
Boost cm = (meMomenta()[0] + meMomenta()[1]).findBoostToCM();
if ( cm.mag2() > Constants::epsilon ) {
for ( vector<Lorentz5Momentum>::iterator m = meMomenta().begin();
m != meMomenta().end(); ++m ) {
*m = m->boost(cm);
}
}
}
if ( !lastProjector() ) {
if ( !group )
subProcess(new_ptr(SubProcess(lastPartons(), tCollPtr(), matrixElement())));
else
subProcess(new_ptr(SubProcessGroup(lastPartons(), tCollPtr(), matrixElement())));
if ( !theExternalDiagram )
lastDiagramIndex(matrixElement()->diagram(diagrams()));
const ColourLines & cl = matrixElement()->selectColourGeometry(lastDiagram());
Lorentz5Momentum p1 = lastPartons().first->momentum();
Lorentz5Momentum p2 = lastPartons().second->momentum();
tPPair inc = lastPartons();
if ( mirror() ) swap(inc.first, inc.second);
if ( matrixElement()->wantCMS() &&
!matrixElement()->haveX1X2() ) {
LorentzRotation r = Utilities::boostToCM(inc);
lastDiagram()->construct(subProcess(), *this, cl);
subProcess()->transform(r.inverse());
lastPartons().first->set5Momentum(p1);
lastPartons().second->set5Momentum(p2);
} else {
lastDiagram()->construct(subProcess(), *this, cl);
}
lastPartons().first ->scale(partonBinInstances().first ->scale());
lastPartons().second->scale(partonBinInstances().second->scale());
for ( int i = 0, N = subProcess()->outgoing().size(); i < N; ++i )
subProcess()->outgoing()[i]->scale(lastScale());
// construct the spin information for the interaction
matrixElement()->constructVertex(subProcess(),&cl);
// set veto scales
matrixElement()->setVetoScales(subProcess());
} else {
lastProjector()->newSubProcess();
subProcess(lastProjector()->subProcess());
lastPartons(lastProjector()->lastPartons());
lastSHat((lastPartons().first->momentum() +
lastPartons().second->momentum()).m2());
lastX1X2(make_pair(lastPartons().first->momentum().plus()/
lastParticles().first->momentum().plus(),
lastPartons().second->momentum().minus()/
lastParticles().second->momentum().minus()));
lastY(log(lastX1()/lastX2())*0.5);
lastCentralScale(lastProjector()->lastCentralScale());
lastShowerScale(lastProjector()->lastShowerScale());
partonBinInstances().first->parton(lastPartons().first);
partonBinInstances().second->parton(lastPartons().second);
if ( !matrixElement()->keepRandomNumbers() )
throw Exception() << "Matrix element needs to request random number storage "
<< "for creating projected subprocesses."
<< Exception::runerror;
const double * r = &lastRandomNumbers()[0];
pExtractor()->generateSHat(lastS(), partonBinInstances(),
r, r + nDim() - partonDims.second,true);
pExtractor()->updatePartonBinInstances(partonBinInstances());
}
}
void StandardXComb::checkReshufflingNeeds() {
theNeedsReshuffling = false;
if ( eventHandler().cascadeHandler() ) {
if ( eventHandler().cascadeHandler()->isReshuffling() )
return;
}
for ( cPDVector::const_iterator p = mePartonData().begin() + 2;
p != mePartonData().end(); ++p ) {
theNeedsReshuffling |= ( (**p).mass() != (**p).hardProcessMass() );
}
}
double StandardXComb::reshuffleEquation(double k,
const vector<pair<Energy2,Energy2> >& coeffs,
Energy2 Q2) const {
double res = 0.;
for ( vector<pair<Energy2,Energy2> >::const_iterator c = coeffs.begin();
c != coeffs.end(); ++c ) {
double x = sqr(k)*c->first/Q2+c->second/Q2;
if ( x < 0.0 )
throw Veto();
res += sqrt(x);
}
return res - 1.;
}
double StandardXComb::solveReshuffleEquation(const vector<pair<Energy2,Energy2> >& coeffs,
Energy2 Q2) const {
// shamelessly adapted from Herwig++'s QTildeReconstructor
// in principle we could have included the exact solution for two
// outgoing particles, but for this to be simple we would require
// boosting to the CM so the gain is questionable
double k1 = 0.,k2 = 1.,k = 0.;
if ( reshuffleEquation(k1,coeffs,Q2) < 0.0 ) {
while ( reshuffleEquation(k2, coeffs, Q2) < 0.0 ) {
k1 = k2;
k2 *= 2;
}
while ( abs( (k1 - k2)/(k1 + k2) ) > 1.e-10 ) {
if( reshuffleEquation(k2,coeffs,Q2) == 0.0 ) {
return k2;
} else {
k = (k1+k2)/2.;
if ( reshuffleEquation(k,coeffs,Q2) > 0.0 ) {
k2 = k;
} else {
k1 = k;
}
}
}
return k1;
}
throw Veto();
return 1.;
}
void StandardXComb::reshuffle(vector<Lorentz5Momentum>& pout) const {
Lorentz5Momentum Q(ZERO,ZERO,ZERO,ZERO);
for ( vector<Lorentz5Momentum>::const_iterator p = pout.begin();
p != pout.end(); ++p )
Q += *p;
if ( Q.m2() <= ZERO )
throw Veto();
LorentzVector<double> Qhat = Q/sqrt(Q.m2());
vector<Energy> pQhat;
vector<pair<Energy2,Energy2> > coeffs;
vector<Lorentz5Momentum>::const_iterator p = pout.begin();
cPDVector::const_iterator pd = mePartonData().begin() + 2;
for ( ; p != pout.end(); ++p, ++pd ) {
pQhat.push_back((*p)*Qhat);
coeffs.push_back(make_pair(sqr(pQhat.back())-sqr((**pd).hardProcessMass()),
sqr((**pd).mass())));
}
double k = solveReshuffleEquation(coeffs,Q.m2());
vector<Lorentz5Momentum>::iterator px = pout.begin();
vector<Energy>::const_iterator pQ = pQhat.begin();
vector<pair<Energy2,Energy2> >::const_iterator coeff = coeffs.begin();
for ( ; px != pout.end(); ++px, ++pQ, ++coeff ) {
*px = k*((*px) - (*pQ) * Qhat) + sqrt(sqr(k)*coeff->first + coeff->second)*Qhat;
px->rescaleMass();
}
}
tSubProPtr StandardXComb::construct() {
matrixElement()->setXComb(this);
if ( !head() ) {
if ( !cuts()->initSubProcess(lastSHat(), lastY()) ) throw Veto();
} else {
cuts()->initSubProcess(lastSHat(), lastY());
}
if ( head() )
if ( !matrixElement()->apply() )
return tSubProPtr();
setPartonBinInfo();
matrixElement()->setKinematics();
newSubProcess();
TmpTransform<tSubProPtr>
tmp(subProcess(), Utilities::getBoostToCM(subProcess()->incoming()));
if ( !cuts()->passCuts(*subProcess()) ) throw Veto();
if ( head() ) {
subProcess()->head(head()->subProcess());
if(lastCrossSection()!=ZERO&&head()->lastCrossSection()!=ZERO)
subProcess()->groupWeight(lastCrossSection()/head()->lastCrossSection());
else
subProcess()->groupWeight(0.);
}
return subProcess();
}
void StandardXComb::Init() {}
void StandardXComb::persistentOutput(PersistentOStream & os) const {
os << theSubProcessHandler << theME << theStats
<< theDiagrams << isMirror << theNDim << partonDims
<< theLastDiagramIndex << theExternalDiagram
<< theMEInfo << theLastRandomNumbers << theMEPartonData
<< theLastPDFWeight << ounit(theLastCrossSection,nanobarn) << theLastJacobian
<< theLastME2 << theLastPreweight
<< ounit(theLastMECrossSection,nanobarn) << theLastMEPDFWeight << theLastMECouplings
<< theHead << theProjectors << theProjector << theKinematicsGenerated
<< checkedCuts << passedCuts << theCutWeight << theNeedsReshuffling;
}
void StandardXComb::persistentInput(PersistentIStream & is, int) {
is >> theSubProcessHandler >> theME >> theStats
>> theDiagrams >> isMirror >> theNDim >> partonDims
>> theLastDiagramIndex >> theExternalDiagram
>> theMEInfo >> theLastRandomNumbers >> theMEPartonData
>> theLastPDFWeight >> iunit(theLastCrossSection,nanobarn) >> theLastJacobian
>> theLastME2 >> theLastPreweight
>> iunit(theLastMECrossSection,nanobarn) >> theLastMEPDFWeight >> theLastMECouplings
>> theHead >> theProjectors >> theProjector >> theKinematicsGenerated
>> checkedCuts >> passedCuts >> theCutWeight >> theNeedsReshuffling;
}
ClassDescription<StandardXComb> StandardXComb::initStandardXComb;
diff --git a/LesHouches/LesHouchesFileReader.cc b/LesHouches/LesHouchesFileReader.cc
--- a/LesHouches/LesHouchesFileReader.cc
+++ b/LesHouches/LesHouchesFileReader.cc
@@ -1,887 +1,920 @@
// -*- C++ -*-
//
// LesHouchesFileReader.cc 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.
//
//
// This is the implementation of the non-inlined, non-templated member
// functions of the LesHouchesFileReader class.
//
#include "LesHouchesFileReader.h"
#include "ThePEG/Interface/ClassDocumentation.h"
#include "ThePEG/Interface/Reference.h"
#include "ThePEG/Interface/Switch.h"
#include "ThePEG/Interface/Parameter.h"
#include "ThePEG/Utilities/Throw.h"
#include "ThePEG/PDT/DecayMode.h"
#include "ThePEG/Persistency/PersistentOStream.h"
#include "ThePEG/Persistency/PersistentIStream.h"
#include <sstream>
#include <iostream>
using namespace ThePEG;
LesHouchesFileReader::
LesHouchesFileReader(const LesHouchesFileReader & x)
: LesHouchesReader(x), neve(x.neve), ieve(0),
LHFVersion(x.LHFVersion), outsideBlock(x.outsideBlock),
headerBlock(x.headerBlock), initComments(x.initComments),
initAttributes(x.initAttributes), eventComments(x.eventComments),
eventAttributes(x.eventAttributes),
theFileName(x.theFileName), theQNumbers(x.theQNumbers),
+ theIncludeFxFxTags(x.theIncludeFxFxTags),
+ theIncludeCentral(x.theIncludeCentral),
theDecayer(x.theDecayer) {}
LesHouchesFileReader::~LesHouchesFileReader() {}
IBPtr LesHouchesFileReader::clone() const {
return new_ptr(*this);
}
IBPtr LesHouchesFileReader::fullclone() const {
return new_ptr(*this);
}
bool LesHouchesFileReader::preInitialize() const {
return true;
}
void LesHouchesFileReader::doinit() {
LesHouchesReader::doinit();
//cout << "theDecayer->fullName() = " << theDecayer->fullName() << endl;
//if(theDecayer) {
// cout << "DECAYER RETURNS TRUE" << endl;
// }
// are we using QNUMBERS
if(!theQNumbers) return;
// parse the header block and create
// any new particles needed in QNUMBERS blocks
string block = headerBlock;
string line = "";
bool readingSLHA = false;
int (*pf)(int) = tolower;
unsigned int newNumber(0);
do {
line = StringUtils::car(block,"\r\n");
block = StringUtils::cdr(block,"\r\n");
if(line[0]=='#') continue;
// are we reading the SLHA block
if(readingSLHA) {
// reached the end of slha block ?
if(line.find("</slha") != string::npos) {
readingSLHA = false;
break;
}
// remove trailing comment from line
vector<string> split = StringUtils::split(line,"#");
// check for a qnumbers block
transform(split[0].begin(), split[0].end(), split[0].begin(), pf);
// if not contine
if(split[0].find("block qnumbers")==string::npos)
continue;
// get name from comment
string name;
if(split.size()>=2) {
name = StringUtils::stripws(split[1]);
}
else {
++newNumber;
ostringstream tname;
tname << "NP" << newNumber;
name = tname.str();
}
// extract the PDG code
split = StringUtils::split(split[0]," ");
istringstream is(split[2]);
long PDGCode(0);
is >> PDGCode;
// get the charge, spin, colour and whether an antiparticle
int charge(0),spin(0),colour(0),anti(0);
for(unsigned int ix=0;ix<4;++ix) {
line = StringUtils::car(block,"\r\n");
block = StringUtils::cdr(block,"\r\n");
int dummy[2];
istringstream is(line);
is >> dummy[0] >> dummy[1];
switch (dummy[0]) {
case 1:
charge = dummy[1];
break;
case 2:
spin = dummy[1];
break;
case 3:
colour = dummy[1];
break;
case 4:
anti = dummy[1];
break;
default:
assert(false);
}
}
// check if particles already exist
PDPair newParticle;
newParticle.first = getParticleData(PDGCode);
if(newParticle.first) Throw<SetupException>()
<< "Particle with PDG code " << PDGCode
<< " whose creation was requested in a QNUMBERS Block"
<< " already exists. Retaining the original particle"
<< Exception::warning;
if(anti) {
newParticle.second = getParticleData(-PDGCode);
if(newParticle.second) Throw<SetupException>()
<< "Anti-particle with PDG code " << -PDGCode
<< " whose creation was requested in a QNUMBERS Block"
<< " already exists. Retaining the original particle"
<< Exception::warning;
if(( newParticle.first && !newParticle.second ) ||
( newParticle.second && !newParticle.first ) )
Throw<SetupException>()
<< "Either particle or anti-particle with PDG code " << PDGCode
<< " whose creation was requested in a QNUMBERS Block"
<< " already exists, but not both the particle and antiparticle. "
<< " Something dodgy here stopping"
<< Exception::runerror;
}
// already exists continue
if(newParticle.first) continue;
// create the particles
// particle with no anti particle
if( anti == 0 ) {
// construct the name
if(name=="") {
ostringstream temp;
temp << PDGCode;
name = temp.str();
}
// create the ParticleData object
newParticle.first = ParticleData::Create(PDGCode,name);
}
// particle anti-particle pair
else {
// construct the names
string nameAnti;
if(name=="") {
ostringstream temp;
temp << PDGCode;
name = temp.str();
ostringstream temp2;
temp << -PDGCode;
nameAnti = temp2.str();
}
else {
nameAnti=name;
for(string::iterator it=nameAnti.begin();it!=nameAnti.end();++it) {
if(*it=='+') nameAnti.replace(it,it+1,"-");
else if(*it=='-') nameAnti.replace(it,it+1,"+");
}
if(nameAnti==name) nameAnti += "bar";
}
// create the ParticleData objects
newParticle = ParticleData::Create(PDGCode,name,nameAnti);
}
// set the particle properties
if(colour==1) colour = 0;
newParticle.first->iColour(PDT::Colour(colour));
newParticle.first->iSpin (PDT::Spin (spin ));
newParticle.first->iCharge(PDT::Charge(charge));
// register it
generator()->preinitRegister(newParticle.first,
"/Herwig/Particles/"+newParticle.first->PDGName());
// set the antiparticle properties
if(newParticle.second) {
if(colour==3||colour==6) colour *= -1;
charge = -charge;
newParticle.second->iColour(PDT::Colour(colour));
newParticle.second->iSpin (PDT::Spin (spin ));
newParticle.second->iCharge(PDT::Charge(charge));
// register it
generator()->preinitRegister(newParticle.second,
"/Herwig/Particles/"+newParticle.second->PDGName());
}
}
// start of SLHA block ?
else if(line.find("<slha") != string::npos) {
readingSLHA = true;
}
}
while(line!="");
// now set any masses/decay modes
block = headerBlock;
line="";
readingSLHA=false;
bool ok=true;
do {
line = StringUtils::car(block,"\r\n");
block = StringUtils::cdr(block,"\r\n");
// are we reading the SLHA block
if(readingSLHA) {
// reached the end?
if(line.find("</slha") == 0 ) {
readingSLHA = false;
break;
}
// make lower case
transform(line.begin(),line.end(),line.begin(), pf);
// found the mass block ?
if(line.find("block mass")!=string::npos) {
// read it
line = StringUtils::car(block,"\r\n");
// check not at end
while(line[0] != 'D' && line[0] != 'B' &&
line[0] != 'd' && line[0] != 'b' &&
line != "") {
// skip comment lines
if(line[0] == '#') {
block = StringUtils::cdr(block,"\r\n");
line = StringUtils::car(block,"\r\n");
continue;
}
// get the mass and PGD code
istringstream temp(line);
long id;
double mass;
temp >> id >> mass;
// skip resetting masses on SM particles
// as it can cause problems later on in event generation
if(abs(id)<=6 || (abs(id)>=11 && abs(id)<=16) ||
abs(id)==23 || abs(id)==24) {
// Throw<SetupException>() << "Standard model mass for PID "
// << id
// << " will not be changed."
// << Exception::warning;
block = StringUtils::cdr(block,"\r\n");
line = StringUtils::car(block,"\r\n");
continue;
}
// magnitude of mass for susy models
mass = abs(mass);
// set the mass
tPDPtr particle = getParticleData(id);
if(!particle) throw SetupException()
<< "LesHouchesFileReader::doinit() - Particle with PDG code not"
<< id << " not found." << Exception::runerror;
const InterfaceBase * ifb = BaseRepository::FindInterface(particle,
"NominalMass");
ostringstream os;
os << mass;
ifb->exec(*particle, "set", os.str());
// read the next line
block = StringUtils::cdr(block,"\r\n");
line = StringUtils::car(block,"\r\n");
};
}
// found a decay block
else if(line.find("decay") == 0) {
// get PGD code and width
istringstream iss(line);
string dummy;
long parent(0);
Energy width(ZERO);
iss >> dummy >> parent >> iunit(width, GeV);
// get the ParticleData object
PDPtr inpart = getParticleData(parent);
if(!inpart) {
throw SetupException()
<< "LesHouchesFileReader::doinit() - A ParticleData object with the PDG code "
<< parent << " does not exist. " << Exception::runerror;
return;
}
if ( abs(inpart->id()) == 6 ||
abs(inpart->id()) == 15 ||
abs(inpart->id()) == 23 ||
abs(inpart->id()) == 24 ||
abs(inpart->id()) == 25 ) {
Throw<SetupException>() << "\n"
"************************************************************************\n"
"* Your LHE file changes the width of " << inpart->PDGName() << ".\n"
"* This can cause serious problems in the event generation!\n"
"************************************************************************\n"
"\n" << Exception::warning;
}
else if (inpart->width() > ZERO && width <= ZERO) {
Throw<SetupException>() << "\n"
"************************************************************************\n"
"* Your LHE file zeroes the non-zero width of " << inpart->PDGName() << ".\n"
"* If " << inpart->PDGName() << " is a decaying SM particle,\n"
"* this can cause serious problems in the event generation!\n"
"************************************************************************\n"
"\n" << Exception::warning;
}
// set the width
inpart->width(width);
if( width > ZERO ) {
inpart->cTau(hbarc/width);
inpart->widthCut(5.*width);
inpart->stable(false);
}
// construct prefix for DecayModes
string prefix(inpart->name() + "->"), tag(prefix),line("");
unsigned int nmode(0);
// read any decay modes
line = StringUtils::car(block,"\r\n");
while(line[0] != 'D' && line[0] != 'B' &&
line[0] != 'd' && line[0] != 'b' &&
line[0] != '<' && line != "") {
// skip comments
if(line[0] == '#') {
block = StringUtils::cdr(block,"\r\n");
line = StringUtils::car(block,"\r\n");
continue;
}
// read decay mode and construct the tag
istringstream is(line);
double brat(0.);
unsigned int nda(0),npr(0);
is >> brat >> nda;
while( true ) {
long t;
is >> t;
if( is.fail() ) break;
if( t == abs(parent) )
throw SetupException()
<< "An error occurred while read a decay of the "
<< inpart->PDGName() << ". One of its products has the same PDG code "
<< "as the parent particle in LesHouchesFileReader::doinit()."
<< " Please check the Les Houches file.\n"
<< Exception::runerror;
tcPDPtr p = getParticleData(t);
if( !p )
throw SetupException()
<< "LesHouchesFileReader::doinit() -"
<< " An unknown PDG code has been encounterd "
<< "while reading a decay mode. ID: " << t
<< Exception::runerror;
++npr;
tag += p->name() + ",";
}
if( npr != nda )
throw SetupException()
<< "LesHouchesFileReader::doinit() - While reading a decay of the "
<< inpart->PDGName() << " from an SLHA file, an inconsistency "
<< "between the number of decay products and the value in "
<< "the 'NDA' column was found. Please check if the spectrum "
<< "file is correct.\n"
<< Exception::warning;
// create the DecayMode
if( npr > 1 ) {
if( nmode==0 ) {
generator()->preinitInterface(inpart, "VariableRatio" , "set","false");
if(inpart->massGenerator()) {
ok = false;
Throw<SetupException>()
<< inpart->PDGName() << " already has a MassGenerator set"
<< " this is incompatible with using QNUMBERS "
<< "Use\n"
<< "set " << inpart->fullName() << ":Mass_generator NULL\n"
<< "to fix this." << Exception::warning;
}
if(inpart->widthGenerator()) {
ok = false;
Throw<SetupException>()
<< inpart->PDGName() << " already has a WidthGenerator set"
<< " this is incompatible with using QNUMBERS "
<< "Use\n"
<< "set " << inpart->fullName() << ":Width_generator NULL\n"
<< "to fix this." << Exception::warning;
}
unsigned int ntemp=0;
for(DecaySet::const_iterator dit = inpart->decayModes().begin();
dit != inpart->decayModes().end(); ++dit ) {
if((**dit).on()) ++ntemp;
}
if(ntemp!=0) {
ok = false;
Throw<SetupException>()
<< inpart->PDGName() << " already has DecayModes"
<< " this is incompatible with using QNUMBERS "
<< "Use\n"
<< "do " << inpart->fullName() << ":SelectDecayModes none\n"
<< " to fix this." << Exception::warning;
}
}
inpart->stable(false);
tag.replace(tag.size() - 1, 1, ";");
DMPtr dm = generator()->findDecayMode(tag);
if(!theDecayer) Throw<SetupException>()
<< "LesHouchesFileReader::doinit() Decayer must be set using the "
<< "LesHouchesFileReader:Decayer"
<< " must be set to allow the creation of new"
<< " decay modes."
<< Exception::runerror;
if(!dm) {
dm = generator()->preinitCreateDecayMode(tag);
if(!dm)
Throw<SetupException>()
<< "LesHouchesFileReader::doinit() - Needed to create "
<< "new decaymode but one could not be created for the tag "
<< tag << Exception::warning;
}
generator()->preinitInterface(dm, "Decayer", "set",
theDecayer->fullName());
ostringstream br;
br << setprecision(13) << brat;
generator()->preinitInterface(dm, "BranchingRatio", "set", br.str());
generator()->preinitInterface(dm, "OnOff", "set", "On");
if(dm->CC()) {
generator()->preinitInterface(dm->CC(), "BranchingRatio", "set", br.str());
generator()->preinitInterface(dm->CC(), "OnOff", "set", "On");
}
++nmode;
}
tag=prefix;
// read the next line
block = StringUtils::cdr(block,"\r\n");
line = StringUtils::car(block,"\r\n");
};
if(nmode>0) {
inpart->update();
if(inpart->CC())
inpart->CC()->update();
}
}
}
// start of SLHA block ?
else if(line.find("<slha") != string::npos) {
readingSLHA = true;
}
}
while(line!="");
if(!ok)
throw SetupException() << "Problem reading QNUMBERS blocks in LesHouchesFileReader::doinit()"
<< Exception::runerror;
}
void LesHouchesFileReader::initialize(LesHouchesEventHandler & eh) {
LesHouchesReader::initialize(eh);
if ( LHFVersion.empty() )
Throw<LesHouchesFileError>()
<< "The file associated with '" << name() << "' does not contain a "
<< "proper formatted Les Houches event file. The events may not be "
<< "properly sampled." << Exception::warning;
}
//vector<string> LesHouchesFileReader::optWeightNamesFunc() { return optionalWeightsNames; }
vector<string> LesHouchesFileReader::optWeightsNamesFunc() { return optionalWeightsNames; }
void LesHouchesFileReader::open() {
if ( filename().empty() )
throw LesHouchesFileError()
<< "No Les Houches file name. "
<< "Use 'set " << name() << ":FileName'."
<< Exception::runerror;
cfile.open(filename());
if ( !cfile )
throw LesHouchesFileError()
<< "The LesHouchesFileReader '" << name() << "' could not open the "
<< "event file called '" << theFileName << "'."
<< Exception::runerror;
cfile.readline();
if ( !cfile.find("<LesHouchesEvents") ) return;
map<string,string> attributes =
StringUtils::xmlAttributes("LesHouchesEvents", cfile.getline());
LHFVersion = attributes["version"];
//cout << LHFVersion << endl;
if ( LHFVersion.empty() ) return;
bool readingHeader = false;
bool readingInit = false;
headerBlock = "";
// char (cwgtinfo_weights_info[250][15]);
string hs;
// int cwgtinfo_nn(0);
// Loop over all lines until we hit the </init> tag.
bool readingInitWeights = false, readingInitWeights_sc = false;
string weightinfo;
while ( cfile.readline() ) {
// found the init block for multiple weights
if(cfile.find("<initrwgt")) { /*cout << "reading weights" << endl;*/ readingInitWeights = true; }
// found end of init block for multiple weights: end the while loop
if(cfile.find("</initrwgt")) { readingInitWeights = false; readingInitWeights_sc = false; continue;}
// found the end of init block
if(cfile.find("</init")) { readingInit = false; break; }
/* read the weight information block
* optionalWeightNames will contain information about the weights
* this will be appended to the weight information
*/
if(readingInitWeights) {
string scalename = "";
if(cfile.find("<weightgroup")) {
/* we found a weight group
* start reading the information
* within it
*/
readingInitWeights_sc = true;
weightinfo = cfile.getline();
/* to make it shorter, erase some stuff
*/
string str_weightgroup = "<weightgroup";
string str_arrow = ">";
string str_newline = "\n";
erase_substr(weightinfo, str_weightgroup);
erase_substr(weightinfo, str_arrow);
erase_substr(weightinfo, str_newline);
}
/* if we are reading a new weightgroup, go on
* until we find the end of it
*/
if(readingInitWeights_sc && !cfile.find("</weightgroup")) {
hs = cfile.getline();
istringstream isc(hs);
int ws = 0;
/* get the name that will be used to identify the scale
*/
do {
string sub; isc >> sub;
if(ws==1) { string str_arrow = ">"; erase_substr(sub, str_arrow); scalename = sub; }
++ws;
} while (isc);
/* now get the relevant information
* e.g. scales or PDF sets used
*/
string startDEL = "'>"; //starting delimiter
string stopDEL = "</weight>"; //end delimiter
unsigned firstLim = hs.find(startDEL); //find start of delimiter
// unsigned lastLim = hs.find(stopDEL); //find end of delimitr
string scinfo = hs.substr(firstLim); //define the information for the scale
erase_substr(scinfo,stopDEL);
erase_substr(scinfo,startDEL);
scinfo = weightinfo + scinfo;
/* fill in the map
* indicating the information to be appended to each scale
* i.e. scinfo for each scalname
*/
scalemap[scalename] = scinfo.c_str();
string str_id = "id=";
string str_prime = "'";
erase_substr(scalename, str_id);
erase_substr(scalename, str_prime);
optionalWeightsNames.push_back(scalename);
}
}
if ( cfile.find("<header") ) {
// We have hit the header block, so we should dump this and all
// following lines to headerBlock until we hit the end of it.
readingHeader = true;
headerBlock = cfile.getline() + "\n";
}
if ( (cfile.find("<init ") && !cfile.find("<initrwgt")) || cfile.find("<init>") ) {
//cout << "found init block" << endl;
// We have hit the init block, so we should expect to find the
// standard information in the following. But first check for
// attributes.
initAttributes = StringUtils::xmlAttributes("init", cfile.getline());
readingInit = true;
cfile.readline();
if ( !( cfile >> heprup.IDBMUP.first >> heprup.IDBMUP.second
>> heprup.EBMUP.first >> heprup.EBMUP.second
>> heprup.PDFGUP.first >> heprup.PDFGUP.second
>> heprup.PDFSUP.first >> heprup.PDFSUP.second
>> heprup.IDWTUP >> heprup.NPRUP ) ) {
heprup.NPRUP = -42;
LHFVersion = "";
return;
}
heprup.resize();
for ( int i = 0; i < heprup.NPRUP; ++i ) {
cfile.readline();
if ( !( cfile >> heprup.XSECUP[i] >> heprup.XERRUP[i]
>> heprup.XMAXUP[i] >> heprup.LPRUP[i] ) ) {
heprup.NPRUP = -42;
LHFVersion = "";
return;
}
}
}
if ( cfile.find("</header") ) {
readingHeader = false;
headerBlock += cfile.getline() + "\n";
}
if ( readingHeader ) {
/* We are in the process of reading the header block. Dump the
line to headerBlock.*/
headerBlock += cfile.getline() + "\n";
}
if ( readingInit ) {
// Here we found a comment line. Dump it to initComments.
initComments += cfile.getline() + "\n";
}
}
string central = "central";
- optionalWeightsNames.push_back(central);
+ if (theIncludeCentral) optionalWeightsNames.push_back(central);
// cout << "reading init finished" << endl;
if ( !cfile ) {
heprup.NPRUP = -42;
LHFVersion = "";
return;
}
}
bool LesHouchesFileReader::doReadEvent() {
if ( !cfile ) return false;
if ( LHFVersion.empty() ) return false;
if ( heprup.NPRUP < 0 ) return false;
eventComments = "";
outsideBlock = "";
hepeup.NUP = 0;
hepeup.XPDWUP.first = hepeup.XPDWUP.second = 0.0;
optionalWeights.clear();
optionalWeightsTemp.clear();
// Keep reading lines until we hit the next event or the end of
// the event block. Save any inbetween lines. Exit if we didn't
// find an event.
while ( cfile.readline() && !cfile.find("<event") )
outsideBlock += cfile.getline() + "\n";
// We found an event. First scan for attributes.
eventAttributes = StringUtils::xmlAttributes("event", cfile.getline());
/* information necessary for FxFx merging:
* the npLO and npNLO tags
*/
istringstream ievat(cfile.getline());
int we(0), npLO(-99), npNLO(-99);
do {
string sub; ievat >> sub;
if(we==2) { npLO = atoi(sub.c_str()); }
if(we==5) { npNLO = atoi(sub.c_str()); }
++we;
} while (ievat);
optionalnpLO = npLO;
optionalnpNLO = npNLO;
std::stringstream npstringstream;
npstringstream << "np " << npLO << " " << npNLO;
std::string npstrings = npstringstream.str();
/* the FxFx merging information
* becomes part of the optionalWeights, labelled -999
* for future reference
*/
- optionalWeights[npstrings.c_str()] = -999;
+
+ if(theIncludeFxFxTags) optionalWeights[npstrings.c_str()] = -999;
if ( !cfile.readline() ) return false;
// The first line determines how many subsequent particle lines we
// have.
if ( !( cfile >> hepeup.NUP >> hepeup.IDPRUP >> hepeup.XWGTUP
>> hepeup.SCALUP >> hepeup.AQEDUP >> hepeup.AQCDUP ) )
return false;
hepeup.resize();
// Read all particle lines.
for ( int i = 0; i < hepeup.NUP; ++i ) {
if ( !cfile.readline() ) return false;
if ( !( cfile >> hepeup.IDUP[i] >> hepeup.ISTUP[i]
>> hepeup.MOTHUP[i].first >> hepeup.MOTHUP[i].second
>> hepeup.ICOLUP[i].first >> hepeup.ICOLUP[i].second
>> hepeup.PUP[i][0] >> hepeup.PUP[i][1] >> hepeup.PUP[i][2]
>> hepeup.PUP[i][3] >> hepeup.PUP[i][4]
>> hepeup.VTIMUP[i] >> hepeup.SPINUP[i] ) )
return false;
//print momenta for debugging
// cout << hepeup.PUP[i][0] << " " << hepeup.PUP[i][1] << " " << hepeup.PUP[i][2] << " " << hepeup.PUP[i][3] << " " << hepeup.PUP[i][4] << endl;
if(isnan(hepeup.PUP[i][0])||isnan(hepeup.PUP[i][1])||
isnan(hepeup.PUP[i][2])||isnan(hepeup.PUP[i][3])||
isnan(hepeup.PUP[i][4]))
throw Exception()
<< "nan's as momenta in Les Houches file "
<< Exception::eventerror;
if(hepeup.MOTHUP[i].first -1==i ||
hepeup.MOTHUP[i].second-1==i) {
throw Exception()
<< "Particle has itself as a mother in Les Houches "
<< "file, this is not allowed\n"
<< Exception::eventerror;
}
}
// Now read any additional comments and named weights.
// read until the end of rwgt is found
bool readingWeights = false, readingaMCFast = false, readingMG5ClusInfo = false;
while ( cfile.readline() && !cfile.find("</event>")) {
if(cfile.find("</applgrid")) { readingaMCFast=false; } //aMCFast weights end
if(cfile.find("</rwgt")) { readingWeights=false; } //optional weights end
if(cfile.find("</clustering")) { readingMG5ClusInfo=false; } // mg5 mclustering scale info end
/* reading of optional weights
*/
if(readingWeights) {
if(!cfile.find("<wgt")) { continue; }
istringstream iss(cfile.getline());
int wi = 0;
double weightValue(0);
string weightName = "";
// we need to put the actual weight value into a double
do {
string sub; iss >> sub;
if(wi==1) { string str_arrow = ">" ; erase_substr(sub, str_arrow); weightName = sub; }
if(wi==2) weightValue = atof(sub.c_str());
++wi;
} while (iss);
// store the optional weights found in the temporary map
optionalWeightsTemp[weightName] = weightValue;
}
/* reading of aMCFast weights
*/
if(readingaMCFast) {
std::stringstream amcfstringstream;
amcfstringstream << "aMCFast " << cfile.getline();
std::string amcfstrings = amcfstringstream.str();
string str_newline = "\n";
erase_substr(amcfstrings,str_newline);
optionalWeights[amcfstrings.c_str()] = -111; //for the aMCFast we give them a weight -111 for future identification
}
/* read additional MG5 Clustering information
* used in LO merging
*/
if(readingMG5ClusInfo) {
string hs = cfile.getline();
string startDEL = "<clus scale="; //starting delimiter
string stopDEL = "</clus>"; //end delimiter
unsigned firstLim = hs.find(startDEL); //find start of delimiter
// unsigned lastLim = hs.find(stopDEL); //find end of delimitr
string mg5clusinfo = hs.substr(firstLim); //define the information for the scale
erase_substr(mg5clusinfo,stopDEL);
erase_substr(mg5clusinfo,startDEL);
string str_arrow = ">";
erase_substr(mg5clusinfo,str_arrow);
string str_quotation = "\"";
erase_substr(mg5clusinfo,str_quotation);
optionalWeights[mg5clusinfo.c_str()] = -222; //for the mg5 scale info weights we give them a weight -222 for future identification
}
//store MG5 clustering information
if(cfile.find("<scales")) {
string hs = cfile.getline();
string startDEL = "<scales"; //starting delimiter
string stopDEL = "</scales>"; //end delimiter
unsigned firstLim = hs.find(startDEL); //find start of delimiter
// unsigned lastLim = hs.find(stopDEL); //find end of delimitr
string mg5scinfo = hs.substr(firstLim); //define the information for the scale
erase_substr(mg5scinfo,stopDEL);
erase_substr(mg5scinfo,startDEL);
string str_arrow = ">";
erase_substr(mg5scinfo,str_arrow);
optionalWeights[mg5scinfo.c_str()] = -333; //for the mg5 scale info weights we give them a weight -333 for future identification
}
//determine start of aMCFast weights
if(cfile.find("<applgrid")) { readingaMCFast = true;}
//determine start of optional weights
if(cfile.find("<rwgt")) { readingWeights = true; }
//determine start of MG5 clustering scale information
if(cfile.find("<clustering")) { readingMG5ClusInfo = true;}
}
// loop over the optional weights and add the extra information as found in the init
for (map<string,double>::const_iterator it=optionalWeightsTemp.begin(); it!=optionalWeightsTemp.end(); ++it){
for (map<string,string>::const_iterator it2=scalemap.begin(); it2!=scalemap.end(); ++it2){
//find the scale id in the scale information and add this information
if(it->first==it2->first) {
string info = it2->second + " " + it->first;
string str_newline = "\n";
erase_substr(info, str_newline);
//set the optional weights
optionalWeights[info] = it->second;
- /*cout << "info = " << info << endl;
- std::cout << it->first << " => " << it->second << '\n';*/
- }
+ }
}
}
/* additionally, we set the "central" scale
* this is actually the default event weight
*/
string central = "central";
- optionalWeights[central] = hepeup.XWGTUP;
+ if (theIncludeCentral) optionalWeights[central] = hepeup.XWGTUP;
if ( !cfile ) return false;
return true;
}
void LesHouchesFileReader::close() {
cfile.close();
}
void LesHouchesFileReader::persistentOutput(PersistentOStream & os) const {
os << neve << LHFVersion << outsideBlock << headerBlock << initComments
<< initAttributes << eventComments << eventAttributes << theFileName
- << theQNumbers << theDecayer ;
+ << theQNumbers << theIncludeFxFxTags << theIncludeCentral << theDecayer ;
}
void LesHouchesFileReader::persistentInput(PersistentIStream & is, int) {
is >> neve >> LHFVersion >> outsideBlock >> headerBlock >> initComments
>> initAttributes >> eventComments >> eventAttributes >> theFileName
- >> theQNumbers >> theDecayer;
+ >> theQNumbers >> theIncludeFxFxTags >> theIncludeCentral >> theDecayer;
ieve = 0;
}
ClassDescription<LesHouchesFileReader>
LesHouchesFileReader::initLesHouchesFileReader;
// Definition of the static class description member.
void LesHouchesFileReader::Init() {
static ClassDocumentation<LesHouchesFileReader> documentation
("ThePEG::LesHouchesFileReader is an base class to be used for objects "
"which reads event files from matrix element generators. This class is "
"able to read plain event files conforming to the Les Houches Event File "
"accord.");
static Parameter<LesHouchesFileReader,string> interfaceFileName
("FileName",
"The name of a file containing events conforming to the Les Houches "
"protocol to be read into ThePEG. A file name ending in "
"<code>.gz</code> will be read from a pipe which uses "
"<code>zcat</code>. If a file name ends in <code>|</code> the "
"preceeding string is interpreted as a command, the output of which "
"will be read through a pipe.",
&LesHouchesFileReader::theFileName, "", false, false);
interfaceFileName.fileType();
interfaceFileName.rank(11);
static Switch<LesHouchesFileReader,bool> interfaceQNumbers
("QNumbers",
"Whether or not to read search for and read a QNUMBERS"
" block in the header of the file.",
&LesHouchesFileReader::theQNumbers, false, false, false);
static SwitchOption interfaceQNumbersYes
(interfaceQNumbers,
"Yes",
"Use QNUMBERS",
true);
static SwitchOption interfaceQNumbersNo
(interfaceQNumbers,
"No",
"Don't use QNUMBERS",
false);
+ static Switch<LesHouchesFileReader,bool> interfaceIncludeFxFxTags
+ ("IncludeFxFxTags",
+ "Include FxFx tags",
+ &LesHouchesFileReader::theIncludeFxFxTags, false, true, false);
+ static SwitchOption interfaceIncludeFxFxTagsYes
+ (interfaceIncludeFxFxTags,
+ "Yes",
+ "Use the FxFx tags",
+ true);
+ static SwitchOption interfaceIncludeFxFxTagsNo
+ (interfaceIncludeFxFxTags,
+ "No",
+ "Don't use the FxFx tags",
+ false);
+
+ static Switch<LesHouchesFileReader,bool> interfaceIncludeCentral
+ ("IncludeCentral",
+ "Include definition of central weight",
+ &LesHouchesFileReader::theIncludeCentral, false, true, false);
+ static SwitchOption interfaceIncludeCentralYes
+ (interfaceIncludeCentral,
+ "Yes",
+ "include definition of central weight",
+ true);
+ static SwitchOption interfaceIncludeCentralNo
+ (interfaceIncludeCentral,
+ "No",
+ "Don't include definition of central weight",
+ false);
+
+
+
static Reference<LesHouchesFileReader,Decayer> interfaceDecayer
("Decayer",
"Decayer to use for any decays read from the QNUMBERS Blocks",
&LesHouchesFileReader::theDecayer, false, false, true, true, false);
}
void LesHouchesFileReader::erase_substr(std::string& subject, const std::string& search) {
size_t pos = 0;
while((pos = subject.find(search, pos)) != std::string::npos) {
subject.erase( pos, search.length() );
}
}
diff --git a/LesHouches/LesHouchesFileReader.h b/LesHouches/LesHouchesFileReader.h
--- a/LesHouches/LesHouchesFileReader.h
+++ b/LesHouches/LesHouchesFileReader.h
@@ -1,323 +1,333 @@
// -*- C++ -*-
//
// LesHouchesFileReader.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_LesHouchesFileReader_H
#define THEPEG_LesHouchesFileReader_H
// This is the declaration of the LesHouchesFileReader class.
#include "LesHouchesReader.h"
#include "LesHouchesFileReader.fh"
#include "ThePEG/PDT/Decayer.h"
#include "ThePEG/Utilities/CFileLineReader.h"
#include <string>
#include <stdio.h>
namespace ThePEG {
/**
* LesHouchesFileReader is an base class to be used for objects which
* reads event files from matrix element generators. It inherits from
* LesHouchesReader and extends it by defining a file handle to be
* read from, which is opened and closed by the open() and close()
* functions. Note that the file handle is a standard C filehandle and
* not a C++ stream. This is because there is no standard way in C++
* to connect a pipe to a stream for reading eg. gzipped files. This
* class is able to read plain event files conforming to the Les
* Houches Event File accord.
*
* @see \ref LesHouchesFileReaderInterfaces "Th1e interfaces"
* defined for LesHouchesFileReader.
* @see Event
* @see LesHouchesReader
*/
class LesHouchesFileReader: public LesHouchesReader {
public:
/** @name Standard constructors and destructors. */
//@{
/**
* Default constructor.
*/
LesHouchesFileReader() : neve(0), ieve(0), theQNumbers(false) {}
/**
* Copy-constructor. Note that a file which is opened in the object
* copied from will have to be reopened in this.
*/
LesHouchesFileReader(const LesHouchesFileReader &);
/**
* Destructor.
*/
virtual ~LesHouchesFileReader();
//@}
public:
/** @name Virtual functions specified by the LesHouchesReader base class. */
//@{
/**
* Initialize. This function is called by the LesHouchesEventHandler
* to which this object is assigned.
*/
virtual void initialize(LesHouchesEventHandler & eh);
/**
* Open a file with events. Derived classes should overwrite it and
* first calling it before reading in the run information into the
* corresponding protected variables.
*/
virtual void open();
/**
* Close the file from which events have been read.
*/
virtual void close();
/**
* Read the next event from the file or stream into the
* corresponding protected variables. Return false if there is no
* more events or if this was not a LHF event file.
*/
virtual bool doReadEvent();
//@}
/**
* Return the name of the file from where to read events.
*/
string filename() const { return theFileName; }
/**
* Return the optional weights information string ("Names")
*/
virtual vector<string> optWeightsNamesFunc();
public:
/** @name Functions used by the persistent I/O system. */
//@{
/**
* Function used to write out object persistently.
* @param os the persistent output stream written to.
*/
void persistentOutput(PersistentOStream & os) const;
/**
* Function used to read in object persistently.
* @param is the persistent input stream read from.
* @param version the version number of the object when written.
*/
void persistentInput(PersistentIStream & is, int version);
//@}
/**
* Standard Init function used to initialize the interfaces.
*/
static void Init();
/**
* Erases all occurences of a substring from a string
*/
void erase_substr(std::string& subject, const std::string& search);
protected:
/** @name Clone Methods. */
//@{
/**
* Make a simple clone of this object.
* @return a pointer to the new object.
*/
virtual IBPtr clone() const;
/** Make a clone of this object, possibly modifying the cloned object
* to make it sane.
* @return a pointer to the new object.
*/
virtual IBPtr fullclone() const;
//@}
/** @name Standard (and non-standard) Interfaced functions. */
//@{
/**
* Initialize this object after the setup phase before saving an
* EventGenerator to disk.
* @throws InitException if object could not be initialized properly.
*/
virtual void doinit();
/**
* Return true if this object needs to be initialized before all
* other objects because it needs to extract PDFs from the event file.
*/
virtual bool preInitialize() const;
//@
protected:
/**
* The wrapper around the C FILE stream from which to read
*/
CFileLineReader cfile;
protected:
/**
* The number of events in this file.
*/
long neve;
/**
* The current event number.
*/
long ieve;
/**
* If the file is a standard Les Houches formatted file (LHF) this
* is its version number. If empty, this is not a Les Houches
* formatted file
*/
string LHFVersion;
/**
* If LHF. All lines (since the last open() or readEvent()) outside
* the header, init and event tags.
*/
string outsideBlock;
/**
* If LHF. All lines from the header block.
*/
string headerBlock;
/**
* If LHF. Additional comments found in the init block.
*/
string initComments;
/**
* If LHF. Map of attributes (name-value pairs) found in the init
* tag.
*/
map<string,string> initAttributes;
/**
* If LHF. Additional comments found with the last read event.
*/
string eventComments;
/**
* If LHF. Map of attributes (name-value pairs) found in the last
* event tag.
*/
map<string,string> eventAttributes;
private:
/**
* The name of the file from where to read events.
*/
string theFileName;
/**
* Whether or not to search for QNUMBERS stuff
*/
bool theQNumbers;
/**
+ * Include/Read FxFx tags
+ */
+ bool theIncludeFxFxTags;
+
+ /**
+ * Include central weight (for backup use)
+ */
+ bool theIncludeCentral;
+
+ /**
* Decayer for any decay modes read from the file
*/
DecayerPtr theDecayer;
/**
* Further information on the weights
*/
map<string,string> scalemap;
/**
* Temporary holder for optional weights
*/
map<string,double> optionalWeightsTemp;
private:
/**
* Describe an abstract base class with persistent data.
*/
static ClassDescription<LesHouchesFileReader> initLesHouchesFileReader;
/**
* Private and non-existent assignment operator.
*/
LesHouchesFileReader & operator=(const LesHouchesFileReader &);
public:
/** @cond EXCEPTIONCLASSES */
/** Exception class used by LesHouchesFileReader if reading the file
* fails. */
class LesHouchesFileError: public Exception {};
/** @endcond */
};
}
#include "ThePEG/Utilities/ClassTraits.h"
namespace ThePEG {
/** @cond TRAITSPECIALIZATIONS */
/**
* This template specialization informs ThePEG about the
* base class of LesHouchesFileReader.
*/
template <>
struct BaseClassTrait<LesHouchesFileReader,1>: public ClassTraitsType {
/** Typedef of the base class of LesHouchesFileReader. */
typedef LesHouchesReader NthBase;
};
/**
* This template specialization informs ThePEG about the name of the
* LesHouchesFileReader class and the shared object where it is
* defined.
*/
template <>
struct ClassTraits<LesHouchesFileReader>
: public ClassTraitsBase<LesHouchesFileReader> {
/**
* Return the class name.
*/
static string className() { return "ThePEG::LesHouchesFileReader"; }
/**
* Return the name of the shared library to be loaded to get access
* to the LesHouchesFileReader class and every other class it uses
* (except the base class).
*/
static string library() { return "LesHouches.so"; }
};
/** @endcond */
}
#endif /* THEPEG_LesHouchesFileReader_H */
diff --git a/PDT/Matcher.tcc b/PDT/Matcher.tcc
--- a/PDT/Matcher.tcc
+++ b/PDT/Matcher.tcc
@@ -1,60 +1,60 @@
// -*- C++ -*-
//
// Matcher.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.
//
//
// This is the implementation of the non-inlined templated member
// functions of the Matcher class.
//
namespace ThePEG {
template <class T>
Matcher<T>::~Matcher() {
- if ( !initMatcher.check() ) throw int();
+ assert ( initMatcher.check() );
}
template <class T>
NoPIOClassDescription< Matcher<T> > Matcher<T>::initMatcher;
template <class T>
PMPtr Matcher<T>::Create(const string & newName, string antiName) {
typedef typename Ptr< Matcher<T> >::pointer MatcherPtr;
typedef typename Ptr< Matcher<typename T::CC> >::pointer AMatcherPtr;
PMPtr pm = new_ptr<MatcherPtr>();
registerRepository(pm, newName);
if ( typeid(T) == typeid(typename T::CC) ) return pm;
if ( antiName.empty() ) antiName = newName + "~";
PMPtr apm = new_ptr<AMatcherPtr>();
setCC(pm, apm);
registerRepository(apm, antiName);
return pm;
}
template <class T>
PMPtr Matcher<T>::pmclone() const {
return new_ptr(*this);
}
template <class T>
IBPtr Matcher<T>::clone() const {
return pmclone();
}
template <class T>
IBPtr Matcher<T>::fullclone() const {
PMPtr pm = pmclone();
registerRepository(pm);
if ( !CC() ) return pm;
PMPtr apm = CC()->pmclone();
setCC(pm, apm);
registerRepository(apm);
return pm;
}
}
diff --git a/Utilities/AnyReference.h b/Utilities/AnyReference.h
--- a/Utilities/AnyReference.h
+++ b/Utilities/AnyReference.h
@@ -1,185 +1,185 @@
// -*- C++ -*-
//
// AnyReference.h is a part of ThePEG - Toolkit for HEP Event Generation
// Copyright (C) 1999-2007 Leif Lonnblad
// Copyright (C) 2010-2011 Simon Platzer
//
// 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_AnyReference_H
#define ThePEG_AnyReference_H
#include "ThePEG/Config/ThePEG.h"
#include "Exception.h"
namespace ThePEG {
/**
* AnyReference is inspired by boost::any to hold a reference to an
* object of arbitrary type.
*/
class AnyReference {
struct ReferenceHolderBase {
/**
* The destructor.
*/
virtual ~ReferenceHolderBase() {}
/**
* Return the type held.
*/
virtual const std::type_info& type() const = 0;
/**
* Clone this reference holder.
*/
virtual ReferenceHolderBase* clone() const = 0;
};
template<class T>
struct ReferenceHolder
: public ReferenceHolderBase {
/**
* The reference held.
*/
T& value;
/**
* Static member to initialize the reference.
*/
static T& init() {
static T v; return v;
}
/**
* The default constructor
*/
ReferenceHolder()
: value(init()) {}
/**
* Construct from given reference.
*/
explicit ReferenceHolder(T& v)
: value(v) {}
/**
* Return the type held.
*/
virtual const std::type_info& type() const {
return typeid(T);
}
/**
* Clone this reference holder.
*/
virtual ReferenceHolderBase* clone() const {
return new ReferenceHolder(*this);
}
};
/**
* The reference holder used.
*/
ReferenceHolderBase* holder;
public:
/**
* The default constructor
*/
AnyReference()
: holder(0) {}
/**
* The standard constructor
*/
template<class T>
AnyReference(T& v)
: holder(new ReferenceHolder<T>(v)) {}
/**
* The copy constructor
*/
AnyReference(const AnyReference& other)
: holder(other.holder ? other.holder->clone() : 0) {}
/**
* The destructor.
*/
~AnyReference() {
if ( holder ) {
delete holder; holder = 0;
}
}
public:
/**
* Return the type held.
*/
const std::type_info& type() const { return holder ? holder->type() : typeid(void); }
/**
* Return true, if no reference is held.
*/
bool empty() const { return !holder; }
public:
/**
* Swap the references held.
*/
AnyReference& swap(AnyReference& other) {
std::swap(holder,other.holder); return *this;
}
/**
* Assign from definite type
*/
template<class T>
AnyReference& operator=(T& v) {
AnyReference(v).swap(*this);
return *this;
}
/**
* Assign from AnyReference
*/
AnyReference& operator=(AnyReference other) {
other.swap(*this);
return *this;
}
/**
* Reset to not keep track of any reference.
*/
void reset() {
- if ( holder ) delete holder; holder = 0;
+ if ( holder ) { delete holder; holder = 0; }
}
public:
/**
* Extract the held reference.
*/
template<class T>
T& cast() const {
if ( !empty() && type() == typeid(T) ) {
return static_cast<ReferenceHolder<T>*>(holder)->value;
}
throw Exception() << "Bad cast in AnyReference" << Exception::abortnow;
return ReferenceHolder<T>::init();
}
};
}
#endif // ThePEG_AnyReference_H
diff --git a/Utilities/Throw.h b/Utilities/Throw.h
--- a/Utilities/Throw.h
+++ b/Utilities/Throw.h
@@ -1,104 +1,104 @@
// -*- C++ -*-
//
// Throw.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_Throw_H
#define ThePEG_Throw_H
// This is the declaration of the Throw class.
#include "ThePEG/Config/ThePEG.h"
#include "ThePEG/Utilities/Exception.h"
#include "ThePEG/Repository/CurrentGenerator.h"
#include "ThePEG/Repository/Repository.h"
namespace ThePEG {
/**
* Helper function to make it easier to throw exceptions. The template
* argument should be a class inheriting from Exception. In the
* constructor, an object of this Exception class is created and
* afterwards a message may be added using ostream-like output
* (&lt;&lt;). If a Exception::Severity value is output with &lt;&lt;
* the Exception object is assumed to be complete and the exception is
* actually thrown, except if the Exception::Severity value
* Exception::warning was specified, in which case the Exception
* object is treated as a warning which is logged with the current
* EventGenerator. If no current EventGenerator is present the warning
* message is instead written to std::cerr. If no Exception::Severity
* is specified, the Exception object is thrown when the Throw object
* is destroyed.
*
* Assuming you have an Exception class called MyEx the Throw class is
* used as follows:<br><code>Throw&lt;MyEx&gt>() &lt;&lt; "My error
* message" &lt;&lt; Exception::eventerror;</code><br> This will throw
* an exception and the current event will be discarded. Changing
* <code>Exception::eventerror</code> to
* <code>Exception::warning</code> will write out a warning, but no
* proper exception is thrown.
*/
template <typename Ex>
struct Throw {
/**
* Standard constructor creating an internal Exception object.
*/
Throw(): ex(Ex()), handled(false) {}
/**
* Add information to the current Exception object.
*/
template <typename T> Throw & operator<<(const T & t) {
ex << t;
return *this;
}
/**
* Specify the Exception::Severity of the exception. If this is
* Exception::warning, the exception will not be thown, instead it
* will be logged with the current * EventGenerator. If no current
* EventGenerator is present the warning * message is instead
* written to std::cerr. All other seveities will cause the
* exception to be thrown immediately.
*/
void operator<<(Exception::Severity sev) {
handled = true;
ex << sev;
if ( sev != Exception::warning && sev != Exception::info ) {
throw ex;
} else {
if ( CurrentGenerator::isVoid() ) {
Repository::clog() << ex.message() << endl;
ex.handle();
} else {
CurrentGenerator::current().logWarning(ex);
}
}
}
/**
* The destructor will throw the exception if it has not been handled.
*/
- ~Throw() {
+ ~Throw() throw (Ex) {
if ( !handled ) throw ex;
}
/**
* The ExceptionObject to be thrown.
*/
Ex ex;
/**
* If true, the exception has been handled and should not be thrown
* in the destructor.
*/
bool handled;
};
}
#endif /* ThePEG_Throw_H */
diff --git a/m4/boost.m4 b/m4/boost.m4
--- a/m4/boost.m4
+++ b/m4/boost.m4
@@ -1,1455 +1,1562 @@
# boost.m4: Locate Boost headers and libraries for autoconf-based projects.
# Copyright (C) 2007-2011, 2014 Benoit Sigoure <tsuna@lrde.epita.fr>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Additional permission under section 7 of the GNU General Public
# License, version 3 ("GPLv3"):
#
# If you convey this file as part of a work that contains a
# configuration script generated by Autoconf, you may do so under
# terms of your choice.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
m4_define([_BOOST_SERIAL], [m4_translit([
# serial 25
], [#
], [])])
# Original sources can be found at http://github.com/tsuna/boost.m4
# You can fetch the latest version of the script by doing:
# wget http://github.com/tsuna/boost.m4/raw/master/build-aux/boost.m4
# ------ #
# README #
# ------ #
# This file provides several macros to use the various Boost libraries.
# The first macro is BOOST_REQUIRE. It will simply check if it's possible to
# find the Boost headers of a given (optional) minimum version and it will
# define BOOST_CPPFLAGS accordingly. It will add an option --with-boost to
# your configure so that users can specify non standard locations.
# If the user's environment contains BOOST_ROOT and --with-boost was not
# specified, --with-boost=$BOOST_ROOT is implicitly used.
# For more README and documentation, go to http://github.com/tsuna/boost.m4
# Note: THESE MACROS ASSUME THAT YOU USE LIBTOOL. If you don't, don't worry,
# simply read the README, it will show you what to do step by step.
m4_pattern_forbid([^_?(BOOST|Boost)_])
# _BOOST_SED_CPP(SED-PROGRAM, PROGRAM,
# [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
# --------------------------------------------------------
# Same as AC_EGREP_CPP, but leave the result in conftest.i.
#
# SED-PROGRAM is *not* overquoted, as in AC_EGREP_CPP. It is expanded
# in double-quotes, so escape your double quotes.
#
# It could be useful to turn this into a macro which extracts the
# value of any macro.
m4_define([_BOOST_SED_CPP],
[AC_LANG_PUSH([C++])dnl
AC_LANG_PREPROC_REQUIRE()dnl
AC_REQUIRE([AC_PROG_SED])dnl
AC_LANG_CONFTEST([AC_LANG_SOURCE([[$2]])])
AS_IF([dnl eval is necessary to expand ac_cpp.
dnl Ultrix and Pyramid sh refuse to redirect output of eval, so use subshell.
dnl Beware of Windows end-of-lines, for instance if we are running
dnl some Windows programs under Wine. In that case, boost/version.hpp
dnl is certainly using "\r\n", but the regular Unix shell will only
dnl strip `\n' with backquotes, not the `\r'. This results in
dnl boost_cv_lib_version='1_37\r' for instance, which breaks
dnl everything else.
dnl Cannot use 'dnl' after [$4] because a trailing dnl may break AC_CACHE_CHECK
dnl
dnl Beware that GCC 5, when expanding macros, may embed # line directives
dnl a within single line:
dnl
dnl # 1 "conftest.cc"
dnl # 1 "<built-in>"
dnl # 1 "<command-line>"
dnl # 1 "conftest.cc"
dnl # 1 "/opt/local/include/boost/version.hpp" 1 3
dnl # 2 "conftest.cc" 2
dnl boost-lib-version =
dnl # 2 "conftest.cc" 3
dnl "1_56"
dnl
dnl So get rid of the # lines, and glue the remaining ones together.
(eval "$ac_cpp conftest.$ac_ext") 2>&AS_MESSAGE_LOG_FD |
grep -v '#' |
tr -d '\r' |
tr -s '\n' ' ' |
$SED -n -e "$1" >conftest.i 2>&1],
[$3],
[$4])
rm -rf conftest*
AC_LANG_POP([C++])dnl
])# _BOOST_SED_CPP
# BOOST_REQUIRE([VERSION], [ACTION-IF-NOT-FOUND])
# -----------------------------------------------
# Look for Boost. If version is given, it must either be a literal of the form
# "X.Y.Z" where X, Y and Z are integers (the ".Z" part being optional) or a
# variable "$var".
# Defines the value BOOST_CPPFLAGS. This macro only checks for headers with
# the required version, it does not check for any of the Boost libraries.
# On # success, defines HAVE_BOOST. On failure, calls the optional
# ACTION-IF-NOT-FOUND action if one was supplied.
# Otherwise aborts with an error message.
AC_DEFUN_ONCE([BOOST_REQUIRE],
[AC_REQUIRE([AC_PROG_CXX])dnl
AC_REQUIRE([AC_PROG_GREP])dnl
echo "$as_me: this is boost.m4[]_BOOST_SERIAL" >&AS_MESSAGE_LOG_FD
boost_save_IFS=$IFS
boost_version_req=$1
IFS=.
set x $boost_version_req 0 0 0
IFS=$boost_save_IFS
shift
boost_version_req=`expr "$[1]" '*' 100000 + "$[2]" '*' 100 + "$[3]"`
boost_version_req_string=$[1].$[2].$[3]
AC_ARG_WITH([boost],
[AS_HELP_STRING([--with-boost=DIR],
[prefix of Boost $1 @<:@guess@:>@])])dnl
AC_ARG_VAR([BOOST_ROOT],[Location of Boost installation])dnl
# If BOOST_ROOT is set and the user has not provided a value to
# --with-boost, then treat BOOST_ROOT as if it the user supplied it.
if test x"$BOOST_ROOT" != x; then
if test x"$with_boost" = x; then
AC_MSG_NOTICE([Detected BOOST_ROOT; continuing with --with-boost=$BOOST_ROOT])
with_boost=$BOOST_ROOT
else
AC_MSG_NOTICE([Detected BOOST_ROOT=$BOOST_ROOT, but overridden by --with-boost=$with_boost])
fi
fi
dnl AC_SUBST([DISTCHECK_CONFIGURE_FLAGS],
dnl ["$DISTCHECK_CONFIGURE_FLAGS '--with-boost=$with_boost'"])dnl
boost_save_CPPFLAGS=$CPPFLAGS
AC_CACHE_CHECK([for Boost headers version >= $boost_version_req_string],
[boost_cv_inc_path],
[boost_cv_inc_path=no
AC_LANG_PUSH([C++])dnl
m4_pattern_allow([^BOOST_VERSION$])dnl
AC_LANG_CONFTEST([AC_LANG_PROGRAM([[#include <boost/version.hpp>
#if !defined BOOST_VERSION
# error BOOST_VERSION is not defined
#elif BOOST_VERSION < $boost_version_req
# error Boost headers version < $boost_version_req
#endif
]])])
# If the user provided a value to --with-boost, use it and only it.
case $with_boost in #(
''|yes) set x '' /opt/local/include /usr/local/include /opt/include \
/usr/include C:/Boost/include;; #(
*) set x "$with_boost/include" "$with_boost";;
esac
shift
for boost_dir
do
# Without --layout=system, Boost (or at least some versions) installs
# itself in <prefix>/include/boost-<version>. This inner loop helps to
# find headers in such directories.
#
# Any ${boost_dir}/boost-x_xx directories are searched in reverse version
# order followed by ${boost_dir}. The final '.' is a sentinel for
# searching $boost_dir" itself. Entries are whitespace separated.
#
# I didn't indent this loop on purpose (to avoid over-indented code)
boost_layout_system_search_list=`cd "$boost_dir" 2>/dev/null \
&& ls -1 | "${GREP}" '^boost-' | sort -rn -t- -k2 \
&& echo .`
for boost_inc in $boost_layout_system_search_list
do
if test x"$boost_inc" != x.; then
boost_inc="$boost_dir/$boost_inc"
else
boost_inc="$boost_dir" # Uses sentinel in boost_layout_system_search_list
fi
if test x"$boost_inc" != x; then
# We are going to check whether the version of Boost installed
# in $boost_inc is usable by running a compilation that
# #includes it. But if we pass a -I/some/path in which Boost
# is not installed, the compiler will just skip this -I and
# use other locations (either from CPPFLAGS, or from its list
# of system include directories). As a result we would use
# header installed on the machine instead of the /some/path
# specified by the user. So in that precise case (trying
# $boost_inc), make sure the version.hpp exists.
#
# Use test -e as there can be symlinks.
test -e "$boost_inc/boost/version.hpp" || continue
CPPFLAGS="$CPPFLAGS -I$boost_inc"
fi
AC_COMPILE_IFELSE([], [boost_cv_inc_path=yes], [boost_cv_version=no])
if test x"$boost_cv_inc_path" = xyes; then
if test x"$boost_inc" != x; then
boost_cv_inc_path=$boost_inc
fi
break 2
fi
done
done
AC_LANG_POP([C++])dnl
])
case $boost_cv_inc_path in #(
no)
boost_errmsg="cannot find Boost headers version >= $boost_version_req_string"
m4_if([$2], [], [AC_MSG_ERROR([$boost_errmsg])],
[AC_MSG_NOTICE([$boost_errmsg])])
$2
;;#(
yes)
BOOST_CPPFLAGS=
;;#(
*)
AC_SUBST([BOOST_CPPFLAGS], ["-I$boost_cv_inc_path"])dnl
;;
esac
if test x"$boost_cv_inc_path" != xno; then
AC_DEFINE([HAVE_BOOST], [1],
[Defined if the requested minimum BOOST version is satisfied])
AC_CACHE_CHECK([for Boost's header version],
[boost_cv_lib_version],
[m4_pattern_allow([^BOOST_LIB_VERSION$])dnl
_BOOST_SED_CPP([[/^boost-lib-version = /{s///;s/[\" ]//g;p;q;}]],
[#include <boost/version.hpp>
boost-lib-version = BOOST_LIB_VERSION],
[boost_cv_lib_version=`cat conftest.i`])])
# e.g. "134" for 1_34_1 or "135" for 1_35
boost_major_version=`echo "$boost_cv_lib_version" | sed 's/_//;s/_.*//'`
case $boost_major_version in #(
'' | *[[!0-9]]*)
AC_MSG_ERROR([invalid value: boost_major_version='$boost_major_version'])
;;
esac
fi
CPPFLAGS=$boost_save_CPPFLAGS
])# BOOST_REQUIRE
# BOOST_STATIC()
# --------------
# Add the "--enable-static-boost" configure argument. If this argument is given
# on the command line, static versions of the libraries will be looked up.
AC_DEFUN([BOOST_STATIC],
[AC_ARG_ENABLE([static-boost],
[AS_HELP_STRING([--enable-static-boost],
[Prefer the static boost libraries over the shared ones [no]])],
[enable_static_boost=yes],
[enable_static_boost=no])])# BOOST_STATIC
# BOOST_FIND_HEADER([HEADER-NAME], [ACTION-IF-NOT-FOUND], [ACTION-IF-FOUND])
# --------------------------------------------------------------------------
# Wrapper around AC_CHECK_HEADER for Boost headers. Useful to check for
# some parts of the Boost library which are only made of headers and don't
# require linking (such as Boost.Foreach).
#
# Default ACTION-IF-NOT-FOUND: Fail with a fatal error unless Boost couldn't be
# found in the first place, in which case by default a notice is issued to the
# user. Presumably if we haven't died already it's because it's OK to not have
# Boost, which is why only a notice is issued instead of a hard error.
#
# Default ACTION-IF-FOUND: define the preprocessor symbol HAVE_<HEADER-NAME> in
# case of success # (where HEADER-NAME is written LIKE_THIS, e.g.,
# HAVE_BOOST_FOREACH_HPP).
AC_DEFUN([BOOST_FIND_HEADER],
[AC_REQUIRE([BOOST_REQUIRE])dnl
if test x"$boost_cv_inc_path" = xno; then
m4_default([$2], [AC_MSG_NOTICE([Boost not available, not searching for $1])])
else
AC_LANG_PUSH([C++])dnl
boost_save_CPPFLAGS=$CPPFLAGS
CPPFLAGS="$CPPFLAGS $BOOST_CPPFLAGS"
AC_CHECK_HEADER([$1],
[m4_default([$3], [AC_DEFINE(AS_TR_CPP([HAVE_$1]), [1],
[Define to 1 if you have <$1>])])],
[m4_default([$2], [AC_MSG_ERROR([cannot find $1])])])
CPPFLAGS=$boost_save_CPPFLAGS
AC_LANG_POP([C++])dnl
fi
])# BOOST_FIND_HEADER
# BOOST_FIND_LIBS([COMPONENT-NAME], [CANDIDATE-LIB-NAMES],
# [PREFERRED-RT-OPT], [HEADER-NAME], [CXX-TEST],
# [CXX-PROLOGUE])
# --------------------------------------------------------------
# Look for the Boost library COMPONENT-NAME (e.g., `thread', for
# libboost_thread) under the possible CANDIDATE-LIB-NAMES (e.g.,
# "thread_win32 thread"). Check that HEADER-NAME works and check that
# libboost_LIB-NAME can link with the code CXX-TEST. The optional
# argument CXX-PROLOGUE can be used to include some C++ code before
# the `main' function.
#
# Invokes BOOST_FIND_HEADER([HEADER-NAME]) (see above).
#
# Boost libraries typically come compiled with several flavors (with different
# runtime options) so PREFERRED-RT-OPT is the preferred suffix. A suffix is one
# or more of the following letters: sgdpn (in that order). s = static
# runtime, d = debug build, g = debug/diagnostic runtime, p = STLPort build,
# n = (unsure) STLPort build without iostreams from STLPort (it looks like `n'
# must always be used along with `p'). Additionally, PREFERRED-RT-OPT can
# start with `mt-' to indicate that there is a preference for multi-thread
# builds. Some sample values for PREFERRED-RT-OPT: (nothing), mt, d, mt-d, gdp
# ... If you want to make sure you have a specific version of Boost
# (eg, >= 1.33) you *must* invoke BOOST_REQUIRE before this macro.
AC_DEFUN([BOOST_FIND_LIBS],
[AC_REQUIRE([BOOST_REQUIRE])dnl
AC_REQUIRE([_BOOST_FIND_COMPILER_TAG])dnl
AC_REQUIRE([BOOST_STATIC])dnl
AC_REQUIRE([_BOOST_GUESS_WHETHER_TO_USE_MT])dnl
if test x"$boost_cv_inc_path" = xno; then
AC_MSG_NOTICE([Boost not available, not searching for the Boost $1 library])
else
dnl The else branch is huge and wasn't intended on purpose.
AC_LANG_PUSH([C++])dnl
AS_VAR_PUSHDEF([Boost_lib], [boost_cv_lib_$1])dnl
AS_VAR_PUSHDEF([Boost_lib_LDFLAGS], [boost_cv_lib_$1_LDFLAGS])dnl
AS_VAR_PUSHDEF([Boost_lib_LDPATH], [boost_cv_lib_$1_LDPATH])dnl
AS_VAR_PUSHDEF([Boost_lib_LIBS], [boost_cv_lib_$1_LIBS])dnl
BOOST_FIND_HEADER([$4])
boost_save_CPPFLAGS=$CPPFLAGS
CPPFLAGS="$CPPFLAGS $BOOST_CPPFLAGS"
AC_CACHE_CHECK([for the Boost $1 library], [Boost_lib],
[_BOOST_FIND_LIBS($@)])
case $Boost_lib in #(
(no) _AC_MSG_LOG_CONFTEST
AC_MSG_ERROR([cannot find the flags to link with Boost $1])
;;
esac
AC_SUBST(AS_TR_CPP([BOOST_$1_LDFLAGS]), [$Boost_lib_LDFLAGS])dnl
AC_SUBST(AS_TR_CPP([BOOST_$1_LDPATH]), [$Boost_lib_LDPATH])dnl
AC_SUBST([BOOST_LDPATH], [$Boost_lib_LDPATH])dnl
AC_SUBST(AS_TR_CPP([BOOST_$1_LIBS]), [$Boost_lib_LIBS])dnl
CPPFLAGS=$boost_save_CPPFLAGS
AS_VAR_POPDEF([Boost_lib])dnl
AS_VAR_POPDEF([Boost_lib_LDFLAGS])dnl
AS_VAR_POPDEF([Boost_lib_LDPATH])dnl
AS_VAR_POPDEF([Boost_lib_LIBS])dnl
AC_LANG_POP([C++])dnl
fi
])
# BOOST_FIND_LIB([LIB-NAME],
# [PREFERRED-RT-OPT], [HEADER-NAME], [CXX-TEST],
# [CXX-PROLOGUE])
# --------------------------------------------------------------
# Backward compatibility wrapper for BOOST_FIND_LIBS.
AC_DEFUN([BOOST_FIND_LIB],
[BOOST_FIND_LIBS([$1], $@)])
# _BOOST_FIND_LIBS([LIB-NAME], [CANDIDATE-LIB-NAMES],
# [PREFERRED-RT-OPT], [HEADER-NAME], [CXX-TEST],
# [CXX-PROLOGUE])
# --------------------------------------------------------------
# Real implementation of BOOST_FIND_LIBS: rely on these local macros:
# Boost_lib, Boost_lib_LDFLAGS, Boost_lib_LDPATH, Boost_lib_LIBS
#
# The algorithm is as follows: first look for a given library name
# according to the user's PREFERRED-RT-OPT. For each library name, we
# prefer to use the ones that carry the tag (toolset name). Each
# library is searched through the various standard paths were Boost is
# usually installed. If we can't find the standard variants, we try
# to enforce -mt (for instance on MacOSX, libboost_thread.dylib
# doesn't exist but there's -obviously- libboost_thread-mt.dylib).
AC_DEFUN([_BOOST_FIND_LIBS],
[Boost_lib=no
case "$3" in #(
(mt | mt-) boost_mt=-mt; boost_rtopt=;; #(
(mt* | mt-*) boost_mt=-mt; boost_rtopt=`expr "X$3" : 'Xmt-*\(.*\)'`;; #(
(*) boost_mt=; boost_rtopt=$3;;
esac
if test $enable_static_boost = yes; then
boost_rtopt="s$boost_rtopt"
fi
# Find the proper debug variant depending on what we've been asked to find.
case $boost_rtopt in #(
(*d*) boost_rt_d=$boost_rtopt;; #(
(*[[sgpn]]*) # Insert the `d' at the right place (in between `sg' and `pn')
boost_rt_d=`echo "$boost_rtopt" | sed 's/\(s*g*\)\(p*n*\)/\1\2/'`;; #(
(*) boost_rt_d='-d';;
esac
# If the PREFERRED-RT-OPT are not empty, prepend a `-'.
test -n "$boost_rtopt" && boost_rtopt="-$boost_rtopt"
$boost_guess_use_mt && boost_mt=-mt
# Look for the abs path the static archive.
# $libext is computed by Libtool but let's make sure it's non empty.
test -z "$libext" &&
AC_MSG_ERROR([the libext variable is empty, did you invoke Libtool?])
boost_save_ac_objext=$ac_objext
# Generate the test file.
AC_LANG_CONFTEST([AC_LANG_PROGRAM([#include <$4>
$6], [$5])])
dnl Optimization hacks: compiling C++ is slow, especially with Boost. What
dnl we're trying to do here is guess the right combination of link flags
dnl (LIBS / LDFLAGS) to use a given library. This can take several
dnl iterations before it succeeds and is thus *very* slow. So what we do
dnl instead is that we compile the code first (and thus get an object file,
dnl typically conftest.o). Then we try various combinations of link flags
dnl until we succeed to link conftest.o in an executable. The problem is
dnl that the various TRY_LINK / COMPILE_IFELSE macros of Autoconf always
dnl remove all the temporary files including conftest.o. So the trick here
dnl is to temporarily change the value of ac_objext so that conftest.o is
dnl preserved accross tests. This is obviously fragile and I will burn in
dnl hell for not respecting Autoconf's documented interfaces, but in the
dnl mean time, it optimizes the macro by a factor of 5 to 30.
dnl Another small optimization: the first argument of AC_COMPILE_IFELSE left
dnl empty because the test file is generated only once above (before we
dnl start the for loops).
AC_COMPILE_IFELSE([],
[ac_objext=do_not_rm_me_plz],
[AC_MSG_ERROR([cannot compile a test that uses Boost $1])])
ac_objext=$boost_save_ac_objext
boost_failed_libs=
# Don't bother to ident the following nested for loops, only the 2
# innermost ones matter.
for boost_lib_ in $2; do
for boost_tag_ in -$boost_cv_lib_tag ''; do
for boost_ver_ in -$boost_cv_lib_version ''; do
for boost_mt_ in $boost_mt -mt ''; do
for boost_rtopt_ in $boost_rtopt '' -d; do
for boost_lib in \
boost_$boost_lib_$boost_tag_$boost_mt_$boost_rtopt_$boost_ver_ \
boost_$boost_lib_$boost_tag_$boost_rtopt_$boost_ver_ \
boost_$boost_lib_$boost_tag_$boost_mt_$boost_ver_ \
boost_$boost_lib_$boost_tag_$boost_ver_
do
# Avoid testing twice the same lib
case $boost_failed_libs in #(
(*@$boost_lib@*) continue;;
esac
# If with_boost is empty, we'll search in /lib first, which is not quite
# right so instead we'll try to a location based on where the headers are.
boost_tmp_lib=$with_boost
test x"$with_boost" = x && boost_tmp_lib=${boost_cv_inc_path%/include}
for boost_ldpath in "$boost_tmp_lib/lib" '' \
/opt/local/lib* /usr/local/lib* /opt/lib* /usr/lib* \
"$with_boost" C:/Boost/lib /lib*
do
# Don't waste time with directories that don't exist.
if test x"$boost_ldpath" != x && test ! -e "$boost_ldpath"; then
continue
fi
boost_save_LDFLAGS=$LDFLAGS
# Are we looking for a static library?
case $boost_ldpath:$boost_rtopt_ in #(
(*?*:*s*) # Yes (Non empty boost_ldpath + s in rt opt)
Boost_lib_LIBS="$boost_ldpath/lib$boost_lib.$libext"
test -e "$Boost_lib_LIBS" || continue;; #(
(*) # No: use -lboost_foo to find the shared library.
Boost_lib_LIBS="-l$boost_lib";;
esac
boost_save_LIBS=$LIBS
LIBS="$Boost_lib_LIBS $LIBS"
test x"$boost_ldpath" != x && LDFLAGS="$LDFLAGS -L$boost_ldpath"
dnl First argument of AC_LINK_IFELSE left empty because the test file is
dnl generated only once above (before we start the for loops).
_BOOST_AC_LINK_IFELSE([],
[Boost_lib=yes], [Boost_lib=no])
ac_objext=$boost_save_ac_objext
LDFLAGS=$boost_save_LDFLAGS
LIBS=$boost_save_LIBS
if test x"$Boost_lib" = xyes; then
# Check or used cached result of whether or not using -R or
# -rpath makes sense. Some implementations of ld, such as for
# Mac OSX, require -rpath but -R is the flag known to work on
# other systems. https://github.com/tsuna/boost.m4/issues/19
AC_CACHE_VAL([boost_cv_rpath_link_ldflag],
[case $boost_ldpath in
'') # Nothing to do.
boost_cv_rpath_link_ldflag=
boost_rpath_link_ldflag_found=yes;;
*)
for boost_cv_rpath_link_ldflag in -Wl,-R, -Wl,-rpath,; do
LDFLAGS="$boost_save_LDFLAGS -L$boost_ldpath $boost_cv_rpath_link_ldflag$boost_ldpath"
LIBS="$boost_save_LIBS $Boost_lib_LIBS"
_BOOST_AC_LINK_IFELSE([],
[boost_rpath_link_ldflag_found=yes
break],
[boost_rpath_link_ldflag_found=no])
done
;;
esac
AS_IF([test "x$boost_rpath_link_ldflag_found" != "xyes"],
[AC_MSG_ERROR([Unable to determine whether to use -R or -rpath])])
LDFLAGS=$boost_save_LDFLAGS
LIBS=$boost_save_LIBS
])
test x"$boost_ldpath" != x &&
Boost_lib_LDFLAGS="-L$boost_ldpath $boost_cv_rpath_link_ldflag$boost_ldpath"
Boost_lib_LDPATH="$boost_ldpath"
break 7
else
boost_failed_libs="$boost_failed_libs@$boost_lib@"
fi
done
done
done
done
done
done
done # boost_lib_
rm -f conftest.$ac_objext
])
# --------------------------------------- #
# Checks for the various Boost libraries. #
# --------------------------------------- #
# List of boost libraries: http://www.boost.org/libs/libraries.htm
# The page http://beta.boost.org/doc/libs is useful: it gives the first release
# version of each library (among other things).
# BOOST_DEFUN(LIBRARY, CODE)
# --------------------------
# Define BOOST_<LIBRARY-UPPERCASE> as a macro that runs CODE.
#
# Use indir to avoid the warning on underquoted macro name given to AC_DEFUN.
m4_define([BOOST_DEFUN],
[m4_indir([AC_DEFUN],
m4_toupper([BOOST_$1]),
[m4_pushdef([BOOST_Library], [$1])dnl
$2
m4_popdef([BOOST_Library])dnl
])
])
# BOOST_ARRAY()
# -------------
# Look for Boost.Array
BOOST_DEFUN([Array],
[BOOST_FIND_HEADER([boost/array.hpp])])
# BOOST_ASIO()
# ------------
# Look for Boost.Asio (new in Boost 1.35).
BOOST_DEFUN([Asio],
[AC_REQUIRE([BOOST_SYSTEM])dnl
BOOST_FIND_HEADER([boost/asio.hpp])])
# BOOST_BIND()
# ------------
# Look for Boost.Bind.
BOOST_DEFUN([Bind],
[BOOST_FIND_HEADER([boost/bind.hpp])])
# BOOST_CHRONO()
# --------------
# Look for Boost.Chrono.
BOOST_DEFUN([Chrono],
[# Do we have to check for Boost.System? This link-time dependency was
# added as of 1.35.0. If we have a version <1.35, we must not attempt to
# find Boost.System as it didn't exist by then.
if test $boost_major_version -ge 135; then
BOOST_SYSTEM([$1])
fi # end of the Boost.System check.
boost_filesystem_save_LIBS=$LIBS
boost_filesystem_save_LDFLAGS=$LDFLAGS
m4_pattern_allow([^BOOST_SYSTEM_(LIBS|LDFLAGS)$])dnl
LIBS="$LIBS $BOOST_SYSTEM_LIBS"
LDFLAGS="$LDFLAGS $BOOST_SYSTEM_LDFLAGS"
BOOST_FIND_LIB([chrono], [$1],
[boost/chrono.hpp],
[boost::chrono::thread_clock d;])
if test $enable_static_boost = yes && test $boost_major_version -ge 135; then
BOOST_CHRONO_LIBS="$BOOST_CHRONO_LIBS $BOOST_SYSTEM_LIBS"
fi
LIBS=$boost_filesystem_save_LIBS
LDFLAGS=$boost_filesystem_save_LDFLAGS
])# BOOST_CHRONO
# BOOST_CONTEXT([PREFERRED-RT-OPT])
# -----------------------------------
# Look for Boost.Context. For the documentation of PREFERRED-RT-OPT, see the
-# documentation of BOOST_FIND_LIB above. This library was introduced in Boost
-# 1.51.0
+# documentation of BOOST_FIND_LIB above.
+#
+# * This library was introduced in Boost 1.51.0
+# * The signatures of make_fcontext() and jump_fcontext were changed in 1.56.0
+# * A dependency on boost_thread appears in 1.57.0
BOOST_DEFUN([Context],
-[BOOST_FIND_LIB([context], [$1],
+[boost_context_save_LIBS=$LIBS
+ boost_context_save_LDFLAGS=$LDFLAGS
+if test $boost_major_version -ge 157; then
+ BOOST_THREAD([$1])
+ m4_pattern_allow([^BOOST_THREAD_(LIBS|LDFLAGS)$])dnl
+ LIBS="$LIBS $BOOST_THREAD_LIBS"
+ LDFLAGS="$LDFLAGS $BOOST_THREAD_LDFLAGS"
+fi
+BOOST_FIND_LIB([context], [$1],
[boost/context/all.hpp],[[
+
// creates a stack
void * stack_pointer = new void*[4096];
std::size_t const size = sizeof(void*[4096]);
-// context fc uses f() as context function
-// fcontext_t is placed on top of context stack
-// a pointer to fcontext_t is returned
+#if BOOST_VERSION <= 105100
+ctx::make_fcontext(&fc, f);
+return ctx::jump_fcontext(&fcm, &fc, 3) == 6;
+
+#else
+
fc = ctx::make_fcontext(stack_pointer, size, f);
-return ctx::jump_fcontext(&fcm, fc, 3) == 6;]],[dnl
+return ctx::jump_fcontext(&fcm, fc, 3) == 6;
+
+#endif
+
+
+]],[dnl
+
+#include <boost/version.hpp>
+#if BOOST_VERSION <= 105100
+
+namespace ctx = boost::ctx;
+
+static ctx::fcontext_t fcm, fc;
+
+static void f(intptr_t i) {
+ ctx::jump_fcontext(&fc, &fcm, i * 2);
+}
+
+#elif BOOST_VERSION <= 105500
+
namespace ctx = boost::context;
+
// context
static ctx::fcontext_t fcm, *fc;
+
// context-function
static void f(intptr_t i) {
ctx::jump_fcontext(fc, &fcm, i * 2);
-}])
+}
+
+#else
+
+namespace ctx = boost::context;
+
+// context
+static ctx::fcontext_t fcm, fc;
+
+// context-function
+static void f(intptr_t i) {
+ ctx::jump_fcontext(&fc, fcm, i * 2);
+}
+#endif
+])
+LIBS=$boost_context_save_LIBS
+LDFLAGS=$boost_context_save_LDFLAGS
])# BOOST_CONTEXT
# BOOST_CONVERSION()
# ------------------
# Look for Boost.Conversion (cast / lexical_cast)
BOOST_DEFUN([Conversion],
[BOOST_FIND_HEADER([boost/cast.hpp])
BOOST_FIND_HEADER([boost/lexical_cast.hpp])
])# BOOST_CONVERSION
# BOOST_COROUTINE([PREFERRED-RT-OPT])
# -----------------------------------
# Look for Boost.Coroutine. For the documentation of PREFERRED-RT-OPT, see the
# documentation of BOOST_FIND_LIB above. This library was introduced in Boost
# 1.53.0
BOOST_DEFUN([Coroutine],
[
boost_coroutine_save_LIBS=$LIBS
boost_coroutine_save_LDFLAGS=$LDFLAGS
# Link-time dependency from coroutine to context
BOOST_CONTEXT([$1])
# Starting from Boost 1.55 a dependency on Boost.System is added
if test $boost_major_version -ge 155; then
BOOST_SYSTEM([$1])
fi
m4_pattern_allow([^BOOST_(CONTEXT|SYSTEM)_(LIBS|LDFLAGS)])
LIBS="$LIBS $BOOST_CONTEXT_LIBS $BOOST_SYSTEM_LIBS"
LDFLAGS="$LDFLAGS $BOOST_CONTEXT_LDFLAGS"
-BOOST_FIND_LIB([coroutine], [$1],
- [boost/coroutine/coroutine.hpp],
- [boost::coroutines::coroutine< int(int) > coro; coro.empty();])
-
+# in 1.53 coroutine was a header only library
+if test $boost_major_version -eq 153; then
+ BOOST_FIND_HEADER([boost/coroutine/coroutine.hpp])
+else
+ BOOST_FIND_LIB([coroutine], [$1],
+ [boost/coroutine/coroutine.hpp],
+ [
+ #include <boost/version.hpp>
+ #if BOOST_VERSION <= 105500
+ boost::coroutines::coroutine<int(int)> coro; coro.get();
+ #else
+ boost::coroutines::asymmetric_coroutine<int>::pull_type coro; coro.get();
+ #endif
+ ])
+fi
# Link-time dependency from coroutine to context, existed only in 1.53, in 1.54
# coroutine doesn't use context from its headers but from its library.
if test $boost_major_version -eq 153 || test $enable_static_boost = yes && test $boost_major_version -ge 154; then
BOOST_COROUTINE_LIBS="$BOOST_COROUTINE_LIBS $BOOST_CONTEXT_LIBS"
BOOST_COROUTINE_LDFLAGS="$BOOST_COROUTINE_LDFLAGS $BOOST_CONTEXT_LDFLAGS"
fi
if test $enable_static_boost = yes && test $boost_major_version -ge 155; then
BOOST_COROUTINE_LIBS="$BOOST_COROUTINE_LIBS $BOOST_SYSTEM_LIBS"
BOOST_COROUTINE_LDFLAGS="$BOOST_COROUTINE_LDFLAGS $BOOST_SYSTEM_LDFLAGS"
fi
LIBS=$boost_coroutine_save_LIBS
LDFLAGS=$boost_coroutine_save_LDFLAGS
])# BOOST_COROUTINE
# BOOST_CRC()
# -----------
# Look for Boost.CRC
BOOST_DEFUN([CRC],
[BOOST_FIND_HEADER([boost/crc.hpp])
])# BOOST_CRC
# BOOST_DATE_TIME([PREFERRED-RT-OPT])
# -----------------------------------
# Look for Boost.Date_Time. For the documentation of PREFERRED-RT-OPT, see the
# documentation of BOOST_FIND_LIB above.
BOOST_DEFUN([Date_Time],
[BOOST_FIND_LIB([date_time], [$1],
[boost/date_time/posix_time/posix_time.hpp],
[boost::posix_time::ptime t;])
])# BOOST_DATE_TIME
# BOOST_FILESYSTEM([PREFERRED-RT-OPT])
# ------------------------------------
# Look for Boost.Filesystem. For the documentation of PREFERRED-RT-OPT, see
# the documentation of BOOST_FIND_LIB above.
# Do not check for boost/filesystem.hpp because this file was introduced in
# 1.34.
BOOST_DEFUN([Filesystem],
[# Do we have to check for Boost.System? This link-time dependency was
# added as of 1.35.0. If we have a version <1.35, we must not attempt to
# find Boost.System as it didn't exist by then.
if test $boost_major_version -ge 135; then
BOOST_SYSTEM([$1])
fi # end of the Boost.System check.
boost_filesystem_save_LIBS=$LIBS
boost_filesystem_save_LDFLAGS=$LDFLAGS
m4_pattern_allow([^BOOST_SYSTEM_(LIBS|LDFLAGS)$])dnl
LIBS="$LIBS $BOOST_SYSTEM_LIBS"
LDFLAGS="$LDFLAGS $BOOST_SYSTEM_LDFLAGS"
BOOST_FIND_LIB([filesystem], [$1],
[boost/filesystem/path.hpp], [boost::filesystem::path p;])
if test $enable_static_boost = yes && test $boost_major_version -ge 135; then
BOOST_FILESYSTEM_LIBS="$BOOST_FILESYSTEM_LIBS $BOOST_SYSTEM_LIBS"
fi
LIBS=$boost_filesystem_save_LIBS
LDFLAGS=$boost_filesystem_save_LDFLAGS
])# BOOST_FILESYSTEM
# BOOST_FLYWEIGHT()
# -----------------
# Look for Boost.Flyweight.
BOOST_DEFUN([Flyweight],
[dnl There's a hidden dependency on pthreads.
AC_REQUIRE([_BOOST_PTHREAD_FLAG])dnl
BOOST_FIND_HEADER([boost/flyweight.hpp])
AC_SUBST([BOOST_FLYWEIGHT_LIBS], [$boost_cv_pthread_flag])
])
# BOOST_FOREACH()
# ---------------
# Look for Boost.Foreach.
BOOST_DEFUN([Foreach],
[BOOST_FIND_HEADER([boost/foreach.hpp])])
# BOOST_FORMAT()
# --------------
# Look for Boost.Format.
# Note: we can't check for boost/format/format_fwd.hpp because the header isn't
# standalone. It can't be compiled because it triggers the following error:
# boost/format/detail/config_macros.hpp:88: error: 'locale' in namespace 'std'
# does not name a type
BOOST_DEFUN([Format],
[BOOST_FIND_HEADER([boost/format.hpp])])
# BOOST_FUNCTION()
# ----------------
# Look for Boost.Function
BOOST_DEFUN([Function],
[BOOST_FIND_HEADER([boost/function.hpp])])
# BOOST_GEOMETRY()
# ----------------
# Look for Boost.Geometry (new since 1.47.0).
BOOST_DEFUN([Geometry],
[BOOST_FIND_HEADER([boost/geometry.hpp])
])# BOOST_GEOMETRY
# BOOST_GRAPH([PREFERRED-RT-OPT])
# -------------------------------
# Look for Boost.Graphs. For the documentation of PREFERRED-RT-OPT, see the
# documentation of BOOST_FIND_LIB above.
BOOST_DEFUN([Graph],
-[BOOST_FIND_LIB([graph], [$1],
+[boost_graph_save_LIBS=$LIBS
+boost_graph_save_LDFLAGS=$LDFLAGS
+# Link-time dependency from graph to regex was added as of 1.40.0.
+if test $boost_major_version -ge 140; then
+ BOOST_REGEX([$1])
+ m4_pattern_allow([^BOOST_REGEX_(LIBS|LDFLAGS)$])dnl
+ LIBS="$LIBS $BOOST_REGEX_LIBS"
+ LDFLAGS="$LDFLAGS $BOOST_REGEX_LDFLAGS"
+fi
+BOOST_FIND_LIB([graph], [$1],
[boost/graph/adjacency_list.hpp], [boost::adjacency_list<> g;])
+LIBS=$boost_graph_save_LIBS
+LDFLAGS=$boost_graph_save_LDFLAGS
])# BOOST_GRAPH
# BOOST_IOSTREAMS([PREFERRED-RT-OPT])
# -----------------------------------
# Look for Boost.IOStreams. For the documentation of PREFERRED-RT-OPT, see the
# documentation of BOOST_FIND_LIB above.
BOOST_DEFUN([IOStreams],
[BOOST_FIND_LIB([iostreams], [$1],
[boost/iostreams/device/file_descriptor.hpp],
[boost::iostreams::file_descriptor fd; fd.close();])
])# BOOST_IOSTREAMS
# BOOST_HASH()
# ------------
# Look for Boost.Functional/Hash
BOOST_DEFUN([Hash],
[BOOST_FIND_HEADER([boost/functional/hash.hpp])])
# BOOST_LAMBDA()
# --------------
# Look for Boost.Lambda
BOOST_DEFUN([Lambda],
[BOOST_FIND_HEADER([boost/lambda/lambda.hpp])])
# BOOST_LOCALE()
# --------------
# Look for Boost.Locale
BOOST_DEFUN([Locale],
-[BOOST_FIND_LIB([locale], [$1],
+[
+boost_locale_save_LIBS=$LIBS
+boost_locale_save_LDFLAGS=$LDFLAGS
+# require SYSTEM for boost-1.50.0 and up
+if test $boost_major_version -ge 150; then
+ BOOST_SYSTEM([$1])
+ m4_pattern_allow([^BOOST_SYSTEM_(LIBS|LDFLAGS)$])dnl
+ LIBS="$LIBS $BOOST_SYSTEM_LIBS"
+ LDFLAGS="$LDFLAGS $BOOST_SYSTEM_LDFLAGS"
+fi # end of the Boost.System check.
+BOOST_FIND_LIB([locale], [$1],
[boost/locale.hpp],
[[boost::locale::generator gen; std::locale::global(gen(""));]])
+LIBS=$boost_locale_save_LIBS
+LDFLAGS=$boost_locale_save_LDFLAGS
])# BOOST_LOCALE
# BOOST_LOG([PREFERRED-RT-OPT])
# -----------------------------
# Look for Boost.Log. For the documentation of PREFERRED-RT-OPT, see the
# documentation of BOOST_FIND_LIB above.
BOOST_DEFUN([Log],
-[BOOST_FIND_LIB([log], [$1],
+[boost_log_save_LIBS=$LIBS
+boost_log_save_LDFLAGS=$LDFLAGS
+BOOST_SYSTEM([$1])
+BOOST_FILESYSTEM([$1])
+BOOST_DATE_TIME([$1])
+m4_pattern_allow([^BOOST_(SYSTEM|FILESYSTEM|DATE_TIME)_(LIBS|LDFLAGS)$])dnl
+LIBS="$LIBS $BOOST_DATE_TIME_LIBS $BOOST_FILESYSTEM_LIBS $BOOST_SYSTEM_LIBS"
+LDFLAGS="$LDFLAGS $BOOST_DATE_TIME_LDFLAGS $BOOST_FILESYSTEM_LDFLAGS $BOOST_SYSTEM_LDFLAGS"
+BOOST_FIND_LIB([log], [$1],
[boost/log/core/core.hpp],
[boost::log::attribute a; a.get_value();])
+LIBS=$boost_log_save_LIBS
+LDFLAGS=$boost_log_save_LDFLAGS
])# BOOST_LOG
# BOOST_LOG_SETUP([PREFERRED-RT-OPT])
# -----------------------------------
# Look for Boost.Log. For the documentation of PREFERRED-RT-OPT, see the
# documentation of BOOST_FIND_LIB above.
BOOST_DEFUN([Log_Setup],
-[AC_REQUIRE([BOOST_LOG])dnl
+[boost_log_setup_save_LIBS=$LIBS
+boost_log_setup_save_LDFLAGS=$LDFLAGS
+BOOST_LOG([$1])
+m4_pattern_allow([^BOOST_LOG_(LIBS|LDFLAGS)$])dnl
+LIBS="$LIBS $BOOST_LOG_LIBS"
+LDFLAGS="$LDFLAGS $BOOST_LOG_LDFLAGS"
BOOST_FIND_LIB([log_setup], [$1],
[boost/log/utility/setup/from_settings.hpp],
[boost::log::basic_settings<char> bs; bs.empty();])
+LIBS=$boost_log_setup_save_LIBS
+LDFLAGS=$boost_log_setup_save_LDFLAGS
])# BOOST_LOG_SETUP
# BOOST_MATH()
# ------------
# Look for Boost.Math
# TODO: This library isn't header-only but it comes in multiple different
# flavors that don't play well with BOOST_FIND_LIB (e.g, libboost_math_c99,
# libboost_math_c99f, libboost_math_c99l, libboost_math_tr1,
# libboost_math_tr1f, libboost_math_tr1l). This macro must be fixed to do the
# right thing anyway.
BOOST_DEFUN([Math],
[BOOST_FIND_HEADER([boost/math/special_functions.hpp])])
# BOOST_MPI([PREFERRED-RT-OPT])
# -------------------------------
# Look for Boost MPI. For the documentation of PREFERRED-RT-OPT, see the
# documentation of BOOST_FIND_LIB above. Uses MPICXX variable if it is
# set, otherwise tries CXX
#
BOOST_DEFUN([MPI],
[boost_save_CXX=${CXX}
boost_save_CXXCPP=${CXXCPP}
if test x"${MPICXX}" != x; then
CXX=${MPICXX}
CXXCPP="${MPICXX} -E"
fi
BOOST_FIND_LIB([mpi], [$1],
[boost/mpi.hpp],
[int argc = 0;
char **argv = 0;
boost::mpi::environment env(argc,argv);])
CXX=${boost_save_CXX}
CXXCPP=${boost_save_CXXCPP}
])# BOOST_MPI
# BOOST_MULTIARRAY()
# ------------------
# Look for Boost.MultiArray
BOOST_DEFUN([MultiArray],
[BOOST_FIND_HEADER([boost/multi_array.hpp])])
# BOOST_NUMERIC_UBLAS()
# --------------------------
# Look for Boost.NumericUblas (Basic Linear Algebra)
BOOST_DEFUN([Numeric_Ublas],
[BOOST_FIND_HEADER([boost/numeric/ublas/vector.hpp])
])# BOOST_NUMERIC_UBLAS
# BOOST_NUMERIC_CONVERSION()
# --------------------------
# Look for Boost.NumericConversion (policy-based numeric conversion)
BOOST_DEFUN([Numeric_Conversion],
[BOOST_FIND_HEADER([boost/numeric/conversion/converter.hpp])
])# BOOST_NUMERIC_CONVERSION
# BOOST_OPTIONAL()
# ----------------
# Look for Boost.Optional
BOOST_DEFUN([Optional],
[BOOST_FIND_HEADER([boost/optional.hpp])])
# BOOST_PREPROCESSOR()
# --------------------
# Look for Boost.Preprocessor
BOOST_DEFUN([Preprocessor],
[BOOST_FIND_HEADER([boost/preprocessor/repeat.hpp])])
# BOOST_RANGE()
# --------------------
# Look for Boost.Range
BOOST_DEFUN([Range],
[BOOST_FIND_HEADER([boost/range/adaptors.hpp])])
# BOOST_UNORDERED()
# -----------------
# Look for Boost.Unordered
BOOST_DEFUN([Unordered],
[BOOST_FIND_HEADER([boost/unordered_map.hpp])])
# BOOST_UUID()
# ------------
# Look for Boost.Uuid
BOOST_DEFUN([Uuid],
[BOOST_FIND_HEADER([boost/uuid/uuid.hpp])])
# BOOST_PROGRAM_OPTIONS([PREFERRED-RT-OPT])
# -----------------------------------------
# Look for Boost.Program_options. For the documentation of PREFERRED-RT-OPT,
# see the documentation of BOOST_FIND_LIB above.
BOOST_DEFUN([Program_Options],
[BOOST_FIND_LIB([program_options], [$1],
[boost/program_options.hpp],
[boost::program_options::options_description d("test");])
])# BOOST_PROGRAM_OPTIONS
# _BOOST_PYTHON_CONFIG(VARIABLE, FLAG)
# ------------------------------------
# Save VARIABLE, and define it via `python-config --FLAG`.
# Substitute BOOST_PYTHON_VARIABLE.
m4_define([_BOOST_PYTHON_CONFIG],
[AC_SUBST([BOOST_PYTHON_$1],
[`python-config --$2 2>/dev/null`])dnl
boost_python_save_$1=$$1
$1="$$1 $BOOST_PYTHON_$1"])
# BOOST_PYTHON([PREFERRED-RT-OPT])
# --------------------------------
# Look for Boost.Python. For the documentation of PREFERRED-RT-OPT,
# see the documentation of BOOST_FIND_LIB above.
BOOST_DEFUN([Python],
[_BOOST_PYTHON_CONFIG([CPPFLAGS], [includes])
_BOOST_PYTHON_CONFIG([LDFLAGS], [ldflags])
_BOOST_PYTHON_CONFIG([LIBS], [libs])
m4_pattern_allow([^BOOST_PYTHON_MODULE$])dnl
BOOST_FIND_LIBS([python], [python python3], [$1],
[boost/python.hpp],
[], [BOOST_PYTHON_MODULE(empty) {}])
CPPFLAGS=$boost_python_save_CPPFLAGS
LDFLAGS=$boost_python_save_LDFLAGS
LIBS=$boost_python_save_LIBS
])# BOOST_PYTHON
# BOOST_REF()
# -----------
# Look for Boost.Ref
BOOST_DEFUN([Ref],
[BOOST_FIND_HEADER([boost/ref.hpp])])
# BOOST_REGEX([PREFERRED-RT-OPT])
# -------------------------------
# Look for Boost.Regex. For the documentation of PREFERRED-RT-OPT, see the
# documentation of BOOST_FIND_LIB above.
BOOST_DEFUN([Regex],
[BOOST_FIND_LIB([regex], [$1],
[boost/regex.hpp],
[boost::regex exp("*"); boost::regex_match("foo", exp);])
])# BOOST_REGEX
# BOOST_SERIALIZATION([PREFERRED-RT-OPT])
# ---------------------------------------
# Look for Boost.Serialization. For the documentation of PREFERRED-RT-OPT, see
# the documentation of BOOST_FIND_LIB above.
BOOST_DEFUN([Serialization],
[BOOST_FIND_LIB([serialization], [$1],
[boost/archive/text_oarchive.hpp],
[std::ostream* o = 0; // Cheap way to get an ostream...
boost::archive::text_oarchive t(*o);])
])# BOOST_SERIALIZATION
# BOOST_SIGNALS([PREFERRED-RT-OPT])
# ---------------------------------
# Look for Boost.Signals. For the documentation of PREFERRED-RT-OPT, see the
# documentation of BOOST_FIND_LIB above.
BOOST_DEFUN([Signals],
[BOOST_FIND_LIB([signals], [$1],
[boost/signal.hpp],
[boost::signal<void ()> s;])
])# BOOST_SIGNALS
# BOOST_SIGNALS2()
# ----------------
# Look for Boost.Signals2 (new since 1.39.0).
BOOST_DEFUN([Signals2],
[BOOST_FIND_HEADER([boost/signals2.hpp])
])# BOOST_SIGNALS2
# BOOST_SMART_PTR()
# -----------------
# Look for Boost.SmartPtr
BOOST_DEFUN([Smart_Ptr],
[BOOST_FIND_HEADER([boost/scoped_ptr.hpp])
BOOST_FIND_HEADER([boost/shared_ptr.hpp])
])
# BOOST_STATICASSERT()
# --------------------
# Look for Boost.StaticAssert
BOOST_DEFUN([StaticAssert],
[BOOST_FIND_HEADER([boost/static_assert.hpp])])
# BOOST_STRING_ALGO()
# -------------------
# Look for Boost.StringAlgo
BOOST_DEFUN([String_Algo],
[BOOST_FIND_HEADER([boost/algorithm/string.hpp])
])
# BOOST_SYSTEM([PREFERRED-RT-OPT])
# --------------------------------
# Look for Boost.System. For the documentation of PREFERRED-RT-OPT, see the
# documentation of BOOST_FIND_LIB above. This library was introduced in Boost
# 1.35.0.
BOOST_DEFUN([System],
[BOOST_FIND_LIB([system], [$1],
[boost/system/error_code.hpp],
[boost::system::error_code e; e.clear();])
])# BOOST_SYSTEM
# BOOST_TEST([PREFERRED-RT-OPT])
# ------------------------------
# Look for Boost.Test. For the documentation of PREFERRED-RT-OPT, see the
# documentation of BOOST_FIND_LIB above.
BOOST_DEFUN([Test],
[m4_pattern_allow([^BOOST_CHECK$])dnl
BOOST_FIND_LIB([unit_test_framework], [$1],
[boost/test/unit_test.hpp], [BOOST_CHECK(2 == 2);],
[using boost::unit_test::test_suite;
test_suite* init_unit_test_suite(int argc, char ** argv)
{ return NULL; }])
])# BOOST_TEST
# BOOST_THREAD([PREFERRED-RT-OPT])
# ---------------------------------
# Look for Boost.Thread. For the documentation of PREFERRED-RT-OPT, see the
# documentation of BOOST_FIND_LIB above.
BOOST_DEFUN([Thread],
[dnl Having the pthread flag is required at least on GCC3 where
dnl boost/thread.hpp would complain if we try to compile without
dnl -pthread on GNU/Linux.
AC_REQUIRE([_BOOST_PTHREAD_FLAG])dnl
boost_thread_save_LIBS=$LIBS
boost_thread_save_LDFLAGS=$LDFLAGS
boost_thread_save_CPPFLAGS=$CPPFLAGS
# Link-time dependency from thread to system was added as of 1.49.0.
if test $boost_major_version -ge 149; then
BOOST_SYSTEM([$1])
fi # end of the Boost.System check.
m4_pattern_allow([^BOOST_SYSTEM_(LIBS|LDFLAGS)$])dnl
LIBS="$LIBS $BOOST_SYSTEM_LIBS $boost_cv_pthread_flag"
LDFLAGS="$LDFLAGS $BOOST_SYSTEM_LDFLAGS"
CPPFLAGS="$CPPFLAGS $boost_cv_pthread_flag"
# When compiling for the Windows platform, the threads library is named
# differently. This suffix doesn't exist in new versions of Boost, or
# possibly new versions of GCC on mingw I am assuming it's Boost's change for
# now and I am setting version to 1.48, for lack of knowledge as to when this
# change occurred.
if test $boost_major_version -lt 148; then
case $host_os in
(*mingw*) boost_thread_lib_ext=_win32;;
esac
fi
BOOST_FIND_LIBS([thread], [thread$boost_thread_lib_ext],
[$1],
[boost/thread.hpp], [boost::thread t; boost::mutex m;])
case $host_os in
(*mingw*) boost_thread_w32_socket_link=-lws2_32;;
esac
BOOST_THREAD_LIBS="$BOOST_THREAD_LIBS $BOOST_SYSTEM_LIBS $boost_cv_pthread_flag $boost_thread_w32_socket_link"
BOOST_THREAD_LDFLAGS="$BOOST_SYSTEM_LDFLAGS"
BOOST_CPPFLAGS="$BOOST_CPPFLAGS $boost_cv_pthread_flag"
LIBS=$boost_thread_save_LIBS
LDFLAGS=$boost_thread_save_LDFLAGS
CPPFLAGS=$boost_thread_save_CPPFLAGS
])# BOOST_THREAD
AU_ALIAS([BOOST_THREADS], [BOOST_THREAD])
# BOOST_TOKENIZER()
# -----------------
# Look for Boost.Tokenizer
BOOST_DEFUN([Tokenizer],
[BOOST_FIND_HEADER([boost/tokenizer.hpp])])
# BOOST_TRIBOOL()
# ---------------
# Look for Boost.Tribool
BOOST_DEFUN([Tribool],
[BOOST_FIND_HEADER([boost/logic/tribool_fwd.hpp])
BOOST_FIND_HEADER([boost/logic/tribool.hpp])
])
# BOOST_TUPLE()
# -------------
# Look for Boost.Tuple
BOOST_DEFUN([Tuple],
[BOOST_FIND_HEADER([boost/tuple/tuple.hpp])])
# BOOST_TYPETRAITS()
# --------------------
# Look for Boost.TypeTraits
BOOST_DEFUN([TypeTraits],
[BOOST_FIND_HEADER([boost/type_traits.hpp])])
# BOOST_UTILITY()
# ---------------
# Look for Boost.Utility (noncopyable, result_of, base-from-member idiom,
# etc.)
BOOST_DEFUN([Utility],
[BOOST_FIND_HEADER([boost/utility.hpp])])
# BOOST_VARIANT()
# ---------------
# Look for Boost.Variant.
BOOST_DEFUN([Variant],
[BOOST_FIND_HEADER([boost/variant/variant_fwd.hpp])
BOOST_FIND_HEADER([boost/variant.hpp])])
# BOOST_POINTER_CONTAINER()
# ------------------------
# Look for Boost.PointerContainer
BOOST_DEFUN([Pointer_Container],
[BOOST_FIND_HEADER([boost/ptr_container/ptr_deque.hpp])
BOOST_FIND_HEADER([boost/ptr_container/ptr_list.hpp])
BOOST_FIND_HEADER([boost/ptr_container/ptr_vector.hpp])
BOOST_FIND_HEADER([boost/ptr_container/ptr_array.hpp])
BOOST_FIND_HEADER([boost/ptr_container/ptr_set.hpp])
BOOST_FIND_HEADER([boost/ptr_container/ptr_map.hpp])
])# BOOST_POINTER_CONTAINER
# BOOST_WAVE([PREFERRED-RT-OPT])
# ------------------------------
# NOTE: If you intend to use Wave/Spirit with thread support, make sure you
# call BOOST_THREAD first.
# Look for Boost.Wave. For the documentation of PREFERRED-RT-OPT, see the
# documentation of BOOST_FIND_LIB above.
BOOST_DEFUN([Wave],
[AC_REQUIRE([BOOST_FILESYSTEM])dnl
AC_REQUIRE([BOOST_DATE_TIME])dnl
boost_wave_save_LIBS=$LIBS
boost_wave_save_LDFLAGS=$LDFLAGS
m4_pattern_allow([^BOOST_((FILE)?SYSTEM|DATE_TIME|THREAD)_(LIBS|LDFLAGS)$])dnl
LIBS="$LIBS $BOOST_SYSTEM_LIBS $BOOST_FILESYSTEM_LIBS $BOOST_DATE_TIME_LIBS \
$BOOST_THREAD_LIBS"
LDFLAGS="$LDFLAGS $BOOST_SYSTEM_LDFLAGS $BOOST_FILESYSTEM_LDFLAGS \
$BOOST_DATE_TIME_LDFLAGS $BOOST_THREAD_LDFLAGS"
BOOST_FIND_LIB([wave], [$1],
[boost/wave.hpp],
[boost::wave::token_id id; get_token_name(id);])
LIBS=$boost_wave_save_LIBS
LDFLAGS=$boost_wave_save_LDFLAGS
])# BOOST_WAVE
# BOOST_XPRESSIVE()
# -----------------
# Look for Boost.Xpressive (new since 1.36.0).
BOOST_DEFUN([Xpressive],
[BOOST_FIND_HEADER([boost/xpressive/xpressive.hpp])])
# ----------------- #
# Internal helpers. #
# ----------------- #
# _BOOST_PTHREAD_FLAG()
# ---------------------
# Internal helper for BOOST_THREAD. Computes boost_cv_pthread_flag
# which must be used in CPPFLAGS and LIBS.
#
# Yes, we *need* to put the -pthread thing in CPPFLAGS because with GCC3,
# boost/thread.hpp will trigger a #error if -pthread isn't used:
# boost/config/requires_threads.hpp:47:5: #error "Compiler threading support
# is not turned on. Please set the correct command line options for
# threading: -pthread (Linux), -pthreads (Solaris) or -mthreads (Mingw32)"
#
# Based on ACX_PTHREAD: http://autoconf-archive.cryp.to/acx_pthread.html
AC_DEFUN([_BOOST_PTHREAD_FLAG],
[AC_REQUIRE([AC_PROG_CXX])dnl
AC_REQUIRE([AC_CANONICAL_HOST])dnl
AC_LANG_PUSH([C++])dnl
AC_CACHE_CHECK([for the flags needed to use pthreads], [boost_cv_pthread_flag],
[ boost_cv_pthread_flag=
# The ordering *is* (sometimes) important. Some notes on the
# individual items follow:
# (none): in case threads are in libc; should be tried before -Kthread and
# other compiler flags to prevent continual compiler warnings
# -lpthreads: AIX (must check this before -lpthread)
# -Kthread: Sequent (threads in libc, but -Kthread needed for pthread.h)
# -kthread: FreeBSD kernel threads (preferred to -pthread since SMP-able)
# -llthread: LinuxThreads port on FreeBSD (also preferred to -pthread)
# -pthread: GNU Linux/GCC (kernel threads), BSD/GCC (userland threads)
# -pthreads: Solaris/GCC
# -mthreads: MinGW32/GCC, Lynx/GCC
# -mt: Sun Workshop C (may only link SunOS threads [-lthread], but it
# doesn't hurt to check since this sometimes defines pthreads too;
# also defines -D_REENTRANT)
# ... -mt is also the pthreads flag for HP/aCC
# -lpthread: GNU Linux, etc.
# --thread-safe: KAI C++
case $host_os in #(
*solaris*)
# On Solaris (at least, for some versions), libc contains stubbed
# (non-functional) versions of the pthreads routines, so link-based
# tests will erroneously succeed. (We need to link with -pthreads/-mt/
# -lpthread.) (The stubs are missing pthread_cleanup_push, or rather
# a function called by this macro, so we could check for that, but
# who knows whether they'll stub that too in a future libc.) So,
# we'll just look for -pthreads and -lpthread first:
boost_pthread_flags="-pthreads -lpthread -mt -pthread";; #(
*)
boost_pthread_flags="-lpthreads -Kthread -kthread -llthread -pthread \
-pthreads -mthreads -lpthread --thread-safe -mt";;
esac
# Generate the test file.
AC_LANG_CONFTEST([AC_LANG_PROGRAM([#include <pthread.h>],
[pthread_t th; pthread_join(th, 0);
pthread_attr_init(0); pthread_cleanup_push(0, 0);
pthread_create(0,0,0,0); pthread_cleanup_pop(0);])])
for boost_pthread_flag in '' $boost_pthread_flags; do
boost_pthread_ok=false
dnl Re-use the test file already generated.
boost_pthreads__save_LIBS=$LIBS
LIBS="$LIBS $boost_pthread_flag"
AC_LINK_IFELSE([],
[if grep ".*$boost_pthread_flag" conftest.err; then
echo "This flag seems to have triggered warnings" >&AS_MESSAGE_LOG_FD
else
boost_pthread_ok=:; boost_cv_pthread_flag=$boost_pthread_flag
fi])
LIBS=$boost_pthreads__save_LIBS
$boost_pthread_ok && break
done
])
AC_LANG_POP([C++])dnl
])# _BOOST_PTHREAD_FLAG
# _BOOST_gcc_test(MAJOR, MINOR)
# -----------------------------
# Internal helper for _BOOST_FIND_COMPILER_TAG.
m4_define([_BOOST_gcc_test],
["defined __GNUC__ && __GNUC__ == $1 && __GNUC_MINOR__ == $2 && !defined __ICC @ gcc$1$2"])dnl
# _BOOST_mingw_test(MAJOR, MINOR)
# -----------------------------
# Internal helper for _BOOST_FIND_COMPILER_TAG.
m4_define([_BOOST_mingw_test],
["defined __GNUC__ && __GNUC__ == $1 && __GNUC_MINOR__ == $2 && !defined __ICC && \
(defined WIN32 || defined WINNT || defined _WIN32 || defined __WIN32 \
|| defined __WIN32__ || defined __WINNT || defined __WINNT__) @ mgw$1$2"])dnl
# _BOOST_FIND_COMPILER_TAG()
# --------------------------
# Internal. When Boost is installed without --layout=system, each library
# filename will hold a suffix that encodes the compiler used during the
# build. The Boost build system seems to call this a `tag'.
AC_DEFUN([_BOOST_FIND_COMPILER_TAG],
[AC_REQUIRE([AC_PROG_CXX])dnl
AC_REQUIRE([AC_CANONICAL_HOST])dnl
AC_CACHE_CHECK([for the toolset name used by Boost for $CXX],
[boost_cv_lib_tag],
[boost_cv_lib_tag=unknown
if test x$boost_cv_inc_path != xno; then
AC_LANG_PUSH([C++])dnl
# The following tests are mostly inspired by boost/config/auto_link.hpp
# The list is sorted to most recent/common to oldest compiler (in order
# to increase the likelihood of finding the right compiler with the
# least number of compilation attempt).
# Beware that some tests are sensible to the order (for instance, we must
# look for MinGW before looking for GCC3).
# I used one compilation test per compiler with a #error to recognize
# each compiler so that it works even when cross-compiling (let me know
# if you know a better approach).
# Known missing tags (known from Boost's tools/build/v2/tools/common.jam):
# como, edg, kcc, bck, mp, sw, tru, xlc
# I'm not sure about my test for `il' (be careful: Intel's ICC pre-defines
# the same defines as GCC's).
for i in \
+ _BOOST_mingw_test(6, 1) \
+ _BOOST_gcc_test(6, 1) \
+ _BOOST_mingw_test(5, 3) \
+ _BOOST_gcc_test(5, 3) \
_BOOST_mingw_test(5, 2) \
_BOOST_gcc_test(5, 2) \
_BOOST_mingw_test(5, 1) \
_BOOST_gcc_test(5, 1) \
_BOOST_mingw_test(5, 0) \
_BOOST_gcc_test(5, 0) \
_BOOST_mingw_test(4, 10) \
_BOOST_gcc_test(4, 10) \
_BOOST_mingw_test(4, 9) \
_BOOST_gcc_test(4, 9) \
_BOOST_mingw_test(4, 8) \
_BOOST_gcc_test(4, 8) \
_BOOST_mingw_test(4, 7) \
_BOOST_gcc_test(4, 7) \
_BOOST_mingw_test(4, 6) \
_BOOST_gcc_test(4, 6) \
_BOOST_mingw_test(4, 5) \
_BOOST_gcc_test(4, 5) \
_BOOST_mingw_test(4, 4) \
_BOOST_gcc_test(4, 4) \
_BOOST_mingw_test(4, 3) \
_BOOST_gcc_test(4, 3) \
_BOOST_mingw_test(4, 2) \
_BOOST_gcc_test(4, 2) \
_BOOST_mingw_test(4, 1) \
_BOOST_gcc_test(4, 1) \
_BOOST_mingw_test(4, 0) \
_BOOST_gcc_test(4, 0) \
"defined __GNUC__ && __GNUC__ == 3 && !defined __ICC \
&& (defined WIN32 || defined WINNT || defined _WIN32 || defined __WIN32 \
|| defined __WIN32__ || defined __WINNT || defined __WINNT__) @ mgw" \
_BOOST_gcc_test(3, 4) \
_BOOST_gcc_test(3, 3) \
"defined _MSC_VER && _MSC_VER >= 1500 @ vc90" \
"defined _MSC_VER && _MSC_VER == 1400 @ vc80" \
_BOOST_gcc_test(3, 2) \
"defined _MSC_VER && _MSC_VER == 1310 @ vc71" \
_BOOST_gcc_test(3, 1) \
_BOOST_gcc_test(3, 0) \
"defined __BORLANDC__ @ bcb" \
"defined __ICC && (defined __unix || defined __unix__) @ il" \
"defined __ICL @ iw" \
"defined _MSC_VER && _MSC_VER == 1300 @ vc7" \
_BOOST_gcc_test(2, 95) \
"defined __MWERKS__ && __MWERKS__ <= 0x32FF @ cw9" \
"defined _MSC_VER && _MSC_VER < 1300 && !defined UNDER_CE @ vc6" \
"defined _MSC_VER && _MSC_VER < 1300 && defined UNDER_CE @ evc4" \
"defined __MWERKS__ && __MWERKS__ <= 0x31FF @ cw8"
do
boost_tag_test=`expr "X$i" : 'X\([[^@]]*\) @ '`
boost_tag=`expr "X$i" : 'X[[^@]]* @ \(.*\)'`
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
#if $boost_tag_test
/* OK */
#else
# error $boost_tag_test
#endif
]])], [boost_cv_lib_tag=$boost_tag; break], [])
done
AC_LANG_POP([C++])dnl
case $boost_cv_lib_tag in #(
# Some newer (>= 1.35?) versions of Boost seem to only use "gcc" as opposed
# to "gcc41" for instance.
*-gcc | *'-gcc ') :;; #( Don't re-add -gcc: it's already in there.
gcc*)
boost_tag_x=
case $host_os in #(
darwin*)
if test $boost_major_version -ge 136; then
# The `x' added in r46793 of Boost.
boost_tag_x=x
fi;;
esac
# We can specify multiple tags in this variable because it's used by
# BOOST_FIND_LIB that does a `for tag in -$boost_cv_lib_tag' ...
boost_cv_lib_tag="$boost_tag_x$boost_cv_lib_tag -${boost_tag_x}gcc"
;; #(
unknown)
AC_MSG_WARN([[could not figure out which toolset name to use for $CXX]])
boost_cv_lib_tag=
;;
esac
fi])dnl end of AC_CACHE_CHECK
])# _BOOST_FIND_COMPILER_TAG
# _BOOST_GUESS_WHETHER_TO_USE_MT()
# --------------------------------
# Compile a small test to try to guess whether we should favor MT (Multi
# Thread) flavors of Boost. Sets boost_guess_use_mt accordingly.
AC_DEFUN([_BOOST_GUESS_WHETHER_TO_USE_MT],
[# Check whether we do better use `mt' even though we weren't ask to.
AC_LANG_PUSH([C++])dnl
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
#if defined _REENTRANT || defined _MT || defined __MT__
/* use -mt */
#else
# error MT not needed
#endif
]])], [boost_guess_use_mt=:], [boost_guess_use_mt=false])
AC_LANG_POP([C++])dnl
])
# _BOOST_AC_LINK_IFELSE(PROGRAM, [ACTION-IF-TRUE], [ACTION-IF-FALSE])
# -------------------------------------------------------------------
# Fork of _AC_LINK_IFELSE that preserves conftest.o across calls. Fragile,
# will break when Autoconf changes its internals. Requires that you manually
# rm -f conftest.$ac_objext in between to really different tests, otherwise
# you will try to link a conftest.o left behind by a previous test.
# Used to aggressively optimize BOOST_FIND_LIB (see the big comment in this
# macro).
#
# Don't use "break" in the actions, as it would short-circuit some code
# this macro runs after the actions.
m4_define([_BOOST_AC_LINK_IFELSE],
[m4_ifvaln([$1], [AC_LANG_CONFTEST([$1])])dnl
rm -f conftest$ac_exeext
boost_save_ac_ext=$ac_ext
boost_use_source=:
# If we already have a .o, re-use it. We change $ac_ext so that $ac_link
# tries to link the existing object file instead of compiling from source.
test -f conftest.$ac_objext && ac_ext=$ac_objext && boost_use_source=false &&
_AS_ECHO_LOG([re-using the existing conftest.$ac_objext])
AS_IF([_AC_DO_STDERR($ac_link) && {
test -z "$ac_[]_AC_LANG_ABBREV[]_werror_flag" ||
test ! -s conftest.err
} && test -s conftest$ac_exeext && {
test "$cross_compiling" = yes ||
$as_executable_p conftest$ac_exeext
dnl FIXME: use AS_TEST_X instead when 2.61 is widespread enough.
}],
[$2],
[if $boost_use_source; then
_AC_MSG_LOG_CONFTEST
fi
$3])
ac_objext=$boost_save_ac_objext
ac_ext=$boost_save_ac_ext
dnl Delete also the IPA/IPO (Inter Procedural Analysis/Optimization)
dnl information created by the PGI compiler (conftest_ipa8_conftest.oo),
dnl as it would interfere with the next link command.
rm -f core conftest.err conftest_ipa8_conftest.oo \
conftest$ac_exeext m4_ifval([$1], [conftest.$ac_ext])[]dnl
])# _BOOST_AC_LINK_IFELSE
# Local Variables:
# mode: autoconf
# End:

File Metadata

Mime Type
text/x-diff
Expires
Wed, May 14, 11:21 AM (17 h, 37 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
5111406
Default Alt Text
(143 KB)

Event Timeline