herwig is hosted by Hepforge, IPPP Durham
Herwig  7.2.1
FxFxEventHandler.h
1 // -*- C++ -*-
2 //
3 // FxFxEventHandler.h is a part of ThePEG - Toolkit for HEP Event Generation
4 // Copyright (C) 1999-2019 Leif Lonnblad
5 //
6 // ThePEG 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 THEPEG_FxFxEventHandler_H
10 #define THEPEG_FxFxEventHandler_H
11 //
12 // This is the declaration of the FxFxEventHandler class.
13 //
14 
15 #include "ThePEG/Handlers/EventHandler.h"
16 #include "FxFxEventHandler.fh"
17 #include "FxFxReader.fh"
18 #include "ThePEG/Utilities/CompSelector.h"
19 #include "ThePEG/Utilities/XSecStat.h"
20 
21 namespace ThePEG {
22 
41 
42 public:
43 
47  typedef vector<FxFxReaderPtr> ReaderVector;
48 
53 
57  enum WeightOpt {
58  unitweight = 1,
60  varweight = 2,
62  };
63 
64  friend class FxFxHandler;
65 
66 
67 public:
68 
76  {
78  }
79 
83  virtual ~FxFxEventHandler();
85 
86 public:
87 
94  virtual void initialize();
95 
100  virtual void statistics(ostream &) const;
101 
107  virtual CrossSection histogramScale() const;
108 
114  virtual CrossSection integratedXSec() const;
115 
116  virtual int ntriesinternal() const;
117 
123  virtual CrossSection integratedXSecErr() const;
124 
125  virtual map<string,CrossSection> optintegratedXSecMap() const;
126 
128 
134  virtual EventPtr generateEvent();
135 
140  virtual tCollPtr performCollision();
141 
146  virtual EventPtr continueEvent();
148 
157  void select(double weight);
158 
163  void accept();
164 
169  void reject(double weight);
170 
174  void increaseMaxXSec(CrossSection maxxsec);
175 
180  void skipEvents();
181 
183 
190 
195  double unitTolerance() const { return theUnitTolerance; }
196 
200  const ReaderVector & readers() const { return theReaders; }
201 
206  const ReaderSelector & selector() const { return theSelector; }
207 
211  tFxFxReaderPtr currentReader() const { return theCurrentReader; }
212 
213 
217  void currentReader(tFxFxReaderPtr x) { theCurrentReader = x; }
218 
220 
221 public:
222 
229  void persistentOutput(PersistentOStream & os) const;
230 
236  void persistentInput(PersistentIStream & is, int version);
238 
245  static void Init();
246 
250  tFxFxReaderPtr theCurrentReader;
251 
252 
253 
254 protected:
255 
262  virtual IBPtr clone() const;
263 
268  virtual IBPtr fullclone() const;
270 
271 protected:
272 
280  virtual void doinit();
281 
286  virtual void doinitrun();
287 
292  virtual void dofinish();
294 
295 protected:
296 
300  ReaderVector & readers() { return theReaders; }
301 
306  ReaderSelector & selector() { return theSelector; }
307 
311  void setUnitTolerance(double);
312 
317 
318  map<string,XSecStat> optstats;
319 
320  map<string,CrossSection> optxs;
321 
322  int ntries;
323 
324  map<string,XSecStat> OptStatsFunc() { return optstats; }
325 
326  map<string,CrossSection> OptXsFunc() { return optxs; }
327 
328 
334 
335  map<string,XSecStat> opthistStats;
336 
337 
338  /*
339  * The weight identifiers for the events
340  */
341 
342  vector<string> weightnames;
343 
344 private:
345 
349  ReaderVector theReaders;
350 
355  ReaderSelector theSelector;
356 
361 
367 
368 
373  bool warnPNum;
374 
378  unsigned int theNormWeight;
379 
380 
381 public:
382 
387  class FxFxInitError: public InitException {};
388 
393  class FxFxPNumException: public InitException {};
396 private:
397 
403 
408  FxFxEventHandler & operator=(const FxFxEventHandler &) = delete;
409 
410 };
411 
412 }
413 
414 // CLASSDOC OFF
415 
416 #include "ThePEG/Utilities/ClassTraits.h"
417 
418 namespace ThePEG {
419 
424 template <>
425 struct BaseClassTrait<FxFxEventHandler,1> {
427  typedef EventHandler NthBase;
428 };
429 
432 template <>
433 struct ClassTraits<FxFxEventHandler>
434  : public ClassTraitsBase<FxFxEventHandler> {
436  static string className() { return "Herwig::FxFxEventHandler"; }
440  static string library() { return "HwFxFx.so"; }
441 };
442 
445 }
446 
447 #endif /* THEPEG_FxFxEventHandler_H */
double unitTolerance() const
If the weight option is set to unit weight, do not start compensating unless the weight is this much ...
void accept()
Accept the current event, taking care of the statistics collection of the corresponding reader object...
ReaderVector & readers()
Access the list of readers.
virtual void initialize()
Initialize this event handler and all related objects needed to generate events.
virtual ~FxFxEventHandler()
The destructor.
Varying positive or negative weights.
The FxFxEventHandler inherits from the general EventHandler class and administers the reading of even...
virtual void doinitrun()
Initialize this object.
virtual CrossSection integratedXSec() const
The estimated total integrated cross section of the processes generated in this run.
FxFxEventHandler & operator=(const FxFxEventHandler &)=delete
The assignment operator is private and must never be called.
bool warnPNum
Warn if the same process number is used in more than one FxFxReader.
virtual EventPtr continueEvent()
Continue generating an event if the generation has been stopped before finishing. ...
ThePEG::Ptr< InterfacedBase >::pointer IBPtr
virtual void statistics(ostream &) const
Write out accumulated statistics about intergrated cross sections and stuff.
void tolerance(double t)
WeightOpt
Enumerate the weighting options.
tFxFxReaderPtr theCurrentReader
The currently selected reader object.
Varying positive weights.
FxFxEventHandler()
The default constructor.
WeightOpt weightOption() const
The way weights are to be treated.
ThePEG::Ptr< Event >::pointer EventPtr
static void Init()
The standard Init function used to initialize the interfaces.
CompSelector< int, CrossSection > ReaderSelector
A selector of readers.
virtual void doinit()
Initialize this object after the setup phase before saving an EventGenerator to disk.
void persistentOutput(PersistentOStream &os) const
Function used to write out object persistently.
double theUnitTolerance
If the weight option is set to unit weight, do not start compensating unless the weight is this much ...
XSecStat histStats
Collect statistics for this event handler.
virtual IBPtr fullclone() const
Make a clone of this object, possibly modifying the cloned object to make it sane.
void reject(double weight)
Reject the current event, taking care of the statistics collection of the corresponding reader object...
void skipEvents()
Skip some events.
WeightOpt theWeightOption
The way weights are to be treated.
void persistentInput(PersistentIStream &is, int version)
Function used to read in object persistently.
static ClassDescription< FxFxEventHandler > initFxFxEventHandler
The static object used to initialize the description of this class.
ReaderVector theReaders
The list of readers.
void setUnitTolerance(double)
Helper function for the interface;.
void select(double weight)
An event has been selected.
vector< FxFxReaderPtr > ReaderVector
A vector of FxFxReader objects.
ThePEG::Ptr< Collision >::transient_pointer tCollPtr
unsigned int theNormWeight
How to normalize the weights.
virtual tCollPtr performCollision()
Create the Event and Collision objects.
const ReaderSelector & selector() const
The selector to choose readers according to their overestimated cross section.
void currentReader(tFxFxReaderPtr x)
Set the currently selected reader object.
virtual void dofinish()
Finalize this object.
ReaderSelector & selector()
The selector to choose readers according to their overestimated cross section.
All events have wight +/- 1.
virtual EventPtr generateEvent()
Generate an event.
void increaseMaxXSec(CrossSection maxxsec)
Increase the overestimated cross section for the selected reader.
virtual IBPtr clone() const
Make a simple clone of this object.
const ReaderVector & readers() const
Access the list of readers.
tFxFxReaderPtr currentReader() const
The currently selected reader object.
virtual CrossSection integratedXSecErr() const
The estimated error in the total integrated cross section of the processes generated in this run...
ReaderSelector theSelector
The selector to choose readers according to their overestimated cross section.
virtual CrossSection histogramScale() const
Histogram scale.
All events have unit weight.
XSecStat stats
Collect statistics for this event handler.