ThePEG  1.8.0
Particle.h
1 // -*- C++ -*-
2 //
3 // Particle.h is a part of ThePEG - Toolkit for HEP Event Generation
4 // Copyright (C) 1999-2011 Leif Lonnblad
5 //
6 // ThePEG is licenced under version 2 of the GPL, see COPYING for details.
7 // Please respect the MCnet academic guidelines, see GUIDELINES for details.
8 //
9 #ifndef ThePEG_Particle_H
10 #define ThePEG_Particle_H
11 // This is the decalaration of the Particle class.
12 
13 #include "EventConfig.h"
14 #include "ThePEG/Vectors/Lorentz5Vector.h"
15 #include "ThePEG/Vectors/LorentzRotation.h"
16 #include "ThePEG/Utilities/ClassDescription.h"
17 #include "ThePEG/EventRecord/MultiColour.h"
18 #include "ThePEG/EventRecord/SpinInfo.h"
19 #include "ThePEG/PDT/ParticleData.h"
20 
21 namespace ThePEG {
22 
83 class Particle: public EventRecordBase {
84 
85 public:
86 
88  friend class Event;
90  friend class Collision;
92  friend class Step;
94  friend class SubProcess;
96  friend class ParticleData;
97 
98  struct ParticleRep;
99 
100 public:
101 
107  Particle(tcEventPDPtr newData) : theData(newData), theRep(0) {}
108 
112  Particle(const Particle &);
113 
117  virtual ~Particle();
119 
125  bool decayed() const {
126  return hasRep() && !rep().theChildren.empty();
127  }
128 
132  const ParticleVector & children() const {
133  static const ParticleVector null;
134  return hasRep() ? rep().theChildren : null;
135  }
136 
140  void addChild(tPPtr c) {
141  rep().theChildren.push_back(c);
142  (c->rep()).theParents.push_back(this);
143  }
144 
150  void abandonChild(tPPtr child) {
151  removeChild(child);
152  child->removeParent(this);
153  }
154 
158  const tParticleVector & parents() const {
159  static const tParticleVector null;
160  return hasRep() ? rep().theParents : null;
161  }
162 
169  tParticleSet siblings() const;
170 
175  void undecay() {
176  if ( hasRep() ) {
177  rep().theChildren.clear();
178  rep().theNext = tPPtr();
179  }
180  }
181 
185  void decayMode(tDMPtr dm) { rep().theDecayMode = dm; }
186 
190  tDMPtr decayMode() const {
191  return hasRep() ? rep().theDecayMode : tDMPtr();
192  }
193 
198  tPPtr next() const {
199  return hasRep() ? rep().theNext : PPtr();
200  }
201 
206  tPPtr previous() const {
207  return hasRep() ? rep().thePrevious : tPPtr();
208  }
209 
214  tcPPtr original() const {
215  return previous() ? tcPPtr(previous()->original()) : tcPPtr(this);
216  }
217 
223  return previous() ? previous()->original() : tPPtr(this);
224  }
225 
226 
231  tcPPtr final() const {
232  return next() ? tcPPtr(next()->final()) : tcPPtr(this);
233  }
234 
239  tPPtr final() {
240  return next() ? next()->final() : tPPtr(this);
241  }
242 
244 
250  tStepPtr birthStep() const {
251  return hasRep() ? rep().theBirthStep : tStepPtr();
252  }
253 
257  int number() const {
258  return hasRep() ? rep().theNumber : 0;
259  }
261 
267  const ParticleDataClass & data() const { return *theData; }
268 
272  tcEventPDPtr dataPtr() const { return theData; }
273 
277  const string & PDGName() const { return data().PDGName(); }
278 
282  long id() const { return data().id(); }
284 
290  const Lorentz5Momentum & momentum() const { return theMomentum; }
291 
296  void set3Momentum(const Momentum3 & p) {
297  theMomentum.setVect(p);
299  }
300 
305  void setMomentum(const LorentzMomentum & p) {
306  theMomentum = p;
307  }
308 
312  void set5Momentum(const Lorentz5Momentum & p) {
313  theMomentum = p;
314  }
315 
319  Energy mass() const { return momentum().mass(); }
320 
324  Energy nominalMass() const { return data().mass(); }
325 
329  Energy2 scale() const {
330  return hasRep() ? rep().theScale : -1.0*GeV2;
331  }
332 
336  void scale(Energy2 q2) { rep().theScale = q2; }
337 
342  Energy2 vetoScale() const {
343  return hasRep() ? rep().theVetoScale : -1.0*GeV2;
344  }
345 
350  void vetoScale(Energy2 q2) { rep().theVetoScale = q2; }
351 
356  Energy2 mt2() const { return sqr(momentum().t()) - sqr(momentum().z()); }
357 
362  Energy mt() const { return sqrt(mt2()); }
363 
368  Energy2 perpmass2() const { return momentum().perp2() + momentum().mass2(); }
369 
374  Energy perpmass() const { return sqrt(perpmass2()); }
375 
379  double rapidity() const {
380  return ( Pplus() > ZERO && Pminus() > ZERO )?
381  0.5*log(Pplus()/Pminus()) : Constants::MaxFloat;
382  }
383 
387  double eta() const {
388  Energy rho = momentum().rho();
389  return rho > abs(momentum().z())?
390  0.5*log((rho+momentum().z())/(rho-momentum().z())) : Constants::MaxFloat;
391  }
392 
396  Energy Pplus() const { return momentum().plus(); }
400  Energy Pminus() const { return momentum().minus(); }
402 
409  const LorentzPoint & vertex() const {
410  static const LorentzPoint null;
411  return hasRep() ? rep().theVertex : null;
412  }
413 
418  LorentzPoint labVertex() const;
419 
425  return vertex() + lifeLength();
426  }
427 
433  return labVertex() + lifeLength();
434  }
435 
440  const Lorentz5Distance & lifeLength() const {
441  static const Lorentz5Distance null;
442  return hasRep() ? rep().theLifeLength : null;
443  }
444 
448  void setVertex(const LorentzPoint & p) {
449  rep().theVertex = p;
450  }
451 
455  void setLabVertex(const LorentzPoint &);
456 
462  void setLifeLength(const Distance & d) {
465  }
466 
471  void setLifeLength(const LorentzDistance & d) {
472  rep().theLifeLength = d;
473  }
474 
478  void setLifeLength(const Lorentz5Distance & d) {
479  rep().theLifeLength = d;
480  }
481 
485  Time lifeTime() const { return lifeLength().m(); }
486 
488 
494  void transform(const LorentzRotation & r);
495 
500  void boost(double bx, double by, double bz) {
501  transform(LorentzRotation(Boost(bx, by, bz)));
502  }
503 
508  void boost(const Boost & b) { transform(LorentzRotation(b)); }
509 
513  void rotateX(double a);
514 
518  void rotateY(double a);
519 
523  void rotateZ(double a);
524 
528  void rotate(double a, const Axis & axis);
529 
533  void mirror() { theMomentum.setZ(-theMomentum.z()); }
534 
538  void deepTransform(const LorentzRotation & r);
539 
545  void deepBoost(double bx, double by, double bz) {
546  deepTransform(LorentzRotation(Boost(bx, by, bz)));
547  }
548 
553  void deepBoost(const Boost & b) { deepTransform(LorentzRotation(b)); }
554 
558  void deepRotateX(double a);
559 
563  void deepRotateY(double a);
564 
568  void deepRotateZ(double a);
569 
573  void deepRotate(double a, const Axis & axis);
574 
576 
582  double massError() const { return theMomentum.massError(); }
583 
587  double energyError() const { return theMomentum.energyError(); }
588 
592  double rhoError() const { return theMomentum.rhoError(); }
593 
599 
605 
612 
620  bool hasColourInfo() const {
621  return hasRep() && rep().theColourInfo;
622  }
623 
629  return hasColourInfo() ? colourInfo()->antiColourLine() : tColinePtr();
630  }
631 
636  tColinePtr colourLine(bool anti = false) const {
637  if ( anti ) return antiColourLine();
638  return hasColourInfo() ? colourInfo()->colourLine() : tColinePtr();
639  }
640 
645  bool hasColourLine(tcColinePtr line, bool anti = false) const {
646  return hasColourInfo() ? colourInfo()->hasColourLine(line, anti) : false;
647  }
648 
653  bool hasAntiColourLine(tcColinePtr line) const {
654  return hasColourLine(line, true);
655  }
656 
660  bool coloured() const { return data().coloured(); }
661 
665  bool hasColour(bool anti = false) const { return data().hasColour(anti); }
666 
670  bool hasAntiColour() const { return data().hasAntiColour(); }
671 
675  tcCBPtr colourInfo() const {
676  return hasRep() ? rep().theColourInfo : CBPtr();
677  }
678 
683  if ( !rep().theColourInfo ) {
684  switch(theData->iColour()) {
685  case PDT::Colour6:
686  case PDT::Colour6bar:
688  break;
689  default:
691  }
692  }
693  return rep().theColourInfo;
694  }
695 
699  void colourInfo(tCBPtr c) {
700  rep().theColourInfo = c;
701  }
702 
709  template <typename Iterator>
710  typename std::iterator_traits<Iterator>::value_type
711  colourNeighbour(Iterator first, Iterator last, bool anti = false) const;
712 
718  template <typename Iterator>
719  typename std::iterator_traits<Iterator>::value_type
720  antiColourNeighbour(Iterator first, Iterator last) const {
721  return colourNeighbour(first, last, true);
722  }
723 
729  void colourNeighbour(tPPtr, bool anti = false);
730 
736 
741  void antiColourConnect(tPPtr neighbour) {
742  colourConnect(neighbour, true);
743  }
744 
750  void colourConnect(tPPtr neighbour, bool anti = false) {
751  colourNeighbour(neighbour, anti);
752  }
753 
759  tPPtr incomingColour(bool anti = false) const;
760 
766  tPPtr incomingAntiColour() const { return incomingColour(true); }
767 
773  void incomingColour(tPPtr p, bool anti = false) { p->outgoingColour(this, anti); }
774 
779  void incomingAntiColour(tPPtr p) { p->outgoingColour(this, true); }
780 
786  tPPtr outgoingColour(bool anti = false) const;
792  tPPtr outgoingAntiColour() const { return outgoingColour(true); }
793 
799  void outgoingColour(tPPtr, bool anti = false);
800 
806 
810  void colourFlow(tPPtr child, bool anti = false) {
811  outgoingColour(child, anti);
812  }
813 
817  void antiColourFlow(tPPtr child) { colourFlow(child, true); }
818 
822  void resetColour() {
823  if ( hasColourInfo() ) rep().theColourInfo = CBPtr();
824  }
825 
827 
833  tcSpinPtr spinInfo() const {
834  return hasRep() ? rep().theSpinInfo : SpinPtr();
835  }
836 
841  return hasRep() ? rep().theSpinInfo : SpinPtr();
842  }
843 
847  void spinInfo(tSpinPtr s) { rep().theSpinInfo = s; }
849 
855  const EIVector & getInfo() const {
856  static const EIVector null;
857  return hasRep() ? rep().theExtraInfo : null;
858  }
859 
863  EIVector & getInfo() { return rep().theExtraInfo; }
865 
866 public:
867 
874  bool hasRep() const { return theRep; }
875 
880  void initFull();
881 
883 
884 public:
885 
891  void persistentOutput(PersistentOStream &) const;
892 
896  void persistentInput(PersistentIStream &, int);
897 
899 
904  ostream & print(ostream & os, tcStepPtr step = tcStepPtr()) const;
905 
909  template <typename Iterator>
910  static void PrintParticles(ostream & os, Iterator first, Iterator last,
911  tcStepPtr step = tcStepPtr());
912 
916  template <typename Cont>
917  static inline void PrintParticles(ostream & os, const Cont & c,
918  tcStepPtr step = tcStepPtr()) {
919  PrintParticles(os, c.begin(), c.end(), step);
920  }
921 
925  static void Init();
926 
931  static string outputFormat;
932 
933 private:
934 
938  virtual PPtr clone() const;
939 
946  virtual void rebind(const EventTranslationMap &);
947 
951  void number(int n) { rep().theNumber = n; }
952 
956  void removeChild(tPPtr c) {
957  if ( hasRep() )
958  rep().theChildren.erase(remove(rep().theChildren.begin(),
959  rep().theChildren.end(), c),
960  rep().theChildren.end());
961  }
962 
966  void removeParent(tPPtr p) {
967  if ( hasRep() )
968  rep().theParents.erase(remove(rep().theParents.begin(),
969  rep().theParents.end(), p),
970  rep().theParents.end());
971  }
972 
976  void mass(Energy m) { theMomentum.setMass(m); }
977 
982 
988  if ( !hasRep() ) initFull();
989  return *theRep;
990  }
991 
996  const ParticleRep & rep() const {
997  static const ParticleRep null;
998  return hasRep() ? *theRep : null;
999  }
1000 
1005 
1010 
1016 
1017 public:
1018 
1025  struct ParticleRep {
1026 
1030  ParticleRep() : theScale(-1.0*GeV2), theVetoScale(-1.0*GeV2), theNumber(0) {}
1031 
1035  ParticleRep(const ParticleRep &);
1036 
1041 
1046 
1051 
1056 
1062 
1067 
1072 
1077 
1081  Energy2 theScale;
1082 
1086  Energy2 theVetoScale;
1087 
1092 
1097 
1102 
1107 
1108  };
1109 
1110 public:
1111 
1116  virtual void debugme() const;
1117 
1118 protected:
1119 
1124  Particle() : theRep(0) {}
1125 
1130  friend struct ClassTraits<Particle>;
1131 
1132 private:
1133 
1137  Particle & operator=(const Particle &);
1138 
1143 
1144 };
1145 
1149 ostream & operator<<(ostream &, const Particle &);
1150 
1151 
1156 template <>
1157 struct BaseClassTrait<Particle,1>: public ClassTraitsType {
1159  typedef EventRecordBase NthBase;
1160 };
1161 
1164 template <>
1165 struct ClassTraits<Particle>: public ClassTraitsBase<Particle> {
1167  static string className() { return "ThePEG::Particle"; }
1169  static TPtr create() { return TPtr::Create(Particle()); }
1170 };
1171 
1174 }
1175 
1176 #ifndef ThePEG_TEMPLATES_IN_CC_FILE
1177 #include "Particle.tcc"
1178 #endif
1179 
1180 #endif /* ThePEG_Particle_H */