`Event`

format, and use a few basic facilities such
as four-vectors. Their ordering is mainly by history; for current
LHC applications the final one, `SlowJet`

, is of
special interest.
In addition to the methods presented here, there is also the possibility to make use of external jet finders .

where the

The above tensor can be generalized by introducing a power
*r*, such that
*
S^{ab} = (sum_i p_i^a p_i^b p_i^{r-2}) / (sum_i p_i^r)
*

In particular, *r = 1* gives a linear dependence on momenta
and thus a collinear safe definition, unlike sphericity.

To do sphericity analyses you have to set up a `Sphericity`

instance, and then feed in events to it, one at a time. The results
for the latest event are available as output from a few methods.

**Sphericity::Sphericity(double power = 2., int select = 2) **

create a sphericity analysis object, where
`argument`

** power ** (`default = `

) :
is the power **2.***r* defined above, i.e.
`argumentoption `

** 2.** : gives Sphericity, and
`argumentoption `

** 1.** : gives the linear form.
`argument`

** select ** (`default = `

) :
tells which particles are analyzed,
**2**`argumentoption `

** 1** : all final-state particles,
`argumentoption `

** 2** : all observable final-state particles,
i.e. excluding neutrinos and other particles without strong or
electromagnetic interactions (the `isVisible()`

particle method), and
`argumentoption `

** 3** : only charged final-state particles.

**bool Sphericity::analyze( const Event& event, ostream& os = cout) **

perform a sphericity analysis, where
`argument`

** event ** : is an object of the `Event`

class,
most likely the `pythia.event`

one.
`argument`

** os ** (`default = `

) : is the output stream for
error messages. (The method does not rely on the **cout**`Info`

machinery for error messages.)

If the routine returns `false`

the
analysis failed, e.g. if too few particles are present to analyze.

After the analysis has been performed, a few methods are available to return the result of the analysis of the latest event:

**double Sphericity::sphericity() **

gives the sphericity (or equivalent if *r* is not 2),

**double Sphericity::aplanarity() **

gives the aplanarity (with the same comment),

**double Sphericity::eigenValue(int i) **

gives one of the three eigenvalues for *i* = 1, 2 or 3, in
descending order,

**Vec4 Sphericity::eventAxis(i) **

gives the matching normalized eigenvector, as a `Vec4`

with vanishing time/energy component.

**void Sphericity::list(ostream& os = cout) **

provides a listing of the above information.

There is also one method that returns information accumulated for all the events analyzed so far.

**int Sphericity::nError() **

tells the number of times `analyze(...)`

failed to analyze
events, i.e. returned `false`

.

The calculation of thrust is more computer-time-intensive than e.g.
linear sphericity, introduced above, and has no specific advantages except
historical precedent. In the PYTHIA 6 implementation the search was
sped up at the price of then not being guaranteed to hit the absolute
maximum. The current implementation studies all possibilities, but at
the price of being slower, with time consumption for an event with
*n* particles growing like *n^3*.

To do thrust analyses you have to set up a `Thrust`

instance, and then feed in events to it, one at a time. The results
for the latest event are available as output from a few methods.

**Thrust::Thrust(int select = 2) **

create a thrust analysis object, where
`argument`

** select ** (`default = `

) :
tells which particles are analyzed,
**2**`argumentoption `

** 1** : all final-state particles,
`argumentoption `

** 2** : all observable final-state particles,
i.e. excluding neutrinos and other particles without strong or
electromagnetic interactions (the `isVisible()`

particle method), and
`argumentoption `

** 3** : only charged final-state particles.

**bool Thrust::analyze( const Event& event, ostream& os = cout) **

perform a thrust analysis, where
`argument`

** event ** : is an object of the `Event`

class,
most likely the `pythia.event`

one.
`argument`

** os ** (`default = `

) : is the output stream for
error messages. (The method does not rely on the **cout**`Info`

machinery for error messages.)

If the routine returns `false`

the
analysis failed, e.g. if too few particles are present to analyze.

After the analysis has been performed, a few methods are available to return the result of the analysis of the latest event:

**double Thrust::thrust() **

**double Thrust::tMajor() **

**double Thrust::tMinor() **

**double Thrust::oblateness() **

gives the thrust, major, minor and oblateness values, respectively,

**Vec4 Thrust::eventAxis(int i) **

