Warning, /include/ThePEG/EventRecord/Step.tcc is written in an unsupported language. File is not indexed.
0001 // -*- C++ -*-
0002 //
0003 // Step.tcc is a part of ThePEG - Toolkit for HEP Event Generation
0004 // Copyright (C) 1999-2019 Leif Lonnblad
0005 //
0006 // ThePEG is licenced under version 3 of the GPL, see COPYING for details.
0007 // Please respect the MCnet academic guidelines, see GUIDELINES for details.
0008 //
0009 //
0010 // This is the implementation of the non-inlined templated member
0011 // functions of the Step class.
0012 //
0013
0014 namespace ThePEG {
0015
0016 template <typename OutputIterator>
0017 void Step::select(OutputIterator r, const SelectorBase & s) const {
0018 if ( s.finalState() ) copyIfCheck(r, particles(), s);
0019 if ( s.intermediate() ) copyIfCheck(r, intermediates(), s);
0020 }
0021
0022 template <typename Iterator>
0023 void Step::addParticles(Iterator first, Iterator last) {
0024 theParticles.insert(first, last);
0025 allParticles.insert(first, last);
0026 if ( collision() ) collision()->addParticles(first, last);
0027 for ( ; first != last; ++first )
0028 if ( !(**first).birthStep() )
0029 (**first).rep().theBirthStep = this;
0030 }
0031
0032 template <typename Iterator>
0033 void Step::addIntermediates(Iterator first, Iterator last) {
0034 theIntermediates.insert(first, last);
0035 allParticles.insert(first, last);
0036 if ( collision() ) collision()->addParticles(first, last);
0037 for ( ; first != last; ++first ) {
0038 if ( !(**first).birthStep() ) (**first).rep().theBirthStep = this;
0039 ParticleSet::iterator pit = theParticles.find(*first);
0040 if ( pit != theParticles.end() ) theParticles.erase(pit);
0041 }
0042 }
0043
0044 template <typename Iterator>
0045 bool Step::
0046 addDecayProduct(Iterator firstParent, Iterator lastParent, tPPtr child,
0047 bool checkfinal) {
0048 if ( !collision() ) return false;
0049 if ( collision()->finalStep() != this ) return false;
0050 if ( checkfinal ) {
0051 for ( Iterator it = firstParent; it != lastParent; ++it ) {
0052 tPPtr parent = const_ptr_cast<tPPtr>((**it).final());
0053 if ( member(theParticles, parent) ) continue;
0054 if ( parent->children().empty() ||
0055 !member(theParticles, parent->children()[0]->final()) ) return false;
0056 }
0057 }
0058 for ( Iterator it = firstParent; it != lastParent; ++it ) {
0059 tPPtr parent = const_ptr_cast<tPPtr>((**it).final());
0060 ParticleSet::iterator pit = theParticles.find(parent);
0061 if ( pit != theParticles.end() ) {
0062 theParticles.erase(pit);
0063 if ( parent->birthStep() == this ) theIntermediates.insert(parent);
0064 }
0065 parent->rep().theChildren.push_back(child);
0066 child->rep().theParents.push_back(parent);
0067 }
0068 child->rep().theBirthStep = this;
0069 addParticle(child);
0070 return true;
0071 }
0072
0073 template <typename PIterator, typename CIterator>
0074 bool Step::addDecayProduct(PIterator firstParent, PIterator lastParent,
0075 CIterator firstChild, CIterator lastChild) {
0076 if ( !collision() ) return false;
0077 if ( collision()->finalStep() != this ) return false;
0078 for ( PIterator it = firstParent; it != lastParent; ++it ) {
0079 tPPtr parent = const_ptr_cast<tPPtr>((**it).final());
0080 if ( member(theParticles, parent) ) continue;
0081 if ( parent->children().empty() ||
0082 !member(theParticles, parent->children()[0]->final()) ) return false;
0083 }
0084 for ( PIterator it = firstParent; it != lastParent; ++it ) {
0085 tPPtr parent = const_ptr_cast<tPPtr>((**it).final());
0086 ParticleSet::iterator pit = theParticles.find(parent);
0087 if ( pit != theParticles.end() ) {
0088 theParticles.erase(pit);
0089 if ( parent->birthStep() == this ) theIntermediates.insert(parent);
0090 }
0091 for ( CIterator cit = firstChild; cit != lastChild; ++cit ) {
0092 parent->rep().theChildren.push_back(*cit);
0093 (**cit).rep().theParents.push_back(parent);
0094 }
0095 }
0096 for ( CIterator cit = firstChild; cit != lastChild; ++cit ) {
0097 (**cit).rep().theBirthStep = this;
0098 addParticle(*cit);
0099 }
0100 return true;
0101 }
0102
0103 template <typename Iterator>
0104 tParticleSet Step::getCurrent(Iterator first, Iterator last) const {
0105 tParticleSet res;
0106 for ( Iterator i = first; i != last; ++i )
0107 addIfFinal(inserter(res), *i);
0108 return res;
0109 }
0110
0111 template <typename Inserter, typename PPointer>
0112 void Step::addIfFinal(Inserter o, PPointer p) {
0113 if ( member(theParticles, p) ) *o++ = p;
0114 else if ( p->next() ) addIfFinal(o, p->next());
0115 else
0116 for ( int i = 0, N = p->children().size(); i < N; ++i )
0117 addIfFinal(o, p->children()[i]);
0118 }
0119
0120 }