1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120
|
// -*- C++ -*-
//
// Step.tcc is a part of ThePEG - Toolkit for HEP Event Generation
// Copyright (C) 1999-2011 Leif Lonnblad
//
// ThePEG is licenced under version 2 of the GPL, see COPYING for details.
// Please respect the MCnet academic guidelines, see GUIDELINES for details.
//
//
// This is the implementation of the non-inlined templated member
// functions of the Step class.
//
namespace ThePEG {
template <typename OutputIterator>
void Step::select(OutputIterator r, const SelectorBase & s) const {
if ( s.finalState() ) copyIfCheck(r, particles(), s);
if ( s.intermediate() ) copyIfCheck(r, intermediates(), s);
}
template <typename Iterator>
void Step::addParticles(Iterator first, Iterator last) {
theParticles.insert(first, last);
allParticles.insert(first, last);
if ( collision() ) collision()->addParticles(first, last);
for ( ; first != last; ++first )
if ( !(**first).birthStep() )
(**first).rep().theBirthStep = this;
}
template <typename Iterator>
void Step::addIntermediates(Iterator first, Iterator last) {
theIntermediates.insert(first, last);
allParticles.insert(first, last);
if ( collision() ) collision()->addParticles(first, last);
for ( ; first != last; ++first ) {
if ( !(**first).birthStep() ) (**first).rep().theBirthStep = this;
ParticleSet::iterator pit = theParticles.find(*first);
if ( pit != theParticles.end() ) theParticles.erase(pit);
}
}
template <typename Iterator>
bool Step::
addDecayProduct(Iterator firstParent, Iterator lastParent, tPPtr child,
bool checkfinal) {
if ( !collision() ) return false;
if ( collision()->finalStep() != this ) return false;
if ( checkfinal ) {
for ( Iterator it = firstParent; it != lastParent; ++it ) {
tPPtr parent = const_ptr_cast<tPPtr>((**it).final());
if ( member(theParticles, parent) ) continue;
if ( parent->children().empty() ||
!member(theParticles, parent->children()[0]) ) return false;
}
}
for ( Iterator it = firstParent; it != lastParent; ++it ) {
tPPtr parent = const_ptr_cast<tPPtr>((**it).final());
ParticleSet::iterator pit = theParticles.find(parent);
if ( pit != theParticles.end() ) {
theParticles.erase(pit);
if ( parent->birthStep() == this ) theIntermediates.insert(parent);
}
parent->rep().theChildren.push_back(child);
child->rep().theParents.push_back(parent);
}
child->rep().theBirthStep = this;
addParticle(child);
return true;
}
template <typename PIterator, typename CIterator>
bool Step::addDecayProduct(PIterator firstParent, PIterator lastParent,
CIterator firstChild, CIterator lastChild) {
if ( !collision() ) return false;
if ( collision()->finalStep() != this ) return false;
for ( PIterator it = firstParent; it != lastParent; ++it ) {
tPPtr parent = const_ptr_cast<tPPtr>((**it).final());
if ( member(theParticles, parent) ) continue;
if ( parent->children().empty() ||
!member(theParticles, parent->children()[0]) ) return false;
}
for ( PIterator it = firstParent; it != lastParent; ++it ) {
tPPtr parent = const_ptr_cast<tPPtr>((**it).final());
ParticleSet::iterator pit = theParticles.find(parent);
if ( pit != theParticles.end() ) {
theParticles.erase(pit);
if ( parent->birthStep() == this ) theIntermediates.insert(parent);
}
for ( CIterator cit = firstChild; cit != lastChild; ++cit ) {
parent->rep().theChildren.push_back(*cit);
(**cit).rep().theParents.push_back(parent);
}
}
for ( CIterator cit = firstChild; cit != lastChild; ++cit ) {
(**cit).rep().theBirthStep = this;
addParticle(*cit);
}
return true;
}
template <typename Iterator>
tParticleSet Step::getCurrent(Iterator first, Iterator last) const {
tParticleSet res;
for ( Iterator i = first; i != last; ++i )
addIfFinal(inserter(res), *i);
return res;
}
template <typename Inserter, typename PPointer>
void Step::addIfFinal(Inserter o, PPointer p) {
if ( member(theParticles, p) ) *o++ = p;
else if ( p->next() ) addIfFinal(o, p->next());
else
for ( int i = 0, N = p->children().size(); i < N; ++i )
addIfFinal(o, p->children()[i]);
}
}
|