00001
00002
00003
00004
00005
00006
00007
00008
00009 #ifndef ThePEG_Event_H
00010 #define ThePEG_Event_H
00011
00012
00013 #include "Particle.h"
00014 #include "StandardSelectors.h"
00015 #include "SubProcess.h"
00016 #include "ThePEG/Utilities/Named.h"
00017
00018 namespace ThePEG {
00019
00036 class Event : public EventRecordBase, public Named {
00037
00038 public:
00039
00043 friend class EventHandler;
00045 friend class Collision;
00046
00048 typedef map<tcColinePtr, int> ColourLineMap;
00049
00050 public:
00051
00065 Event(const PPair & newIncoming, tcEventBasePtr newHandler = tcEventBasePtr(),
00066 string newName = "", long newNumber = -1, double weight = 1.0);
00067
00071 Event(const Event&);
00072
00076 ~Event();
00077
00082 EventPtr clone() const;
00083
00084 public:
00085
00090 tcEventBasePtr handler() const { return theHandler; }
00091
00102 template <class OutputIterator>
00103 void select(OutputIterator r, const SelectorBase & s) const;
00104
00110 template <class OutputIterator>
00111 void selectFinalState(OutputIterator r) const {
00112 select(r, SelectFinalState());
00113 }
00114
00120 template <class Container>
00121 void getFinalState(Container & c) const {
00122 selectFinalState(inserter(c));
00123 }
00124
00129 tPVector getFinalState() const {
00130 tPVector ret;
00131 selectFinalState(back_inserter(ret));
00132 return ret;
00133 }
00134
00139 tCollPtr primaryCollision() const {
00140 return collisions().empty() ? tCollPtr() : tCollPtr(collisions()[0]);
00141 }
00142
00146 const CollisionVector & collisions() const { return theCollisions; }
00147
00152 tSubProPtr primarySubProcess() const;
00153
00158 const PPair & incoming() const { return theIncoming; }
00159
00161
00165 tCollPtr newCollision();
00166
00172 tStepPtr newStep();
00173
00177 void transform(const LorentzRotation &);
00178
00183 long number() const { return theNumber; }
00184
00188 int colourLineIndex(tcColinePtr) const;
00189
00196 void removeDecay(tPPtr);
00197
00203 void removeParticle(tPPtr);
00204
00208 void cleanSteps();
00209
00211
00215 double weight() const { return theWeight; }
00216
00220 void printGraphviz() const;
00221
00225 void weight(double w) { theWeight = w; }
00226
00230 void setInfo(tcEventBasePtr newHandler, string newName,
00231 long newNumber, double weight);
00232
00236 void addCollision(tCollPtr c);
00237
00241 void primaryCollision(tCollPtr c);
00242
00243 protected:
00244
00248 template <class Iterator>
00249 void addParticles(Iterator first, Iterator last) {
00250 while ( first != last ) addParticle(*first++);
00251 }
00252
00256 void addParticle(tPPtr p);
00257
00263 void addSubProcess(tSubProPtr p) {
00264 if ( p ) allSubProcesses.insert(p);
00265 }
00266
00270 void removeSubProcess(tSubProPtr p) { allSubProcesses.erase(p); }
00271
00277 void addStep(tStepPtr s) {
00278 if ( s ) allSteps.insert(s);
00279 }
00280
00284 void removeEntry(tPPtr p);
00285
00293 void rebind(const EventTranslationMap & trans);
00294
00295 public:
00296
00300 void persistentOutput(PersistentOStream &) const;
00301
00305 void persistentInput(PersistentIStream &, int);
00306
00310 static void Init();
00311
00312 private:
00313
00317 PPair theIncoming;
00318
00322 CollisionVector theCollisions;
00323
00327 StepSet allSteps;
00328
00332 SubProcessSet allSubProcesses;
00333
00337 ParticleSet allParticles;
00338
00343 tcEventBasePtr theHandler;
00344
00348 mutable ColourLineMap theColourLines;
00349
00353 long theNumber;
00354
00358 double theWeight;
00359
00363 long theParticleNumber;
00364
00365 public:
00366
00371 virtual void debugme() const;
00372
00373 private:
00374
00378 static ClassDescription<Event> initEvent;
00379
00384 Event() : theNumber(-1), theWeight(1.0), theParticleNumber(0) {}
00385
00390 friend class ClassTraits<Event>;
00391
00395 Event & operator=(const Event&);
00396
00397 };
00398
00400 ostream & operator<<(ostream &, const Event &);
00401
00403 void printGraphviz(ostream &, tcEventPtr);
00404
00409 template <>
00410 struct BaseClassTrait<Event,1>: public ClassTraitsType {
00412 typedef EventRecordBase NthBase;
00413 };
00414
00417 template <>
00418 struct ClassTraits<Event>: public ClassTraitsBase<Event> {
00420 static string className() { return "ThePEG::Event"; }
00422 static TPtr create() { return TPtr::Create(Event()); }
00423 };
00424
00427 }
00428
00429 #include "Collision.h"
00430
00431 inline ThePEG::tSubProPtr ThePEG::Event::primarySubProcess() const {
00432 return collisions().empty() ? ThePEG::tSubProPtr() :
00433 ThePEG::tSubProPtr(primaryCollision()->primarySubProcess());
00434 }
00435
00436 namespace ThePEG {
00437 template <class OutputIterator>
00438 void Event::select(OutputIterator r, const SelectorBase & s) const {
00439 if ( s.allCollisions() ) {
00440 for ( CollisionVector::const_iterator it = theCollisions.begin();
00441 it != theCollisions.end(); ++it ) (**it).select(r, s);
00442 } else {
00443 primaryCollision()->select(r, s);
00444 }
00445 }
00446 }
00447
00448 #endif