This file is indexed.

/usr/share/pythia8-data/xmldoc/UserHooks.xml is in pythia8-data 8.1.65-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
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
<chapter name="User Hooks">

<h2>User Hooks</h2>

Sometimes it may be convenient to step in during the generation
process: to modify the built-in cross sections, to veto undesirable
events or simply to collect statistics at various stages of the
evolution. There is a base class <code>UserHooks</code> that gives 
you this access at a few selected places. This class in itself does 
nothing; the idea is that you should write your own derived class
for your task. One simple derived class (<code>SuppressSmallPT</code>)
comes with the program, mainly as illustration, and the 
<code>main10.cc</code> program provides a complete (toy) example how 
a derived class could be set up and used.

<p/>
There are six sets of routines, that give you different kinds of
freedom. They are, in no particular order:
<br/>(i) Ones that give you access to the event record in between
the process-level and parton-level steps, or in between the 
parton-level and hadron-level ones. You can study the event record
and decide whether to veto this event.
<br/>(ii) Ones that allow you to set a scale at which the combined
parton-level MPI+ISR+FSR downwards evolution in <ei>pT</ei> is
temporarily interrupted, so the event can be studied and either 
vetoed or allowed to continue the evolution.
<br/>(iii) Ones that allow you to to study the event after the first
few ISR/FSR emissions, or first few MPI, so the event can be vetoed 
or allowed to continue the evolution.
<br/>(iv) Ones that allow you to study the latest initial- or
final-state emission and veto that emission, without vetoing the
event as a whole.
<br/>(v) Ones that give you access to the properties of the trial 
hard process, so that you can modify the internal Pythia cross section,
alternatively the phase space sampling, by your own correction factors.
<br/>(vi) Ones that let you set the scale of shower evolution, 
specifically for matching in resonance decays.
<br/>They are described further in the following numbered subsections. 

<p/> 
All the possibilities above can be combined freely and also be combined
with the standard flags. An event would then survive only if it survived
each of the possible veto methods. There are no hidden interdependencies 
in this game, but of course some combinations may not be particularly 
meaningful. For instance, if you set <code>PartonLevel:all = off</code> 
then the <code>doVetoPT(...)</code> and <code>doVetoPartonLevel(...)</code> 
locations in the code are not even reached, so they would never be called. 

<p/> 
The effect of the vetoes of types (i), (ii) and (iii) can be studied 
in the output of the 
<code><aloc href="EventStatistics">Pythia::statistics()</aloc></code> 
method. The "Selected" column represents the number of events that were 
found acceptable by the internal Pythia machinery, whereas the "Accepted" 
one are the events that also survived the user cuts. The cross section
is based on the latter number, and so is reduced by the amount associated 
by the vetoed events. Also type (v) modifies the cross section, while
types (iv) and (vi) do not.

<p/>
A warning. When you program your own derived class, do remember that you 
must exactly match the arguments of the base-class methods you overload. 
If not, your methods will be considered as completely new ones, and 
compile without any warnings, but not be used inside <code>Pythia</code>.
So, at the debug stage, do insert some suitable print statements to check
that the new methods are called (and do what they should).

<h3>The basic components</h3>

For a derived <code>UserHooks</code> class to be called during the 
execution, a pointer to an object of this class should be handed in 
with the 
<br/><code><aloc href="ProgramFlow">
Pythia::setUserHooksPtr( UserHooks*)</aloc></code>
<br/>method. The first step therefore is to construct your own derived 
class, of course. This must contain a constructor and a destructor. The 
<code>initPtr</code> method comes "for free", and is set up without 
any intervention from you.

<method name="UserHooks::UserHooks()">
</method>
<methodmore name="virtual UserHooks::~UserHooks()">
The constructor and destructor do not need to do anything.
</methodmore>