gives the matching normalized event-axis vectors, for *i* = 1, 2 or 3
corresponding to thrust, major or minor, as a `Vec4`

with
vanishing time/energy component.

**void Thrust::list(ostream& os = cout) **

provides a listing of the above information.

There is also one method that returns information accumulated for all the events analyzed so far.

**int Thrust::nError() **

tells the number of times `analyze(...)`

failed to analyze
events, i.e. returned `false`

.

`ClusterJet`

(a.k.a. `LUCLUS`

and
`PYCLUS`

) is a clustering algorithm of the type used for
analyses of
Note that we have deliberately chosen not to include the *e^+e^-*
equivalents of the Cambridge/Aachen and anti-*kRT* algorithms.
These tend to be good at clustering the densely populated (in angle)
cores of jets, but less successful for the sparsely populated transverse
regions, where many jets may come to consist of a single low-momentum
particle. In hadron collisions such jets could easily be disregarded,
while in *e^+e^-* annihilation all particles derive back from the
hard process.

To do jet finding analyses you have to set up a `ClusterJet`

instance, and then feed in events to it, one at a time. The results
for the latest event are available as output from a few methods.

**ClusterJet::ClusterJet(string measure = "Lund", int select = 2, int massSet = 2, bool precluster = false, bool reassign = false) **

create a `ClusterJet`

instance, where
`argument`

** measure ** (`default = `

) : distance measure,
to be provided as a character string (actually, only the first character
is necessary)
**"Lund"**`argumentoption `

** "Lund"** : the Lund *pT* distance,
`argumentoption `

** "JADE"** : the JADE mass distance, and
`argumentoption `

** "Durham"** : the Durham *kT* measure.
`argument`

** select ** (`default = `

) :
tells which particles are analyzed,
**2**`argumentoption `

** 1** : all final-state particles,
`argumentoption `

** 2** : all observable final-state particles,
i.e. excluding neutrinos and other particles without strong or
electromagnetic interactions (the `isVisible()`

particle
method), and
`argumentoption `

** 3** : only charged final-state particles.
`argument`

** massSet ** (`default = `

) : masses assumed for the particles
used in the analysis
**2**`argumentoption `

** 0** : all massless,
`argumentoption `

** 1** : photons are massless while all others are
assigned the *pi+-* mass, and
`argumentoption `

** 2** : all given their correct masses.
`argument`

** precluster ** (`default = `

) :
perform or not a early preclustering step, where nearby particles
are lumped together so as to speed up the subsequent normal clustering.
**false**`argument`

** reassign ** (`default = `

) :
reassign all particles to the nearest jet each time after two jets
have been joined.
**false**

**ClusterJet::analyze( const Event& event, double yScale, double pTscale, int nJetMin = 1, int nJetMax = 0, ostream& os = cout) **

performs a jet finding analysis, where
`argument`

** event ** : is an object of the `Event`

class,
most likely the `pythia.event`

one.
`argument`

** yScale ** :
is the cutoff joining scale, below which jets are joined. Is given
in quadratic dimensionless quantities. Either `yScale`

or `pTscale`

must be set nonvanishing, and the larger of
the two dictates the actual value.
`argument`

** pTscale ** :
is the cutoff joining scale, below which jets are joined. Is given
in linear quantities, such as *pT* or *m* depending on
the measure used, but always in units of GeV. Either `yScale`

or `pTscale`

must be set nonvanishing, and the larger of
the two dictates the actual value.
`argument`

** nJetMin ** (`default = `

) :
the minimum number of jets to be reconstructed. If used, it can override
the **1**`yScale`

and `pTscale`

values.
`argument`

** nJetMax ** (`default = `

) :
the maximum number of jets to be reconstructed. Is not used if below
**0**`nJetMin`

. If used, it can override the `yScale`

and `pTscale`

values. Thus e.g.
`nJetMin = nJetMax = 3`

can be used to reconstruct exactly
3 jets.
`argument`

** os ** (`default = `

) : is the output stream for
error messages. (The method does not rely on the **cout**`Info`

machinery for error messages.)

If the routine returns `false`

the analysis failed,
e.g. because the number of particles was smaller than the minimum number
of jets requested.

After the analysis has been performed, a few `ClusterJet`

class methods are available to return the result of the analysis:

**int ClusterJet::size() **

