thepeg is hosted by Hepforge, IPPP Durham
ThePEG  2.1.5
Event.h
1 // -*- C++ -*-
2 //
3 // Event.h is a part of ThePEG - Toolkit for HEP Event Generation
4 // Copyright (C) 1999-2017 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 
18 namespace ThePEG {
19 
36 class Event : public EventRecordBase, public Named {
37 
38 public:
39 
43  friend class EventHandler;
45  friend class Collision;
46 
48  typedef map<tcColinePtr, int> ColourLineMap;
49 
50 public:
51 
65  Event(const PPair & newIncoming, tcEventBasePtr newHandler = tcEventBasePtr(),
66  string newName = "", long newNumber = -1, double weight = 1.0);
67 
71  Event(const Event&);
72 
76  ~Event();
77 
82  EventPtr clone() const;
83 
84 public:
85 
90  tcEventBasePtr handler() const { return theHandler; }
91 
102  template <class OutputIterator>
103  void select(OutputIterator r, const SelectorBase & s) const;
104 
110  template <class OutputIterator>
111  void selectFinalState(OutputIterator r) const {
112  select(r, SelectFinalState());
113  }
114 
120  template <class Container>
121  void getFinalState(Container & c) const {
123  }
124 
130  tPVector ret;
131  selectFinalState(back_inserter(ret));
132  return ret;
133  }
134 
140  return collisions().empty() ? tCollPtr() : tCollPtr(collisions()[0]);
141  }
142 
146  const CollisionVector & collisions() const { return theCollisions; }
147 
153 
158  const PPair & incoming() const { return theIncoming; }
159 
161 
166 
172  tStepPtr newStep();
173 
177  void transform(const LorentzRotation &);
178 
183  long number() const { return theNumber; }
184 
188  int colourLineIndex(tcColinePtr) const;
189 
196  void removeDecay(tPPtr);
197 
203  void removeParticle(tPPtr);
204 
208  void cleanSteps();
209 
211 
215  double weight() const { return theWeight; }
216 
221  double optionalWeight(const string& name) const;
222 
226  const map<string,double>& optionalWeights() const { return theOptionalWeights; }
227 
231  void printGraphviz() const;
232 
236  void weight(double w) { theWeight = w; }
237 
241  void optionalWeight(const string& name, double value);
242 
246  map<string,double>& optionalWeights() { return theOptionalWeights; }
247 
251  void setInfo(tcEventBasePtr newHandler, string newName,
252  long newNumber, double weight);
253 
257  void addCollision(tCollPtr c);
258 
262  void primaryCollision(tCollPtr c);
263 
264 protected:
265 
269  template <class Iterator>
270  void addParticles(Iterator first, Iterator last) {
271  while ( first != last ) addParticle(*first++);
272  }
273 
277  void addParticle(tPPtr p);
278 
285  if ( p ) allSubProcesses.insert(p);
286  }
287 
292 
298  void addStep(tStepPtr s) {
299  if ( s ) allSteps.insert(s);
300  }
301 
305  void removeEntry(tPPtr p);
306 
314  void rebind(const EventTranslationMap & trans);
315 
316 public:
317 
321  void persistentOutput(PersistentOStream &) const;
322 
326  void persistentInput(PersistentIStream &, int);
327 
331  static void Init();
332 
333 private:
334 
339 
344 
349 
354 
359 
365 
369  mutable ColourLineMap theColourLines;
370 
374  long theNumber;
375 
379  double theWeight;
380 
384  map<string,double> theOptionalWeights;
385 
390 
391 public:
392 
397  virtual void debugme() const;
398 
399 private:
400 
405 
410  Event() : theNumber(-1), theWeight(1.0), theParticleNumber(0) {}
411 
416  friend struct ClassTraits<Event>;
417 
421  Event & operator=(const Event&) = delete;
422 
423 };
424 
426 ostream & operator<<(ostream &, const Event &);
427 
429 void printGraphviz(ostream &, tcEventPtr);
430 
435 template <>
436 struct BaseClassTrait<Event,1>: public ClassTraitsType {
438  typedef EventRecordBase NthBase;
439 };
440 
443 template <>
444 struct ClassTraits<Event>: public ClassTraitsBase<Event> {
446  static string className() { return "ThePEG::Event"; }
448  static TPtr create() { return TPtr::Create(Event()); }
449 };
450 
453 }
454 
455 #include "Collision.h"
456 
458  return collisions().empty() ? ThePEG::tSubProPtr() :
460 }
461 
462 namespace ThePEG {
463  template <class OutputIterator>
464  void Event::select(OutputIterator r, const SelectorBase & s) const {
465  if ( s.allCollisions() ) {
466  for ( CollisionVector::const_iterator it = theCollisions.begin();
467  it != theCollisions.end(); ++it ) (**it).select(r, s);
468  } else {
469  primaryCollision()->select(r, s);
470  }
471  }
472 }
473 
474 #endif /* ThePEG_Event_H */
void persistentOutput(PersistentOStream &) const
Standard function for writing to a persistent stream.
tCollPtr primaryCollision() const
Return a pointer to the primary Collision in this Event.
Definition: Event.h:139
PersistentIStream is used to read persistent objects from a stream where they were previously written...
void addStep(tStepPtr s)
Add a new Step to this Collision.
Definition: Event.h:298
tPVector getFinalState() const
Extract all final state particles in this Event.
Definition: Event.h:129
tSubProPtr primarySubProcess() const
Return a pointer to the primary SubProcess in the prinmary Collision in this Event.
Definition: Event.h:457
void removeParticle(tPPtr)
Remove the given Particle from the Collision.
The EventHandler is the base class used to implement event handlers in ThePEG.
Definition: EventHandler.h:63
ParticleSet allParticles
A set of all particles in this Event.
Definition: Event.h:358
Define the base class from which all (polymorphic) classes in ThePEG are derived. ...
Definition: ThePEG.h:54
ClassTraitsType is an empty, non-polymorphic, base class.
Definition: ClassTraits.h:30
void selectFinalState(OutputIterator r) const
Extract all final state particles in this Event.
Definition: Event.h:111
The Event class contains all Particles produced in the generation of an event.
Definition: Event.h:36
Classes derived from the SelectorBase class are used to extract particles from an Event with Event::s...
Definition: SelectorBase.h:45
A concreate implementation of ClassDescriptionBase describing a concrete class with persistent data...
PersistentOStream is used to write objects persistently to a stream from which they can be read in ag...
TransientConstRCPtr is a simple wrapper around a bare const pointer which can be assigned to and from...
Definition: RCPtr.h:696
Ptr< EventRecordBase >::transient_const_pointer tcEventBasePtr
Alias for a transient pointer to const EventRecordBase.
Definition: EventConfig.h:49
The LorentzRotation class combine a SpinOneLorentzRotation and a spin SpinHalfLorentzRotation to prov...
TransientRCPtr is a simple wrapper around a bare pointer which can be assigned to and from an RCPtr a...
Definition: RCPtr.h:519
void removeDecay(tPPtr)
Remove (recursively) the decay products from a given Particle and add the particle to the list of fin...
long theNumber
The number assigned to this Event.
Definition: Event.h:374
Rebinder is a class associating pairs of pointers to objects.
Definition: Rebinder.h:27
void addSubProcess(tSubProPtr p)
Add a new SubProcess to this Event.
Definition: Event.h:284
long theParticleNumber
Counter to keep track of particle numbering.
Definition: Event.h:389
static void Init()
Standard Init function.
This is the main namespace within which all identifiers in ThePEG are declared.
Definition: FactoryBase.h:28
The Named class is a simple concrete base class to used by classes of objects with a name...
Definition: Named.h:24
std::insert_iterator< Cont > inserter(Cont &c)
Return an insert iterator for a given container.
Definition: std.h:139
double theWeight
The weight associated with this event.
Definition: Event.h:379
const PPair & incoming() const
Return a reference to the pair of colliding particles in the primary Collision of this Event...
Definition: Event.h:158
EventPtr clone() const
Returns a full clone of this Event.
StepSet allSteps
A set of all particles in this Event.
Definition: Event.h:348
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:464
Event & operator=(const Event &)=delete
The assignment operator is private and not implemented.
const CollisionVector & collisions() const
Return a possibly empty list of collisions in this Event.
Definition: Event.h:146
void weight(double w)
Set the weight associated with this event.
Definition: Event.h:236
void cleanSteps()
Remove all steps which have no new particles introduced in them.
set< PPtr, less< PPtr > > ParticleSet
A set of pointers to Particle.
Definition: EventConfig.h:76
map< tcColinePtr, int > ColourLineMap
Map colour lines to indices.
Definition: Event.h:48
void getFinalState(Container &c) const
Extract all final state particles in this Event.
Definition: Event.h:121
CollisionVector theCollisions
A vector of collisions in this Event.
Definition: Event.h:343
PPair theIncoming
The pair of colliding particles.
Definition: Event.h:338
void persistentInput(PersistentIStream &, int)
Standard functions for reading from a persistent stream.
ThePEG::Ptr< SubProcess >::transient_pointer tSubProPtr
Alias for a transient pointer to SubProcess .
Definition: Pointers.h:86
ColourLineMap theColourLines
Map of all registered colour lines to their index numbers.
Definition: Event.h:369
int colourLineIndex(tcColinePtr) const
Return the index of the given colour line.
pair< PPtr, PPtr > PPair
A pair of pointers to Particle objects.
Definition: Containers.h:127
RCPtr is a reference counted (smart) pointer.
Definition: RCPtr.h:60
const map< string, double > & optionalWeights() const
Return the optional named weights associated to this event.
Definition: Event.h:226
void removeEntry(tPPtr p)
Remove a given Particle entry.
const string & name() const
Return name.
Definition: Named.h:42
Event()
Private default constructor must only be used by the PersistentIStream class via the ClassTraits<Even...
Definition: Event.h:410
map< string, double > & optionalWeights()
Access the optional named weights associated to this event.
Definition: Event.h:246
void transform(const LorentzRotation &)
Transform all particles in this Event.
tcEventBasePtr theHandler
A pointer to the EventHandler which performed the generation of this Event.
Definition: Event.h:364
void setInfo(tcEventBasePtr newHandler, string newName, long newNumber, double weight)
Set event info.
ThePEG::Ptr< Collision >::transient_pointer tCollPtr
Alias for a transient pointer to Collision .
Definition: Pointers.h:84
This is the decalaration of the Collision class.
Definition: Collision.h:34
virtual bool allCollisions() const
Return ture if all collisions should be considered.
Definition: SelectorBase.h:104
virtual void debugme() const
Print out debugging information for this object on std::cerr.
tcEventBasePtr handler() const
Return a pointer to the EventHandler which produced this Event.
Definition: Event.h:90
vector< CollPtr > CollisionVector
A vector of pointers to Collision.
Definition: EventConfig.h:88
void addCollision(tCollPtr c)
Add a collision to this Event.
SubProcessSet allSubProcesses
A set of all sub-processes in this Event.
Definition: Event.h:353
void addParticles(Iterator first, Iterator last)
Add a range of particles to this Collision.
Definition: Event.h:270
The default concrete implementation of ClassTraitsBase.
Definition: ClassTraits.h:134
double optionalWeight(const string &name) const
Return an optional named weight associated to this event.
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
static ClassDescription< Event > initEvent
Describe concrete class with persistent data.
Definition: Event.h:404
tStepPtr newStep()
Create a new Step in the current Collision, which is a copy of the last Step (if any) and return a po...
tCollPtr newCollision()
Create a new Collision in this event and return a pointer to it.
map< string, double > theOptionalWeights
Optional named weights.
Definition: Event.h:384
double weight() const
Return the weight associated with this event.
Definition: Event.h:215
void printGraphviz() const
Print this Event in Graphviz format on the standard output.
vector< tPPtr > tPVector
A vector of transient pointers to Particle objects.
Definition: Containers.h:82
This file contains declarations of standard selector classes.
set< StepPtr, less< StepPtr > > StepSet
A set of pointers to Step.
Definition: EventConfig.h:90
void rebind(const EventTranslationMap &trans)
Rebind to cloned objects.
BaseClassTraits describes the base classes of the templated class.
Definition: ClassTraits.h:156
long number() const
Return the number assigned to this Event.
Definition: Event.h:183
ParticleSelector< FinalStateSelector > SelectFinalState
Typedef to declare a selector used to extract all final state particles from an event.
void removeSubProcess(tSubProPtr p)
Remove a SubProcess from this Event.
Definition: Event.h:291
~Event()
The destructor.
void addParticle(tPPtr p)
Add a particle to this Collision.
The templated ClassTraitsBase class defines a set of default information about classes used by ThePEG...
Definition: ClassTraits.h:52
set< SubProPtr, less< SubProPtr > > SubProcessSet
A set of pointers to SubProcess.
Definition: EventConfig.h:92