agile is hosted by Hepforge, IPPP Durham

Generator Class Reference

#include <Generator.hh>

Inheritance diagram for Generator:
Collaboration diagram for Generator:

List of all members.

Public Types

enum  Result { SUCCESS = 1, FAILURE = 0 }
 

Really just syntactic sugar for bool returns from setParam.

More...

Public Member Functions

 Generator ()
 Standard constructor.
virtual ~Generator ()
 Destructor.
void setInitialState (int p1=PROTON, double e1=7000.0, int p2=PROTON, double e2=7000.0)
 Define initial state.
virtual const GeneratorStategetState ()
 Get a generator state object.
virtual void setState (const GeneratorState &state)
 Setup the generator from a generator state object.
virtual const std::string getName () const
 Get the generator name.
virtual void setVersion (const std::string &version)
 Set the generator version.
virtual const std::string getVersion ()
 Get the generator version. This implementation is used as a last resort to determine the generator version. Ideally a specific generator will know its own version and overwrite this. Some generators (e.g. FHerwig) don't know this.
virtual std::string getPDFSet (PdgCode pid)
virtual int getPDFMember (PdgCode pid)
 Get the PDF id number for a given particle.
virtual std::string getPDFScheme (PdgCode pid) const
 Get the PDF scheme used by the generator (LHAPDF or other).
virtual void setSeed (const int value)
 Set the random number generator seed.
virtual bool setParam (const std::string &name, const int &value)
 Pass an int-valued parameter to the generator.
virtual bool setParam (const std::string &name, const unsigned int &value)
 Pass an int-valued parameter to the generator.
virtual bool setParam (const std::string &name, const long &value)
 Pass an int-valued parameter to the generator.
virtual bool setParam (const std::string &name, const unsigned long &value)
 Pass an int-valued parameter to the generator.
virtual bool setParam (const std::string &name, const double &value)
 Pass a double/float-valued parameter to the generator.
virtual bool setParam (const std::string &name, const float &value)
 Pass a double/float-valued parameter to the generator.
virtual bool setParam (const std::string &name, const bool &value)
 Pass a bool-valued parameter to the generator.
virtual bool setParam (const std::string &name, const std::string &value)
 Pass a string-valued parameter to the generator.
virtual void makeEvent (HepMC::GenEvent &evt)
 Run one event.
virtual const double getCrossSection ()
 Return the generated cross section in pb.
virtual void finalize ()=0
 Finalise.

Protected Member Functions

LoggetLog () const
 Get named logger.
virtual void setGenSpecificInitialState (int p1=PROTON, double e1=7000.0, int p2=PROTON, double e2=7000.0)=0
 Set initial state implementation details.
virtual void initialize ()
 Initialise.
virtual void clearEvent (HepMC::GenEvent &evt)
 Clear the supplied event.

Protected Attributes

double _crossSection
bool _initialstateset
 Flag for detecting whether the setInitialState method has run.
bool _initialized
 Flag for detecting whether the initialization method has run.
map< PdgCode, std::string > _particleNames
 Collection of translated names for particles.
string _myName
 Generator name.

Private Attributes

GeneratorState _myState
string _myVersion
bool _versionSet

Detailed Description

Author:
Andy Buckley

Definition at line 33 of file Generator.hh.


Member Enumeration Documentation

enum Result

Really just syntactic sugar for bool returns from setParam.

Enumerator:
SUCCESS 
FAILURE 

Definition at line 37 of file Generator.hh.

00037 { SUCCESS=1, FAILURE=0 };


Constructor & Destructor Documentation

Generator (  )  [inline]

Standard constructor.

Definition at line 41 of file Generator.hh.

00042                 :
00043       _initialstateset(false),
00044       _initialized(false),
00045       _myName("GENERATOR"),
00046       _versionSet(false)
    { }

virtual ~Generator (  )  [inline, virtual]

Destructor.

Definition at line 50 of file Generator.hh.

00050 { }


Member Function Documentation

virtual void clearEvent ( HepMC::GenEvent &  evt  )  [inline, protected, virtual]

Clear the supplied event.

Definition at line 275 of file Generator.hh.

Referenced by Generator::makeEvent(), FHerwigJimmy::makeEvent(), and AlpGenFHerwigJimmy::makeEvent().

00275                                                 {
00276       evt.clear();
00277     }

virtual void finalize (  )  [pure virtual]

Finalise.

