10 #ifndef Pythia8_UserHooks_H
11 #define Pythia8_UserHooks_H
13 #include "Pythia8/Event.h"
14 #include "Pythia8/PartonSystems.h"
15 #include "Pythia8/PythiaStdlib.h"
16 #include "Pythia8/SigmaProcess.h"
34 virtual ~UserHooks() {}
37 void initPtr( Info* infoPtrIn, Settings* settingsPtrIn,
38 ParticleData* particleDataPtrIn, Rndm* rndmPtrIn,
39 BeamParticle* beamAPtrIn, BeamParticle* beamBPtrIn,
40 BeamParticle* beamPomAPtrIn, BeamParticle* beamPomBPtrIn,
41 CoupSM* coupSMPtrIn, PartonSystems* partonSystemsPtrIn,
42 SigmaTotal* sigmaTotPtrIn) { infoPtr = infoPtrIn;
43 settingsPtr = settingsPtrIn; particleDataPtr = particleDataPtrIn;
44 rndmPtr = rndmPtrIn; beamAPtr = beamAPtrIn; beamBPtr = beamBPtrIn;
45 beamPomAPtr = beamPomAPtrIn; beamPomBPtr = beamPomBPtrIn;
46 coupSMPtr = coupSMPtrIn; partonSystemsPtr = partonSystemsPtrIn;
47 sigmaTotPtr = sigmaTotPtrIn;
48 workEvent.init(
"(work event)", particleDataPtr);}
51 virtual bool initAfterBeams() {
return true; }
54 virtual bool canModifySigma() {
return false;}
57 virtual double multiplySigmaBy(
const SigmaProcess* sigmaProcessPtr,
58 const PhaseSpace* phaseSpacePtr,
bool inEvent);
61 virtual bool canBiasSelection() {
return false;}
64 virtual double biasSelectionBy(
const SigmaProcess* sigmaProcessPtr,
65 const PhaseSpace* phaseSpacePtr,
bool inEvent);
68 virtual double biasedSelectionWeight() {
return 1./selBias;}
71 virtual bool canVetoProcessLevel() {
return false;}
75 virtual bool doVetoProcessLevel(
Event& ) {
return false;}
78 virtual bool canVetoResonanceDecays() {
return false;}
82 virtual bool doVetoResonanceDecays(
Event& ) {
return false;}
86 virtual bool canVetoPT() {
return false;}
89 virtual double scaleVetoPT() {
return 0.;}
95 virtual bool doVetoPT(
int ,
const Event& ) {
return false;}
99 virtual bool canVetoStep() {
return false;}
102 virtual int numberVetoStep() {
return 1;}
107 virtual bool doVetoStep(
int ,
int ,
int ,
const Event& ) {
return false;}
111 virtual bool canVetoMPIStep() {
return false;}
114 virtual int numberVetoMPIStep() {
return 1;}
118 virtual bool doVetoMPIStep(
int ,
const Event& ) {
return false;}
122 virtual bool canVetoPartonLevelEarly() {
return false;}
126 virtual bool doVetoPartonLevelEarly(
const Event& ) {
return false;}
131 virtual bool retryPartonLevel() {
return false;}
134 virtual bool canVetoPartonLevel() {
return false;}
138 virtual bool doVetoPartonLevel(
const Event& ) {
return false;}
141 virtual bool canSetResonanceScale() {
return false;}
146 virtual double scaleResonance(
int,
const Event& ) {
return 0.;}
149 virtual bool canVetoISREmission() {
return false;}
155 virtual bool doVetoISREmission(
int,
const Event&,
int ) {
return false;}
158 virtual bool canVetoFSREmission() {
return false;}
166 virtual bool doVetoFSREmission(
int,
const Event&,
int,
bool =
false )
170 virtual bool canVetoMPIEmission() {
return false; }
175 virtual bool doVetoMPIEmission(
int,
const Event &) {
return false; }
178 virtual bool canReconnectResonanceSystems() {
return false; }
185 virtual bool doReconnectResonanceSystems(
int,
Event &) {
return true;}
188 virtual bool canEnhanceEmission() {
return false;}
189 virtual double enhanceFactor(
string ) {
return 1.;}
190 virtual double vetoProbability(
string ) {
return 0.;}
191 void setEnhancedEventWeight(
double wt) { enhancedEventWeight = wt;}
192 double getEnhancedEventWeight() {
return enhancedEventWeight;}
196 virtual bool canEnhanceTrial() {
return false;}
197 void setEnhancedTrial(
double pTIn,
double wtIn) { pTEnhanced = pTIn;
199 double getEnhancedTrialPT() {
return pTEnhanced;}
200 double getEnhancedTrialWeight() {
return wtEnhanced;}
203 virtual bool canChangeFragPar() {
return false;}
207 virtual bool doChangeFragPar( StringFlav*, StringZ*, StringPT*,
int,
208 double, vector<int>) {
return false;}
211 virtual bool doVetoFragmentation( Particle) {
return false;}
214 virtual bool canSetImpactParameter()
const {
return false; }
217 virtual double doSetImpactParameter() {
return 0.0; }
222 UserHooks() : infoPtr(0), settingsPtr(0), particleDataPtr(0), rndmPtr(0),
223 beamAPtr(0), beamBPtr(0), beamPomAPtr(0), beamPomBPtr(0), coupSMPtr(0),
224 partonSystemsPtr(0), sigmaTotPtr(0), selBias(1.) {}
230 Settings* settingsPtr;
233 ParticleData* particleDataPtr;
239 BeamParticle* beamAPtr;
240 BeamParticle* beamBPtr;
241 BeamParticle* beamPomAPtr;
242 BeamParticle* beamPomBPtr;
248 PartonSystems* partonSystemsPtr;
251 SigmaTotal* sigmaTotPtr;
254 void omitResonanceDecays(
const Event& process,
bool finalOnly =
false);
257 void subEvent(
const Event& event,
bool isHardest =
true);
266 double enhancedEventWeight, pTEnhanced, wtEnhanced;
277 class SuppressSmallPT :
public UserHooks {
282 SuppressSmallPT(
double pT0timesMPIIn = 1.,
int numberAlphaSIn = 0,
283 bool useSameAlphaSasMPIIn =
true) : pT20(0.) {isInit =
false;
284 pT0timesMPI = pT0timesMPIIn; numberAlphaS = numberAlphaSIn;
285 useSameAlphaSasMPI = useSameAlphaSasMPIIn;}
288 virtual bool canModifySigma() {
return true;}
292 virtual double multiplySigmaBy(
const SigmaProcess* sigmaProcessPtr,
293 const PhaseSpace* phaseSpacePtr,
bool );
298 bool isInit, useSameAlphaSasMPI;
300 double pT0timesMPI, pT20;
327 virtual bool initAfterBeams() {
328 int nCanSetResonanceScale = 0;
329 int nCanChangeFragPar = 0;
330 int nCanSetImpactParameter = 0;
331 for (
int i = 0, N = hooks.size(); i < N; ++i ) {
332 hooks[i]->initPtr(infoPtr, settingsPtr, particleDataPtr, rndmPtr,
333 beamAPtr, beamBPtr, beamPomAPtr, beamPomBPtr,
334 coupSMPtr, partonSystemsPtr, sigmaTotPtr);
335 if ( !hooks[i]->initAfterBeams() )
return false;
336 if (hooks[i]->canSetResonanceScale()) ++nCanSetResonanceScale;
337 if (hooks[i]->canChangeFragPar()) ++nCanChangeFragPar;
338 if (hooks[i]->canSetImpactParameter()) ++nCanSetImpactParameter;
340 if (nCanSetResonanceScale > 1) {
341 infoPtr->errorMsg(
"Error in UserHooksVector::initAfterBeams "
342 "multiple UserHooks with canSetResonanceScale() not allowed");
345 if (nCanChangeFragPar > 1) {
346 infoPtr->errorMsg(
"Error in UserHooksVector::initAfterBeams "
347 "multiple UserHooks with canChangeFragPar() not allowed");
350 if (nCanSetImpactParameter > 1) {
351 infoPtr->errorMsg(
"Error in UserHooksVector::initAfterBeams "
352 "multiple UserHooks with canSetImpactParameter() not allowed");
359 virtual bool canModifySigma() {
360 for (
int i = 0, N = hooks.size(); i < N; ++i )
361 if ( hooks[i]->canModifySigma() )
return true;
366 virtual double multiplySigmaBy(
const SigmaProcess* sigmaProcessPtr,
367 const PhaseSpace* phaseSpacePtr,
bool inEvent) {
369 for (
int i = 0, N = hooks.size(); i < N; ++i )
370 if ( hooks[i]->canModifySigma() )
371 f *= hooks[i]->multiplySigmaBy(sigmaProcessPtr, phaseSpacePtr,inEvent);
376 virtual bool canBiasSelection() {
377 for (
int i = 0, N = hooks.size(); i < N; ++i )
378 if ( hooks[i]->canBiasSelection() )
return true;
383 virtual double biasSelectionBy(
const SigmaProcess* sigmaProcessPtr,
384 const PhaseSpace* phaseSpacePtr,
bool inEvent) {
386 for (
int i = 0, N = hooks.size(); i < N; ++i )
387 if ( hooks[i]->canBiasSelection() )
388 f *= hooks[i]->biasSelectionBy(sigmaProcessPtr, phaseSpacePtr,
394 virtual double biasedSelectionWeight() {
396 for (
int i = 0, N = hooks.size(); i < N; ++i )
397 if ( hooks[i]->canBiasSelection() )
398 f *= hooks[i]->biasedSelectionWeight();
403 virtual bool canVetoProcessLevel() {
404 for (
int i = 0, N = hooks.size(); i < N; ++i )
405 if ( hooks[i]->canVetoProcessLevel() )
return true;
411 virtual bool doVetoProcessLevel(
Event& e) {
412 for (
int i = 0, N = hooks.size(); i < N; ++i )
413 if ( hooks[i]->canVetoProcessLevel() &&
414 hooks[i]->doVetoProcessLevel(e) )
return true;
419 virtual bool canVetoResonanceDecays() {
420 for (
int i = 0, N = hooks.size(); i < N; ++i )
421 if ( hooks[i]->canVetoResonanceDecays() )
return true;
427 virtual bool doVetoResonanceDecays(
Event& e) {
428 for (
int i = 0, N = hooks.size(); i < N; ++i )
429 if ( hooks[i]->canVetoResonanceDecays() &&
430 hooks[i]->doVetoResonanceDecays(e) )
return true;
436 virtual bool canVetoPT() {
437 for (
int i = 0, N = hooks.size(); i < N; ++i )
438 if ( hooks[i]->canVetoPT() )
return true;
443 virtual double scaleVetoPT() {
445 for (
int i = 0, N = hooks.size(); i < N; ++i )
446 if ( hooks[i]->canVetoPT() ) s = max(s, hooks[i]->scaleVetoPT());
454 virtual bool doVetoPT(
int iPos,
const Event& e) {
455 for (
int i = 0, N = hooks.size(); i < N; ++i )
456 if ( hooks[i]->canVetoPT() && hooks[i]->doVetoPT(iPos, e) )
return true;
462 virtual bool canVetoStep() {
463 for (
int i = 0, N = hooks.size(); i < N; ++i )
464 if ( hooks[i]->canVetoStep() )
return true;
469 virtual int numberVetoStep() {
471 for (
int i = 0, N = hooks.size(); i < N; ++i )
472 if ( hooks[i]->canVetoStep() ) n = max(n, hooks[i]->numberVetoStep());
479 virtual bool doVetoStep(
int iPos,
int nISR,
int nFSR,
const Event& e) {
480 for (
int i = 0, N = hooks.size(); i < N; ++i )
481 if ( hooks[i]->canVetoStep()
482 && hooks[i]->doVetoStep(iPos, nISR, nFSR, e) )
return true;
488 virtual bool canVetoMPIStep() {
489 for (
int i = 0, N = hooks.size(); i < N; ++i )
490 if ( hooks[i]->canVetoMPIStep() )
return true;
495 virtual int numberVetoMPIStep() {
497 for (
int i = 0, N = hooks.size(); i < N; ++i )
498 if ( hooks[i]->canVetoMPIStep() )
499 n = max(n, hooks[i]->numberVetoMPIStep());
505 virtual bool doVetoMPIStep(
int nMPI,
const Event& e) {
506 for (
int i = 0, N = hooks.size(); i < N; ++i )
507 if ( hooks[i]->canVetoMPIStep() && hooks[i]->doVetoMPIStep(nMPI, e) )
514 virtual bool canVetoPartonLevelEarly() {
515 for (
int i = 0, N = hooks.size(); i < N; ++i )
516 if ( hooks[i]->canVetoPartonLevelEarly() )
return true;
522 virtual bool doVetoPartonLevelEarly(
const Event& e) {
523 for (
int i = 0, N = hooks.size(); i < N; ++i )
524 if ( hooks[i]->canVetoPartonLevelEarly()
525 && hooks[i]->doVetoPartonLevelEarly(e) )
return true;
532 virtual bool retryPartonLevel() {
533 for (
int i = 0, N = hooks.size(); i < N; ++i )
534 if ( hooks[i]->retryPartonLevel() )
return true;
539 virtual bool canVetoPartonLevel() {
540 for (
int i = 0, N = hooks.size(); i < N; ++i )
541 if ( hooks[i]->canVetoPartonLevel() )
return true;
547 virtual bool doVetoPartonLevel(
const Event& e) {
548 for (
int i = 0, N = hooks.size(); i < N; ++i )
549 if ( hooks[i]->canVetoPartonLevel()
550 && hooks[i]->doVetoPartonLevel(e) )
return true;
555 virtual bool canSetResonanceScale() {
556 for (
int i = 0, N = hooks.size(); i < N; ++i )
557 if ( hooks[i]->canSetResonanceScale() )
return true;
564 virtual double scaleResonance(
int iRes,
const Event& e) {
566 for (
int i = 0, N = hooks.size(); i < N; ++i )
567 if ( hooks[i]->canSetResonanceScale() )
568 s = max(s, hooks[i]->scaleResonance(iRes, e));
573 virtual bool canVetoISREmission() {
574 for (
int i = 0, N = hooks.size(); i < N; ++i )
575 if ( hooks[i]->canVetoISREmission() )
return true;
583 virtual bool doVetoISREmission(
int sizeOld,
const Event& e,
int iSys) {
584 for (
int i = 0, N = hooks.size(); i < N; ++i )
585 if ( hooks[i]->canVetoISREmission()
586 && hooks[i]->doVetoISREmission(sizeOld, e, iSys) )
return true;
591 virtual bool canVetoFSREmission() {
592 for (
int i = 0, N = hooks.size(); i < N; ++i )
593 if ( hooks[i]->canVetoFSREmission() )
return true;
603 virtual bool doVetoFSREmission(
int sizeOld,
const Event& e,
604 int iSys,
bool inResonance =
false ) {
605 for (
int i = 0, N = hooks.size(); i < N; ++i )
606 if ( hooks[i]->canVetoFSREmission()
607 && hooks[i]->doVetoFSREmission(sizeOld, e, iSys, inResonance) )
614 virtual bool canVetoMPIEmission() {
615 for (
int i = 0, N = hooks.size(); i < N; ++i )
616 if ( hooks[i]->canVetoMPIEmission() )
return true;
623 virtual bool doVetoMPIEmission(
int sizeOld,
const Event & e) {
624 for (
int i = 0, N = hooks.size(); i < N; ++i )
625 if ( hooks[i]->canVetoMPIEmission()
626 && hooks[i]->doVetoMPIEmission(sizeOld, e) )
632 virtual bool canReconnectResonanceSystems() {
633 for (
int i = 0, N = hooks.size(); i < N; ++i )
634 if ( hooks[i]->canReconnectResonanceSystems() )
return true;
643 virtual bool doReconnectResonanceSystems(
int j,
Event & e) {
644 for (
int i = 0, N = hooks.size(); i < N; ++i )
645 if ( hooks[i]->canReconnectResonanceSystems()
646 && hooks[i]->doReconnectResonanceSystems(j, e) )
return true;
651 virtual bool canEnhanceEmission() {
652 for (
int i = 0, N = hooks.size(); i < N; ++i )
653 if ( hooks[i]->canEnhanceEmission() )
return true;
656 virtual double enhanceFactor(
string s) {
658 for (
int i = 0, N = hooks.size(); i < N; ++i )
659 if ( hooks[i]->canEnhanceEmission() ) f *= hooks[i]->enhanceFactor(s);
662 virtual double vetoProbability(
string s) {
664 for (
int i = 0, N = hooks.size(); i < N; ++i )
665 if ( hooks[i]->canEnhanceEmission() )
666 keep *= 1.0 - hooks[i]->vetoProbability(s);
672 virtual bool canEnhanceTrial() {
673 for (
int i = 0, N = hooks.size(); i < N; ++i )
674 if ( hooks[i]->canEnhanceTrial() )
return true;
679 virtual bool canChangeFragPar() {
680 for (
int i = 0, N = hooks.size(); i < N; ++i )
681 if ( hooks[i]->canChangeFragPar() )
return true;
686 virtual bool canSetImpactParameter()
const {
687 for (
int i = 0, N = hooks.size(); i < N; ++i )
688 if ( hooks[i]->canSetImpactParameter() )
return true;
693 virtual double doSetImpactParameter() {
694 for (
int i = 0, N = hooks.size(); i < N; ++i )
695 if ( hooks[i]->canSetImpactParameter() )
696 return hooks[i]->doSetImpactParameter();
702 vector<UserHooks*> hooks;
710 #endif // Pythia8_UserHooks_H