agile is hosted by Hepforge, IPPP Durham

AlpGen Class Reference

#include <AlpGen.hh>

Inheritance diagram for AlpGen:
Collaboration diagram for AlpGen:

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

 AlpGen ()
 Constructor.
 ~AlpGen ()
 Destructor.
bool setParam (const string &name, const string &value)
 Make sure that generic setParam is visible.
void finalize ()
 Finalise.
void setGenSpecificInitialState (int, double, int, double)
 Set initial state implementation details.
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.

Protected Member Functions

LoggetLog () const
 Get named logger.
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.

Detailed Description

Abstract base class for AlpGen interface

Author:
Andy Buckley

Definition at line 11 of file AlpGen.hh.


Member Enumeration Documentation

enum Result [inherited]

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

AlpGen (  )  [inline]

Constructor.

Definition at line 14 of file AlpGen.hh.

00014 { }

~AlpGen (  )  [inline]

Destructor.

Definition at line 17 of file AlpGen.hh.

00017 { }


Member Function Documentation

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

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     }

void finalize (  )  [inline, virtual]

Finalise.

Implements Generator.

Definition at line 26 of file AlpGen.hh.

00026 { }

virtual const double getCrossSection (  )  [inline, virtual, inherited]

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, inherited]

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, inherited]

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, inherited]

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, inherited]

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, inherited]

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, inherited]

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, inherited]

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, inherited]

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     }

void setGenSpecificInitialState ( int  p1,
double  e1,
int  p2,
double  e2 
) [inline, virtual]

Set initial state implementation details.

Implements Generator.

Definition at line 27 of file AlpGen.hh.

00027 { }

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

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, inherited]

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, inherited]

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, inherited]

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, inherited]

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, inherited]

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, inherited]

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, inherited]

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, inherited]

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     }

bool setParam ( const string &  name,
const string &  value 
)

Make sure that generic setParam is visible.

Pass a parameter to the generator.

Definition at line 21 of file AlpGen.cc.

References AGILe::asDouble(), AGILe::asInt(), Generator::FAILURE, FC_AHIO, FC_AHOPTS, Generator::getLog(), Log::INFO, and Generator::SUCCESS.

Referenced by AlpGenFPythia::setParam(), AlpGenFHerwigJimmy::setParam(), and AlpGenFHerwig::setParam().

00021                                                                {
00022     Generator::setParam(name, value);
00023 
00024     // Strings
00025     if (name == "ALPGENFILE") {
00026       getLog() << Log::INFO << "Setting ALPGENFILE = " << value << endl;
00027       size_t nch = (value.size() < 100) ? value.size() : 99;
00028       for (size_t i = 0; i < 100; i++) {
00029         if (i < nch) {
00030           FC_AHIO.FILENAME[i] = value.data()[i];
00031         } else {
00032           FC_AHIO.FILENAME[i] = ' ';
00033         }
00034       }
00035     }
00036 
00037     // Integers
00038     if (name == "IEXC") {
00039       getLog() << Log::INFO << "Setting ALPGEN IEXC = " << value << endl;
00040       FC_AHOPTS.IEXC = asInt(value);
00041     }
00042 
00043     // Doubles
00044     else if (name == "ETACLMAX") {
00045       getLog() << Log::INFO << "Setting ETACLMAX = " << value << endl;
00046       FC_AHOPTS.ETACLMAX = asDouble(value);
00047     }
00048 
00049     // Fallback
00050     else {
00051       //getLog() << Log::ERROR << "AlpGen doesn't have a parameter called " << name << endl;
00052       return FAILURE;
00053     }
00054     return SUCCESS;
00055   }

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

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, inherited]

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, inherited]

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 _initialized [protected, inherited]
bool _initialstateset [protected, inherited]

Flag for detecting whether the setInitialState method has run.

Definition at line 285 of file Generator.hh.

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


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