Implemented in AlpGen, Ariadne, Cascade, Charybdis, FHerwig, FHerwigJimmy, FPythia, Phojet, and Rapgap.

virtual const double getCrossSection (  )  [inline, virtual]

Return the generated cross section in pb.

Reimplemented in Ariadne, Cascade, FHerwig, FPythia, Phojet, and Rapgap.

Definition at line 243 of file Generator.hh.

References Generator::_crossSection, Generator::getName(), and MSG_ERROR.

Referenced by Generator::getState().

00243                                            {
00244       MSG_ERROR("getCrossSection not implemented in generator " << getName());
00245       throw runtime_error("Tried to access cross-section in Generator base class");
00246       return _crossSection;
00247     }

virtual const std::string getName (  )  const [inline, virtual]

Get the generator name.

Reimplemented in Ariadne, Cascade, FHerwigJimmy, FPythia, Phojet, and Rapgap.

Definition at line 96 of file Generator.hh.

References Generator::_myName.

Referenced by Generator::getCrossSection(), Generator::getLog(), Generator::getPDFMember(), Generator::getPDFScheme(), Generator::getPDFSet(), and Generator::getState().

00096                                             {
00097       return _myName;
00098     }

virtual int getPDFMember ( PdgCode  pid  )  [inline, virtual]

Get the PDF id number for a given particle.

Reimplemented in Ariadne, FHerwig, FPythia, and Phojet.

Definition at line 132 of file Generator.hh.

References Generator::getName().

Referenced by Generator::getState().

00132                                           {
00133       throw runtime_error("Have not implemented getPDFMember in " + getName());
00134     }

virtual std::string getPDFScheme ( PdgCode  pid  )  const [inline, virtual]

Get the PDF scheme used by the generator (LHAPDF or other).

Reimplemented in Ariadne, FHerwig, FPythia, and Phojet.

Definition at line 138 of file Generator.hh.

References Generator::getName().

Referenced by Generator::getState().

00138                                                       {
00139       throw runtime_error("Have not implemented getPDFScheme in " + getName());
00140     }

virtual std::string getPDFSet ( PdgCode  pid  )  [inline, virtual]

Get the PDF set used by the generator, e.g. HWLHAPDF (for herwig) or one of the default sets.

Reimplemented in Ariadne, FHerwig, FPythia, and Phojet.

Definition at line 126 of file Generator.hh.

References Generator::getName().

Referenced by Generator::getState().

00126                                              {
00127       throw runtime_error("Have not implemented getPDFSet in " + getName());
00128     }

virtual const GeneratorState& getState (  )  [inline, virtual]

Get a generator state object.

Definition at line 72 of file Generator.hh.

References Generator::_myState, GeneratorState::addPDF(), GeneratorState::getBeams(), Generator::getCrossSection(), Generator::getName(), Generator::getPDFMember(), Generator::getPDFScheme(), Generator::getPDFSet(), Generator::getVersion(), PDF::member, Beam::name, PDF::particleId, PDF::scheme, PDF::set, GeneratorState::setCrossSection(), GeneratorState::setName(), and GeneratorState::setVersion().

00072                                              {
00073       string myName = getName();
00074       _myState.setName(myName);
00075       _myState.setVersion(getVersion());
00076       _myState.setCrossSection(getCrossSection());
00077       PDF pdf;
00078       foreach (Beam b, _myState.getBeams()) {
00079         pdf.particleId = b.name;
00080         pdf.set = getPDFSet(b.name);
00081         pdf.member = getPDFMember(b.name);
00082         pdf.scheme = getPDFScheme(b.name);
00083         _myState.addPDF(pdf);
00084       }
00085       return _myState;
00086     }

virtual const std::string getVersion (  )  [inline, virtual]

Get the generator version. This implementation is used as a last resort to determine the generator version. Ideally a specific generator will know its own version and overwrite this. Some generators (e.g. FHerwig) don't know this.

Todo:
This getName() doesn't get used polymophically: fix it!

Reimplemented in Ariadne, FPythia, and Phojet.

Definition at line 112 of file Generator.hh.

References Generator::_myVersion, Generator::_versionSet, and MSG_ERROR.

Referenced by Generator::getState().

00112                                          {
00113       if (!_versionSet) {
00115         MSG_ERROR("You asked the generator " //<< getName()
00116                   << " what version it is, but it doesn't know!\n"
00117                   << "You should set the version with a call to setVersion(string)");
00118         throw runtime_error("Version unknown for generator");
00119       }
00120       return _myVersion;
00121     }

