/usr/include/ThePEG/Handlers/EventHandler.h is in libthepeg-dev 1.8.0-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 | // -*- C++ -*-
//
// EventHandler.h is a part of ThePEG - Toolkit for HEP Event Generation
// Copyright (C) 1999-2011 Leif Lonnblad
//
// ThePEG is licenced under version 2 of the GPL, see COPYING for details.
// Please respect the MCnet academic guidelines, see GUIDELINES for details.
//
#ifndef ThePEG_EventHandler_H
#define ThePEG_EventHandler_H
// This is the declaration of the EventHandler class.
#include "ThePEG/Handlers/HandlerBase.h"
#include "ThePEG/Handlers/HandlerGroup.h"
#include "ThePEG/Handlers/StepHandler.h"
#include "ThePEG/EventRecord/Event.h"
#include "ThePEG/Handlers/LastXCombInfo.h"
#include "ThePEG/Handlers/SubProcessHandler.fh"
#include "ThePEG/Cuts/Cuts.fh"
#include "EventHandler.fh"
namespace ThePEG {
/**
* The EventHandler is the base class used to implement event handlers
* in ThePEG. Objects of this class is assigned to an EventGenerator
* object which supervises a run. This base class is not able to
* generate complete events, although it does have a virtual
* generateEvent(). If the EventGenerator to which an EventGenerator
* is assinged is asked to generate a full event, it will call the
* generateEvent() function which will write an error message and
* abort the run.
*
* Objects of this base class can, however, be used to administer the
* evolution of a partially generated event supplied from the
* outside. To specify this event evolution the EventHandler maintains
* five groups of so-called StepHandlers implemented as
* HandlerGroups. Each group have a main step handler:
* SubProcessHandler, CascadeHandler, MultipleInteractionHandler,
* HadronizationHandler and DecayHandler respectively, whereof the
* first group only uses the post-handler part of the group.
*
* The EventHandler class inherits from the LastXCombInfo class to
* have easy interface to the information in the last selected XComb
* which carries information about the hard sub-process in the event.
*
* If a sub-class implements the generation of sub-processes and thus
* becomes a full event handler it should implement the
* generateEvent() function appropriately. It should also set the flag
* warnIncomplete to false, to avoid warnings when initialized as the main
* EventHandler of an Eventgenerator.
*
* @see \ref EventHandlerInterfaces "The interfaces" defined for EventHandler.
* @see Collision
* @see StepHandler
* @see HandlerGroup
* @see SubProcessHandler
* @see CascadeHandler
* @see MultipleInteractionHandler
* @see HadronizationHandler
* @see DecayHandler
*/
class EventHandler: public HandlerBase, public LastXCombInfo<> {
public:
/** Enumerate the different levels of consistency checking. */
enum ConsistencyLevel {
clNoCheck, /**< Do not perform consistency checks. */
clCollision, /**< Check every Collision. */
clStep, /**< Check every Step. */
clPrintCollision, /**< Check every Collision. Print event if inconsistent.*/
clPrintStep /**< Check every Step. Print event if inconsistent. */
};
/** A vector of <code>HandlerGroup</code>s. */
typedef vector<HandlerGroupBase *> GroupVector;
public:
/** @name Standard constructors and destructors. */
//@{
/**
* Default constructor.
*/
EventHandler(bool warnincomplete = true);
/**
* Copy-constructor.
*/
EventHandler(const EventHandler &);
/**
* Destructor.
*/
virtual ~EventHandler();
//@}
public:
/** @name Main functions, some of which may be overridden by subclasses. */
//@{
/**
* Initialize this event handler and all related objects needed to
* generate events.
*/
virtual void initialize();
/**
* Generate an event. This base class is not capable of generating
* complete events and calling this function will result in an
* exception. Sub-classes which are capable of generating complete
* events from scratch must override this function.
*/
virtual EventPtr generateEvent();
/**
* Generate an Event, where the initial state is supplied
* from the outside.
* @return a pointer to the generated Event.
*/
tEventPtr generateEvent(tEventPtr e);
/**
* Generate an Event, where the initial state is supplied as a
* single step from the outside.
* @return a pointer to the generated Event.
*/
tEventPtr generateEvent(tStepPtr s);
/**
* Continue generating an event if the generation has been stopped
* before finishing.
*/
virtual EventPtr continueEvent();
/**
* Continue the generation of a Collision. Used if the generation
* was previously interrupted.
*/
tCollPtr continueCollision();
/**
* Clear all step handlers, making the handler ready for a new event.
*/
void clearEvent();
/**
* Change the XComb object
*/
virtual void select(tXCombPtr newXComb);
/**
* Returns true if there are no step handlers left to apply to the
* current event;
*/
virtual bool empty() const;
/**
* Write out accumulated statistics about intergrated cross sections
* and stuff.
*/
virtual void statistics(ostream &) const;
/**
* Histogram scale. A histogram bin which has been filled with the
* weights associated with the Event objects should be scaled by
* this factor to give the correct cross section. This version of
* the function will produce an error message. It is up to a
* sub-class able to generate full events to return the correct
* value.
*/
virtual CrossSection histogramScale() const;
/**
* The total integrated cross section of the processes generated in
* this run. This version of the function will produce an error
* message. It is up to a sub-class able to generate full events to
* return the correct value.
* @return 0 if no integrated cross section could be estimated.
*/
virtual CrossSection integratedXSec() const;
/**
* The estimated error in the total integrated cross section of the
* processes generated in this run. This version of the function
* will produce an error message. It is up to a sub-class able to
* generate full events to return the correct value.
* @return 0 if no integrated cross section error could be estimated.
*/
virtual CrossSection integratedXSecErr() const;
//@}
/** @name Simple access functions. */
//@{
/**
* Return the maximum number attemts allowed to select a sub-process
* for each event.
*/
long maxLoop() const { return theMaxLoop; }
/**
* The pair of incoming particle types. These are null if not set by
* a subclass.
*/
const cPDPair & incoming() const { return theIncoming; }
/**
* Access the luminosity function.
*/
const LuminosityFunction & lumiFn() const { return *theLumiFn; }
/**
* Access the luminosity function.
*/
tcLumiFnPtr lumiFnPtr() const{ return theLumiFn; }
/**
* Access to the luminosity function.
*/
tLumiFnPtr lumiFnPtr(){ return theLumiFn; }
/**
* The kinematical cuts to used by subclasses which do not provide their own.
*/
tCutsPtr cuts() const { return theCuts; }
/**
* A PartonExtractor object to be used by sub classes which do not
* provide their own.
*/
tPExtrPtr partonExtractor() const { return thePartonExtractor; }
/**
* Return a pointer (possibly null) to the assigned main
* CascadeHandler to be used as CKKW-reweighter.
*/
tCascHdlPtr CKKWHandler() const;
/**
* Gget current event.
*/
tEventPtr currentEvent() const { return theCurrentEvent; }
/**
* Get current collision.
*/
tCollPtr currentCollision() const { return theCurrentCollision; }
/**
* Get current step.
*/
tStepPtr currentStep() const { return theCurrentStep; }
/**
* The level of statistics. Controlls the amount of statistics
* written out after each run to the <code>EventGenerator</code>s
* <code>.out</code> file.
*/
int statLevel() const { return theStatLevel; }
/**
* Determines how often the event handler should check for charge
* and energy-momentum conservation.
*/
ConsistencyLevel consistencyLevel() const { return theConsistencyLevel; }
/**
* The maximum fraction of the total invariant mass of a collision
* that any of the components of the summed momentum is allowed to
* change during the generation.
*/
double consistencyEpsilon() const { return theConsistencyEpsilon; }
//@}
/** @name Internal functions used by main functions and possibly
from the outside. */
//@{
/**
* Perform a given step using a handler and a hint.
*/
void performStep(tStepHdlPtr handler, tHintPtr hint);
/**
* In the curresnt list of step handlers to go through, add another
* step handler and/or hint.
*/
void addStep(Group::Level, Group::Handler,
tStepHdlPtr = tStepHdlPtr(), tHintPtr = tHintPtr());
/**
* Create a new step and make it current. A StepHandler should be
* supplied which will be set as the handler for the created
* Step.
*/
tStepPtr newStep(tcStepHdlPtr sh) {
currentStep(currentCollision()->newStep(sh));
return currentStep();
}
/**
* Remove the last step.
*/
void popStep() {
currentCollision()->popStep();
currentStep(currentCollision()->finalStep());
}
/**
* Initialize the groups of step handlers.
*/
virtual void initGroups();
/**
* Set current event.
*/
void currentEvent(tEventPtr e) { theCurrentEvent = e; }
/**
* Set current collision.
*/
void currentCollision(tCollPtr c) { theCurrentCollision = c; }
/**
* Set current step.
*/
void currentStep(tStepPtr s) { theCurrentStep = s; }
/**
* Get current StepHandler.
*/
tStepHdlPtr currentStepHandler() const { return theCurrentStepHandler; }
/**
* Set current StepHandler.
*/
void currentStepHandler(tStepHdlPtr sh) { theCurrentStepHandler = sh; }
/**
* Throw away the current event/collision.
*/
void throwCurrent();
/**
* Throw away the last generated event before generating a new one.
*/
virtual void clean();
/**
* Check that the charge and energy-momentum in the last step of the
* current collision is consistent with the incoming particles. If
* not, a warning will be generated.
*/
virtual void checkConsistency() const;
//@}
public:
/** @name Functions used by the persistent I/O system. */
//@{
/**
* Function used to write out object persistently.
* @param os the persistent output stream written to.
*/
void persistentOutput(PersistentOStream & os) const;
/**
* Function used to read in object persistently.
* @param is the persistent input stream read from.
* @param version the version number of the object when written.
*/
void persistentInput(PersistentIStream & is, int version);
//@}
/**
* Standard Init function used to initialize the interface.
*/
static void Init();
protected:
/** @name Clone Methods. */
//@{
/**
* Make a simple clone of this object.
* @return a pointer to the new object.
*/
virtual IBPtr clone() const;
/** Make a clone of this object, possibly modifying the cloned object
* to make it sane.
* @return a pointer to the new object.
*/
virtual IBPtr fullclone() const;
//@}
/** @name Standard Interfaced functions. */
//@{
/**
* Finalize this object. Called in the run phase just after a
* run has ended. Used eg. to write out statistics.
*/
virtual void dofinish() {
currentEvent(tEventPtr());
currentCollision(tCollPtr());
currentStep(tStepPtr());
HandlerBase::dofinish();
}
/**
* Rebind pointer to other Interfaced objects. Called in the setup phase
* after all objects used in an EventGenerator has been cloned so that
* the pointers will refer to the cloned objects afterwards.
* @param trans a TranslationMap relating the original objects to
* their respective clones.
* @throws RebindException if no cloned object was found for a given
* pointer.
*/
virtual void rebind(const TranslationMap & trans);
/**
* Return a vector of all pointers to Interfaced objects used in this
* object.
* @return a vector of pointers.
*/
virtual IVector getReferences();
//@}
protected:
/**
* Access to the luminosity function.
*/
LuminosityFunction & lumiFn() { return *theLumiFn; }
/**
* Setup the step handler groups.
*/
void setupGroups();
/**
* Access the step handler groups
*/
GroupVector & groups() { return theGroups; }
/**
* Access the step handler groups
*/
const GroupVector & groups() const { return theGroups; }
protected:
/**
* Set the luminosity function
*/
void lumiFn(LumiFnPtr);
private:
/**
* The maximum number of attempts to select a sub-process allowed
* per event.
*/
long theMaxLoop;
/**
* Controlls the amount of statistics written out after each run to
* the EventGenerators .out file.
*/
int theStatLevel;
/**
* Determines how often the event handler should check for charge
* and energy-momentum conservation.
*/
ConsistencyLevel theConsistencyLevel;
/**
* The maximum fraction of the total invariant mass of a collision
* that any of the components of the summed momentum is allowed to
* change during the generation.
*/
double theConsistencyEpsilon;
/**
* Pointer to a luminosity function tobe used by subclasses.
*/
LumiFnPtr theLumiFn;
/**
* The kinematical cuts to used by subclasses which do not provide
* their own.
*/
CutsPtr theCuts;
/**
* A PartonExtractor object to be used by sub classes which do not
* provide their own.
*/
PExtrPtr thePartonExtractor;
/**
* The SubProcessHandler group.
*/
HandlerGroup<SubProcessHandler> theSubprocessGroup;
/**
* The CascadeHandler group.
*/
HandlerGroup<CascadeHandler> theCascadeGroup;
/**
* The MultipleInteractionHandler group.
*/
HandlerGroup<MultipleInteractionHandler> theMultiGroup;
/**
* The HadronizationHandler group.
*/
HandlerGroup<HadronizationHandler> theHadronizationGroup;
/**
* The DecayHandler group.
*/
HandlerGroup<DecayHandler> theDecayGroup;
/**
* The step handler groups.
*/
GroupVector theGroups;
/**
* The current Event.
*/
EventPtr theCurrentEvent;
/**
* The current Collision.
*/
CollPtr theCurrentCollision;
/**
* The current Step.
*/
StepPtr theCurrentStep;
/**
* The current StepHandler.
*/
StepHdlPtr theCurrentStepHandler;
protected:
/**
* Utility object to facilitate default selection of step handlers.
*/
HandlerGroup<SubProcessHandler> optSubprocessGroup;
/**
* Utility object to facilitate default selection of step handlers.
*/
HandlerGroup<CascadeHandler> optCascadeGroup;
/**
* Utility object to facilitate default selection of step handlers.
*/
HandlerGroup<MultipleInteractionHandler> optMultiGroup;
/**
* Utility object to facilitate default selection of step handlers.
*/
HandlerGroup<HadronizationHandler> optHadronizationGroup;
/**
* Utility object to facilitate default selection of step handlers.
*/
HandlerGroup<DecayHandler> optDecayGroup;
protected:
/**
* Utility object to facilitate default selection of step handlers.
*/
GroupVector optGroups;
protected:
/**
* Emit warning that this EventHandler is incomplete.
*/
bool warnIncomplete;
/**
* The pair of incoming particle types. Should be set by a subclass
* which implements a complete EventHandler.
*/
cPDPair theIncoming;
protected:
/** @cond EXCEPTIONCLASSES */
/**
* Exception class used by EventHandler when a StepHandler of the
* wrong class was added.
*/
class EventHandlerStepError: public Exception {};
/**
* Exception class used by EventHandler when not able to produce a
* correct histogram scale.
*/
class EventHandlerHistError: public Exception {};
/**
* Exception class used by EventHandler if asked to generate a
* complete event.
*/
class EventHandlerIncompleteError: public Exception {};
/** Exception class used if too many attempts to generate an event
* failed. */
struct EventLoopException: public Exception {
/** Standard constructor. */
EventLoopException(const EventHandler &);
};
/**
* Exception class used if the assignment of a LuminosityFunction
* failed
*/
struct LumiFuncError: public Exception {};
/**
* Exception class used if inconsistent charge or energy-momentum was found.
*/
struct ConsistencyException: public Exception {};
/** @endcond */
private:
ThePEG_DECLARE_PREPOST_GROUP(SubProcessHandler,Post);
ThePEG_DECLARE_GROUPINTERFACE(CascadeHandler,CascHdlPtr);
ThePEG_DECLARE_GROUPINTERFACE(MultipleInteractionHandler,MIHdlPtr);
ThePEG_DECLARE_GROUPINTERFACE(HadronizationHandler,HadrHdlPtr);
ThePEG_DECLARE_GROUPINTERFACE(DecayHandler,DecayHdlPtr);
ThePEG_DECLARE_CLASS_DESCRIPTION(EventHandler);
/**
* Private and non-existent assignment operator.
*/
EventHandler & operator=(const EventHandler &);
};
/** @cond TRAITSPECIALIZATIONS */
ThePEG_DECLARE_CLASS_TRAITS(EventHandler,HandlerBase);
/** @endcond */
}
#endif /* ThePEG_EventHandler_H */
|