thepeg is hosted by Hepforge, IPPP Durham
ThePEG  2.2.1
Step.h
1 // -*- C++ -*-
2 //
3 // Step.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_BasicStep_H
10 #define ThePEG_BasicStep_H
11 // This is the declaration of the Step class.
12 
13 #include "ThePEG/EventRecord/Particle.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 &) = delete;
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 
tPPtr find(tcPPtr p) const
Get mutable particle.
Definition: Step.h:153
static void Init()
Standard Init function.
PersistentIStream is used to read persistent objects from a stream where they were previously written...
bool setCopy(tcPPtr pold, tPPtr pnew)
Make particles copies of eachother.
const ParticleSet & all() const
A reference to the set of all particles in this step.
Definition: Step.h:121
void removeEntry(tPPtr p)
Remove a particle entry from the step.
Define the base class from which all (polymorphic) classes in ThePEG are derived. ...
Definition: ThePEG.h:54
static ClassDescription< Step > initStep
Describe concrete class with persistent data.
Definition: Step.h:518
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
static vector< tPVector > getSinglets(PIterator first, PIterator last)
Return a vector of particle vectors with colour-connected partons, where each particle vector is in a...
Definition: Step.h:113
tPPtr colourNeighbour(tcPPtr particle, bool anti=false) const
Return the (anti-)colour neighbour of the given particle if one exists in the final state of this Ste...
set< tPPtr, less< tPPtr > > tParticleSet
A set of transient pointers to Particle.
Definition: EventConfig.h:78
A concreate implementation of ClassDescriptionBase describing a concrete class with persistent data...
void insertIntermediate(tPPtr p, tPPtr parent, tPPtr child)
Add an intermediate particle.
tPVector getFinalState() const
Extract all final state particles in this Step.
Definition: Step.h:101
bool member(const Container &c, const Key &k)
Check if a given object is a part of a container.
Definition: std.h:125
void rebind(const EventTranslationMap &trans)
Rebind to cloned objects.
PersistentOStream is used to write objects persistently to a stream from which they can be read in ag...
bool nullStep() const
Return true if no new particles were introduced in this step.
bool removeDecayProduct(tcPPtr parent, tPPtr child)
Remove the child form the given parent.
TransientConstRCPtr is a simple wrapper around a bare const pointer which can be assigned to and from...
Definition: RCPtr.h:696
void removeParticle(tPPtr p)
Remove (recursively) the given Particle from the Step.
Ptr< EventRecordBase >::transient_const_pointer tcEventBasePtr
Alias for a transient pointer to const EventRecordBase.
Definition: EventConfig.h:49
ParticleSet theIntermediates
The set of all intermediate particle in this step.
Definition: Step.h:483
TransientRCPtr is a simple wrapper around a bare pointer which can be assigned to and from an RCPtr a...
Definition: RCPtr.h:519
tCollPtr theCollision
Pointer to the collision to which this step belongs.
Definition: Step.h:498
void addParticle(tPPtr p)
Add a particle to this step.
Rebinder is a class associating pairs of pointers to objects.
Definition: Rebinder.h:27
tPPtr insertCopy(tcPPtr p)
Insert a copy.
This is the main namespace within which all identifiers in ThePEG are declared.
Definition: FactoryBase.h:28
ostream & left(ostream &os)
Stream manipulator setting an ostream to left-adjust its ouput.
Definition: std.h:160
const ParticleSet & particles() const
A reference to the set of outgoing particles in this step.
Definition: Step.h:126
void selectFinalState(OutputIterator r) const
Extract all final state particles in this Step.
Definition: Step.h:93
ParticleSet theParticles
The set of all outgoing particle in this step.
Definition: Step.h:478
const PPair & incoming() const
Returns the colliding particles in the collision to which this step belongs.
Definition: Step.h:533
void collision(tCollPtr c)
Setup pointer to the Collision.
Definition: Step.h:466
ParticleSet allParticles
The set of all particles available in this step.
Definition: Step.h:493
void handler(tcEventBasePtr sh)
Setup pointer to the step handler.
Definition: Step.h:471
void addParticles(Iterator first, Iterator last)
Add a range of particles to this Step.
SubProcessVector theSubProcesses
The vector of all sub-processes introduced in this step.
Definition: Step.h:488
Step(tCollPtr newCollision=tCollPtr(), tcEventBasePtr newHandler=tcEventBasePtr())
Standard constructor.
Definition: Step.h:51
set< PPtr, less< PPtr > > ParticleSet
A set of pointers to Particle.
Definition: EventConfig.h:76
tParticleSet getCurrent(const Cont &c) const
Get final state particles.
Definition: Step.h:392
tcEventBasePtr theHandler
Pointer ot the step handler which performed this step.
Definition: Step.h:503
void addDecayNoCheck(tPPtr parent, tPPtr child)
Add a particle to this Step.
tcEventBasePtr handler() const
Return a pointer to the step handler which performed the generation of this step. ...
Definition: Step.h:69
void fixColourFlow()
Fix the colour flow of particles which have been added to this step and which have not already had th...
vector< SubProPtr > SubProcessVector
A vector of pointers to SubProcess.
Definition: EventConfig.h:84
pair< PPtr, PPtr > PPair
A pair of pointers to Particle objects.
Definition: Containers.h:127
T1 const_ptr_cast(const T2 &t2)
Replacement for the standard const_cast.
Definition: PtrTraits.h:175
tCollPtr collision() const
Return a pointer to the Collision to which this step belongs.
Definition: Step.h:74
void addIfFinal(Inserter o, PPointer p)
Get final state particles.
RCPtr is a reference counted (smart) pointer.
Definition: RCPtr.h:60
ThePEG::Ptr< Particle >::transient_pointer tPPtr
Alias for a transient pointer to Particle .
Definition: Pointers.h:67
bool addDecayProduct(tcPPtr parent, CIterator firstChild, CIterator lastChild, bool fixColour=true)
Add decay products.
Definition: Step.h:217
void removeSubProcess(tSubProPtr)
Remove a sub-process.
bool addDecayProduct(tcPPtr parent, tPPtr child, bool fixColour=true)
Add decay product.
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
void addIntermediates(Iterator first, Iterator last)
Add a range of intermediate particles in this step.
StepPtr clone() const
Return a clone of this step.
const SubProcessVector & subProcesses() const
A reference to the vector of sub-processes introduced in this step.
Definition: Step.h:137
tPPtr copyParticle(tcPPtr p)
Copy a particle.
tPPtr antiColourNeighbour(tcPPtr particle) const
Return the anti-colour neighbour of the given particle if one exists in the final state of this Step...
void select(OutputIterator r, const SelectorBase &s) const
Extract particles from this Step which satisfies the requirements given by an object of the SelectorB...
void persistentOutput(PersistentOStream &) const
Standard function for writing to a persistent stream.
void addSubProcess(tSubProPtr)
Add a sub-process.
void addIntermediate(tPPtr p)
Add an intermediate particle in this Step.
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
Step & operator=(const Step &)=delete
Assignement is not allowed.
~Step()
The destructor.
vector< tPPtr > tPVector
A vector of transient pointers to Particle objects.
Definition: Containers.h:82
This file contains declarations of standard selector classes.
bool removeDecayProduct(tcPPtr parent, CIterator firstChild, CIterator lastChild)
Remove children form the given parent.
Definition: Step.h:252
const ParticleSet & intermediates() const
A reference to the set of intermediate particles in this step.
Definition: Step.h:131
void persistentInput(PersistentIStream &, int)
Standard function for reading from a persistent stream.
virtual void debugme() const
Print out debugging information for this object on std::cerr.
ParticleSelector< FinalStateSelector > SelectFinalState
Typedef to declare a selector used to extract all final state particles from an event.
The Step class contains information of all particles present after certain step in the event generati...
Definition: Step.h:34