ThePEG  1.8.0
EventHandler.h
1 // -*- C++ -*-
2 //
3 // EventHandler.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_EventHandler_H
10 #define ThePEG_EventHandler_H
11 // This is the declaration of the EventHandler class.
12 
13 #include "ThePEG/Handlers/HandlerBase.h"
14 #include "ThePEG/Handlers/HandlerGroup.h"
15 #include "ThePEG/Handlers/StepHandler.h"
16 #include "ThePEG/EventRecord/Event.h"
17 #include "ThePEG/Handlers/LastXCombInfo.h"
18 #include "ThePEG/Handlers/SubProcessHandler.fh"
19 #include "ThePEG/Cuts/Cuts.fh"
20 #include "EventHandler.fh"
21 
22 namespace ThePEG {
23 
63 class EventHandler: public HandlerBase, public LastXCombInfo<> {
64 
65 public:
66 
74  };
75 
77  typedef vector<HandlerGroupBase *> GroupVector;
78 
79 public:
80 
86  EventHandler(bool warnincomplete = true);
87 
91  EventHandler(const EventHandler &);
92 
96  virtual ~EventHandler();
98 
99 public:
100 
107  virtual void initialize();
108 
115  virtual EventPtr generateEvent();
116 
123 
130 
135  virtual EventPtr continueEvent();
136 
142 
146  void clearEvent();
147 
151  virtual void select(tXCombPtr newXComb);
152 
157  virtual bool empty() const;
158 
163  virtual void statistics(ostream &) const;
164 
173  virtual CrossSection histogramScale() const;
174 
182  virtual CrossSection integratedXSec() const;
183 
191  virtual CrossSection integratedXSecErr() const;
193 
200  long maxLoop() const { return theMaxLoop; }
201 
206  const cPDPair & incoming() const { return theIncoming; }
207 
211  const LuminosityFunction & lumiFn() const { return *theLumiFn; }
212 
216  tcLumiFnPtr lumiFnPtr() const{ return theLumiFn; }
217 
222 
226  tCutsPtr cuts() const { return theCuts; }
227 
233 
234 
239  tCascHdlPtr CKKWHandler() const;
240 
245 
250 
254  tStepPtr currentStep() const { return theCurrentStep; }
260  int statLevel() const { return theStatLevel; }
261 
267 
273  double consistencyEpsilon() const { return theConsistencyEpsilon; }
274 
276 
283  void performStep(tStepHdlPtr handler, tHintPtr hint);
284 
291 
299  return currentStep();
300  }
301 
305  void popStep() {
306  currentCollision()->popStep();
307  currentStep(currentCollision()->finalStep());
308  }
309 
313  virtual void initGroups();
314 
319 
324 
329 
334 
339 
343  void throwCurrent();
344 
348  virtual void clean();
349 
355  virtual void checkConsistency() const;
356 
358 
359 public:
360 
367  void persistentOutput(PersistentOStream & os) const;
368 
374  void persistentInput(PersistentIStream & is, int version);
376 
380  static void Init();
381 
382 protected:
383 
390  virtual IBPtr clone() const;
391 
396  virtual IBPtr fullclone() const;
398 
405  virtual void dofinish() {
410  }
411 
421  virtual void rebind(const TranslationMap & trans);
422 
428  virtual IVector getReferences();
430 
431 
432 protected:
433 
438 
442  void setupGroups();
443 
447  GroupVector & groups() { return theGroups; }
448 
452  const GroupVector & groups() const { return theGroups; }
453 
454 
455 protected:
456 
460  void lumiFn(LumiFnPtr);
461 
462 private:
463 
469 
475 
481 
488 
493 
498  CutsPtr theCuts;
499 
505 
510 
515 
520 
525 
530 
534  GroupVector theGroups;
535 
540 
545 
550 
555 
556 protected:
557 
562 
567 
572 
577 
582 
583 protected:
584 
588  GroupVector optGroups;
589 
590 protected:
591 
596 
602 
603 protected:
604 
610  class EventHandlerStepError: public Exception {};
611 
616  class EventHandlerHistError: public Exception {};
617 
622  class EventHandlerIncompleteError: public Exception {};
623 
626  struct EventLoopException: public Exception {
628  EventLoopException(const EventHandler &);
629  };
630 
635  struct LumiFuncError: public Exception {};
636 
640  struct ConsistencyException: public Exception {};
641 
644 private:
645 
646  ThePEG_DECLARE_PREPOST_GROUP(SubProcessHandler,Post);
647  ThePEG_DECLARE_GROUPINTERFACE(CascadeHandler,CascHdlPtr);
648  ThePEG_DECLARE_GROUPINTERFACE(MultipleInteractionHandler,MIHdlPtr);
649  ThePEG_DECLARE_GROUPINTERFACE(HadronizationHandler,HadrHdlPtr);
650  ThePEG_DECLARE_GROUPINTERFACE(DecayHandler,DecayHdlPtr);
651 
652  ThePEG_DECLARE_CLASS_DESCRIPTION(EventHandler);
653 
658 
659 };
660 
662 ThePEG_DECLARE_CLASS_TRAITS(EventHandler,HandlerBase);
665 }
666 
667 #endif /* ThePEG_EventHandler_H */
void setupGroups()
Setup the step handler groups.
virtual void initialize()
Initialize this event handler and all related objects needed to generate events.
ThePEG::Ptr< HadronizationHandler >::pointer HadrHdlPtr
Alias for a reference counted pointer to HadronizationHandler .
Definition: Pointers.h:72
HandlerGroup< CascadeHandler > theCascadeGroup
The CascadeHandler group.
Definition: EventHandler.h:514
PersistentIStream is used to read persistent objects from a stream where they were previously written...
void performStep(tStepHdlPtr handler, tHintPtr hint)
Perform a given step using a handler and a hint.
ThePEG::Ptr< Step >::transient_pointer tStepPtr
Alias for a transient pointer to Step .
Definition: Pointers.h:85
static void Init()
Standard Init function used to initialize the interface.
The EventHandler is the base class used to implement event handlers in ThePEG.
Definition: EventHandler.h:63
EventPtr theCurrentEvent
The current Event.
Definition: EventHandler.h:539
const LuminosityFunction & lumiFn() const
Access the luminosity function.
Definition: EventHandler.h:211
tLumiFnPtr lumiFnPtr()
Access to the luminosity function.
Definition: EventHandler.h:221
The LuminosityFunction describes the momentum distribution of the incoming beams in an experiment...
virtual void checkConsistency() const
Check that the charge and energy-momentum in the last step of the current collision is consistent wit...
virtual IBPtr fullclone() const
Make a clone of this object, possibly modifying the cloned object to make it sane.
ThePEG::Ptr< Hint >::transient_pointer tHintPtr
Alias for a transient pointer to Hint .
Definition: Pointers.h:71
int theStatLevel
Controlls the amount of statistics written out after each run to the EventGenerators ...
Definition: EventHandler.h:474
HandlerGroup< MultipleInteractionHandler > theMultiGroup
The MultipleInteractionHandler group.
Definition: EventHandler.h:519
virtual CrossSection integratedXSec() const
The total integrated cross section of the processes generated in this run.
PersistentOStream is used to write objects persistently to a stream from which they can be read in ag...
LastXCombInfo is a templated class giving easy access to the information in an XComb object...
Definition: LastXCombInfo.h:32
double theConsistencyEpsilon
The maximum fraction of the total invariant mass of a collision that any of the components of the sum...
Definition: EventHandler.h:487
EventHandler(bool warnincomplete=true)
Default constructor.
virtual void initGroups()
Initialize the groups of step handlers.
tCollPtr continueCollision()
Continue the generation of a Collision.
virtual EventPtr continueEvent()
Continue generating an event if the generation has been stopped before finishing. ...
StepPtr theCurrentStep
The current Step.
Definition: EventHandler.h:549
TransientConstRCPtr is a simple wrapper around a bare const pointer which can be assigned to and from...
Definition: RCPtr.h:681
tStepHdlPtr currentStepHandler() const
Get current StepHandler.
Definition: EventHandler.h:333
virtual CrossSection histogramScale() const
Histogram scale.
TransientRCPtr is a simple wrapper around a bare pointer which can be assigned to and from an RCPtr a...
Definition: RCPtr.h:509
tCollPtr currentCollision() const
Get current collision.
Definition: EventHandler.h:249
void persistentInput(PersistentIStream &is, int version)
Function used to read in object persistently.
void currentStep(tStepPtr s)
Set current step.
Definition: EventHandler.h:328
void popStep()
Remove the last step.
Definition: EventHandler.h:305
GroupVector optGroups
Utility object to facilitate default selection of step handlers.
Definition: EventHandler.h:588
void clearEvent()
Clear all step handlers, making the handler ready for a new event.
vector< HandlerGroupBase * > GroupVector
A vector of HandlerGroups.
Definition: EventHandler.h:77
Rebinder is a class associating pairs of pointers to objects.
Definition: Rebinder.h:27
tcLumiFnPtr lumiFnPtr() const
Access the luminosity function.
Definition: EventHandler.h:216
void currentEvent(tEventPtr e)
Set current event.
Definition: EventHandler.h:318
This is the main namespace within which all identifiers in ThePEG are declared.
Definition: FactoryBase.h:28
LumiFnPtr theLumiFn
Pointer to a luminosity function tobe used by subclasses.
Definition: EventHandler.h:492
tCascHdlPtr CKKWHandler() const
Return a pointer (possibly null) to the assigned main CascadeHandler to be used as CKKW-reweighter...
long maxLoop() const
Return the maximum number attemts allowed to select a sub-process for each event. ...
Definition: EventHandler.h:200
bool warnIncomplete
Emit warning that this EventHandler is incomplete.
Definition: EventHandler.h:595
Check every Collision.
Definition: EventHandler.h:70
void persistentOutput(PersistentOStream &os) const
Function used to write out object persistently.
int statLevel() const
The level of statistics.
Definition: EventHandler.h:260
CutsPtr theCuts
The kinematical cuts to used by subclasses which do not provide their own.
Definition: EventHandler.h:498
void currentCollision(tCollPtr c)
Set current collision.
Definition: EventHandler.h:323
double consistencyEpsilon() const
The maximum fraction of the total invariant mass of a collision that any of the components of the sum...
Definition: EventHandler.h:273
HandlerGroup< HadronizationHandler > optHadronizationGroup
Utility object to facilitate default selection of step handlers.
Definition: EventHandler.h:576
Level
Enumeration for the type of step handler.
Definition: HandlerGroup.h:442
EventHandler & operator=(const EventHandler &)
Private and non-existent assignment operator.
virtual void rebind(const TranslationMap &trans)
Rebind pointer to other Interfaced objects.
virtual void dofinish()
Finalize this object.
Definition: EventHandler.h:405
ConsistencyLevel theConsistencyLevel
Determines how often the event handler should check for charge and energy-momentum conservation...
Definition: EventHandler.h:480
ThePEG::Ptr< StepHandler >::transient_pointer tStepHdlPtr
Alias for a transient pointer to StepHandler .
Definition: Pointers.h:70
tEventPtr currentEvent() const
Gget current event.
Definition: EventHandler.h:244
CollPtr theCurrentCollision
The current Collision.
Definition: EventHandler.h:544
HandlerGroup< DecayHandler > optDecayGroup
Utility object to facilitate default selection of step handlers.
Definition: EventHandler.h:581
HandlerGroup< SubProcessHandler > theSubprocessGroup
The SubProcessHandler group.
Definition: EventHandler.h:509
HandlerGroup< MultipleInteractionHandler > optMultiGroup
Utility object to facilitate default selection of step handlers.
Definition: EventHandler.h:571
virtual CrossSection integratedXSecErr() const
The estimated error in the total integrated cross section of the processes generated in this run...
void addStep(Group::Level, Group::Handler, tStepHdlPtr=tStepHdlPtr(), tHintPtr=tHintPtr())
In the curresnt list of step handlers to go through, add another step handler and/or hint...
LuminosityFunction & lumiFn()
Access to the luminosity function.
Definition: EventHandler.h:437
ThePEG::Ptr< CascadeHandler >::pointer CascHdlPtr
Alias for a reference counted pointer to CascadeHandler .
Definition: Pointers.h:73
Handler
Enumeration for the type of HandlerGroups.
Definition: HandlerGroup.h:433
RCPtr is a reference counted (smart) pointer.
Definition: RCPtr.h:60
cPDPair theIncoming
The pair of incoming particle types.
Definition: EventHandler.h:601
virtual void dofinish()
Finalize this object.
virtual IVector getReferences()
Return a vector of all pointers to Interfaced objects used in this object.
ThePEG::Ptr< DecayHandler >::pointer DecayHdlPtr
Alias for a reference counted pointer to DecayHandler .
Definition: Pointers.h:75
Do not perform consistency checks.
Definition: EventHandler.h:69
tStepPtr newStep(tcStepHdlPtr sh)
Create a new step and make it current.
Definition: EventHandler.h:297
virtual EventPtr generateEvent()
Generate an event.
ThePEG::Ptr< Collision >::transient_pointer tCollPtr
Alias for a transient pointer to Collision .
Definition: Pointers.h:84
HandlerBase is an abstract base class derived from the Interfaced class via the HandlerBaseT class ad...
Definition: HandlerBase.h:151
HandlerGroup< DecayHandler > theDecayGroup
The DecayHandler group.
Definition: EventHandler.h:529
ConsistencyLevel
Enumerate the different levels of consistency checking.
Definition: EventHandler.h:68
Exception is the base class for all exceptions to be used in ThePEG.
Definition: Exception.h:44
HandlerGroup< SubProcessHandler > optSubprocessGroup
Utility object to facilitate default selection of step handlers.
Definition: EventHandler.h:561
virtual void clean()
Throw away the last generated event before generating a new one.
tStepPtr currentStep() const
Get current step.
Definition: EventHandler.h:254
ThePEG::Ptr< Event >::transient_pointer tEventPtr
Alias for a transient pointer to Event .
Definition: Pointers.h:83
HandlerGroup is a templated utility class to manage a group of StepHandlers.
Definition: HandlerGroup.h:321
const GroupVector & groups() const
Access the step handler groups.
Definition: EventHandler.h:452
long theMaxLoop
The maximum number of attempts to select a sub-process allowed per event.
Definition: EventHandler.h:468
virtual ~EventHandler()
Destructor.
This template class allows the compiler to check calculations with physical quantities for dimensiona...
Definition: PhysicalQty.h:81
void throwCurrent()
Throw away the current event/collision.
pair< cPDPtr, cPDPtr > cPDPair
A pair of pointers to const ParticleData objects.
Definition: Containers.h:118
virtual bool empty() const
Returns true if there are no step handlers left to apply to the current event;.
HandlerGroup< HadronizationHandler > theHadronizationGroup
The HadronizationHandler group.
Definition: EventHandler.h:524
PExtrPtr thePartonExtractor
A PartonExtractor object to be used by sub classes which do not provide their own.
Definition: EventHandler.h:504
vector< IBPtr > IVector
A vector of pointers to InterfacedBase objects.
Definition: Containers.h:67
const cPDPair & incoming() const
The pair of incoming particle types.
Definition: EventHandler.h:206
GroupVector theGroups
The step handler groups.
Definition: EventHandler.h:534
ThePEG::Ptr< MultipleInteractionHandler >::pointer MIHdlPtr
Alias for a reference counted pointer to MultipleInteractionHandler .
Definition: Pointers.h:74
StepHdlPtr theCurrentStepHandler
The current StepHandler.
Definition: EventHandler.h:554
HandlerGroup< CascadeHandler > optCascadeGroup
Utility object to facilitate default selection of step handlers.
Definition: EventHandler.h:566
ConsistencyLevel consistencyLevel() const
Determines how often the event handler should check for charge and energy-momentum conservation...
Definition: EventHandler.h:266
virtual void statistics(ostream &) const
Write out accumulated statistics about intergrated cross sections and stuff.
void currentStepHandler(tStepHdlPtr sh)
Set current StepHandler.
Definition: EventHandler.h:338
GroupVector & groups()
Access the step handler groups.
Definition: EventHandler.h:447
tPExtrPtr partonExtractor() const
A PartonExtractor object to be used by sub classes which do not provide their own.
Definition: EventHandler.h:232
virtual void select(tXCombPtr newXComb)
Change the XComb object.
tCutsPtr cuts() const
The kinematical cuts to used by subclasses which do not provide their own.
Definition: EventHandler.h:226
virtual IBPtr clone() const
Make a simple clone of this object.
Check every Step.
Definition: EventHandler.h:71