9 #ifndef ThePEG_EventGenerator_H
10 #define ThePEG_EventGenerator_H
13 #include "ThePEG/Config/ThePEG.h"
14 #include "ThePEG/Utilities/Named.h"
15 #include "EventGenerator.fh"
16 #include "RandomGenerator.h"
17 #include "ThePEG/Repository/UseRandom.h"
18 #include "ThePEG/Repository/Strategy.h"
19 #include "ThePEG/Repository/CurrentGenerator.fh"
20 #include "ThePEG/Utilities/ClassDescription.h"
21 #include "ThePEG/Handlers/EventHandler.fh"
22 #include "ThePEG/Analysis/FactoryBase.fh"
24 #include "EventGenerator.xh"
180 void go(
long next = 1,
long maxevent = -1,
bool tics =
false);
237 virtual void dump()
const;
399 template <
typename T>
414 template <
typename T>
423 template <
typename T>
476 void setup(
string newRunName, ObjectSet & newObjects,
477 ParticleMap & newParticles, MatcherSet & newMatchers);
484 virtual void doGo(
long next,
long maxevent,
bool tics);
500 void tic(
long currev = 0,
long totev = 0)
const;
671 string cmd,
string value);
710 string cmd,
string value);
1158 struct ClassTraits<EventGenerator>:
public ClassTraitsBase<EventGenerator> {
1160 static string className() {
return "ThePEG::EventGenerator"; }
1167 #ifndef ThePEG_TEMPLATES_IN_CC_FILE
1168 #include "EventGenerator.tcc"
bool loadMain(string file)
Dynamically load the Main class in the given file, making it run its Init() method where it may use t...
const MatcherSet & matchers() const
Return a reference to the complete list of matchers in this generator.
virtual ~EventGenerator()
Destructor.
int maxWarnings
The maximum number of warnings reported of each type.
tStrategyPtr strategy() const
Return a pointer to the strategy object containing a set of non-default particles to use...
void currentEventHandler(tEHPtr eh)
Set the currently active EventHandler.
PID is a helper class implementing the type of PDG particle ids.
PDVector theQuickParticles
A vector of particles indexed by the id number for quick access.
virtual EventPtr doGenerateEvent(tEventPtr)
Finish generating an event constructed from the outside.
PersistentIStream is used to read persistent objects from a stream where they were previously written...
Ptr< T >::pointer getObject(string name) const
Return a pointer to an object of type T present in this run given its full name.
static void Init()
Standard Init function used to initialize the interface.
vector< string > theGlobalLibraries
The global libraries needed for objects used in this EventGenerator.
void setup(string newRunName, ObjectSet &newObjects, ParticleMap &newParticles, MatcherSet &newMatchers)
Finish the setup of an event generator run.
virtual void doInitialize()
Initialize this generator.
tPDPtr findParticle(string pdgname) const
Find a particle in this run, using its PDG name.
double weightSum
The sum of the weights of the events produced so far.
ostream & out()
This stream should be used for output of information and statistics of an EventGenerator run in the f...
void finalize()
Indicate that the run has ended and call finish() for all objects including this one.
void flushOutputFile()
Flush the content of the internal output string stream to the .out file.
SMPtr theStandardModel
Pointer to an object containing standard model parameters.
void persistentOutput(PersistentOStream &os) const
Function used to write out object persistently.
void tic(long currev=0, long totev=0) const
Write out the number of events generated and the elapsed time in suitable periods.
long theNumberOfEvents
Number of events to be generated in this run.
const ObjectMap & objectMap() const
Return the map of objects used in this run indexed by their name.
virtual void doinit()
Initialize this object after the setup phase before saving an EventGenerator to disk.
tEvtManipPtr manipulator() const
Return the EventManipulator used in the run.
DMPtr constructDecayMode(string &tag)
Used internally by preinitCreateDecayMode();.
virtual void doinitrun()
Initialize this object.
void addTag(string tag)
Append a tag to the run name.
ClassTraitsType is an empty, non-polymorphic, base class.
tcEventPtr currentEvent() const
Return the event being generated.
void currentStepHandler(tStepHdlPtr sh)
Set the currently active step handler.
ostringstream theOutStream
A string stream used as a buffer for messages written to the .out file.
The Event class contains all Particles produced in the generation of an event.
EHPtr theEventHandler
Pointer to the event handler used to generate the indivudual events.
vector< IPtr > theDefaultObjects
A vector of default objects.
bool preinitRegister(IPtr obj, string fullname)
Register a new object to be included in the run currently being initialized.
long ieve
The current event number;.
string path() const
The directory in which the filename() is located.
ostringstream theMiscStream
A stream to be used to redirect cout for external modules which prints out messages there...
string theRunName
The name of this run.
A concreate implementation of ClassDescriptionBase describing a concrete class with persistent data...
CurrentGenerator * theCurrentGenerator
The CurrentGenerator object constructed for the duration of an EventGenerator run so that the default...
CrossSection histogramScale() const
Histogram scale.
tStepHdlPtr currentStepHandler() const
Get the currently active step handler.
tPMPtr findMatcher(string name) const
Find a matcher in this run given its name.
ExceptionMap theExceptions
A map of all Exceptions which have been caught by the event generator and the number of time each exc...
double sumWeights() const
The sum of all weight of the events generated so far.
ObjectSet usedObjects
The set of objects which have actually been used in this run.
virtual IBPtr clone() const
Make a simple clone of this object.
string name() const
Returns the name of this object, without the path.
PersistentOStream is used to write objects persistently to a stream from which they can be read in ag...
void N(long n)
Set number of events to be generated.
void setLocalParticles(PDPtr pd, int)
Utility function for the interface.
string defPath() const
Utility function for the interface.
This UseRandom class keeps a static stack of RandomGenerator objects which can be used anywhere by an...
const ParticleMap & particles() const
Return a reference to the complete map of particle data objects in this generator, indexed by their id numbers.
EvtManipPtr theEventManipulator
A pointer to an optional event manipulator object.
ObjectSet & objects()
Return the set of all objects to be used in this run.
bool logException(const Exception &, tcEventPtr)
Log a given exception.
TransientConstRCPtr is a simple wrapper around a bare const pointer which can be assigned to and from...
Ptr< T >::pointer getDefault() const
Return the default object for class T.
ofstream & logfile()
Return a reference to the log file stream.
RandomGenerator & random() const
Return a reference to the default RandomGenerator object in this run.
TransientRCPtr is a simple wrapper around a bare pointer which can be assigned to and from an RCPtr a...
virtual IBPtr fullclone() const
Make a clone of this object, possibly modifying the cloned object to make it sane.
ostream & log()
Return a reference to the stream connected to the file for logging information.
void use(const Interfaced &i)
Register a given object as used.
void setSeed(long seed)
Set the random seed for the global random number generator.
ObjectMap theObjectMap
All objects to be used in this run mapped to their name.
Repository inherits from the BaseRepository class.
int logNonDefault
List all modified interfaces in the log file.
tDMPtr preinitCreateDecayMode(string tag)
Create a decay mode according to the given tag.
long N() const
The number of events to be generated in this run.
T1 dynamic_ptr_cast(const T2 &t2)
Replacement for the standard dynamic_cast.
ObjectMap & objectMap()
Return the map of all objects to be used in this run indexed by their name.
virtual void setSeed(long seed)=0
Reset the underlying random engine with the given seed.
virtual void dump() const
Dump the full state of the current run - including the number of generated events, so that it can be fully continued from this point.
This is the main namespace within which all identifiers in ThePEG are declared.
RandomGenerator is an interface to the CLHEP::RandomEngine classes.
int count(const Exception &)
Increase and return the count for the given exception.
const ObjectSet & used() const
Return a reference to the set of objects which have been registered as used during the current run...
void logWarning(const Exception &)
Log a given exception.
ParticleMap theLocalParticles
Map of non-default particles used in this EventGenerator.
HistFacPtr theHistogramFactory
A pointer to an associated factory objects for handling histograms to be used by AnalysisHandlers.
tEHPtr theCurrentEventHandler
The currently active EventHandler.
virtual Energy maximumCMEnergy() const
Return the maximum center of mass energy possible for an event.
int printEvent
If the debug level is higher than 0, print the first 'printEvent' events to the logfile.
ofstream theReffile
A reference to the reference file stream.
virtual void doGo(long next, long maxevent, bool tics)
Run this EventGenerator session.
vector< PDPtr > getLocalParticles() const
Utility function for the interface.
void delLocalParticles(int place)
Utility function for the interface.
void insLocalParticles(PDPtr pd, int)
Utility function for the interface.
ostream & ref()
Return a reference to the stream connected to the filea for references from used objects.
void openOutputFiles()
Open all ouput files.
void path(string f)
Set the directory where the output files will be stored.
void go(long next=1, long maxevent=-1, bool tics=false)
Run this EventGenerator session.
ostream & misc()
Return a reference to a stream to be used to redirect cout for external modules which prints out mess...
IPtr preinitCreate(string classname, string fullname, string libraries="")
Create a new Interfaced object to be used in the run being initialized.
const ParticleMap & localParticles() const
Access the special particles used in this generator.
long debugEvent
If the debug level is higher than 0, step up to the highest debug level just before the event with nu...
void printException(const Exception &)
Print the message of an exception to the log file.
tHistFacPtr histogramFactory() const
Return a pointer to an associated factory objects for handling histograms to be used by AnalysisHandl...
AnalysisVector theAnalysisHandlers
A vector of all analysis handlers to be called after each event.
QTY< 0, 1, 0 >::Type Energy
Energy.
Ptr< T >::pointer getPtr(const T &) const
Return a garbage collected pointer to a given object.
tDMPtr findDecayMode(string tag) const
Find a decaymode given a decay tag.
string filename() const
The base filename used in this run.
EventPtr shoot()
Generate one event.
MatcherSet theMatchers
The set of all matchers to be used in this run.
UseRandom * theCurrentRandom
The UseRandom object constructed for the duration of an EventGenerator run so that the default random...
void setPath(string newPath)
Utility function for the interface.
PDPtr getParticleData(PID id) const
Return a pointer to the ParticleData object corresponding to the given id number. ...
bool preinitializing
A flag to tell if we are in the pre-initialization phase where objects with preInitialize() functions...
void checkSignalState()
Check if there has been an interrupt signal from the OS.
string runName() const
Return the name assigned to this run.
int maxErrors
The maximum number of warnings and errors reported of each type.
ParticleMap theParticles
The map of all particles to be used in this run, indexed by the id number.
long theQuickSize
Only particles with id number less than theQuickSize are available in theQuickParticles.
ofstream & reffile()
Return a reference to the reference file stream.
long dumpPeriod
If the debug level is higher than 0, dump the complete state of this run to the default dump file eve...
tEHPtr eventHandler() const
Return a pointer to the EventHandler.
string thePath
The directory where the input and output files resides.
string doSaveRun(string)
Isolate, initialize and save this generator to a file.
string doMakeRun(string)
Isolate and initialize this generator.
RCPtr is a reference counted (smart) pointer.
bool useStdout
Whether to use files or stdout for logging and output.
The Interfaced class is derived from the InterfacedBase class adding a couple of things particular to...
static ClassDescription< EventGenerator > initEventGenerator
Describe an abstract class with persistent data.
virtual void dofinish()
Finalize this object.
EventPtr generateEvent(Event &event)
Finish generating an event which has already been partially constructed from the outside.
Exception is the base class for all exceptions to be used in ThePEG.
ofstream & outfile()
Return a reference to the output file stream.
const vector< string > & globalLibraries() const
The global libraries needed for objects used in this EventGenerator.
tStepHdlPtr theCurrentStepHandler
The currently active step handler.
PPtr getParticle(PID id) const
Create a particle instance corresponding to the given id number.
ParticleMap & localParticles()
Access the special particles used in this generator.
This CurrentGenerator class keeps a static stack of EventGenerators which can be used anywhere by any...
CrossSection integratedXSec() const
The total integrated cross section of the processes generated in this run.
StrategyPtr theStrategy
Pointer to a strategy object with other non-default particles to be used in this EventGenerator.
void persistentInput(PersistentIStream &is, int version)
Function used to read in object persistently.
ObjectSet theObjects
The set of all objects to be used in this run.
void runName(string f)
Set the name of this run.
const ObjectSet & objects() const
Return the set of objects used in this run.
string theOutFileName
Remember the name of the file where the output should be sent.
vector< PDPtr > PDVector
A vector of pointers to ParticleData objects.
void generateReferences()
Print out the .tex file with descriptions of and references to all models used in the run...
static string className()
Return the name of class T.
This template class allows the compiler to check calculations with physical quantities for dimensiona...
IBPtr getPointer(string name) const
Return a pointer to an object present in this run given its full name.
int NthBase
The type of the BaseN'th base class (int means there are no further base classes).
void initialize()
Initialize this generator.
virtual EventPtr doShoot()
Generate one event.
void closeOutputFiles()
Close all ouput files.
map< pair< string, Exception::Severity >, int > ExceptionMap
A map of integers giving the number of times an exception of the key type has been thrown...
CrossSection integratedXSecErr() const
The error estimate for the total integrated cross section of the processes generated in this run...
AnalysisVector & analysisHandlers()
Return the vector of analysis objects to be used in the run.
ofstream theOutfile
A reference to the output file stream.
bool useStdOut() const
Has the generator been asked to redirect everything to standard output?
ofstream theLogfile
A reference to the log file stream.
long currentEventNumber() const
The number of the event currently being generated.
BaseClassTraits describes the base classes of the templated class.
RanGenPtr theRandom
Pointer to the default RandomGenerator to be used in this run.
const vector< IPtr > & defaultObjects() const
Return the vector of default objects.
tEHPtr currentEventHandler() const
Get the currently active EventHandler.
int theDebugLevel
The debug level.
EventGenerator()
Default constructor.
The EventGenerator class manages a whole event generator run.
tSMPtr standardModel() const
Return a pointer to the standard model parameters.
vector< AnaPtr > AnalysisVector
A vector of pointers to AnalysisHandler objects.
EventGenerator & operator=(const EventGenerator &)
Private and non-existent assignment operator.
string preinitInterface(string fullname, string ifcname, string cmd, string value)
Manipulate an interface of an Interfaced object.
The Step class contains information of all particles present after certain step in the event generati...