herwig is hosted by Hepforge, IPPP Durham
Herwig  7.2.1
SubtractedME.h
1 // -*- C++ -*-
2 //
3 // SubtractedME.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_SubtractedME_H
10 #define HERWIG_SubtractedME_H
11 //
12 // This is the declaration of the SubtractedME class.
13 //
14 
15 #include "ThePEG/MatrixElement/MEGroup.h"
16 #include "Herwig/MatrixElement/Matchbox/Base/MatchboxMEBase.h"
17 #include "Herwig/MatrixElement/Matchbox/Dipoles/SubtractionDipole.h"
18 #include "Herwig/MatrixElement/Matchbox/Utility/LastMatchboxXCombInfo.h"
19 #include "Herwig/MatrixElement/Matchbox/MatchboxFactory.fh"
20 
21 namespace Herwig {
22 
23 using namespace ThePEG;
24 
34 class SubtractedME:
35  public MEGroup,
36  public LastMatchboxXCombInfo {
37 
38 public:
39 
45  SubtractedME();
46 
50  virtual ~SubtractedME();
52 
53 public:
54 
58  Ptr<MatchboxFactory>::tcptr factory() const;
59 
62 
67  virtual StdXCombPtr makeXComb(Energy newMaxEnergy, const cPDPair & inc,
68  tEHPtr newEventHandler,tSubHdlPtr newSubProcessHandler,
69  tPExtrPtr newExtractor, tCascHdlPtr newCKKW,
70  const PBPair & newPartonBins, tCutsPtr newCuts,
71  const DiagramVector & newDiagrams, bool mir,
72  const PartonPairVec& allPBins,
73  tStdXCombPtr newHead = tStdXCombPtr(),
74  tMEPtr newME = tMEPtr());
75 
80  virtual void setXComb(tStdXCombPtr);
81 
87  virtual bool uniformAdditional() const { return true; }
88 
94  virtual bool keepRandomNumbers() const { return true; }
95 
101  virtual MEBase::DiagramVector dependentDiagrams(const cPDVector& proc,
102  tMEPtr depME) const;
103 
110  virtual bool subProcessGroups() const;
111 
117  virtual bool selectDependentSubProcess() const { return false; }
118 
123  virtual void fillProjectors();
124 
128  virtual bool willProject() const {
129  return virtualShowerSubtraction() || loopSimSubtraction();
130  }
131 
136  virtual bool groupReweighted() const {
137  return showerApproximation();
138  }
139 
143  virtual double reweightHead(const vector<tStdXCombPtr>&);
144 
148  virtual double reweightDependent(tStdXCombPtr, const vector<tStdXCombPtr>&);
149 
153  void doRealEmissionScales();
154 
156 
159 
165  virtual void flushCaches() {
167  if ( showerApproximation() )
168  showerApproximation()->resetBelowCutoff();
169  }
170 
174  Ptr<ShowerApproximation>::tptr showerApproximation() const;
175 
179  void doRealShowerSubtraction();
180 
184  bool realShowerSubtraction() const { return theRealShowerSubtraction; }
185 
189  void doVirtualShowerSubtraction();
190 
194  bool virtualShowerSubtraction() const { return theVirtualShowerSubtraction; }
195 
199  void doLoopSimSubtraction();
200 
204  bool loopSimSubtraction() const { return theLoopSimSubtraction; }
205 
207 
210 
214  vector<Ptr<SubtractionDipole>::ptr> dipoles();
215 
219  const vector<Ptr<MatchboxMEBase>::ptr>& borns() const;
220 
225  void setBorns(const vector<Ptr<MatchboxMEBase>::ptr>& newBorns) { theBorns = newBorns; }
226 
230  void getDipoles();
231 
235  void cloneDipoles(const string& prefix = "");
236 
240  void cloneRealME(const string& prefix = "");
241 
245  void cloneDependencies(const string& prefix = "") {
246  cloneDipoles(prefix);
247  cloneRealME(prefix);
248  }
249 
253  vector<Ptr<SubtractionDipole>::ptr> splitDipoles(const cPDVector&);
254 
256 
264  virtual void setVetoScales(tSubProPtr) const;
266 
269 
273  void print(ostream&) const;
274 
281  virtual void lastEventStatistics();
282 
286  void printLastEvent(ostream&) const;
287 
291  void lastEventSubtraction();
292 
296  bool verbose() const;
297 
301  bool initVerbose() const;
302 
304 
307 
314  virtual bool preInitialize() const { return true; }
315 
320 
324  double lower;
325 
329  map<double,pair<double,double> > bins;
330 
334  SubtractionHistogram(double low = 0.001,
335  double up = 10.,
336  unsigned int nbins = 100);
337 
341  void book(double inv, double diff) {
342  map<double,pair<double,double> >::iterator b =
343  bins.upper_bound(inv);
344  if ( b == bins.end() ) return;
345  b->second.first = min(b->second.first,diff);
346  b->second.second = max(b->second.second,diff);
347  }
348 
352  void dump(const std::string& prefix,
353  const int& plottype,
354  const bool& scatterplot,
355  const cPDVector& proc,
356  int i, int j) const;
357 
361  void persistentOutput(PersistentOStream&) const;
362 
366  void persistentInput(PersistentIStream&);
367 
368  };
369 
371 
372 public:
373 
380  void persistentOutput(PersistentOStream & os) const;
381 
387  void persistentInput(PersistentIStream & is, int version);
389 
396  static void Init();
397 
398 protected:
399 
406  virtual IBPtr clone() const;
407 
412  virtual IBPtr fullclone() const;
414 
415 
416 // If needed, insert declarations of virtual function defined in the
417 // InterfacedBase class here (using ThePEG-interfaced-decl in Emacs).
418 
419 
420 protected:
421 
429  virtual void doinit();
430 
435  virtual void doinitrun();
436 
441  virtual void dofinish();
442 
444 
445 private:
446 
451  vector<Ptr<MatchboxMEBase>::ptr> theBorns;
452 
457  Ptr<MatchboxMEBase>::ptr theReal;
458 
462  typedef pair<cPDVector,pair<size_t, size_t> > CollinearSubtractionIndex;
463 
467  map<CollinearSubtractionIndex,SubtractionHistogram> collinearHistograms;
468 
472  map<CollinearSubtractionIndex,string> fnamesCollinearSubtraction;
473 
477  typedef pair<cPDVector,size_t> SoftSubtractionIndex;
478 
482  map<SoftSubtractionIndex,SubtractionHistogram> softHistograms;
483 
487  map<SoftSubtractionIndex,string> fnamesSoftSubtraction;
488 
493 
498 
503 
504 private:
505 
510  SubtractedME & operator=(const SubtractedME &) = delete;
511 
512 };
513 
516  h.persistentOutput(os);
517  return os;
518 }
519 
522  h.persistentInput(is);
523  return is;
524 }
525 
526 }
527 
528 #endif /* HERWIG_SubtractedME_H */
map< SoftSubtractionIndex, SubtractionHistogram > softHistograms
subtraction data for soft limits.
Definition: SubtractedME.h:482
void setBorns(const vector< Ptr< MatchboxMEBase >::ptr > &newBorns)
Access the underlying born matrix elements, overriding the ones contained in the factory object...
Definition: SubtractedME.h:225
bool realShowerSubtraction() const
Return true, if the shower real emission contribution should be subtracted.
Definition: SubtractedME.h:184
Ptr< MatchboxMEBase >::ptr theReal
Pointer to the head real emission ME casted to a MatchboxMEBase object.
Definition: SubtractedME.h:457
virtual bool selectDependentSubProcess() const
Return true, if one of the dependent subprocesses should be constructed in place of the one driven by...
Definition: SubtractedME.h:117
map< double, pair< double, double > > bins
The bins, indexed by upper bound.
Definition: SubtractedME.h:329
void cloneDependencies(const string &prefix="")
Clone all dependencies.
Definition: SubtractedME.h:245
virtual bool uniformAdditional() const
Return true, if the same additional random numbers should be presented to any of the dependent matrix...
Definition: SubtractedME.h:87
bool loopSimSubtraction() const
Return true, if the loopsim matched virtual contribution should be subtracted.
Definition: SubtractedME.h:204
ThePEG::Ptr< InterfacedBase >::pointer IBPtr
virtual bool keepRandomNumbers() const
Return true, if the XComb steering this matrix element should keep track of the random numbers used t...
Definition: SubtractedME.h:94
bool virtualShowerSubtraction() const
Return true, if the shower virtual contribution should be subtracted.
Definition: SubtractedME.h:194
vector< Ptr< MatchboxMEBase >::ptr > theBorns
The underlying born matrix elements, overriding the ones contained in the factory object...
Definition: SubtractedME.h:451
virtual bool willProject() const
Return true, if projectors will be used.
Definition: SubtractedME.h:128
void persistentInput(PersistentIStream &)
Read from persistent istream.
pair< cPDVector, size_t > SoftSubtractionIndex
Define the key for the soft subtraction data.
Definition: SubtractedME.h:477
bool theLoopSimSubtraction
True, if the loopsim matched virtual contribution should be subtracted.
Definition: SubtractedME.h:502
ostream & operator<<(ostream &, const DecayIntegrator &)
Output information on the DecayIntegrator for debugging purposes.
map< CollinearSubtractionIndex, SubtractionHistogram > collinearHistograms
subtraction data for collinear limits.
Definition: SubtractedME.h:467
ThePEG::Ptr< EventHandler >::transient_pointer tEHPtr
void persistentOutput(PersistentOStream &) const
Write to persistent ostream.
ThePEG::Ptr< CascadeHandler >::transient_pointer tCascHdlPtr
Provide easy access to MatchboxXComb XComb extensions.
PersistentIStream & operator>>(PersistentIStream &is, map< ShowerInteraction, T, Cmp, A > &m)
Read a map with ShowerInteraction as the key.
map< CollinearSubtractionIndex, string > fnamesCollinearSubtraction
names of files to which subtraction data is written for all phase space points individually ...
Definition: SubtractedME.h:472
ThePEG::Ptr< SubProcess >::transient_pointer tSubProPtr
bool theVirtualShowerSubtraction
True, if the shower virtual contribution should be subtracted.
Definition: SubtractedME.h:497
Simple envelope histogram to keep track of subtraction.
Definition: SubtractedME.h:319
vector< cPDPtr > cPDVector
SubtractedME represents a subtracted real emission matrix element.
Definition: SubtractedME.h:34
vector< DiagPtr > DiagramVector
pair< cPDVector, pair< size_t, size_t > > CollinearSubtractionIndex
Define the key for the collinear subtraction data.
Definition: SubtractedME.h:462
-*- C++ -*-
pair< cPDPtr, cPDPtr > cPDPair
virtual bool preInitialize() const
Return true if this object needs to be initialized before all other objects (except those for which t...
Definition: SubtractedME.h:314
bool theRealShowerSubtraction
True, if the shower real emission contribution should be subtracted.
Definition: SubtractedME.h:492
virtual void flushCaches()
virtual bool groupReweighted() const
Return true, if this MEGroup will reweight the contributing cross sections.
Definition: SubtractedME.h:136
map< SoftSubtractionIndex, string > fnamesSoftSubtraction
names of files to which subtraction data is written for all phase space points individually ...
Definition: SubtractedME.h:487
void book(double inv, double diff)
Book an event.
Definition: SubtractedME.h:341
ThePEG::Ptr< PartonExtractor >::transient_pointer tPExtrPtr
virtual void flushCaches()
Inform this matrix element that a new phase space point is about to be generated, so all caches shoul...
Definition: SubtractedME.h:165