thepeg is hosted by Hepforge, IPPP Durham
ThePEG  2.2.1
LesHouchesEventHandler.h
1 // -*- C++ -*-
2 //
3 // LesHouchesEventHandler.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_LesHouchesEventHandler_H
10 #define THEPEG_LesHouchesEventHandler_H
11 //
12 // This is the declaration of the LesHouchesEventHandler class.
13 //
14 
15 #include "ThePEG/Handlers/EventHandler.h"
16 #include "LesHouchesEventHandler.fh"
17 #include "LesHouchesReader.fh"
18 #include "ThePEG/Utilities/CompSelector.h"
19 #include "ThePEG/Utilities/XSecStat.h"
20 
21 namespace ThePEG {
22 
23 
42 
43 public:
44 
48  typedef vector<LesHouchesReaderPtr> ReaderVector;
49 
54 
58  enum WeightOpt {
59  unitweight = 1,
61  varweight = 2,
63  };
64 
65 public:
66 
74  theNormWeight(0)
75  {
77  }
78 
82  virtual ~LesHouchesEventHandler();
84 
85 public:
86 
93  virtual void initialize();
94 
99  virtual void statistics(ostream &) const;
100 
106  virtual CrossSection histogramScale() const;
107 
113  virtual CrossSection integratedXSec() const;
114 
119  virtual int ntriesinternal() const;
120 
126  virtual CrossSection integratedXSecErr() const;
127 
132  virtual const map<string,CrossSection> & optintegratedXSecMap() const;
133 
135 
141  virtual EventPtr generateEvent();
142 
147  virtual tCollPtr performCollision();
148 
153  virtual EventPtr continueEvent();
155 
164  void select(double weight);
165 
170  void accept();
171 
176  void reject(double weight);
177 
181  void increaseMaxXSec(CrossSection maxxsec);
182 
187  void skipEvents();
188 
190 
197 
202  double unitTolerance() const { return theUnitTolerance; }
203 
207  const ReaderVector & readers() const { return theReaders; }
208 
213  const ReaderSelector & selector() const { return theSelector; }
214 
218  tLesHouchesReaderPtr currentReader() const { return theCurrentReader; }
219 
220 
224  void currentReader(tLesHouchesReaderPtr x) { theCurrentReader = x; }
225 
227 
228 public:
229 
236  void persistentOutput(PersistentOStream & os) const;
237 
243  void persistentInput(PersistentIStream & is, int version);
245 
252  static void Init();
253 
257  tLesHouchesReaderPtr theCurrentReader;
258 
259 protected:
260 
267  virtual IBPtr clone() const;
268 
273  virtual IBPtr fullclone() const;
275 
276 protected:
277 
285  virtual void doinit();
286 
291  virtual void doinitrun();
292 
297  virtual void dofinish();
299 
300 protected:
301 
305  ReaderVector & readers() { return theReaders; }
306 
311  ReaderSelector & selector() { return theSelector; }
312 
316  void setUnitTolerance(double);
317 
322 
328 
333  vector<string> weightnames;
334 
338  struct OptWeight {
339 
344 
349 
355  };
356 
358  map <string,OptWeight> opt;
359 
364  int ntries;
365 
370  const map<string,OptWeight> & optWeights() const { return opt; }
371 
372 private:
373 
377  ReaderVector theReaders;
378 
383  ReaderSelector theSelector;
384 
389 
395 
396 
401  bool warnPNum;
402 
406  unsigned int theNormWeight;
407 
408 public:
409 
414  class LesHouchesInitError: public InitException {};
415 
420  class LesHouchesPNumException: public InitException {};
423 private:
424 
430 
436 
437 };
438 
439 }
440 
441 // CLASSDOC OFF
442 
443 #include "ThePEG/Utilities/ClassTraits.h"
444 
445 namespace ThePEG {
446 
451 template <>
452 struct BaseClassTrait<LesHouchesEventHandler,1> {
454  typedef EventHandler NthBase;
455 };
456 
459 template <>
460 struct ClassTraits<LesHouchesEventHandler>
461  : public ClassTraitsBase<LesHouchesEventHandler> {
463  static string className() { return "ThePEG::LesHouchesEventHandler"; }
467  static string library() { return "LesHouches.so"; }
468 };
469 
472 }
473 
474 #endif /* THEPEG_LesHouchesEventHandler_H */
virtual IBPtr fullclone() const
Make a clone of this object, possibly modifying the cloned object to make it sane.
PersistentIStream is used to read persistent objects from a stream where they were previously written...
double theUnitTolerance
If the weight option is set to unit weight, do not start compensating unless the weight is this much ...
ReaderVector theReaders
The list of readers.
ReaderSelector theSelector
The selector to choose readers according to their overestimated cross section.
The EventHandler is the base class used to implement event handlers in ThePEG.
Definition: EventHandler.h:63
The LesHouchesEventHandler inherits from the general EventHandler class and administers the reading o...
virtual const map< string, CrossSection > & optintegratedXSecMap() const
Map to aid the calculation of the optional weights&#39; integrated cross section.
tLesHouchesReaderPtr currentReader() const
The currently selected reader object.
int ntries
Counter for the number of tries for the purpose of statistics.
A concreate implementation of ClassDescriptionBase describing a concrete class with persistent data...
Varying positive or negative weights.
virtual void statistics(ostream &) const
Write out accumulated statistics about intergrated cross sections and stuff.
PersistentOStream is used to write objects persistently to a stream from which they can be read in ag...
ReaderSelector & selector()
The selector to choose readers according to their overestimated cross section.
tLesHouchesReaderPtr theCurrentReader
The currently selected reader object.
vector< LesHouchesReaderPtr > ReaderVector
A vector of LesHouchesReader objects.
LesHouchesEventHandler()
The default constructor.
virtual void initialize()
Initialize this event handler and all related objects needed to generate events.
const ReaderSelector & selector() const
The selector to choose readers according to their overestimated cross section.
TransientRCPtr is a simple wrapper around a bare pointer which can be assigned to and from an RCPtr a...
Definition: RCPtr.h:519
bool warnPNum
Warn if the same process number is used in more than one LesHouchesReader.
virtual CrossSection histogramScale() const
Histogram scale.
CompSelector< int, CrossSection > ReaderSelector
A selector of readers.
void tolerance(double t)
Set the tolerance for how much a weight is allowed to be larger than unity before starting the compen...
Definition: CompSelector.h:166
const ReaderVector & readers() const
Access the list of readers.
This is the main namespace within which all identifiers in ThePEG are declared.
Definition: FactoryBase.h:28
void currentReader(tLesHouchesReaderPtr x)
Set the currently selected reader object.
XSecStat histStats
Collect statistics for this event handler&#39;s optional weights.
void skipEvents()
Skip some events.
WeightOpt theWeightOption
The way weights are to be treated.
virtual int ntriesinternal() const
The number of attempts inside the statistics object.
void accept()
Accept the current event, taking care of the statistics collection of the corresponding reader object...
map< string, OptWeight > opt
Map statistics to weight name strings.
void increaseMaxXSec(CrossSection maxxsec)
Increase the overestimated cross section for the selected reader.
void persistentInput(PersistentIStream &is, int version)
Function used to read in object persistently.
XSecStat histStats
Collect statistics for this event handler.
CrossSection xs
Calculate the cross section for the optional weights.
void select(double weight)
An event has been selected.
WeightOpt weightOption() const
The way weights are to be treated.
virtual ~LesHouchesEventHandler()
The destructor.
virtual EventPtr generateEvent()
Generate an event.
virtual void doinitrun()
Initialize this object.
virtual void dofinish()
Finalize this object.
virtual CrossSection integratedXSecErr() const
The estimated error in the total integrated cross section of the processes generated in this run...
static ClassDescription< LesHouchesEventHandler > initLesHouchesEventHandler
The static object used to initialize the description of this class.
XSecStat stats
Collect statistics for this event handler.
virtual CrossSection integratedXSec() const
The estimated total integrated cross section of the processes generated in this run.
RCPtr is a reference counted (smart) pointer.
Definition: RCPtr.h:60
double unitTolerance() const
If the weight option is set to unit weight, do not start compensating unless the weight is this much ...
WeightOpt
Enumerate the weighting options.
const map< string, OptWeight > & optWeights() const
Return the optional weights&#39; statistics.
XSecStat stats
Collect statistics for the optional weights.
void setUnitTolerance(double)
Helper function for the interface;.
virtual EventPtr continueEvent()
Continue generating an event if the generation has been stopped before finishing. ...
The default concrete implementation of ClassTraitsBase.
Definition: ClassTraits.h:134
unsigned int theNormWeight
How to normalize the weights.
Collect statistics for this event handler&#39;s optional weights.
vector< string > weightnames
The weight identifiers for the events.
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.
static void Init()
The standard Init function used to initialize the interfaces.
virtual tCollPtr performCollision()
Create the Event and Collision objects.
virtual IBPtr clone() const
Make a simple clone of this object.
BaseClassTraits describes the base classes of the templated class.
Definition: ClassTraits.h:156
XSecStat is a concrete helper class used to collect statistics about the cross section for a specific...
Definition: XSecStat.h:36
ReaderVector & readers()
Access the list of readers.
LesHouchesEventHandler & operator=(const LesHouchesEventHandler &)=delete
The assignment operator is private and must never be called.
The templated ClassTraitsBase class defines a set of default information about classes used by ThePEG...
Definition: ClassTraits.h:52
void reject(double weight)
Reject the current event, taking care of the statistics collection of the corresponding reader object...