ThePEG  1.8.0
LesHouchesEventHandler.h
1 // -*- C++ -*-
2 //
3 // LesHouchesEventHandler.h is a part of ThePEG - Toolkit for HEP Event Generation
4 // Copyright (C) 1999-2011 Leif Lonnblad
5 //
6 // ThePEG is licenced under version 2 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 
41 
42 public:
43 
47  typedef vector<LesHouchesReaderPtr> ReaderVector;
48 
53 
57  enum WeightOpt {
58  unitweight = 1,
60  varweight = 2,
62  };
63 
64 public:
65 
73  {
75  }
76 
80  virtual ~LesHouchesEventHandler();
82 
83 public:
84 
91  virtual void initialize();
92 
97  virtual void statistics(ostream &) const;
98 
104  virtual CrossSection histogramScale() const;
105 
111  virtual CrossSection integratedXSec() const;
112 
118  virtual CrossSection integratedXSecErr() const;
120 
126  virtual EventPtr generateEvent();
127 
132  virtual tCollPtr performCollision();
133 
138  virtual EventPtr continueEvent();
140 
149  void select(double weight);
150 
155  void accept();
156 
161  void reject(double weight);
162 
166  void increaseMaxXSec(CrossSection maxxsec);
167 
172  void skipEvents();
173 
175 
182 
187  double unitTolerance() const { return theUnitTolerance; }
188 
192  const ReaderVector & readers() const { return theReaders; }
193 
198  const ReaderSelector & selector() const { return theSelector; }
199 
203  tLesHouchesReaderPtr currentReader() const { return theCurrentReader; }
204 
208  void currentReader(tLesHouchesReaderPtr x) { theCurrentReader = x; }
209 
211 
212 public:
213 
220  void persistentOutput(PersistentOStream & os) const;
221 
227  void persistentInput(PersistentIStream & is, int version);
229 
236  static void Init();
237 
238 protected:
239 
246  virtual IBPtr clone() const;
247 
252  virtual IBPtr fullclone() const;
254 
255 protected:
256 
264  virtual void doinit();
265 
270  virtual void doinitrun();
271 
276  virtual void dofinish();
278 
279 protected:
280 
284  ReaderVector & readers() { return theReaders; }
285 
290  ReaderSelector & selector() { return theSelector; }
291 
295  void setUnitTolerance(double);
296 
301 
307 
308 private:
309 
313  ReaderVector theReaders;
314 
319  ReaderSelector theSelector;
320 
325 
331 
335  tLesHouchesReaderPtr theCurrentReader;
336 
341  bool warnPNum;
342 
343 public:
344 
349  class LesHouchesInitError: public InitException {};
350 
355  class LesHouchesPNumException: public InitException {};
358 private:
359 
365 
371 
372 };
373 
374 }
375 
376 // CLASSDOC OFF
377 
378 #include "ThePEG/Utilities/ClassTraits.h"
379 
380 namespace ThePEG {
381 
386 template <>
389  typedef EventHandler NthBase;
390 };
391 
394 template <>
396  : public ClassTraitsBase<LesHouchesEventHandler> {
398  static string className() { return "ThePEG::LesHouchesEventHandler"; }
402  static string library() { return "LesHouches.so"; }
403 };
404 
407 }
408 
409 #endif /* THEPEG_LesHouchesEventHandler_H */
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.
virtual CrossSection histogramScale() const
Histogram scale.
ReaderSelector theSelector
The selector to choose readers according to their overestimated cross section.
LesHouchesEventHandler & operator=(const LesHouchesEventHandler &)
The assignment operator is private and must never be called.
The EventHandler is the base class used to implement event handlers in ThePEG.
Definition: EventHandler.h:63
WeightOpt weightOption() const
The way weights are to be treated.
The LesHouchesEventHandler inherits from the general EventHandler class and administers the reading o...
tLesHouchesReaderPtr currentReader() const
The currently selected reader object.
A concreate implementation of ClassDescriptionBase describing a concrete class with persistent data...
Varying positive or negative weights.
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.
TransientRCPtr is a simple wrapper around a bare pointer which can be assigned to and from an RCPtr a...
Definition: RCPtr.h:509
bool warnPNum
Warn if the same process number is used in more than one LesHouchesReader.
const ReaderVector & readers() const
Access the list of readers.
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
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.
virtual IBPtr clone() const
Make a simple clone of this object.
void skipEvents()
Skip some events.
WeightOpt theWeightOption
The way weights are to be treated.
void accept()
Accept the current event, taking care of the statistics collection of the corresponding reader object...
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.
double unitTolerance() const
If the weight option is set to unit weight, do not start compensating unless the weight is this much ...
void select(double weight)
An event has been selected.
virtual ~LesHouchesEventHandler()
The destructor.
virtual EventPtr generateEvent()
Generate an event.
virtual void doinitrun()
Initialize this object.
virtual void dofinish()
Finalize this object.
static ClassDescription< LesHouchesEventHandler > initLesHouchesEventHandler
The static object used to initialize the description of this class.
XSecStat stats
Collect statistics for this event handler.
RCPtr is a reference counted (smart) pointer.
Definition: RCPtr.h:60
WeightOpt
Enumerate the weighting options.
void persistentOutput(PersistentOStream &os) const
Function used to write out object persistently.
virtual CrossSection integratedXSecErr() const
The estimated error in the total integrated cross section of the processes generated in this run...
virtual IBPtr fullclone() const
Make a clone of this object, possibly modifying the cloned object to make it sane.
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
This template class allows the compiler to check calculations with physical quantities for dimensiona...
Definition: PhysicalQty.h:81
virtual void doinit()
Initialize this object after the setup phase before saving an EventGenerator to disk.
static void Init()
The standard Init function used to initialize the interfaces.
virtual tCollPtr performCollision()
Create the Event and Collision objects.
virtual CrossSection integratedXSec() const
The estimated total integrated cross section of the processes generated in this run.
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
virtual void statistics(ostream &) const
Write out accumulated statistics about intergrated cross sections and stuff.
ReaderVector & readers()
Access the list of readers.
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...
const ReaderSelector & selector() const
The selector to choose readers according to their overestimated cross section.