diff --git a/.hgtags b/.hgtags --- a/.hgtags +++ b/.hgtags @@ -1,37 +1,40 @@ 0704eccbbae770dd2df2e8145a5dd46e4cb29b66 java-merge 0704eccbbae770dd2df2e8145a5dd46e4cb29b66 pre-cuts-merge 2763da36e168c75a5b48d63a5f44836eb521b343 herwig-2-0-alpha1 337e051dcffc653cd0429988f12806758c183472 release-1-6-1 3f01c180519e15200a4de8e0e9b7f298ab145d57 pre-java-merge 432bd5d28ebdf0c95e737452ac068515c589872f pre-libtool-merge 57f60f2e143afcc16543173ce59601fded4b8247 release-1-7-0 5830e4eb9afe3ba3705341778a40d0fe2dc6567c release-1-8-0 67c66b02adf69f650c77c50d89b698d8ed54c929 release-1-7-2 7e8967c704d1f8a551637a300130587154e9028b LHA-merge 825d126ced6f38223a9b378ba9b09dba4f48751e pre-LHA-merge 8cab12da53be26a852e6a407f53db5e1997fd0b1 release-1-7-1 8d298cf18309cdbded5344990a4955699afff04b cuts-merge b6a8110c61f6226e9a8e0c7f3fa73ec3638bc9c1 herwig-2-0-alpha3 b6a8110c61f6226e9a8e0c7f3fa73ec3638bc9c1 herwig-2-0-beta d063c89add007af8bcff8d8b166576b6b1c091ba release-1-6-0 f4f74476f4db925446c84b54e90c0ef27b82a3d6 libtool-merge d6ba7d425e3ae8b01157223638cbcf0dac939904 release-1-8-1 813a7eb367a9a119998aaf74682a5543bf570da1 release-1-8-2 52eeb52c35cf8b1ceed0e754ef47dd4af282cfa3 release-1-8-3 9ac24d1eb03b6286038402b3420b2520846ce9f0 release-1-9-0 f0ef8fb93d924e1c01a30eeaf172f9fd82d0b4d2 release-1-9-1 2d8e0f74b65ef7f5acdf0128e7280fff535d1f82 release-1-9-2 4cf20ed60ecd8c9016cdaf9e3f6cd0347cee8185 release-2-0-0 7346f289aba9116f5b2327b98adb4b4e8b6a76dc release-2-0-1 16491c05f54af0c4c02cbf40fc3e77120eba8374 release-2-0-2 b08a997136055e39cac6187eeb3c3f84ddc148bc release-2-0-3 9772c45ac9a165f4c30764e1ba1df43d778d6932 release-2-0-4 46d46e5f0edf5bf67b778b86a5515685be648ae5 release-2-1-0 f0a8c5985691243ee3c0b5f79be829a68601a527 release-2-1-1 647f106f32b2d3423854e3791467edd3bb523fec release-2-1-2 f6610876ef80299ea6d470d616539ac82a89a7f9 release-2-1-3 5e3e27541e17c42085935e7a8c6181bdf6a09191 release-2-1-4 eea16346ccff6eeb694b64c7bcfb88c7f525f6f3 release-2-1-5 f0199517f6279a79be29173dfdd727414f45922a release-2-2-0 f0199517f6279a79be29173dfdd727414f45922a release-2-2-0 16e9b5ae0123dc557d34b8561787aa5f8282f58f release-2-2-0 +501eda17fe1bb5cc317c7d9d3d9cafccbd2de057 release-2-1-6 +501eda17fe1bb5cc317c7d9d3d9cafccbd2de057 release-2-1-6 +90387985f69c9b5d34c8b897effabad6fcf6bd3f release-2-1-6 diff --git a/EventRecord/SpinInfo.cc b/EventRecord/SpinInfo.cc --- a/EventRecord/SpinInfo.cc +++ b/EventRecord/SpinInfo.cc @@ -1,208 +1,208 @@ // -*- C++ -*- // // SpinInfo.cc is a part of ThePEG - Toolkit for HEP Event Generation // Copyright (C) 2003-2019 Peter Richardson, Leif Lonnblad // // ThePEG is licenced under version 3 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, non-templated member // functions of the SpinInfo class. // // Author: Peter Richardson // #include "SpinInfo.h" #include "ThePEG/Repository/CurrentGenerator.h" #include "ThePEG/Repository/EventGenerator.h" #include "Event.h" using namespace ThePEG; -const double SpinInfo::_eps=1.0e-6; +const double SpinInfo::_eps=1.0e-8; SpinInfo::SpinInfo(const SpinInfo & x) : EventInfoBase(x), _production(x._production), _decay(x._decay), _timelike(x._timelike), _prodloc(x._prodloc), _decayloc(x._decayloc), _decayed(x._decayed), _developed(x._developed), _oldDeveloped(x._oldDeveloped), _rhomatrix(x._rhomatrix), _Dmatrix(x._Dmatrix),_spin(x._spin), _productionmomentum(x._productionmomentum), _decaymomentum(x._decaymomentum), _currentmomentum(x._currentmomentum) { x._production=VertexPtr(); x._decay=VertexPtr(); // set the vertex so it now points to the copy if(_production) { // for timelike if(_timelike) _production->resetOutgoing(this,_prodloc); // for spacelike else _production->resetIncoming(this,_prodloc); } } EIPtr SpinInfo::clone() const { tcSpinPtr temp=this; return const_ptr_cast(temp); } void SpinInfo::rebind(const EventTranslationMap & trans) { if(_production) _production = trans.translate(_production); if(_decay) _decay = trans.translate(_decay); EventInfoBase::rebind(trans); } NoPIOClassDescription SpinInfo::initSpinInfo; // Definition of the static class description member. void SpinInfo::Init() {} void SpinInfo::update() const { // number of instances fo this object int nref=referenceCount(); if(nref<2||nref>3) return; // work out the number of references there should be int nmin=0; // check the production pointers if(_production) { if(_timelike) { if(_production->outgoing()[_prodloc]==this) ++nmin;} else { if(_production->incoming()[_prodloc]==this) ++nmin;} } // check the decay pointers if(_decay) { if(_decay->incoming()[_decayloc]==this) ++nmin; } // delete the pointers SpinPtr temp; if(nmin+1==nref) { // delete the production pointers if(_production) { if(_timelike) { if(_production->outgoing()[_prodloc]==this) _production->resetOutgoing(SpinPtr(),_prodloc); } else { if(_production->incoming()[_prodloc]==this) _production->resetIncoming(SpinPtr(),_prodloc); } } // delete the decay pointers if(_decay) { if(_decay->incoming()[_decayloc]==this) _decay->resetIncoming(SpinPtr(),_decayloc); } } } void SpinInfo::decay(bool recursive) const { // if the particle has already been decayed do nothing if(_decayed) return; // otherwise we need to obtain the correct rho (timelike) or D (spacelike) matrix assert(_developed!=NeedsUpdate); if(_timelike) { if(_developed==Developed&&iSpin()!=PDT::Spin0) { if(_developed!=NeedsUpdate) _oldDeveloped=_developed; _developed=NeedsUpdate; } if(productionVertex()) { if(recursive) redecay(); else _rhomatrix = productionVertex()->getRhoMatrix(_prodloc,true); } } else { if(_developed==Developed&&iSpin()!=PDT::Spin0) { if(_developed!=NeedsUpdate) _oldDeveloped=_developed; _developed=NeedsUpdate; } if(productionVertex()) { if (recursive) redecay(); else _Dmatrix = productionVertex()->getDMatrix(_prodloc); } } _decaymomentum = _currentmomentum; _decayed=true; } void SpinInfo::undecay() const { // if the particle has not been decayed do nothing if(!_decayed) return; _decayed=false; _developed=_oldDeveloped; } void SpinInfo::redevelop() const { assert(developed()==NeedsUpdate); // calculate rho/D matrix if(_timelike) { _Dmatrix = decayVertex() ? decayVertex()->getDMatrix(decayLocation()) : RhoDMatrix(iSpin()); } else { _rhomatrix = decayVertex() ? decayVertex()->getRhoMatrix(decayLocation(),false) : RhoDMatrix(iSpin()); } // update the D matrix of this spininfo if(_developed!=NeedsUpdate) _oldDeveloped=_developed; _developed = Developed; // update the parent if needed if(productionVertex() && productionVertex()->incoming().size()==1) { tcSpinPtr parent = _timelike ? productionVertex()->incoming()[0] : productionVertex()->outgoing()[0]; if ( parent->developed() != StopUpdate ) { parent->needsUpdate(); parent->redevelop(); } } } void SpinInfo::develop() const { // if the particle has already been developed do nothing switch(_developed) { case Developed: return; case StopUpdate: return; case NeedsUpdate: redevelop(); return; case Undeveloped: if(_timelike) { if(_decay) _Dmatrix = _decay->getDMatrix(_decayloc); else _Dmatrix = RhoDMatrix(iSpin()); } else { if(_decay) _rhomatrix = _decay->getRhoMatrix(_decayloc,false); else _rhomatrix = RhoDMatrix(iSpin()); } if(_developed!=NeedsUpdate) _oldDeveloped=_developed; _developed=Developed; return; } } void SpinInfo::redecay() const { if(!productionVertex()) return; if(productionVertex()->incoming().size()==1) { tcSpinPtr parent; if(productionVertex()->incoming()[0]->timelike()) parent = productionVertex()->incoming()[0]; else { if(productionVertex()->outgoing()[0]!=this) parent = productionVertex()->outgoing()[0]; else parent = productionVertex()->outgoing()[1]; } if ( parent->developed() != StopUpdate ) parent->redecay(); } if(timelike()) _rhomatrix = productionVertex()->getRhoMatrix(_prodloc,true); else _Dmatrix = productionVertex()->getDMatrix(_prodloc); } diff --git a/EventRecord/SpinInfo.h b/EventRecord/SpinInfo.h --- a/EventRecord/SpinInfo.h +++ b/EventRecord/SpinInfo.h @@ -1,480 +1,480 @@ // -*- C++ -*- // // SpinInfo.h is a part of ThePEG - Toolkit for HEP Event Generation // Copyright (C) 2003-2019 Peter Richardson, Leif Lonnblad // // ThePEG is licenced under version 3 of the GPL, see COPYING for details. // Please respect the MCnet academic guidelines, see GUIDELINES for details. // #ifndef ThePEG_SpinInfo_H #define ThePEG_SpinInfo_H // This is the declaration of the SpinInfo class. #include "ThePEG/EventRecord/EventInfoBase.h" #include "ThePEG/PDT/PDT.h" #include "ThePEG/Interface/ClassDocumentation.h" #include "HelicityVertex.h" namespace ThePEG { /** * The SpinInfo is the base class for the spin information for the * spin correlation algorithm. The implementations for different spin * states inherit from this. * * The class contains pointers to the vertex where the particle is * produced and where it decays, together with methods to set/get * these. * * There are two flags decayed which store information on the state * of the particle. * * The decayed() members provides access to the _decay data member * which is true if the spin density matrix required to perform the * decay of a timelike particle has been calculated (this would be a * decay matrix for a spacelike particle.) This is set by the * decay() method which calls a method from the production vertex to * calculate this matrix. The decay() method should be called by a * decayer which uses spin correlation method before it uses the * spin density matrix to calculate the matrix element for the * decay. * * The developed() member provides access to the _developed data * member which is true if the decay matrix required to perform the * decays of the siblings of a particle has been calculated (this * would a spin density matrix for a spacelike particle.) This is * set by the developed() method which calls a method from the decay * vertex to calculate the matrix. The developed() method is called * by a DecayHandler which is capable of performing spin * correlations after all the unstable particles produced by a * decaying particle are decayed. * * Methods are also provided to access the spin density and decay * matrices for a particle. * * @author Peter Richardson * */ class SpinInfo: public EventInfoBase { public: /** * Status for the implementation of spin correlations */ enum DevelopedStatus { Undeveloped=0, /**< Not developed. */ Developed=1, /**< Developed. */ NeedsUpdate=2, /**< Developed but needs recalculating due to some change. */ StopUpdate=3 /**< Stop recalculating at this spin info. */ }; public: /** @name Standard constructors and destructors. */ //@{ /** * Default constructor. */ SpinInfo() : _timelike(false), _prodloc(-1), _decayloc(-1), _decayed(false), _developed(Undeveloped), _oldDeveloped(Undeveloped) {} /** * Standard Constructor. * @param s the spin. * @param p the production momentum. * @param time true if the particle is time-like. */ SpinInfo(PDT::Spin s, const Lorentz5Momentum & p = Lorentz5Momentum(), bool time = false) : _timelike(time), _prodloc(-1), _decayloc(-1), _decayed(false), _developed(Undeveloped), _oldDeveloped(Undeveloped), _rhomatrix(s), _Dmatrix(s), _spin(s), _productionmomentum(p), _currentmomentum(p) {} /** * Copy-constructor. */ SpinInfo(const SpinInfo &); //@} public: /** * Returns true if the polarization() has been implemented in a * subclass. This default version returns false. */ virtual bool hasPolarization() const { return false; } /** * Return the angles of the polarization vector as a pair of * doubles. first is the polar angle and second is the azimuth * wrt. the particles direction. This default version of the * function returns 0,0, and if a subclass implements a proper * function it should also implement 'hasPolarization()' to return * true. */ virtual DPair polarization() const { return DPair(); } public: /** * Standard Init function. */ static void Init(); /** * Rebind to cloned objects. If a FermionSpinInfo is cloned together * with a whole Event and this has pointers to other event record * objects, these should be rebound to their clones in this * function. */ virtual void rebind(const EventTranslationMap & trans); /** * Standard clone method. */ virtual EIPtr clone() const; /** * Method to handle the delelation */ void update() const; /** * Perform a lorentz rotation of the spin information */ virtual void transform(const LorentzMomentum & m, const LorentzRotation & r) { _currentmomentum = m; _currentmomentum.transform(r); } /** * Reset - Undoes any transformations and calls undecay. */ virtual void reset() { _currentmomentum = _productionmomentum; } public: /** @name Access the vertices. */ //@{ /** * Set the vertex at which the particle was produced. */ void productionVertex(VertexPtr in) const { _production=in; // add to the list of outgoing if timelike int temp(-1); if(_timelike) in->addOutgoing(this,temp); // or incoming if spacelike else in->addIncoming(this,temp); _prodloc=temp; } /** * Get the vertex at which the particle was produced. */ tcVertexPtr productionVertex() const { return _production; } /** * Set the vertex at which the particle decayed or branched. */ void decayVertex(VertexPtr in) const { if(in) { _decay=in; if(_timelike) { int temp(-1); in->addIncoming(this,temp); _decayloc=temp; assert(temp==0); } else { int temp(-1); in->addOutgoing(this,temp); _decayloc=temp; } } else { _decay=VertexPtr(); _decayloc=-1; } } /** * Get the vertex at which the particle decayed or branched. */ tcVertexPtr decayVertex() const { return _decay; } //@} /** @name Access information about the associated particle. */ //@{ /** * Has the particle decayed? */ bool decayed() const { return _decayed; } /** * Set if the particle has decayed. */ void decayed(bool b) const { _decayed = b; } /** * Return true if the decay matrix required to perform the decays of * the siblings of a particle has been calculated. */ DevelopedStatus developed() const { return _developed; } /** * Calculate the rho matrix for the decay if not already done. */ void decay(bool recursive=false) const ; /** * Calculate the rho matrix for the decay if not already done. */ virtual void undecay() const ; /** * Set the developed flag and calculate the D matrix for the decay. */ void develop() const ; /** * Needs update */ void needsUpdate() const { if(_developed!=NeedsUpdate) _oldDeveloped = _developed; _developed=NeedsUpdate; } /** * Used for an unstable particle to *temporarily* stop * redevelop and redecay at that particle */ void stopUpdate() const {_developed=StopUpdate;} /** * Return 2s+1 for the particle */ PDT::Spin iSpin() const { return _spin; } /** * Return the momentum of the particle when it was produced. */ const Lorentz5Momentum & productionMomentum() const { return _productionmomentum; } /** * The current momentum of the particle */ const Lorentz5Momentum & currentMomentum() const { return _currentmomentum; } /** * Return true if particle is timelike (rather than spacelike). */ bool timelike() const { return _timelike; } //@} /** * Access to the locations */ //@{ /** * Production Location */ int productionLocation() const {return _prodloc;} /** * Decay Location */ int decayLocation() const {return _decayloc;} //@} public: /** @name Access the rho and D matrices. */ //@{ /** * Access the rho matrix. */ RhoDMatrix rhoMatrix() const { return _rhomatrix; } /** * Access the rho matrix. */ RhoDMatrix & rhoMatrix() { return _rhomatrix; } /** * Access the D matrix. */ RhoDMatrix DMatrix() const { return _Dmatrix; } /** * Access the D matrix. */ RhoDMatrix & DMatrix() { return _Dmatrix; } //@} -protected: +public: /** * Check if momentum is near to the current momentum */ bool isNear(const Lorentz5Momentum & p) { return currentMomentum().isNear(p,_eps); } private: /** * Describe a concrete class without persistent data. */ static NoPIOClassDescription initSpinInfo; /** * Private and non-existent assignment operator. */ SpinInfo & operator=(const SpinInfo &) = delete; private: /** * Set the developed flag and calculate the D matrix for the decay, * and all decays further up the chain. */ void redevelop() const ; /** * Recursively recalulate all the rho matrices from the top of the chain */ void redecay() const ; private: /** * Pointer to the production vertex for the particle */ mutable VertexPtr _production; /** * Pointers to the decay vertex for the particle */ mutable VertexPtr _decay; /** * Is this is timelike (true) or spacelike (false ) particle? This * is used to decide if the particle is incoming or outgoing at the * production vertex */ bool _timelike; /** * Location in the hard vertex array at production. */ mutable int _prodloc; /** * Location in the hard vertex array at decay. */ mutable int _decayloc; /** * Has the particle been decayed? (I.e. has the rho matrix for the * decay been calculated.) */ mutable bool _decayed; /** * Has the particle been developed? (I.e. has the D matrix encoding * the info about the decay been calculated) */ mutable DevelopedStatus _developed; /** * Has the particle been developed? (I.e. has the D matrix encoding * the info about the decay been calculated) */ mutable DevelopedStatus _oldDeveloped; /** * Storage of the rho matrix. */ mutable RhoDMatrix _rhomatrix; /** * Storage of the decay matrix */ mutable RhoDMatrix _Dmatrix; /** * The spin of the particle */ PDT::Spin _spin; /** * Momentum of the particle when it was produced */ Lorentz5Momentum _productionmomentum; /** * Momentum of the particle when it decayed */ mutable Lorentz5Momentum _decaymomentum; /** * Current momentum of the particle */ Lorentz5Momentum _currentmomentum; /** * A small energy for comparing momenta to check if Lorentz Transformations * should be performed */ static const double _eps; }; } namespace ThePEG { /** @cond TRAITSPECIALIZATIONS */ /** * This template specialization informs ThePEG about the base class of * SpinInfo. */ template <> struct BaseClassTrait: public ClassTraitsType { /** Typedef of the base class of SpinInfo. */ typedef EventInfoBase NthBase; }; /** * This template specialization informs ThePEG about the name of the * SpinInfo class and the shared object where it is defined. */ template <> struct ClassTraits : public ClassTraitsBase { /** * Return the class name. */ static string className() { return "ThePEG::SpinInfo"; } }; /** @endcond */ } #endif /* ThePEG_SpinInfo_H */