<method name="void UserHooks::initPtr( Info* infoPtr, 
Settings* settingsPtr, ParticleData* particleDataPtr,  
Rndm* rndmPtr, BeamParticle* beamAPtr, BeamParticle* beamBPtr, 
BeamParticle* beamPomAPtr, BeamParticle* beamPomBPtr, 
CoupSM* coupSMPtr, PartonSystems* partonSystemsPtr, 
SigmaTotal* sigmaTotPtr)">
this (non-virtual) method is automatically called during the 
initialization stage to set several useful pointers, and to set up 
the <code>workEvent</code> below. The corresponding objects can 
later be used to extract some useful information.
<br/><aloc href="EventInformation">Info</aloc>:
general event and run information, including some loop counters.
<br/><aloc href="SettingsScheme">Settings</aloc>: 
the settings used to determine the character of the run. 
<br/><aloc href="ParticleDataScheme">ParticleData</aloc>: 
the particle data used in the event record 
(including <code>workEvent</code> below).
<br/><aloc href="RandomNumbers">Rndm</aloc>: the random number 
generator, that you could also use in your code.
<br/><aloc href="BeamRemnants">BeamParticle</aloc>: 
the <code>beamAPtr</code> and <code>beamBPtr</code> beam particles 
contain info on partons extracted from the two incoming beams, 
on the PDFs used, and more. In cases when diffraction is simulated, 
also special Pomeron beams <code>beamPomAPtr</code> and 
<code>beamPomBPtr</code> are introduced, for the Pomerons residing 
inside the respective proton. 
<br/><aloc href="StandardModelParameters">CoupSM</aloc>: 
Standard Model couplings. 
<br/><aloc href="AdvancedUsage">PartonSystems</aloc>: 
the list of partons that belong to each individual subcollision system.   
<br/><aloc href="TotalCrossSections">SigmaTotal</aloc>: 
total/elastic/diffractive cross section parametrizations.
</method>

<p/> 
Next you overload the desired methods listed in the sections below. 
These often come in pairs or triplets, where the first must return 
true for the last method to be called. This latter method typically 
hands you a reference to the event record, which you then can use to 
decide whether or not to veto. Often the event record can be quite 
lengthy and difficult to overview. The following methods and data member 
can then come in handy. 

<method name="void UserHooks::omitResonanceDecays(const Event& process)"> 
is a protected method that you can make use of in your own methods to 
extract a simplified list of the hard process, where all resonance decay 
chains are omitted. Intended for the <code>can/doVetoProcessLevel</code> 
routines. Note that the normal process-level generation does include
resonance decays. That is, if a top quark is produced in the hard process, 
then also decays such as <ei>t -> b W+, W+ -> u dbar</ei> will be generated 
and stored in <code>process</code>. The <code>omitResonanceDecays</code> 
routine will take the input <code>process</code> and copy it to 
<code>workEvent</code> (see below), minus the resonance decay chains. 
All particles produced in the hard process, such as the top, will be 
considered final-state ones, with positive status and no daughters, 
just as it is before resonances are allowed to decay.
<br/>(In the <code>PartonLevel</code> routines, these decay chains will 
initially not be copied from <code>process</code> to <code>event</code>. 
Instead the combined MPI, ISR and FSR evolution is done with the top 
above as final particle. Only afterwards will the resonance decay chains 
be copied over, with kinematics changes reflecting those of the top, and 
showers in the decays carried out.)
<br/>
</method>


<method name="void UserHooks::subEvent(const Event& event, 
bool isHardest = true)">
is a protected method that you can make use of in your own methods to 
extract a brief list of the current 
partons of interest, with all irrelevant ones omitted. For the default 
<code>isHardest = true</code> only the outgoing partons from the hardest 
interaction (including the partons added to it by ISR and FSR) are 
extracted, as relevant e.g. for <code>doVetoPT( iPos, event)</code> with 
<code>iPos = 0 - 4</code>. With <code>isHardest = false</code> instead 
the outgoing partons of the latest "subprocess" are extracted, as relevant 
when <code>iPos = 5</code>, where it corresponds to the outgoing partons 
in the currently considered decay. The resut is stored in 
<code>workEvent</code> below. The partons are stored in slots 0 through 
<code>workEvent.size() - 1</code>. The <code>mother1()</code> and 
<code>mother2()</code> indices of a particle in this list both return 0. 
The <code>daughter1()</code> and <code>daughter2()</code> indices both 
return the index of the same parton in the original event record 
(<code>event</code>; possibly <code>process</code>), 
so that you can trace the full history, if of interest. 
</method>

<method name="Event UserHooks::workEvent">
This protected class member contains the outcome of the above
<code>omitResonanceDecays(...)</code> and
<code>subEvent(...)</code> methods. Alternatively you can use it for 
whatever temporary purposes you wish. You are free to use standard 
operations, e.g. to boost the event to its rest frame before analysis, 
or remove particles that should not be analyzed.  
The <code>workEvent</code> can also be sent on to a 
<aloc href="EventAnalysis">jet clustering algorithm</aloc>.

