StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
UserHooks.h
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  // Possibility to modify cross section of process.
51  virtual bool canModifySigma() {return false;}
52 
53  // Multiplicative factor modifying the cross section of a hard process.
54  virtual double multiplySigmaBy(const SigmaProcess* sigmaProcessPtr,
55  const PhaseSpace* phaseSpacePtr, bool inEvent);
56 
57  // Possibility to bias selection of events, compensated by a weight.
58  virtual bool canBiasSelection() {return false;}
59 
60  // Multiplicative factor in the phase space selection of a hard process.
61  virtual double biasSelectionBy(const SigmaProcess* sigmaProcessPtr,
62  const PhaseSpace* phaseSpacePtr, bool inEvent);
63 
64  // Event weight to compensate for selection weight above.
65  virtual double biasedSelectionWeight() {return 1./selBias;}
66 
67  // Possibility to veto event after process-level selection.
68  virtual bool canVetoProcessLevel() {return false;}
69 
70  // Decide whether to veto current process or not, based on process record.
71  // Usage: doVetoProcessLevel( process).
72  virtual bool doVetoProcessLevel(Event& ) {return false;}
73 
74  // Possibility to veto MPI + ISR + FSR evolution and kill event,
75  // making decision at a fixed pT scale. Useful for MLM-style matching.
76  virtual bool canVetoPT() {return false;}
77 
78  // Transverse-momentum scale for veto test.
79  virtual double scaleVetoPT() {return 0.;}
80 
81  // Decide whether to veto current event or not, based on event record.
82  // Usage: doVetoPT( iPos, event), where iPos = 0: no emissions so far;
83  // iPos = 1/2/3 joint evolution, latest step was MPI/ISR/FSR;
84  // iPos = 4: FSR only afterwards; iPos = 5: FSR in resonance decay.
85  virtual bool doVetoPT( int , const Event& ) {return false;}
86 
87  // Possibility to veto MPI + ISR + FSR evolution and kill event,
88  // making decision after fixed number of ISR or FSR steps.
89  virtual bool canVetoStep() {return false;}
90 
91  // Up to how many ISR + FSR steps of hardest interaction should be checked.
92  virtual int numberVetoStep() {return 1;}
93 
94  // Decide whether to veto current event or not, based on event record.
95  // Usage: doVetoStep( iPos, nISR, nFSR, event), where iPos as above,
96  // nISR and nFSR number of emissions so far for hard interaction only.
97  virtual bool doVetoStep( int , int , int , const Event& ) {return false;}
98 
99  // Possibility to veto MPI + ISR + FSR evolution and kill event,
100  // making decision after fixed number of MPI steps.
101  virtual bool canVetoMPIStep() {return false;}
102 
103  // Up to how many MPI steps should be checked.
104  virtual int numberVetoMPIStep() {return 1;}
105 
106  // Decide whether to veto current event or not, based on event record.
107  // Usage: doVetoMPIStep( nMPI, event), where nMPI is number of MPI's so far.
108  virtual bool doVetoMPIStep( int , const Event& ) {return false;}
109 
110  // Possibility to veto event after parton-level selection.
111  virtual bool canVetoPartonLevel() {return false;}
112 
113  // Decide whether to veto current partons or not, based on event record.
114  // Usage: doVetoPartonLevel( event).
115  virtual bool doVetoPartonLevel( const Event& ) {return false;}
116 
117  // Possibility to set initial scale in TimeShower for resonance decay.
118  virtual bool canSetResonanceScale() {return false;}
119 
120  // Initial scale for TimeShower evolution.
121  // Usage: scaleResonance( iRes, event), where iRes is location
122  // of decaying resonance in the event record.
123  virtual double scaleResonance( int, const Event& ) {return 0.;}
124 
125  // Possibility to veto an emission in the ISR machinery.
126  virtual bool canVetoISREmission() {return false;}
127 
128  // Decide whether to veto current emission or not, based on event record.
129  // Usage: doVetoISREmission( sizeOld, event, iSys) where sizeOld is size
130  // of event record before current emission-to-be-scrutinized was added,
131  // and iSys is the system of the radiation (according to PartonSystems).
132  virtual bool doVetoISREmission( int, const Event&, int ) {return false;}
133 
134  // Possibility to veto an emission in the FSR machinery.
135  virtual bool canVetoFSREmission() {return false;}
136 
137  // Decide whether to veto current emission or not, based on event record.
138  // Usage: doVetoFSREmission( sizeOld, event, iSys, inResonance) where
139  // sizeOld is size of event record before current emission-to-be-scrutinized
140  // was added, iSys is the system of the radiation (according to
141  // PartonSystems), and inResonance is true if the emission takes place in a
142  // resonance decay.
143  virtual bool doVetoFSREmission( int, const Event&, int, bool = false )
144  {return false;}
145 
146  // Possibility to veto an MPI.
147  virtual bool canVetoMPIEmission() { return false; }
148 
149  // Decide whether to veto an MPI based on event record.
150  // Usage: doVetoMPIEmission( sizeOld, event) where sizeOld
151  // is size of event record before the current MPI.
152  virtual bool doVetoMPIEmission(int, const Event &) { return false; }
153 
154 protected:
155 
156  // Constructor.
157  UserHooks() {}
158 
159  // Pointer to various information on the generation.
160  Info* infoPtr;
161 
162  // Pointer to the settings database.
163  Settings* settingsPtr;
164 
165  // Pointer to the particle data table.
166  ParticleData* particleDataPtr;
167 
168  // Pointer to the random number generator.
169  Rndm* rndmPtr;
170 
171  // Pointers to the two incoming beams and to Pomeron beam-inside-beam.
172  BeamParticle* beamAPtr;
173  BeamParticle* beamBPtr;
174  BeamParticle* beamPomAPtr;
175  BeamParticle* beamPomBPtr;
176 
177  // Pointers to Standard Model couplings.
178  CoupSM* coupSMPtr;
179 
180  // Pointer to information on subcollision parton locations.
181  PartonSystems* partonSystemsPtr;
182 
183  // Pointer to the total/elastic/diffractive cross sections.
184  SigmaTotal* sigmaTotPtr;
185 
186  // omitResonanceDecays omits resonance decay chains from process record.
187  void omitResonanceDecays(const Event& process);
188 
189  // subEvent extracts currently resolved partons in the hard process.
190  void subEvent(const Event& event, bool isHardest = true);
191 
192  // Have one event object around as work area.
193  Event workEvent;
194 
195  // User-imposed selection bias.
196  double selBias;
197 
198 };
199 
200 //==========================================================================
201 
202 // SuppressSmallPT is a derived class for user access to program execution.
203 // It is a simple example, illustrating how to suppress the cross section
204 // of 2 -> 2 processes by a factor pT^4 / (pT0^2 + pT^2)^2, with pT0 input,
205 // and also modify alpha_strong scale similarly.
206 
207 class SuppressSmallPT : public UserHooks {
208 
209 public:
210 
211  // Constructor.
212  SuppressSmallPT( double pT0timesMPIIn = 1., int numberAlphaSIn = 0,
213  bool useSameAlphaSasMPIIn = true) {isInit = false;
214  pT0timesMPI = pT0timesMPIIn; numberAlphaS = numberAlphaSIn;
215  useSameAlphaSasMPI = useSameAlphaSasMPIIn;}
216 
217  // Possibility to modify cross section of process.
218  virtual bool canModifySigma() {return true;}
219 
220  // Multiplicative factor modifying the cross section of a hard process.
221  // Usage: inEvent is true for event generation, false for initialization.
222  virtual double multiplySigmaBy(const SigmaProcess* sigmaProcessPtr,
223  const PhaseSpace* phaseSpacePtr, bool );
224 
225 private:
226 
227  // Save input properties and the squared pT0 scale.
228  bool isInit, useSameAlphaSasMPI;
229  int numberAlphaS;
230  double pT0timesMPI, pT20;
231 
232  // Alpha_strong calculation.
233  AlphaStrong alphaS;
234 
235 };
236 
237 //==========================================================================
238 
239 } // end namespace Pythia8
240 
241 #endif // Pythia8_UserHooks_H