ThePEG  1.8.0
Event.h
1 // -*- C++ -*-
2 //
3 // Event.h is a part of ThePEG - Toolkit for HEP Event Generation
4 // Copyright (C) 1999-2011 Leif Lonnblad
5 //
6 // ThePEG is licenced under version 2 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 
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 
411 
416  friend struct ClassTraits<Event>;
417 
421  Event & operator=(const Event&);
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 */