gives the number of jets found, with jets numbered 0 through
`size() - 1`

.

**Vec4 ClusterJet::p(int i) **

gives a `Vec4`

corresponding to the four-momentum defined by
the sum of all the contributing particles to the *i*'th jet.

**int ClusterJet::mult(int i) **

the number of particles that have been clustered into the *i*'th jet.

**int ClusterJet::jetAssignment(int i) **

gives the index of the jet that the particle *i* of the event
record belongs to,

**void ClusterJet::list(ostream& os = cout) **

provides a listing of the reconstructed jets.

**int ClusterJet::distanceSize() **

the number of most recent clustering scales that have been stored
for readout with the next method. Normally this would be five,
but less if fewer clustering steps occurred.

**double ClusterJet::distance(int i) **

clustering scales, with `distance(0)`

being the most
recent one, i.e. normally the highest, up to `distance(4)`

being the fifth most recent. That is, with *n* being the final
number of jets, `ClusterJet::size()`

, the scales at which
*n+1* jets become *n*, *n+2* become *n+1*,
and so on till *n+5* become *n+4*. Nonexisting clustering
scales are returned as zero. The physical interpretation of a scale is
as provided by the respective distance measure (Lund, JADE, Durham).

There is also one method that returns information accumulated for all the events analyzed so far.

**int ClusterJet::nError() **

tells the number of times `analyze(...)`

failed to analyze
events, i.e. returned `false`

.

`CellJet`

(a.k.a. `PYCELL`

) is a simple cone jet
finder in the UA1 spirit, see the PYTHIA 6 manual. It works in an
To do jet finding analyses you have to set up a `CellJet`

instance, and then feed in events to it, one at a time. Especially note
that, if you want to use the options where energies are smeared in
order so emulate detector imperfections, you must hand in an external
random number generator, preferably the one residing in the
`Pythia`

class. The results for the latest event are
available as output from a few methods.

**CellJet::CellJet(double etaMax = 5., int nEta = 50, int nPhi = 32, int select = 2, int smear = 0, double resolution = 0.5, double upperCut = 2., double threshold = 0., Rndm* rndmPtr = 0) **

create a `CellJet`

instance, where
`argument`

** etaMax ** (`default = `

) :
the maximum +-pseudorapidity that the detector is assumed to cover.
**5.**`argument`

** nEta ** (`default = `

) :
the number of equal-sized bins that the **50***+-etaMax* range
is assumed to be divided into.
`argument`

** nPhi ** (`default = `

) :
the number of equal-sized bins that the **32***phi* range
*+-pi* is assumed to be divided into.
`argument`

** select ** (`default = `

) :
tells which particles are analyzed,
**2**`argumentoption `

** 1** : all final-state particles,
`argumentoption `

** 2** : all observable final-state particles,
i.e. excluding neutrinos and other particles without strong or
electromagnetic interactions (the `isVisible()`

particle
method),
and
`argumentoption `

** 3** : only charged final-state particles.
`argument`

** smear ** (`default = `

) :
strategy to smear the actual **0***eT* bin by bin,
`argumentoption `

** 0** : no smearing,
`argumentoption `

** 1** : smear the *eT* according to a Gaussian
with width *resolution * sqrt(eT)*, with the Gaussian truncated
at 0 and *upperCut * eT*,
`argumentoption `

** 2** : smear the *e = eT * cosh(eta)* according
to a Gaussian with width *resolution * sqrt(e)*, with the
Gaussian truncated at 0 and *upperCut * e*.
`argument`

** resolution ** (`default = `

) :
see above.
**0.5**`argument`

** upperCut ** (`default = `

) :
see above.
**2.**`argument`

** threshold ** (`default = `

) :
completely neglect all bins with an **0 GeV***eT < threshold*.
`argument`

** rndmPtr ** (`default = `

) :
the random-number generator used to select the smearing described
above. Must be handed in for smearing to be possible. If your
**0**`Pythia`

class instance is named `pythia`

,
then `&pythia.rndm`

would be the logical choice.

**bool CellJet::analyze( const Event& event, double eTjetMin = 20., double coneRadius = 0.7, double eTseed = 1.5, ostream& os = cout) **

performs a jet finding analysis, where
`argument`

** event ** : is an object of the `Event`

class,
most likely the `pythia.event`

one.
`argument`

