00001
00002
00003
00004
00005
00006
00007
00008
00009 #ifndef ThePEG_BasicStep_H
00010 #define ThePEG_BasicStep_H
00011
00012
00013 #include "ThePEG/EventRecord/Particle.h"
00014 #include "ThePEG/EventRecord/StandardSelectors.h"
00015
00016 namespace ThePEG {
00017
00034 class Step: public EventRecordBase {
00035
00036 public:
00037
00039 friend class Collision;
00041 friend class Event;
00042
00043 public:
00044
00051 Step(tCollPtr newCollision = tCollPtr(),
00052 tcEventBasePtr newHandler = tcEventBasePtr())
00053 : theCollision(newCollision), theHandler(newHandler) {}
00054
00058 Step(const Step &);
00059
00063 ~Step();
00064
00069 tcEventBasePtr handler() const { return theHandler; }
00070
00074 tCollPtr collision() const { return theCollision; }
00075
00084 template <typename OutputIterator>
00085 void select(OutputIterator r, const SelectorBase & s) const;
00086
00092 template <typename OutputIterator>
00093 void selectFinalState(OutputIterator r) const {
00094 select(r, SelectFinalState());
00095 }
00096
00101 tPVector getFinalState() const {
00102 tPVector ret;
00103 selectFinalState(back_inserter(ret));
00104 return ret;
00105 }
00106
00112 template <typename PIterator>
00113 static vector<tPVector> getSinglets(PIterator first, PIterator last) {
00114 tParticleSet left(first, last);
00115 return getSinglets(left);
00116 }
00117
00121 const ParticleSet & all() const { return allParticles; }
00122
00126 const ParticleSet & particles() const { return theParticles; }
00127
00131 const ParticleSet & intermediates() const { return theIntermediates; }
00132
00137 const SubProcessVector & subProcesses() const {
00138 return theSubProcesses;
00139 }
00140
00147 const PPair & incoming() const;
00148
00153 tPPtr find(tcPPtr p) const {
00154 tPPtr r = const_ptr_cast<tPPtr>(p);
00155 if ( !member(all(), r) ) return tPPtr();
00156 return r;
00157 }
00158
00159
00168 tPPtr copyParticle(tcPPtr p);
00169
00177 bool setCopy(tcPPtr pold, tPPtr pnew);
00178
00188 tPPtr insertCopy(tcPPtr p);
00189
00201 bool addDecayProduct(tcPPtr parent, tPPtr child, bool fixColour = true);
00202
00216 template <typename CIterator>
00217 bool addDecayProduct(tcPPtr parent,
00218 CIterator firstChild, CIterator lastChild,
00219 bool fixColour = true) {
00220 for ( ; firstChild != lastChild; ++firstChild )
00221 if ( !addDecayProduct(parent, *firstChild, fixColour) ) return false;
00222 return true;
00223 }
00224
00231 void addDecayNoCheck(tPPtr parent, tPPtr child);
00232
00239 void addDecayProduct(tPPtr child);
00240
00245 bool removeDecayProduct(tcPPtr parent, tPPtr child);
00246
00251 template <typename CIterator>
00252 bool removeDecayProduct(tcPPtr parent,
00253 CIterator firstChild, CIterator lastChild) {
00254 bool success = true;
00255 for ( ; firstChild != lastChild; ++firstChild )
00256 if ( !removeDecayProduct(parent, *firstChild) ) success = false;
00257 return success;
00258 }
00259
00270 template <typename Iterator>
00271 bool addDecayProduct(Iterator firstParent, Iterator lastParent, tPPtr child,
00272 bool checkfinal = true);
00273
00282 template <typename PIterator, typename CIterator>
00283 bool addDecayProduct(PIterator firstParent, PIterator lastParent,
00284 CIterator firstChild, CIterator lastChild);
00285
00294 void fixColourFlow();
00295
00303 tPPtr colourNeighbour(tcPPtr particle, bool anti = false) const;
00304
00312 tPPtr antiColourNeighbour(tcPPtr particle) const;
00313
00320 template <typename Iterator>
00321 void addParticles(Iterator first, Iterator last);
00322
00329 void addParticle(tPPtr p);
00330
00339 template <typename Iterator>
00340 void addIntermediates(Iterator first, Iterator last);
00341
00350 void addIntermediate(tPPtr p);
00351
00358 void insertIntermediate(tPPtr p, tPPtr parent, tPPtr child);
00359
00365 void addSubProcess(tSubProPtr);
00366
00371 void removeSubProcess(tSubProPtr);
00372
00378 void removeParticle(tPPtr p);
00379
00383 bool nullStep() const;
00384
00391 template <typename Cont>
00392 tParticleSet getCurrent(const Cont & c) const {
00393 return getCurrent(c.begin(), c.end());
00394 }
00395
00402 template <typename Iterator>
00403 tParticleSet getCurrent(Iterator first, Iterator last) const;
00404
00408 StepPtr clone() const;
00409
00410 public:
00411
00415 void persistentOutput(PersistentOStream &) const;
00419 void persistentInput(PersistentIStream &, int);
00420
00424 static void Init();
00425
00426 protected:
00427
00432 static vector<tPVector> getSinglets(tParticleSet &);
00433
00438 void removeEntry(tPPtr p);
00439
00446 void rebind(const EventTranslationMap & trans);
00447
00453 template <typename Inserter, typename PPointer>
00454 void addIfFinal(Inserter o, PPointer p);
00455
00456 private:
00457
00461 Step & operator=(const Step &);
00462
00466 void collision(tCollPtr c) { theCollision = c; }
00467
00471 void handler(tcEventBasePtr sh) { theHandler = sh; }
00472
00473 private:
00474
00478 ParticleSet theParticles;
00479
00483 ParticleSet theIntermediates;
00484
00488 SubProcessVector theSubProcesses;
00489
00493 ParticleSet allParticles;
00494
00498 tCollPtr theCollision;
00499
00503 tcEventBasePtr theHandler;
00504
00505 public:
00506
00511 virtual void debugme() const;
00512
00513 private:
00514
00518 static ClassDescription<Step> initStep;
00519
00520 };
00521
00523 ostream & operator<<(ostream &, const Step &);
00524
00526 ThePEG_DECLARE_CLASS_TRAITS(Step,EventRecordBase);
00529 }
00530
00531 #include "Collision.h"
00532
00533 inline const ThePEG::PPair & ThePEG::Step::incoming() const {
00534 return collision()->incoming();
00535 }
00536
00537 #ifndef ThePEG_TEMPLATES_IN_CC_FILE
00538 #include "Step.tcc"
00539 #endif
00540
00541 #endif
00542