<h3>(i) Interrupt between the main generation levels</h3>

<method name="virtual bool UserHooks::canVetoProcessLevel()">
In the base class this method returns false. If you redefine it
to return true then the method <code>doVetoProcessLevel(...)</code>
will be called immediately after a hard process (and associated
resonance decays) has been selected and stored in the 
<code><aloc href="EventRecord">process</aloc></code> event record.
<br/>At this stage, the <code>process</code> record typically contains 
the two beams in slots 1 and 2, the two incoming partons to the hard 
process in slots 3 and 4, the N (usually 1, 2 or 3) primary produced 
particles in slots 5 through 4 + N, and thereafter recursively the 
resonance decay chains, if any. Use the method 
<code>omitResonanceDecays(...)</code> if you want to skip these 
decay chains. There are exceptions to this structure, 
for <aloc href="QCDProcesses">soft QCD processes</aloc> (where
the partonic process may not yet have been selected at this stage), 
and when <aloc href="ASecondHardProcess">a second hard process</aloc> has
been requested (where two hard processes are bookkept). In general
it is useful to begin the development work by listing a few 
<code>process</code> records, to clarify what the structure is for 
the cases of interest.
</method>

<method name="virtual bool UserHooks::doVetoProcessLevel(Event& process)">
can optionally be called, as described above. You can study the 
<code>process</code> event record of the hard process. 
Based on that you can decide whether to veto the event, true, or let 
it continue to evolve, false. If you veto, then this event is not
counted among the accepted ones, and does not contribute to the estimated
cross section. The <code>Pytha::next()</code> method will begin a 
completely new event, so the vetoed event will not appear in the 
output of <code>Pythia::next()</code>.
<note>Warning:</note> Normally you should not modify the <code>process</code>
event record. However, for some matrix-element-matching procedures it may 
become unavoidable. If so, be very careful, since there are many pitfalls.
Only to give one example: if you modify the incoming partons then also
the information stored in the beam particles may need to be modified. 
<note>Note:</note> the above veto is different from setting the flag
<code><aloc href="MasterSwitches">PartonLevel:all = off</aloc></code>. 
Also in the latter case the event generation will stop after the process 
level, but an event generated up to this point is considered perfectly 
acceptable. It can be studied and it contributes to the cross section. 
That is, <code>PartonLevel:all = off</code> is intended for simple studies 
of hard processes, where one can save a lot of time by not generating 
the rest of the story. By contrast, the <code>doVetoProcessLevel()</code> 
method allows you to throw away uninteresting events at an early stage 
to save time, but those events that do survive the veto are allowed to 
develop into complete final states (unless flags have been set otherwise). 
</method>

<method name="virtual bool UserHooks::canVetoPartonLevel()">
In the base class this method returns false. If you redefine it
to return true then the method <code>doVetoPartonLevel(...)</code>
will be called immediately after the parton level has been generated 
and stored in the <code><aloc href="EventRecord">event</aloc></code> 
event record. Thus showers, multiparton interactions and beam remnants 
have been set up, but hadronization and decays have not yet been 
performed. This is already a fairly complete event, possibly with quite
a complex parton-level history. Therefore it is usually only meaningful
to study the hardest interaction, e.g. using <code>subEvent(...)</code>
introduced above, or fairly generic properties, such as the parton-level 
jet structure.
</method>

<method name="virtual bool UserHooks::doVetoPartonLevel(const Event& event)">
can optionally be called, as described above. You can study, but not
modify, the <code>event</code> event record of the partonic process. 
Based on that you can decide whether to veto the event, true, or let 
it continue to evolve, false. If you veto, then this event is not
counted among the accepted ones, and does not contribute to the estimated
cross section. The <code>Pytha::next()</code> method will begin a 
completely new event, so the vetoed event will not appear in the 
output of <code>Pythia::next()</code>.
<note>Note:</note> the above veto is different from setting the flag
<code><aloc href="MasterSwitches">HadronLevel:all = off</aloc></code>. 
Also in the latter case the event generation will stop after the parton 
level, but an event generated up to this point is considered perfectly 
acceptable. It can be studied and it contributes to the cross section.
That is, <code>HadronLevel:all = off</code> is intended for simple 
studies of complete partonic states, where one can save time by not 
generating the complete hadronic final state. By contrast, the 
<code>doVetoPartonLevel()</code> method allows you to throw away 
uninteresting events to save time that way, but those events that 
do survive the veto are allowed to develop into complete final states 
(unless flags have been set otherwise). 
</method>

