agile is hosted by Hepforge, IPPP Durham

Cascade Class Reference

#include <Cascade.hh>

Inheritance diagram for Cascade:
Collaboration diagram for Cascade:

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

 Cascade ()
 Standard constructor.
virtual ~Cascade ()
 Destructor.
void setGenSpecificInitialState (PdgCode p1=PROTON, double e1=6000.0, PdgCode p2=PROTON, double e2=7000.0)
 Set up initial state from supplied params.
virtual bool setParam (const string &name, const string &value)
 Pass an string parameter to the generator.
virtual const string getName () const
 Generator name.
void makeEvent (HepMC::GenEvent &evt)
 Run the generator for one event.
virtual const double getCrossSection ()
 Set the random number generator seed.
void finalize ()
 Tidy up after ourselves.
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 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.

Protected Member Functions

void initialize ()
 Set up default params etc.
void fillEvent (HepMC::GenEvent &evt)
 Fill a HepMC event.
LoggetLog () const
 Get named logger.
virtual void clearEvent (HepMC::GenEvent &evt)
 Clear the supplied event.

Protected Attributes

string _particleName1
 Internal storage of initial state params.
string _particleName2
double _e1
double _e2
int _nevt
 Event counter.
HepMC::IO_HEPEVT _hepevt
 HEPEVT->HepMC converter.
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 Cascade interface

Author:
Andy Buckley
Holger Schulz

Definition at line 13 of file Cascade.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

Cascade (  ) 

Standard constructor.

Definition at line 23 of file Cascade.cc.

References Cascade::_nevt.

00023                    {
00024     HepMC::HEPEVT_Wrapper::set_max_number_entries(4000);
00025     HepMC::HEPEVT_Wrapper::set_sizeof_real(8);
00026 
00027     // Start counting events at 1.
00028     _nevt = 1;
00029   }

virtual ~Cascade (  )  [inline, virtual]

Destructor.

Definition at line 19 of file Cascade.hh.

00019 { }


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 fillEvent ( HepMC::GenEvent &  evt  )  [protected]

Fill a HepMC event.

Definition at line 119 of file Cascade.cc.

References Cascade::_hepevt, Log::DEBUG, FC_CAEFFIC, AGILe::fixHepMCUnitsFromGeVmm(), Cascade::getCrossSection(), Generator::getLog(), and xsec.

Referenced by Cascade::makeEvent().

00119                                             {
00120     _hepevt.fill_next_event(&evt);
00121     fixHepMCUnitsFromGeVmm(evt);
00122     #ifdef HEPMC_HAS_CROSS_SECTION
00123     const double xsecval = getCrossSection();
00124     const double xsecerr = FC_CAEFFIC.SD;
00125     getLog() << Log::DEBUG << "Writing cross-section = " << xsecval << " +- " << xsecerr << endl;
00126     HepMC::GenCrossSection xsec;
00127     xsec.set_cross_section(xsecval, xsecerr);
00128     evt.set_cross_section(xsec);
00129     #endif
00130   }

void finalize (  )  [virtual]

Tidy up after ourselves.

Implements Generator.

Definition at line 177 of file Cascade.cc.

References call_caend(), Generator::getLog(), and Log::INFO.

00177                          {
00178     getLog() << Log::INFO << "Finalising..." << endl;
00179     // Print out stats from run
00180     call_caend(20);
00181   }

const double getCrossSection (  )  [virtual]

Set the random number generator seed.

Return the generated cross section in pb.

Reimplemented from Generator.

Definition at line 132 of file Cascade.cc.

References Generator::_crossSection, and FC_CAEFFIC.

Referenced by Cascade::fillEvent().

00132                                        {
00133     _crossSection = FC_CAEFFIC.AVGI * 1000.0;
00134     return _crossSection;
00135   }

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

Generator name.

Reimplemented from Generator.

Definition at line 35 of file Cascade.hh.

00035                                         {
00036       return "Cascade";
00037     }

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     }

void initialize (  )  [protected, virtual]

Set up default params etc.

Reimplemented from Generator.

Definition at line 32 of file Cascade.cc.

References Generator::_initialized, call_caend(), call_cascade(), call_cascha(), call_casini(), call_ptime(), call_pytcha(), call_steer(), Generator::getLog(), Log::INFO, k, and Cascade::setParam().