** eTjetMin ** (`default = `

) :
is the minimum transverse energy inside a cone for this to be
accepted as a jet.
**20. GeV**`argument`

** coneRadius ** (`default = `

) :
is the size of the cone in **0.7***(eta, phi)* space drawn around
the geometric center of the jet.
`argument`

** eTseed ** (`default = `

) :
the minimum **1.5 GeV***eT* in a cell for this to be acceptable as
the trial center of a jet.
`argument`

** os ** (`default = `

) : is the output stream for
error messages. (The method does not rely on the **cout**`Info`

machinery for error messages.)

If the routine returns `false`

the analysis failed,
but currently this is not foreseen ever to happen.

After the analysis has been performed, a few `CellJet`

class methods are available to return the result of the analysis:

**int CellJet::size() **

gives the number of jets found, with jets numbered 0 through
`size() - 1`

,

**double CellJet::eT(i) **

gives the *eT* of the *i*'th jet, where jets have been
ordered with decreasing *eT* values,

**double CellJet::etaCenter(int i) **

**double CellJet::phiCenter(int i) **

gives the *eta* and *phi* coordinates of the geometrical
center of the *i*'th jet,

**double CellJet::etaWeighted(int i) **

**double CellJet::phiWeighted(int i) **

gives the *eta* and *phi* coordinates of the
*eT*-weighted center of the *i*'th jet,

**int CellJet::multiplicity(int i) **

gives the number of particles clustered into the *i*'th jet,

**Vec4 CellJet::pMassless(int i) **

gives a `Vec4`

corresponding to the four-momentum defined
by the *eT* and the weighted center of the *i*'th jet,

**Vec4 CellJet::pMassive(int i) **

gives a `Vec4`

corresponding to the four-momentum defined by
the sum of all the contributing cells to the *i*'th jet, where
each cell contributes a four-momentum as if all the *eT* is
deposited in the center of the cell,

**double CellJet::m(int i) **

gives the invariant mass of the *i*'th jet, defined by the
`pMassive`

above,

**void CellJet::list() **

provides a listing of the above information (except `pMassless`

,
for reasons of space).

There is also one method that returns information accumulated for all the events analyzed so far.

**int CellJet::nError() **

tells the number of times `analyze(...)`

failed to analyze
events, i.e. returned `false`

.

`SlowJet`

is a simple program for doing jet finding according
to either of the `FastJet`

program [Cac06, Cac12].
That package contains many more algorithms, with many more options,
and, above all, is `SlowJet`

is not so much intended for massive processing of data or Monte Carlo
files as for simple first tests. Nevertheless, within the advertised
capabilities of `SlowJet`

, it has been checked to find
identically the same jets as `FastJet`

. The time consumption
typically is around or below that to generate an LHC `SlowJet`

can not
be used for tricks like distributing a dense grid of pseudoparticles
to be able to define jet areas, like `FastJet`

can, and also
not for events with much pileup or other noise.
The recent introduction of `fjcore`

, containing the core
functionality of `FastJet`

in a very much smaller package,
has changed the conditions. It now is possible (even encouraged by the
authors) to distribute the two `fjcore`

files as part of the
PYTHIA package. Therefore the `SlowJet`

class doubles as a
convenient front end to `fjcore`

, managing the conversion
back and forth between PYTHIA and `FastJet`

variables. Some
applications may still benefit from using the native codes, but the default
now is to let `SlowJet`

call on `fjcore`

for the
jet finding.

The first step is to decide which particles should be included in the
analysis, and with what four-momenta. The `SlowJet`

constructor
allows to pick a maximum pseudorapidity defined by the extent of the
assumed detector, to pick among some standard options of which particles
to analyze, and to allow for some standard mass assumptions, like that
all charged particles have the pion mass. Obviously this is only a
restricted set of possibilities.

Full flexibility can be obtained by deriving from the base class
`SlowJetHook`

to write your own `include`

method.
This will be presented with one final-state particle at a time, and
should return `true`

for those particles that should be
analyzed. It is also possible to return modified four-momenta and masses,
to take into account detector smearing effects or particle identity
misassignments, but you must respect *E^2 - p^2 = m^2*.

Alternatively you can modify the event record itself, or a copy of it
(if you want to keep the original intact). For instance, only final
particles are considered in the analysis, i.e. particles with positive
status code, so negative status code should then be assigned to those
particles that you do not want to see analyzed. Again four-momenta and
masses can be modified, subject to *E^2 - p^2 = m^2*.