<h3>(ii) Interrupt during the parton-level evolution, at a 
<ei>pT</ei> scale</h3>

During the parton-level evolution, multiparton interactions (MPI), 
initial-state radiation (ISR) and final-state radiation (FSR)
are normally evolved downwards in
one interleaved evolution sequence of decreasing <ei>pT</ei> values.
For some applications, e.g  matrix-element-matching approaches, it
may be convenient to stop the evolution temporarily when the "hard"
emissions have been considered, but before continuing with the more
time-consuming soft activity. Based on these hard partons one can make
a decision whether the event at all falls in the intended event class,
e.g. has the "right" number of parton-level jets. If yes then, as for 
the methods above, the evolution will continue all the way up to a 
complete event. Also as above, if no, then the event will not be 
considered in the final cross section. 

<p/>
Recall that the new or modified partons resulting from a MPI, ISR or FSR 
step are always appended to the end of the then-current event record.
Previously existing partons are not touched, except for the 
<aloc href="ParticleProperties">status, mother and daughter</aloc> 
values, which are updated to reflect the modified history. It is 
therefore straightforward to find the partons associated with the most 
recent occurence.
<br/>An MPI results in four new partons being appended, two incoming
and two outgoing ones.
<br/>An ISR results in the whole affected system being copied down,
with one of the two incoming partons being replaced by a new one, and
one more outgoing parton.
<br/>An FSR results in three new partons, two that come from the
branching and one that takes the recoil.
<br/>The story becomes more messy when rescattering is allowed as part
of the MPI machinery. Then there will not only be a new system, as 
outlined above, but additionally some existing systems will undergo
cascade effects, and be copied down with changed kinematics. 

<p/>
In this subsection we outline the possibility to interrupt at a given 
<ei>pT</ei> scale, in the next to interrupt after a given number of 
emissions.

<method name="virtual bool UserHooks::canVetoPT()">
In the base class this method returns false. If you redefine it
to return true then the method <code>doVetoPT(...)</code> will 
interrupt the downward evolution at <code>scaleVetoPT()</code>. 

<method name="virtual double UserHooks::scaleVetoPT()">
In the base class this method returns 0. You should redefine it
to return the <ei>pT</ei> scale at which you want to study the event.
</method>

<method name="virtual bool UserHooks::doVetoPT(int iPos, const Event& event)">
can optionally be called, as described above. You can study, but not
modify, the <code>event</code> event record of the partonic process. 
Based on that you can decide whether to veto the event, true, or let 
it continue to evolve, false. If you veto, then this event is not
counted among the accepted ones, and does not contribute to the estimated
cross section. The <code>Pytha::next()</code> method will begin a 
completely new event, so the vetoed event will not appear in the 
output of <code>Pythia::next()</code>.
<argument name="iPos"> is the position/status when the routine is
called, information that can help you decide your course of action: 
<argoption value="0"> when no MPI, ISR or FSR occured above the veto scale;
</argoption>
<argoption value="1"> when inside the interleaved MPI + ISR + FSR evolution, 
after an MPI process;  
</argoption>
<argoption value="2"> when inside the interleaved MPI + ISR + FSR evolution, 
after an ISR emission;
</argoption>
<argoption value="3"> when inside the interleaved MPI + ISR + FSR evolution, 
after an FSR emission;
</argoption>
<argoption value="4"> for the optional case where FSR is deferred from the 
interleaved evolution and only considered separately afterward (then 
alternative 3 would never occur);
</argoption>
<argoption value="5"> is for subsequent resonance decays, and is called once
for each decaying resonance in a chain such as <ei>t -> b W, W -> u dbar</ei>.
</argoption>
</argument>
<argument name="event"> the event record contains a list of all partons 
generated so far, also including intermediate ones not part of the 
"current final state", and also those from further multiparton interactions. 
This may not be desirable for comparisons with matrix-element calculations.
You may want to make use of the <code>subEvent(...)</code> method below to 
obtain a simplified event record <code>workEvent</code>. 
</argument>
</method>

<h3>(iii) Interrupt during the parton-level evolution, after a step</h3>

