Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-08-06 09:24:06

0001 // -*- C++ -*-
0002 //
0003 // ColourReconnector.h is a part of Herwig - A multi-purpose Monte Carlo event generator
0004 // Copyright (C) 2002-2019 The Herwig Collaboration
0005 //
0006 // Herwig is licenced under version 3 of the GPL, see COPYING for details.
0007 // Please respect the MCnet academic guidelines, see GUIDELINES for details.
0008 //
0009 #ifndef HERWIG_ColourReconnector_H
0010 #define HERWIG_ColourReconnector_H
0011 
0012 #include <ThePEG/Interface/Interfaced.h>
0013 #include "CluHadConfig.h"
0014 #include "ColourReconnector.fh"
0015 
0016 namespace Herwig {
0017 
0018 
0019 using namespace ThePEG;
0020 
0021 /** \ingroup Hadronization
0022  *  \class ColourReconnector
0023  *  \brief Class for changing colour reconnections of partons.
0024  *  \author Alberto Ribon, Christian Roehr
0025  * 
0026  *  This class does the nonperturbative colour rearrangement, after the 
0027  *  nonperturbative gluon splitting and the "normal" cluster formation. 
0028  *  It uses the list of particles in the event record, and the collections of
0029  *  "usual" clusters which is passed to the main method. If the colour 
0030  *  reconnection is actually accepted, then the previous collections of "usual"
0031  *  clusters is first deleted and then the new one is created.
0032  *
0033  * * @see \ref ColourReconnectorInterfaces "The interfaces"
0034  * defined for ColourReconnector.
0035  */
0036 class ColourReconnector: public Interfaced {
0037 
0038 public:
0039 
0040   /**
0041    * Does the colour rearrangement, starting out from the list of particles in
0042    * the event record and the collection of "usual" clusters passed as
0043    * arguments. If the actual rearrangement is accepted, the initial collection of
0044    * clusters is overridden by the old ones.
0045    */
0046   void rearrange(ClusterVector & clusters);
0047 
0048   using CluVecIt = ClusterVector::iterator;
0049 
0050 private:
0051 
0052   /** PRIVATE MEMBER FUNCTIONS */
0053 
0054   /**
0055    * @brief     Calculates the sum of the squared cluster masses.
0056    * @arguments q, aq vectors containing the quarks and antiquarks respectively
0057    * @return    Sum of cluster squared masses M^2_{q[i],aq[i]}.
0058    */
0059   Energy2 _clusterMassSum(const PVector & q, const PVector & aq) const;
0060   
0061   
0062   
0063   /**
0064    * @brief     calculates the "euclidean" distance of two quarks in the 
0065    *            rapdidity-phi plane
0066    * @arguments p, q the two quarks
0067    * @return    the dimensionless distance:
0068    *            \deltaR_12=sqrt(\deltaY_12^2 + \delta\phi_12^2)
0069    */
0070   double _displacement(tcPPtr p, tcPPtr q) const;
0071   
0072    
0073   /**
0074    * @brief     calculates the "euclidean" distance of a the 3 (anti)quarks
0075    *            (anti)baryonic cluster in the rapdidity-phi plane
0076    * @arguments p, q the two quarks
0077    * @return    the dimensionless distance:
0078    *            if Junction is enabled the difference of all 3 quarks
0079    *            with respect to their mean point is calculated:
0080    *                <Y>    = sum_i Y_i/3
0081    *                <\phi> = sum_i \phi_i/3
0082    *                \deltaR     = sum_i sqrt( (Y_i - <Y>)^2 + (\phi_i - <phi>)^2)
0083    *
0084    *            if Junction is disabled the difference of all distinct
0085    *            pairing of the 3 quarks is computed:
0086    *                \deltaR_ij  = sqrt(\deltaY_ij^2 + \delta\phi_ij^2)
0087    *                \deltaR_tot = sum_{i,j<i} \deltaR_ij
0088    *            
0089    *            NOTE:   switch the Junction option will necessarily
0090    *                    need to be combined with a change (or re-tune)
0091    *                    of _mesonToBaryonFactor otherwise no well 
0092    *                    description is to be expected
0093    *            TODO:   maybe add a different p-norm option to get
0094    *                    more phenomenology
0095    */
0096   double _displacementBaryonic(tcPPtr p1, tcPPtr p2, tcPPtr p3) const;
0097 
0098   
0099   /**
0100    * @brief  Examines whether the cluster vector (under the given permutation of
0101    *         the antiquarks) contains colour-octet clusters
0102    * @param  cv Cluster vector
0103    * @param  P  Permutation, a vector of permutated indices from 0 to
0104    *            cv.size()-1
0105    */
0106   bool _containsColour8(const ClusterVector & cv, const vector<size_t> & P) const;
0107 
0108   /**
0109    * @brief     A Metropolis-type algorithm which finds a local minimum in the
0110    *            total sum of cluster masses
0111    * @arguments cv cluster vector
0112    */
0113   void _doRecoStatistical(ClusterVector & cv) const;
0114 
0115   /**
0116    * @brief     Plain colour reconnection as used in Herwig 2.5.0
0117    * @arguments cv cluster vector
0118    */
0119   void _doRecoPlain(ClusterVector & cv) const;
0120 
0121 
0122   /**
0123    * Baryonic Colour Reconnection model
0124    */
0125   void _doRecoBaryonic(ClusterVector & cv) const;
0126   
0127   
0128   /**
0129    * @brief     BaryonicMesonic colour reconnection model
0130    * @arguments cv cluster vector
0131    * BaryonicMesonic Colour Reconnection model with reconnections from mesonic clusters
0132    * to baryonic cluster and the contrary. Allows also reconnection between mesonic
0133    * and baryonic Clusters 
0134    */
0135   void _doRecoBaryonicMesonic(ClusterVector & cv) const; 
0136   
0137   
0138 
0139 
0140   void _makeBaryonicClusters(ClusterPtr &c1, ClusterPtr &c2, ClusterPtr &c3,
0141                  ClusterPtr &newcluster1, ClusterPtr &newcluster2) const;
0142   
0143 
0144   /**
0145    * @brief     Finds the cluster in cv which, if reconnected with the given
0146    *            cluster cl, would result in the smallest sum of cluster masses.
0147    *            If no reconnection partner can be found, a pointer to the
0148    *            original Cluster cl is returned.
0149    * @arguments cv cluster vector
0150    *            cl cluster iterator (must be from cv) which wants to have a reconnection partner
0151    * @return    iterator to the found cluster, or the original cluster pointer if
0152    *            no mass-reducing combination can be found
0153    */
0154 
0155 
0156   CluVecIt _findRecoPartner(CluVecIt cl, ClusterVector & cv) const;
0157 
0158   CluVecIt _findPartnerRapidity(CluVecIt cl, ClusterVector & cv) const;
0159 
0160   CluVecIt _findPartnerBaryonic(CluVecIt cl, ClusterVector & cv, 
0161                                                bool & tetraCand, 
0162                                                const ClusterVector& a, 
0163                                                CluVecIt  &baryonic1,
0164                                                CluVecIt  &baryonic2 ) const;
0165   
0166   /**
0167    * @brief     Finds best CR option for the BaryonicMesonic CR model
0168    * @arguments cls vector of selected clusters, baryonic is the number of baryonic
0169    *            clusters in selection, kind_of_reco is output string denoting best
0170    *            CR option and reco_info is output storage for information on which
0171    *            (anti-)quarks to exchange and in which way.
0172    * BaryonicMesonic Colour Reconnection model with reconnections from mesonic clusters
0173    * to baryonic cluster and the contrary. Allows also reconnection between mesonic
0174    * and baryonic Clusters 
0175    */
0176   void _findbestreconnectionoption(std::vector<CluVecIt> &cls,
0177                                             const unsigned &baryonic,
0178                                             string &kind_of_reco,
0179                                             int (&reco_info)[3]) const;
0180 
0181   /**
0182    * @brief     Reconnects the constituents of the given clusters to the (only)
0183    *            other possible cluster combination.
0184    * @return    pair of pointers to the two new clusters
0185    * Used for Plain and Baryonic Colour Reconnection models
0186    */
0187   pair <ClusterPtr,ClusterPtr> _reconnect(ClusterPtr &c1, ClusterPtr &c2) const;
0188   
0189   /**
0190    * @brief     Reconnects (2B->2B) the constituents of the given clusters to 
0191                 another possible cluster combination whose information is given 
0192                 in s1 and s2.
0193    * @arguments c1 and c2 are baryonic clusters and s1 and s2 are the respective
0194                 indices of the constituents of c1 and c2 respectively 
0195    * @return    pair of pointers to the two new clusters
0196    * Used only in BaryonicMesonic algorithm and will exchange constituent s1 of
0197    * c1 with constituent s2 of c2
0198    */
0199   pair <ClusterPtr,ClusterPtr> _reconnect2Bto2B(ClusterPtr &c1, ClusterPtr &c2, const int s1, const int s2) const;
0200   
0201   /**
0202    * @brief     Reconnects (B,Bbar->3M) the constituents of the given clusters to 
0203                 another possible cluster combination whose information is given in 
0204                 s0, s1 and s2.
0205    * @arguments c1 and c2 are baryonic clusters. s0, s1 and s2 are the respective
0206                 indices which determine the CR 
0207    * @return    tuple of pointers to the 3 new mesonic clusters
0208    * Used only in BaryonicMesonic algorithm and will form 3 mesonic clusters according
0209    * to the indices s0, s1 and s2. The i-th constituent of c1 is connected to the si-th 
0210    * constituent of c2
0211    */
0212   std::tuple  <ClusterPtr, ClusterPtr, ClusterPtr> _reconnectBbarBto3M(ClusterPtr &c1, ClusterPtr &c2, const int s0, const int s1, const int s2 ) const;
0213   
0214   /**
0215    * @brief     Reconnects (3M->3M) the constituents of the given clusters to 
0216                 another possible cluster combination whose information is given in 
0217                 sinfos
0218    * @arguments c1, c2 and c3 are mesonic clusters. infos[3] are the respective
0219                 indices which determine the CR 
0220    * @return    tuple of pointers to the 3 CR'd mesonic clusters
0221    * Used only in BaryonicMesonic algorithm and will reconnect 3 mesonic clusters according
0222    * to the infos, which determine the CR. The coloured quark of the i-th cluster forms 
0223    * a new cluster with the anticoloured quark of the info[i]-th cluster
0224    */
0225   std::tuple  <ClusterPtr, ClusterPtr, ClusterPtr> _reconnect3Mto3M(ClusterPtr &c1, ClusterPtr &c2, ClusterPtr &c3, const int infos[3] ) const;
0226   
0227    
0228     /**
0229    * Reconnection method for a Baryonic and a Mesonic Cluster to a Baryonic and a Mesonic Cluster
0230    * s0 is the Number of the (Anti)Patrticle of the Baryonic Cluster , which should be swapped with the Anti(Particle) of the Mesonic Cluster
0231    */ 
0232   /**
0233    * @brief     Reconnects the constituents of the given clusters to 
0234                 another possible cluster combination whose information 
0235                 is given in s0.
0236    * @arguments c1 and c2 are one baryonic and one mesonic cluster respectively 
0237                 and s0 is the respective index of the constituents of the baryonic
0238                 cluster which is to be exchangeed with the mesonic cluster.
0239    * @return    pair of pointers to the two new clusters
0240    * Used only in BaryonicMesonic algorithm and will exchange constituent s0 of
0241    * the baryonic cluster with the (anti)-quark of the mesonic cluster
0242    */
0243   pair  <ClusterPtr, ClusterPtr> _reconnectMBtoMB(ClusterPtr &c1, ClusterPtr &c2, const int s0) const;
0244   
0245   
0246   
0247   
0248   /**
0249    * Methods for the BaryonicMesonic CR algorithm
0250    * Find the best reconnection option for the respective cluster-combination 
0251    * 
0252    */
0253 
0254   /**
0255    * @brief     veto for far apart clusters
0256    * @arguments expects at most 3 CluVecIt in clu vector
0257    * @return    returns true if clusters are more distant than _maxDistance 
0258    *            in space
0259    * TODO: problematic maybe add option to turn off
0260    */
0261   bool _clustersFarApart( const std::vector<CluVecIt> & clu ) const;
0262     
0263   /**
0264    * @brief     Does reconnect 2 beam clusters for BaryonicMesonic CR model
0265    *            if option CR2BeamClusters is enabled
0266    * @arguments cv cluster vector
0267    */
0268   void _doReco2BeamClusters(ClusterVector & cv) const;
0269 
0270 
0271   /**
0272    * @brief     finds the best reconnection option and stores it in bswap1
0273    *            and bswap2 (2B->2B colour reconnection)
0274    * @arguments c1 and c2 cluster pointers and kind_of_reco will output
0275    *            the best found reconnection option for c1 and c2
0276    */
0277   void _2Bto2BreconnectionFinder(ClusterPtr &c1, ClusterPtr &c2, int &bswap1, int &bswap2, double mindisplsum, string &kind_of_reco ) const;
0278 
0279   /**
0280    * @brief     finds the best reconnection option and stores it in mswap0
0281    *            mswap1 and mswap2 (BbarB->3M colour reconnection)
0282    * @arguments c1 and c2 cluster pointers and kind_of_reco will output
0283    *            the best found reconnection option for c1 and c2
0284    */
0285   void _BbarBto3MreconnectionFinder(ClusterPtr &c1, ClusterPtr &c2, int &mswap0, int &mswap1, int &mswap2,
0286                                                             double min_displ_sum, string & kind_of_reco) const; 
0287 
0288   /**
0289    * @brief     finds the best reconnection option and stores it in swap
0290    *            (BM->BM colour reconnection)
0291    * @arguments c1 and c2 cluster pointers and kind_of_reco will output
0292    *            the best found reconnection option for c1 and c2
0293    */
0294   void _BMtoBMreconnectionfinder(ClusterPtr &c1, ClusterPtr &c2, int &swap, 
0295                                                             double min_displ_sum, string &kind_of_reco) const;
0296 
0297   /**
0298    * @brief     finds the best reconnection option and stores it in swap0,
0299    *            swap1 and swap2 (3M->{3M,BbarB} colour reconnection)
0300    * @arguments c1 and c2 cluster pointers and kind_of_reco will output
0301    *            the best found reconnection option for c1 and c2
0302    */
0303   void _3MtoXreconnectionfinder(std::vector<CluVecIt> &cv, int &swap0, int &swap1,
0304                                                                 int &swap2, double min_displ_sum, string &kind_of_reco) const;
0305 
0306   /**
0307    * @brief     At random, swap two antiquarks, if not excluded by the
0308    *            constraint that there must not be any colour-octet clusters.
0309    * @arguments q, aq vectors containing the quarks and antiquarks respectively
0310    *            maxtries  maximal number of tries to find a non-colour-octet
0311    *                      reconfiguration
0312    * @return    Pair of ints indicating the indices of the antiquarks to be
0313    *            swapped. Returns (-1,-1) if no valid reconfiguration could be
0314    *            found after maxtries trials
0315    */
0316   pair <int,int>
0317     _shuffle(const PVector & q, const PVector & aq, unsigned maxtries = 10) const;
0318 
0319 
0320   /** DATA MEMBERS */
0321 
0322   /**
0323    * Specifies the colour reconnection algorithm to be used.
0324    */
0325   int _algorithm = 0;
0326 
0327   /**
0328    * Do we do colour reconnections?
0329    */
0330   int _clreco = 0;
0331 
0332   /**
0333    * Do we want debug informations? 
0334    */
0335   int _debug = 0;
0336   
0337   /**
0338    * @brief     Junction-like model for BaryonicMesonic model
0339    * Do we want to use the junction-like model for
0340    * computing the displacements of BaryonicMesonic model?
0341    * otherwise pairwise distances are used.
0342    * If _junctionMBCR is activated the displacements are computed in the
0343    * rapidity-Phi plane by difference to the average rapidity and phi:
0344    * DeltaR_i^2 = (rapidity_i - meanRap)^2 + (phi_i - meanPhi)^2 
0345    * DeltaR = sum_i DeltaR_i 
0346    * if _junctionMBCR=0 the displacements are computed:
0347    * DeltaR_ij^2 = (rapidity_i - rapidity_j)^2 + (phi_i - phi_j)^2 
0348    * DeltaR = sum_i,j<i DeltaR_ij
0349    */
0350   int _junctionMBCR = 1;
0351 
0352   /**
0353    * Statistical Reco: 
0354    * Factor used to determine the initial temperature according to
0355    * InitialTemperature = _initTemp * median {energy changes in a few random
0356    * rearrangements}
0357    */
0358   double _initTemp = 0.01;
0359 
0360   /**
0361    * Statistical Reco: 
0362    * The annealing factor is the ratio of two successive temperature steps:
0363    * T_n = _annealingFactor * T_(n-1)
0364    */
0365   double _annealingFactor = 0.21;
0366 
0367   /**
0368    * Statistical Reco: 
0369    * Number of temperature steps in the statistical annealing algorithm
0370    */
0371   unsigned int _annealingSteps = 10;
0372 
0373   /**
0374    * Statistical Reco:
0375    * The number of tries per temperature steps is the number of clusters times
0376    * this factor.
0377    */
0378   double _triesPerStepFactor = 0.66;
0379 
0380   /**
0381    * Probability that a found reconnection possibility is actually accepted.
0382    * used in Plain & Baryonic CR
0383    */
0384   double _preco = 0.5;
0385 
0386   /**
0387    * Probability that a found reconnection possibility is actually accepted.
0388    * used in Baryonic CR
0389    */
0390   double _precoBaryonic = 0.5;
0391 
0392   /**
0393    * Probability that a found reconnection possibility is actually accepted.
0394    * For reconnecting 3M -> 3M'
0395    * used in BaryonicMesonic
0396    * NOTE: if 0 this type of reconnection is not even tried
0397    */
0398   double _preco3M_3M = 0.5;
0399 
0400   /**
0401    * Probability that a found reconnection possibility is actually accepted.
0402    * For reconnecting 3M -> B,Bbar
0403    * used in BaryonicMesonic
0404    */
0405   double _preco3M_BBbar = 0.5;
0406 
0407   /**
0408    * Probability that a found reconnection possibility is actually accepted.
0409    * For reconnecting Bbar,B -> 3M
0410    * used in BaryonicMesonic
0411    */
0412   double _precoBbarB_3M = 0.5;
0413   
0414   /**
0415    * Probability that a found reconnection possibility is actually accepted.
0416    * For reconnecting 2B -> 2B' or 2Bbar -> 2Bbar' 
0417    * used in BaryonicMesonic
0418    * NOTE: if 0 this type of reconnection is not even tried
0419    */
0420   double _preco2B_2B = 0.5;
0421   
0422   /**
0423    * Probability that a found reconnection possibility is actually accepted.
0424    * For reconnecting M,B -> M',B' or M,Bbar -> M',Bbar'
0425    * used in BaryonicMesonic
0426    * NOTE: if 0 this type of reconnection is not even tried
0427    */
0428   double _precoMB_MB = 0.5;
0429   
0430   /**
0431    * For the BaryonicMesonic algorithm
0432    * How many times do suggest cluster for reconnection?
0433    * n(reconnectionstries) = _stepFactor * n(clusters)*n(clusters);
0434    */ 
0435   double _stepFactor = 5.0;
0436 
0437   /**
0438    * Factor for comparing mesonic clusters to baryonic clusters
0439    */
0440   double _mesonToBaryonFactor = 2.0;
0441 
0442   /**
0443    *  Maximium distance for reconnections
0444    *  TODO: remove if issues with anticausality are discussed and resolved
0445    */
0446   Length _maxDistance = femtometer;
0447 
0448   /**
0449    * @return    true, if the two partons are splitting products of the same
0450    *        gluon
0451    */
0452   bool _isColour8(tcPPtr p, tcPPtr q) const;
0453   
0454   /**
0455    *  Option for handling octets
0456    */
0457   unsigned int _octetOption = 0;
0458 
0459   /**
0460    *  Option for colour reconnecting 2 Beam Clusters if no others are present
0461    */
0462   int _cr2BeamClusters = 0;
0463 
0464   /**
0465    *  Option for performing Plain colour reconnection before the Statistical,
0466    *  Baryonic or BaryonicMesonic algorithm is performed
0467    */
0468   int _prePlainCR = 0;
0469 
0470   /**
0471    *  Option for colour reconnecting Clusters only if their vertex 3-distance
0472    *  is less than _maxDistance
0473    */
0474   int _localCR = 0;
0475 
0476   /**
0477    *  Option for colour reconnecting Clusters only if their spacetime difference
0478    *  is bigger than 0
0479    */
0480   int _causalCR = 0;
0481 
0482 public:
0483 
0484   /** @name Functions used by the persistent I/O system. */
0485   //@{
0486   /**
0487    * Function used to write out object persistently.
0488    * @param os the persistent output stream written to.
0489    */
0490   void persistentOutput(PersistentOStream & os) const;
0491 
0492   /**
0493    * Function used to read in object persistently.
0494    * @param is the persistent input stream read from.
0495    * @param version the version number of the object when written.
0496    */
0497   void persistentInput(PersistentIStream & is, int version);
0498   //@}
0499 
0500   /**
0501    * Standard Init function used to initialize the interfaces.
0502    */
0503   static void Init();
0504 
0505 protected:
0506 
0507   /** @name Clone Methods. */
0508   //@{
0509   /**
0510    * Make a simple clone of this object.
0511    * @return a pointer to the new object.
0512    */
0513   virtual IBPtr clone() const;
0514 
0515   /** Make a clone of this object, possibly modifying the cloned object
0516    * to make it sane.
0517    * @return a pointer to the new object.
0518    */
0519   virtual IBPtr fullclone() const;
0520   //@}
0521 
0522 
0523 private:
0524 
0525   /**
0526    * Private and non-existent assignment operator.
0527    */
0528   ColourReconnector & operator=(const ColourReconnector &) = delete;
0529 
0530 
0531 };
0532 
0533 
0534 }
0535 
0536 #endif /* HERWIG_ColourReconnector_H */
0537