virtual void initialize (  )  [inline, protected, virtual]

Initialise.

Reimplemented in Ariadne, Cascade, FHerwig, FHerwigJimmy, FPythia, Phojet, and Rapgap.

Definition at line 269 of file Generator.hh.

References Generator::_initialstateset, and Generator::setInitialState().

Referenced by Generator::makeEvent().

00269                               {
00270       if (!_initialstateset) setInitialState();
00271     }

virtual void makeEvent ( HepMC::GenEvent &  evt  )  [inline, virtual]

Run one event.

Reimplemented in AlpGenFHerwig, AlpGenFHerwigJimmy, Ariadne, Cascade, FHerwig, FHerwigJimmy, FPythia, Phojet, and Rapgap.

Definition at line 235 of file Generator.hh.

References Generator::_initialized, Generator::_myState, GeneratorState::addEvent(), Generator::clearEvent(), and Generator::initialize().

Referenced by Run::makeEvent().

00235                                                {
00236       if (!_initialized) initialize();
00237       clearEvent(evt);
00238       _myState.addEvent();
00239     }

virtual void setGenSpecificInitialState ( int  p1 = PROTON,
double  e1 = 7000.0,
int  p2 = PROTON,
double  e2 = 7000.0 
) [protected, pure virtual]

Set initial state implementation details.

Implemented in AlpGen, Ariadne, Cascade, Charybdis, FHerwig, FPythia, Phojet, and Rapgap.

Referenced by Generator::setInitialState().

void setInitialState ( int  p1 = PROTON,
double  e1 = 7000.0,
int  p2 = PROTON,
double  e2 = 7000.0 
) [inline]

Define initial state.

Todo:
Make sure it was successful - exception handling

Definition at line 54 of file Generator.hh.

References Generator::_initialstateset, Generator::_myState, Beam::energy, Beam::name, Beam::position, GeneratorState::setBeams(), and Generator::setGenSpecificInitialState().

Referenced by Generator::initialize().

00056     {
00057       setGenSpecificInitialState(p1, e1, p2, e2);
00059       _initialstateset = true;
00060       Beam beam1, beam2;
00061       beam1.name = p1;
00062       beam2.name = p2;
00063       beam1.energy = e1;
00064       beam2.energy = e2;
00065       beam1.position = 1;
00066       beam2.position = 2;
00067       _myState.setBeams(beam1, beam2);
00068     }

virtual bool setParam ( const std::string &  name,
const std::string &  value 
) [inline, virtual]

Pass a string-valued parameter to the generator.

Definition at line 224 of file Generator.hh.

References Generator::_initialized, Generator::_myState, MSG_ERROR, and GeneratorState::setParam().

00224                                                                          {
00225       if (_initialized) {
00226         MSG_ERROR("Can't set parameter " << name << ": generator has already been initialized");
00227         throw runtime_error("Tried to set param after generator initialization");
00228       }
00229       _myState.setParam(name, value);
00230       return true;
00231     }

virtual bool setParam ( const std::string &  name,
const bool &  value 
) [inline, virtual]

Pass a bool-valued parameter to the generator.

Definition at line 214 of file Generator.hh.

References Generator::_initialized, MSG_ERROR, Generator::setParam(), and AGILe::toString().

00214                                                                     {
00215       if (_initialized) {
00216         MSG_ERROR("Can't set parameter " << name << ": generator has already been initialized");
00217         throw runtime_error("Tried to set param after generator initialization");
00218       }
00219       return setParam(name, toString(value));
00220     }

virtual bool setParam ( const std::string &  name,
const float &  value 
) [inline, virtual]

Pass a double/float-valued parameter to the generator.

Definition at line 204 of file Generator.hh.

References Generator::_initialized, MSG_ERROR, Generator::setParam(), and AGILe::toString().

00204                                                                      {
00205       if (_initialized) {
00206         MSG_ERROR("Can't set parameter " << name << ": generator has already been initialized");
00207         throw runtime_error("Tried to set param after generator initialization");
00208       }
00209       return setParam(name, toString(value));
00210     }

virtual bool setParam ( const std::string &  name,
const double &  value 
) [inline, virtual]

Pass a double/float-valued parameter to the generator.

Definition at line 194 of file Generator.hh.

References Generator::_initialized, MSG_ERROR, Generator::setParam(), and AGILe::toString().

