ThePEG  1.8.0
Step.h
1 // -*- C++ -*-
2 //
3 // Step.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_BasicStep_H
10 #define ThePEG_BasicStep_H
11 // This is the declaration of the Step class.
12 
13 #include "ThePEG/EventRecord/Particle.h"
14 #include "ThePEG/EventRecord/StandardSelectors.h"
15 
16 namespace ThePEG {
17 
34 class Step: public EventRecordBase {
35 
36 public:
37 
39  friend class Collision;
41  friend class Event;
42 
43 public:
44 
51  Step(tCollPtr newCollision = tCollPtr(),
52  tcEventBasePtr newHandler = tcEventBasePtr())
53  : theCollision(newCollision), theHandler(newHandler) {}
54 
58  Step(const Step &);
59 
63  ~Step();
64 
69  tcEventBasePtr handler() const { return theHandler; }
70 
74  tCollPtr collision() const { return theCollision; }
75 
84  template <typename OutputIterator>
85  void select(OutputIterator r, const SelectorBase & s) const;
86 
92  template <typename OutputIterator>
93  void selectFinalState(OutputIterator r) const {
95  }
96 
102  tPVector ret;
103  selectFinalState(back_inserter(ret));
104  return ret;
105  }
106 
112  template <typename PIterator>
113  static vector<tPVector> getSinglets(PIterator first, PIterator last) {
114  tParticleSet left(first, last);
115  return getSinglets(left);
116  }
117 
121  const ParticleSet & all() const { return allParticles; }
122 
126  const ParticleSet & particles() const { return theParticles; }
127 
131  const ParticleSet & intermediates() const { return theIntermediates; }
132 
137  const SubProcessVector & subProcesses() const {
138  return theSubProcesses;
139  }
140 
147  const PPair & incoming() const;
148 
153  tPPtr find(tcPPtr p) const {
154  tPPtr r = const_ptr_cast<tPPtr>(p);
155  if ( !member(all(), r) ) return tPPtr();
156  return r;
157  }
158 
159 
169 
177  bool setCopy(tcPPtr pold, tPPtr pnew);
178 
189 
201  bool addDecayProduct(tcPPtr parent, tPPtr child, bool fixColour = true);
202 
216  template <typename CIterator>
217  bool addDecayProduct(tcPPtr parent,
218  CIterator firstChild, CIterator lastChild,
219  bool fixColour = true) {
220  for ( ; firstChild != lastChild; ++firstChild )
221  if ( !addDecayProduct(parent, *firstChild, fixColour) ) return false;
222  return true;
223  }
224 
231  void addDecayNoCheck(tPPtr parent, tPPtr child);
232 
239  void addDecayProduct(tPPtr child);
240 
245  bool removeDecayProduct(tcPPtr parent, tPPtr child);
246 
251  template <typename CIterator>
253  CIterator firstChild, CIterator lastChild) {
254  bool success = true;
255  for ( ; firstChild != lastChild; ++firstChild )
256  if ( !removeDecayProduct(parent, *firstChild) ) success = false;
257  return success;
258  }
259 
270  template <typename Iterator>
271  bool addDecayProduct(Iterator firstParent, Iterator lastParent, tPPtr child,
272  bool checkfinal = true);
273 
282  template <typename PIterator, typename CIterator>
283  bool addDecayProduct(PIterator firstParent, PIterator lastParent,
284  CIterator firstChild, CIterator lastChild);
285 
294  void fixColourFlow();
295 
303  tPPtr colourNeighbour(tcPPtr particle, bool anti = false) const;
304 
312  tPPtr antiColourNeighbour(tcPPtr particle) const;
313 
320  template <typename Iterator>
321  void addParticles(Iterator first, Iterator last);
322 
329  void addParticle(tPPtr p);
330 
339  template <typename Iterator>
340  void addIntermediates(Iterator first, Iterator last);
341 
350  void addIntermediate(tPPtr p);
351 
358  void insertIntermediate(tPPtr p, tPPtr parent, tPPtr child);
359 
366 
372 
378  void removeParticle(tPPtr p);
379 
383  bool nullStep() const;
384 
391  template <typename Cont>
392  tParticleSet getCurrent(const Cont & c) const {
393  return getCurrent(c.begin(), c.end());
394  }
395 
402  template <typename Iterator>
403  tParticleSet getCurrent(Iterator first, Iterator last) const;
404 
408  StepPtr clone() const;
409 
410 public:
411 
415  void persistentOutput(PersistentOStream &) const;
419  void persistentInput(PersistentIStream &, int);
420 
424  static void Init();
425 
426 protected:
427 
432  static vector<tPVector> getSinglets(tParticleSet &);
433 
438  void removeEntry(tPPtr p);
439 
446  void rebind(const EventTranslationMap & trans);
447 
453  template <typename Inserter, typename PPointer>
454  void addIfFinal(Inserter o, PPointer p);
455 
456 private:
457 
461  Step & operator=(const Step &);
462 
466  void collision(tCollPtr c) { theCollision = c; }
467 
471  void handler(tcEventBasePtr sh) { theHandler = sh; }
472 
473 private:
474 
479 
484 
489 
494 
499 
504 
505 public:
506 
511  virtual void debugme() const;
512 
513 private:
514 
519 
520 };
521 
523 ostream & operator<<(ostream &, const Step &);
524 
526 ThePEG_DECLARE_CLASS_TRAITS(Step,EventRecordBase);
529 }
530 
531 #include "Collision.h"
532 
533 inline const ThePEG::PPair & ThePEG::Step::incoming() const {
534  return collision()->incoming();
535 }
536 
537 #ifndef ThePEG_TEMPLATES_IN_CC_FILE
538 #include "Step.tcc"
539 #endif
540 
541 #endif /* ThePEG_BasicStep_H */
542