These options are closely related to the ones above in section (ii), so 
we do not repeat the introduction, nor the possibilities to study the 
event record, also by using <code>subEvent(...)</code> and 
<code>workEvent</code>.  
What is different is that the methods in this section give access to the 
event as it looks like after each of the first few steps in the downwards
evolution, irrespectively of the <ei>pT</ei> scales of these branchings.
Furthermore, it is here assumed that the focus normally is on the hardest
subprocess, so that ISR/FSR emissions associated with additional MPI's
are not considered. For MPI studies, however, a separate simpler 
alternative is offered to consider the event after a given number
of interactions.  

<method name="virtual bool UserHooks::canVetoStep()">
In the base class this method returns false. If you redefine it
to return true then the method <code>doVetoStep(...)</code> will 
interrupt the downward ISR and FSR evolution the first
<code>numberVetoStep()</code> times. 

<method name="virtual int UserHooks::numberVetoStep()">
Returns the number of steps <ei>n</ei> each of ISR and FSR, for the 
hardest interaction, that you want to be able to study. That is,
the method will be called after the first <ei>n</ei> ISR emissions,
irrespective of the number of FSR ones at the time, and after the 
first <ei>n</ei> FSR emissions, irespective of the number of ISR ones.
The number of steps defaults to the first one only, but you are free 
to pick another value. Note that double diffraction is handled as two 
separate Pomeron-proton collisions, and thus has two sequences of 
emissions.
</method>

<method name="virtual bool UserHooks::doVetoStep(int iPos, 
int nISR, int nFSR, const Event& event)">
can optionally be called, as described above. You can study, but not
modify, the <code>event</code> event record of the partonic process. 
Based on that you can decide whether to veto the event, true, or let 
it continue to evolve, false. If you veto, then this event is not
counted among the accepted ones, and does not contribute to the estimated
cross section. The <code>Pytha::next()</code> method will begin a 
completely new event, so the vetoed event will not appear in the 
output of <code>Pythia::next()</code>.
<argument name="iPos"> is the position/status when the routine is
called, information that can help you decide your course of action.
Agrees with options 2 - 5 of the <code>doVetoPT(...)</code> routine
above, while options 0 and 1 are not relevant here.
</argument>
<argument name="nISR"> is the number of ISR emissions in the hardest 
process so far. For resonance decays, <code>iPos = 5</code>, it is 0.
</argument>
<argument name="nFSR"> is the number of FSR emissions in the hardest 
process so far. For resonance decays, <code>iPos = 5</code>, it is the 
number of emissions in the currently studied system. 
</argument>
<argument name="event"> the event record contains a list of all partons 
generated so far, also including intermediate ones not part of the 
"current final state", and also those from further multiparton interactions. 
This may not be desirable for comparisons with matrix-element calculations.
You may want to make use of the <code>subEvent(...)</code> method above to 
obtain a simplified event record.
</argument>
</method>

<method name="virtual bool UserHooks::canVetoMPIStep()">
In the base class this method returns false. If you redefine it
to return true then the method <code>doVetoMPIStep(...)</code> will 
interrupt the downward MPI evolution the first
<code>numberVetoMPIStep()</code> times. 

<method name="virtual int UserHooks::numberVetoMPIStep()">
Returns the number of steps in the MPI evolution that you want to be 
able to study, right after each new step has been taken and the 
subcollision has been added to the event record. The number of steps 
defaults to the first one only, but you are free to pick another value.
Note that the hardest interaction of an events counts as the first
multiparton interaction. For most hard processes it thus at the first
step offers nothing not available with the <code>VetoProcessLevel</code>
functionality above. For the minimum-bias and diffractive systems the
hardest interaction is not selected at the process level, however, so
there a check after the first multiparton interaction offers new 
functionality. Note that double diffraction is handled as two separate
Pomeron-proton collisions, and thus has two sequences of interactions.
Also, if you have set up a second hard process then a check is made
after these first two, and the first interaction coming from the MPI
machinery would have sequence number 3.
</method>

<method name="virtual bool UserHooks::doVetoMPIStep(int nMPI,
const Event& event)">
can optionally be called, as described above. You can study, but not
modify, the <code>event</code> event record of the partonic process. 
Based on that you can decide whether to veto the event, true, or let 
it continue to evolve, false. If you veto, then this event is not
counted among the accepted ones, and does not contribute to the estimated
cross section. The <code>Pytha::next()</code> method will begin a 
completely new event, so the vetoed event will not appear in the 
output of <code>Pythia::next()</code>.
<argument name="nMPI"> is the number of MPI subprocesses has occured
so far.
</argument>
<argument name="event"> the event record contains a list of all partons 
generated so far, also including intermediate ones not part of the 
"current final state", e.g. leftovers from the ISR and FSR evolution
of previously generated systems. The most recently added one has not
had time to radiate, of course.
</argument>
</method>