00032                            {
00033     Generator::initialize();
00034     //Cascade::setParam("LEPI", "2212");
00035     //Cascade::setParam("HADI", "2212");
00036       //int ISEED = 213123;
00037       //int N1 = 0;
00038       //int N2 = 0;
00039       //call_rm48in(ISEED, N1, N2);
00040 
00041     // Initialise Cascade parameters
00042     getLog() << Log::INFO << "Initialise Cascade parameters (CASINI)..." << endl;
00043     call_casini();
00044     getLog() << Log::INFO << "CASINI is done..." << endl;
00045 
00046     // Read steering file
00047     getLog() << Log::INFO << "Now calling Steer..." << endl;
00048     getLog() << Log::INFO << "In case nothing happens from this point on," << endl;
00049     getLog() << Log::INFO << "make sure you specified a cascade steering file on CL:" << endl;
00050     getLog() << Log::INFO << "agile-runmc CascadePythia6:423:HEAD < steer_pp ... " << endl;
00051     call_steer();
00052     getLog() << Log::INFO << "Steer is done..." << endl;
00053 
00054     // Change standard parameters of Cascade
00055     getLog() << Log::INFO << "Change standard Cascade parameters (CASCHA)..." << endl;
00056     call_cascha();
00057     getLog() << Log::INFO << "CASCHA is done..." << endl;
00058 
00059     // Change standard parameters of Pythia
00060     getLog() << Log::INFO << "Change standard Pythia parameters (PYTCHA)..." << endl;
00061     call_pytcha();
00062     getLog() << Log::INFO << "PYTCHA is done..." << endl;
00063     //Cascade::setParam("IFPS", 3);
00064 
00065     // Switch on QCD processes by default
00066     //getLog() << Log::INFO << "Setup basic processes..." << endl;
00067     //Cascade::setParam("IPRO", 18);
00068     //Cascade::setParam("IDIR", 0);  // Don't do DIS but diffractive stuff by default
00069     //Cascade::setParam("INTER", 2);  // Switch to charged current interaction
00073 
00074     // Perform internal Cascade remnant treatment
00075     Cascade::setParam("ILHA", 0);
00076 
00077     // Set time
00078     getLog() << Log::INFO << "Calling PTIME..." << endl;
00079     const char* name = "cascade";
00080     int j = 1;
00081     int k = 0;
00082     call_ptime(name, j, k);
00083 
00084     // Run cascade
00085     getLog() << Log::INFO << "Now performing basic cross-section integration (CASCADE)..." << endl;
00086     call_cascade();
00087     getLog() << Log::INFO << "CASCADE is done..." << endl;
00088 
00089     // Summary of integration result
00090     call_caend(1);
00091 
00092     _initialized = true;
00093   }

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

Run the generator for one event.

Reimplemented from Generator.

Definition at line 104 of file Cascade.cc.

References Cascade::_nevt, call_event(), call_pyhepc(), Log::DEBUG, Cascade::fillEvent(), and Generator::getLog().

00104                                             {
00105     Generator::makeEvent(evt);
00106     getLog() << Log::DEBUG << "Fill event Nr: " << _nevt << endl;
00107     call_event();
00108     getLog() << Log::DEBUG << "Call pyhepc " << endl;
00109     call_pyhepc(1);
00110 
00111     // fill the event using HepMC
00112     Cascade::fillEvent(evt);
00113     evt.set_event_number(_nevt);
00114     // Increment an event counter (Cascade does not count for itself (?)).
00115     _nevt++;
00116   }

void setGenSpecificInitialState ( PdgCode  p1 = PROTON,
double  e1 = 6000.0,
PdgCode  p2 = PROTON,
double  e2 = 7000.0 
) [virtual]

Set up initial state from supplied params.

Implements Generator.

Definition at line 95 of file Cascade.cc.

References Generator::getLog(), Log::INFO, and Cascade::setParam().

00095                                                                                        {
00096     getLog() << Log::INFO << "Setting initial state..." << endl;
00097     Cascade::setParam("KBE1", p1);
00098     Cascade::setParam("KBE2", p2);
00099     Cascade::setParam("PBE1", e1);
00100     Cascade::setParam("PBE2", e2);
00101   }

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 
) [virtual]

Pass an string parameter to the generator.

Definition at line 138 of file Cascade.cc.

References AGILe::asDouble(), AGILe::asInt(), Log::ERROR, FC_CABEAM, FC_CAHERUP, FC_CAINPU, Generator::getLog(), Log::INFO, and Generator::SUCCESS.

Referenced by Cascade::initialize(), and Cascade::setGenSpecificInitialState().

00138                                                                 {
00139     Generator::setParam(name, value);
00140 
00142     if (name == "PBE1") {
00143       getLog() << Log::INFO << "Setting ... (PBE1) = " << value << endl;
00144       FC_CABEAM.PBEAM[0] = -1*asDouble(value);
00145     }
00146     else if (name == "PBE2") {
00147       getLog() << Log::INFO << "Setting ... (PBE2) = " << value << endl;
00148       FC_CABEAM.PBEAM[1] = asDouble(value);
00149     }
00150 
00152     else if (name == "IFPS") {
00153       getLog() << Log::INFO << "Setting ... (IFPS) = " << value << endl;
00154       FC_CAINPU.IFPS = asInt(value);
00155     }
00156     else if (name == "ILHA") {
00157       getLog() << Log::INFO << "Setting ... (ILHA) = " << value << endl;
00158       FC_CAHERUP.Ilha = asInt(value);
00159     }
00160     else if (name == "KBE1") {
00161       getLog() << Log::INFO << "Setting ... (KBE1) = " << value << endl;
00162       FC_CABEAM.KBEAM[0] = asInt(value);
00163     }
00164     else if (name == "KBE2") {
00165       getLog() << Log::INFO << "Setting ... (KBE2) = " << value << endl;
00166       FC_CABEAM.KBEAM[1] = asInt(value);
00167     }
00168 
00169     else {
00170       getLog() << Log::ERROR << "Cascade doesn't have a parameter called " << name << endl;
00171       //return FAILURE;
00172     }
00173     return SUCCESS;
00174   }

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

double _e1 [protected]

Definition at line 70 of file Cascade.hh.

double _e2 [protected]

Definition at line 70 of file Cascade.hh.

HepMC::IO_HEPEVT _hepevt [protected]

HEPEVT->HepMC converter.

Definition at line 76 of file Cascade.hh.

Referenced by Cascade::fillEvent().

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().

int _nevt [protected]

Event counter.

Definition at line 73 of file Cascade.hh.

Referenced by Cascade::Cascade(), and Cascade::makeEvent().

string _particleName1 [protected]

Internal storage of initial state params.

Definition at line 69 of file Cascade.hh.

string _particleName2 [protected]

Definition at line 69 of file Cascade.hh.


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