The jet reconstructions is then based on sequential recombination with
progressive removal, using the *E* recombination scheme. To be
more specific, the algorithm works as follows.

- Each particle to be analyzed defines an original cluster. It has a
well-defined four-momentum and mass at input. From this information the
triplet
*(pT, y, phi)*is calculated, i.e. the transverse momentum, rapidity and azimuthal angle of the cluster. - Define distance measures of all clusters
*i*to the beam*d_iB = pT_i^2p*

and of all pairs*(i,j)*relative to each other*d_ij = min( pT_i^2p, pT_j^2p) DeltaR_ij^2 / R^2*

where*DeltaR_ij^2 = (y_i - y_j)^2 + (phi_i - phi_j)^2.*

The jet algorithm is determined by the user-selected*p*value, where*p = -1*corresponds to the anti-*kT*one,*p = 0*to the Cambridge/Aachen one and*p = 1*to the*kT*one. Also*R*is chosen by the user, to give an approximate measure of the size of jets. However, note that jets need not have a circular shape in*(y, phi)*space, so*R*can not straight off be interpreted as a jet radius. - Find the smallest of all
*d_iB*and*d_ij*. - If this is a
*d_iB*then cluster*i*is removed from the clusters list and instead added to the jets list. Optionally, a*pTjetMin*requirement is imposed, where only clusters with*pT > pTjetMin*are added to the jets list. If so, some of the analyzed particles will not be part of any final jet. - If instead the smallest measure is a
*d_ij*then the four-momenta of the*i*and*j*clusters are added to define a single new cluster. Convert this four-momentum to a new*(pT, y, phi)*triplet and update the list of*d_iB*and*d_ij*. - Return to step 3 until no clusters remain.

To do jet finding analyses you first have to set up a `SlowJet`

instance, where the arguments of the constructor specifies the details
of the subsequent analyses. Thereafter you can feed in events to it,
one at a time, and have them analyzed by the `analyze`

method.
Information on the resulting jets can be extracted by a few different methods.
The minimal procedure only requires one call per event to do the analysis.
We will begin by presenting it, and only afterwards some extensions.

**SlowJet::SlowJet(int power, double R, double pTjetMin = 0., double etaMax = 25., int select = 2, int massSet = 2, SlowJetHook* sjHookPtr = 0, bool useFJcore = true, bool useStandardR = true) **

create a `SlowJet`

instance, where
`argument`

** power ** :
tells (half) the power of the transverse-momentum dependence of the
distance measure,
`argumentoption `

** -1** : the anti-*kT* algorithm,
`argumentoption `

** 0** : the Cambridge/Aachen algorithm, and
`argumentoption `

** 1** : the *kT* algorithm.
`argument`

** R ** :
the *R* size parameter, which is crudely related to the radius of
the jet cone in *(y, phi)* space around the center of the jet.
`argument`

** pTjetMin ** (`default = `

) :
the minimum transverse momentum required for a cluster
to become a jet. By default all clusters become jets, and therefore
all analyzed particles are assigned to a jet.
For comparisons with perturbative QCD, however, it is only meaningful
to consider jets with a significant **0.0 GeV***pT*.
`argument`

** etaMax ** (`default = `

) :
the maximum +-pseudorapidity that the detector is assumed to cover.
If you pick a value above 20 there is assumed to be full coverage
(obviously only meaningful for theoretical studies).
**25.**`argument`

** select ** (`default = `

) :
tells which particles are analyzed,
**2**`argumentoption `

** 1** : all final-state particles,
`argumentoption `

** 2** : all observable final-state particles,
i.e. excluding neutrinos and other particles without strong or
electromagnetic interactions (the `isVisible()`

particle
method),
and
`argumentoption `

** 3** : only charged final-state particles.
`argument`

** massSet ** (`default = `

) : masses assumed for the particles
used in the analysis
**2**`argumentoption `

** 0** : all massless,
`argumentoption `

** 1** : photons are massless while all others are
assigned the *pi+-* mass, and
`argumentoption `

** 2** : all given their correct masses.
`argument`

** sjHookPtr ** (`default = `

) :
gives the possibility to send in your own selection routine for which
particles should be part of the analysis; see further below on the
**0**`SlowJetHook`

