thepeg is hosted by Hepforge, IPPP Durham
ThePEG 2.3.0
Event.h
1// -*- C++ -*-
2//
3// Event.h is a part of ThePEG - Toolkit for HEP Event Generation
4// Copyright (C) 1999-2019 Leif Lonnblad
5//
6// ThePEG is licenced under version 3 of the GPL, see COPYING for details.
7// Please respect the MCnet academic guidelines, see GUIDELINES for details.
8//
9#ifndef ThePEG_Event_H
10#define ThePEG_Event_H
11// This is the decalaration of the Event class.
12
13#include "Particle.h"
14#include "StandardSelectors.h"
15#include "SubProcess.h"
16#include "ThePEG/Utilities/Named.h"
17#include "ThePEG/Utilities/AnyReference.h"
18
19namespace ThePEG {
20
37class Event : public EventRecordBase, public Named {
38
39public:
40
44 friend class EventHandler;
46 friend class Collision;
47
49 typedef map<tcColinePtr, int> ColourLineMap;
50
51public:
52
66 Event(const PPair & newIncoming, tcEventBasePtr newHandler = tcEventBasePtr(),
67 string newName = "", long newNumber = -1, double weight = 1.0);
68
72 Event(const Event&);
73
78
83 EventPtr clone() const;
84
85public:
86
91 tcEventBasePtr handler() const { return theHandler; }
92
103 template <class OutputIterator>
104 void select(OutputIterator r, const SelectorBase & s) const;
105
111 template <class OutputIterator>
112 void selectFinalState(OutputIterator r) const {
114 }
115
121 template <class Container>
122 void getFinalState(Container & c) const {
124 }
125
131 tPVector ret;
132 selectFinalState(back_inserter(ret));
133 return ret;
134 }
135
141 return collisions().empty() ? tCollPtr() : tCollPtr(collisions()[0]);
142 }
143
147 const CollisionVector & collisions() const { return theCollisions; }
148
154
159 const PPair & incoming() const { return theIncoming; }
160
162
167
174
179
184 long number() const { return theNumber; }
185
190
198
205
210
212
216 double weight() const { return theWeight; }
217
222 double optionalWeight(const string& name) const;
223
227 const map<string,double>& optionalWeights() const { return theOptionalWeights; }
228
232 void printGraphviz() const;
233
237 void weight(double w) { theWeight = w; }
238
242 void optionalWeight(const string& name, double value);
243
247 map<string,double>& optionalWeights() { return theOptionalWeights; }
248
252 void setInfo(tcEventBasePtr newHandler, string newName,
253 long newNumber, double weight);
254
259
264
265public:
266
270 bool hasMeta(const string& id) const {
271 return theMeta.find(id) != theMeta.end();
272 }
273
277 template<class T>
278 void meta(const string& id, T& ref) {
279 theMeta[id] = AnyReference(ref);
280 }
281
285 void eraseMeta(const string& id) {
286 theMeta.erase(id);
287 }
288
292 template<class T>
293 T& meta(const string& id) const {
294 return theMeta.find(id)->second.cast<T>();
295 }
296
297protected:
298
302 template <class Iterator>
303 void addParticles(Iterator first, Iterator last) {
304 while ( first != last ) addParticle(*first++);
305 }
306
311
318 if ( p ) allSubProcesses.insert(p);
319 }
320
325
331 void addStep(tStepPtr s) {
332 if ( s ) allSteps.insert(s);
333 }
334
339
347 void rebind(const EventTranslationMap & trans);
348
349public:
350
355
360
364 static void Init();
365
366private:
367
372
377
382
387
392
398
403
408
412 double theWeight;
413
417 map<string,double> theOptionalWeights;
418
423
427 map<string,AnyReference> theMeta;
428
429public:
430
435 virtual void debugme() const;
436
437private:
438
443
449
454 friend struct ClassTraits<Event>;
455
459 Event & operator=(const Event&) = delete;
460
461};
462
464ostream & operator<<(ostream &, const Event &);
465
467void printGraphviz(ostream &, tcEventPtr);
468
473template <>
474struct BaseClassTrait<Event,1>: public ClassTraitsType {
476 typedef EventRecordBase NthBase;
477};
478
481template <>
482struct ClassTraits<Event>: public ClassTraitsBase<Event> {
484 static string className() { return "ThePEG::Event"; }
486 static TPtr create() { return TPtr::Create(Event()); }
487};
488
491}
492
493#include "Collision.h"
494
496 return collisions().empty() ? ThePEG::tSubProPtr() :
498}
499
500namespace ThePEG {
501 template <class OutputIterator>
502 void Event::select(OutputIterator r, const SelectorBase & s) const {
503 if ( s.allCollisions() ) {
504 for ( CollisionVector::const_iterator it = theCollisions.begin();
505 it != theCollisions.end(); ++it ) (**it).select(r, s);
506 } else {
507 primaryCollision()->select(r, s);
508 }
509 }
510}
511
512#endif /* ThePEG_Event_H */
This file contains declarations of standard selector classes.
AnyReference is inspired by boost::any to hold a reference to an object of arbitrary type.
Definition: AnyReference.h:22
A concreate implementation of ClassDescriptionBase describing a concrete class with persistent data.
This is the decalaration of the Collision class.
Definition: Collision.h:34
The EventHandler is the base class used to implement event handlers in ThePEG.
Definition: EventHandler.h:63
The Event class contains all Particles produced in the generation of an event.
Definition: Event.h:37
static ClassDescription< Event > initEvent
Describe concrete class with persistent data.
Definition: Event.h:442
EventPtr clone() const
Returns a full clone of this Event.
Event(const Event &)
The copy constructor.
tCollPtr primaryCollision() const
Return a pointer to the primary Collision in this Event.
Definition: Event.h:140
void select(OutputIterator r, const SelectorBase &s) const
Extract particles from this event which satisfies the requirements given by an object of the Selector...
Definition: Event.h:502
void eraseMeta(const string &id)
Erase meta information.
Definition: Event.h:285
const PPair & incoming() const
Return a reference to the pair of colliding particles in the primary Collision of this Event.
Definition: Event.h:159
void persistentOutput(PersistentOStream &) const
Standard function for writing to a persistent stream.
double optionalWeight(const string &name) const
Return an optional named weight associated to this event.
void weight(double w)
Set the weight associated with this event.
Definition: Event.h:237
tcEventBasePtr theHandler
A pointer to the EventHandler which performed the generation of this Event.
Definition: Event.h:397
CollisionVector theCollisions
A vector of collisions in this Event.
Definition: Event.h:376
Event(const PPair &newIncoming, tcEventBasePtr newHandler=tcEventBasePtr(), string newName="", long newNumber=-1, double weight=1.0)
The standard constructor for an Event takes as arguments a pair of colliding particles (corresponding...
long theParticleNumber
Counter to keep track of particle numbering.
Definition: Event.h:422
tCollPtr newCollision()
Create a new Collision in this event and return a pointer to it.
void addParticles(Iterator first, Iterator last)
Add a range of particles to this Collision.
Definition: Event.h:303
void primaryCollision(tCollPtr c)
Set the primary collision in this Event.
map< tcColinePtr, int > ColourLineMap
Map colour lines to indices.
Definition: Event.h:49
map< string, double > & optionalWeights()
Access the optional named weights associated to this event.
Definition: Event.h:247
void removeDecay(tPPtr)
Remove (recursively) the decay products from a given Particle and add the particle to the list of fin...
void getFinalState(Container &c) const
Extract all final state particles in this Event.
Definition: Event.h:122
void addSubProcess(tSubProPtr p)
Add a new SubProcess to this Event.
Definition: Event.h:317
void cleanSteps()
Remove all steps which have no new particles introduced in them.
T & meta(const string &id) const
Retrieve meta information.
Definition: Event.h:293
double theWeight
The weight associated with this event.
Definition: Event.h:412
void printGraphviz() const
Print this Event in Graphviz format on the standard output.
int colourLineIndex(tcColinePtr) const
Return the index of the given colour line.
~Event()
The destructor.
map< string, AnyReference > theMeta
The meta information.
Definition: Event.h:427
StepSet allSteps
A set of all particles in this Event.
Definition: Event.h:381
void removeSubProcess(tSubProPtr p)
Remove a SubProcess from this Event.
Definition: Event.h:324
SubProcessSet allSubProcesses
A set of all sub-processes in this Event.
Definition: Event.h:386
void setInfo(tcEventBasePtr newHandler, string newName, long newNumber, double weight)
Set event info.
const map< string, double > & optionalWeights() const
Return the optional named weights associated to this event.
Definition: Event.h:227
Event()
Private default constructor must only be used by the PersistentIStream class via the ClassTraits<Even...
Definition: Event.h:448
Event & operator=(const Event &)=delete
The assignment operator is private and not implemented.
void optionalWeight(const string &name, double value)
Set an optional named weight associated to this event.
long number() const
Return the number assigned to this Event.
Definition: Event.h:184
tPVector getFinalState() const
Extract all final state particles in this Event.
Definition: Event.h:130
bool hasMeta(const string &id) const
Check for meta information.
Definition: Event.h:270
void persistentInput(PersistentIStream &, int)
Standard functions for reading from a persistent stream.
const CollisionVector & collisions() const
Return a possibly empty list of collisions in this Event.
Definition: Event.h:147
void removeEntry(tPPtr p)
Remove a given Particle entry.
void addStep(tStepPtr s)
Add a new Step to this Collision.
Definition: Event.h:331
void removeParticle(tPPtr)
Remove the given Particle from the Collision.
tSubProPtr primarySubProcess() const
Return a pointer to the primary SubProcess in the prinmary Collision in this Event.
Definition: Event.h:495
map< string, double > theOptionalWeights
Optional named weights.
Definition: Event.h:417
void rebind(const EventTranslationMap &trans)
Rebind to cloned objects.
tcEventBasePtr handler() const
Return a pointer to the EventHandler which produced this Event.
Definition: Event.h:91
virtual void debugme() const
Print out debugging information for this object on std::cerr.
tStepPtr newStep()
Create a new Step in the current Collision, which is a copy of the last Step (if any) and return a po...
void selectFinalState(OutputIterator r) const
Extract all final state particles in this Event.
Definition: Event.h:112
void transform(const LorentzRotation &)
Transform all particles in this Event.
void meta(const string &id, T &ref)
Set meta information.
Definition: Event.h:278
static void Init()
Standard Init function.
long theNumber
The number assigned to this Event.
Definition: Event.h:407
ParticleSet allParticles
A set of all particles in this Event.
Definition: Event.h:391
ColourLineMap theColourLines
Map of all registered colour lines to their index numbers.
Definition: Event.h:402
void addCollision(tCollPtr c)
Add a collision to this Event.
PPair theIncoming
The pair of colliding particles.
Definition: Event.h:371
void addParticle(tPPtr p)
Add a particle to this Collision.
double weight() const
Return the weight associated with this event.
Definition: Event.h:216
The LorentzRotation class combine a SpinOneLorentzRotation and a spin SpinHalfLorentzRotation to prov...
The Named class is a simple concrete base class to used by classes of objects with a name.
Definition: Named.h:24
const string & name() const
Return name.
Definition: Named.h:42
PersistentIStream is used to read persistent objects from a stream where they were previously written...
PersistentOStream is used to write objects persistently to a stream from which they can be read in ag...
RCPtr is a reference counted (smart) pointer.
Definition: RCPtr.h:60
static RCPtr Create()
Allocate and construct an object of class T and return a RCPtr to it.
Definition: RCPtr.h:120
TransientConstRCPtr is a simple wrapper around a bare const pointer which can be assigned to and from...
Definition: RCPtr.h:696
TransientRCPtr is a simple wrapper around a bare pointer which can be assigned to and from an RCPtr a...
Definition: RCPtr.h:519
Rebinder is a class associating pairs of pointers to objects.
Definition: Rebinder.h:27
Classes derived from the SelectorBase class are used to extract particles from an Event with Event::s...
Definition: SelectorBase.h:45
This is the main namespace within which all identifiers in ThePEG are declared.
Definition: FactoryBase.h:28
pair< PPtr, PPtr > PPair
A pair of pointers to Particle objects.
Definition: Containers.h:127
Ptr< EventRecordBase >::transient_const_pointer tcEventBasePtr
Alias for a transient pointer to const EventRecordBase.
Definition: EventConfig.h:49
set< PPtr, less< PPtr > > ParticleSet
A set of pointers to Particle.
Definition: EventConfig.h:76
set< StepPtr, less< StepPtr > > StepSet
A set of pointers to Step.
Definition: EventConfig.h:90
ThePEG::Ptr< SubProcess >::transient_pointer tSubProPtr
Alias for a transient pointer to SubProcess .
Definition: Pointers.h:86
vector< T > & operator<<(vector< T > &tv, const U &u)
Overload the left shift operator for vector to push_back objects to a vector.
Definition: Containers.h:179
vector< CollPtr > CollisionVector
A vector of pointers to Collision.
Definition: EventConfig.h:88
vector< tPPtr > tPVector
A vector of transient pointers to Particle objects.
Definition: Containers.h:82
ParticleSelector< FinalStateSelector > SelectFinalState
Typedef to declare a selector used to extract all final state particles from an event.
ThePEG::Ptr< Collision >::transient_pointer tCollPtr
Alias for a transient pointer to Collision .
Definition: Pointers.h:84
void printGraphviz(ostream &, tcEventPtr)
Print event tree in Graphviz format, ready for plotting.
std::insert_iterator< Cont > inserter(Cont &c)
Return an insert iterator for a given container.
Definition: std.h:141
set< SubProPtr, less< SubProPtr > > SubProcessSet
A set of pointers to SubProcess.
Definition: EventConfig.h:92
BaseClassTraits describes the base classes of the templated class.
Definition: ClassTraits.h:156
int NthBase
The type of the BaseN'th base class (int means there are no further base classes).
Definition: ClassTraits.h:161
Define the base class from which all (polymorphic) classes in ThePEG are derived.
Definition: ThePEG.h:54
static string className()
Return the name of class T.
Definition: ClassTraits.h:66
static TPtr create()
Create a T object and return a smart pointer to it.
Definition: ClassTraits.h:60
ThePEG::Ptr< T >::pointer TPtr
Alias for a reference counted pointer to T .
Definition: ClassTraits.h:54
ClassTraitsType is an empty, non-polymorphic, base class.
Definition: ClassTraits.h:30
The default concrete implementation of ClassTraitsBase.
Definition: ClassTraits.h:134