1 | // UserHooks.h is a part of the PYTHIA event generator. |
---|
2 | // Copyright (C) 2012 Torbjorn Sjostrand. |
---|
3 | // PYTHIA is licenced under the GNU GPL version 2, see COPYING for details. |
---|
4 | // Please respect the MCnet Guidelines, see GUIDELINES for details. |
---|
5 | |
---|
6 | // Header file to allow user access to program at different stages. |
---|
7 | // UserHooks: almost empty base class, with user to write the rela code. |
---|
8 | // MyUserHooks: derived class, only intended as an example. |
---|
9 | |
---|
10 | #ifndef Pythia8_UserHooks_H |
---|
11 | #define Pythia8_UserHooks_H |
---|
12 | |
---|
13 | #include "Event.h" |
---|
14 | #include "PartonSystems.h" |
---|
15 | #include "PythiaStdlib.h" |
---|
16 | #include "SigmaProcess.h" |
---|
17 | |
---|
18 | namespace Pythia8 { |
---|
19 | |
---|
20 | //========================================================================== |
---|
21 | |
---|
22 | // Forward reference to the PhaseSpace class. |
---|
23 | class PhaseSpace; |
---|
24 | |
---|
25 | //========================================================================== |
---|
26 | |
---|
27 | // UserHooks is base class for user access to program execution. |
---|
28 | |
---|
29 | class UserHooks { |
---|
30 | |
---|
31 | public: |
---|
32 | |
---|
33 | // Destructor. |
---|
34 | virtual ~UserHooks() {selBias = 1.;} |
---|
35 | |
---|
36 | // Initialize pointers and workEvent. Note: not virtual. |
---|
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);} |
---|
49 | |
---|
50 | // Initialisation after beams have been set by Pythia::init() |
---|
51 | virtual bool initAfterBeams() { return true; } |
---|
52 | |
---|
53 | // Possibility to modify cross section of process. |
---|
54 | virtual bool canModifySigma() {return false;} |
---|
55 | |
---|
56 | // Multiplicative factor modifying the cross section of a hard process. |
---|
57 | virtual double multiplySigmaBy(const SigmaProcess* sigmaProcessPtr, |
---|
58 | const PhaseSpace* phaseSpacePtr, bool inEvent); |
---|
59 | |
---|
60 | // Possibility to bias selection of events, compensated by a weight. |
---|
61 | virtual bool canBiasSelection() {return false;} |
---|
62 | |
---|
63 | // Multiplicative factor in the phase space selection of a hard process. |
---|
64 | virtual double biasSelectionBy(const SigmaProcess* sigmaProcessPtr, |
---|
65 | const PhaseSpace* phaseSpacePtr, bool inEvent); |
---|
66 | |
---|
67 | // Event weight to compensate for selection weight above. |
---|
68 | virtual double biasedSelectionWeight() {return 1./selBias;} |
---|
69 | |
---|
70 | // Possibility to veto event after process-level selection. |
---|
71 | virtual bool canVetoProcessLevel() {return false;} |
---|
72 | |
---|
73 | // Decide whether to veto current process or not, based on process record. |
---|
74 | // Usage: doVetoProcessLevel( process). |
---|
75 | virtual bool doVetoProcessLevel(Event& ) {return false;} |
---|
76 | |
---|
77 | // Possibility to veto resonance decay chain. |
---|
78 | virtual bool canVetoResonanceDecays() {return false;} |
---|
79 | |
---|
80 | // Decide whether to veto current resonance decay chain or not, based on |
---|
81 | // process record. Usage: doVetoProcessLevel( process). |
---|
82 | virtual bool doVetoResonanceDecays(Event& ) {return false;} |
---|
83 | |
---|
84 | // Possibility to veto MPI + ISR + FSR evolution and kill event, |
---|
85 | // making decision at a fixed pT scale. Useful for MLM-style matching. |
---|
86 | virtual bool canVetoPT() {return false;} |
---|
87 | |
---|
88 | // Transverse-momentum scale for veto test. |
---|
89 | virtual double scaleVetoPT() {return 0.;} |
---|
90 | |
---|
91 | // Decide whether to veto current event or not, based on event record. |
---|
92 | // Usage: doVetoPT( iPos, event), where iPos = 0: no emissions so far; |
---|
93 | // iPos = 1/2/3 joint evolution, latest step was MPI/ISR/FSR; |
---|
94 | // iPos = 4: FSR only afterwards; iPos = 5: FSR in resonance decay. |
---|
95 | virtual bool doVetoPT( int , const Event& ) {return false;} |
---|
96 | |
---|
97 | // Possibility to veto MPI + ISR + FSR evolution and kill event, |
---|
98 | // making decision after fixed number of ISR or FSR steps. |
---|
99 | virtual bool canVetoStep() {return false;} |
---|
100 | |
---|
101 | // Up to how many ISR + FSR steps of hardest interaction should be checked. |
---|
102 | virtual int numberVetoStep() {return 1;} |
---|
103 | |
---|
104 | // Decide whether to veto current event or not, based on event record. |
---|
105 | // Usage: doVetoStep( iPos, nISR, nFSR, event), where iPos as above, |
---|
106 | // nISR and nFSR number of emissions so far for hard interaction only. |
---|
107 | virtual bool doVetoStep( int , int , int , const Event& ) {return false;} |
---|
108 | |
---|
109 | // Possibility to veto MPI + ISR + FSR evolution and kill event, |
---|
110 | // making decision after fixed number of MPI steps. |
---|
111 | virtual bool canVetoMPIStep() {return false;} |
---|
112 | |
---|
113 | // Up to how many MPI steps should be checked. |
---|
114 | virtual int numberVetoMPIStep() {return 1;} |
---|
115 | |
---|
116 | // Decide whether to veto current event or not, based on event record. |
---|
117 | // Usage: doVetoMPIStep( nMPI, event), where nMPI is number of MPI's so far. |
---|
118 | virtual bool doVetoMPIStep( int , const Event& ) {return false;} |
---|
119 | |
---|
120 | // Possibility to veto event after ISR + FSR + MPI in parton level, |
---|
121 | // but before beam remnants and resonance decays. |
---|
122 | virtual bool canVetoPartonLevelEarly() {return false;} |
---|
123 | |
---|
124 | // Decide whether to veto current partons or not, based on event record. |
---|
125 | // Usage: doVetoPartonLevelEarly( event). |
---|
126 | virtual bool doVetoPartonLevelEarly( const Event& ) {return false;} |
---|
127 | |
---|
128 | // Possibility to veto event after parton-level selection. |
---|
129 | virtual bool canVetoPartonLevel() {return false;} |
---|
130 | |
---|
131 | // Decide whether to veto current partons or not, based on event record. |
---|
132 | // Usage: doVetoPartonLevel( event). |
---|
133 | virtual bool doVetoPartonLevel( const Event& ) {return false;} |
---|
134 | |
---|
135 | // Possibility to set initial scale in TimeShower for resonance decay. |
---|
136 | virtual bool canSetResonanceScale() {return false;} |
---|
137 | |
---|
138 | // Initial scale for TimeShower evolution. |
---|
139 | // Usage: scaleResonance( iRes, event), where iRes is location |
---|
140 | // of decaying resonance in the event record. |
---|
141 | virtual double scaleResonance( int, const Event& ) {return 0.;} |
---|
142 | |
---|
143 | // Possibility to veto an emission in the ISR machinery. |
---|
144 | virtual bool canVetoISREmission() {return false;} |
---|
145 | |
---|
146 | // Decide whether to veto current emission or not, based on event record. |
---|
147 | // Usage: doVetoISREmission( sizeOld, event, iSys) where sizeOld is size |
---|
148 | // of event record before current emission-to-be-scrutinized was added, |
---|
149 | // and iSys is the system of the radiation (according to PartonSystems). |
---|
150 | virtual bool doVetoISREmission( int, const Event&, int ) {return false;} |
---|
151 | |
---|
152 | // Possibility to veto an emission in the FSR machinery. |
---|
153 | virtual bool canVetoFSREmission() {return false;} |
---|
154 | |
---|
155 | // Decide whether to veto current emission or not, based on event record. |
---|
156 | // Usage: doVetoFSREmission( sizeOld, event, iSys, inResonance) where |
---|
157 | // sizeOld is size of event record before current emission-to-be-scrutinized |
---|
158 | // was added, iSys is the system of the radiation (according to |
---|
159 | // PartonSystems), and inResonance is true if the emission takes place in a |
---|
160 | // resonance decay. |
---|
161 | virtual bool doVetoFSREmission( int, const Event&, int, bool = false ) |
---|
162 | {return false;} |
---|
163 | |
---|
164 | // Possibility to veto an MPI. |
---|
165 | virtual bool canVetoMPIEmission() { return false; } |
---|
166 | |
---|
167 | // Decide whether to veto an MPI based on event record. |
---|
168 | // Usage: doVetoMPIEmission( sizeOld, event) where sizeOld |
---|
169 | // is size of event record before the current MPI. |
---|
170 | virtual bool doVetoMPIEmission(int, const Event &) { return false; } |
---|
171 | |
---|
172 | protected: |
---|
173 | |
---|
174 | // Constructor. |
---|
175 | UserHooks() : infoPtr(0), settingsPtr(0), particleDataPtr(0), rndmPtr(0), |
---|
176 | beamAPtr(0), beamBPtr(0), beamPomAPtr(0), beamPomBPtr(0), coupSMPtr(0), |
---|
177 | partonSystemsPtr(0), sigmaTotPtr(0) {} |
---|
178 | |
---|
179 | // Pointer to various information on the generation. |
---|
180 | Info* infoPtr; |
---|
181 | |
---|
182 | // Pointer to the settings database. |
---|
183 | Settings* settingsPtr; |
---|
184 | |
---|
185 | // Pointer to the particle data table. |
---|
186 | ParticleData* particleDataPtr; |
---|
187 | |
---|
188 | // Pointer to the random number generator. |
---|
189 | Rndm* rndmPtr; |
---|
190 | |
---|
191 | // Pointers to the two incoming beams and to Pomeron beam-inside-beam. |
---|
192 | BeamParticle* beamAPtr; |
---|
193 | BeamParticle* beamBPtr; |
---|
194 | BeamParticle* beamPomAPtr; |
---|
195 | BeamParticle* beamPomBPtr; |
---|
196 | |
---|
197 | // Pointers to Standard Model couplings. |
---|
198 | CoupSM* coupSMPtr; |
---|
199 | |
---|
200 | // Pointer to information on subcollision parton locations. |
---|
201 | PartonSystems* partonSystemsPtr; |
---|
202 | |
---|
203 | // Pointer to the total/elastic/diffractive cross sections. |
---|
204 | SigmaTotal* sigmaTotPtr; |
---|
205 | |
---|
206 | // omitResonanceDecays omits resonance decay chains from process record. |
---|
207 | void omitResonanceDecays(const Event& process, bool finalOnly = false); |
---|
208 | |
---|
209 | // subEvent extracts currently resolved partons in the hard process. |
---|
210 | void subEvent(const Event& event, bool isHardest = true); |
---|
211 | |
---|
212 | // Have one event object around as work area. |
---|
213 | Event workEvent; |
---|
214 | |
---|
215 | // User-imposed selection bias. |
---|
216 | double selBias; |
---|
217 | |
---|
218 | }; |
---|
219 | |
---|
220 | //========================================================================== |
---|
221 | |
---|
222 | // SuppressSmallPT is a derived class for user access to program execution. |
---|
223 | // It is a simple example, illustrating how to suppress the cross section |
---|
224 | // of 2 -> 2 processes by a factor pT^4 / (pT0^2 + pT^2)^2, with pT0 input, |
---|
225 | // and also modify alpha_strong scale similarly. |
---|
226 | |
---|
227 | class SuppressSmallPT : public UserHooks { |
---|
228 | |
---|
229 | public: |
---|
230 | |
---|
231 | // Constructor. |
---|
232 | SuppressSmallPT( double pT0timesMPIIn = 1., int numberAlphaSIn = 0, |
---|
233 | bool useSameAlphaSasMPIIn = true) : pT20(0.) {isInit = false; |
---|
234 | pT0timesMPI = pT0timesMPIIn; numberAlphaS = numberAlphaSIn; |
---|
235 | useSameAlphaSasMPI = useSameAlphaSasMPIIn;} |
---|
236 | |
---|
237 | // Possibility to modify cross section of process. |
---|
238 | virtual bool canModifySigma() {return true;} |
---|
239 | |
---|
240 | // Multiplicative factor modifying the cross section of a hard process. |
---|
241 | // Usage: inEvent is true for event generation, false for initialization. |
---|
242 | virtual double multiplySigmaBy(const SigmaProcess* sigmaProcessPtr, |
---|
243 | const PhaseSpace* phaseSpacePtr, bool ); |
---|
244 | |
---|
245 | private: |
---|
246 | |
---|
247 | // Save input properties and the squared pT0 scale. |
---|
248 | bool isInit, useSameAlphaSasMPI; |
---|
249 | int numberAlphaS; |
---|
250 | double pT0timesMPI, pT20; |
---|
251 | |
---|
252 | // Alpha_strong calculation. |
---|
253 | AlphaStrong alphaS; |
---|
254 | |
---|
255 | }; |
---|
256 | |
---|
257 | //========================================================================== |
---|
258 | |
---|
259 | } // end namespace Pythia8 |
---|
260 | |
---|
261 | #endif // Pythia8_UserHooks_H |
---|