Skip to content

Commit

Permalink
Merge pull request #3 from mfasDa/alice/v2.2.2
Browse files Browse the repository at this point in the history
Import ThePEG v2.2.2 (needed for Herwig v7.2.2)
  • Loading branch information
maireiphc authored May 11, 2021
2 parents b4f7fa2 + be4d395 commit cf9dafb
Show file tree
Hide file tree
Showing 8 changed files with 141 additions and 75 deletions.
54 changes: 32 additions & 22 deletions Analysis/RivetAnalysis.cc
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,11 @@
#include "Rivet/AnalysisHandler.hh"
#include "Rivet/Tools/RivetPaths.hh"
#include "Rivet/Tools/Logging.hh"
#include "ThePEG/Utilities/DescribeClass.h"

using namespace ThePEG;

RivetAnalysis::RivetAnalysis() : debug(false), _rivet(), _nevent(0)
RivetAnalysis::RivetAnalysis() : _debug(false), _rivet(), _nevent(0)
{}

void RivetAnalysis::analyze(ThePEG::tEventPtr event, long ieve, int loop, int state) {
Expand All @@ -34,9 +35,7 @@ void RivetAnalysis::analyze(ThePEG::tEventPtr event, long ieve, int loop, int st
// analyse the event
if(_nevent>1) CurrentGenerator::Redirect stdout(cout);
if ( _rivet ){
#if ThePEG_RIVET_VERSION == 1
_rivet->analyze(*hepmc);
#elif ThePEG_RIVET_VERSION > 1
#if ThePEG_RIVET_VERSION > 1
try {
_rivet->analyze(*hepmc);
} catch (const YODA::Exception & e) {
Expand Down Expand Up @@ -69,15 +68,17 @@ ThePEG::IBPtr RivetAnalysis::fullclone() const {
}

void RivetAnalysis::persistentOutput(ThePEG::PersistentOStream & os) const {
os << _analyses << _paths << filename << debug;
os << _analyses << _preload << _paths << _filename << _debug;
}

void RivetAnalysis::persistentInput(ThePEG::PersistentIStream & is, int) {
is >> _analyses >> _paths >> filename >> debug;
is >> _analyses >> _preload >> _paths >> _filename >> _debug;
}

ThePEG::ClassDescription<RivetAnalysis> RivetAnalysis::initRivetAnalysis;
// Definition of the static class description member.
// The following static variable is needed for the type
// description system in ThePEG.
DescribeClass<RivetAnalysis,AnalysisHandler>
describeRivetAnalysis("ThePEG::RivetAnalysis", "RivetAnalysis.so");

void RivetAnalysis::Init() {

Expand All @@ -91,6 +92,12 @@ void RivetAnalysis::Init() {
&RivetAnalysis::_analyses, -1, "", "","" "",
false, false, ThePEG::Interface::nolimits);

static ParVector<RivetAnalysis,string> interfacePreLoad
("PreLoad",
"The yoda files to be preloaded",
&RivetAnalysis::_preload, -1, "", "", "",
false, false, Interface::nolimits);

static ThePEG::ParVector<RivetAnalysis,string> interfacePaths
("Paths",
"The directory paths where Rivet should look for analyses.",
Expand All @@ -99,24 +106,20 @@ void RivetAnalysis::Init() {

static Parameter<RivetAnalysis,string> interfaceFilename
("Filename",
#if ThePEG_RIVET_VERSION == 1
"The name of the file where the AIDA histograms are put. If empty, "
"the run name will be used instead. '.aida' will in any case be "
"appended to the file name.",
#elif ThePEG_RIVET_VERSION > 1
#if ThePEG_RIVET_VERSION > 1
"The name of the file where the YODA histograms are put. If empty, "
"the run name will be used instead. '.yoda' will in any case be "
"appended to the file name.",
#else
#error "Unknown ThePEG_RIVET_VERSION"
#endif
&RivetAnalysis::filename, "", true, false);
&RivetAnalysis::_filename, "", true, false);


static Switch<RivetAnalysis,bool> interfaceDebug
("Debug",
"Enable debug information from Rivet",
&RivetAnalysis::debug, false, true, false);
&RivetAnalysis::_debug, false, true, false);
static SwitchOption interfaceDebugNo
(interfaceDebug,
"No",
Expand Down Expand Up @@ -145,11 +148,8 @@ void RivetAnalysis::dofinish() {
#endif
_rivet->finalize();

string fname = filename;
#if ThePEG_RIVET_VERSION == 1
if ( fname.empty() )
fname = generator()->path() + "/" + generator()->runName() + ".aida";
#elif ThePEG_RIVET_VERSION > 1
string fname = _filename;
#if ThePEG_RIVET_VERSION > 1
if ( fname.empty() )
fname = generator()->path() + "/" + generator()->runName() + ".yoda";
#else
Expand Down Expand Up @@ -186,7 +186,7 @@ void RivetAnalysis::doinitrun() {
AnalysisHandler::doinitrun();
// create Rivet analysis handler
CurrentGenerator::Redirect stdout(cout);
_rivet = new Rivet::AnalysisHandler; //(fname);
_rivet = new Rivet::AnalysisHandler;
for ( int i = 0, N = _paths.size(); i < N; ++i ) Rivet::addAnalysisLibPath(_paths[i]);
_rivet->addAnalyses(_analyses);
// check that analysis list is still available
Expand All @@ -196,6 +196,16 @@ void RivetAnalysis::doinitrun() {
<< "Use 'rivet --list-analyses' to check availability.\n"
<< ThePEG::Exception::runerror;
}
if ( debug )
// preload files
#if ThePEG_RIVET_VERSION > 2
for(string fname : _preload) {
_rivet->readData(fname);
}
#else
if(!_preload.empty())
throw Exception() << "You have requested yoda files are preloaded by Rivet but this only supported for Rivet 3 and above";
#endif
// debugging
if ( _debug )
Rivet::Log::setLevel("Rivet",Rivet::Log::DEBUG);
}
44 changes: 7 additions & 37 deletions Analysis/RivetAnalysis.h
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,11 @@ class RivetAnalysis: public ThePEG::AnalysisHandler {
*/
vector<string> _analyses;

/**
* Yoda files to be preloaded
*/
vector<string> _preload;

/**
* Search paths for finding rivet analyses.
*/
Expand All @@ -143,12 +148,12 @@ class RivetAnalysis: public ThePEG::AnalysisHandler {
/**
* The base name of the output file.
*/
string filename;
string _filename;

/**
* Enable debugging information from Rivet
*/
bool debug;
bool _debug;

/**
* The RivetAnalysisHandler
Expand All @@ -163,39 +168,4 @@ class RivetAnalysis: public ThePEG::AnalysisHandler {

}

#include "ThePEG/Utilities/ClassTraits.h"

namespace ThePEG {

/** @cond TRAITSPECIALIZATIONS */

/** This template specialization informs ThePEG about the
* base classes of RivetAnalysis. */
template <>
struct BaseClassTrait<RivetAnalysis,1> {
/** Typedef of the first base class of RivetAnalysis. */
typedef AnalysisHandler NthBase;
};

/** This template specialization informs ThePEG about the name of
* the RivetAnalysis class and the shared object where it is defined. */
template <>
struct ClassTraits<RivetAnalysis>
: public ClassTraitsBase<RivetAnalysis> {
/** Return a platform-independent class name */
static string className() { return "ThePEG::RivetAnalysis"; }
/**
* The name of a file containing the dynamic library where the class
* RivetAnalysis is implemented. It may also include several, space-separated,
* libraries if the class RivetAnalysis depends on other classes (base classes
* excepted). In this case the listed libraries will be dynamically
* linked in the order they are specified.
*/
static string library() { return "RivetAnalysis.so"; }
};

/** @endcond */

}

#endif /* THEPEG_RivetAnalysis_H */
38 changes: 38 additions & 0 deletions EventRecord/Event.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#include "StandardSelectors.h"
#include "SubProcess.h"
#include "ThePEG/Utilities/Named.h"
#include "ThePEG/Utilities/AnyReference.h"

namespace ThePEG {

Expand Down Expand Up @@ -261,6 +262,38 @@ class Event : public EventRecordBase, public Named {
*/
void primaryCollision(tCollPtr c);

public:

/**
* Check for meta information
*/
bool hasMeta(const string& id) const {
return theMeta.find(id) != theMeta.end();
}

/**
* Set meta information.
*/
template<class T>
void meta(const string& id, T& ref) {
theMeta[id] = AnyReference(ref);
}

/**
* Erase meta information.
*/
void eraseMeta(const string& id) {
theMeta.erase(id);
}

/**
* Retrieve meta information.
*/
template<class T>
T& meta(const string& id) const {
return theMeta.find(id)->second.cast<T>();
}

protected:

/**
Expand Down Expand Up @@ -388,6 +421,11 @@ class Event : public EventRecordBase, public Named {
*/
long theParticleNumber;

/**
* The meta information
*/
map<string,AnyReference> theMeta;

public:

/**
Expand Down
2 changes: 1 addition & 1 deletion Helicity/Vertex/Scalar/VSSVertex.cc
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ describeThePEGVSSVertex("ThePEG::VSSVertex", "libThePEG.so");
void VSSVertex::Init() {

static ClassDocumentation<VSSVertex> documentation
("The VSSVertex class is hte implementation of the"
("The VSSVertex class is the implementation of the"
"vector-scalar-scalar vertex for helicity amplitude calculations."
" all such vertices should inherit from it");
}
14 changes: 14 additions & 0 deletions NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,26 @@ where NN is the bug number.
The latest version of ThePEG can be found at http://www.thep.lu.se/ThePEG
or at https:///herwig.hepforge.org/

* ThePEG-2.2.2 release: 2021-01-22

** add meta mechanism to event record

** add option of preloading yoda files and remove support for rivet-1 and aida

* ThePEG-2.2.1 release: 2019-04-10

** new release solely to keep Herwig and ThePEG version numbers in sync

* ThePEG-2.2.0 release: 2019-12-12

** Improvements to the unit templates, building with gcc 4.8 is no longer possible

** Several smaller bug fixes and additions, to allow new features in Herwig 7.2

* ThePEG-2.1.7 release: 2020-04-10

** new release solely to keep Herwig and ThePEG version numbers in sync

* ThePEG-2.1.6 release: 2019-12-11

** update boost.m4 to allow compliation with new boost versions
Expand Down
42 changes: 38 additions & 4 deletions PDF/LHAPDF6.cc
Original file line number Diff line number Diff line change
Expand Up @@ -143,14 +143,36 @@ cPDVector ThePEG::LHAPDF::partons(tcPDPtr particle) const {
const vector<int> & flavs =
pdfset.get_entry_as< vector<int> >("Flavors");

// check for leptons and antileptons
bool hasLepton [3] = {false,false,false};
bool hasAntiLepton[3] = {false,false,false};
vector<int> flav2;
flav2.reserve(flavs.size()+3);
for (int val : flavs) {
if(abs(val) == 11 || abs(val) ==13 || abs(val)==15) {
int ilep = (abs(val)-11)/2;
if(val>0) hasLepton[ilep]=true;
else hasAntiLepton[ilep]=true;
}
flav2.push_back(val);
}
for(unsigned int ix=0;ix<3;++ix) {
if(hasLepton[ix] && !hasAntiLepton[ix]) {
int pid = 11+2*ix;
cerr << "Charged lepton with pid=" << pid << " found in PDF but not the antilepton"
<< " assumming antilepton PDF is equal to the lepton one\n";
flav2.push_back(-pid);
}
}

cPDVector ret;
ret.reserve( flavs.size() );
ret.reserve( flav2.size() );
if ( canHandleParticle(particle) ) {
for ( size_t i=0; i < flavs.size(); ++i ) {
ret.push_back(getParticleData(flavs[i]));
for ( size_t i=0; i < flav2.size(); ++i ) {
ret.push_back(getParticleData(flav2[i]));
}
}
assert( ret.size() == flavs.size() );
assert( ret.size() == flav2.size() );
return ret;
}

Expand Down Expand Up @@ -227,6 +249,12 @@ double ThePEG::LHAPDF::xfx(tcPDPtr particle, tcPDPtr parton,
return thePDF->xfxQ2(g,x,Q2);
case ParticleID::gamma:
return thePDF->xfxQ2(ParticleID::gamma,x,Q2);
case ParticleID::eminus: case ParticleID::muminus: case ParticleID::tauminus:
case ParticleID::eplus : case ParticleID::muplus : case ParticleID::tauplus :
if(pid>0 || thePDF->hasFlavor(pid))
return thePDF->xfxQ2(pid,x,Q2);
else
return thePDF->xfxQ2(-pid,x,Q2);
}
return 0.0;
}
Expand Down Expand Up @@ -384,6 +412,12 @@ double ThePEG::LHAPDF::xfsx(tcPDPtr particle, tcPDPtr parton,
return thePDF->xfxQ2(g,x,Q2);
case ParticleID::gamma:
return thePDF->xfxQ2(ParticleID::gamma,x,Q2);
case ParticleID::eminus: case ParticleID::muminus: case ParticleID::tauminus:
case ParticleID::eplus : case ParticleID::muplus : case ParticleID::tauplus :
if(pid>0 || thePDF->hasFlavor(pid))
return thePDF->xfxQ2(pid,x,Q2);
else
return thePDF->xfxQ2(-pid,x,Q2);
}
return 0.0;
}
Expand Down
Loading

0 comments on commit cf9dafb

Please sign in to comment.