herwig is hosted by Hepforge, IPPP Durham
Herwig  7.2.1
ShowerHandler.h
1 // -*- C++ -*-
2 //
3 // ShowerHandler.h is a part of Herwig - A multi-purpose Monte Carlo event generator
4 // Copyright (C) 2002-2019 The Herwig Collaboration
5 //
6 // Herwig is licenced under version 3 of the GPL, see COPYING for details.
7 // Please respect the MCnet academic guidelines, see GUIDELINES for details.
8 //
9 #ifndef HERWIG_ShowerHandler_H
10 #define HERWIG_ShowerHandler_H
11 //
12 // This is the declaration of the ShowerHandler class.
13 //
14 
15 #include "ThePEG/Handlers/EventHandler.h"
16 #include "ThePEG/Handlers/CascadeHandler.h"
17 #include "ShowerVariation.h"
18 #include "Herwig/PDF/HwRemDecayer.fh"
19 #include "ThePEG/EventRecord/RemnantParticle.fh"
20 #include "UEBase.h"
21 #include "PerturbativeProcess.h"
22 #include "Herwig/MatrixElement/Matchbox/Matching/HardScaleProfile.h"
23 #include "ShowerHandler.fh"
24 
25 namespace Herwig {
26 using namespace ThePEG;
27 
41 
42 public:
43 
47  typedef pair<tRemPPtr, tRemPPtr> RemPair;
48 
49 public:
50 
54  ShowerHandler();
55 
59  virtual ~ShowerHandler();
60 
61 public:
62 
67  virtual void cascade();
68 
72  static const tShowerHandlerPtr currentHandler() {
73  assert(currentHandler_);
74  return currentHandler_;
75  }
76 
80  static bool currentHandlerIsSet() {
81  return currentHandler_;
82  }
83 
84 public:
85 
90  virtual bool showerHardProcessVeto() const { return false; }
91 
96  virtual bool isReshuffling() const { return true; }
97 
102  virtual bool retConstituentMasses() const { return useConstituentMasses_; }
103 
104 
105 
110  virtual bool canHandleMatchboxTrunc() const { return false; }
111 
115  Energy pdfFreezingScale() const { return pdfFreezingScale_; }
116 
120  PDFPtr getPDFA() const {return PDFA_;}
121 
125  PDFPtr getPDFB() const {return PDFB_;}
126 
130  bool firstInteraction() const {
131  if (!eventHandler()->currentCollision())return true;
132  return ( subProcess_ ==
133  eventHandler()->currentCollision()->primarySubProcess() );
134  }
135 
139  tHwRemDecPtr remnantDecayer() const { return remDec_; }
140 
147  void splitHardProcess(tPVector tagged, PerturbativeProcessPtr & hard,
148  DecayProcessMap & decay) const;
149 
153  bool doesSplitHardProcess()const {return splitHardProcess_;}
154 
161  tDMPtr decay(PerturbativeProcessPtr,
162  DecayProcessMap & decay,
163  bool radPhotons = false) const;
164 
165 
170  tDMPtr findDecayMode(const string & tag) const;
171 
172 
178 
179  bool operator() (tcPDPtr p1, tcPDPtr p2) const;
180 
181  };
182 
183 
188  typedef multiset<tcPDPtr,ParticleOrdering> OrderedParticles;
189 
190 
191 public:
192 
200  bool doRadiation() const {return doFSR_ || doISR_;}
201 
205  bool doFSR() const { return doFSR_;}
206 
210  bool doISR() const { return doISR_;}
212 
213 public:
214 
222  bool hardScaleIsMuF() const { return maxPtIsMuF_; }
223 
227  double factorizationScaleFactor() const {
228  return factorizationScaleFactor_;
229  }
230 
234  double renFac() const {
235  return renormalizationScaleFactor_;
236  }
237 
241  double facFac() const {
242  return factorizationScaleFactor_;
243  }
244 
248  double renormalizationScaleFactor() const {
249  return renormalizationScaleFactor_;
250  }
251 
255  double hardScaleFactor() const {
256  return hardScaleFactor_;
257  }
262  bool restrictPhasespace() const { return restrictPhasespace_; }
263 
267  Ptr<HardScaleProfile>::tptr profileScales() const { return hardScaleProfile_; }
268 
272  virtual Energy hardScale() const;
273 
277  virtual int showerPhaseSpaceOption() const {
278  assert(false && "not implemented in general");
279  return -1;
280  }
282 
283 public:
284 
288  map<string,ShowerVariation>& showerVariations() {
289  return showerVariations_;
290  }
291 
295  const map<string,ShowerVariation>& showerVariations() const {
296  return showerVariations_;
297  }
298 
302  map<string,double>& currentWeights() {
303  return currentWeights_;
304  }
305 
309  const map<string,double>& currentWeights() const {
310  return currentWeights_;
311  }
312 
316  void reweight(double w) {
317  reweight_ = w;
318  }
319 
323  double reweight() const {
324  return reweight_;
325  }
326 
327 public :
328 
336  unsigned int spinCorrelations() const {
337  return spinOpt_;
338  }
339 
343  virtual bool correlations() const {
344  return spinOpt_!=0;
345  }
347 
348 public:
349 
354  struct ExtraScatterVeto {};
355 
363  const int tries;
364 
366  ShowerTriesVeto(int t) : tries(t) {}
367  };
368 
369 public:
370 
377  void persistentOutput(PersistentOStream & os) const;
378 
384  void persistentInput(PersistentIStream & is, int version);
386 
393  static void Init();
394 
395 protected:
396 
403  virtual tPPair cascade(tSubProPtr sub, XCPtr xcomb);
404 
409  current_ = currentStep();
410  subProcess_ = sub;
411  }
412 
417  void boostCollision(bool boost);
419 
420 protected:
421 
430  currentHandler_ = tShowerHandlerPtr(this);
431  }
432 
437  currentHandler_ = tShowerHandlerPtr();
438  }
440 
441 protected:
442 
451  bool isMPIOn() const {
452  return MPIHandler_ && MPIHandler_->beamOK();
453  }
454 
459  tUEBasePtr getMPIHandler() const {
460  assert(MPIHandler_);
461  return MPIHandler_;
462  }
463 
467  bool isResolvedHadron(tPPtr);
468 
473  RemPair getRemnants(PBIPair incbins);
474 
478  void setMPIPDFs();
480 
481 public:
482 
487  bool decaysInShower(long id) const {
488  return ( particlesDecayInShower_.find( abs(id) ) !=
489  particlesDecayInShower_.end() );
490  }
491 
492 protected:
493 
504  void findDecayProducts(PPtr parent, PerturbativeProcessPtr hard, DecayProcessMap & decay) const;
505 
512  void createDecayProcess(PPtr parent,PerturbativeProcessPtr hard, DecayProcessMap & decay) const;
514 
523  assert(subProcess_);
524  return subProcess_;
525  }
526 
531  return incoming_;
532  }
534 
535 protected:
536 
540  //@
544  void combineWeights();
545 
549  void initializeWeights();
550 
554  void resetWeights();
556 
557 protected:
558 
563  unsigned int maxtry() const { return maxtry_; }
564 
565 protected:
566 
574  bool includeSpaceTime() const {return includeSpaceTime_;}
575 
579  Energy2 vMin() const {return vMin_;}
581 
582 protected:
583 
590  virtual IBPtr clone() const;
591 
596  virtual IBPtr fullclone() const;
598 
599 protected:
600 
608  virtual void doinit();
609 
614  virtual void doinitrun();
615 
620  virtual void dofinish();
622 
623 private:
624 
629  ShowerHandler & operator=(const ShowerHandler &) = delete;
630 
631 private:
632 
636  static tShowerHandlerPtr currentHandler_;
637 
642  UEBasePtr MPIHandler_;
643 
647  HwRemDecPtr remDec_;
648 
649 private:
650 
659  unsigned int maxtry_;
660 
665  unsigned int maxtryMPI_;
666 
671  unsigned int maxtryDP_;
672 
676  unsigned int maxtryDecay_;
678 
679 private:
680 
689 
694 
699 
705 
710 
714  Ptr<HardScaleProfile>::ptr hardScaleProfile_;
716 
720  unsigned int spinOpt_;
721 
722 private:
723 
732 
737 
742 
748 
749 private:
750 
759 
768 
773 
778 
783 
787  pair <PDFPtr, PDFPtr> mpipdfs_;
788 
792  pair <PDFPtr, PDFPtr> rempdfs_;
793 
797  pair <PDFPtr, PDFPtr> remmpipdfs_;
799 
800 private:
801 
809  bool doFSR_;
810 
814  bool doISR_;
816 
817 private:
818 
827 
833 
840 
841 private:
842 
851 
855  Energy2 vMin_;
857 
858 
859 private:
860 
865  // True if shower should return constituent masses.
866  bool useConstituentMasses_=true;
868 private:
869 
877  map<string,ShowerVariation> showerVariations_;
878 
882  string doAddVariation(string);
883 
887  double reweight_;
888 
892  map<string,double> currentWeights_;
894 };
895 
896 }
897 
898 #endif /* HERWIG_ShowerHandler_H */
ThePEG::Ptr< Particle >::pointer PPtr
bool firstInteraction() const
Return true if currently the primary subprocess is showered.
Energy2 vMin() const
The minimum virtuality for the space-time model.
pair< PDFPtr, PDFPtr > remmpipdfs_
The MPI PDF&#39;s to be used for secondary scatters.
double facFac() const
The factorization scale factor.
map< string, ShowerVariation > showerVariations_
Parameters relevant for reweight and variations.
bool doFSR() const
Switch on or off final state radiation.
tPPair incoming_
Storage of information about the current event.
HwRemDecPtr remDec_
Pointer to the HwRemDecayer.
pair< PDFPtr, PDFPtr > mpipdfs_
The MPI PDF&#39;s to be used for secondary scatters.
bool decaysInShower(long id) const
Check if a particle decays in the shower.
Definition: expm-1.h:45
pair< PDFPtr, PDFPtr > rempdfs_
The MPI PDF&#39;s to be used for secondary scatters.
static bool currentHandlerIsSet()
pointer to "this", the current ShowerHandler.
Definition: ShowerHandler.h:80
void prepareCascade(tSubProPtr sub)
Set up for the cascade.
double factorizationScaleFactor() const
The factorization scale factor.
tHwRemDecPtr remnantDecayer() const
Return the remnant decayer.
void reweight(double w)
Change the current reweighting factor.
PDFPtr getPDFB() const
Get the local PDFs.
double renormalizationScaleFactor() const
The renormalization scale factor.
map< string, ShowerVariation > & showerVariations()
Access the shower variations.
PDFPtr PDFB_
The PDF for beam particle B.
Energy2 vMin_
The minimum virtuality for the space-time model.
double reweight() const
Return the current reweighting factor.
void setCurrentHandler()
Set/unset the current shower handler.
Energy pdfFreezingScale_
PDFs to be used for the various stages and related parameters.
ThePEG::Ptr< InterfacedBase >::pointer IBPtr
virtual bool canHandleMatchboxTrunc() const
Return true, if the shower handler can generate a truncated shower for POWHEG style events generated ...
struct that is used to catch exceptions which are thrown due to fact that the Shower has been invoked...
tSubProPtr currentSubProcess() const
Return the currently used SubProcess.
virtual bool showerHardProcessVeto() const
Hook to allow vetoing of event after showering hard sub-process as in e.g.
Definition: ShowerHandler.h:90
map< string, double > currentWeights_
The shower variation weights.
tUEBasePtr getMPIHandler() const
Access function for the MPIHandler, it should only be called after checking with isMPIOn.
bool includeSpaceTime_
Parameters for the space-time model.
virtual bool retConstituentMasses() const
Return true, if this cascade handler will put the final state particles to their constituent mass...
bool restrictPhasespace() const
Return true, if the phase space restrictions of the dipole shower should be applied.
bool doesSplitHardProcess() const
Information if the Showerhandler splits the hard process.
tcStepPtr current_
Const pointer to the current step.
bool maxPtIsMuF_
True if maximum pt should be deduced from the factorization scale.
pair< tPPtr, tPPtr > tPPair
tSubProPtr subProcess_
Const pointer to the currently handeled ThePEG::SubProcess.
unsigned int maxtryMPI_
Maximum number of attempts for the regeneration of an additional scattering, before the number of sca...
Ptr< HardScaleProfile >::tptr profileScales() const
Return profile scales.
unsigned int maxtry_
Maximum tries for various stages of the showering process.
double renFac() const
The renormalization scale factor.
Energy pdfFreezingScale() const
Get the PDF freezing scale.
static tShowerHandlerPtr currentHandler_
pointer to "this", the current ShowerHandler.
bool includeSpaceTime() const
Parameters for the space-time model.
const map< string, double > & currentWeights() const
Return the current Weights.
unsigned int maxtryDP_
Maximum number of attempts for the regeneration of an additional hard scattering, before this event i...
ThePEG::Ptr< Step >::transient_const_pointer tcStepPtr
unsigned int spinCorrelations() const
Access to switches for spin correlations.
ThePEG::Ptr< DecayMode >::transient_pointer tDMPtr
PDFPtr PDFARemnant_
The PDF for beam particle A for remnant splitting.
Ptr< HardScaleProfile >::ptr hardScaleProfile_
The profile scales.
bool doISR_
Switch on or off initial state radiation.
bool splitHardProcess_
Whether or not to split into hard and decay trees.
ThePEG::Ptr< ParticleData >::transient_const_pointer tcPDPtr
A struct to order the particles in the same way as in the DecayMode&#39;s.
bool doFSR_
Switch on or off final state radiation.
struct that is used to catch exceptions which are thrown due to energy conservation issues of additio...
virtual bool correlations() const
Any correlations.
pair< tRemPPtr, tRemPPtr > RemPair
Typedef for a pair of ThePEG::RemnantParticle pointers.
Definition: ShowerHandler.h:47
ThePEG::Ptr< SubProcess >::transient_pointer tSubProPtr
ThePEG::Ptr< XC >::pointer XCPtr
pair< PBIPtr, PBIPtr > PBIPair
bool doRadiation() const
Switch for any radiation.
UEBasePtr MPIHandler_
a MPIHandler to administer the creation of several (semihard) partonic interactions.
ThePEG::Ptr< Particle >::transient_pointer tPPtr
map< string, double > & currentWeights()
Access the current Weights.
virtual bool isReshuffling() const
Return true, if this cascade handler will perform reshuffling from hard process masses.
Definition: ShowerHandler.h:96
PDFPtr PDFA_
PDFs to be used for the various stages and related parameters.
PDFPtr getPDFA() const
Get the local PDFs.
bool hardScaleIsMuF() const
Return true if maximum pt should be deduced from the factorization scale.
void unSetCurrentHandler()
Unset the current handler.
static const tShowerHandlerPtr currentHandler()
pointer to "this", the current ShowerHandler.
Definition: ShowerHandler.h:72
double hardScaleFactor() const
The scale factor for the hard scale.
tPPair incomingBeams() const
Access to the incoming beam particles.
unsigned int maxtry() const
Return the maximum number of attempts for showering a given subprocess.
const map< string, ShowerVariation > & showerVariations() const
Return the shower variations.
-*- C++ -*-
bool restrictPhasespace_
True, if the phase space restrictions of the dipole shower should be applied.
ThePEG::Ptr< PDFBase >::pointer PDFPtr
double reweight_
A reweighting factor applied by the showering.
unsigned int maxtryDecay_
Maximum number of attempts to generate a decay.
unsigned int spinOpt_
Option to include spin correlations.
multimap< Energy, PerturbativeProcessPtr, std::greater< Energy > > DecayProcessMap
Typedef for map of PerturbativeProcess for decays.
set< long > particlesDecayInShower_
PDG codes of the particles which decay during showering this is fast storage for use during running...
bool doISR() const
Switch on or off initial state radiation.
vector< long > inputparticlesDecayInShower_
PDG codes of the particles which decay during showering this is a vector that is interfaced so they c...
This class is the main driver of the shower: it is responsible for the proper handling of all other s...
Definition: ShowerHandler.h:40
vector< tPPtr > tPVector
multiset< tcPDPtr, ParticleOrdering > OrderedParticles
A container for ordered particles required for constructing tags for decay mode lookup.
PDFPtr PDFBRemnant_
The PDF for beam particle B for remnant splitting.
virtual int showerPhaseSpaceOption() const
Return information about shower phase space choices.
double renormalizationScaleFactor_
The renormalization scale factor.
double hardScaleFactor_
The scale factor for the hard scale.
bool isMPIOn() const
Return true if multiple parton interactions are switched on and can be used for this beam setup...
double factorizationScaleFactor_
Factors for the various scales.
LorentzRotation boost_
Boost to get back to the lab.
const int tries
variable to store the number of attempts