Back to home page

EIC code displayed by LXR

 
 

    


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

0001 // -*- C++ -*-
0002 //
0003 // DipoleEventRecord.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_DipoleEventRecord_H
0010 #define HERWIG_DipoleEventRecord_H
0011 //
0012 // This is the declaration of the DipoleEventRecord class.
0013 //
0014 
0015 #include "Herwig/Shower/ShowerEventRecord.h"
0016 #include "Herwig/Shower/PerturbativeProcess.h"
0017 #include "ThePEG/PDF/PDF.h"
0018 #include "Dipole.h"
0019 #include "DipoleChain.h"
0020 #include "Herwig/MatrixElement/Matchbox/Utility/DensityOperator.h"
0021 
0022 #include <tuple>
0023 
0024 namespace Herwig {
0025 
0026 using namespace ThePEG;
0027 
0028 /**
0029  * \ingroup DipoleShower
0030  * \author Simon Platzer, Johannes Bellm
0031  *
0032  * \brief Generalized dipole splitting info to deal with subleading-N
0033  * splittings.
0034  */
0035 class SubleadingSplittingInfo
0036   : public DipoleSplittingInfo {
0037 
0038 public:
0039 
0040   /**
0041    * Default constructor
0042    */
0043   SubleadingSplittingInfo()
0044     : DipoleSplittingInfo() {}
0045 
0046   /**
0047    * Get the iterator of the emitter dipole chain
0048    */
0049   list<DipoleChain>::iterator emitterChain() const { return theEmitterChain; }
0050 
0051   /**
0052    * Get the iterator of the emitter dipole
0053    */
0054   list<Dipole>::iterator emitterDipole() const { return theEmitterDipole; }
0055 
0056   /**
0057    * Get the iterator of the spectator dipole chain
0058    */
0059   list<DipoleChain>::iterator spectatorChain() const { return theSpectatorChain; }
0060 
0061   /**
0062    * Get the iterator of the spectator dipole
0063    */
0064   list<Dipole>::iterator spectatorDipole() const { return theSpectatorDipole; }
0065 
0066   /**
0067    * Get the starting scale
0068    */
0069   Energy startScale() const { return theStartScale; }
0070   
0071   /**
0072    * Set the iterator of the emitter dipole chain
0073    */
0074   void emitterChain(list<DipoleChain>::iterator it) { theEmitterChain = it; }
0075 
0076   /**
0077    * Set the iterator of the emitter dipole
0078    */
0079   void emitterDipole(list<Dipole>::iterator it) { theEmitterDipole = it; }
0080 
0081   /**
0082    * Set the iterator of the spectator dipole chain
0083    */
0084   void spectatorChain(list<DipoleChain>::iterator it) { theSpectatorChain = it; }
0085 
0086   /**
0087    * Set the iterator of the spectator dipole
0088    */
0089   void spectatorDipole(list<Dipole>::iterator it) { theSpectatorDipole = it; }
0090 
0091   /**
0092    * Set the starting scale
0093    */
0094   void startScale(Energy s) { theStartScale = s; }
0095 
0096 private:
0097 
0098   /**
0099    * Iterator of the emitter dipole chain
0100    */
0101   list<DipoleChain>::iterator theEmitterChain;
0102 
0103   /**
0104    * Iterator of the emitter dipole
0105    */
0106   list<Dipole>::iterator theEmitterDipole;
0107 
0108   /**
0109    * Iterator of the spectator dipole chain
0110    */
0111   list<DipoleChain>::iterator theSpectatorChain;
0112 
0113   /**
0114    * Iterator of the spectator dipole
0115    */
0116   list<Dipole>::iterator theSpectatorDipole;
0117 
0118   /**
0119    * The starting scale
0120    */
0121   Energy theStartScale;
0122 
0123 };
0124 
0125 /**
0126  * \ingroup DipoleShower
0127  * \author Simon Platzer, Stephen Webster
0128  *
0129  * \brief The DipoleEventRecord class is 
0130  * used internally by the dipole shower.
0131  */
0132 class DipoleEventRecord : public ShowerEventRecord {
0133 
0134 public:
0135 
0136   /**
0137    * The default constructor.
0138    */
0139   DipoleEventRecord() {}
0140 
0141   /**
0142    * The default destructor just cleans up.
0143    */
0144   ~DipoleEventRecord() { clear(); }
0145 
0146 public:
0147 
0148   /**
0149    * Return any non-coloured outgoing particles in the
0150    * current subprocess.
0151    */
0152   PList& hard() { return theHard; }
0153 
0154   /**
0155    * Return any non-coloured outgoing particles in the
0156    * current subprocess.
0157    */
0158   const PList& hard() const { return theHard; }
0159 
0160   /**
0161    * Return the momentum of the hard system
0162    */
0163   const Lorentz5Momentum& pX() const { return thePX; }
0164 
0165   /**
0166    * Return the particles after emission.
0167    */
0168   cPDVector& particlesAfter() { return theParticlesAfter; }
0169   
0170   /**
0171    * Return the particles after emission.
0172    */
0173   const cPDVector& particlesAfter() const { return theParticlesAfter; }
0174   
0175   /**
0176    * Return the particles before emission.
0177    */
0178   cPDVector& particlesBefore() { return theParticlesBefore; }
0179   
0180   /**
0181    * Return the particles before emission.
0182    */
0183   const cPDVector& particlesBefore() const { return theParticlesBefore; }
0184 
0185   /**
0186    * Return the momenta after emission.
0187    */
0188   vector<Lorentz5Momentum>& momentaAfter() { return theMomentaAfter; }
0189   
0190   /**
0191    * Return the momenta after emission.
0192    */
0193   const vector<Lorentz5Momentum>& momentaAfter() const { return theMomentaAfter; }
0194 
0195   /**
0196    * Return the dictionary for the particles
0197    */
0198   map<PPtr,size_t>& particleIndices() { return theParticleIndices; }
0199 
0200   /**
0201    * Return the dictionary for the particles
0202    */
0203   const map<PPtr,size_t>& particleIndices() const { return theParticleIndices; }
0204 
0205   /**
0206    * Return the density operator
0207    */
0208   DensityOperator& densityOperator() { return theDensityOperator; }
0209 
0210   /**
0211    * Return the density operator
0212    */
0213   const DensityOperator& densityOperator() const { return theDensityOperator; }
0214   
0215   /**
0216    * Set the subleading Nc flag and the number of emissions to calculate
0217    * subleading Nc corrections for.
0218    */
0219   void setSubleadingNc( bool doSub, size_t emissionsLimit ) { 
0220     doSubleadingNc = doSub;
0221     continueSubleadingNc = doSub;
0222     subleadingNcEmissionsLimit = emissionsLimit;
0223   }
0224   
0225   /**
0226    * Get the continue subleading Nc flag.
0227    */
0228   bool getContinueSubleadingNc() const { return continueSubleadingNc; }
0229 
0230   /**
0231    * Set the scheme and cutoff for the density operator evolution.
0232    */
0233   void setDensityOperatorEvolution( int scheme, Energy2 cutoff ) {
0234     densityOperatorEvolution = scheme;
0235     densityOperatorCutoff = cutoff;
0236   }
0237 
0238   /**
0239    * Calculates the dipole kernel to use for the density operator evolution. Takes
0240    * the index of the emitter and spectator, and momentum invariants.
0241    */
0242   double dipoleKernelForEvolution(size_t em, size_t spec, 
0243                   Energy2 pEmitpSpec, Energy2 pEmitpEmis, 
0244                   Energy2 pEmispSpec);
0245 
0246   /**
0247    * Transform all intermediate, hard and outgoing
0248    * particles using the given transformation.
0249    * Also update their spinInfo if applicable.
0250    */
0251   void transform(const LorentzRotation& rot);
0252 
0253 public:
0254 
0255   /**
0256    * Return the dipole chains to be showered.
0257    */
0258   const list<DipoleChain>& chains() const { return theChains; }
0259 
0260   /**
0261    * Access the dipole chains to be showered.
0262    */
0263   list<DipoleChain>& chains() { return theChains; }
0264 
0265   /**
0266    * Return the dipole chains which ceased evolving.
0267    */
0268   const list<DipoleChain>& doneChains() const { return theDoneChains; }
0269 
0270   /**
0271    * Access the dipole chains which ceased evolving.
0272    */
0273   list<DipoleChain>& doneChains() { return theDoneChains; }
0274 
0275   /**
0276    * Return true, if there are chains to be
0277    * showered.
0278    */
0279   bool haveChain() const { return !theChains.empty(); }
0280 
0281   /**
0282    * Return the current dipole chain
0283    */
0284   DipoleChain& currentChain() { assert(haveChain()); return theChains.front(); }
0285 
0286   /**
0287    * Pop the current dipole chain
0288    */
0289   void popChain();
0290 
0291   /**
0292    * Remove the given chain.
0293    */
0294   void popChain(list<DipoleChain>::iterator);
0295 
0296   /**
0297    * Remove the given chains.
0298    */
0299   void popChains(const list<list<DipoleChain>::iterator>&);
0300 
0301   /**
0302    * Create a merged dipole index given two independent dipoles;
0303    * the first dipole is to provide the emitter.
0304    */
0305   DipoleIndex 
0306   mergeIndex(list<Dipole>::iterator firstDipole, const pair<bool,bool>& whichFirst,
0307          list<Dipole>::iterator secondDipole, const pair<bool,bool>& whichSecond) const;
0308 
0309   /**
0310    * Create a SubleadingSplitingInfo given two independent dipoles;
0311    * the first dipole is to provide the emitter.
0312    */
0313   SubleadingSplittingInfo 
0314   mergeSplittingInfo(list<DipoleChain>::iterator firstChain, list<Dipole>::iterator firstDipole, 
0315              const pair<bool,bool>& whichFirst,
0316              list<DipoleChain>::iterator secondChain, list<Dipole>::iterator secondDipole, 
0317              const pair<bool,bool>& whichSecond) const;
0318 
0319   /**
0320    * Return a list of all possible subleading-N emitting pairs
0321    */
0322   void getSubleadingSplittings(list<SubleadingSplittingInfo>&);
0323 
0324 public:
0325 
0326   /**
0327    * Split the dipole pointed to by the given iterator.
0328    * Return references to the affected chains, and update
0329    * iterators pointing to the children in the returned
0330    * chains.
0331    */
0332 
0333   void split(list<Dipole>::iterator dip,
0334          DipoleSplittingInfo& dsplit,
0335          pair<list<Dipole>::iterator,list<Dipole>::iterator>& childIterators,
0336          DipoleChain*& firstChain, DipoleChain*& secondChain) {
0337     split(dip,theChains.begin(),dsplit,childIterators,firstChain,secondChain,false);
0338   }
0339 
0340   /**
0341    * Split the dipole pointed to by the given iterator
0342    * in the indicated chain, indicating a splitting with
0343    * a colour spectator.
0344    * Return references to the affected chains, and update
0345    * iterators pointing to the children in the returned
0346    * chains.
0347    */
0348   void split(list<Dipole>::iterator dip,
0349          list<DipoleChain>::iterator ch,
0350          DipoleSplittingInfo& dsplit,
0351          pair<list<Dipole>::iterator,list<Dipole>::iterator>& childIterators,
0352          DipoleChain*& firstChain, DipoleChain*& secondChain,
0353          bool colourSpectator = true);
0354   
0355   /**
0356    * As split, but not touching the acctual event record.
0357    */
0358   
0359   pair<PVector,PVector> tmpsplit(list<Dipole>::iterator dip,
0360              DipoleSplittingInfo& dsplit,
0361              pair<list<Dipole>::iterator,list<Dipole>::iterator>& childIterators,
0362              DipoleChain*& firstChain, DipoleChain*& secondChain) {
0363     return tmpsplit(dip,theChains.begin(),dsplit,childIterators,firstChain,secondChain,false);
0364   }
0365   
0366   /**
0367    * As split, but not touching the acctual event record.
0368    */
0369   pair<PVector,PVector> tmpsplit(list<Dipole>::iterator dip,
0370              list<DipoleChain>::iterator ch,
0371              DipoleSplittingInfo& dsplit,
0372              pair<list<Dipole>::iterator,list<Dipole>::iterator>& childIterators,
0373              DipoleChain*& firstChain, DipoleChain*& secondChain,
0374              bool colourSpectator = true);
0375 
0376 
0377   /**
0378    * Let the given dipole take the recoil of 
0379    * the indicated splitting.
0380    */
0381   void recoil(list<Dipole>::iterator dip,
0382           list<DipoleChain>::iterator ch,
0383           DipoleSplittingInfo& dsplit);
0384 
0385   /**
0386    * Peform a subleading-N splitting
0387    */
0388   void splitSubleading(SubleadingSplittingInfo& dsplit,
0389                pair<list<Dipole>::iterator,list<Dipole>::iterator>& childIterators,
0390                DipoleChain*& firstChain, DipoleChain*& secondChain);
0391 
0392   /**
0393    * Update the particles upon insertion of the
0394    * given splitting.
0395    */
0396   void update(DipoleSplittingInfo& dsplit);
0397   
0398   /**
0399    * As update, but not touching the acctual event record.
0400    */
0401   pair<PVector,PVector> tmpupdate(DipoleSplittingInfo& dsplit);
0402 
0403   /**
0404    * Inverse of update, updateInverse(update(dsplit)) would return the 
0405    * event record to the state if update would not have been called.
0406    */
0407   void updateInverse(DipoleSplittingInfo& dsplit);
0408 
0409   /**
0410    * Return the dipole(s) containing the incoming
0411    * partons after the evolution has ended. Put back
0412    * the chains containing these to the chains to be
0413    * showered.
0414    */
0415   list<pair<list<Dipole>::iterator,list<DipoleChain>::iterator> >
0416   inDipoles();
0417 
0418   /**
0419    * Fill the given step and return incoming partons.
0420    */
0421   tPPair fillEventRecord(StepPtr step, bool firstInteraction, bool realigned);
0422 
0423 public:
0424 
0425   /**
0426    * Prepare the event record for the given
0427    * subprocess.
0428    */
0429   const map<PPtr,PPtr>& prepare(tSubProPtr subpro,
0430                                 tStdXCombPtr xc,
0431                 StepPtr step,
0432                                 const pair<PDF,PDF>& pdf,
0433                 tPPair beam,
0434                 bool firstInteraction,
0435                 const set<long>& offShellPartons,
0436                                 bool dipoles = true);
0437   /**
0438    * Prepare the event record for the given
0439    * subprocess.
0440    */
0441   void slimprepare(tSubProPtr subpro,
0442            tStdXCombPtr xc,
0443            const pair<PDF,PDF>& pdf,tPPair beam,
0444            const set<long>& offShellPartons,
0445            bool dipoles = true);
0446 
0447   /**
0448    * Clear the event record: Give up ownership
0449    * on any object involved in the evolution.
0450    */
0451   virtual void clear();
0452 
0453   /**
0454    * Prepare the dipole chains for the eventRecord after
0455    * the subleading shower
0456    */
0457   void prepareChainsSubleading(const bool decay) {
0458     static set<long> empty;
0459     continueSubleadingNc = false;
0460     PList cordered = colourOrdered(incoming(),outgoing());
0461     findChains(cordered,empty,decay);
0462   }
0463 
0464 public:
0465 
0466   /**
0467    * Print event record at current state.
0468    */
0469   void debugLastEvent(ostream&) const;
0470 
0471 public:
0472 
0473   /**
0474    *  Get the decays
0475    */
0476   map<PPtr,PerturbativeProcessPtr> & decays() {return theDecays;}
0477 
0478   /**
0479    * Used in DipoleEventRecord::prepare.
0480    * Add the outgoing particles from a perturbative 
0481    * process to the vector of original particles. 
0482    * Iterates through decay chains.
0483    **/
0484   void fillFromDecays(PerturbativeProcessPtr decayProc, vector<PPtr>& original);
0485 
0486   /**
0487    * Used in DipoleEventRecord::prepare.
0488    * Replace the particles in the given 
0489    * perturbative process with their copies from the 
0490    * map, theOriginals.
0491    * Iterates through decays chains.
0492    **/
0493   void separateDecay(PerturbativeProcessPtr decayProc);
0494 
0495   /**
0496    *  Decay the particle
0497    */
0498   Energy decay(PPtr incoming, bool& powhegEmission);
0499 
0500   /**
0501    * Prepare the event record for the showering of a decay.
0502    * Return false if the decay does not need to be showered.
0503    **/
0504   bool prepareDecay(PerturbativeProcessPtr decayProc,
0505                 const set<long>& offShellPartons);
0506 
0507   /**
0508    * Boost the momentum of the outgoing of the given 
0509    * perturbative process to the momentum of given particle.
0510    **/
0511   void updateDecayMom(PPtr decayParent, PerturbativeProcessPtr decayProc);
0512 
0513   /**
0514    * Iteratively update the momenta of all
0515    * particles in a decay chain, starting 
0516    * with the outgoing from the given parent
0517    **/
0518   void updateDecayChainMom(PPtr decayParent, PerturbativeProcessPtr decayProc);
0519 
0520   /**
0521    * Update theDecays following the decay and/or
0522    * showering of a decay particle.
0523    * With iteration switched on (true) this will
0524    * update theDecays with the entire decay chain.
0525    `**/
0526   void updateDecays(PerturbativeProcessPtr decayProc, bool iterate = true);
0527 
0528   /**
0529    *  Access current decay process
0530    */
0531   PerturbativeProcessPtr currentDecay() {return theCurrentDecay;}
0532 
0533   /**
0534    *  Set current decay process
0535    */
0536   void currentDecay(PerturbativeProcessPtr in) {theCurrentDecay=in;}
0537 
0538   /**
0539    * Return the next particle to be decayed.
0540    */
0541   PPtr nextDecay() {
0542     if ( !theNextDecays.empty() )
0543       return theNextDecays.back();
0544     else
0545       return PPtr();
0546   }
0547   
0548 
0549   // SW - Changed from protected to public so that functions can be used in DipoleShowerHandler
0550 public:
0551 
0552   /**
0553    * Find the chains to be showered.
0554    * The decay bool avoids mixing up decaying particles in hard and decay processes
0555    */
0556   void findChains(const PList& ordered, 
0557           const set<long>& offShellpartons,
0558           const bool decay = false);
0559 
0560   /**
0561    * Sort the coloured partons into a colour ordered ensemble.
0562    */
0563   PList colourOrdered(PPair & in,PList & out);
0564 
0565 
0566 private:
0567 
0568   struct getMomentum {
0569     const Lorentz5Momentum& operator() (PPtr particle) const {
0570       return particle->momentum();
0571     }
0572   };
0573 
0574   /**
0575    * The momentum of the hard system
0576    */
0577   Lorentz5Momentum thePX;
0578 
0579   /**
0580    * Any non-coloured outgoing particles in the
0581    * current subprocess.
0582    */
0583   PList theHard;
0584 
0585   /**
0586    * Map originals to copies.
0587    */
0588   map<PPtr,PPtr> theOriginals;
0589 
0590   /**
0591    * The dipole chains currently showered.
0592    */
0593   list<DipoleChain> theChains;
0594 
0595   /**
0596    * The dipole chains which ceased evolving.
0597    */
0598   list<DipoleChain> theDoneChains;
0599   
0600   /**
0601    * Particles after the emission.
0602    */
0603   cPDVector theParticlesAfter;
0604   
0605   /**
0606    * Particles before the emission.
0607    */
0608   cPDVector theParticlesBefore;
0609   
0610   /**
0611    * Momenta of the particles after emission.
0612    */
0613   vector<Lorentz5Momentum> theMomentaAfter;
0614   
0615   /**
0616    * Pair of the emitters index before emission and both the emitters
0617    * and the emissions indices after emission, 
0618    * <emitter_before,<emitter_after,emission> >
0619    */
0620   pair<size_t,pair<size_t,size_t> > theEmitterEmissionIndices;
0621   
0622   /**
0623    * Pair of the spectators index before and after emission.
0624    */
0625   pair<size_t,size_t> theSpectatorIndices;
0626   
0627   /**
0628    * The density operator.
0629    */
0630   DensityOperator theDensityOperator;
0631 
0632   /**
0633    * Switch on or off for subleading Nc corrections.
0634    */
0635   bool doSubleadingNc;
0636   
0637   /**
0638    * Flag to keep track of when to stop calculating colour
0639    * matrix element corrections.
0640    */
0641   bool continueSubleadingNc;
0642   
0643   /**
0644    * Number of emissions to calculate subleading Nc corrections for.
0645    */
0646   size_t subleadingNcEmissionsLimit;
0647 
0648   /**
0649    * Current number of subleading emissions.
0650    */
0651   size_t subEmDone;
0652 
0653   
0654   /**
0655    * Dictionary for particles before emission.
0656    */
0657   map<PPtr,size_t> theParticleIndices;
0658 
0659   /**
0660    * Integer used to set which method of evolving the density operator
0661    * to use:
0662    * 0 - Vijk is Eikonal but there is a cutoff.
0663    * 1 - Vijk is Eikonal.
0664    * 2 - Vijk=1 for all i,j,k.
0665    * 3 - Semi-leading Nc, Vijk=0 for all 
0666    */
0667   int densityOperatorEvolution;
0668 
0669   /**
0670    * Cutoff scale for the invariants (e.g. pEmitter*pEmission) in the 
0671    * Eikonal dipole kernel, Vijk.
0672    */
0673   Energy2 densityOperatorCutoff;
0674 
0675   /**
0676    * Dictionary for emissions, maps the three indices
0677    * - emitter before emission
0678    * - emitter after emission
0679    * - emission
0680    * to another map of the indices before emission mapped to the indices after
0681    * emission (except the emitters index)
0682    */
0683   map<std::tuple<size_t,size_t,size_t>,map<size_t,size_t> > theEmissionsMap;
0684 
0685   /**
0686    * The coloured partons that can be off-shell
0687    * To only be filled by DipoleShowerHandler.
0688    **/
0689 
0690 
0691   
0692 private:
0693 
0694   /**
0695    * Storage of the particles which need to be decayed
0696    */
0697   map<PPtr,PerturbativeProcessPtr> theDecays;
0698 
0699   /**
0700    *
0701    */
0702   PerturbativeProcessPtr theCurrentDecay;
0703 
0704   /**
0705    * List of unstable particles, the decay to be performed
0706    * and/or showered next is always at the back.
0707    * This list is required to force the dipole shower to shower one decay
0708    * chain at a time, without jumping between decay chains.
0709    * Note this is not *required* but this is the most 
0710    * obvious/intuitive way to treat the decays.
0711    **/
0712   PList theNextDecays;
0713 
0714 };
0715 
0716 
0717 }
0718 
0719 #endif /* HERWIG_DipoleEventRecord_H */