class. If this pointer is sent in nonzero,
`etaMax`

and `massSet`

are disregarded,
and `select`

only gives the basic selection, to which
the user can add further requirements.
`argument`

** useFJcore ** (`default = `

) : choice of code used for finding
the jets. Does not affect the outcome of the analysis, but only the speed,
and some more specialized options.
**true**`argumentoption `

** true** : use the `fjcore`

package of
`FastJet 3.0.5`

.
`argumentoption `

** false** : use the native `SlowJet`

implementation,
which gives a slower jet finding, but allows some extra options of
step-by-step jet joining.
`argument`

** useStandardR ** (`default = `

) : definition of **true***R*
distance between two jets. This switch is only meaningful for
`useFJcore = false`

; within the `fjcore`

package
the standard option below is always used.
`argumentoption `

** true** : standard, as described above,
*DeltaR_ij^2 = (y_i - y_j)^2 + (phi_i - phi_j)^2.*
`argumentoption `

** false** : alternative,
*DeltaR_ij^2 = 2 (cosh(y_i - y_j) - cos(phi_i - phi_j))*,
which corresponds to the rim of the "deformed cone" giving a constant
invariant mass between the two partons considered (for fixed
masses and transverse momenta).

**bool SlowJet::analyze( const Event& event) **

performs a jet finding analysis, where
`argument`

** event ** : is an object of the `Event`

class,
most likely the `pythia.event`

one.

If the routine returns `false`

the analysis failed,
but currently this is not foreseen ever to happen.

After the analysis has been performed, a few `SlowJet`

class methods are available to return the result of the analysis:

**int SlowJet::sizeOrig() **

gives the original number of particles (and thus clusters) that the
analysis starts with.

**int SlowJet::sizeJet() **

gives the number of jets found, with jets numbered 0 through
`sizeJet() - 1`

, and ordered in terms of decreasing
transverse momentum values w.r.t. the beam axis,

**double SlowJet::pT(i) **

gives the transverse momentum *pT* of the *i*'th jet,

**double SlowJet::y(int i) **

**double SlowJet::phi(int i) **

gives the rapidity *y* and azimuthal angle *phi*
of the center of the *i*'th jet (defined by the vector sum
of constituent four-momenta),

**Vec4 SlowJet::p(int i) **

**double SlowJet::m(int i) **

gives a `Vec4`

corresponding to the four-momentum
sum of the particles assigned to the *i*'th jet, and
the invariant mass of this four-vector,

**int SlowJet::multiplicity(int i) **

gives the number of particles clustered into the *i*'th jet,

**vector<int> SlowJet::constituents(int i) **

gives a list of the indices of the particles that have been
clustered into the *i*'th jet,

**vector<int> SlowJet::clusConstituents(int i) **

gives a list of the indices of the particles that have been
clustered into the *i*'th cluster, at the current stage of
the clustering process,

**int SlowJet::jetAssignment(int i) **

gives the index of the jet that the particle *i* of the event
record belongs to, or -1 if there is no jet containing particle
*i*,

**void SlowJet::removeJet(int i) **

removes the *i*'th jet,

**void SlowJet::list() **

provides a listing of the basic jet information from above.

These are the basic methods. For more sophisticated usage
it is possible to trace the clustering, one step at a time.
It requires the native jet finding code, `useFJcore = false`

in the constructor. If so, the `setup`

method should be used
to read in the event and find the initial smallest distance. Each subsequent
`doStep`

will then do one cluster joining and find the new
smallest distance. You can therefore interrogate which clusters will be
joined next before the joining actually is performed. Alternatively you
can take several steps in one go, or take steps down to a predetermined
number of jets plus remaining clusters.

**bool SlowJet::setup( const Event& event) **

selects the particles to be analyzed, calculates initial distances,
and finds the initial smallest distance.
`argument`

** event ** : is an object of the `Event`

class,
most likely the `pythia.event`

one.

If the routine returns `false`

the setup failed,
but currently this is not foreseen ever to happen.

**bool SlowJet::doStep() **

do the next step of the clustering. This can either be that two
clusters are joined to one, or that a cluster is promoted to a jet
(which is discarded if its *pT* value is below
`pTjetMin`

).

The routine will only return `false`

if there are no
clusters left, or if `useFJcore = true`

.