00194                                                                       {
00195       if (_initialized) {
00196         MSG_ERROR("Can't set parameter " << name << ": generator has already been initialized");
00197         throw runtime_error("Tried to set param after generator initialization.");
00198       }
00199       return setParam(name, toString(value));
00200     }

virtual bool setParam ( const std::string &  name,
const unsigned long &  value 
) [inline, virtual]

Pass an int-valued parameter to the generator.

Definition at line 184 of file Generator.hh.

References Generator::_initialized, MSG_ERROR, Generator::setParam(), and AGILe::toString().

00184                                                                              {
00185       if (_initialized) {
00186         MSG_ERROR("Can't set parameter " << name << ": generator has already been initialized");
00187       throw runtime_error("Tried to set param after generator initialization");
00188       }
00189       return setParam(name, toString(value));
00190     }

virtual bool setParam ( const std::string &  name,
const long &  value 
) [inline, virtual]

Pass an int-valued parameter to the generator.

Definition at line 174 of file Generator.hh.

References Generator::_initialized, MSG_ERROR, Generator::setParam(), and AGILe::toString().

00174                                                                     {
00175       if (_initialized) {
00176         MSG_ERROR("Can't set parameter " << name << ": generator has already been initialized");
00177         throw runtime_error("Tried to set param after generator initialization");
00178       }
00179       return setParam(name, toString(value));
00180     }

virtual bool setParam ( const std::string &  name,
const unsigned int &  value 
) [inline, virtual]

Pass an int-valued parameter to the generator.

Definition at line 164 of file Generator.hh.

References Generator::_initialized, MSG_ERROR, Generator::setParam(), and AGILe::toString().

00164                                                                             {
00165       if (_initialized) {
00166         MSG_ERROR("Can't set parameter " << name << ": generator has already been initialized");
00167         throw runtime_error("Tried to set param after generator initialization");
00168       }
00169       return setParam(name, toString(value));
00170     }

virtual bool setParam ( const std::string &  name,
const int &  value 
) [inline, virtual]

Pass an int-valued parameter to the generator.

Definition at line 154 of file Generator.hh.

References Generator::_initialized, MSG_ERROR, and AGILe::toString().

Referenced by Generator::setParam().

00154                                                                    {
00155       if (_initialized) {
00156         MSG_ERROR("Can't set parameter " << name << ": generator has already been initialized");
00157         throw runtime_error("Tried to set param after generator initialization");
00158       }
00159       return setParam(name, toString(value));
00160     }

virtual void setSeed ( const int  value  )  [inline, virtual]

Set the random number generator seed.

Reimplemented in Ariadne, FHerwig, FPythia, and Phojet.

Definition at line 144 of file Generator.hh.

References Generator::_initialized, Generator::_myState, GeneratorState::addSeed(), and MSG_ERROR.

00144                                           {
00145       if (_initialized) {
00146         MSG_ERROR("Can't set seed: generator has already been initialized");
00147         throw (runtime_error("Tried to set RNG seed after generator initialization"));
00148       }
00149       _myState.addSeed(value);
00150     }

virtual void setState ( const GeneratorState state  )  [inline, virtual]

Setup the generator from a generator state object.

Definition at line 90 of file Generator.hh.

00090                                                        {
00091       throw runtime_error("This ain't ready yet, it's just here as an interface placeholder. Sorry.");
00092     }

virtual void setVersion ( const std::string &  version  )  [inline, virtual]

Set the generator version.

Definition at line 102 of file Generator.hh.

References Generator::_myVersion, and Generator::_versionSet.

Referenced by AGILe::Loader::createGen().

00102                                                       {
00103       _myVersion = version;
00104       _versionSet = true;
00105     }


Member Data Documentation

bool _initialstateset [protected]

Flag for detecting whether the setInitialState method has run.

Definition at line 285 of file Generator.hh.

Referenced by Generator::initialize(), and Generator::setInitialState().

string _myVersion [private]

Definition at line 301 of file Generator.hh.

Referenced by Generator::getVersion(), and Generator::setVersion().

bool _versionSet [private]

Definition at line 303 of file Generator.hh.

Referenced by Generator::getVersion(), and Generator::setVersion().


The documentation for this class was generated from the following file:
Generated on Tue Mar 6 10:39:41 2012 for AGILe - A Generator Interface Library (+ executable) by  doxygen 1.6.3