<h3>(iv) Veto emissions</h3>

The methods in this group are intended to allow the veto of an emission
in ISR, FSR or MPI, without affecting the evolution in any other way.
If an emission is vetoed, the event record is "rolled back" to the 
way it was before the emission occured, and the evolution in <ei>pT</ei> 
is continued downwards from the rejected value. The decision can be 
based on full knowledge of the kinematics of the shower branching or MPI.

<p/>
To identify where shower emissions originated, the ISR/FSR veto
routines are passed the system from which the radiation occured, according
to the Parton Systems class (see <aloc href="AdvancedUsage">Advanced
Usage</aloc>). Note, however, that inside the veto routines only the event
record has been updated; all other information, including the Parton
Systems, reflects the event before the shower branching or MPI has
taken place.

<method name="virtual bool UserHooks::canVetoISREmission()">
In the base class this method returns false. If you redefine it
to return true then the method <code>doVetoISREmission(...)</code> 
will interrupt the initial-state shower immediately after each
emission and allow that emission to be vetoed.

<method name="virtual bool UserHooks::doVetoISREmission( 
int sizeOld, const Event& event, int iSys)">
can optionally be called, as described above. You can study, but not
modify, the <code>event</code> event record of the partonic process. 
Based on that you can decide whether to veto the emission, true, or 
not, false. If you veto, then the latest emission is removed from
the event record. In either case the evolution of the shower will
continue from the point where it was left off.
<argument name="sizeOld"> is the size of the event record before the
latest emission was added to it. It will also become the new size if 
the emission is vetoed.
</argument>
<argument name="event"> the event record contains a list of all partons 
generated so far. Of special interest are the ones associated with the 
most recent emission, which are stored in entries from <code>sizeOld</code> 
through <code>event.size() - 1</code> inclusive. If you veto the emission
these entries will be removed, and the history info in the remaining
partons will be restored to a state as if the emission had never occured.
</argument>
<argument name="iSys"> the system where the radiation occurs, according
to Parton Systems.
</argument>
</method>

<method name="virtual bool UserHooks::canVetoFSREmission()">
In the base class this method returns false. If you redefine it
to return true then the method <code>doVetoFSREmission(...)</code> 
will interrupt the final-state shower immediately after each
emission and allow that emission to be vetoed.

<method name="virtual bool UserHooks::doVetoFSREmission( 
int sizeOld, const Event& event, int iSys, bool inResonance = false)">
can optionally be called, as described above. You can study, but not
modify, the <code>event</code> event record of the partonic process. 
Based on that you can decide whether to veto the emission, true, or 
not, false. If you veto, then the latest emission is removed from
the event record. In either case the evolution of the shower will
continue from the point where it was left off.
<argument name="sizeOld"> is the size of the event record before the
latest emission was added to it. It will also become the new size if 
the emission is vetoed.
</argument>
<argument name="event"> the event record contains a list of all partons 
generated so far. Of special interest are the ones associated with the 
most recent emission, which are stored in entries from <code>sizeOld</code> 
through <code>event.size() - 1</code> inclusive. If you veto the emission
these entries will be removed, and the history info in the remaining
partons will be restored to a state as if the emission had never occured.
</argument>
<argument name="iSys"> the system where the radiation occurs, according
to Parton Systems.
</argument>
<argument name="inResonance"> <code>true</code> if the emission takes
place in a resonance decay, subsequent to the hard process.
</argument>
</method>

<method name="virtual bool UserHooks::canVetoMPIEmission()">
In the base class this method returns false. If you redefine it
to return true then the method <code>doVetoMPIEmission(...)</code> 
will interrupt the MPI machinery immediately after each multiparton
interaction and allow it to be vetoed.

<method name="virtual bool UserHooks::doVetoMPIEmission( 
int sizeOld, const Event& event)">
can optionally be called, as described above. You can study, but not
modify, the <code>event</code> event record of the partonic process. 
Based on that you can decide whether to veto the MPI, true, or 
not, false. If you veto, then the latest MPI is removed from
the event record. In either case the interleaved evolution will
continue from the point where it was left off.
<argument name="sizeOld"> is the size of the event record before the
latest MPI was added to it. It will also become the new size if 
the MPI is vetoed.
</argument>
<argument name="event"> the event record contains a list of all partons 
generated so far. Of special interest are the ones associated with the 
most recent MPI, which are stored in entries from <code>sizeOld</code> 
through <code>event.size() - 1</code> inclusive. If you veto the MPI
these entries will be removed.
</argument>
</method>