**bool SlowJet::doNSteps(int nStep) **

calls the `doStep()`

method `nStep`

times,
if possible. Will return `false`

if the list of clusters
is emptied before then. The stored jet information is still perfectly
fine; it is only the number of steps that is wrong. Will also return
`false`

if `useFJcore = true`

.

**bool SlowJet::stopAtN(int nStop) **

calls the `doStep()`

method until a total of `nStop`

jet and cluster objects remain. Will return `false`

if this
is not possible, specifically if the number of objects already is smaller
than `nStop`

when the method is called. The stored jet and
cluster information is still perfectly fine; it only does not have the
expected multiplicity. Will also return `false`

if
`useFJcore = true`

.

**int SlowJet::sizeAll() **

gives the total current number of jets and clusters. The jets are
numbered 0 through `sizeJet() - 1`

, while the clusters
are numbered `sizeJet()`

through `sizeAll() - 1`

.
(Internally jets and clusters are represented by two separate arrays,
but are here presented in one flat range.) Note that the jets are ordered
in decreasing *pT*, while the clusters are not ordered.
When `useFJcore = true`

there are no intermediate steps, and
thus the number of clusters is zero (after jet finding).

With this extension, the methods `double pT(int i)`

,
`double y(int i)`

, `double phi(int i)`

,
`Vec4 p(int i)`

, `double m(int i)`

and
`int multiplicity(int i)`

can be used as before.
Furthermore, `list()`

generalizes

**void SlowJet::list(bool listAll = false, ostream& os = cout) **

provides a listing of the above information.
`argument`

** listAll ** : lists both jets and clusters if `true`

,
else only jets.

Three further methods can be used to check what will happen next.

**int SlowJet::iNext() **

**int SlowJet::jNext() **

**double SlowJet::dNext() **

if the next step is to join two clusters, then the methods give
the *(i,j, d_ij)* values, if instead to promote
a cluster to a jet then *(i, -1, d_iB)*.
If no clusters remain then *(-1, -1, 0.)*. Note that
the cluster numbers are offset as described above, i.e. they begin at
`sizeJet()`

, which of course easily could be subtracted off.
Also note that the jet and cluster lists are (moderately) reshuffled
in each new step. When `useFJcore = true`

there are no
intermediate steps, and thus these methods do not return meaningul
information.

Finally, and separately, the `SlowJetHook`

class can be used
for a more smart selection of which particles to include in the analysis.
For instance, isolated and/or high-*pT* muons, electrons and
photons should presumably be identified separately at an early stage,
and then not clustered to jets.

Technically, it works like with User Hooks.
That is, PYTHIA contains the base class. You write a derived class.
In the main program you create an instance of this class, and hand it
in to `SlowJet`

; in this case already as part of the
constructor.

The following methods should be defined in your derived class.

**SlowJetHook::SlowJetHook() **

**virtual SlowJetHook::~SlowJetHook() **

the constructor and destructor need not do anything, and if so you
need not write your own destructor.

**virtual bool SlowJetHook::include(int iSel, const Event& event, Vec4& pSel, double& mSel) **

is the main method that you will need to write. It will be called
once for each final-state particle in an event, subject to the
value of the `select`

switch in the `SlowJet`

constructor. The value `select = 2`

may be convenient
since then you do not need to remove e.g. neutrinos yourself, but
use `select = 1`

for full control. The method should then
return `true`

if you want to see particle included in the
jet clustering, and `false`

if not.
`argument`

** iSel ** : is the index in the event record of the
currently studied particle.
`argument`

** event ** : is an object of the `Event`

class,
most likely the `pythia.event`

one, where the currently
studied particle is found.
`argument`

** pSel ** : is at input the four-momentum of the
currently studied particle. You can change the values, e.g. to take
into account energy smearing in the detector, to define the initial
cluster value, without corrupting the event record itself.
`argument`

** mSel ** : is at input the mass of the currently studied
particle. You can change the value, e.g. to take into account
particle misidentification, to define the initial cluster value,
without corrupting the event record itself. Note that the changes of
`pSel`

and `mSel`

must be coordinated such that
*E^2 - p^2 = m^2* holds.

It is also possible to define further methods of your own.
One such could e.g. be called directly in the main program before the
`analyze`

method is called, to identify and bookkeep
some event properties you may not want to reanalyze for each
individual particle.