ThePEG  1.8.0
Collision.h
1 // -*- C++ -*-
2 //
3 // Collision.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_Collision_H
10 #define ThePEG_Collision_H
11 // This is the decalaration of the Collision class. It
12 
13 #include "EventConfig.h"
14 #include "Particle.h"
15 #include "StandardSelectors.h"
16 #include "ThePEG/Vectors/LorentzVector.h"
17 #include "ThePEG/Vectors/LorentzRotation.h"
18 
19 namespace ThePEG {
20 
34 class Collision: public EventRecordBase {
35 
36 public:
37 
41  friend class EventHandler;
43  friend class Event;
45  friend class Step;
46 
47 public:
48 
59  Collision(const PPair & newIncoming, tEventPtr newEvent = tEventPtr(),
60  tcEventBasePtr newHandler = tcEventBasePtr())
61  : theIncoming(newIncoming), theEvent(newEvent), theHandler(newHandler) {
62  addParticle(incoming().first);
63  addParticle(incoming().second);
64  }
65 
69  ~Collision();
70 
71 public:
72 
80 
84  void addStep(tStepPtr s);
85 
90  tcEventBasePtr handler() const { return theHandler; }
91 
96  tEventPtr event() const { return theEvent; }
97 
108  template <class OutputIterator>
109  void select(OutputIterator r, const SelectorBase & s) const;
110 
116  template <class OutputIterator>
117  void selectFinalState(OutputIterator r) const {
118  select(r, SelectFinalState());
119  }
120 
126  tPVector ret;
127  selectFinalState(back_inserter(ret));
128  return ret;
129  }
130 
136  return subProcesses().empty()? SubProPtr(): subProcesses().front();
137  }
138 
142  const SubProcessVector & subProcesses() const {
143  return theSubProcesses;
144  }
145 
150  return steps().empty()? tcStepPtr(): tcStepPtr(steps().back());
151  }
152 
157  return steps().empty()? StepPtr(): steps().back();
158  }
159 
163  const StepVector & steps() const { return theSteps; }
164 
168  tcStepPtr step(unsigned int i) const {
169  return i < steps().size()? tcStepPtr(theSteps[i]): tcStepPtr();
170  }
171 
177  const PPair & incoming() const { return theIncoming; }
178 
185  tParticleSet getRemnants() const;
186 
193  bool isRemnant(tPPtr p) const { return member(getRemnants(), p); }
194 
196 
200  const LorentzPoint & vertex() const { return theVertex; }
201 
205  void vertex(const LorentzPoint & p) { theVertex = p; }
206 
210  void transform(const LorentzRotation &);
211 
216  Energy2 m2() const {
217  return ( incoming().first->momentum() + incoming().second->momentum() ).m2();
218  }
219 
226  void removeDecay(tPPtr);
227 
233  void removeParticle(tPPtr);
234 
238  void cleanSteps();
239 
243  void popStep();
244 
246 
247 public:
248 
252  void persistentOutput(PersistentOStream &) const;
253 
257  void persistentInput(PersistentIStream &, int);
258 
262  static void Init();
263 
264 protected:
265 
271  void addSubProcess(tSubProPtr p);
272 
277 
281  template <class Iterator>
282  void addParticles(Iterator first, Iterator last);
283 
287  void addParticle(tPPtr p);
288 
292  void removeEntry(tPPtr p);
293 
295 
299  const ParticleSet & all() const { return allParticles; }
300 
305  CollPtr clone() const;
306 
314  void rebind(const EventTranslationMap & trans);
315 
316 private:
317 
322 
327 
333 
338 
343 
349 
354 
355 private:
356 
361 
367 
372  friend struct ClassTraits<Collision>;
373 
377  Collision & operator=(const Collision &);
378 
380  friend ostream & operator<<(ostream & os, const Collision & c);
381 
382 };
383 
385 ostream & operator<<(ostream &, const Collision &);
386 
387 
392 template <>
393 struct BaseClassTrait<Collision,1>: public ClassTraitsType {
395  typedef EventRecordBase NthBase;
396 };
397 
400 template <>
401 struct ClassTraits<Collision>: public ClassTraitsBase<Collision> {
403  static string className() { return "ThePEG::Collision"; }
405  static TPtr create() { return TPtr::Create(Collision()); }
406 };
407 
410 }
411 
412 #ifndef ThePEG_TEMPLATES_IN_CC_FILE
413 #include "Collision.tcc"
414 #endif
415 
416 #endif /* ThePEG_Collision_H */