Back to home page

EIC code displayed by LXR

 
 

    


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

0001 // -*- C++ -*-
0002 //
0003 // DipoleShowerHandler.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_DipoleShowerHandler_H
0010 #define HERWIG_DipoleShowerHandler_H
0011 //
0012 // This is the declaration of the DipoleShowerHandler class.
0013 //
0014 
0015 #include "Herwig/Shower/ShowerHandler.h"
0016 
0017 #include "Herwig/Shower/Dipole/DipoleShowerHandler.fh"
0018 #include "Herwig/Shower/Dipole/Base/DipoleSplittingInfo.h"
0019 #include "Herwig/Shower/Dipole/Base/DipoleSplittingReweight.h"
0020 #include "Herwig/Shower/Dipole/Kernels/DipoleSplittingKernel.h"
0021 #include "Herwig/Shower/Dipole/Base/DipoleSplittingGenerator.h"
0022 #include "Herwig/Shower/Dipole/Base/DipoleEventRecord.h"
0023 #include "Herwig/Shower/Dipole/Base/DipoleEvolutionOrdering.h"
0024 #include "Herwig/Shower/Dipole/Base/DipoleEventReweight.h"
0025 #include "Herwig/Shower/Dipole/Utility/ConstituentReshuffler.h"
0026 #include "Herwig/Shower/Dipole/Utility/IntrinsicPtGenerator.h"
0027 #include "Herwig/MatrixElement/Matchbox/Base/MergerBase.h"
0028 #include "Herwig/MatrixElement/Matchbox/Matching/ShowerApproximation.h"
0029 
0030 #include "Herwig/Shower/Dipole/SpinCorrelations/DipoleVertexRecord.h"
0031 #include "Herwig/MatrixElement/Matchbox/Utility/DensityOperator.h"
0032 
0033 #include <tuple>
0034 
0035 namespace Herwig {
0036 
0037 using namespace ThePEG;
0038 
0039 /** 
0040  * \ingroup DipoleShower
0041  * \author Simon Platzer, Stephen Webster
0042  *
0043  * \brief The DipoleShowerHandler class manages the showering using
0044  * the dipole shower algorithm.
0045  *
0046  * @see \ref DipoleShowerHandlerInterfaces "The interfaces"
0047  * defined for DipoleShowerHandler.
0048  */
0049 class DipoleShowerHandler: public ShowerHandler {
0050 
0051 
0052  friend class Merger;
0053 
0054 public:
0055 
0056   /**
0057    * The default constructor.
0058    */
0059   DipoleShowerHandler();
0060 
0061 public:
0062 
0063 
0064   inline void colourPrint();
0065 
0066   /**
0067    * Indicate a problem in the shower.
0068    */
0069   struct RedoShower {};
0070 
0071   /**
0072    * Insert an additional splitting kernel.
0073    */
0074   void addSplitting(Ptr<DipoleSplittingKernel>::ptr sp) {
0075     kernels.push_back(sp);
0076   }
0077 
0078   /**
0079    * Reset the alpha_s for all splitting kernels.
0080    */
0081   void resetAlphaS(Ptr<AlphaSBase>::tptr);
0082   
0083   
0084   virtual void cascade(tPVector); 
0085 
0086   /**
0087    * Reset the splitting reweight for all splitting kernels.
0088    */
0089   void resetReweight(Ptr<DipoleSplittingReweight>::tptr);
0090 
0091   /**
0092    * Return true, if the shower handler can generate a truncated 
0093    * shower for POWHEG style events generated using Matchbox
0094    */
0095   virtual bool canHandleMatchboxTrunc() const { return false; }
0096 
0097   /**
0098    * Return true, if this cascade handler will perform reshuffling from hard
0099    * process masses.
0100    */
0101   virtual bool isReshuffling() const { return false; }
0102 
0103   /**
0104    * Return the relevant hard scale to be used in the profile scales
0105    */
0106   virtual Energy hardScale() const {
0107     return muPt;
0108   }
0109   
0110   /**
0111    * Calculate the alpha_s value the shower uses for Q.
0112    */
0113   
0114   double as(Energy Q)const{return theGlobalAlphaS->value(sqr(Q));}
0115   
0116   /**
0117    * Return the number of scale dependent active flavours from 
0118    * the alpha_s object.
0119    */
0120 
0121   double Nf(Energy Q)const{return theGlobalAlphaS->Nf(sqr(Q));}
0122 
0123   /*
0124    * Access the vertex record
0125    */
0126   DipoleVertexRecord& vertexRecord() { return theVertexRecord; }
0127 
0128   /**
0129    * Return the event record
0130    */
0131   const DipoleVertexRecord& vertexRecord() const { return theVertexRecord; }
0132 
0133 
0134   /**
0135    * Set the pointer to the Merging Helper.
0136    * Used by the merging factory.
0137    */
0138   void setMerger(Ptr<MergerBase>::ptr mh){theMergingHelper=mh;}
0139 
0140 
0141 
0142 public:
0143 
0144   /**
0145    * Return the dictionary for the incoming particles and outgoing partons 
0146    * in the event, will be empty if subleading Nc is turned off.
0147    */
0148   const map<PPtr,size_t>& particleIndices() const { return eventRecord().particleIndices(); }
0149 
0150   /**
0151    * Return the particle data vector of the particles in the event, will 
0152    * be empty if subleading Nc is turned off.
0153    */
0154   const cPDVector& particlesAfter() const { return eventRecord().particlesAfter(); }
0155 
0156   /**
0157    * Return the density operator from the event record.
0158    */
0159   DensityOperator& densityOperator() { return eventRecord().densityOperator(); }
0160 
0161   /**
0162    * Return the colour matrix element correction map, will be empty if
0163    * subleading Nc is turned off. NOT USED, REMOVE
0164    */
0165   const map<pair<vector<PDT::Colour>,pair<size_t,size_t> >,double>& correlatorMap() const {
0166     return eventRecord().densityOperator().correlatorMap();
0167   }
0168 
0169   /**
0170    * Return the colour basis used in the density operator. NOT USED, REMOVE
0171    */
0172   Ptr<ColourBasis>::tptr colourBasis() {
0173     return eventRecord().densityOperator().colourBasis();
0174   }
0175 
0176   /**
0177    * Return the continue subleading Nc flag from the event record.
0178    */
0179   bool continueSubleadingNc() const { return eventRecord().getContinueSubleadingNc(); }
0180 
0181 protected:
0182 
0183   /**
0184    * Add the possible splitting candidates given a pair of emitting particles
0185    */
0186   void addCandidates(PPair particles, list<DipoleSplittingInfo>& clist) const;
0187 
0188   /**
0189    * Get all possible radiating dipoles
0190    */
0191   void getCandidates(list<DipoleSplittingInfo>& clist) const;
0192 
0193   /**
0194    * Perform a splitting independent of any chains
0195    */
0196   void performSplitting(DipoleSplittingInfo&) const;
0197 
0198   /**
0199    * Generate the next subleading Nc improved splitting and return the scale
0200    */
0201   Energy nextSubleadingSplitting(Energy hardPt,
0202                  Energy optHardPt, Energy optCutoff,
0203                  const bool decay);
0204 
0205 protected:
0206 
0207   typedef multimap<DipoleIndex,Ptr<DipoleSplittingGenerator>::ptr> GeneratorMap;
0208 
0209   /**
0210    * The main method which manages the showering of a subprocess.
0211    */
0212   virtual tPPair cascade(tSubProPtr sub, XCombPtr xcomb) {
0213     return cascade(sub,xcomb,ZERO,ZERO);
0214   }
0215 
0216   /**
0217    * The main method which manages the showering of a subprocess.
0218    */
0219   tPPair cascade(tSubProPtr sub, XCombPtr xcomb, 
0220          Energy optHardPt, Energy optCutoff);
0221 
0222   /**
0223    * Build splitting generators for the given
0224    * dipole index.
0225    */
0226   void getGenerators(const DipoleIndex&,
0227              Ptr<DipoleSplittingReweight>::tptr rw =
0228              Ptr<DipoleSplittingReweight>::tptr());
0229 
0230   /**
0231    * Setup the hard scales.
0232    */
0233   void hardScales(Energy2 scale);
0234 
0235   /**
0236    * Setup the hard scales of the dipoles after subleading emissions.//debug
0237    */
0238   void hardScalesSubleading(list<DipoleSplittingInfo> candidates,Energy hardPt);
0239 
0240   /**
0241    * Return the evolution ordering
0242    */
0243   Ptr<DipoleEvolutionOrdering>::tptr evolutionOrdering() const { return theEvolutionOrdering; }
0244 
0245   /**
0246    * Reshuffle to constituent mass shells
0247    */
0248   void constituentReshuffle();
0249 
0250   /**
0251    * Reshuffle to constituent mass shells
0252    */
0253   void decayConstituentReshuffle( PerturbativeProcessPtr decayProc);
0254 
0255   /**
0256    * Access the generator map
0257    */
0258   GeneratorMap& generators() { return theGenerators; }
0259 
0260   /**
0261    * Access the event record
0262    */
0263   DipoleEventRecord& eventRecord() { return theEventRecord; }
0264 
0265   /**
0266    * Return the event record
0267    */
0268   const DipoleEventRecord& eventRecord() const { return theEventRecord; }
0269 
0270   /**
0271    * Return the splitting kernels.
0272    */
0273   const vector<Ptr<DipoleSplittingKernel>::ptr>& splittingKernels() const {
0274     return kernels;
0275   }
0276   
0277   /**
0278    * Return the set of offshell parton ids.
0279    **/
0280   const set<long>& offShellPartons() { return theColouredOffShellInShower; }
0281   
0282   /**
0283    * In a merging setup this function checks if the next shower
0284    * configuration is part of the matrix element region.
0285    */
0286   bool isMERegion(const Energy winnerScale,
0287                   const DipoleSplittingInfo & winner,
0288                   const list<Dipole>::iterator winnerDip);
0289   
0290   /**
0291    * Realign the event such as to have the incoming partons along thre
0292    * beam axes.
0293    */
0294   bool realign();
0295 
0296   /**
0297    * The choice of z boundaries; 0 = restricted, 1 = open, 2 = mixed/other
0298    */
0299   virtual int showerPhaseSpaceOption() const {
0300     return theZBoundaries;
0301   }
0302 
0303 protected:
0304 
0305   /**
0306    * Perform the cascade.
0307    */
0308   void doCascade(unsigned int& emDone,
0309          Energy optHardPt = ZERO,
0310          Energy optCutoff = ZERO,
0311          const bool decay = false);
0312   /**
0313    * Set the number of emissions 
0314    **/
0315   void setNEmissions(unsigned int n){nEmissions=n;}
0316   
0317 
0318   /**
0319    * Get the winning splitting for the
0320    * given dipole and configuration.
0321    */
0322   Energy getWinner(DipoleSplittingInfo& winner,
0323            const Dipole& dip,
0324            pair<bool,bool> conf,
0325            Energy optHardPt = ZERO,
0326            Energy optCutoff = ZERO);
0327 
0328   /**
0329    * Get the winning splitting for the
0330    * given dipole and configuration.
0331    */
0332   Energy getWinner(DipoleSplittingInfo& winner,
0333            Energy optHardPt = ZERO,
0334            Energy optCutoff = ZERO);
0335 
0336   /**
0337    * Get the winning splitting for the
0338    * given dipole and configuration.
0339    */
0340   Energy getWinner(SubleadingSplittingInfo& winner,
0341            Energy optHardPt = ZERO,
0342            Energy optCutoff = ZERO);
0343 
0344   /**
0345    * Get the winning splitting for the
0346    * given dipole and configuration.
0347    */
0348   Energy getWinner(DipoleSplittingInfo& winner,
0349            const DipoleIndex& index,
0350            double emitterX, double spectatorX,
0351            pair<bool,bool> conf,
0352            tPPtr emitter, tPPtr spectator,
0353            Energy startScale,
0354            Energy optHardPt = ZERO,
0355            Energy optCutoff = ZERO);
0356   
0357 public:
0358 
0359   /** @name Functions used by the persistent I/O system. */
0360   //@{
0361   /**
0362    * Function used to write out object persistently.
0363    * @param os the persistent output stream written to.
0364    */
0365   void persistentOutput(PersistentOStream & os) const;
0366 
0367   /**
0368    * Function used to read in object persistently.
0369    * @param is the persistent input stream read from.
0370    * @param version the version number of the object when written.
0371    */
0372   void persistentInput(PersistentIStream & is, int version);
0373   //@}
0374 
0375   /**
0376    * The standard Init function used to initialize the interfaces.
0377    * Called exactly once for each class by the class description system
0378    * before the main function starts or
0379    * when this class is dynamically loaded.
0380    */
0381   static void Init();
0382 
0383 protected:
0384 
0385   /** @name Clone Methods. */
0386   //@{
0387   /**
0388    * Make a simple clone of this object.
0389    * @return a pointer to the new object.
0390    */
0391   virtual IBPtr clone() const;
0392 
0393   /** Make a clone of this object, possibly modifying the cloned object
0394    * to make it sane.
0395    * @return a pointer to the new object.
0396    */
0397   virtual IBPtr fullclone() const;
0398   //@}
0399 
0400 
0401 // If needed, insert declarations of virtual function defined in the
0402 // InterfacedBase class here (using ThePEG-interfaced-decl in Emacs).
0403 
0404 
0405 protected:
0406 
0407   /** @name Standard Interfaced functions. */
0408   //@{
0409   /**
0410    * Initialize this object after the setup phase before saving an
0411    * EventGenerator to disk.
0412    * @throws InitException if object could not be initialized properly.
0413    */
0414   virtual void doinit();
0415 
0416   /**
0417    * Initialize this object. Called in the run phase just before
0418    * a run begins.
0419    */
0420   virtual void doinitrun();
0421 
0422   /**
0423    * Finalize this object. Called in the run phase just after a
0424    * run has ended. Used eg. to write out statistics.
0425    */
0426   virtual void dofinish();
0427   //@}
0428 
0429 
0430 private:
0431 
0432   /**
0433    * The splitting kernels to be used.
0434    */
0435   vector<Ptr<DipoleSplittingKernel>::ptr> kernels;
0436 
0437   /**
0438    * The evolution ordering considered
0439    */
0440   Ptr<DipoleEvolutionOrdering>::ptr theEvolutionOrdering;
0441 
0442   /**
0443    * The ConstituentReshuffler to be used
0444    */
0445   Ptr<ConstituentReshuffler>::ptr constituentReshuffler;
0446 
0447   /**
0448    * The intrinsic pt generator to be used.
0449    */
0450   Ptr<IntrinsicPtGenerator>::ptr intrinsicPtGenerator;
0451 
0452   /**
0453    * A global alpha_s to be used for all splitting kernels.
0454    */
0455   Ptr<AlphaSBase>::ptr theGlobalAlphaS;
0456 
0457   /**
0458    * Apply chain ordering to events from matrix
0459    * element corrections.
0460    */
0461   bool chainOrderVetoScales;
0462 
0463   /**
0464    * Limit the number of emissions.
0465    * Limit applied if > 0.
0466    */
0467   unsigned int nEmissions;
0468 
0469   /**
0470    * Discard events which did not radiate.
0471    */
0472   bool discardNoEmissions;
0473 
0474   /**
0475    * Perform the first MC@NLO emission only.
0476    */
0477   bool firstMCatNLOEmission;
0478 
0479   /**
0480    * True if powheg style emissions are to be used in the decays
0481    */
0482   bool thePowhegDecayEmission;
0483 
0484  /**
0485    * Switch to record information required for the 
0486    * nearest neighbour analysis.
0487    */
0488   //bool theAnalyseSpinCorrelations;
0489 
0490   /**
0491    * The realignment scheme
0492    */
0493   int realignmentScheme;
0494 
0495   /**
0496    * Switch on or off subleading Nc corrections
0497    */
0498   bool doSubleadingNc;
0499   
0500   /**
0501    * Number of emissions to do subleading Nc corrections to.
0502    */
0503   size_t subleadingNcEmissionsLimit;
0504 
0505   /**
0506    * Current reference weight used for partial unweighting of the 
0507    * subleading colour shower (updated each emission).
0508    */
0509   int currentReferenceWeight;
0510 
0511   /**
0512    * Integer used to set which method of evolving the density operator
0513    * to use:
0514    * 0 - Vijk is Eikonal but there is a cutoff.
0515    * 1 - Vijk is Eikonal.
0516    * 2 - Vijk=1 for all i,j,k.
0517    * 3 - Semi-leading Nc, Vijk=0 for all 
0518    */
0519   int densityOperatorEvolution;
0520 
0521   /**
0522    * Cutoff scale for the invariants (e.g. pEmitter*pEmission) in the 
0523    * Eikonal dipole kernel, Vijk.
0524    */
0525   Energy2 densityOperatorCutoff;
0526 
0527   /**
0528    * Switch on or off partial unweighting in after each subleading emission.
0529    */
0530   bool doPartialUnweightingAtEmission;
0531 
0532   /**
0533    * Switch on or off partial unweighting in the splitting generator.
0534    */
0535   bool doPartialUnweighting;
0536 
0537   /**
0538    * Reference weight for the partial unweighting.
0539    */
0540   double referenceWeight;
0541 
0542   /**
0543    * Factor changing the acceptance probability for the veto algorithm.
0544    */
0545   double cmecReweightFactor;
0546 
0547   /**
0548    * Scaling factor for the negative colour matrix element corrections.
0549    */
0550   double negCMECScaling;
0551 
0552 private:
0553 
0554   /**
0555    * The verbosity level.
0556    * 0 - print no info
0557    * 1 - print diagnostic information on setting up
0558    *     splitting generators etc.
0559    * 2 - print detailed event information for up to
0560    *     printEvent events.
0561    * 3 - print dipole chains after each splitting.
0562    */
0563   int verbosity;
0564 
0565   /**
0566    * See verbosity.
0567    */
0568   int printEvent;
0569 
0570 private:
0571 
0572   /**
0573    * The splitting generators indexed by the dipole
0574    * indices they can work on.
0575    */
0576   GeneratorMap theGenerators;
0577 
0578   /**
0579    * The evnt record used.
0580    */
0581   DipoleEventRecord theEventRecord;
0582 
0583   /**
0584    * The vertex record.
0585    **/
0586   DipoleVertexRecord theVertexRecord;
0587 
0588   /**
0589    * The number of shoer tries so far.
0590    */
0591   unsigned int nTries;
0592 
0593   /**
0594    * Whether or not we did radiate anything
0595    */
0596   bool didRadiate;
0597 
0598   /**
0599    * Whether or not we did realign the event
0600    */
0601   bool didRealign;
0602 
0603   /**
0604    * Vector of candidate splittings containing a vector of the
0605    * weights, scale and a bool for every step in the reweighted 
0606    * veto algorithm. The bool is true for an accept step.
0607    */
0608   vector<vector<std::tuple<Energy,double,bool> > > theWeightsVector;
0609 
0610   /**
0611    * Winning candidate index.
0612    */
0613   size_t winnerIndex;//debug
0614   size_t kernelIndex;//debug
0615   size_t winningKernelIndex;//debug
0616   vector<Energy> scales;//debug
0617 
0618 private:
0619 
0620   /**
0621    * A freezing value for the renormalization scale
0622    */
0623   Energy theRenormalizationScaleFreeze;
0624 
0625   /**
0626    * A freezing value for the factorization scale
0627    */
0628   Energy theFactorizationScaleFreeze;
0629 
0630   /**
0631    * The matching subtraction, if appropriate
0632    */
0633   Ptr<ShowerApproximation>::tptr theShowerApproximation;
0634 
0635   /**
0636    * True, if sampler should apply compensation
0637    */
0638   bool theDoCompensate;
0639 
0640   /**
0641    * Return the number of accepted points after which the grid should
0642    * be frozen
0643    */
0644   unsigned long theFreezeGrid;
0645 
0646   /**
0647    * The detuning factor applied to the sampling overestimate kernel
0648    */
0649   double theDetuning;
0650 
0651   /**
0652    * A pointer to the dipole event reweight object
0653    */
0654   Ptr<DipoleEventReweight>::ptr theEventReweight;
0655 
0656   /**
0657    * A pointer to a global dipole splitting reweight
0658    */
0659   Ptr<DipoleSplittingReweight>::ptr theSplittingReweight;
0660 
0661   /**
0662    * True if no warnings have been issued yet
0663    */
0664   static bool firstWarn;
0665 
0666   /**
0667    * The shower starting scale for the last event encountered
0668    */
0669   Energy maxPt;
0670 
0671   /**
0672    * The shower hard scale for the last event encountered
0673    */
0674   Energy muPt;
0675   
0676   
0677   /**
0678    * The merging helper takes care of merging multiple LO and NLO
0679    * cross sections. Here we need to check if an emission would 
0680    * radiate in the matrix element region of an other multipicity.
0681    * If so, the emission is vetoed.
0682    */
0683   Ptr<MergerBase>::ptr theMergingHelper;
0684 
0685 
0686   /**
0687    *  PDG codes of the partons which can have an off-shell mass,
0688    *  this is fast storage for use during running
0689    */
0690   set<long> theColouredOffShellInShower;
0691 
0692   /**
0693    *  PDG codes of the partons which can have an off-shell mass,
0694    *  this is a vector that is interfaced so they can be changed
0695    */
0696   vector<long> theInputColouredOffShellInShower;
0697   
0698   /**
0699    * The choice of z boundaries; 0 = restricted, 1 = open, 2 = mixed/other
0700    */
0701   int theZBoundaries;
0702   
0703 private:
0704 
0705   /**
0706    * The static object used to initialize the description of this class.
0707    * Indicates that this is a concrete class with persistent data.
0708    */
0709   static ClassDescription<DipoleShowerHandler> initDipoleShowerHandler;
0710 
0711   /**
0712    * The assignment operator is private and must never be called.
0713    * In fact, it should not even be implemented.
0714    */
0715   DipoleShowerHandler & operator=(const DipoleShowerHandler &) = delete;
0716 
0717 };
0718 
0719 }
0720 
0721 #include "ThePEG/Utilities/ClassTraits.h"
0722 
0723 namespace ThePEG {
0724 
0725 /** @cond TRAITSPECIALIZATIONS */
0726 
0727 /** This template specialization informs ThePEG about the
0728  *  base classes of DipoleShowerHandler. */
0729 template <>
0730 struct BaseClassTrait<Herwig::DipoleShowerHandler,1> {
0731   /** Typedef of the first base class of DipoleShowerHandler. */
0732   typedef Herwig::ShowerHandler NthBase;
0733 };
0734 
0735 /** This template specialization informs ThePEG about the name of
0736  *  the DipoleShowerHandler class and the shared object where it is defined. */
0737 template <>
0738 struct ClassTraits<Herwig::DipoleShowerHandler>
0739   : public ClassTraitsBase<Herwig::DipoleShowerHandler> {
0740   /** Return a platform-independent class name */
0741   static string className() { return "Herwig::DipoleShowerHandler"; }
0742   /**
0743    * The name of a file containing the dynamic library where the class
0744    * DipoleShowerHandler is implemented. It may also include several, space-separated,
0745    * libraries if the class DipoleShowerHandler depends on other classes (base classes
0746    * excepted). In this case the listed libraries will be dynamically
0747    * linked in the order they are specified.
0748    */
0749   static string library() { return "HwDipoleShower.so"; }
0750 };
0751 
0752 /** @endcond */
0753 
0754 }
0755 
0756 #endif /* HERWIG_DipoleShowerHandler_H */