<h3>(v) Modify cross-sections or phase space samling</h3>

This section addresses two related but different topics. In both
cases the sampling of events in phase space is modified, so that
some regions are more populated while others are depleted. 
In the first case, this is assumed to be because the physical
cross section should be modified relative to the built-in Pythia
form. Therefore not only the relative population of phase space
is changed, but also the integrated cross section of the process.
In the second case the repopulation is only to be viewed as a 
technical trick to sample some phase-space regions better, so as 
to reduce the statistical error. There each event instead obtains
a compensating weight, the inverse of the differential cross section
reweighting factor, in such a way thet the integrated cross section
is unchanged. Below these two cases are considered separately,  
but note that they share many points.

<method name="virtual bool UserHooks::canModifySigma()">
In the base class this method returns false. If you redefine it
to return true then the method <code>multiplySigmaBy(...)</code> will 
allow you to modify the cross section weight assigned to the current
event.
</method>

<method name="virtual double UserHooks::multiplySigmaBy(
const SigmaProcess* sigmaProcessPtr, const PhaseSpace* phaseSpacePtr, 
bool inEvent)">
when called this method should provide the factor by which you want to 
see the cross section weight of the current event modified. If you 
return unity then the normal cross section is obtained. Note that, unlike 
the methods above, these modifications do not lead to a difference between
the number of "selected" events and the number of "accepted" ones, 
since the modifications occur already before the "selected" level.
The integrated cross section of a process is modified, of course.
Note that the cross section is only modifiable for normal hard processes.
It does not affect the cross section in further multiparton interactions,
nor in elastic/diffractive/minimum-bias events.
<argument name="sigmaProcessPtr, phaseSpacePtr">:
what makes this routine somewhat tricky to write is that the 
hard-process event has not yet been constructed, so one is restricted 
to use the information available in the phase-space and cross-section 
objects currently being accessed. Which of their  methods are applicable 
depends on the process, in particular the number of final-state particles. 
The <code>multiplySigmaBy</code> code in <code>UserHooks.cc</code> 
contains explicit instructions about which methods provide meaningful 
information, and so offers a convenient starting point. 
</argument>
<argument name="inEvent">: this flag is true when the method is 
called from within the event-generation machinery and false
when it is called at the initialization stage of the run, when the 
cross section is explored to find a maximum for later Monte Carlo usage. 
Cross-section modifications should be independent of this flag,
for consistency, but if <code> multiplySigmaBy(...)</code> is used to
collect statistics on the original kinematics distributions before cuts,
then it is important to be able to exclude the initialization stage
from comparisons.
</argument>
</method>

<p/>
One derived class is supplied as an example how this facility can be used
to reweight cross sections in the same spirit as is done with QCD cross
sections for the minimum-bias/underlying-event description:

<class name="SuppressSmallPT : public UserHooks">
suppress small-<ei>pT</ei> production for <ei>2 -> 2</ei> processes
only, while leaving other processes unaffected. The basic suppression
factor is <ei>pT^4 / ((k*pT0)^2 + pT^2)^2</ei>, where <ei>pT</ei>
refers to the current hard subprocess and <ei>pT0</ei> is the same
energy-dependent dampening scale as used for 
<aloc href="MultipartonInteractions">multiparton interactions</aloc>.
This class contains <code>canModifySigma()</code> and
<code>multiplySigmaBy()</code> methods that overload the base class ones.

<method name="SuppressSmallPT::SuppressSmallPT( double pT0timesMPI = 1., 
int numberAlphaS = 0, bool useSameAlphaSasMPI = true)">
 The optional arguments of the constructor provides further variability. 
