Back to home page

EIC code displayed by LXR

 
 

    


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

0001 // -*- C++ -*-
0002 //
0003 // ShowerTree.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_ShowerTree_H
0010 #define HERWIG_ShowerTree_H
0011 
0012 #include "ThePEG/Config/ThePEG.h"
0013 #include "Herwig/Shower/ShowerHandler.fh"
0014 #include "Herwig/Shower/PerturbativeProcess.h"
0015 #include "Herwig/Shower/RealEmissionProcess.h"
0016 #include "Herwig/Shower/ShowerEventRecord.h"
0017 #include "Herwig/Shower/QTilde/ShowerConfig.h"
0018 #include "Herwig/Shower/QTilde/Base/ShowerParticle.h"
0019 #include "Herwig/Shower/QTilde/Base/ShowerProgenitor.h"
0020 #include "ThePEG/EventRecord/Step.h"
0021 #include <cassert>
0022 #include "ShowerTree.fh"
0023 
0024 namespace Herwig {
0025 
0026 /**
0027  *  Typedef for map of ShowerTrees for decays
0028  */
0029 typedef multimap<Energy,ShowerTreePtr,std::greater<Energy> > ShowerDecayMap;
0030   
0031 using namespace ThePEG;
0032  
0033 /** \ingroup Shower
0034  * 
0035  *  The ShowerTree class stores the basic information needed for
0036  *  each hard interaction, either a scattering process or decay, which 
0037  *  needs to be showered.
0038  *
0039  */
0040 class ShowerTree : public ShowerEventRecord {
0041 
0042   friend class QTildeShowerHandler;
0043 
0044 public:
0045 
0046   /**
0047    * Constructor from a perturbative process
0048    * @param process The perturbative process
0049    */
0050   ShowerTree(PerturbativeProcessPtr process);
0051 
0052   /**
0053    * Calculate the space-time displacement
0054    * @param particle The particle for which to calculate the displacement
0055    */
0056   static Lorentz5Distance spaceTimeDistance(tPPtr particle);
0057 
0058   /**
0059    *  Construct the trees from the hard process
0060    * @param hardTree The output ShowerTree for the hard process
0061    * @param decayTrees The output ShowerTrees for any decays.
0062    * @param hard The output ShowerTree for the hard process
0063    * @param decay The output ShowerTrees for any decays.
0064    */
0065   static void constructTrees(ShowerTreePtr & hardTree,
0066                  ShowerDecayMap & decayTrees,
0067                  PerturbativeProcessPtr hard,
0068                  DecayProcessMap decay);
0069 
0070 public:
0071 
0072   /**
0073    * Insert the tree into the event record
0074    * @param pstep The step into which the particles should be inserted
0075    * @param ISR Whether or not ISR is switched on
0076    * @param FSR Whether or not FSR is switched on
0077    */
0078   void fillEventRecord(StepPtr pstep,bool ISR,bool FSR) {
0079     if(_wasHard) 
0080       insertHard (pstep,ISR,FSR);
0081     else         
0082       insertDecay(pstep,ISR,FSR);
0083   }
0084   
0085 
0086   /**
0087    * Set the parent tree to this tree for trees which come from this one.
0088    * This needs to be run after the constructor.
0089    */
0090   void setParents();
0091 
0092   /**
0093    * Access methods for the type of interaction
0094    */
0095   //@{
0096   /**
0097    *  Whether or not this is a scattering process
0098    */
0099   bool isHard() const { return _wasHard; } 
0100 
0101 
0102   /**
0103    *  Whether or not this is a decay.
0104    */
0105   bool isDecay() const { return !_wasHard; }
0106   //@}
0107 
0108   /**
0109    *  Get the incoming shower particles
0110    */
0111   map<ShowerProgenitorPtr,ShowerParticlePtr> & incomingLines() {
0112     return _incomingLines; 
0113   }
0114 
0115   /**
0116    *  Get the outgoing shower particles
0117    */
0118   map<ShowerProgenitorPtr,tShowerParticlePtr> & outgoingLines() {
0119     return _outgoingLines; 
0120   }
0121 
0122   /**
0123    *  Update the shower product for a final-state particle
0124    */
0125   void updateFinalStateShowerProduct(ShowerProgenitorPtr progenitor,
0126                      ShowerParticlePtr parent,
0127                      const ShowerParticleVector & children);
0128 
0129   /**
0130    *  Update the shower product for an initial-state particle
0131    */
0132   void updateInitialStateShowerProduct(ShowerProgenitorPtr progenitor,
0133                        ShowerParticlePtr newParent);
0134 
0135   /**
0136    *  Get the current final shower product for a final-state particle
0137    */
0138   tShowerParticlePtr getFinalStateShowerProduct(ShowerProgenitorPtr progenitor) {
0139     return _outgoingLines.find(progenitor)==_outgoingLines.end()
0140       ? tShowerParticlePtr() : _outgoingLines[progenitor];
0141   }
0142 
0143   /**
0144    * Add a final-state branching. This method removes the parent of the branching
0145    * from the list of particles at the end of the shower and inserts the children
0146    * @param parent The parent for the branching
0147    * @param children The outgoing particles in the branching
0148    */
0149   void addFinalStateBranching(ShowerParticlePtr parent,
0150                   const ShowerParticleVector & children);
0151 
0152   /**
0153    *  Add an initial-state branching. This method removes the oldParent of the
0154    *  branching and inserts the result of the backward evolution and the 
0155    *  outgoing particle into the relevant lists.
0156    * @param oldParent The particle being backward evolved
0157    * @param newParent The initial-state particle resulting from the backward evolution
0158    * @param otherChild The final-state particle produced in the evolution.
0159    */
0160   void addInitialStateBranching(ShowerParticlePtr oldParent,
0161                 ShowerParticlePtr newParent,
0162                 ShowerParticlePtr otherChild);
0163 
0164   // /**
0165   //  *  Member called at the end of the shower of a tree to perform a number of
0166   //  *  updates.
0167   //  *  @param decay The map of widths and ShowerTrees for the decays so that
0168   //  *  any unstable decay products can be added.
0169   //  */
0170   void updateAfterShower(ShowerDecayMap & decay);
0171 
0172   /**
0173    *  Access and set the flag for whether this tree has been showered
0174    */
0175   //@{
0176   /**
0177    *  Access the flag
0178    */
0179   bool hasShowered() const { return _hasShowered; }
0180 
0181   /**
0182    *  Set the flag
0183    */
0184   void hasShowered(bool in) { _hasShowered=in; }
0185   //@}
0186 
0187   /**
0188    *  Access the parent tree
0189    */
0190   ShowerTreePtr parent() const { return _parent; }
0191 
0192   /**
0193    *  Clear all the shower products so that the event can be reshowered
0194    * if the first attempt fail
0195    */
0196   void clear();
0197 
0198   /**
0199    *  Reset the particles resulting from the shower to those which started
0200    *  the shower
0201    */
0202   void resetShowerProducts();
0203 
0204   /**
0205    *  Set maximum Emission scales
0206    */
0207   void setVetoes(const map<ShowerInteraction,Energy> & pTs,
0208          unsigned int type);
0209 
0210   /**
0211    *  Extract the progenitors for the reconstruction
0212    */
0213   vector<ShowerProgenitorPtr> extractProgenitors();
0214 
0215   /**
0216    *  Access to the outgoing particles
0217    */
0218   const set<tShowerParticlePtr> & forwardParticles() const { return _forward; }
0219 
0220   /**
0221    *  Map of particles in this Tree which are the initial particles in other
0222    *  trees
0223    */
0224   const map<tShowerTreePtr,pair<tShowerProgenitorPtr,tShowerParticlePtr> > &
0225   treelinks()  const {return _treelinks;}
0226 
0227   /**
0228    *  Update the link between shower particle and tree
0229    */
0230   void updateLink(tShowerTreePtr tree,
0231           pair<tShowerProgenitorPtr,tShowerParticlePtr> in) {
0232     _treelinks[tree] = in;
0233   }
0234 
0235   /**
0236    *  Transform the tree
0237    */
0238   void transform(const LorentzRotation & rot, bool applyNow);
0239 
0240   /**
0241    *  Apply any postphoned transformations
0242    */
0243   void applyTransforms();
0244 
0245   /**
0246    *   Clear any postphoned transformations
0247    */ 
0248   void clearTransforms();
0249 
0250   /**
0251    *  Transform which needs to be applied
0252    */
0253   const LorentzRotation & transform() {return _transforms;}
0254 
0255   /**
0256    *  Get all the progenitors
0257    */
0258   vector<ShowerParticlePtr> extractProgenitorParticles();
0259 
0260   /**
0261    *    Check the momentum conservation in the tree
0262    */
0263   void checkMomenta();
0264 
0265   /**
0266    *  Update tree after the parent has been decayed.
0267    */
0268   void update(PerturbativeProcessPtr newProcess);
0269 
0270   /**
0271    *  The perturbative process
0272    */
0273   RealEmissionProcessPtr perturbativeProcess();
0274 
0275 protected:
0276 
0277   /**
0278    * Functions to add the shower to the event record.
0279    */
0280   //@{
0281   /**
0282    * Insert a hard process
0283    * @param pstep The step into which the particles should be inserted
0284    * @param ISR Whether or not ISR is switched on
0285    * @param FSR Whether or not FSR is switched on
0286    */
0287   void insertHard(StepPtr pstep,bool ISR,bool FSR);
0288 
0289   /**
0290    * Insert a decay process
0291    * @param pstep The step into which the particles should be inserted
0292    * @param ISR Whether or not ISR is switched on
0293    * @param FSR Whether or not FSR is switched on
0294    */
0295   void insertDecay(StepPtr pstep,bool ISR,bool FSR);
0296 
0297   /**
0298    * Recursively add the final-state shower from the particle to the event record.
0299    * @param particle The final-state particle
0300    * @param step The step
0301    */
0302   void addFinalStateShower(PPtr particle, StepPtr step);
0303 
0304   /**
0305    *  Add the initial-state shwoer from the particle to the step
0306    * @param particle The final-state particle
0307    * @param hadron The incoming hadron
0308    * @param step The step
0309    * @param addchildren Add the children of the particle
0310    */
0311   void addInitialStateShower(PPtr particle, PPtr hadron,
0312                  StepPtr step, bool addchildren=true);
0313   //@}
0314 
0315   /**
0316    *  After the creatation of a ShowerParticle make sure it is properly attached 
0317    *  to its ColourLine
0318    * @param part The particle
0319    */
0320   void fixColour(tShowerParticlePtr part);
0321 
0322 private:
0323   /**
0324    * Incoming partons for the hard process
0325    */
0326   PPair _incoming;
0327   
0328   /**
0329    *  The incoming ShowerParticles connected to the interaction
0330    *  as the index of a map with the particle the shower backward evolves
0331    *  them to as the value
0332    */
0333   map<ShowerProgenitorPtr,ShowerParticlePtr> _incomingLines;
0334 
0335   /**
0336    *  The outgoing ShowerParticles connected to the interaction
0337    *  as the index of a map with the particle the shower
0338    *  evolves them to as the value
0339    */
0340   map<ShowerProgenitorPtr,tShowerParticlePtr> _outgoingLines;
0341 
0342   /**
0343    *  The outgoing ShowerParticles at the end of the final-state shower
0344    */
0345   set<tShowerParticlePtr> _forward;
0346 
0347   /**
0348    *  Was this a scattering process or a decay
0349    */
0350   bool _wasHard;
0351 
0352   /**
0353    *  Map of particles in this Tree which are the initial particles in other
0354    *  trees
0355    */
0356   map<tShowerTreePtr,pair<tShowerProgenitorPtr,tShowerParticlePtr> > _treelinks;
0357 
0358   /**
0359    *  The parent tree
0360    */
0361   tShowerTreePtr _parent;
0362 
0363   /**
0364    *  Has this tree showered
0365    */
0366   bool _hasShowered;
0367 
0368   /**
0369    *  The transforms which still need to be applied
0370    */
0371   LorentzRotation _transforms;
0372 
0373 private:
0374 
0375   /**
0376    *  Whether or not to include space-time distances
0377    */
0378   static bool _spaceTime;
0379 
0380   /**
0381    *  Minimum virtuality for the space-time model
0382    */
0383   static Energy2 _vmin2;
0384 
0385 };
0386 }
0387 
0388 #endif