thepeg is hosted by Hepforge, IPPP Durham
ThePEG  2.2.1
EventHandler.h
1 // -*- C++ -*-
2 //
3 // EventHandler.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_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 
238  tCascHdlPtr cascadeHandler() const;
239 
244  tCascHdlPtr CKKWHandler() const { return cascadeHandler(); }
245 
250 
255 
259  tStepPtr currentStep() const { return theCurrentStep; }
260 
264  bool weighted() const { return weightedEvents; }
265 
271  int statLevel() const { return theStatLevel; }
272 
278 
284  double consistencyEpsilon() const { return theConsistencyEpsilon; }
285 
287 
294  void performStep(tStepHdlPtr handler, tHintPtr hint);
295 
302 
310  return currentStep();
311  }
312 
316  void popStep() {
317  currentCollision()->popStep();
318  currentStep(currentCollision()->finalStep());
319  }
320 
324  virtual void initGroups();
325 
330 
335 
340 
345 
350 
354  void throwCurrent();
355 
359  virtual void clean();
360 
366  virtual void checkConsistency() const;
367 
369 
370 public:
371 
378  void persistentOutput(PersistentOStream & os) const;
379 
385  void persistentInput(PersistentIStream & is, int version);
387 
391  static void Init();
392 
393 protected:
394 
401  virtual IBPtr clone() const;
402 
407  virtual IBPtr fullclone() const;
409 
416  virtual void dofinish() {
417  clean();
419  }
420 
430  virtual void rebind(const TranslationMap & trans);
431 
437  virtual IVector getReferences();
439 
440 
441 protected:
442 
447 
451  void setupGroups();
452 
456  GroupVector & groups() { return theGroups; }
457 
461  const GroupVector & groups() const { return theGroups; }
462 
463 
464 protected:
465 
469  void lumiFn(LumiFnPtr);
470 
471 private:
472 
478 
483 
489 
495 
502 
507 
512  CutsPtr theCuts;
513 
519 
524 
529 
534 
539 
544 
548  GroupVector theGroups;
549 
554 
559 
564 
569 
570 protected:
571 
576 
581 
586 
591 
596 
597 protected:
598 
602  GroupVector optGroups;
603 
604 protected:
605 
610 
616 
617 protected:
618 
624  class EventHandlerStepError: public Exception {};
625 
630  class EventHandlerHistError: public Exception {};
631 
636  class EventHandlerIncompleteError: public Exception {};
637 
640  struct EventLoopException: public Exception {
642  EventLoopException(const EventHandler &);
643  };
644 
649  struct LumiFuncError: public Exception {};
650 
654  struct ConsistencyException: public Exception {};
655 
658 private:
659 
660  ThePEG_DECLARE_PREPOST_GROUP(SubProcessHandler,Post);
661  ThePEG_DECLARE_GROUPINTERFACE(CascadeHandler,CascHdlPtr);
662  ThePEG_DECLARE_GROUPINTERFACE(MultipleInteractionHandler,MIHdlPtr);
663  ThePEG_DECLARE_GROUPINTERFACE(HadronizationHandler,HadrHdlPtr);
664  ThePEG_DECLARE_GROUPINTERFACE(DecayHandler,DecayHdlPtr);
665 
666  ThePEG_DECLARE_CLASS_DESCRIPTION(EventHandler);
667 
671  EventHandler & operator=(const EventHandler &) = delete;
672 
673 };
674 
676 ThePEG_DECLARE_CLASS_TRAITS(EventHandler,HandlerBase);
679 }
680 
681 #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.
HandlerGroup< CascadeHandler > theCascadeGroup
The CascadeHandler group.
Definition: EventHandler.h:528
PersistentIStream is used to read persistent objects from a stream where they were previously written...
The SubProcessHandler class is used to handle a set of MEBase objects together with a PartonExtractor...
void performStep(tStepHdlPtr handler, tHintPtr hint)
Perform a given step using a handler and a hint.
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
tCutsPtr cuts() const
The kinematical cuts to used by subclasses which do not provide their own.
Definition: EventHandler.h:226
EventPtr theCurrentEvent
The current Event.
Definition: EventHandler.h:553
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 bool empty() const
Returns true if there are no step handlers left to apply to the current event;.
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:488
HandlerGroup< MultipleInteractionHandler > theMultiGroup
The MultipleInteractionHandler group.
Definition: EventHandler.h:533
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:501
EventHandler(bool warnincomplete=true)
Default constructor.
virtual void initGroups()
Initialize the groups of step handlers.
virtual void statistics(ostream &) const
Write out accumulated statistics about intergrated cross sections and stuff.
tCollPtr continueCollision()
Continue the generation of a Collision.
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:284
bool weighted() const
Return true if this event handler should produce weightes events.
Definition: EventHandler.h:264
virtual EventPtr continueEvent()
Continue generating an event if the generation has been stopped before finishing. ...
StepPtr theCurrentStep
The current Step.
Definition: EventHandler.h:563
tCollPtr currentCollision() const
Get current collision.
Definition: EventHandler.h:254
TransientConstRCPtr is a simple wrapper around a bare const pointer which can be assigned to and from...
Definition: RCPtr.h:696
TransientRCPtr is a simple wrapper around a bare pointer which can be assigned to and from an RCPtr a...
Definition: RCPtr.h:519
void persistentInput(PersistentIStream &is, int version)
Function used to read in object persistently.
void currentStep(tStepPtr s)
Set current step.
Definition: EventHandler.h:339
void popStep()
Remove the last step.
Definition: EventHandler.h:316
GroupVector optGroups
Utility object to facilitate default selection of step handlers.
Definition: EventHandler.h:602
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
void currentEvent(tEventPtr e)
Set current event.
Definition: EventHandler.h:329
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:506
bool warnIncomplete
Emit warning that this EventHandler is incomplete.
Definition: EventHandler.h:609
tStepHdlPtr currentStepHandler() const
Get current StepHandler.
Definition: EventHandler.h:344
const LuminosityFunction & lumiFn() const
Access the luminosity function.
Definition: EventHandler.h:211
Check every Collision.
Definition: EventHandler.h:70
ConsistencyLevel consistencyLevel() const
Determines how often the event handler should check for charge and energy-momentum conservation...
Definition: EventHandler.h:277
tStepPtr currentStep() const
Get current step.
Definition: EventHandler.h:259
CutsPtr theCuts
The kinematical cuts to used by subclasses which do not provide their own.
Definition: EventHandler.h:512
void currentCollision(tCollPtr c)
Set current collision.
Definition: EventHandler.h:334
tCascHdlPtr cascadeHandler() const
Return a pointer (possibly null) to the assigned main CascadeHandler.
HandlerGroup< HadronizationHandler > optHadronizationGroup
Utility object to facilitate default selection of step handlers.
Definition: EventHandler.h:590
const GroupVector & groups() const
Access the step handler groups.
Definition: EventHandler.h:461
The HadronizationHandler is the base class of all handlers implementing models for hadronization of c...
Level
Enumeration for the type of step handler.
Definition: HandlerGroup.h:442
long maxLoop() const
Return the maximum number attemts allowed to select a sub-process for each event. ...
Definition: EventHandler.h:200
virtual void rebind(const TranslationMap &trans)
Rebind pointer to other Interfaced objects.
virtual void dofinish()
Finalize this object.
Definition: EventHandler.h:416
ConsistencyLevel theConsistencyLevel
Determines how often the event handler should check for charge and energy-momentum conservation...
Definition: EventHandler.h:494
ThePEG::Ptr< StepHandler >::transient_pointer tStepHdlPtr
Alias for a transient pointer to StepHandler .
Definition: Pointers.h:70
CollPtr theCurrentCollision
The current Collision.
Definition: EventHandler.h:558
virtual CrossSection integratedXSec() const
The total integrated cross section of the processes generated in this run.
HandlerGroup< DecayHandler > optDecayGroup
Utility object to facilitate default selection of step handlers.
Definition: EventHandler.h:595
const cPDPair & incoming() const
The pair of incoming particle types.
Definition: EventHandler.h:206
The DecayHandler is the base class of all handlers implementing the administration of decays of unsta...
Definition: DecayHandler.h:31
HandlerGroup< SubProcessHandler > theSubprocessGroup
The SubProcessHandler group.
Definition: EventHandler.h:523
HandlerGroup< MultipleInteractionHandler > optMultiGroup
Utility object to facilitate default selection of step handlers.
Definition: EventHandler.h:585
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...
bool weightedEvents
True if this event handler should produce weightes events.
Definition: EventHandler.h:482
tCascHdlPtr CKKWHandler() const
Return a pointer (possibly null) to the assigned main CascadeHandler to be used as CKKW-reweighter...
Definition: EventHandler.h:244
The MultipleInteractionHandler is the base class of all handlers implementing models for multiple int...
LuminosityFunction & lumiFn()
Access to the luminosity function.
Definition: EventHandler.h:446
tcLumiFnPtr lumiFnPtr() const
Access the luminosity function.
Definition: EventHandler.h:216
Handler
Enumeration for the type of HandlerGroups.
Definition: HandlerGroup.h:433
RCPtr is a reference counted (smart) pointer.
Definition: RCPtr.h:60
void persistentOutput(PersistentOStream &os) const
Function used to write out object persistently.
cPDPair theIncoming
The pair of incoming particle types.
Definition: EventHandler.h:615
virtual void dofinish()
Finalize this object.
virtual IVector getReferences()
Return a vector of all pointers to Interfaced objects used in this object.
virtual CrossSection integratedXSecErr() const
The estimated error in the total integrated cross section of the processes generated in this run...
Do not perform consistency checks.
Definition: EventHandler.h:69
tStepPtr newStep(tcStepHdlPtr sh)
Create a new step and make it current.
Definition: EventHandler.h:308
virtual CrossSection histogramScale() const
Histogram scale.
virtual EventPtr generateEvent()
Generate an event.
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:543
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:575
virtual void clean()
Throw away the last generated event before generating a new one.
virtual IBPtr fullclone() const
Make a clone of this object, possibly modifying the cloned object to make it sane.
HandlerGroup is a templated utility class to manage a group of StepHandlers.
Definition: HandlerGroup.h:321
virtual IBPtr clone() const
Make a simple clone of this object.
long theMaxLoop
The maximum number of attempts to select a sub-process allowed per event.
Definition: EventHandler.h:477
virtual void checkConsistency() const
Check that the charge and energy-momentum in the last step of the current collision is consistent wit...
virtual ~EventHandler()
Destructor.
The CascadeHandler is the base class of all handlers implementing perturbative partonic cascade model...
void throwCurrent()
Throw away the current event/collision.
EventHandler & operator=(const EventHandler &)=delete
Private and non-existent assignment operator.
pair< cPDPtr, cPDPtr > cPDPair
A pair of pointers to const ParticleData objects.
Definition: Containers.h:118
HandlerGroup< HadronizationHandler > theHadronizationGroup
The HadronizationHandler group.
Definition: EventHandler.h:538
PExtrPtr thePartonExtractor
A PartonExtractor object to be used by sub classes which do not provide their own.
Definition: EventHandler.h:518
vector< IBPtr > IVector
A vector of pointers to InterfacedBase objects.
Definition: Containers.h:67
GroupVector theGroups
The step handler groups.
Definition: EventHandler.h:548
StepHdlPtr theCurrentStepHandler
The current StepHandler.
Definition: EventHandler.h:568
int statLevel() const
The level of statistics.
Definition: EventHandler.h:271
HandlerGroup< CascadeHandler > optCascadeGroup
Utility object to facilitate default selection of step handlers.
Definition: EventHandler.h:580
void currentStepHandler(tStepHdlPtr sh)
Set current StepHandler.
Definition: EventHandler.h:349
GroupVector & groups()
Access the step handler groups.
Definition: EventHandler.h:456
virtual void select(tXCombPtr newXComb)
Change the XComb object.
tPExtrPtr partonExtractor() const
A PartonExtractor object to be used by sub classes which do not provide their own.
Definition: EventHandler.h:232
Check every Step.
Definition: EventHandler.h:71
tEventPtr currentEvent() const
Gget current event.
Definition: EventHandler.h:249