<argument name="pT0timesMPI"> 
corresponds to the additional factor <ei>k</ei> in the above formula. 
It is by default equal to 1 but can be used to explore deviations from 
the expected value.
</argument>
<argument name="numberAlphaS">  
if this number <ei>n</ei> is bigger than the default 0, the 
corresponding number of <ei>alpha_strong</ei> factors is also 
reweighted from the normal renormalization scale to a modified one,
i.e. a further suppression factor
<ei>( alpha_s((k*pT0)^2 + Q^2_ren) / alpha_s(Q^2_ren) )^n</ei>
is introduced.
</argument>
<argument name="useSameAlphaSasMPI"> 
regulates which kind of new <ei>alpha_strong</ei> value is evaluated
for the numerator in the above expression. It is by default the same 
as set for multiparton interactions (i.e. same starting value at 
<ei>M_Z</ei> and same order of running), but if <code>false</code> 
instead the one for hard subprocesses. The denominator 
<ei>alpha_s(Q^2_ren)</ei> is always the value used for the "original", 
unweighted cross section. 
</argument>
</class>

<p/>
The second main case of the current section involves three methods,
as follows.

<method name="virtual bool UserHooks::canBiasSelection()">
In the base class this method returns false. If you redefine it
to return true then the method <code>biasSelectionBy(...)</code> will 
allow you to modify the phase space sampling, with a compensating
event weight, such that the cross section is unchanged. You cannot 
combine this kind of reweighting with the selection of 
<aloc href="ASecondHardProcess">a second hard process</aloc>.
</method>

<method name="virtual double UserHooks::biasSelectionBy(
const SigmaProcess* sigmaProcessPtr, const PhaseSpace* phaseSpacePtr, 
bool inEvent)">
when called this method should provide the factor by which you want to 
see the phase space sampling of the current event modified. Events are
assigned a weight being the inverse of this, such that the integrated 
cross section of a process is unchanged. Note that the selection
is only modifiable for normal hard processes. It does not affect the 
selection in further multiparton interactions, nor in 
elastic/diffractive/minimum-bias events.
<argument name="sigmaProcessPtr, phaseSpacePtr">:
what makes this routine somewhat tricky to write is that the 
hard-process event has not yet been constructed, so one is restricted 
to use the information available in the phase-space and cross-section 
objects currently being accessed. Which of their  methods are applicable 
depends on the process, in particular the number of final-state particles. 
The <code>biasSelectionBy</code> code in <code>UserHooks.cc</code> 
contains explicit instructions about which methods provide meaningful 
information, and so offers a convenient starting point. 
</argument>
<argument name="inEvent">: this flag is true when the method is 
called from within the event-generation machinery and false
when it is called at the initialization stage of the run, when the 
cross section is explored to find a maximum for later Monte Carlo usage. 
Cross-section modifications should be independent of this flag,
for consistency, but if <code>biasSelectionBy(...)</code> is used to
collect statistics on the original kinematics distributions before cuts,
then it is important to be able to exclude the initialization stage
from comparisons.
</argument>
</method>

<method name="virtual double UserHooks::biasedSelectionWeight()">
Returns the weight you should assign to the event, to use e.g. when
you histogram results. It is the exact inverse of the weight you 
used to modify the phase-space sampling, a weight that must be stored
in the <code>selBias</code> member variable, such that this routine
can return <code>1/selBias</code>. The weight is also returned by the
<code>Info::weight()</code> method, which may be more convenient to use.
</method>
 
<h3>(vi) Modify scale in shower evolution</h3>

The choice of maximum shower scale in resonance decays is normally not a
big issue, since the shower here is expected to cover the full phase
space. In some special cases a matching scheme is intended, where hard
radiation is covered by matrix elements, and only softer by showers. The 
below two methods support such an approach. Note that the two methods
are not used in the <code>TimeShower</code> class itself, but when 
showers are called from the <code>PartonLevel</code> generation. Thus
user calls directly to <code>TimeShower</code> are not affected. 

<method name="virtual bool UserHooks::canSetResonanceScale()">
In the base class this method returns false. If you redefine it
to return true then the method <code>scaleResonance(...)</code> 
will set the initial scale of downwards shower evolution.

<method name="virtual double UserHooks::scaleResonance( int iRes, 
const Event& event)">
can optionally be called, as described above. You should return the maximum
scale, in GeV, from which the shower evolution will begin. The base class
method returns 0, i.e. gives no shower evolution at all.
You can study, but not modify, the <code>event</code> event record 
of the partonic process to check which resonance is decaying, and into what. 
<argument name="iRes"> is the location in the event record of the 
resonance that decayed to the particles that now will shower.
</argument>
<argument name="event"> the event record contains a list of all partons 
generated so far, specifically the decaying resonance and its immediate
decay products. 
</argument>
</method>

</chapter>

<!-- Copyright (C) 2012 Torbjorn Sjostrand -->