1\documentclass[12pt,a4]{article}
2
3
4\usepackage{a4wide}
5\usepackage{xspace}
6\usepackage{amsmath}
7\usepackage{amssymb}
8\usepackage{booktabs}
9\usepackage{graphicx}
10\usepackage{url}
11\usepackage[breaklinks=true]{hyperref}
12%\usepackage[colorlinks=true]{hyperref}
13\addtolength{\textwidth}{2cm}
14\addtolength{\oddsidemargin}{-1cm}
15\addtolength{\textheight}{2cm}
16\addtolength{\topmargin}{-2cm}
17
18\usepackage{color}
19\definecolor{comment}{rgb}{0,0.3,0}
20\definecolor{identifier}{rgb}{0.0,0,0.3}
21\usepackage{listings}
22\lstset{language=C++}
23\lstset{
24  columns=flexible,
25  basicstyle=\tt\small,
26  keywordstyle=,
27  identifierstyle=\color{black},
28  commentstyle=\tt\color{comment},
29  mathescape=true,
30  escapebegin=\color{comment},
31  showstringspaces=false,
32  keepspaces=true
33}
34
35%% \lstset{% general command to set parameter(s)
36%%   columns=fullflexible
37%%   basicstyle=\tt, % print whole listing small
38%%   keywordstyle=\color{black},
39%%   % underlined bold black keywords
40%%   identifierstyle=, % nothing happens
41%%   commentstyle=\color{comment}, % white comments
42%%   stringstyle=\ttfamily, % typewriter type for strings
43%%   showstringspaces=false} % no special string spaces
44
45
46\parskip 3pt
47
48% make tex more amenable to
49\global\emergencystretch = .9\hsize
50
51\newcommand{\fastjet}{\texttt{FastJet}\xspace}
52\newcommand{\contrib}{\texttt{Contrib}\xspace}
53\newcommand{\fjcontrib}{\texttt{\href{http://fastjet.hepforge.org/contrib/}{fjcontrib}}\xspace}
54\newcommand{\fjcore}{\texttt{fjcore}\xspace}
55\newcommand{\ktjet}{\texttt{KtJet}\xspace}
56\newcommand{\clhep}{\texttt{CLHEP}\xspace}
57% ttt includes some resizing of text so that things look nicer inline
58\newcommand{\ttt}[1]{{\small\texttt{#1}}}
59%\newcommand{\ttt}[1]{\scalebox{0.9}{\texttt{#1}}}
60%\newcommand{\ttt}[1]{\texttt{#1}}
61\newcommand{\comment}[1]{\textbf{[#1]}}
62\newcommand{\order}[1]{{\cal O}\left(#1\right)}
63\newcommand{\ie}{{\it i.e.}\ }
64\newcommand{\eg}{{\it e.g.}\ }
65\newcommand{\ee}{e^+e^-}
66%\newcommand{\Dzero}{D0\!\!\!/\xspace}
67\newcommand{\Dzero}{D\O\xspace}
68\newcommand{\GeV}{\,\text{GeV}}
69
70% some things that crop up often
71\newcommand{\PseudoJet}{\ttt{PseudoJet}\xspace}
72\newcommand{\PJ}{\ttt{PseudoJet}\xspace}
73\newcommand{\ClusterSequence}{\ttt{ClusterSequence}\xspace}
74\newcommand{\CS}{\ttt{ClusterSequence}\xspace}
75
76\newcommand{\throws}{{\it throws}}
77
78\title{\sf FastJet user manual%
79  \\ \large (for version
80  3.3.4%  %%%-VERSION-NUMBER (do not remove this comment; used
81             %  for automatic version-number changes; version number must
82             %  stay one a single line)
83  )
84}
85\author{Matteo Cacciari,$^{1,2}$ Gavin P. Salam$^{3,4,}$\footnote{On
86    leave from CERN, Theoretical Physics Department, Geneva,
87    Switzerland and from CNRS, UMR 7589, LPTHE, F-75005, Paris, France.}\; and Gregory Soyez$^{5}$\\[10pt]
88  \normalsize
89  $^1$LPTHE, UPMC Univ.~Paris 6 and CNRS UMR 7589, Paris, France\\
90  \normalsize
91  $^2$Universit\'e Paris Diderot, Paris, France\\
92  \normalsize
93  $^3$ Rudolf Peierls Centre for Theoretical Physics,\\[-5pt]
94  \normalsize
95  Clarendon Laboratory, University of Oxford, United Kingdom\\
96  \normalsize
97  $^4$ All Souls College, Oxford, United Kingdom\\
98  \normalsize
99  $^5$Institut de Physique Th\'eorique, CNRS, CEA Saclay, Universit\'e
100  Paris-Saclay, France
101%  $^3$CERN, Physics Department, Theory Unit, Geneva, Switzerland\\
102%  \normalsize
103}
104
105\date{}
106
107\begin{document}
108
109\maketitle
110
111\vspace{-10cm}
112\begin{flushright}
113  CERN-PH-TH/2011-297
114\end{flushright}
115\vspace{9cm}
116
117
118\begin{abstract}
119
120  \fastjet is a \ttt{C++} package that provides a broad range of jet
121  finding and analysis tools.
122  %
123  It includes efficient native implementations of all widely used $2\to 1$
124  sequential recombination jet algorithms for $pp$ and $e^+e^-$
125  collisions, as well as access to 3rd party jet algorithms through a
126  plugin mechanism, including all currently used cone algorithms.
127  %
128  \fastjet also provides means to facilitate the manipulation of jet
129  substructure, including some common boosted heavy-object taggers, as
130  well as tools for estimation of pileup and underlying-event noise
131  levels, determination of jet areas and subtraction or suppression
132  of noise in jets.
133
134\end{abstract}
135
136%----------------------------------------------------------------------
137\newpage
138\tableofcontents
139\newpage
140
141%----------------------------------------------------------------------
142\section{Introduction}
143
144
145
146
147Jets are the collimated sprays of hadrons that result from the
148fragmentation of a high-energy quark or gluon.
149%
150They tend to be visually obvious structures when one looks at an
151experimental event display, and by measuring their energy and
152direction one can approach the idea of the original ``parton'' that
153produced them.
154%
155Consequently jets are both an intuitive and quantitatively essential
156part of collider experiments, used in a vast array of analyses, from
157new physics searches to studies of Quantum Chromodynamics (QCD).
158%
159For any tool to be so widely used, its behaviour must be well defined
160and reproducible: it is not sufficient that one be able to visually
161identify jets, but rather one should have rules that project a set of
162particles onto a set of jets.
163%
164Such a set of rules is referred to as a jet algorithm.
165%
166Usually a jet algorithm involves one or more parameters that govern
167its detailed behaviour.
168%
169The combination of a jet algorithm and its parameters is known as a
170jet definition.
171%
172Suitable jet definitions can be applied to particles,
173calorimeter towers, or even to the partonic events of perturbative QCD
174calculations, with the feature that the jets resulting from these
175different kinds of input are not just physically close to the
176concept of partons, but can be meaningfully be compared to each other.
177
178Jet finding dates back to seminal work by Sterman and
179Weinberg~\cite{StermanWeinberg} and several reviews have been written
180describing the various kinds of jet finders, their different uses and
181properties, and even the history of the
182field, for example~\cite{Moretti:1998qx,RunII-jet-physics,Ellis:2007ib,Salam:2009jx,Ali:2010tw}.
183
184It is possible to classify most jet algorithms into one of two broad
185classes: sequential recombination algorithms and cone algorithms.
186
187Sequential recombination algorithms usually identify the pair of
188particles that are closest in some distance measure, recombine them,
189and then repeat the procedure over and again, until some stopping
190criterion is reached.
191%
192The distance measure is usually related to the structure of
193divergences in perturbative QCD.
194%
195The various sequential recombination algorithms differ mainly in their
196particular choices of distance measure and stopping criterion.
197
198Cone algorithms put together particles within specific conical angular
199regions, notably such that the momentum sum of the particles contained
200in a given cone coincides with the cone axis (a ``stable cone'').
201%
202Because QCD radiation and hadronisation leaves the direction of a
203parton's energy flow essentially unchanged, the stable cones are
204physically close in direction and energy to the original partons.
205%
206Differences between various cone algorithms are essentially to do with
207the strategy taken to search for the stable cones (e.g.\ whether
208iterative or exhaustive) and the procedure used to deal with cases
209where the same particle is found in multiple stable cones (e.g.\
210split--merge procedures).
211
212One of the aims of the \fastjet C++ library is to provide
213straightforward, efficient implementations for the majority of widely
214used sequential-recombination algorithms, both for hadron-hadron and
215$e^+e^-$ colliders, and easy access also to cone-type jet algorithms.
216%
217It is distributed under the terms of the GNU General Public License
218(GPL), either version 2 of the License~\cite{GPLv2} or (at your
219option) any later version.
220
221To help introduce the terminology used throughout \fastjet and this
222manual, let us consider the longitudinally-invariant $k_t$ algorithm
223for hadron colliders~\cite{ktexcl,ktincl}.
224%
225This was the first jet algorithm to be implemented in
226\fastjet~\cite{fastjet} and its
227structure, together with that of other sequential recombination
228algorithms, has played a key role in the design of \fastjet's interface.
229%
230The $k_t$ algorithm involves a (symmetric) distance measure, $d_{ij}$,
231between all pairs of particles $i$ and $j$,
232\begin{equation}
233  \label{eq:dij-illustr}
234  d_{ij} = d_{ji} = \min(p_{ti}^2, p_{tj}^2) \frac{\Delta R_{ij}^2}{R^2}\,,
235\end{equation}
236where $p_{ti}$ is the transverse momentum of particle $i$ with respect
237to the beam ($z$) direction and $\Delta R_{ij}^2 = (y_i - y_j)^2 +
238(\phi_i - \phi_j)^2$, with $y_i = \frac12 \ln \frac{E_i + p_{zi}}{E_i
239  - p_{zi}}$ and $\phi_i$ respectively $i$'s rapidity and azimuth.
240%
241The $k_t$ algorithm also involves a distance measure between every
242particle $i$ and the beam
243\begin{equation}
244  \label{eq:diB-illustr}
245  d_{iB} = p_{ti}^2\,.
246\end{equation}
247%
248$R$ in eq.~(\ref{eq:dij-illustr}), usually called the jet radius, is a
249parameter of the algorithm that determines its angular reach.
250%
251In the original, so-called ``exclusive'' formulation of the $k_t$
252algorithm~\cite{ktexcl} (proposed with $R\equiv 1$), one identifies
253the smallest of the $d_{ij}$ and $d_{iB}$.
254%
255If it is a $d_{ij}$, one replaces $i$ and $j$ with a single new object
256whose momentum is $p_i + p_j$ --- often this object is called a
257``pseudojet'', since it is neither a particle, nor yet a full
258jet.\footnote{In \fastjet we actually will use \texttt{PseudoJet} to denote any
259  generic object with 4-momentum.}
260%
261If instead the smallest distance is a $d_{iB}$, then one removes $i$
262from the list of particles/pseudojets and declares it to be part of
263the ``beam'' jet.
264%
265One repeats this procedure until the smallest $d_{ij}$ or $d_{iB}$ is
266above some threshold $d_{\text{cut}}$; all particles/pseudojets that
267are left are then that event's (non-beam) jets.%
268%
269\footnote{One can also choose to have the exclusive algorithm stop
270  when it reaches a configuration with a predetermined number of
271  remaining particles/pseudojets, which then become the event's
272  (non-beam) jets.}
273
274In the ``inclusive'' formulation of the $k_t$ algorithm~\cite{ktincl},
275the $d_{ij}$ and $d_{iB}$ distances are the same as above.
276%
277The only difference is that when a $d_{iB}$ is smallest, then $i$ is
278removed from the list of particles/pseudojets and added to the list of
279final ``inclusive'' jets (this is instead of being incorporated into a
280beam jet).
281%
282There is no $d_{\text{cut}}$ threshold and the clustering continues
283until no particles/pseudojets remain.
284%
285Of the final jets, generally only those above some transverse momentum
286are actually used.\footnote{This transverse momentum cut has some
287  similarity to $d_{\text{cut}}$ in the exclusive case, since in the
288  exclusive case pseudojets with $p_t < \sqrt{d_{\text{cut}}}$ become
289  part of the beam jets, i.e.\ are discarded.}
290%
291Because the distance measures are the same in the inclusive and
292exclusive algorithms, the clustering sequence is common to both
293formulations (at least up to $d_{\text{cut}}$), a property that will
294be reflected in \fastjet's common interface to both formulations.
295
296Having seen these descriptions, the reader may wonder why a special
297library is needed for sequential-recombination jet finding.
298%
299Indeed, the $k_t$ algorithm can be easily implemented in just a few
300dozen lines of code.
301%
302The difficulty that arises, however, is that at hadron colliders,
303clustering is often performed with several hundreds or even thousands
304of particles.
305%
306Given $N$ particles, there are $N(N-1)/2$ $d_{ij}$ distances to
307calculate, and since one must identify the smallest of these
308$\order{N^2}$ distances at each of $\order{N}$ iterations of the
309algorithm, original implementations of the $k_t$
310algorithm~\cite{KtClus,KtJet} involved $\order{N^3}$ operations to
311perform the clustering.
312%
313In practice this translates to about 1\,s for $N=1000$. Given that
314events with pileup can have multiplicities significantly in excess of
3151000 and that it can be necessary to cluster hundreds of millions of
316events, $N^3$ timing quickly becomes prohibitive, all the more so in
317time-critical contexts such as online triggers.
318%
319To alleviate this problem, \fastjet makes use of the
320observation~\cite{fastjet} that the smallest pairwise distance remains
321the same if one uses the following alternative (non-symmetric)
322$d_{ij}$ distance measure:
323\begin{equation}
324  \label{eq:dij-illustr-asym}
325  d_{ij} = p_{ti}^2 \frac{\Delta R_{ij}^2}{R^2}\,,\qquad
326  d_{ji} = p_{tj}^2 \frac{\Delta R_{ij}^2}{R^2}
327\end{equation}
328For a given $i$, the smallest of the $d_{ij}$ is simply found by
329choosing the $j$ that minimises the $\Delta R_{ij}$, i.e.\ by
330identifying $i$'s geometrical nearest neighbour on the $y-\phi$
331cylinder.
332%
333Geometry adds many constraints to closest pair and nearest neighbour
334type problems, e.g.\ if $i$ is geometrically close to $k$ and $j$ is
335geometrically close to $k$, then $i$ and $j$ are also geometrically
336close; such a property is not true for the $d_{ij}$. The factorisation
337of the problem into momentum and geometrical parts makes it possible
338to calculate and search for minima among a much smaller set of
339distances.
340%
341This is sufficiently powerful that with the help of the external
342Computational Geometry Algorithms Library (CGAL)~\cite{CGAL}
343(specifically, its Delaunay triangulation modules), \fastjet achieves
344expected $N\ln N$ timing for many sequential recombination algorithms.
345%
346This $N\ln N$ strategy is supplemented in \fastjet with several other
347implementations, also partially based on geometry, which help optimise
348clustering speed up to moderately large multiplicities, $N \lesssim
34930000$.
350%
351The timing for $N=1000$ is thus reduced to a few milliseconds.
352%
353The same techniques apply to a range of sequential recombination
354algorithms, described in section~\ref{sec:native-algs}.
355
356At the time of writing, sequential recombination jet algorithms are
357the main kind of algorithm in use at CERN's Large Hadron Collider
358(LHC), notably the anti-$k_t$ algorithm~\cite{antikt}, which simply
359replaces $p_{t}^2$ with $p_{t}^{-2}$ in
360eqs.~(\ref{eq:dij-illustr},\ref{eq:diB-illustr}). Sequential
361recombination algorithms were also widely used at HERA and LEP.
362%
363However at Fermilab's Tevatron, and in much preparatory LHC work, cone
364algorithms were used for nearly all studies.
365%
366For theoretical and phenomenological comparisons with these results,
367it is therefore useful to have straightforward access also to cone
368algorithm codes.
369%
370The main challenge that would be faced by someone wishing to write
371their own implementation of a given cone algorithm comes from the
372large number of details that enter into a full specification of such
373algorithms, e.g.\ the precise manner in which stable cones are found,
374or in which the split--merge step is carried out.
375%
376The complexity is such that in many cases the written descriptions
377that exist of specific cone algorithms are simply insufficient to
378allow a user to correctly implement them.
379%
380Fortunately, in most cases, the authors of cone algorithms have
381provided public implementations and these serve as a reference for the
382algorithm.
383%
384While each tends to involve a different interface, a different
3854-momentum type, etc.,
386%
387\fastjet has a ``plugin'' mechanism, which makes it possible
388to provide a uniform interface to these different third party jet
389algorithms.
390%
391Many plugins (and the corresponding third party code) are distributed
392with \fastjet.
393%
394Together with the natively-implemented sequential-recombination
395algorithms, they ensure easy access to all jet algorithms used at
396colliders in the past decade (section~\ref{sec:plugins}).
397%
398Our distribution of this codebase is complemented with some limited
399curatorial activity, e.g.\ solving bugs that become apparent when
400updating compiler versions, providing a common build infrastructure,
401etc.
402%
403
404In the past few years, research into jets has evolved significantly
405beyond the question of just ``finding'' jets.
406%
407This has been spurred by two characteristics of CERN's LHC
408experimental programme.
409%
410The first is that the LHC starts to probe momentum scales that are far
411above the the electroweak scale, $M_{EW}$, e.g.\ in the search for new
412particles or the study of high-energy $WW$ scattering.
413%
414However, even in events with transverse momenta $\gg M_{EW}$, there can
415simultaneously be hadronic physics occurring on the electroweak scale
416(e.g.\ hadronic $W$ decays).
417%
418Jet finding then becomes a multi-scale problem, one manifestation of
419which is that hadronic decays of W's, Z's and top quarks may be so
420collimated that they are entirely contained within a single jet.
421%
422The study of this kind of problem has led to the development of a wide
423array of jet substructure tools for identifying ``boosted'' object
424decays, as reviewed in~\cite{Abdesselam:2010pt}.
425%
426As was the situation with cone algorithms a few years ago, there is
427considerable fragmentation among these different tools, with some
428public code available from a range of different sources, but
429interfaces that differ from one tool to the next.
430%
431Furthermore, the facilities provided with version 2 of \fastjet did not
432always easily accommodate tools to manipulate and transform jets.
433%
434Version 3 of \fastjet aims to improve this situation, providing
435implementations of the most common jet substructure tools\footnote{To
436  some extent there is overlap here with SpartyJet~\cite{SpartyJet},
437  however we believe there are benefits to being able to easily carry
438  jet structure manipulations natively within the framework of
439  \fastjet.} and a framework to help guide third party authors who wish
440to write further such tools using a standard interface
441(section~\ref{sec:transformers}).
442%
443In the near future we also envisage the creation of a \fastjet
444``contrib'' space, to provide a common location for access to these
445new tools as they are developed.
446
447The second characteristic of the LHC that motivates facilities beyond
448simple jet finding in \fastjet is the need to use jets in high-noise
449environments.
450%
451This is the case for proton-proton ($pp$) collisions, where in
452addition to the $pp$ collision of interest there are many additional
453soft ``pileup'' $pp$ collisions, which contaminate jets with a high
454density of low-momentum particles.
455%
456A similar problem of ``background contamination'' arises also for
457heavy-ion collisions (also at RHIC) where the underlying event in the
458nuclear collision can generate over a TeV of transverse momentum per
459unit rapidity, part of which contaminates any hard jets that are
460present.
461%
462One way of correcting for this involves the use of jet ``areas'',
463which provide a measure of a given jet's susceptibility to soft
464contamination.
465%
466Jet areas can be determined for example by examining the clustering of
467a large number of additional, infinitesimally soft ``ghost''
468particles~\cite{CSSAreas}.
469%
470Together with a determination of the level of pileup or
471underlying-event noise in a specific event, one can then perform
472event-by-event and
473jet-by-jet subtraction of the
474contamination~\cite{cs,Cacciari:2010te}.
475%
476\fastjet allows jet clustering to be performed in such a way that the
477jet areas are determined at the same time as the jets are identified,
478simply by providing an ``area definition'' in addition to the jet
479definition (section~\ref{sec:areas}).
480%
481Furthermore it provides the tools needed to estimate the density of
482noise contamination in an event and to subtract the appropriate amount
483of noise from each jet (section~\ref{sec:BackgroundEstimator}).
484%
485The interface here shares a number of characteristics with the
486substructure tools, some of which also serve to remove noise
487contamination. Both the substructure and pileup removal make use
488also of a ``selectors'' framework for specifying and combining simple
489cuts (section~\ref{sect:selectors}).
490
491While \fastjet provides a broad range of facilities, usage for basic
492jet finding is straightforward.
493%
494To illustrate this, a quick-start guide is provided in
495section~\ref{sec:quick-start}, while the core classes
496(\ttt{PseudoJet}, \ttt{JetDefinition} and \ttt{ClusterSequence}) are
497described in section~\ref{sec:core-classes}.
498%
499For more advanced usage, one of the design considerations in \fastjet
500has been to favour user extensibility, for example through plugins,
501selectors, tools, etc. This is one of the topics covered in the
502appendices.
503%
504Further information is also available from the extensive
505``doxygen'' documentation, available online at
506\url{http://fastjet.fr}.
507
508
509%======================================================================
510\section{Quick-start guide}
511\label{sec:quick-start}
512
513For the impatient, the \fastjet package can be set up and run as follows.
514
515\begin{itemize}
516\item Download the code and the unpack it
517\begin{verbatim}
518 curl -O http://fastjet.fr/repo/fastjet-X.Y.Z.tar.gz
519 tar zxvf fastjet-X.Y.Z.tar.gz
520 cd fastjet-X.Y.Z/
521\end{verbatim}
522replacing \ttt{X.Y.Z} with the appropriate version number. On some
523systems you may need to replace ``\texttt{curl -O}'' with
524``\texttt{wget}''.
525
526\item Compile and install (choose your own preferred prefix), and when
527you're done go back to the original directory
528\begin{verbatim}
529 ./configure --prefix=`pwd`/../fastjet-install
530 make
531 make check
532 make install
533 cd ..
534\end{verbatim}
535If you copy and paste the above lines from one very widespread PDF
536viewer, you should note that the first line contains \emph{back-quotes}
537not forward quotes but that your PDF viewer may nevertheless paste
538forward quotes, causing problems down the line (the issue arises again
539below).
540
541\item
542Now paste the following piece of code into a file called \tt{short-example.cc}
543\begin{lstlisting}
544#include "fastjet/ClusterSequence.hh"
545#include <iostream>
546using namespace fastjet;
547using namespace std;
548
549int main () {
550  vector<PseudoJet> particles;
551  // an event with three particles:   px    py  pz      E
552  particles.push_back( PseudoJet(   99.0,  0.1,  0, 100.0) );
553  particles.push_back( PseudoJet(    4.0, -0.1,  0,   5.0) );
554  particles.push_back( PseudoJet(  -99.0,    0,  0,  99.0) );
555
556  // choose a jet definition
557  double R = 0.7;
558  JetDefinition jet_def(antikt_algorithm, R);
559
560  // run the clustering, extract the jets
561  ClusterSequence cs(particles, jet_def);
562  vector<PseudoJet> jets = sorted_by_pt(cs.inclusive_jets());
563
564  // print out some info
565  cout << "Clustered with " << jet_def.description() << endl;
566
567  // print the jets
568  cout <<   "        pt y phi" << endl;
569  for (unsigned i = 0; i < jets.size(); i++) {
570    cout << "jet " << i << ": "<< jets[i].pt() << " "
571                   << jets[i].rap() << " " << jets[i].phi() << endl;
572    vector<PseudoJet> constituents = jets[i].constituents();
573    for (unsigned j = 0; j < constituents.size(); j++) {
574      cout << "    constituent " << j << "'s pt: "<< constituents[j].pt() << endl;
575    }
576  }
577}
578\end{lstlisting}
579
580% force \rm, because of a some problem from lstlisting
581\item \rm Then compile and run it with
582\begin{verbatim}
583 g++ short-example.cc -o short-example \
584     `fastjet-install/bin/fastjet-config --cxxflags --libs --plugins`
585 ./short-example
586\end{verbatim}
587(watch out, once again, for the back-quotes if you cut and paste from the PDF).
588\end{itemize}
589\noindent
590The output will consist of a banner, followed by the lines
591\begin{verbatim}
592Clustering with Longitudinally invariant anti-kt algorithm with R = 0.7
593and E scheme recombination
594        pt y phi
595jet 0: 103 0 0
596    constituent 0's pt: 99.0001
597    constituent 1's pt: 4.00125
598jet 1: 99 0 3.14159
599    constituent 0's pt: 99
600\end{verbatim}
601
602More evolved example programs, illustrating many of the capabilities of \fastjet,
603are available in the \ttt{example/} subdirectory of the
604\fastjet distribution.
605
606%----------------------------------------------------------------------
607\section{Core classes}
608\label{sec:core-classes}
609
610All classes are contained in the \ttt{fastjet} namespace. For brevity this namespace
611will usually not be explicitly written below, with the possible exception of the first
612appearance of a \fastjet class, and code excerpts will
613assume that a ``\ttt{using namespace fastjet;}'' statement is present in the user
614code.
615For basic
616usage, the user is exposed to three main classes:
617\begin{lstlisting}
618  class fastjet::PseudoJet;
619  class fastjet::JetDefinition;
620  class fastjet::ClusterSequence;
621\end{lstlisting}
622\ttt{PseudoJet} provides a jet object with a four-momentum and some
623internal indices to situate it in the context of a jet-clustering
624sequence.
625%
626The class \ttt{JetDefinition} contains a specification of how
627jet clustering is to be performed.
628%
629\ttt{ClusterSequence} is the class that carries out
630jet-clustering and provides access to the final jets.
631
632
633%......................................................................
634\subsection{\tt fastjet::PseudoJet}
635\label{sec:PseudoJet}
636
637
638All jets, as well as input particles to the clustering (optionally)
639are \ttt{PseudoJet} objects.  They can be created using one of the
640following constructors
641\begin{lstlisting}
642  PseudoJet (double px, double py, double pz, double  E);
643  template<class T> PseudoJet (const T & some_lorentz_vector);
644\end{lstlisting}
645where the second form allows the initialisation to be obtained from
646any class \ttt{T} that allows subscripting to return the components of
647the momentum (running from $0\ldots3$ in the order $p_x,p_y,p_z,E$).
648%%
649The default constructor for a \PJ sets the momentum components to
650zero.
651
652The \ttt{PseudoJet} class includes the following member functions for
653accessing the components
654{
655\begin{lstlisting}
656  double E()        const ; // returns the energy component
657  double e()        const ; // returns the energy component
658  double px()       const ; // returns the x momentum component
659  double py()       const ; // returns the y momentum component
660  double pz()       const ; // returns the z momentum component
661  double phi()      const ; // returns the azimuthal angle in range $0\ldots2\pi$
662  double phi_std()  const ; // returns the azimuthal angle in range $-\pi\ldots\pi$
663  double rap()      const ; // returns the rapidity
664  double rapidity() const ; // returns the rapidity
665  double pseudorapidity() const ; // returns the pseudo-rapidity
666  double eta()      const ; // returns the pseudo-rapidity
667  double pt2()      const ; // returns the squared transverse momentum
668  double pt()       const ; // returns the transverse momentum
669  double perp2()    const ; // returns the squared transverse momentum
670  double perp()     const ; // returns the transverse momentum
671  double m2()       const ; // returns squared invariant mass
672  double m()        const ; // returns invariant mass ($-\sqrt{-m^2}$ if $m^2 < 0$)
673  double mt2()      const ; // returns the squared transverse mass = $k_t^2+m^2$
674  double mt()       const ; // returns the transverse mass
675  double mperp2()   const ; // returns the squared transverse mass = $k_t^2+m^2$
676  double mperp()    const ; // returns the transverse mass
677  double operator[] (int i) const; // returns component i
678  double operator() (int i) const; // returns component i
679
680  /// return a valarray containing the four-momentum (components 0-2
681  /// are 3-momentum, component 3 is energy).
682  valarray<double> four_mom() const;
683\end{lstlisting}}
684%
685\noindent The reader may have observed that in some cases more than
686one name can be used to access the same quantity. This is intended to
687reflect the diversity of common usages within the
688community.\footnote{The \texttt{pt()}, \texttt{pt2()}, \texttt{mt()},
689  \texttt{mt2()} names are available only from version 3.0.1 onwards.}
690
691There are two ways of associating user information with a
692\ttt{PseudoJet}.
693%
694The simpler method is through an integer called the user index
695\begin{lstlisting}
696  /// set the user_index, intended to allow the user to label the object (default is -1)
697  void set_user_index(const int index);
698  /// return the user_index
699  int user_index() const ;
700\end{lstlisting}
701A more powerful method, new in \fastjet 3, involves passing a pointer to a derived class
702of \ttt{PseudoJet::UserInfoBase}. The two essential calls are
703\begin{lstlisting}
704  /// set the pointer to user information (the PseudoJet will then own it)
705  void set_user_info(UserInfoBase * user_info);
706  /// retrieve a reference to a dynamic cast of type L of the user info
707  template<class L> const L & user_info() const;
708\end{lstlisting}
709Further details are to be found in appendix~\ref{app:user-info} and in
710\ttt{example/09-user\_info.cc}.
711
712A \verb:PseudoJet: can be reset with
713\begin{lstlisting}
714  /// Reset the 4-momentum according to the supplied components, put the user
715  /// and history indices and user info back to their default values (-1, unset)
716  inline void reset(double px, double py, double pz, double E);
717  /// Reset just the 4-momentum according to the supplied components,
718  /// all other information is left unchanged
719  inline void reset_momentum(double px, double py, double pz, double E);
720\end{lstlisting}
721and similarly taking as argument a templated
722\verb:some_lorentz_vector: or a \verb:PseudoJet: (in the latter case,
723or when \verb:some_lorentz_vector: is of a type derived from
724\verb:PseudoJet:, \ttt{reset} also copies the user and internal indices and
725user-info).
726
727Additionally, the \ttt{+}, \ttt{-}, \ttt{*} and \ttt{/} operators are
728defined, with \ttt{+}, \ttt{-} acting on pairs of \ttt{PseudoJet}s and
729\ttt{*}, \ttt{/} acting on a \ttt{PseudoJet} and a \ttt{double}
730coefficient.
731%
732The analogous \ttt{+=}, etc., operators, are also defined.\footnote{
733  The \texttt{+}, \texttt{-} operators return a \texttt{PseudoJet}
734  with default user information; the \texttt{*} and \texttt{/} operators
735  return a \texttt{PseudoJet} with the same user information as the
736  original \texttt{PseudoJet}; the
737  \texttt{+=}, \texttt{-=}, etc., operators all preserve the user
738  information of the \texttt{PseudoJet} on the left-hand side of the operator.  }
739
740There are also equality testing operators: \ttt{(jet1 == jet2)}
741returns true if the two jets have identical 4-momenta, structural
742information and user information;
743%
744the \ttt{(jet == 0.0)} test returns true if all the components of the
7454-momentum are zero.
746%
747The \ttt{!=} operator works analogously.
748
749Finally, we also provide routines for taking an unsorted vector of
750\ttt{PseudoJet}s and returning a sorted vector,
751\begin{lstlisting}
752  /// return a vector of jets sorted into decreasing transverse momentum
753  vector<PseudoJet> sorted_by_pt(const vector<PseudoJet> & jets);
754
755  /// return a vector of jets sorted into increasing rapidity
756  vector<PseudoJet> sorted_by_rapidity(const vector<PseudoJet> & jets);
757
758  /// return a vector of jets sorted into decreasing energy
759  vector<PseudoJet> sorted_by_E(const vector<PseudoJet> & jets);
760\end{lstlisting}
761These will typically be used on the jets returned by
762\ttt{ClusterSequence}.
763
764A number of further \PJ member functions provide access to information
765on a jet's structure. They are documented below in
766sections~\ref{sec:constituents} and \ref{sec:composite-jet}.
767
768%......................................................................
769\subsection{\tt fastjet::JetDefinition}
770\label{sec:JetDefinition}
771
772The class \ttt{JetDefinition} contains a full specification
773of how to carry out the clustering. According to the Les Houches convention
774detailed in~\cite{Buttar:2008jx}, a `jet definition' should include the
775jet algorithm name, its parameters (often the radius $R$) and the
776recombination scheme.
777Its constructor is
778%
779\begin{lstlisting}
780  JetDefinition(fastjet::JetAlgorithm jet_algorithm,
781                double R,
782                fastjet::RecombinationScheme recomb_scheme = E_scheme,
783                fastjet::Strategy strategy = Best);
784\end{lstlisting}
785%
786The jet algorithm is one of the entries of the \ttt{JetAlgorithm}
787\ttt{enum}:\footnote{As of v2.3, the \ttt{JetAlgorithm} name replaces the old \ttt{JetFinder}
788one, in keeping with the Les Houches convention. Backward compatibility is
789assured at the user level by a typedef and a doubling of the methods' names.
790Backward compatibility (with versions $<$ 2.3) is however broken for
791user-written derived classes of \ttt{ClusterSequence}, as the protected
792variables \ttt{\_default\_jet\_finder} and  \ttt{\_jet\_finder} have been
793replaced by \ttt{\_default\_jet\_algorithm} and \ttt{\_jet\_algorithm}.}
794\begin{lstlisting}
795  enum JetAlgorithm {kt_algorithm, cambridge_algorithm,
796                     antikt_algorithm, genkt_algorithm,
797                     ee_kt_algorithm, ee_genkt_algorithm, ...};
798\end{lstlisting}
799Each algorithm is described in detail in section~\ref{sec:native-algs}.
800%
801The $\ldots$ represent additional values that are present for
802internal or testing purposes. They include
803\ttt{plugin\_algorithm}, automatically set when plugins are used
804(section~\ref{sec:plugins}) and  \ttt{undefined\_jet\_algorithm},
805which is the value set in \ttt{JetDefinition}'s default constructor.
806%}
807
808
809The parameter \texttt{R} specifies the value of $R$ that appears in
810eq.~(\ref{eq:dij-illustr}) and in the various definitions of
811section~\ref{sec:native-algs}.
812%
813For one algorithm, \verb:ee_kt_algorithm:, there is no $R$ parameter,
814so the constructor is to be called without the \verb:R: argument.
815% \begin{lstlisting}
816%   JetDefinition(JetAlgorithm jet_algorithm,
817%                 RecombinationScheme recomb_scheme = E_scheme,
818%                 Strategy strategy = Best);
819% \end{lstlisting}
820%
821For the generalised $k_t$ algorithm and its $e^+e^-$ version, one
822requires $R$ and (immediately after $R$) an extra
823parameter $p$.
824%, and the following constructor should then be used
825% %
826% \begin{lstlisting}
827%   JetDefinition(JetAlgorithm jet_algorithm,
828%                 double R,
829%                 double p,
830%                 RecombinationScheme recomb_scheme = E_scheme,
831%                 Strategy strategy = Best);
832% \end{lstlisting}
833%
834Details are to be found in sections~\ref{sec:genkt}--\ref{sec:kt-ee-alg}.
835%
836If the user calls a constructor with the incorrect number of arguments
837for the requested jet algorithm, a \ttt{fastjet::Error()} exception
838will be thrown with an explanatory message.
839%
840
841The recombination scheme is set by an \ttt{enum} of type
842\ttt{RecombinationScheme}, and it is related to the choice of how to
843recombine the 4-momenta of \ttt{PseudoJet}s during the clustering procedure.
844The default in \fastjet is the $E$-scheme, where the four components of
845two 4-vectors are simply added.
846%
847This scheme is used when no explicit choice is made in the
848constructor.
849%
850Further recombination schemes are described below in
851section~\ref{sec:recomb_schemes}.
852
853
854The strategy selects the algorithmic strategy to use while clustering
855and is an \ttt{enum} of type \ttt{Strategy}. The default option of
856\ttt{Best} automatically determines and selects a strategy that
857should be close to optimal in speed for each event, based on its
858multiplicity.
859%
860A discussion of the main available strategies together with their
861performance is given in appendix~\ref{app:strategies}.
862%
863Different strategies give identical clustering results, except
864potentially in the presence of distance degeneracies, where different
865strategies may resolve those degeneracies differently.
866
867A textual description of the jet definition can be obtained by a call
868to the member function \ttt{std::string description()}.
869
870As of \fastjet version 3.1, the \ttt{JetDefinition} class allows one
871to directly perform the clustering and access the inclusive jets through
872a \ttt{()} operator:
873\begin{lstlisting}
874  template<class L> std::vector<PseudoJet> JetDefinition::operator()(
875                                         const std::vector<L> & particles
876					 ) const;
877\end{lstlisting}
878Doing
879\begin{lstlisting}
880  fastjet::JetDefinition AKT4(fastjet::antikt_algorithm,0.4);
881  vector<fastjet::PseudoJet> akt4_jets = AKT4(particles);
882\end{lstlisting}
883returns the list of all the inclusive jets given by clustering with
884the anti-$k_t$ algorithm with radius parameter $R=0.4$.
885%
886Jets from the anti-$k_t$ algorithm and other hadron-collider
887algorithms are returned sorted in decreasing transverse momentum,
888while those from $e^+e^-$ algorithms are returned sorted in decreasing
889energy.
890%
891This behaviour differs from that of
892\ttt{ClusterSequence::inclusive\_jets()}, where the ordering of the
893jets is not a priori determined (i.e.\ the user must manually sort the
894jets themselves).
895
896%......................................................................
897\subsection{\tt fastjet::ClusterSequence}
898\label{sec:ClusterSequence}
899
900To run the jet clustering, create a \ttt{ClusterSequence}
901object
902through the following constructor
903\begin{lstlisting}
904  template<class L> ClusterSequence(const std::vector<L> & input_particles,
905                                    const JetDefinition & jet_def);
906\end{lstlisting}
907where \ttt{input\_particles} is the vector of initial particles of any
908type (\ttt{PseudoJet}, \ttt{HepLorentzVector}, etc.) that can be
909used to initialise a \ttt{PseudoJet} and \ttt{jet\_def} contains
910the full specification of the clustering (see Section
911\ref{sec:JetDefinition}).
912
913%......................................................................
914\subsubsection{Accessing inclusive jets}
915
916Inclusive jets correspond to all objects that have undergone a
917``beam'' clustering (i.e. $d_{iB}$ recombination) in the description
918following Eq.~(\ref{eq:diB-illustr}).
919%
920For nearly all hadron-collider algorithms, the ``inclusive'' jets
921above some given transverse momentum cut are the ones usually just
922referred to as the ``jets''.
923
924To access inclusive jets, the following member function should be used
925\begin{lstlisting}
926  /// return a vector of all jets (in the sense of the inclusive
927  /// algorithm) with pt >= ptmin.
928  vector<PseudoJet> inclusive_jets (const double ptmin = 0.0) const;
929\end{lstlisting}
930where \ttt{ptmin} may be omitted, then implicitly taking the value
931zero.
932%
933Note that the order in which the inclusive jets are provided depends
934on the jet algorithm. To obtain a specific ordering, such as
935decreasing $p_t$, the user should perform a sort themselves, e.g.\
936with the \ttt{sorted\_by\_pt(...)} function, described in
937section~\ref{sec:PseudoJet}.
938
939With a zero transverse momentum cut, the number of jets found in the
940event is not an infrared safe quantity (adding a single soft particle
941can lead to one extra soft jet).
942%
943However it can still be useful to talk of all the objects returned by
944\ttt{inclusive\_jets()} as being ``jets'', e.g. in the context of the
945estimation underlying-event and pileup densities, cf.\
946section~\ref{sec:BackgroundEstimator}.
947
948%......................................................................
949\subsubsection{Accessing exclusive jets}
950There are two ways of accessing exclusive jets,
951one where one specifies
952$d_{cut}$, the other where one specifies that the clustering is taken
953to be stopped once it reaches the specified number of jets.
954\begin{lstlisting}
955  /// return a vector of all jets (in the sense of the exclusive algorithm) that would
956  /// be obtained when running the algorithm with the given dcut.
957  vector<PseudoJet> exclusive_jets (const double dcut) const;
958
959  /// return a vector of all jets when the event is clustered (in the exclusive sense)
960  /// to exactly njets. Throws an error if the event has fewer than njets particles.
961  vector<PseudoJet> exclusive_jets (const int njets) const;
962
963  /// return a vector of all jets when the event is clustered (in the exclusive sense)
964  /// to exactly njets. If the event has fewer than njets particles, it returns all
965  /// available particles.
966  vector<PseudoJet> exclusive_jets_up_to (const int njets) const;
967\end{lstlisting}
968%
969The user may also wish just to obtain information about the number of
970jets in the exclusive algorithm:
971\begin{lstlisting}
972  /// return the number of jets (in the sense of the exclusive algorithm) that would
973  /// be obtained when running the algorithm with the given dcut.
974  int n_exclusive_jets (const double dcut) const;
975\end{lstlisting}
976Another common query is to establish the $d_{\min}$ value associated
977with merging from $n+1$ to $n$ jets. Two member functions are
978available for determining this:
979\begin{lstlisting}
980  /// return the dmin corresponding to the recombination that went from n+1 to n jets
981  /// (sometimes known as $d_{n,n+1}$).
982  double exclusive_dmerge (const int n) const;
983
984  /// return the maximum of the dmin encountered during all recombinations up to the one
985  /// that led to an n-jet final state; identical to exclusive_dmerge, except in cases
986  /// where the dmin do not increase monotonically.
987  double exclusive_dmerge_max (const int n) const;
988\end{lstlisting}
989The first returns the $d_{\min}$  in going from $n+1$ to $n$ jets.
990%
991Occasionally however the $d_{\min}$ value does not increase
992monotonically during successive mergings and using a $d_{cut}$ smaller
993than the return value from \ttt{exclusive\_dmerge} does not guarantee
994an event with more than $n$ jets.
995%
996For this reason the second function \ttt{exclusive\_dmerge\_max} is
997provided --- using a $d_{cut}$ below its return value is guaranteed to
998provide a final state with more than $n$ jets, while using a larger
999value will return a final state with $n$ or fewer jets.
1000
1001For $\ee$ collisions, where it is usual to refer to $y_{ij} =
1002d_{ij}/Q^2$ ($Q$ is the total (visible) energy) \fastjet provides the
1003following methods:
1004\begin{lstlisting}
1005  double exclusive_ymerge (int njets);
1006  double exclusive_ymerge_max (int njets);
1007  int n_exclusive_jets_ycut (double ycut);
1008  std::vector<PseudoJet> exclusive_jets_ycut (double ycut);
1009\end{lstlisting}
1010which are relevant for use with the $\ee$ $k_t$ algorithm and with the
1011Jade plugin (section~\ref{sec:ee-jade}).
1012
1013%......................................................................
1014\subsubsection{Other functionality}
1015
1016\paragraph{Unclustered particles.}
1017%
1018Some jet algorithms (e.g.\ a number of the plugins in
1019section~\ref{sec:plugins}) have the property that not all particles
1020necessarily participate in the clustering.
1021%
1022In other cases, particles may take part in the clustering, but not end
1023up in any final inclusive jet.
1024%
1025Two member functions are provided to obtain the list of these
1026particles.
1027%
1028One is
1029\begin{lstlisting}
1030  vector<PseudoJet> unclustered = clust_seq.unclustered_particles();
1031\end{lstlisting}
1032which returns the list of particles that never took part in the clustering.
1033%
1034The other additionally returns objects that are the result of
1035clustering but that never made it into a inclusive jet (i.e.\ into a
1036``beam'' recombination):
1037\begin{lstlisting}
1038  vector<PseudoJet> childless = clust_seq.childless_pseudojets();
1039\end{lstlisting}
1040A practical example where this is relevant is with plugins that
1041perform pruning~\cite{Ellis:2009su}, since they include a condition for
1042vetoing certain recombinations.%
1043\footnote{To obtain the list of all initial particles that never end up in any
1044  inclusive jet, one should simply concatenate the vectors of
1045  constituents of all the childless \texttt{PseudoJet}s.}
1046
1047
1048\paragraph{Copying and transforming a ClusterSequence.}
1049%
1050A standard copy constructor is available for {\CS}s.
1051%
1052Additionally it is possible to copy the clustering history of a \CS
1053while modifying the momenta of the \ttt{PseudoJet}s at all (initial,
1054intermediate, final) stages of the clustering, with the \CS member
1055function
1056\begin{lstlisting}
1057  void transfer_from_sequence(const ClusterSequence & original_cs,
1058                              const FunctionOfPseudoJet<PseudoJet> * action_on_jets = 0);
1059\end{lstlisting}
1060\ttt{FunctionOfPseudoJet<PseudoJet>} is an abstract base class whose
1061interface provides a \ttt{PseudoJet operator()(const PseudoJet \& jet)}
1062function, i.e.\ a function of a \PJ that returns a \PJ (cf.\
1063appendix~\ref{app:function-of-pj}).
1064%
1065As the clustering history is copied to the target \CS, each \PJ in the
1066target \CS is set to the result of
1067\ttt{action\_on\_jet(original\_pseudojet)}.
1068%
1069One use case for this is if one wishes to obtain a Lorentz-boosted
1070copy of a \CS, which can be achieved as follows
1071\begin{lstlisting}
1072  #include "fastjet/tools/Boost.hh"
1073  // ...
1074  ClusterSequence original_cs(...);
1075  ClusterSequence boosted_cs;
1076  Boost boost(boost_4momentum);
1077  boosted_cs.transfer_from_sequence(cs, &boost);
1078\end{lstlisting}
1079
1080%......................................................................
1081\subsection{Recombination schemes}
1082\label{sec:recomb_schemes}
1083
1084
1085%
1086
1087When merging particles (i.e. \ttt{PseudoJet}s) during
1088the clustering procedure, one must
1089specify how to combine the momenta. The simplest procedure
1090($E$-scheme) simply adds the four-vectors.
1091%
1092This has been advocated as a standard in~\cite{RunII-jet-physics}, was
1093the main scheme in use during Run~II of the Tevatron, is currently
1094used by the LHC experiments, and is the default option in \fastjet.
1095%
1096Other choices are listed in
1097table~\ref{tab:RecombSchemes}, and are described below.
1098
1099
1100
1101\begin{table}
1102  \centering
1103  \begin{tabular}{|l|}\hline
1104    \ttt{E\_scheme}     \\\hline
1105    \ttt{pt\_scheme}    \\\hline
1106    \ttt{pt2\_scheme}   \\\hline
1107    \ttt{Et\_scheme}    \\\hline
1108    \ttt{Et2\_scheme}   \\\hline
1109    \ttt{BIpt\_scheme}  \\\hline
1110    \ttt{BIpt2\_scheme} \\\hline
1111    \ttt{WTA\_pt\_scheme} \\\hline
1112    \ttt{WTA\_modp\_scheme} \\\hline
1113  \end{tabular}
1114  \caption{Members of the \ttt{RecombinationScheme} enum; the schemes
1115    prefixed by ``BI''
1116    boost-invariant version of the $p_t$ and $p_t^2$ schemes
1117    (as defined in section~\ref{sec:recomb_schemes}).}
1118  \label{tab:RecombSchemes}
1119\end{table}
1120
1121\paragraph{Other schemes for $\boldsymbol{pp}$ collisions.} Other
1122schemes provided by earlier $k_t$-clustering implementations
1123\cite{KtClus,KtJet} are the $p_t$, $p_t^2$, $E_t$ and $E_t^2$ schemes. They
1124all incorporate a `preprocessing' stage to make the initial momenta
1125massless (rescaling the energy to be equal to the 3-momentum for the
1126$p_t$ and $p_t^2$ schemes, rescaling to the 3-momentum to be equal to
1127the energy in the $E_t$ and $E_t^2$ schemes). Then for all schemes the
1128recombination $p_r$ of $p_i$ and $p_j$ is a massless 4-vector
1129satisfying
1130\begin{subequations}
1131  \label{eq:recomb-weights}
1132  \begin{align}
1133    p_{t,r} &= p_{t,i} + p_{t,j}\,,\\
1134    \phi_r &= (w_i \phi_i + w_j \phi_j)/(w_i + w_j)\,,\\
1135    y_r &= (w_i y_i + w_j y_j)/(w_i + w_j)\,,
1136  \end{align}
1137\end{subequations}
1138where $w_i$ is $p_{t,i}$ for the $p_t$ and $E_t$ schemes, and is
1139$p_{t,i}^2$ for the $p_t^2$ and $E_t^2$ schemes.
1140
1141Note that for massive particles the schemes defined in the previous
1142paragraph are not invariant under longitudinal boosts.
1143%
1144As a workaround for this issue, we propose boost-invariant $p_t$ and
1145$p_t^2$ schemes, which are identical to the normal $p_t$ and $p_t^2$
1146schemes, except that they omit the preprocessing stage. They are
1147available as \ttt{BIpt\_scheme} and \ttt{BIpt2\_scheme}.
1148
1149A generalisation of the $p_t$ and $p_t^2$ schemes is to take a
1150weighting by $w_i = p_t^n$.
1151%
1152An interesting limit is then $n \to \infty$, referred to as the
1153winner-takes-all scheme (WTA), because the new rapidity and azimuth in
1154Eq.~(\ref{eq:recomb-weights}) coincide with those of the harder of the
1155two particles~\cite{Bertolini:2013iqa}.
1156%
1157This gives the \ttt{WTA\_pt\_scheme}.
1158%
1159The \ttt{WTA\_pt\_scheme} does not perform any preprocessing, but
1160differs from the \ttt{BIpt...} schemes in that the result of a
1161recombination acquires the mass of the higher-$p_t$ of the two
1162particles (instead of setting the mass to zero).
1163%
1164This treatment ensures, for example, that recombination of a massive
1165particle with an infinitesimally soft particle leaves the mass
1166unchanged.
1167
1168\paragraph{Other schemes for $\boldsymbol{e^+e^-}$ collisions.}
1169%
1170The default $E$-scheme is a sensible choice also for $e^+e^-$
1171collisions.
1172%
1173The only non-standard $e^+e^-$-specific scheme currently implemented
1174is the \ttt{WTA\_modp\_scheme}, in which the recombination of $p_i$ ad
1175$p_j$ points in the direction and has the mass of the particle with
1176larger 3-vector modulus ($|\vec p|$), and has a 3-vector modulus
1177$|\vec p_r| = |\vec p_i| + |\vec p_i|$.
1178%
1179\footnote{It is tempting to define also a \ttt{WTA\_E\_scheme} in
1180  which the recombination would point in the direction of the particle
1181  with the largest energy. This is however dangerous in situations
1182  where the most energetic particle is at rest. As a consequence, this
1183  scheme is not provided in \fastjet. A similar consideration applies
1184  for a \ttt{WTA\_mt\_scheme}.}
1185
1186%
1187On request, we may in the future provide further dedicated schemes for
1188$\ee$ collisions.
1189
1190\paragraph{User-defined schemes.} The user may define their own,
1191custom recombination schemes, as described in Appendix~\ref{sec:recombiner}.
1192
1193
1194
1195
1196
1197%......................................................................
1198\subsection{Constituents and substructure of jets}
1199\label{sec:constituents}
1200
1201For any \PseudoJet that results from a clustering, the user can
1202obtain information about its constituents, internal substructure,
1203etc., through  member functions of the \PseudoJet
1204class.\footnote{This is a new development in version 3 of
1205  \fastjet. In earlier versions, access to information about a jet's
1206  contents had to be made through its \CS. Those forms of access,
1207  though not documented here, will be retained throughout the 3.X
1208  series.}
1209
1210\paragraph{Jet constituents.}
1211The constituents of a given \PseudoJet \verb|jet| can be
1212obtained through
1213\begin{lstlisting}
1214  vector<PseudoJet> constituents = jet.constituents();
1215\end{lstlisting}
1216%
1217Note that if the user wishes to identify these constituents with the
1218original particles provided to \ttt{ClusterSequence}, she or
1219he should have set a unique index for each of the original particles
1220with the \ttt{PseudoJet::set\_user\_index} function.
1221%
1222Alternatively more detailed information can also be set through the
1223\verb|user_info| facilities of \PseudoJet, as discussed in
1224appendix~\ref{app:user-info}.
1225
1226\paragraph{Subjet properties.} To obtain the set of subjets at a specific
1227$d_{\mathrm{cut}}$ scale inside a given jet, one may use the following
1228\PseudoJet member function:
1229\begin{lstlisting}
1230  /// Returns a vector of all subjets of the current jet (in the sense of the exclusive
1231  /// algorithm) that would be obtained when running the algorithm with the given dcut
1232  std::vector<PseudoJet> exclusive_subjets (const double dcut) const;
1233\end{lstlisting}
1234If $m$ jets are found, this takes a time $\order{m \ln m}$ (owing to
1235the internal use of a priority queue). Alternatively one may obtain
1236the jet's constituents, cluster them separately and then carry out an
1237\ttt{exclusive\_jets} analysis on the resulting \ttt{ClusterSequence}.
1238The results should be identical. This second method is mandatory if
1239one wishes to identify subjets with an algorithm that differs from the
1240one used to find the original jets.
1241%
1242
1243In analogy with the \ttt{exclusive\_jets(...)} functions of \CS, \PJ
1244also has \ttt{exclusive\_subjets(int nsub)} and
1245\ttt{exclusive\_subjets\_up\_to(int nsub)} functions.
1246
1247
1248One can also make use of the following methods, which allow one to
1249follow the merging sequence (and walk back through it):
1250\begin{lstlisting}
1251  /// If the jet has parents in the clustering, returns true and sets parent1 and parent2
1252  /// equal to them. If it has no parents returns false and sets parent1 and parent2 to 0
1253  bool has_parents(PseudoJet & parent1, PseudoJet & parent2) const;
1254
1255  /// If the jet has a child then returns true and sets the child jet otherwise returns
1256  /// false and sets the child to 0
1257  bool has_child(PseudoJet & child) const;
1258
1259  /// If this jet has a child (and so a partner), returns true and sets the partner,
1260  /// otherwise returns false and sets the partner to 0
1261  bool has_partner(PseudoJet & partner) const;
1262\end{lstlisting}
1263
1264\paragraph{Accessibility of structural information.}
1265If any of the above functions are used with a \PseudoJet that is not
1266associated with a \ClusterSequence, an error will be thrown.
1267%
1268Since the information about a jet's constituents is actually stored in
1269the \CS and not in the jet itself, these methods will also throw an
1270error if the \CS associated with the jet has gone out of scope, been
1271deleted, or in any other way become invalid.
1272%
1273One can establish the status of a \PseudoJet's associated cluster
1274sequence with the following enquiry functions:
1275\begin{lstlisting}
1276  // returns true if this PseudoJet has an associated (and valid) ClusterSequence.
1277  bool has_valid_cluster_sequence() const;
1278
1279  // returns a (const) pointer to the parent ClusterSequence (throws if inexistent
1280  // or no longer valid)
1281  const ClusterSequence* validated_cluster_sequence() const;
1282\end{lstlisting}
1283There are also \ttt{has\_associated\_cluster\_sequence()} and
1284\ttt{associated\_cluster\_sequence()} member functions. The first
1285returns true even when the cluster sequence is not valid, and the
1286second returns a null pointer in that case.
1287%
1288Further information is to be found in
1289appendix~\ref{app:structure_table}.
1290
1291There are contexts in which, within some function, one might create a
1292\ClusterSequence, obtain a jet from it and then return that jet from
1293the function. For the user to be able to access the information about
1294the jet's internal structure, the \ClusterSequence must not have gone
1295out of scope and/or been deleted.
1296%
1297To aid with potential memory management issues in this case, as long
1298the \ClusterSequence was created via a \ttt{new} operation,
1299then one can tell the \ClusterSequence that it should be automatically
1300deleted after the last external object (jet, etc.)  associated with it
1301has disappeared.
1302%
1303The call to do this is
1304\ttt{ClusterSequence::delete\_self\_when\_unused()}. There must be at
1305least one external object already associated with the \ClusterSequence
1306at the time of the call (e.g. a jet, subjet or jet constituent).
1307%
1308Note that \ClusterSequence tends to be a large object, so this should be
1309used with care.
1310
1311%......................................................................
1312\subsection{Composite jets, general considerations on jet structure}
1313\label{sec:composite-jet}
1314
1315There are a number of cases where it is useful to be able to take two
1316separate jets and create a single object that is the sum of the two,
1317not just from the point of view of its 4-momentum, but also as
1318concerns its structure.
1319%
1320For example, in a search for a dijet resonance, some user code may
1321identify two jets, \ttt{jet1} and \ttt{jet2}, that are thought to come
1322from a resonance decay and then wish to return a single object that
1323combines both \ttt{jet1} and \ttt{jet2}.
1324%
1325This can be accomplished with the function \ttt{join}:
1326%
1327\begin{lstlisting}
1328  PseudoJet resonance = join(jet1,jet2);
1329\end{lstlisting}
1330The 4-momenta are added,\footnote{This corresponds to $E$-scheme
1331  recombination. If the user wishes to have the jets joined with a
1332  different recombination scheme he/she can pass a
1333  \texttt{JetDefinition::Recombiner} (cf.\ section~\ref{sec:recombiner})
1334  as the last argument to \texttt{join(...)}.} and in addition the
1335\ttt{resonance} remembers that it came from \ttt{jet1} and
1336\ttt{jet2}. So, for example, a call to \ttt{resonance.constituents()}
1337will return the constituents of both \ttt{jet1} and \ttt{jet2}.
1338%
1339It is possible to \ttt{join} 1, 2, 3 or 4 jets or a \ttt{vector} of
1340jets.
1341%
1342If the jets being joined had areas (section~\ref{sec:areas}) then the
1343joined jet will also have an area.
1344
1345
1346
1347For a jet formed with \ttt{join}, one can find out which pieces it has
1348been composed from with the function
1349\begin{lstlisting}
1350  vector<PseudoJet> pieces = resonance.pieces();
1351\end{lstlisting}
1352In the above example, this would simply return a vector of size 2
1353containing \ttt{jet1} and \ttt{jet2}.
1354%
1355The \ttt{pieces()} function also works for jets that come from a \CS,
1356returning two pieces if the jet has parents, zero otherwise.
1357
1358
1359
1360%......................................................................
1361\paragraph{Enquiries as to available structural information.}
1362
1363Whether or not a given jet has constituents, recursive substructure or
1364pieces depends on how it was formed.
1365%
1366Generally a user will know how a given jet was formed, and so know if
1367it makes sense, say, to call \ttt{pieces()}.
1368%
1369However if a jet is returned from some third-party code, it may not
1370always be clear what kinds of structural information it has.
1371%
1372Accordingly a number of enquiry functions are available:
1373\begin{lstlisting}
1374  bool has_structure();         // true if the jet has some kind of structural info
1375  bool has_constituents();      // true if the jet has constituents
1376  bool has_exclusive_subjets(); // true if there is cluster-sequence style subjet info
1377  bool has_pieces();            // true if the jet can be broken up into pieces
1378  bool has_area();              // true if the jet has jet-area information
1379  string description();         // returns a textual description of the type
1380                                // of structural info associated with the jet
1381\end{lstlisting}
1382Asking (say) for the \ttt{pieces()} of a jet for which
1383\ttt{has\_pieces()} returns false will cause an error to be thrown.
1384%
1385The structural information available for different kinds of jets is
1386summarised in appendix~\ref{app:structure_table}.
1387
1388
1389
1390%----------------------------------------------------------------------
1391\subsection{Version information}
1392\label{sec:version-information}
1393
1394Information on the version of \fastjet that is being run can be
1395obtained by making a call to
1396\begin{lstlisting}
1397  std::string fastjet_version_string();
1398\end{lstlisting}
1399(defined in \ttt{fastjet/JetDefinition.hh}).
1400%
1401In line with recommendations for other programs in high-energy
1402physics, the user should include this information in publications and
1403plots so as to facilitate reproducibility of the
1404jet-finding.\footnote{We devote significant effort to ensuring that
1405  all versions of the \fastjet\ program give identical, correct
1406  clustering results, and that any other changes from one version to
1407  the next are clearly indicated.
1408  %
1409  However, as per the terms of the GNU General Public License (v2),
1410  under which \fastjet\ is released, we are not able to provide
1411  a warranty that \fastjet\ is free of bugs that might affect your use
1412  of the program.
1413  %
1414  Accordingly it is important for physics publications to include a
1415  mention of the \fastjet version number used, in order to help trace
1416  the impact of any bugs that might be discovered in the future.  }
1417%
1418We recommend also that the main elements of the
1419\ttt{jet\_def.description()} be provided, together with citations to
1420the original article that defines the algorithm, as well as to this
1421manual and, optionally, the original \fastjet paper~\cite{fastjet}.
1422
1423As of version 3.1, it is also possible to conditionally compile code
1424based on the the \fastjet version number, which is encoded in the
1425\ttt{FASTJET\_VERSION\_NUMBER} preprocessor symbol as a single integer
1426Mmmpp: M is the major version number, mm the minor version
1427number and pp the patch level.
1428%
1429Thus version 3.1.12 would be represented as 30112.
1430%
1431Code requiring at least version 3.1.0 could be included as follows:
1432\begin{lstlisting}
1433  #include "fastjet/config.h"
1434
1435  #if FASTJET_VERSION_NUMBER >= 30100
1436  // code that needs version 3.1.0 or higher
1437  # else
1438  // alternative code that works also with version 3.0.x
1439  #endif
1440\end{lstlisting}
1441In versions prior to 3.1.0 the \ttt{FASTJET\_VERSION\_NUMBER} symbol
1442is undefined and is accordingly treated by the preprocessor as if it
1443were zero.
1444
1445%======================================================================
1446\section{\fastjet native jet algorithms}
1447\label{sec:native-algs}
1448
1449%......................................................................
1450\subsection[Longitudinally invariant $k_t$ jet algorithm]{Longitudinally invariant $\boldsymbol{k_t}$ jet algorithm}
1451%
1452The longitudinally invariant $k_t$ jet algorithm \cite{ktexcl,ktincl}
1453comes in inclusive and exclusive variants.
1454%
1455The inclusive variant (corresponding to \cite{ktincl}, modulo small
1456changes of notation) is formulated as follows:
1457\begin{itemize}
1458\item[1.] For each pair of particles $i$, $j$ work out the $k_t$
1459  distance\footnote{In the soft, small angle limit for $i$, the $k_t$
1460    distance is the (squared) transverse momentum of $i$ relative to $j$.}
1461  \begin{equation}
1462    \label{eq:dij}
1463    d_{ij} = \min(p_{ti}^2,{p_{tj}^2}) \, \Delta R_{ij}^2 / R^2
1464  \end{equation}
1465  with $\Delta R_{ij}^2 = (y_i-y_j)^2 + (\phi_i-\phi_j)^2$,
1466  where $p_{ti}$, $y_i$ and $\phi_i$ are the transverse momentum (with
1467  respect to the beam direction),
1468  rapidity and azimuth of particle $i$. $R$ is a jet-radius
1469  parameter usually taken of order $1$. For each parton $i$ also work
1470  out the beam distance $d_{iB} = p_{ti}^2$.
1471\item[2.] Find the minimum $d_{\min}$ of all the $d_{ij},d_{iB}$. If
1472  $d_{\min}$ is a $d_{ij}$ merge particles $i$ and $j$ into a single
1473  particle, summing their four-momenta (this is $E$-scheme
1474  recombination); if it is a $d_{iB}$ then declare particle $i$ to be
1475  a final jet and remove it from the list.
1476\item[3.] Repeat from step 1 until no particles are left.
1477\end{itemize}
1478The exclusive variant of the longitudinally invariant $k_t$ jet
1479algorithm \cite{ktexcl} is similar, except that (a) when a $d_{iB}$ is
1480the smallest value, that particle is considered to become part of the
1481beam jet (i.e.\ is discarded) and (b) clustering is stopped when all
1482$d_{ij}$ and $d_{iB}$ are above some $d_{cut}$. In the exclusive mode
1483$R$ is commonly set to $1$.
1484
1485The inclusive and exclusive variants are both obtained through
1486\begin{lstlisting}
1487   JetDefinition jet_def(kt_algorithm, R);
1488   ClusterSequence cs(particles, jet_def);
1489\end{lstlisting}
1490The clustering sequence is identical in the inclusive and exclusive
1491cases and the jets can then be obtained as follows:
1492\begin{lstlisting}
1493   vector<PseudoJet> inclusive_kt_jets = cs.inclusive_jets();
1494   vector<PseudoJet> exclusive_kt_jets = cs.exclusive_jets(dcut);
1495\end{lstlisting}
1496
1497%......................................................................
1498\subsection{Cambridge/Aachen jet algorithm}
1499
1500The $pp$ Cambridge/Aachen (C/A) jet
1501algorithm~\cite{CamOrig,CamWobisch} is provided in the form proposed
1502in Ref.~\cite{CamWobisch}.
1503%
1504Its formulation is identical to that of the (inclusive) $pp$ $k_t$ jet
1505algorithm, except as regards the distance measures, which are:
1506\begin{subequations}
1507  \label{eq:dij_cam}
1508  \begin{align}
1509    d_{ij} &= \Delta R_{ij}^2 / R^2\,,\\
1510    d_{iB} &= 1\,.
1511  \end{align}
1512\end{subequations}
1513To use this algorithm, define
1514\begin{lstlisting}
1515   JetDefinition jet_def(cambridge_algorithm, R);
1516\end{lstlisting}
1517and then extract inclusive jets from the cluster sequence.
1518
1519Attempting to extract exclusive jets from the Cambridge/Aachen
1520algorithm with a
1521$d_{cut}$ parameter simply provides the set of jets obtained up to the
1522point where all $d_{ij},d_{iB} > d_{cut}$. Having clustered with some
1523given $R$, this can actually be an effective way of viewing the event
1524at a smaller radius, $R_\text{eff} = \sqrt{d_{cut}} R$, thus allowing a
1525single event to be viewed at a continuous range of $R_\text{eff}$ within a
1526single clustering.
1527
1528We note that the original formulation of the Cambridge
1529algorithm~\cite{CamOrig} (in $e^+e^-$) instead makes use of an
1530auxiliary ($k_t$) distance measure and `freezes' pseudojets whose
1531recombination would involve too large a value of the auxiliary
1532distance measure. Details are given in section~\ref{sec:ee-cam}.
1533
1534
1535%......................................................................
1536\subsection[Anti-$k_t$ jet algorithm]{Anti-$\boldsymbol{k_t}$ jet algorithm}
1537This algorithm, introduced and studied in~\cite{antikt}, is defined
1538exactly like the standard $k_t$ algorithm, except for the distance
1539measures which are now given by
1540\begin{subequations}
1541    \label{eq:dij_antikt}
1542  \begin{eqnarray}
1543    &&d_{ij} = \min(1/p_{ti}^2,1/{p_{tj}^2}) \, \Delta R_{ij}^2 / R^2 \, , \\
1544    &&d_{iB} = 1/p_{ti}^2 \, .
1545  \end{eqnarray}
1546\end{subequations}
1547While it is a sequential recombination algorithm like $k_t$ and
1548Cambridge/Aachen, the anti-$k_t$ algorithm behaves in some sense like a
1549`perfect' cone algorithm, in that its hard jets are exactly
1550circular on the $y$-$\phi$ cylinder~\cite{antikt}.
1551%
1552To use this algorithm, define
1553\begin{lstlisting}
1554   JetDefinition jet_def(antikt_algorithm, R);
1555\end{lstlisting}
1556and then extract inclusive jets from the cluster sequence.
1557%
1558We advise against the use of exclusive jets in the context of the
1559anti-$k_t$ algorithm, because of the lack of physically meaningful
1560hierarchy in the clustering sequence.
1561
1562%......................................................................
1563\subsection[Generalised-$k_t$ jet algorithm]{Generalised $\boldsymbol{k_t}$ jet algorithm}
1564\label{sec:genkt}
1565
1566The ``generalised $k_t$'' algorithm again follows the same procedure,
1567but depends on an additional continuous parameter $p$, and has the
1568following distance measure:
1569\begin{subequations}
1570  \label{eq:dij_genkt}
1571  \begin{eqnarray}
1572    &&d_{ij} = \min(p_{ti}^{2p},p_{tj}^{2p}) \, \Delta R_{ij}^2 / R^2 \, , \\
1573    &&d_{iB} = p_{ti}^{2p} \, .
1574  \end{eqnarray}
1575\end{subequations}
1576For specific values of $p$, it reduces to one or other of the
1577algorithms list above, $k_t$ ($p=1$), Cambridge/Aachen ($p=0$) and
1578anti-$k_t$ ($p=-1$).
1579%
1580To use this algorithm, define
1581\begin{lstlisting}
1582  JetDefinition jet_def(genkt_algorithm, R, p);
1583\end{lstlisting}
1584and then extract inclusive jets from the cluster sequence (or, for
1585$p\ge 0$, also the exclusive jets).
1586
1587%......................................................................
1588\subsection[Generalised $k_t$ algorithm for $e^+e^-$ collisions]
1589{Generalised $\boldsymbol{k_t}$ algorithm for $\boldsymbol{e^+e^-}$ collisions}
1590\label{sec:ee-algs}
1591
1592\fastjet also provides native implementations of clustering algorithms
1593in spherical coordinates (specifically for $e^+e^-$ collisions) along
1594the lines of the original $k_t$ algorithms~\cite{eekt}, but extended
1595following  the generalised $pp$ algorithm of~\cite{antikt} and
1596section \ref{sec:genkt}. We define the two following distances:
1597\begin{subequations}
1598  \label{eq:dij_eegenkt}
1599\begin{align}
1600  \label{eq:dij_eegenkt_ij}
1601  d_{ij} &= \min(E_i^{2p}, E_j^{2p}) \frac{(1- \cos
1602    \theta_{ij})}{(1-\cos R)}\,,\\
1603  d_{iB} &= E_i^{2p}\,,
1604\end{align}
1605\end{subequations}
1606for a general value of $p$ and $R$. At a given stage of the clustering
1607sequence, if a $d_{ij}$ is smallest then $i$ and $j$ are recombined,
1608while if a $d_{iB}$ is smallest then $i$ is called an ``inclusive
1609jet''.
1610
1611For values of $R \le \pi$ in eq.~(\ref{eq:dij_eegenkt}), the
1612generalised $e^+e^-$ $k_t$ algorithm behaves in analogy with the $pp$
1613algorithms: when an object is at an angle $\theta_{iX} > R$ from all
1614other objects $X$ then it forms an inclusive jet.
1615%
1616With the choice $p=-1$ this provides a simple, infrared and collinear
1617safe way of obtaining a cone-like algorithm for $e^+e^-$ collisions,
1618since hard well-separated jets have a circular profile on the $3$D
1619sphere, with opening half-angle $R$.
1620%
1621To use this form of the algorithm, define
1622\begin{lstlisting}
1623   JetDefinition jet_def(ee_genkt_algorithm, R, p);
1624\end{lstlisting}
1625and then extract inclusive jets from the cluster sequence.
1626
1627For values of $R > \pi$, \fastjet replaces the factor $(1-\cos R)$ in
1628the denominator of eq.~(\ref{eq:dij_eegenkt_ij}) with $(3+\cos
1629R)$. With this choice (as long as $R < 3\pi$), the only time a $d_{iB}$ will
1630be relevant is when there is just a single particle in the event.
1631%
1632The \ttt{inclusive\_jets(...)} will then always return a single jet
1633consisting of all the particles in the event.
1634%
1635In such a context it is only the \ttt{exclusive\_jets(...)} call that
1636provides non-trivial information.
1637
1638%......................................................................
1639\subsection[$k_t$ algorithm for $e^+e^-$ collisions]
1640{$\boldsymbol{k_t}$ algorithm for $\boldsymbol{e^+e^-}$ collisions}
1641\label{sec:kt-ee-alg}
1642
1643The $e^+e^-$ $k_t$ algorithm~\cite{eekt}, often referred to also as
1644the Durham algorithm,  has a single distance:
1645\begin{align}
1646  \label{eq:dij_eekt}
1647  d_{ij} &= 2 \min(E_i^{2}, E_j^{2}) (1- \cos \theta_{ij})\,.
1648\end{align}
1649Note the difference in normalisation between the $d_{ij}$ in
1650eqs.~(\ref{eq:dij_eegenkt}) and (\ref{eq:dij_eekt}), and the fact that in neither
1651case have we normalised to the total energy $Q$ in the event, contrary
1652to the convention adopted originally in~\cite{eekt} (where the
1653distance measure was called $y_{ij}$).
1654%
1655To use the $e^+e^-$ $k_t$  algorithm, define
1656\begin{lstlisting}
1657   JetDefinition jet_def(ee_kt_algorithm);
1658\end{lstlisting}
1659and then extract exclusive jets from the cluster sequence.
1660
1661%
1662Note that the \ttt{ee\_genkt\_algorithm} with $ \pi < R < 3\pi$ and
1663$p=1$ gives a clustering sequence that is identical to that of the
1664\ttt{ee\_kt\_algorithm}.
1665%
1666The normalisation of the $d_{ij}$'s will however be different.
1667
1668
1669%======================================================================
1670\section{Plugin jet algorithms}
1671\label{sec:plugins}
1672
1673It can be useful to have a common interface for a range of jet
1674algorithms beyond the native ($k_t$, anti-$k_t$ and Cambridge/Aachen)
1675algorithms, notably for the many cone algorithms that are in
1676existence.
1677%
1678It can also be useful to be able to use \fastjet features such as
1679area-measurement tools for these other jet algorithms.
1680%
1681In order to facilitate this, the
1682\fastjet package provides a \emph{plugin} facility, allowing almost
1683any other jet algorithm\footnote{Except those for which one particle
1684  may be assigned to more than one jet, e.g.\ algorithms such as
1685  ARCLUS~\cite{Lonnblad:1992qd}, which performs $3\to2$
1686  clustering.} to be used within the same framework.
1687
1688Generic plugin use is described in the next subsection.
1689%
1690The plugins distributed with \fastjet are described afterwards in
1691sections~\ref{sec:siscone-plugin}--\ref{sec:other-ee-plugins}.
1692%
1693They are all accessible within the \ttt{fastjet} namespace and their code
1694is to be found in \fastjet's \ttt{plugins/} directory.
1695%
1696New user-defined plugins can also be implemented, as described
1697in section~\ref{sec:new-plugin}.
1698%
1699Some third-party plugins are linked to from the tools page at
1700\url{http://fastjet.fr/}$\,$.
1701
1702Not all plugins are enabled by default in \fastjet. At configuration
1703time \verb:./configure --help: will indicate which ones get enabled
1704by default. To enable all plugins, run \verb|configure| with the
1705argument \verb|--enable-allplugins|, while to enable all but PxCone
1706(which requires a Fortran compiler, and can introduce link-time issues) use
1707\verb|--enable-allcxxplugins|.
1708
1709
1710%----------------------------------------------------------------------
1711\subsection{Generic plugin use}
1712\label{sec:generic-plugin-use}
1713
1714Plugins are classes derived from the abstract base class
1715\ttt{fastjet::JetDefinition::Plugin}.
1716%
1717A \ttt{JetDefinition} can be constructed by providing a pointer to a
1718\ttt{JetDefinition::Plugin}; the resulting \ttt{JetDefinition} object
1719can then be used identically to the normal \ttt{JetDefinition} objects
1720used in the previous sections.
1721%
1722We illustrate this with an example based on the SISCone plugin:
1723\begin{lstlisting}
1724  #include "fastjet/SISConePlugin.hh"
1725
1726  // allocate a new plugin for SISCone (for other plugins, simply
1727  // replace the appropriate parameters and plugin name)
1728  double cone_radius = 0.7;
1729  double overlap_threshold = 0.75;
1730  JetDefinition::Plugin * plugin = new SISConePlugin(cone_radius, overlap_threshold);
1731
1732  // create a jet definition based on the plugin
1733  JetDefinition jet_def(plugin);
1734
1735  // run the jet algorithm and extract the jets
1736  ClusterSequence clust_seq(particles, jet_def);
1737  vector<PseudoJet> inclusive_jets = clust_seq.inclusive_jets();
1738
1739  // then analyse the jets as for native fastjet algorithms
1740  ...
1741
1742  // only when you will no longer be using the jet definition, or
1743  // ClusterSequence objects that involve it, may you delete the plugin
1744  delete plugin;
1745\end{lstlisting}
1746%
1747In cases such as this where the plugin has been created with a
1748\ttt{new} statement and the user does not wish to manage the deletion
1749of the corresponding memory when the \ttt{JetDefinition} (and any
1750copies) using the plugin goes out of scope, then the user may wish to
1751call the \ttt{JetDefinition}'s \ttt{delete\_plugin\_when\_unused()}
1752function, which tells the \ttt{JetDefinition} to acquire ownership of
1753the pointer to the plugin and delete it when it is no longer needed.
1754
1755
1756%----------------------------------------------------------------------
1757\subsection{SISCone Plugin}
1758\label{sec:siscone-plugin}
1759
1760SISCone provides infrared and collinear-safe implementations of the
1761two most common kinds of cone algorithm.
1762%
1763Cone algorithm execution generally involves two phases.
1764%
1765The first is the search for stable cones (SC).
1766%
1767Then, because a given particle can appear in more than one stable
1768cone, there are two options for the second phase: the standard
1769approach is to apply a
1770`split--merge' (see e.g.\ Ref.\ \cite{RunII-jet-physics}) procedure,
1771which ensures that no particle ends up in more than one jet.
1772%
1773Alternatively, one can identify the highest-$p_t$ stable cone, call it a jet,
1774remove all particles that it contained and then repeat the stable-cone
1775search and removal over and over until no particles remain (we call
1776this progressive removal).
1777
1778The stable cones are identified using an $\order{N^2 \ln N}$ seedless
1779approach~\cite{SISCone}. This (and some care in the `split--merge'
1780procedure, if used) ensures that the jets it produces are insensitive
1781to additional soft particles and collinear splittings, i.e.\ the
1782algorithm is infrared and collinear safe.
1783
1784By default SISCone runs with a split--merge step.
1785%
1786The implementation with progressive removal was made public in version
17873.0 of SISCone, first released with version 3.1 of \fastjet.
1788
1789%  `split--merge' procedure is applied,  which
1790% ensures that no particle ends up in more than one jet.
1791%
1792%  using an
1793% exhaustive geometric approach~\cite{SISCone} to help identify all
1794% possible stable cones.
1795% %
1796% Because the exhaustive approach avoids the need for seeds and cone
1797% iterations, it bypasses many of infrared and collinear-safety issues
1798% that are present for seeded algorithms.
1799%
1800% Cone algorithms generally have two steps: the identification of stable
1801% cones and a step that processes those stable cones, e.g.\ dealing with
1802% the fact that two distinct stable cones may share particles
1803% %
1804% SISCone can be operated in two variants: the default and original
1805% mode, as described in Ref.\cite{SISCone}, performs a
1806% Tevatron-style~\cite{RunII-jet-physics} split--merge (SM) operation to
1807% handle overlaps;
1808% %
1809% The progressive removal (PR) variant
1810
1811%......................................................................
1812\subsubsection{Default mode: SISCone with a split--merge step (SISCone-SM)}
1813
1814The original implementation of SISCone~\cite{SISCone} corresponded to
1815a stable-cone jet algorithm with a split--merge step (SC-SM in the
1816notation of~\cite{Salam:2009jx}).
1817%
1818This remains SISCone's default and, unless explicitly mentioned
1819otherwise, it corresponds to the version of SISCone used in the literature.
1820
1821% As with most modern cone algorithms, it is divided into two parts:
1822% first it searches for stable cones; then, because a particle can
1823% appear in more than one stable cone, a `split--merge' procedure is
1824% applied, which ensures that no particle ends up in more than one jet.
1825% %
1826% The stable cones are identified using an $\order{N^2 \ln N}$ seedless
1827% approach. This (and some care in the the `split--merge' procedure)
1828% ensures that the jets it produces are insensitive to additional soft
1829% particles and collinear splittings, i.e.\ the algorithm is infrared
1830% and collinear safe.
1831
1832The plugin library and include files are to be be found in the
1833\verb:plugins/SISCone: directory, and the main header file is
1834\verb:fastjet/SISConePlugin.hh:. The \verb:SISConePlugin: class has a
1835constructor with the following structure
1836\begin{lstlisting}
1837  #include "fastjet/SISConePlugin.hh"
1838
1839  SISConePlugin (double cone_radius,
1840                 double overlap_threshold,
1841                 int    n_pass_max = 0,
1842                 double protojet_ptmin = 0.0,
1843                 bool   caching = false,
1844                 SISConePlugin::SplitMergeScale
1845                                split_merge_scale = SISConePlugin::SM_pttilde);
1846\end{lstlisting}
1847A cone centred at $y_c,\phi_c$ is stable if the sum of momenta of all
1848particles $i$ satisfying $\Delta y_{ic}^2 + \Delta \phi_{ic}^2 <
1849\verb:cone_radius:^2$ has rapidity $y_c,\phi_c$.
1850%
1851The \verb:overlap_threshold: is the fraction of overlapping momentum
1852above which two protojets are merged in a Tevatron Run~II type
1853\cite{RunII-jet-physics} split--merge procedure.
1854The
1855radius and overlap parameters are a common feature of most modern cone
1856algorithms. Because some event particles are not to be found in any
1857stable cone \cite{EHT}, SISCone can carry out multiple stable-cone
1858search passes (as advocated in \cite{TeV4LHC}): in each pass one
1859searches for stable cones using just the subset of particles not
1860present in any stable cone in earlier passes. Up to \verb:n_pass_max:
1861passes are carried out, and the algorithm automatically stops at the
1862highest pass that gives no new stable cones. The default of
1863$\verb:n_pass_max: = 0$ is equivalent to setting it to $\infty$.
1864
1865Concern had at some point been expressed that an excessive number of
1866stable cones might complicate cone jets in events with high
1867noise~\cite{RunII-jet-physics}, and in particular lead to large
1868``monster'' jets.
1869%
1870The \verb:protojet_ptmin: parameter allows one to use only protojets
1871with $p_t \ge \verb:protojet_ptmin:$ in the split--merge phase (all
1872others are thrown away), so as to limit this issue.
1873%
1874A large value of the split--merge overlap threshold, e.g.\ $0.75$,
1875also helps to disfavour the production of these monster jets through
1876repeated merge operations.
1877
1878In many cases SISCone's most time-consuming step is the search for
1879stable cones. If one has multiple \verb:SISConePlugin:-based jet
1880definitions, each with \verb:caching=true:, a check will be carried
1881out whether the previously clustered event had the same set of
1882particles and the same cone radius and number of passes. If it did,
1883the stable cones are simply reused from the previous event, rather
1884than being recalculated, and only the split--merge step is repeated,
1885often leading to considerable speed gains.
1886
1887A final comment concerns the \verb:split_merge_scale:
1888parameter. This controls both the scale used for ordering the
1889protojets during the split--merge step during the split--merge step,
1890and also the scale used to measure the degree of overlap between
1891protojets. While various options have been implemented,
1892\begin{lstlisting}
1893  enum SplitMergeScale {SM_pt, SM_Et, SM_mt, SM_pttilde};
1894\end{lstlisting}
1895we recommend using only the last of them $\tilde p_t = \sum_{i \in
1896  \mathrm{jet}}|p_{t,i}|$, which is also the default scale. The other
1897scales are included only for historical comparison purposes: $p_t$
1898(used in several other codes) is IR unsafe for events whose hadronic
1899component conserves momentum, $E_t$ (advocated in
1900\cite{RunII-jet-physics}) is not boost-invariant, and $m_t = \sqrt{m^2
1901  + p_t^2}$ is IR unsafe for events whose hadronic component conserves
1902momentum and stems from the decay of two identical particles.
1903
1904
1905An example of the use of the SISCone plugin was given in
1906section~\ref{sec:generic-plugin-use}.
1907%
1908As can be seen there, SISCone jets are to be obtained by requesting
1909inclusive jets from the cluster sequence.
1910%
1911Note that it makes no sense to ask for exclusive jets from a
1912SISCone based \verb:ClusterSequence:.
1913
1914% would be as follows:
1915% \begin{lstlisting}
1916%   // define a SISCone plugin pointer
1917%   fastjet::SISConePlugin * plugin;
1918%
1919%   // allocate a new plugin for SISCone
1920%   double cone_radius = 0.7;
1921%   double overlap_threshold = 0.5;
1922%   plugin = new fastjet::SISConePlugin (cone_radius, overlap_threshold);
1923%
1924%   // create a jet-definition based on the plugin
1925%   fastjet::JetDefinition jet_def(plugin);
1926%
1927%   // prepare the set of particles
1928%   vector<fastjet::PseudoJet> particles;
1929%   read_input_particles(cin, particles); // or whatever you want here
1930%
1931%   // run the jet algorithm and look at the jets
1932%   fastjet::ClusterSequence clust_seq(particles, jet_def);
1933%   vector<fastjet::PseudoJet> inclusive_jets = clust_seq.inclusive_jets();
1934%   // then analyse the jets as for native \fastjet jets
1935%
1936%   // only when you will no longer be using the jet definition, or
1937%   // ClusterSequence objects that involve it, may you delete the
1938%   // plugin
1939%   delete plugin;
1940% \end{lstlisting}
1941
1942Some cone algorithms provide information beyond that simply about the
1943jets.
1944%
1945Such additional information, where available, can be accessed with the
1946help of the \ttt{ClusterSequence::extras()} function.
1947%
1948In the case of SISCone, one can access that information as follows:
1949\begin{lstlisting}
1950  const fastjet::SISConeExtras * extras =
1951            dynamic_cast<const fastjet::SISConeExtras *>(clust_seq.extras());
1952\end{lstlisting}
1953To determine the pass at which a given jet was found, one then
1954uses\footnote{ In versions of \fastjet prior to 3.0.1, a jet's user
1955  index indicated the pass at which it had been found. The
1956  value was however incorrectly set for single-particle
1957  jets. The current choice is to leave the user index unchanged from
1958  its default.}
1959\begin{lstlisting}
1960  int pass = extras->pass(jet);
1961\end{lstlisting}
1962%
1963One may also obtain a list of the positions of original stable
1964cones as follows:
1965\begin{lstlisting}
1966  const vector<PseudoJet> & stable_cones = extras->stable_cones();
1967\end{lstlisting}
1968The stable cones are represented as \ttt{PseudoJet}s, for which only the
1969rapidity and azimuth are meaningful. The \verb:user_index(): indicates
1970the pass at which a given stable cone was found.
1971
1972SISCone uses $E$-scheme recombination internally and also for
1973constructing the final jets from the list of constituents.
1974%
1975For the latter task, the user may instead instruct SISCone to use the
1976jet-definition's own recombiner, with the command
1977\begin{lstlisting}
1978  plugin->set_use_jet_def_recombiner(true);
1979\end{lstlisting}
1980For this to work, \ttt{plugin} must explicitly be of type
1981\ttt{SISConePlugin *} rather than \ttt{JetDefinition::Plugin *}.
1982
1983Since SISCone is infrared safe, it may meaningfully be used also with
1984the \verb:ClusterSequenceArea: class. Note however that in that
1985case ones loses the cone-specific information from the jets, because
1986of the way \fastjet filters out the information relating to ghosts in
1987the clustering. If the user needs both areas and cone-specific
1988information, she/he may use the
1989\verb:ClusterSequenceActiveAreaExplicitGhosts: class (for usage
1990information, see the corresponding \verb:.hh: file).
1991
1992A final remark concerns speed and memory requirements: as mentioned
1993above, SISCone takes $\order{N^2 \ln N}$ time to find jets, and the
1994memory use is $\order{N^2}$; taking $N=10^3$ as a reference point, it
1995runs in a few tenths of a second, making it about 100 times slower
1996than native \fastjet algorithms.
1997%
1998These are `expected' results, i.e.\ valid for a suitably random set of
1999particles.\footnote{%
2000  In area determinations, the ghost particles are not entirely random,
2001  but distributed close to a grid pattern, all with similar transverse
2002  momenta.
2003  %
2004  Run times and memory usage are then, in practice, somewhat larger
2005  than for a normal QCD event with the same number of particles.
2006  %
2007  We therefore recommend running with not too small a
2008  \texttt{ghost\_area} (e.g.\ $\sim 0.05$) and using
2009  \texttt{grid\_scatter=1} (cf.\ section~\ref{sec:areas}), which helps
2010  to reduce the number of stable cones (and correspondingly, the time
2011  and memory usage of the subsequent split--merge step).
2012  %
2013  An alternative, which has been found to be acceptable in many
2014  situations, is to use a passive area, since this is relatively fast
2015  to calculate with SISCone.
2016  %
2017}
2018
2019
2020Note that the underlying implementation of SISCone is optimised for
2021large $N$.
2022%
2023An alternative implementation that is faster for $N \lesssim 10$ was
2024presented in~\cite{Weinzierl:2011jx}.
2025
2026%......................................................................
2027\subsubsection{SISCone with progressive removal (SISCone-PR)}
2028\label{sec:SISCone-PR}
2029
2030After creating an instance of \ttt{SISConePlugin}, the
2031progressive-removal option can be enabled by calling
2032\begin{lstlisting}
2033  plugin->set_progressive_removal(true);
2034\end{lstlisting}
2035The value of the split--merge overlap threshold is then ignored and
2036caching is not available.
2037%
2038The \ttt{SplitMergeScale} argument in the constructor, instead of
2039being interpreted as the choice of scale to use in the split-merge step,
2040is instead interpreted as the scale used to order the stable cones (the
2041default is \ttt{SISConePlugin::SM\_pttilde}, i.e.\ the scalar sum of
2042$p_t$'s of the constituents) and it is the hardest stable cone
2043according to that choice that is removed.
2044%
2045The stable cone finding is then repeated on the remaining set of
2046particles, the new hardest cone is removed, and so forth.
2047%
2048As for other progressive-removal cone algorithms, SISCone-PR
2049guarantees that the first jet that is found has area $\pi
2050R^2$.\footnote{The \texttt{inclusive\_jets()} function returns the
2051  jets in the order in which they were found. Each jet's
2052  \texttt{extras->pass(jet)} value also corresponds to the pass of
2053  stable-cone finding at which it was obtained.}
2054
2055There can be interest in trying out other choices of scale variable for
2056the ordering of stable cones.
2057%
2058This can be achieved by calling
2059\begin{lstlisting}
2060  plugin->set_user_scale(&user_scale);
2061\end{lstlisting}
2062where \ttt{user\_scale} is an instance of any class that derives from
2063the \ttt{SISConePlugin::UserScaleBase} class (actually defined in
2064\ttt{SISConeBasePlugin}).
2065
2066In discussing the speed of SISCone with progressive removal, it is
2067useful to distinguish $N$, the total number of particles in the event
2068from $n$, the number inside a typical circle of radius $R$.
2069%
2070SISCone with split--merge actually takes a time $N n \ln n$.
2071%
2072SISCone with progressive removal, in its current implementation,
2073repeats the full stable cone finding $\order{N/n}$ times.
2074%
2075Thus it takes a time $\sim N^2 \ln n$.
2076%
2077This could be reduced by repeating the stable-cone finding only for
2078particles in the neighbourhood of the last stable-cone that was
2079removed: that more limited stable-cone finding should take a time $n^2
2080\ln n$ at each iteration, so that the total time would then be $N n
2081\ln n$, albeit with a larger coefficient than for the split--merge
2082variant.
2083%
2084We leave such an improvement to future work, should there be demand
2085for it.
2086
2087%----------------------------------------------------------------------
2088\subsection{Other plugins for hadron colliders }
2089\label{sec:other-pp-plugins}
2090
2091Most of the algorithms listed below are cone algorithms.
2092%
2093They are usually either infrared (IR) or collinear unsafe.
2094%
2095The details are indicated for each algorithm following the
2096notation of Ref.~\cite{Salam:2009jx}: IR$_{n+1}$ means
2097that the hard jets may be modified if, to an ensemble of $n$ hard
2098particles in a common neighbourhood, one adds a single soft particle;
2099Coll$_{n+1}$ means that for $n$ hard particles in a common
2100neighbourhood, the collinear splitting of one of them may modify the
2101hard jets.
2102%
2103The \fastjet authors (and numerous theory-experiment accords) advise
2104against the use of IR and/or collinear unsafe jet algorithms.  Interfaces to
2105these algorithms have been provided mainly for legacy comparison
2106purposes.
2107
2108Except where stated, the usual way to access jets from these plugins
2109is through \ttt{ClusterSequence::inclusive\_jets()}.
2110
2111
2112
2113\subsubsection{CDF Midpoint}
2114%
2115This is one of the two cone algorithms used by CDF in Run~II of the Tevatron, based
2116on \cite{RunII-jet-physics}. It is a midpoint-type iterative cone with
2117a split--merge step.
2118%
2119\begin{lstlisting}
2120  #include "fastjet/CDFCones.hh"
2121  // ...
2122  CDFMidPointPlugin(double R,
2123                    double overlap_threshold,
2124                    double seed_threshold = 1.0,
2125                    double cone_area_fraction = 1.0);
2126\end{lstlisting}
2127The overlap threshold ($f$) used by CDF is usually $0.5$, the seed
2128threshold is $1$\,GeV.
2129%
2130With a cone area fraction $\alpha < 1$, the search for stable
2131cones is performed with a radius that is $R \times
2132\sqrt{\alpha}$, i.e.\ it becomes the searchcone
2133algorithm of \cite{EHT}.
2134%
2135CDF has used both $\alpha = 0.25$ and $\alpha = 1.0$.
2136%
2137It is our understanding that the particular choice of $\alpha$ is not
2138always clearly documented in the corresponding publications.
2139
2140Further control over the plugin can be obtained by consulting the
2141header file.
2142
2143The original underlying code for this algorithm was provided on a
2144webpage belonging to Joey Huston~\cite{CDFCones} (with minor
2145modifications to ensure reasonable run times with optimising compilers
2146for 32-bit Intel processors --- these modifications do not affect the
2147final jets).
2148
2149This algorithm is IR$_{3+1}$ unsafe in the limit of zero seed
2150threshold~\cite{SISCone} (with $\alpha \neq 1$ it
2151becomes IR$_{2+1}$ unsafe~\cite{TeV4LHC}).
2152%
2153With a non-zero seed threshold (and no preclustering into calorimeter
2154towers) it is collinear unsafe.
2155%
2156It is to be
2157deprecated for new experimental or theoretical analyses.
2158
2159\subsubsection{CDF JetClu}
2160
2161JetClu is the other cone algorithm used by CDF during Run~II, as well
2162as their main algorithm during Run~I~\cite{Abe:1991ui}.
2163%
2164It is an iterative cone with split-merge and optional ``ratcheting''
2165if \ttt{iratch == 1} (particles that appear in one iteration of a cone
2166are retained in future iterations).
2167%
2168It can be obtained as follows:
2169\begin{lstlisting}
2170  #include "fastjet/CDFCones.hh"
2171  // ...
2172  CDFJetCluPlugin (double   cone_radius,
2173		   double   overlap_threshold,
2174		   double   seed_threshold = 1.0,
2175		   int      iratch = 1);
2176\end{lstlisting}
2177%
2178The overlap threshold is usually set to 0.75 in CDF analyses.
2179%
2180Further control over the plugin can be obtained by consulting the
2181header file.
2182
2183The original underlying code for this algorithm was provided on a
2184webpage belonging to Joey Huston~\cite{CDFCones}.
2185
2186This algorithm is IR$_{2+1}$ unsafe (for zero seed threshold; some
2187IR unsafety persists with non-zero seed threshold).
2188It is to be
2189deprecated for new experimental or theoretical analyses.
2190%
2191Note also that the underlying implementation groups particles together
2192into calorimeter towers, with CDF-type geometry, before running the
2193jet algorithm.
2194
2195%......................................................................
2196\subsubsection{\Dzero Run I cone}
2197
2198This is the main algorithm used by \Dzero in Run~I of the
2199Tevatron~\cite{Abbott:1997fc}. It is an iterative cone algorithm
2200with a split-merge step. It comes in two versions
2201\begin{lstlisting}
2202  #include "fastjet/D0RunIpre96ConePlugin.hh"
2203  // ...
2204  D0RunIpre96ConePlugin (double R,
2205                         double min_jet_Et,
2206                         double split_ratio = 0.5);
2207\end{lstlisting}
2208and
2209\begin{lstlisting}
2210  #include "fastjet/D0RunIConePlugin.hh"
2211  // ...
2212  D0RunIConePlugin (double R,
2213                    double min_jet_Et,
2214                    double split_ratio = 0.5);
2215\end{lstlisting}
2216corresponding to versions of the algorithm used respectively before
2217and after 1996.
2218%
2219They differ only in the recombination scheme used to determine the jet
2220momenta once each jet's constituents have been identified.
2221%
2222In the pre-1996 version, a hybrid between an $E$-like scheme and an
2223$E_t$ scheme recombination is used, while in the post-1996 version it
2224is just the $E_t$ scheme~\cite{Abbott:1997fc}.
2225
2226The algorithm places a cut on the minimum $E_t$ of the cones during
2227iteration (related to \verb|min_jet_Et|).
2228%
2229The \verb|split_ratio| is the same as the overlap threshold in other
2230split-merge based algorithms (\Dzero usually use 0.5).
2231%
2232It is the \fastjet authors' understanding that the value
2233used for \verb|min_jet_Et| was 8\,GeV, corresponding to a cut of
2234$4\GeV$ on cones.
2235%
2236The publication that describes this algorithm~\cite{Abbott:1997fc}
2237mentions the use of a $1\GeV$ seed threshold applied to preclustered
2238calorimeter towers in order to obtain the seeds for the stable cone
2239finding.
2240%
2241Such a threshold and the pre-clustering appear not to be included in the code
2242distributed with \fastjet.
2243
2244The underlying code for this algorithm was provided by
2245Lars Sonnenschein.
2246%
2247Permission to redistribute this code with \fastjet has been granted by
2248the \Dzero collaboration under the terms of the GPL license.
2249
2250
2251
2252Note: this algorithm is IR$_{2+1}$ unsafe. It is recommended that it
2253be used only for the purpose of comparison with Run~I data from
2254\Dzero.
2255%
2256It is to be deprecated for new experimental or theoretical analyse
2257
2258%......................................................................
2259\subsubsection{\Dzero Run II cone}
2260%
2261This is the main algorithm used by \Dzero in Run~II of the
2262Tevatron. It is a midpoint type iterative cone with split-merge step.
2263%
2264The \Dzero collaboration usually refers to
2265Ref.~\cite{RunII-jet-physics} when introducing the algorithm in its
2266articles.
2267%
2268That generic Tevatron document does not reflect all details of the
2269actual \Dzero algorithm, and for a complementary description
2270%
2271the reader is referred to Ref.~\cite{arXiv:1110.3771}.
2272\begin{lstlisting}
2273  #include "fastjet/D0RunIIConePlugin.hh"
2274  // ...
2275  D0RunIIConePlugin (double R,
2276                     double min_jet_Et,
2277                     double split_ratio = 0.5);
2278\end{lstlisting}
2279The parameters have the same meaning as in the \Dzero Run~I
2280cone.
2281%
2282There is a cut on the minimum $E_t$ of the cones during iteration,
2283which by default is half of \verb|min_jet_Et|.
2284%
2285It is the \fastjet authors' understanding that two values have been
2286used for \verb|min_jet_Et|, 8\,GeV (in earlier publications) and
22876\,GeV (in more recent publications).
2288
2289As concerns seed thresholds and preclustering, \Dzero describes them
2290as being applied to calorimeter towers in data and in Monte Carlo studies
2291that include detector simulation~\cite{arXiv:1110.3771}.
2292%
2293However, for NLO calculations and Monte Carlo studies based on stable
2294particles, no seed threshold is applied.
2295%
2296The code distributed with \fastjet does not allow for seed thresholds.
2297
2298The underlying code for this algorithm was provided by
2299Lars Sonnenschein.
2300%
2301Permission to redistribute this code with \fastjet has been granted by
2302the \Dzero collaboration under the terms of the GPL license.
2303
2304Note: this algorithm is IR$_{3+1}$ unsafe (IR$_{2+1}$ for jets with
2305energy too close to \verb:min_jet_Et:). It is to be deprecated for new
2306experimental or theoretical analyses.
2307
2308%......................................................................
2309\subsubsection{ATLAS iterative cone}
2310%
2311This iterative cone algorithm, with a split-merge step, was used by
2312ATLAS during the preparation for the LHC.
2313\begin{lstlisting}
2314  #include "fastjet/AtlasConePlugin.hh"
2315  // ...
2316  ATLASConePlugin (double R,
2317                   double seedPt = 2.0,
2318                   double f = 0.5);
2319\end{lstlisting}
2320$f$ is the overlap threshold
2321
2322The underlying code for this algorithm was extracted from an early
2323version of SpartyJet \cite{SpartyJet} (which itself was distributed
2324under the GPL license).
2325%
2326Since version 3.0 of \fastjet it is a slightly modified version that
2327we distribute, where an internal \ttt{sort} function has been replaced
2328with a \ttt{stable\_sort}, to ensure reproducibility of results across
2329compilers and architectures (results are unchanged when the results of
2330the sort are unambiguous).
2331
2332Note: this algorithm is IR$_{2+1}$ unsafe (in the limit of zero seed
2333threshold). It is to be deprecated for new experimental or theoretical
2334analyses.
2335
2336%......................................................................
2337\subsubsection{CMS iterative cone}
2338%
2339This iterative cone algorithm with progressive removal was used by CMS
2340during the preparation for the LHC.
2341\begin{lstlisting}
2342  #include "fastjet/CMSIterativeConePlugin.hh"
2343  // ...
2344  CMSIterativeConePlugin (double ConeRadius, double SeedThreshold=0.0);
2345\end{lstlisting}
2346
2347
2348The underlying code for this algorithm was extracted from the CMSSW
2349web site, with certain small service routines having been rewritten by
2350the \fastjet authors.
2351%
2352Permission to redistribute the resulting code with \fastjet has been
2353granted by CMS under the terms of the GPL license.
2354%
2355The code was validated by clustering 1000 events with the original
2356version of the CMS software and comparing the output to the clustering
2357performed with the \fastjet plugin.
2358%
2359The jet contents were identical in all cases. However the jet momenta
2360differed at a relative precision level of $10^{-7}$, related to the
2361use of single-precision arithmetic at some internal stage of the CMS
2362software (while the \fastjet version is in double precision).
2363
2364
2365Note: this algorithm is Coll$_{3+1}$ unsafe~\cite{antikt}. It is to be
2366deprecated for new experimental or theoretical analyses.
2367
2368
2369
2370\subsubsection{PxCone}
2371
2372The PxCone algorithm is an iterative cone with midpoints and a
2373split-drop procedure:
2374\begin{lstlisting}
2375  #include "fastjet/PxConePlugin.hh"
2376  // ...
2377  PxConePlugin (double  cone_radius      ,
2378		double  min_jet_energy = 5.0  ,
2379		double  overlap_threshold = 0.5,
2380                bool    E_scheme_jets = false);
2381\end{lstlisting}
2382It includes a threshold on the minimum transverse energy for a cone
2383(jet) to be included in the split-drop stage.
2384%
2385If \verb|E_scheme_jets| is true then the plugin applies an $E$-scheme
2386recombination to provide the momenta of the final jets (by default an
2387$E_t$ type recombination scheme is used).
2388
2389The base code for this plugin is written in Fortran and, on some
2390systems, problems have been reported at the link stage due to mixing
2391Fortran and C++.
2392%
2393The Fortran code has been modified by the \fastjet authors to provide
2394the same jets regardless of the order of the input particles.
2395%
2396This involved a small modification of the midpoint procedure, which
2397can have a minor effect on the final jets and should make the algorithm
2398correspond to the description of \cite{Seymour:2006vv}.
2399
2400The underlying code for this algorithm was written by Luis del Pozo
2401and Michael Seymour with input also from David Ward~\cite{PxCone}
2402%
2403and they have granted permission for their code to be distributed with
2404\fastjet under the terms of the GPL license.
2405% %
2406
2407This algorithm is IR$_{3+1}$ unsafe. It is to be deprecated for
2408new experimental or theoretical analyses.
2409
2410
2411\subsubsection{TrackJet}
2412%
2413This algorithm has been used at the Tevatron for identifying jets from
2414charged-particle tracks in underlying-event studies~\cite{Affolder:2001xt}.
2415%
2416\begin{lstlisting}
2417  #include "fastjet/TrackJetPlugin.hh"
2418  // ...
2419  TrackJetPlugin (double radius,
2420		  RecombinationScheme jet_recombination_scheme=pt_scheme,
2421		  RecombinationScheme track_recombination_scheme=pt_scheme);
2422\end{lstlisting}
2423Two recombination schemes are involved: the first one indicates how
2424momenta are recombined to provide the final jets (once particle-jet
2425assignments are known), the second one indicates how momenta are
2426combined in the procedure that constructs the jets.
2427
2428The underlying code for this algorithm was written by the \fastjet
2429authors, based on code extracts from the (GPL) Rivet implementation, written
2430by Andy Buckley with input from Manuel Bahr and Rick Field.
2431%
2432Since version 3.0 of \fastjet it is a slightly modified version that
2433we distribute, where an internal \ttt{sort} function has been replaced
2434with a \ttt{stable\_sort}, to ensure reproducibility of results across
2435compilers and architectures (results are unchanged when the results of
2436the sort are unambiguous, which is the usual case).
2437
2438Note: this algorithm is believed to be Coll$_{3+1}$ unsafe. It is to
2439be deprecated for new experimental or theoretical analyses.
2440
2441\subsubsection{GridJet}
2442%
2443GridJet allows you to define a grid and then cluster particles such
2444that all particles in a common grid cell combine to form a jet.
2445%
2446Its main interest is in providing fast clustering for high
2447multiplicities (the clustering time scales linearly with the number of
2448particles).
2449%
2450The jets that it forms are not always physically meaningful: for
2451example, a genuine physical jet may lie at the corner of 4 grid cells
2452and so be split up somewhat arbitrarily into 4 pieces.
2453%
2454It is therefore not intended to be used for standard jet finding.
2455%
2456However for some purposes (such as background estimation) this
2457drawback is offset by the greater uniformity of the area of the jets.
2458%
2459Its interface is as follows
2460\begin{lstlisting}
2461  #include "fastjet/GridJetPlugin.hh"
2462  // ...
2463  GridJetPlugin (double ymax, double requested_grid_spacing);
2464\end{lstlisting}
2465creating a grid that covers $|y|<$\ttt{ymax} with a grid spacing close
2466to the \ttt{requested\_grid\_spacing}: the spacings chosen in $\phi$
2467and $y$ are those that are closest to the requested spacing while also
2468giving an integer number of grid cells that fit exactly into the
2469rapidity and $0<\phi <2\pi$ ranges.
2470
2471Note that for background estimation purposes the
2472\ttt{GridMedianBackgroundEstimator} is much faster than using the
2473\ttt{GridJetPlugin} with ghosts and a
2474\ttt{JetMedianBackgroundEstimator}.
2475
2476The underlying code for this algorithm was written by the \fastjet
2477authors.
2478
2479
2480%----------------------------------------------------------------------
2481\subsection{Plugins for $e^+e^-$ collisions}
2482\label{sec:other-ee-plugins}
2483
2484%......................................................................
2485\subsubsection{Cambridge algorithm}
2486\label{sec:ee-cam}
2487The original $\ee$ Cambridge~\cite{CamOrig} algorithm is provided as a plugin:
2488\begin{lstlisting}
2489  #include "fastjet/EECambridgePlugin.hh"
2490  // ...
2491  EECambridgePlugin (double ycut);
2492\end{lstlisting}
2493This algorithms performs sequential recombination of the pair of
2494particles that is closest in angle, except when $y_{ij} =
2495\frac{2\min(E_i^2,E_j^2)}{Q^2}(1-\cos\theta) > y_{cut}$, in which case
2496the less energetic of $i$ and $j$ is labelled a jet, and the other
2497member of the pair remains free to cluster.
2498
2499To access the jets, the user should use the \verb|inclusive_jets()|,
2500\ie as they would for the majority of the $pp$ algorithms.
2501
2502The underlying code for this algorithm was written by the \fastjet
2503authors.
2504
2505%......................................................................
2506\subsubsection{Jade algorithm}
2507\label{sec:ee-jade}
2508The JADE algorithm~\cite{Bartel:1986ua,Bethke:1988zc}, a sequential
2509recombination algorithm with distance measure $d_{ij} = 2E_i E_j
2510(1-\cos\theta)$, is available through
2511\begin{lstlisting}
2512  #include "fastjet/JadePlugin.hh"
2513  // ...
2514  JadePlugin ();
2515\end{lstlisting}
2516To access the jets at a given $y_{cut} = d_{cut}/Q^2$, the user
2517should call \ttt{ClusterSequence::exclusive\_jets\_ycut(double ycut)}.
2518
2519Note: the JADE algorithm has been used with various recombination
2520schemes. The current plugin will use whatever recombination scheme the
2521user specifies with for the jet definition. The default $E$-scheme is
2522what was used in the original JADE publication \cite{Bartel:1986ua}.
2523%
2524To modify the recombination scheme, the user may first construct the
2525jet definition and then use either of
2526\begin{lstlisting}
2527  void JetDefinition::set_recombination_scheme(RecombinationScheme recomb_scheme);
2528  void JetDefinition::set_recombiner(const Recombiner * recomb)
2529\end{lstlisting}
2530(cf.~sections~\ref{sec:recomb_schemes}, \ref{sec:recombiner}) to modify the
2531recombination scheme.
2532
2533The underlying code for this algorithm was written by the \fastjet
2534authors.
2535
2536%......................................................................
2537\subsubsection{Spherical SISCone algorithm}
2538\label{sec:spherical-siscone}
2539
2540The spherical SISCone algorithm is an extension~\cite{SpheriSISCone}
2541to spherical coordinates of the hadron-collider SISCone
2542algorithm~\cite{SISCone}.
2543\begin{lstlisting}
2544  #include "fastjet/SISConeSphericalPlugin.hh"
2545  // ...
2546  SISConeSphericalPlugin(double R,
2547                         double overlap_threshold
2548			 double protojet_Emin = 0.0,
2549			 bool   caching = false,
2550			 SISConeSphericalPlugin::SplitMergeScale
2551                           split_merge_scale = SISConeSphericalPlugin::SM_Etilde,
2552			 double split_merge_stopping_scale = 0.0);
2553\end{lstlisting}
2554The functionality follows directly that of \ttt{SISConePlugin},
2555including options for using a split--merge step (the default) or
2556progressive removal.
2557
2558Note that the underlying implementation of spherical SISCone is
2559optimised for large $N$.
2560%
2561An alternative implementation that is faster for $N \lesssim 10$ was
2562presented in~\cite{Weinzierl:2011jx}. That reference also contains a
2563nice description of the algorithm.
2564
2565
2566%======================================================================
2567\section{Selectors}
2568\label{sect:selectors}
2569
2570Analyses often place constraints (cuts) on jets' transverse momenta,
2571rapidity, maybe consider only some $N$ hardest jets, etc.
2572%
2573There are situations in which it is convenient to be able to define
2574a basic set of jet cuts in one part of a program and then have it used
2575elsewhere.
2576%
2577To allow for this, we provide a \ttt{fastjet::Selector} class, available
2578through
2579\begin{lstlisting}
2580  #include "fastjet/Selector.hh"
2581\end{lstlisting}
2582
2583%----------------------------------------------------------------------
2584\subsection{Essential usage}
2585
2586
2587As an example of how \ttt{Selector}s are used, suppose that we  have a vector of jets, \ttt{jets},
2588and wish to select those that have rapidities $|y|<2.5$ and transverse
2589momenta above $20\GeV$. We might write the following:
2590\begin{lstlisting}
2591  Selector select_rapidity = SelectorAbsRapMax(2.5);
2592  Selector select_pt       = SelectorPtMin(20.0);
2593  Selector select_both     = select_pt && select_rapidity;
2594
2595  vector<PseudoJet> selected_jets = select_both(jets);
2596\end{lstlisting}
2597Here, \ttt{Selector} is a class, while \ttt{SelectorAbsRapMax} and
2598\ttt{SelectorPtMin} are functions that return an instance of the
2599\ttt{Selector} class containing the internal information needed to
2600carry out the selection.
2601%
2602\ttt{Selector::operator(const vector<PseudoJet> \& jets)} takes the
2603jets given as input and returns a vector containing those that pass
2604the selection cuts. The logical operations \ttt{\&\&}, \ttt{||} and
2605\ttt{!} enable different selectors to be combined.
2606%
2607
2608Nearly all selectors, like those above, apply jet by jet (the function
2609\ttt{Selector::applies\_jet\_by\_jet()} returns \ttt{true}).
2610%
2611For these, one can
2612query whether a single jet passes the selection with the help of the
2613function \ttt{bool Selector::pass(const PseudoJet \&)}.
2614
2615There are also selectors that only make sense applied to an ensemble
2616of jets.
2617%
2618This is the case specifically for \ttt{SelectorNHardest(unsigned
2619  int n)}, which, acting on an ensemble of jets, selects the $n$ jets with
2620largest transverse momenta. If there are fewer than $n$ jets, then all
2621jets pass.
2622
2623When a selector is applied to an ensemble of jets one can also use
2624\begin{lstlisting}
2625  Selector::sift(vector<PseudoJet> & jets,
2626                 vector<PseudoJet> & jets_that_pass,
2627		 vector<PseudoJet> & jets_that_fail)
2628\end{lstlisting}
2629to obtain the vectors of \ttt{PseudoJet}s that pass or fail the selection.
2630
2631For selectors that apply jet-by-jet, the selectors on either
2632side of the logical operators \ttt{\&\&} and \ttt{||} naturally
2633commute.
2634%
2635For operators that act only on the ensemble of jets the behaviour needs
2636specifying.
2637%
2638The design choice that we have made is that
2639\begin{lstlisting}
2640  SelectorNHardest(2)    && SelectorAbsRapMax(2.5)
2641  SelectorAbsRapMax(2.5) && SelectorNHardest(2)
2642\end{lstlisting}
2643give identical results: in logical combinations of selectors, each
2644constituent selector is applied independently to the ensemble of jets,
2645and then a decision whether a jet passes is determined from the
2646corresponding logical combination of each of the selectors'
2647results. Thus, here only jets that are among the 2 hardest of the
2648whole ensemble and that have $|y|<2.5$ will be selected.
2649%
2650If one wishes to first apply a rapidity cut, and {\sl then} find the 2
2651hardest among those jets that pass the rapidity cut, then one should
2652instead use the \ttt{*} operator:
2653\begin{lstlisting}
2654  SelectorNHardest(2)  *  SelectorAbsRapMax(2.5)
2655\end{lstlisting}
2656In this combined selector, the right-hand selector is applied first,
2657and then the left-hand selector is applied to the results of the
2658right-hand selection.
2659
2660A complementary selector can also be defined using the negation operator. For
2661instance
2662\begin{lstlisting}
2663  Selector sel_allbut2hardest = !SelectorNHardest(2);
2664\end{lstlisting}
2665Note that, if directly applying (as opposed to first defining) a similar
2666negated selector to a collection
2667of jets, one should write
2668\begin{lstlisting}
2669  vector<PseudoJet> allbut2hardest = (!SelectorNHardest(2))(jets);
2670\end{lstlisting}
2671with the brackets around the selector definition being now necessary due to
2672\ttt{()} having higher precedence in C++ than Boolean operators.
2673
2674
2675A user can obtain a string describing a given \ttt{Selector}'s action by
2676calling its \ttt{description()} member function.
2677%
2678This behaves sensibly also for compound selectors.
2679
2680New selectors can be implemented as described in
2681section~\ref{sec:new-selectors}.
2682
2683
2684%......................................................................
2685\subsubsection{Other information about selectors}
2686
2687
2688Selectors contain a certain amount of additional information that can
2689provide useful hints to the functions using them.
2690
2691One such piece of information is a selector's rapidity extent,
2692accessible through a \ttt{get\_rapidity\_extent(rapmin,rapmax)} call,
2693which is useful in the context of background estimation
2694(section~\ref{sec:BackgroundEstimator}).
2695%
2696If it is not sensible to talk about a rapidity extent for a given
2697selector (e.g.\ for \ttt{SelectorPtMin}) the rapidity limits that are
2698returned are the largest (negative and positive) numbers that can be
2699represented as doubles.
2700%
2701The function \ttt{is\_geometric()} returns true if the selector places
2702constraints only on rapidity and azimuth.
2703
2704Selectors may also have areas associated with them (in analogy with
2705jet areas, section~\ref{sec:areas}).
2706%
2707The \ttt{has\_finite\_area()} member function returns true if a selector has a
2708meaningful finite area. The \ttt{area()} function returns this area.
2709%
2710In some cases the area may be computed using ghosts (by default with
2711ghosts of area $0.01$; the user can specify a different ghost area as
2712an argument to the \ttt{area} function).
2713
2714
2715
2716%......................................................................
2717\subsection{Available selectors}
2718
2719\subsubsection{Absolute kinematical cuts}
2720
2721A number of selectors have been implemented following the naming
2722convention \ttt{Selector}{\it\{Var\}\{LimitType\}}.
2723%
2724The {\it\{Var\}} indicates which variable is being cut on, and can be
2725one of
2726\begin{lstlisting}
2727       pt, Et, E, Mass, Rap, AbsRap, Eta, AbsEta
2728\end{lstlisting}
2729%
2730The {\it\{LimitType\}} indicates whether one places a lower-limit on
2731the variable, an upper limit or a range, corresponding to the choices
2732\begin{lstlisting}
2733       Min, Max, Range
2734\end{lstlisting}
2735%
2736A couple of examples are
2737\begin{lstlisting}
2738  SelectorPtMin(25.0)        // Selects $p_t>25$ (units are user's default for momenta)
2739  SelectorRapRange(1.9,4.9)  // Selects $1.9<y<4.9$
2740\end{lstlisting}
2741Following a similar naming convention, there are also
2742\ttt{SelectorPhiRange(}$\phi_{\min},\phi_{\max}$\ttt{)} and
2743\ttt{SelectorRapPhiRange(}$y_{\min},y_{\max},\phi_{\min},\phi_{\max}$\ttt{)}.
2744
2745\subsubsection{Relative kinematical cuts}
2746
2747Some selectors take a \emph{reference jet}.
2748%
2749They have been developed because it is can be useful for a selector to
2750make its decision based on information about some other jet.
2751%
2752For example one might wish to select all jets within some distance of
2753a given reference jet; or all jets whose transverse momentum is at
2754least some fraction of a reference jet's.
2755%
2756That reference jet may change from event to event, or even from one
2757invocation of the Selector to the next, even though the Selector is
2758fundamentally performing the same underlying type of action.
2759
2760The available selectors of this kind are:
2761\begin{lstlisting}
2762  SelectorCircle($R$)                   // a circle of radius R around the reference jet
2763  SelectorDoughnut($R_{in}$, $R_{out}$)          // a doughnut between $R_{in}$ and $R_{out}$
2764  SelectorStrip(half_width)           // a rapidity strip 2*half_width large
2765  SelectorRectangle(half_rap_width, half_phi_width) // a rectangle in rapidity and phi
2766  SelectorPtFractionMin($f$)            // $p_t$ larger than $f p_t^{ref}$
2767\end{lstlisting}
2768%
2769One example of selectors taking a reference jet is the following.
2770First, one constructs the selector,
2771\begin{lstlisting}
2772  Selector sel = SelectorCircle(1.0);
2773\end{lstlisting}
2774Then if one is interested in the subset of \ttt{jets} near
2775\ttt{jet1}, and then those near \ttt{jet2}, one performs the following
2776operations:
2777\begin{lstlisting}
2778  sel.set_reference(jet1);
2779  vector<PseudoJet> jets_near_jet1 = sel(jets);
2780
2781  sel.set_reference(jet2);
2782  vector<PseudoJet> jets_near_jet2 = sel(jets);
2783\end{lstlisting}
2784If one uses a selector that takes a reference without the reference having been
2785actually set, an exception will be thrown.
2786%
2787If one sets a reference for a compound selector, the reference is
2788automatically set for all components that take a reference.
2789%
2790One can verify whether a given selector takes a reference by calling
2791the member function
2792\begin{lstlisting}
2793  bool Selector::takes_reference() const;
2794\end{lstlisting}
2795Attempting to set a reference for a Selector that returns \ttt{false}
2796here will cause an exception to be thrown.
2797%
2798
2799\subsubsection{Other selectors}
2800
2801The following selectors are also available:
2802
2803\begin{lstlisting}
2804  SelectorNHardest($n$)      //  selects the $n$ hardest jets
2805  SelectorIsPureGhost()    //  selects jets that are made exclusively of ghost particles
2806  SelectorIsZero()         //  selects jets with zero momentum
2807  SelectorIdentity()       //  selects everything. Included for completeness
2808\end{lstlisting}
2809
2810
2811
2812
2813%======================================================================
2814\section{Jet areas}
2815\label{sec:areas}
2816
2817Jet areas provide a measure of the surface in the $y$-$\phi$ plane
2818over which a jet extends, or, equivalently, a measure of a jet's
2819susceptibility to soft contamination.
2820
2821Since a jet is made up of only a finite number of particles, one needs
2822a specific definition in order to make its area an unambiguous
2823concept. Three definitions of area have been proposed
2824in~\cite{CSSAreas} and implemented in \fastjet:
2825\begin{itemize}
2826\item {\it Active} areas add a uniform background of extremely soft massless
2827  `ghost' particles to the event and allow them to participate in the
2828  clustering. The area of a given jet is proportional to the number of
2829  ghosts it contains.
2830  %
2831  Because the ghosts are extremely soft (and sensible jet algorithms
2832  are infrared safe), the presence of the ghosts does not affect the
2833  set of user particles that end up in a given jet.
2834  %
2835  Active areas give a measure of a jet's sensitivity to diffuse
2836  background noise.
2837
2838\item {\it Passive} areas are defined as follows: one adds a single randomly
2839  placed ghost at a time to the event. One examines which jet (if any)
2840  the ghost ends up in. One repeats the procedure many times and the
2841  passive area of a jet is then proportional to the probability of it
2842  containing the ghost.
2843  %
2844  Passive areas give a measure of a jet's sensitivity to point-like
2845  background noise.
2846
2847\item The {\it Voronoi} area of a jet is the sum of the Voronoi areas of its
2848  constituent particles. The Voronoi area of a particle is obtained by
2849  determining the Voronoi diagram for the event as a whole, and
2850  intersecting the Voronoi cell of the particle with a circle of
2851  radius $R$ centred on the particle. Note that for the $k_t$
2852  algorithm (but not in general for other algorithms) the Voronoi area
2853  of a jet coincides with its passive area.
2854\end{itemize}
2855In the limit of very densely populated events, all area definitions
2856lead to the same jet-area results~\cite{CSSAreas}.\footnote{This can
2857  be useful when one area is particularly expensive to calculate: for
2858  example active areas for SISCone tend to be memory and CPU
2859  intensive; however, for dense events, they can be adequately
2860  replaced with passive areas, which, for SISCone, are computationally
2861  more straightforward.}
2862
2863The area of a jet can be calculated either as a scalar, or as a 4-vector.
2864Essentially the scalar case corresponds to counting the number of
2865ghosts in the jet; the $4$-vector case corresponds to summing their
28664-vectors, normalised such that for a narrow jet, the transverse
2867component of the $4$-vector is equal to the scalar area.
2868
2869To access jet areas, the user is exposed to two main classes:
2870\begin{lstlisting}
2871  class fastjet::AreaDefinition;
2872  class fastjet::ClusterSequenceArea;
2873\end{lstlisting}
2874with input particles, a jet definition and an area definition being
2875supplied to a \ttt{ClusterSequenceArea} in order to obtain jets with
2876area information.
2877%
2878Typical usage would be as follows:
2879\begin{lstlisting}
2880  #include "fastjet/ClusterSequenceArea.hh"
2881  // ...
2882  double ghost_maxrap = 5.0; // e.g. if particles go up to y=5
2883  AreaDefinition area_def(active_area, GhostedAreaSpec(ghost_maxrap));
2884  ClusterSequenceArea clust_seq(input_particles, jet_def, area_def);
2885  vector<PseudoJet> jets = sorted_by_pt(clust_seq.inclusive_jets());
2886  double area_hardest_jet = jets[0].area();
2887\end{lstlisting}
2888Details are to be found below and an example program is given as
2889\ttt{example/06-area.cc}.
2890
2891
2892When jet areas are to be used to establish the level of a diffuse noise
2893that might be present in the event (e.g.\ from underlying event particles
2894or pileup), and maybe subtract it from jets, further classes such as
2895\ttt{fastjet::JetMedianBackgroundEstimator} and
2896\ttt{fastjet::Subtractor} are useful. This topic is discussed in
2897Section \ref{sec:BackgroundEstimator} and an example program is given
2898in \ttt{example/07-subtraction.cc}.
2899
2900
2901
2902%----------------------------------------------------------------------
2903\subsection{\tt AreaDefinition}
2904
2905Area definitions are contained in the \ttt{AreaDefinition}
2906class. Its two main constructors are:
2907\begin{lstlisting}
2908  AreaDefinition(fastjet::AreaType area_type,
2909                 fastjet::GhostedAreaSpec ghost_spec);
2910\end{lstlisting}
2911for the various active and passive areas (which all involve ghosts)
2912and
2913\begin{lstlisting}
2914  AreaDefinition(fastjet::VoronoiAreaSpec voronoi_spec);
2915\end{lstlisting}
2916for the Voronoi area. A default constructor exists, and provides an
2917active area with a \ttt{ghost\_spec} that is acceptable for a majority
2918of area measurements with clustering algorithms and typical Tevatron
2919and LHC rapidity coverage.
2920
2921Information about the current \ttt{AreaDefinition} can be retrieved
2922with the help of \ttt{description()}, \ttt{area\_type()},
2923\ttt{ghost\_spec()} and \ttt{voronoi\_spec()} member functions.
2924
2925\subsubsection{Ghosted Areas (active and passive)}
2926\label{sec:ghosted-areas}
2927
2928There are two variants each of the active and passive areas, as
2929defined by the \ttt{AreaType} \ttt{enum}:
2930\begin{lstlisting}
2931  enum AreaType{ [...],
2932                 active_area,
2933                 active_area_explicit_ghosts,
2934                 one_ghost_passive_area,
2935                 passive_area,
2936                 [...]};
2937\end{lstlisting}
2938The two active variants give identical results for the areas of hard
2939jets.
2940%
2941The second one explicitly includes the ghosts when the user requests
2942the constituents of a jet and also leads to the presence of ``pure
2943ghost'' jets.
2944%
2945The first of the passive variants
2946explicitly runs through the procedure mentioned above, \ie it clusters
2947the events with one ghost at a time, and repeats this for very many
2948ghosts. This can be quite slow, so we also provide the
2949\ttt{passive\_area} option, which makes use of information specific to
2950the jet algorithm in order to speed up the passive-area
2951determination.\footnote{This ability is provided for $k_t$,
2952  Cambridge/Aachen, anti-$k_t$ and the SISCone plugin. In the case of
2953  $k_t$ it is actually a Voronoi area that is used, since this can be
2954  shown to be equivalent to the passive area~\cite{CSSAreas} (though
2955  some approximations are made for 4-vector areas).
2956  %
2957  For other algorithms it defaults back to the
2958  \texttt{one\_ghost\_passive\_area} approach.}
2959
2960In order to carry out a clustering with a ghosted area determination,
2961the user should also create an object that specifies how to distribute
2962the ghosts.\footnote{Or accept a default --- which uses the default
2963  values listed in the explicit constructor and $\texttt{ghost\_maxrap} =
2964  6$} %
2965This is done via the class \ttt{GhostedAreaSpec} whose
2966constructor is
2967\begin{lstlisting}
2968  GhostedAreaSpec(double ghost_maxrap,
2969                  int    repeat        = 1,   double ghost_area    = 0.01,
2970                  double grid_scatter  = 1.0, double pt_scatter    = 0.1,
2971                  double mean_ghost_pt = 1e-100);
2972\end{lstlisting}
2973The ghosts are distributed on a uniform grid in $y$ and $\phi$, with
2974small random fluctuations to avoid clustering degeneracies.
2975
2976The \ttt{ghost\_maxrap} variable defines the maximum rapidity up to
2977which ghosts are generated.
2978%
2979If one places ghosts well beyond the particle acceptance (at least $R$
2980beyond it), then jet areas also stretch beyond the acceptance, giving
2981a measure of the jet's full extent in rapidity and azimuth.
2982%
2983If ghosts are placed only up to the particle acceptance, then the jet
2984areas are clipped at that acceptance and correspond more closely
2985to a measure of the jet's susceptibility to contamination from
2986accepted soft particles.
2987%
2988This is relevant in particular for jets within a distance $R$ of the
2989particle acceptance boundary.
2990%
2991The two choices are illustrated in fig.~\ref{fig:ghost-placement}.
2992%
2993To define more complicated ghost acceptances it is possible to replace
2994\ttt{ghost\_maxrap} with a \ttt{Selector}, which must be purely
2995geometrical and have finite rapidity extent.
2996
2997\begin{figure}
2998  \centering
2999  \includegraphics[width=0.48\textwidth]{figs/ghost-extent-y4}\hfill
3000  \includegraphics[width=0.48\textwidth]{figs/ghost-extent-y3}
3001  \caption{Two choices for ghost placement. The grey area in each plot
3002    indicates
3003    the region containing ghosts, while the dots are particles, which
3004    here are accepted up to $|y|<3$.
3005    %
3006    The circular regions indicate the areas that will be found for two
3007    particular jets.
3008    %
3009    In the left-hand case, with ghosts that extend well beyond the
3010    acceptance for particles, jet areas are unaffected by the particle
3011    acceptance;
3012    %
3013    in the right-hand case, with ghosts placed only up to the
3014    acceptance limit, jet areas are clipped at the edge of the
3015    acceptance.  }
3016  \label{fig:ghost-placement}
3017\end{figure}
3018
3019The \ttt{ghost\_area} parameter in the \ttt{GhostedAreaSpec}
3020constructor is the area associated with a single ghost.
3021%
3022The number of ghosts is inversely proportional to the ghost area, and
3023so a smaller area leads to a longer CPU-time for clustering. However
3024small ghost areas give more accurate results.
3025%
3026We have found the default ghost area given above to be adequate for
3027most applications.
3028%
3029Smaller ghost areas are beneficial mainly for high-precision
3030determinations of areas of jets with small $R$.
3031
3032By default, one set of ghosts is generated for each event that is
3033clustered.
3034%
3035The small random fluctuations in ghost positions and $p_t$'s,
3036introduced to break clustering degeneracies, mean that for repeated
3037clustering of the same event a given hard jet's area will be different
3038after each clustering.
3039%
3040This is especially true for sparse events, where a jet's particle
3041content fails to accurately delineate the boundaries of the jet.
3042%
3043For the \texttt{active\_area} choice (and certain passive areas),
3044specifying $\ttt{repeat} > 1$ causes \fastjet to directly cluster the
3045same hard event with multiple ghost sets.
3046%
3047This results in a pseudo-Monte Carlo type evaluation of the jet areas.
3048%
3049A statistical uncertainty on the area is available for each jet,
3050through the \ttt{jet.area\_error()} call.
3051%
3052It is calculated as the standard deviation of areas obtained for that
3053jet, divided by $\sqrt{\ttt{repeat}-1}$.
3054%
3055While there are situations in which this facility is useful, for most
3056applications of jet areas it is sufficient to use
3057$\ttt{repeat}=1$.\footnote{%
3058  Several parameters are available to control the properties and
3059  randomness of the ghosts: each ghost's position differs from an
3060  exact grid vertex by a random amount distributed uniformly in the
3061  range $\pm \frac12 \texttt{grid\_scatter}$ times the grid spacing in
3062  both the rapidity and azimuth directions.
3063  %
3064  Each ghost's $p_t$ is distributed randomly in the range $(1 \pm \frac12
3065  \texttt{pt\_scatter})$ times \texttt{mean\_ghost\_pt}.
3066  %
3067  For nearly all applications, it makes sense to use the default
3068  values.
3069  %
3070  Facilities are also available to set and retrieve the seeds for the
3071  random-number generator, notably through the
3072  \texttt{set\_random\_status(...)} and
3073  \texttt{get\_random\_status(...)} members of
3074  \texttt{GhostedAreaSpec}.  }
3075
3076
3077
3078After initialisation, the parameters can be modified and retrieved
3079respectively with calls such as \ttt{set\_ghost\_area(...)} and
3080\ttt{ghost\_maxrap()} (similarly for the other
3081parameters\footnote{In versions of \fastjet prior to 3.0.1, the names
3082  \texttt{mean\_ghost\_kt} and \texttt{kt\_scatter} should be used
3083  rather than \texttt{mean\_ghost\_pt} and \texttt{pt\_scatter}. The
3084  former names will be maintained for the foreseeable future.}).
3085%
3086A textual description of the \ttt{GhostedAreaSpec} can be obtained, as
3087usual, with the \ttt{description()} member function.
3088
3089% Finally, an alternative constructor
3090% \begin{lstlisting}
3091%   GhostedAreaSpec(const  Selector & selector,
3092%                   int    repeat        = 1,
3093%                   double ghost_area    = 0.01,
3094%                   double grid_scatter  = 1.0,
3095%                   double pt_scatter    = 0.1,
3096%                   double mean_ghost_pt = 1e-100);
3097% \end{lstlisting}
3098% allows the user to have ghosts placed in the region specified by the
3099% \ttt{selector}, which must be purely geometrical and have finite
3100% rapidity extent.
3101% %
3102% This option is useful, for example, if one wishes to place ghosts in a
3103% manner that reflects a detector's acceptance for particles.
3104
3105\subsubsection{Voronoi Areas}
3106\label{sec:voronoi-areas}
3107
3108The Voronoi areas of jets are evaluated by summing the corresponding
3109Voronoi areas of the jets' constituents. The latter are obtained
3110by considering the intersection between
3111the Voronoi cell of each particle and a circle of radius $R$ centred
3112on the particle's position in the rapidity-azimuth plane.
3113
3114The jets' Voronoi areas can be obtained from
3115\ttt{ClusterSequenceArea} by passing
3116the proper \ttt{VoronoiAreaSpec} specification to
3117\ttt{AreaDefinition}. Its constructors are
3118\begin{lstlisting}
3119  /// default constructor (effective_Rfact = 1)
3120  VoronoiAreaSpec() ;
3121
3122  /// constructor that allows you to set effective_Rfact
3123  VoronoiAreaSpec(double effective_Rfact) ;
3124\end{lstlisting}
3125The second constructor allows one to modify (by a multiplicative
3126factor \ttt{effective\_Rfact}) the radius of the circle which is
3127intersected with the Voronoi cells. With $\ttt{effective\_Rfact} = 1$,
3128for the $k_t$ algorithm, the Voronoi area is equivalent to the passive
3129area.
3130%
3131Information about the specification in use is returned by
3132\ttt{effective\_Rfact()} and \ttt{description()} member functions.
3133
3134The Voronoi areas are calculated with the help of Fortune's ($N \ln
3135N$) Voronoi diagram generator for planar static point
3136sets~\cite{Fortune}.
3137
3138One use for the Voronoi area is in background determination with the
3139$k_t$ algorithm (see below, section~\ref{sec:BackgroundEstimator}): with
3140the choice $\ttt{effective\_Rfact}\simeq0.9$ it provides an acceptable
3141approximation to the $k_t$ algorithm's active area and is often
3142significantly faster to compute than the active area.
3143%
3144Note that it is not currently possible to clip Voronoi areas with a
3145given particle acceptance.
3146%
3147As a result, given particles up to $|y|<y_{\max}$, only jets with $|y|
3148\lesssim y_{\max} - R$ will have areas that reflect the jets'
3149sensitivity to accepted particle contamination.
3150%
3151It is only these jets that should then be used for background
3152determinations.
3153
3154%----------------------------------------------------------------------
3155\subsection{\tt ClusterSequenceArea}
3156
3157This is the class%
3158%
3159\footnote{
3160  \texttt{ClusterSequenceArea} is derived from
3161  \texttt{ClusterSequenceAreaBase} (itself derived from
3162  \texttt{ClusterSequence}) and makes use of one among
3163  \texttt{ClusterSequenceActiveAreaExplicitGhosts},
3164  \texttt{ClusterSequenceActiveArea},
3165  \texttt{ClusterSequencePassiveArea},
3166  \texttt{ClusterSequence1GhostPassiveArea} or
3167  \texttt{ClusterSequenceVoronoiArea} (all of them in the \texttt{fastjet}
3168  namespace of course), according to the choice
3169  made with \texttt{AreaDefinition}. The user can also use these
3170  classes directly.
3171  %
3172  \texttt{ClusterSequenceActiveAreaExplicitGhosts} is particularly
3173  useful in that it allows the user to specify their own set of ghost
3174  particles.
3175  %
3176  This is exploited to provide area support in a number of the
3177  transformers of section~\ref{sec:transformers}.
3178}
3179%
3180used for producing a cluster sequence that also calculates jet areas.
3181Its constructor is
3182\begin{lstlisting}
3183  template<class L> ClusterSequenceArea(const std::vector<L> & input_particles,
3184                                        const JetDefinition & jet_def,
3185	                                const AreaDefinition & area_def);
3186\end{lstlisting}
3187and the class includes the methods
3188\begin{lstlisting}
3189  /// Return a reference to the area definition
3190  virtual const AreaDefinition & area_def() const;
3191
3192  /// Returns an estimate of the area contained within the selector that is free of jets.
3193  /// The selector needs to have a finite area and be applicable jet by jet.
3194  /// The function returns 0 if active_area_explicit_ghosts was used.
3195  virtual double empty_area(const Selector & selector) const;
3196\end{lstlisting}
3197
3198As long as an instance of this class is in scope, a user can access
3199information about the area of its jets using the following methods of
3200\ttt{PseudoJet}:
3201\begin{lstlisting}
3202  /// Returns the scalar area associated with the given jet
3203  double area = jet.area();
3204
3205  /// Returns the error (uncertainty) associated with the determination of the
3206  /// scalar area of the jet; gives zero when the repeat=1 and for passive/Voronoi areas
3207  double area_error = jet.area_error();
3208
3209  /// Returns a PseudoJet whose 4-vector is defined by the following integral
3210  ///
3211  ///       $\int dy d\phi$ PseudoJet($y$,$\phi$,$p_t=1$) * $\Theta$("$y,\phi$ inside jet boundary")
3212  ///
3213  /// where PseudoJet($y$,$\phi$,$p_t=1$) is a 4-vector with the given rapidity ($y$),
3214  /// azimuth ($\phi$) and $p_t=1$, while $\Theta$("$y,\phi$ inside jet boundary") is 1
3215  /// when $y,\phi$ define a direction inside the jet boundary and 0 otherwise.
3216  PseudoJet area_4vector = jet.area_4vector();
3217
3218  /// When using active_area_explicit_ghosts, returns true for jets made
3219  /// exclusively of ghosts and for ghost constituents.
3220  bool is_pure_ghost = jet.is_pure_ghost();
3221\end{lstlisting}
3222In the limit of small-$R$ jets, the transverse component of the
32234-vector area is close to the scalar area; for moderate $R$ values,
3224the transverse component of the 4-vector area is smaller by a factor
3225that reads $1 - R^2/8 + R^4/192 + \order{R^6}$~for the case of
3226circular jets~\cite{Dasgupta:2007wa}.
3227%
3228Note that 4-vector areas are not currently computed exactly for
3229Voronoi areas of jets in sparse events, insofar as the 4-vector area
3230of each particle's Voronoi cell is approximated as massless and
3231pointing in the direction of the particle.
3232
3233%----------------------------------------------------------------------
3234\section{Background estimation and subtraction}
3235\label{sec:BackgroundEstimator}
3236
3237Events with hard jets are often accompanied by a more diffuse
3238``background'' of relatively soft particles, for example from the
3239underlying event (in $pp$ or PbPb collisions) or from pileup (in $pp$
3240collisions).
3241%
3242For many physical applications, it is useful to be able to
3243estimate characteristics of the background on an event-by-event basis,
3244for example the $p_t$ per unit area ($\rho$), or fluctuations from
3245point to point ($\sigma$).
3246%
3247One use of this information is to correct the hard jets for the soft
3248contamination, as discussed below in section~\ref{sec:subtractor}.
3249
3250One of the issues in characterising the background is that it is
3251difficult to introduce a robust criterion to distinguish
3252``background'' jets from hard jets.
3253%
3254The main method that is available in \fastjet involves the
3255determination of the distribution of $p_t/A$ for the jets in a given
3256event (or region of the event) and then taking the median of the
3257distribution as an estimate of $\rho$, as proposed in~\cite{cs} and
3258studied in detail also in~\cite{Cacciari:2009dp,GridMedianLH}.
3259%
3260This is largely insensitive to the presence of a handful of hard jets, and
3261avoids any need for introducing a $p_t$ scale to distinguish hard and
3262background jets.
3263
3264
3265The original form of this method used the $k_t$ or Cambridge/Aachen
3266jet algorithms to find the jets.
3267%
3268These algorithms have the advantage that the resulting jets tend to
3269have reasonably uniform areas\footnote{Whereas anti-$k_t$ and SISCone
3270  suffer from jets with near zero areas or, for SISCone, sometimes
3271  huge, ``monster'' jets, biasing the $\rho$ determination. They are
3272  therefore not recommended.}
3273%
3274In the meantime a variant of the approach that has emerged is to
3275cluster the particles into rectangular grid cells in $y$ and $\phi$
3276and determine their median $p_t/A$.
3277%
3278This has the advantage of simplicity and much greater speed.
3279%
3280One may worry that a hard jet will sometimes lie at a corner of
3281multiple grid cells, inducing larger biases in the median than with a
3282normal jet finder jets, however we have found this not
3283to be an issue in practice~\cite{GridMedianLH}.
3284
3285\subsection{General Usage}\label{sec:bkg_general_usage}
3286
3287\subsubsection{Background estimation}\label{sec:bkg_estim_usage}
3288
3289The simplest workflow for background estimation is first, outside the
3290event loop, to create a background estimator.
3291%
3292For the jet-based method, one creates a
3293\ttt{fastjet::JetMedianBackgroundEstimator},
3294\begin{lstlisting}
3295  #include "fastjet/tools/JetMedianBackgroundEstimator.hh"
3296  // ...
3297  JetMedianBackgroundEstimator bge(const Selector & selector,
3298                                   const JetDefinition & jet_def,
3299                                   const AreaDefinition & area_def);
3300\end{lstlisting}
3301where the selector is used to indicate which jets are used for
3302background estimation (for simple use cases, one just specifies a
3303rapidity range, e.g.\ \ttt{SelectorAbsRapMax(4.5)} to use all jets
3304with $|y|<4.5$), together with a jet definition  and an area
3305definition.
3306%
3307We have found that the $k_t$ or Cambridge/Aachen jet algorithms with $R
3308= 0.4 - 0.6$ generally provide adequate background estimates, with
3309the lower range of $R$ values to be preferred if the events are likely
3310to be busy~\cite{Cacciari:2009dp,GridMedianLH}.
3311%
3312An active area with explicit ghosts is generally
3313recommended.\footnote{With the $k_t$ algorithm one may also use a
3314  Voronoi area (\texttt{effective\_Rfact = 0.9} is recommended), which
3315  has the advantage of being deterministic and faster than ghosted
3316  areas. In this case however one must use a selector that is
3317  geometrical and selects only jets well within the range of event
3318  particles.
3319  %
3320  E.g. if particles are present up to $|y| = y_{\max}$ one should only
3321  use jets with $|y| \lesssim y_{\max} - R$.
3322  %
3323  When using ghosts, the selector can instead go right up
3324  to the edge of the acceptance, if the ghosts also only go right up
3325  to the edge, as in the right-hand plot of
3326  fig.~\ref{fig:ghost-placement}.}
3327%
3328
3329For the grid based method one creates a
3330\ttt{fastjet::GridMedianBackgroundEstimator},
3331\begin{lstlisting}
3332  #include "fastjet/tools/GridMedianBackgroundEstimator.hh"
3333  // ...
3334  GridMedianBackgroundEstimator bge(double max_rapidity,
3335                                    double requested_grid_spacing);
3336\end{lstlisting}
3337We have found grid spacings in the range $0.5-0.7$ to be
3338adequate~\cite{GridMedianLH}, with lower values preferred for events
3339that are likely to have high multiplicities.
3340
3341Both of the above background estimators derive from a
3342\ttt{fastjet::BackgroundEstimatorBase} class and the remaining
3343functionality is common to both.
3344%
3345In particular, for each event, one tells the background estimator
3346about the event particles,
3347\begin{lstlisting}
3348  bge.set_particles(event_particles);
3349\end{lstlisting}
3350where \ttt{event\_particles} is a vector of \PJ, and then extracts the
3351background density and a measure of its fluctuations with the two
3352following calls
3353%
3354\begin{lstlisting}
3355  // the median of ($p_t$/area) for grid cells, or for jets that pass the selection cut,
3356  // making use also of information on empty area in the event (in the jets case)
3357  rho = bge.rho();
3358
3359  // an estimate of the fluctuations in the $p_t$ density per unit $\smash{\sqrt{A}}$,
3360  // which is obtained from the 1-sigma half-width of the distribution of pt/A.
3361  // To be precise it is defined such that a fraction (1-0.6827)/2 of the jets
3362  // (including empty jets) have $p_t/A < \rho - \sigma / \sqrt{\langle A \rangle}$
3363  sigma = bge.sigma();
3364\end{lstlisting}
3365Note that $\rho$ and $\sigma$ determinations count empty area within
3366the relevant region as consisting of jets of zero $p_t$.
3367%
3368Thus (roughly speaking), if more that half of the area covered by the
3369jets selector or grid rapidity range is empty, the median estimate for
3370$\rho$ will be zero, as expected and appropriate for quiet events.
3371
3372
3373%----------------------------------------------------------------------
3374\subsubsection{Background subtraction}\label{sec:subtractor}
3375
3376A common use of an estimation of the background is to subtract its contamination
3377from the
3378transverse momentum of hard jets, in the form
3379\begin{equation}
3380  \label{eq:BGE-scalar-pt}
3381  p_{t,jet}^{sub} = p_{t,jet}^{raw} - \rho A_{jet}
3382\end{equation}
3383or its 4-vector version
3384\begin{equation}
3385  \label{eq:BGE-4vector-massless}
3386  p_{\mu,jet}^{sub} = p_{\mu,jet}^{raw} - \rho A_{\mu,jet} \, ,
3387\end{equation}
3388as first proposed in~\cite{cs}.
3389
3390To this end, the \ttt{Subtractor} class is defined in
3391\ttt{include/tools/Subtractor.hh}. Its constructor takes a pointer to
3392a background estimator:
3393\begin{lstlisting}
3394  JetMedianBackgroundEstimator bge(....); // or a grid-based estimator
3395  Subtractor subtractor(&bge);
3396\end{lstlisting}
3397(it is also possible to construct the Subtractor with a fixed value
3398for $\rho$).
3399%
3400The subtractor can then be used as follows:
3401\begin{lstlisting}
3402  PseudoJet jet;
3403  vector<PseudoJet> jets;
3404  // ...
3405  PseudoJet subtracted_jet = subtractor(jet);
3406  vector<PseudoJet> subtracted_jets = subtractor(jets);
3407\end{lstlisting}
3408The subtractor normally returns \ttt{jet - bge.rho(jet)*jet.area\_4vector()}.
3409%
3410If \ttt{jet.pt() < bge.rho(jet)*jet.area\_4vector().pt()}, then
3411the subtractor instead returns a jet with zero 4-momentum (so that
3412\ttt{(subtracted\_jet==0)} returns \ttt{true}).
3413%
3414In both cases, the returned jet retains the user and structural
3415information of the original jet.
3416
3417An example program is given in \ttt{example/07-subtraction.cc}.
3418
3419Note that \ttt{Subtractor} derives from the \ttt{Transformer} class (see
3420section~\ref{sec:transformers}) and hence from
3421\ttt{FunctionOfPseudoJet<PseudoJet>} (cf.\
3422appendix~\ref{app:function-of-pj}).
3423
3424
3425
3426%......................................................................
3427\subsection{Positional dependence of background}
3428\label{sec:BGE-positional}
3429
3430The background density in $pp$ and heavy-ion collisions usually has
3431some non-negligible dependence on rapidity (and sometimes azimuth).
3432%
3433This dependence is not accounted for in the standard estimate of
3434$\rho$ based on all jets or grid cells from (say) $|y|<4.5$.
3435%
3436Two techniques are described below to help alleviate this problem.
3437%
3438In each case the properties of the background are to be obtained
3439through the methods (available for both
3440\ttt{JetMedianBackgroundEstimator} and
3441\ttt{GridMedianBackgroundEstimator})
3442\begin{lstlisting}
3443  double rho  (const PseudoJet & jet); // $p_t$ density per unit area $A$ near jet
3444  double sigma(const PseudoJet & jet); // fluctuations in the $p_t$ density near jet
3445\end{lstlisting}
3446
3447
3448%......................................................................
3449\subsubsection{Local estimation (jet based)}
3450\label{sec:local-bkgd-estimation}
3451
3452The first technique, ``local estimation'', available for now only in
3453the case of the jet-based estimator, involves the use of a more local
3454range for the determination of $\rho$, with the help of a
3455\ttt{Selector} that is able to take a reference jet,
3456e.g. \ttt{SelectorStrip(}$\Delta y$\ttt{)}, a strip of half-width
3457$\Delta y$ (which might be of order $1$) centred on whichever jet is
3458set as its reference.
3459%
3460With this kind of selector, when the user calls either \ttt{rho(jet)}
3461or \ttt{sigma(jet)} a \ttt{selector.set\_reference(jet)} call is made
3462to centre the selector on the specified jet. Then only the jets in the
3463event that
3464pass the cut specified by this newly positioned \ttt{selector} are
3465used to estimate $\rho$ or $\sigma$.\footnote{If the selector does not
3466  take a reference jet, then these calls give identical results to the
3467  plain \texttt{rho()} and \texttt{sigma()} calls (unless a manual
3468  rapidity rescaling is also in effect, cf.\
3469  section~\ref{sec:rescaled-bkgd-estimation}).}
3470%
3471This method is adequate if the number of jets that pass the selector
3472is much larger than the number of hard jets in the range (otherwise
3473the median $p_t/A$ will be noticeably biased by the hard jets).
3474%
3475It therefore tends to be suitable for dijet events in $pp$ or PbPb
3476collisions, but may fare less well in event samples such as
3477hadronically decaying $t\bar t$ which may have many central hard jets.
3478%
3479One can attempt to remove some given number of hard jets before
3480carrying out the median estimation, e.g.\ with a \ttt{selector} such
3481as
3482\begin{lstlisting}
3483  selector = SelectorStrip($\Delta y$) * (!SelectorNHardest(2))
3484\end{lstlisting}
3485which removes the 2 hardest jets globally and then, of the remainder,
3486takes the ones within the strip.\footnote{If you use non-geometric
3487  selectors such as this in determining $\rho$, the area must have
3488  explicit ghosts in order to simplify the determination of the empty
3489  area. If it does not, an error will be thrown.}
3490%
3491This is however not always very effective, because one may not know
3492how many hard jets to remove.
3493
3494%......................................................................
3495\subsubsection{Estimation in regions (grid based)}
3496\label{sec:region-bkgd-estimation}
3497
3498The grid-based estimator does not currently provide for local
3499estimates, in the sense that the set of tiles used for a given
3500instance of the grid-based estimator is always fixed.
3501%
3502However, as of \fastjet 3.1, it is possible to obtain relatively fine
3503control over which fixed set of tiles a grid-based estimator uses.
3504%
3505This is done with the help of the \ttt{RectangularGrid} class
3506%
3507\begin{lstlisting}
3508  RectangularGrid grid(rap_min, rap_max, rap_spacing, phi_spacing, selector);
3509  GridMedianBackgroundEstimator bge(grid);
3510\end{lstlisting}
3511A given grid tile will be used only if a massless \ttt{PseudoJet}
3512placed at the centre of the tile passes the \ttt{selector}.
3513%
3514So, for example, to obtain an estimate for $\rho$ based on the activity
3515in the two forward regions of a detector, one might set \ttt{rap\_min}
3516and \ttt{rap\_min} to cover the whole detector and then supply a
3517\ttt{SelectorAbsRapRange(rap\_central\_max, rap\_max)} to select just
3518the two forward regions.
3519
3520%......................................................................
3521\subsubsection{Rescaling method}
3522\label{sec:rescaled-bkgd-estimation}
3523
3524A second technique to account for positional dependence of the
3525background is ``rescaling''.
3526%
3527First one parametrises the average shape of the rapidity
3528dependence from some number of pileup events.
3529%
3530Then for subsequent event-by-event background determinations, one
3531carries out a global $\rho$ determination and then applies the
3532previously determined average rescaling function to that global
3533determination to obtain an estimate for $\rho$ in the neighbourhood of
3534a specific jet.
3535
3536The rescaling approach approach is available for both grid and
3537jet-based methods.
3538%
3539To encode the background shape, one defines an object such as
3540\begin{lstlisting}
3541  // gives rescaling$(y) = 1.16 + 0\cdot y -0.023 \cdot y^2 + 0\cdot y^3 + 0.000041 \cdot y^4$
3542  fastjet::BackgroundRescalingYPolynomial rescaling(1.16, 0, -0.023, 0, 0.000041);
3543\end{lstlisting}
3544(for other shapes, e.g. parametrisation of elliptic flow in heavy ion
3545collisions, with both rapidity and azimuth dependence, derive a class
3546from \ttt{FunctionOfPseudoJet<double>} --- see appendix
3547\ref{app:function-of-pj}). Then one tells the background estimator
3548(whether jet or grid based) about the rescaling with the call
3549\begin{lstlisting}
3550  // tell JetMedianBackgroundEstimator or GridMedianBackgroundEstimator about the rescaling
3551  bge.set_rescaling_class(&rescaling);
3552\end{lstlisting}
3553Subsequent calls to \ttt{rho()} will return the median of the
3554distribution $p_t/A / \ttt{rescaling}(y)$ (rather than $p_t/A$).
3555%
3556Any calls to \ttt{rho(jet)} and \ttt{sigma(jet)} will include an
3557additional factor of \ttt{rescaling}$(y_\ttt{jet})$.
3558%
3559Note that any overall factor in the rescaling function cancels out for
3560\ttt{rho(jet)} and \ttt{sigma(jet)}, but not for calls to \ttt{rho()}
3561and \ttt{sigma()} (which are in any case less meaningful when a
3562rapidity dependence is being assumed for the background).
3563
3564In ongoing studies \cite{GridMedianLH}, we have found that despite its
3565use of an average background shape, the rescaling method generally
3566performs comparably to local estimation in terms of its residual $p_t$
3567dispersion after subtraction.
3568%
3569Additionally, it has the advantage of reduced sensitivity to biases in
3570events with high multiplicities of hard jets.
3571
3572%......................................................................
3573\subsection{Handling masses}
3574\label{sec:BGE-masses}
3575
3576There are several subtleties in handling masses in
3577subtraction.
3578%
3579The first is related to the fact that hadrons have
3580masses.
3581%
3582In some contexts those masses are ignored and set to zero, e.g.\
3583because they are experimentally unconstrained: detectors do not
3584systematically give information on the mass for every particle.
3585%
3586However, if particle masses are kept non-zero, then
3587Eq.~(\ref{eq:BGE-4vector-massless}) must be
3588extended~\cite{Soyez:2012hv} to read
3589\begin{equation}
3590  \label{eq:4vector-subtraction-with-rhom}
3591  p^\mu_\text{jet,sub} =
3592  p^\mu_\text{jet}
3593  - [\rho A^x_\text{jet}, \,
3594     \rho A^y_\text{jet}, \,
3595     (\rho+\rho_m) A^z_\text{jet}, \,
3596     (\rho+\rho_m) A^E_\text{jet}
3597     ]\,,
3598\end{equation}
3599where $\rho_m$ accounts the massive component of the energy flow.
3600%
3601It can be approximately determined as the median across patches of a
3602quantity $m_{\delta,\text{patch}}/A_{\text{patch}}$, where
3603\begin{equation}
3604  \label{eq:m-delta}
3605  m_{\delta,\text{patch}} = \sum_{i\in\text{patch}}
3606  \left(\sqrt{\smash[b]{m^2_{i} + p_{t,i}^2}} - p_{ti}\right)\,.
3607\end{equation}
3608By default, as of \fastjet 3.1, the grid and jet-median background
3609estimators automatically determine $\rho_m$.
3610%
3611It is returned from a call to \ttt{rho\_m()}, with fluctuations
3612accessible through \ttt{sigma\_m()}.
3613%
3614The determination of $\rho_m$ involves a small speed penalty and can
3615be disabled with a call to \ttt{set\_compute\_rho\_m(false)} for
3616either of the background estimators.
3617
3618To avoid changes in results relative to version 3.0, by default
3619\fastjet 3.1 does not use $\rho_m$ in the \ttt{Subtractor}, i.e.\ it
3620uses Eq.~(\ref{eq:BGE-4vector-massless}).
3621%
3622However, for a given subtractor, a call to
3623\ttt{set\_use\_rho\_m(true)}, will cause it to instead use
3624Eq.~(\ref{eq:4vector-subtraction-with-rhom}) for all subsequent
3625subtractions.
3626%
3627We \emph{strongly recommend} switching this on if your input particles
3628have masses, and in future versions of \fastjet we may change the
3629default so that it is automatically switched on.\footnote{It is also
3630  possible to construct a \texttt{Subtractor} with explicit $\rho$ and
3631  $\rho_m$ values, \texttt{Subtractor subtractor(rho, rho\_m)}; if
3632  this is done, then $\rho_m$ use \emph{is enabled} by default.}
3633%
3634An alternative is to make the input particles massless.
3635
3636A second issue, relevant both for
3637Eqs.~(\ref{eq:BGE-4vector-massless}) and
3638(\ref{eq:4vector-subtraction-with-rhom}), is that sometimes the
3639resulting squared jet mass is negative.\footnote{Recall that if
3640  $m^2<0$, \ttt{m()} returns $-\sqrt{-m^2}$, to avoid having to
3641  introduce complex numbers just for this special case.}
3642%
3643This is obviously unphysical.
3644%
3645By default the 4-vector returned by the subtractor is left in that
3646unphysical state, so that the user can decide what to do with it.
3647%
3648For most applications a sensible behaviour is to adjust the
36494-vector so as to maintain its $p_t$ and azimuth, while setting the
3650mass to zero.
3651%
3652This behaviour can be enabled for a given subtractor by a call to
3653its \ttt{set\_safe\_mass(true)} function (available since v.3.1).
3654%
3655In this case the rapidity is then taken to be that of the original
3656unsubtracted jet.
3657%
3658In future versions of \fastjet, the default behaviour may be changed
3659so that ``safe'' subtraction is automatically enabled.
3660
3661A general note with regards to jet masses is that a number of
3662techniques have been proposed as alternatives to 4-vector subtraction
3663for jet masses.
3664%
3665They include Jet Cleansing~\cite{Krohn:2013lba} (which requires
3666charged-track information; see also the discussion in
3667Ref.~\cite{Cacciari:2014jta}), Constituent
3668Subtraction~\cite{Berta:2014eza}, the
3669SoftKiller~\cite{Cacciari:2014gra} method and
3670PUPPI~\cite{Bertolini:2014bba}.
3671%
3672Some of these can give significant improvements in the resolution of
3673the subtraction for the jet masses, though potentially at the expense
3674of some bias.
3675%
3676SoftKiller and PUPPI appear to give improved resolution also for the
3677jet $p_t$ (again at the potential expense of modest biases).
3678%
3679Implementations of most of these techniques are, or will soon become
3680available in \fjcontrib.
3681%
3682There one will also find the \ttt{GenericSubtractor} contrib, with
3683code for area-based subtraction of jet shapes and other generic
3684observables as discussed in Refs.~\cite{Soyez:2012hv,Cacciari:2012mu}.
3685
3686%......................................................................
3687\subsection{Other facilities}
3688\label{sec:BGE-other-facilities}
3689
3690The \ttt{JetMedianBackgroundEstimator} has a number of enquiry
3691functions to access information used internally within the median
3692$\rho$ and $\sigma$ determination.
3693\begin{lstlisting}
3694  // Returns the mean area of the jets used to actually compute the background properties,
3695  // including empty area and jets (available also in grid-based estimator)
3696  double mean_area() const;
3697
3698  // Returns the number of jets used to actually compute the background properties
3699  // (including empty jets)
3700  unsigned int n_jets_used() const;
3701
3702  // Returns the estimate of the area (within the range defined by the selector) that
3703  // is not occupied by jets.
3704  double empty_area() const;
3705
3706  // Returns the number of empty jets used when computing the background properties.
3707  double n_empty_jets() const;
3708\end{lstlisting}
3709For area definitions with explicit ghosts the last two functions
3710return $0$.
3711%
3712For active areas without explicit ghosts the results are calculated
3713based on the observed number of internally recorded pure ghost jets
3714(and unclustered ghosts) that pass the selector; for Voronoi and
3715passive areas, they are calculated using the difference between the
3716total range area and the area of the jets contained in the range, with
3717the number of empty jets then being calculated based on the average
3718jet area for ghost jets ($0.55\pi R^2$~\cite{CSSAreas}).
3719%
3720All four functions above return a result corresponding to the last call
3721to \ttt{rho} or \ttt{sigma} (as long as the particles, cluster sequence or
3722selector have not changed in the meantime).
3723
3724The \ttt{Subtractor} has an option
3725\begin{lstlisting}
3726  void set_known_selectors(const Selector & sel_known_vertex,
3727                           const Selector & sel_leading_vertex);
3728\end{lstlisting}
3729The idea here is that there are contexts where it is possible, for
3730some of a jet's constituents, to identify which vertex they come from.
3731%
3732In that case it is possible to provide a user-defined a selector
3733(section~\ref{sect:selectors}) that indicates whether a particle comes
3734from an identified vertex or not and a second user-defined selector
3735that indicates whether that vertex was the leading vertex.
3736%
3737The 4-momentum from the non-leading vertex is then discarded, that
3738from the leading vertex is kept, and subtraction is applied to
3739component that is not from identified vertices.
3740%
3741It follows that $\rho$ must correspond only to the momentum flow from
3742non-identified vertices.
3743%
3744With this setup, the jet $p_t$ is bounded to be at least equal to that
3745from the leading vertex, as is the mass if the ``safe'' subtraction
3746option is enabled.
3747
3748%......................................................................
3749\subsection{Alternative workflows}
3750%
3751To allow flexibility in the user's workflow,
3752alternative constructors to \ttt{JetMedianBackgroundEstimator} are provided.
3753%
3754These can come in useful if, for example, the user wishes to carry out
3755multiple background estimations with the same particles but different
3756selectors, or wishes to take care of the jet clustering themselves,
3757e.g.\ because the results of that same jet clustering will be used in
3758multiple contexts and it is more efficient to perform it just once. These
3759constructors are:
3760\begin{lstlisting}
3761  // create an estimator that uses the inclusive jets from the supplied cluster sequence
3762  JetMedianBackgroundEstimator(const Selector & rho_range,
3763                               const ClusterSequenceAreaBase & csa);
3764  // a default constructor that requires all information to be set later
3765  JetMedianBackgroundEstimator();
3766\end{lstlisting}
3767In the first case, the background estimator already has all the information it
3768needs. Instead, if the default constructor has been used, one can then employ
3769\begin{lstlisting}
3770  // (re)set the selector to be used for future calls to rho() etc.
3771  void set_selector(const Selector & rho_range_selector);
3772  // (re)set the cluster sequence to be used by future calls to rho() etc.
3773  // (as with the cluster-sequence based constructor, its inclusive jets are used)
3774  void set_cluster_sequence(const ClusterSequenceAreaBase & csa);
3775\end{lstlisting}
3776to set the rest of the necessary information. If a list of jets is already
3777available, they can be submitted to the background estimator in place
3778of a cluster sequence:
3779\begin{lstlisting}
3780  // (re)set the jets to be used by future calls to rho() etc.
3781  void set_jets(const std::vector<PseudoJet> & jets);
3782\end{lstlisting}
3783Note that the
3784jets passed via the \ttt{set\_jets()} call above must all originate from a common
3785\ttt{ClusterSequenceAreaBase} type class.
3786
3787
3788%......................................................................
3789\subsection{Recommendations}
3790
3791While the basic idea of pileup subtraction is rather simple, in
3792practice a few details are relevant to obtaining the best possible
3793performance.
3794%
3795Here we summarise some useful recommendations:
3796\begin{enumerate}
3797\item The \ttt{GridMedianBackgroundEstimator} is significantly faster
3798  than the \ttt{JetMedianBackgroundEstimator} and performs equally
3799  well in nearly all cases.
3800
3801\item Pileup usually has non-negligible rapidity dependence (and
3802  in the case of heavy-ion collisions, the underlying event also has
3803  azimuthal dependence).
3804  %
3805  It is often important to account for this dependence, which can be
3806  done either with the rescaling method
3807  (section~\ref{sec:rescaled-bkgd-estimation}) or via a local
3808  background estimator (section \ref{sec:local-bkgd-estimation}) or
3809  the use of regions (section~\ref{sec:region-bkgd-estimation}).
3810  %
3811  For their own work in pileup subtraction the \fastjet authors tend
3812  to prefer the rescaling method, with local estimation also a useful
3813  option e.g.\ in the case of heavy-ion collisions.
3814
3815\item If you are interested in jet masses, and wish to use non-zero
3816  input particle masses, make sure you use the $\rho_m$ component in
3817  Eq.~(\ref{eq:4vector-subtraction-with-rhom}) by calling your
3818  subtractor's \ttt{set\_use\_rho\_m()} method
3819  (section~\ref{sec:BGE-masses}).
3820  %
3821  You should also pay attention to what happens with negative squared
3822  masses, and consider calling the subtractor's \ttt{set\_safe\_mass()}
3823  option.
3824  %
3825  For reasons of backwards compatibility, both of these options are
3826  disabled by default; in future versions of \fastjet, this may change.
3827
3828\item For jet masses and shapes, there are various other techniques
3829  that may be of use, see e.g.\
3830  Refs.~\cite{Cacciari:2012mu,Soyez:2012hv,Krohn:2013lba,Cacciari:2014jta,Berta:2014eza,Cacciari:2014gra,Bertolini:2014bba}.
3831\end{enumerate}
3832
3833
3834
3835%======================================================================
3836\section{Jet transformers (substructure, taggers, etc...)}
3837\label{sec:transformers}
3838
3839
3840Performing post-clustering actions on jets has in recent years become
3841quite widespread: for example, numerous techniques have been
3842introduced to tag boosted hadronically decaying objects, and various
3843methods also exist for suppressing the underlying event and pileup in
3844jets, beyond the subtraction approach discussed in
3845section~\ref{sec:BackgroundEstimator}.
3846%
3847\fastjet 3 provides a common interface for such
3848tools, intended to help simplify their usage and to guide authors of
3849new ones.
3850%
3851Below, we first discuss generic considerations about these tools, which
3852we call \ttt{fastjet::Transformer}s.
3853%
3854We then describe some that have already been implemented.
3855%
3856New user-defined transformers can be implemented as described in
3857section~\ref{sec:transformerdetails}.
3858
3859
3860
3861A transformer derived from \ttt{Transformer}, e.g. the
3862 class \ttt{MyTransformer}, will generally be used as follows:
3863\begin{lstlisting}
3864  MyTransformer transformer;
3865  PseudoJet transformed_jet = transformer(jet);
3866\end{lstlisting}
3867Often, transformers provide new structural information that is to be
3868associated with the returned result.
3869%
3870For a given transformer, say \ttt{MyTransformer}, the new information
3871that is not already directly accessible from \ttt{PseudoJet} (like its
3872\ttt{constituents}, \ttt{pieces} or \ttt{area} when they are
3873relevant), can be accessed through
3874\begin{lstlisting}
3875  transformed_jet.structure_of<MyTransformer>()
3876\end{lstlisting}
3877which returns a reference to an object of type
3878\ttt{MyTransformer::StructureType}.
3879%
3880This is illustrated below on a case-by-case basis for each of the
3881transformers that we discuss.
3882%
3883Using the Boolean function
3884\ttt{transformed\_jet.has\_structure\_of<MyTransformer>()} it is possible to
3885check if \ttt{transformed\_jet} is compatible with the structure provided by
3886\ttt{MyTransformer}.
3887
3888A number of the transformers that we discuss below are ``taggers'' for
3889boosted objects.
3890%
3891In some cases they will determine that a given jet does not satisfy
3892the tagging conditions (e.g., for a top tagger, because it seems not
3893to be a top jet).
3894%
3895We will adopt the convention that in such cases the result of the
3896transformer is a jet whose 4-momentum is zero, i.e.\ one that satisfies
3897\ttt{jet == 0}.
3898%
3899Such a jet may still have structural information however (e.g.\ to
3900indicate why the jet was not tagged).
3901
3902
3903\subsection{Noise-removal transformers}
3904
3905In section \ref{sec:subtractor} we already saw one transformer for
3906noise removal, i.e.\ \ttt{Subtractor}.
3907%
3908Others have emerged in the context of jet substructure studies and are
3909described here.
3910%
3911
3912\subsubsection{Jet Filtering and Trimming using \texttt{Filter}}
3913\label{sec:filtering}
3914
3915Filtering was first introduced in \cite{BDRS} to reduce the
3916sensitivity of a boosted Higgs-candidate jet's mass to the underlying
3917event.
3918%
3919Generally speaking, filtering clusters a jet's constituents with a
3920smaller-than-original jet radius $R_{\rm filt}$.
3921%
3922It then keeps just the $n_{\rm filt}$ hardest of the resulting
3923subjets, rejecting the others.
3924%
3925Trimming~\cite{trimming} is similar, but selects the subjets to be kept based on a
3926$p_t$ cut.
3927%
3928The use of filtering and trimming has been advocated in number of
3929contexts, beyond just the realm of boosted object reconstruction.
3930
3931The \ttt{fastjet::Filter} class derives from \ttt{Transformer}, and
3932can be constructed
3933using a \ttt{JetDefinition}, a \ttt{Selector} and (optionally) a
3934value for the background density,
3935\begin{lstlisting}
3936  #include "fastjet/tools/Filter.hh"
3937  // ...
3938  Filter filter(subjet_def, selector, rho);
3939\end{lstlisting}
3940This reclusters the jet's constituents with the jet definition
3941\ttt{subjet\_def}\footnote{
3942%
3943When the input jet was obtained with the Cambridge/Aachen
3944algorithm and the subjet definition also involves the Cambridge/Aachen
3945algorithm, the \ttt{Filter} uses the exclusive subjets of the input
3946jet to avoid having to recluster its constituents.
3947}
3948and then
3949applies \ttt{selector} on the \ttt{inclusive\_jets} resulting from the
3950clustering to decide which of these (sub)jets have to be kept.
3951%
3952If \ttt{rho} is non-zero, each of the subjets is subtracted
3953(using the specified value for the background density) prior to the
3954selection of the kept subjets. Alternatively, the user can set a
3955\ttt{Subtractor} (see section~\ref{sec:subtractor}), e.g.
3956\begin{lstlisting}
3957  GridMedianBackgroundEstimator bge(...);
3958  Subtractor sub(&bge);
3959  filter.set_subtractor(sub);
3960\end{lstlisting}
3961When this is done, the subtraction operation is performed using the
3962\ttt{Subtractor}, independently of whether a value had been set for
3963\ttt{rho}.
3964
3965If the jet definition to be used to recluster the jet's constituents is
3966the Cambridge/Aachen algorithm, two additional constructors are available:
3967\begin{lstlisting}
3968  Filter(double Rfilt, Selector selector, double rho = 0.0);
3969  Filter(FunctionOfPseudoJet<double> * Rfilt_dyn, Selector selector, double rho = 0.0);
3970\end{lstlisting}
3971In the first one, only the radius parameter is specified instead of
3972the full subjet definition.
3973In the second, one has to provide a
3974(pointer to) a class derived from \ttt{FunctionOfPseudoJet<double>}
3975which dynamically computes the filtering radius as a function of the
3976jet being filtered (as was originally used in \cite{BDRS} where
3977$R_{\rm filt}={\rm min}(0.3,R_{b\bar{b}/2})$, with $R_{b\bar b}$ the
3978distance between the parents of the jet).
3979
3980As an example, a simple filter, giving the subjets obtained clustering
3981with the Cambridge/Aachen algorithm with radius $R_{\rm filt}$ and
3982keeping the $n_{\rm filt}$ hardest subjets found, can be set up and applied using
3983\begin{lstlisting}
3984  Filter filter(Rfilt, SelectorNHardest(nfilt));
3985  PseudoJet filtered_jet = filter(jet);
3986\end{lstlisting}
3987The \ttt{pieces()} of the resulting
3988filtered/trimmed jet correspond to the subjets that were kept:
3989\begin{lstlisting}
3990  vector<PseudoJet> kept = filtered_jet.pieces();
3991\end{lstlisting}
3992%
3993Additional structural information is available as follows:
3994%
3995\begin{lstlisting}
3996  // the subjets (on the scale Rfilt) not kept by the filtering
3997  vector<PseudoJet> rejected = filtered_jet.structure_of<Filter>().rejected();
3998\end{lstlisting}
3999
4000Trimming, which keeps the subjets with a $p_t$ larger than a fixed
4001fraction of the input jet, can be obtained defining
4002\begin{lstlisting}
4003  Filter trimmer(Rfilt, SelectorPtFractionMin(pt_fraction_min));
4004\end{lstlisting}
4005and then applying \ttt{trimmer} similarly to \ttt{filter} above.
4006
4007Note that the jet being filtered must have constituents. Furthermore,
4008if \ttt{rho} is non-zero or if a \ttt{Subtractor} is set, the input
4009jet must come from a cluster sequence with area support and explicit
4010ghosts. If any of these requirements fail, an exception is thrown.
4011%
4012In cases where the filter/trimmer has been defined with just a jet
4013radius, the reclustering of the jet is performed with the same
4014recombination scheme as was used in producing the original jet
4015(assuming it can be uniquely determined).
4016
4017%......................................................................
4018\subsubsection{Jet pruning}
4019\label{sec:pruning}
4020
4021Pruning was introduced in \cite{Ellis:2009su}.
4022%
4023It works by reclustering a jet's constituents with some given
4024sequential recombination algorithm, but vetoing soft and large-angle
4025recombinations between pseudojets $i$ and $j$, specifically when the
4026two following conditions are met
4027%
4028\begin{enumerate}
4029\item the geometric distance between $i$ and $j$ is larger than a
4030  parameter \ttt{Rcut}, with \ttt{Rcut} = \ttt{Rcut\_factor}$\times
4031  2m/p_t$, where $m$ and $p_t$ are the mass and transverse momentum of
4032  the original jet being pruned;
4033\item one of $p_t^i, p_t^j $ is $<$~\ttt{zcut}$\times p_t^{i+j}$.
4034\end{enumerate}
4035When the veto condition occurs, the softer of $i$ and $j$ is
4036discarded, while the harder one continues to participate in the
4037clustering.
4038
4039Pruning bears similarity to filtering in that it reduces the
4040contamination of soft noise in a jet while aiming to retain hard
4041perturbative radiation within the jet.
4042%
4043However, because by default the parameters for the noise removal
4044depend on the original mass of the jet, the type of radiation that is
4045discarded depends significantly on the initial jet structure.
4046%
4047As a result pruning, in its default form, is better thought of as a
4048noise-removing boosted-object tagger (to be used in conjunction with a
4049pruned-jet mass cut) rather than a generic noise-removal procedure.
4050%
4051
4052The \ttt{fastjet::Pruner} class, derived from \ttt{Transformer}, can be used as
4053follows, using a \ttt{JetAlgorithm} and two \ttt{double} parameters:
4054\begin{lstlisting}
4055  #include "fastjet/tools/Pruner.hh"
4056  // ...
4057  Pruner pruner(jet_algorithm, zcut, Rcut_factor);
4058  // ...
4059  PseudoJet pruned_jet = pruner(jet);
4060\end{lstlisting}
4061The \ttt{pruned\_jet} will have a valid associated cluster sequence, so that one
4062can, for instance, ask for its constituents with
4063\ttt{pruned\_jet.constituents()}.
4064%
4065In addition, the subjets that have been rejected by the pruning algorithm (i.e.
4066have been `pruned away') can be obtained with
4067\begin{lstlisting}
4068  vector<PseudoJet> rejected_subjets = pruned_jet.structure_of<Pruner>().rejected();
4069\end{lstlisting}
4070and each of these subjets will also have a valid associated clustering sequence.
4071
4072When using the constructor given above, the jet radius used by the pruning clustering
4073sequence is set internally to the functional equivalent of infinity. Alternatively,
4074a pruner transformer can be constructed with a \ttt{JetDefinition} instead of just a
4075\ttt{JetAlgorithm}:
4076\begin{lstlisting}
4077  JetDefinition pruner_jetdef(jet_algorithm, Rpruner);
4078  Pruner pruner(pruner_jetdef, zcut, Rcut_factor);
4079\end{lstlisting}
4080In this situation, the jet definition \ttt{pruner\_jetdef} should normally have a radius
4081\ttt{Rpruner}
4082large enough to ensure that
4083all the constituents of the jet being pruned are reclustered into a single jet.
4084%
4085If this is not the case, pruning is applied to the entire reclustering
4086and it is the hardest resulting pruned jet that is returned; the
4087others can be retrieved using
4088\begin{lstlisting}
4089  vector<PseudoJet> extra_jets = pruned_jet.structure_of<Pruner>().extra_jets();
4090\end{lstlisting}
4091
4092Finally, note that a third constructor for \ttt{Pruner} exists, that allows one
4093to construct the pruner using functions that dynamically compute \ttt{zcut} and
4094\ttt{Rcut} for the jet being pruned:
4095\begin{lstlisting}
4096  Pruner (const JetDefinition &jet_def,
4097          const FunctionOfPseudoJet< double > *zcut_dyn,
4098	  const FunctionOfPseudoJet< double > *Rcut_dyn);
4099\end{lstlisting}
4100The \ttt{pruned\_jet.structure\_of<Pruner>()} object also provides
4101\ttt{Rcut()} and \ttt{zcut()} members, in order to retrieve the
4102actual $R_\text{cut}$ and $z_\text{cut}$ values used for that jet.
4103
4104
4105\subsection{Boosted-object taggers}
4106\label{sec:taggers}
4107
4108A number of the taggers developed to distinguish 2- or 3-pronged
4109decays of massive objects from plain QCD jets (see the review
4110\cite{Abdesselam:2010pt}) naturally fall into the category of
4111transformers.
4112%
4113Typically they search for one or more hard branchings within the jet
4114and then return the part of the jet that has been identified as
4115associated with those hard branchings.
4116%
4117They share the convention that if they were not able to identify
4118suitable substructure, they return a \ttt{jet} with zero momentum,
4119i.e.\ one that has the property \ttt{jet == 0}.
4120
4121
4122At the time of writing, we provide only a small set of taggers.
4123%
4124These include one main two-body tagger, the
4125\ttt{fastjet::MassDropTagger} introduced in \cite{BDRS} and one main
4126boosted top tagger, \ttt{fastjet::JHTopTagger} from
4127\cite{Kaplan:2008ie} (\ttt{JHTopTagger} derives from the
4128\ttt{fastjet::TopTaggerBase} class, expressly included to provide a
4129common framework for all top taggers capable of also returning a $W$).
4130%
4131In addition, to help provide a more complete set of examples of coding
4132methods to which users may refer when writing their own taggers, we
4133have also included the
4134%
4135\ttt{fastjet::CASubJetTagger} introduced in~\cite{Butterworth:2009qa},
4136which illustrates the use of a \ttt{WrappedStructure} (cf.\
4137appendix~\ref{sec:transformerdetails}) and the
4138rest-frame \ttt{fastjet::RestFrameNSubjettinessTagger}
4139from Ref.~\cite{nsubtagger}, which makes use of facilities to boost a
4140cluster sequence.
4141
4142
4143We refer the reader to the original papers for a more extensive
4144description of the physics use of these taggers.
4145
4146More taggers may be provided in the future, either through native
4147implementations or, potentially, through a ``contrib'' type area.
4148%
4149Users are invited to contact the \fastjet authors for further
4150information in this regard.
4151
4152%......................................................................
4153\subsubsection{The mass-drop tagger}
4154
4155Introduced in \cite{BDRS} for the purpose of identifying a boosted Higgs
4156decaying into a $b\bar b$ pair, this is a general 2-pronged tagger. It starts with a fat jet obtained
4157with a Cambridge/Aachen algorithm (originally, $R=1.2$ was suggested
4158for boosted Higgs tagging). Tagging then proceeds as follows:
4159\begin{enumerate}
4160\item the last step of the clustering is undone: $j \to j_1,j_2$, with
4161  $m_{j_1} > m_{j_2}$;
4162\item if there is a significant mass drop, $\mu \equiv m_{j_1}/m_j <
4163  \mu_{\rm cut}$, and the splitting is sufficiently symmetric,
4164  $y\equiv {\rm min}(p_{tj_1}^2, p_{tj_2}^2)\Delta R_{j_1j_2}^2/m_j^2
4165  > y_{\rm cut}$, then $j$ is the resulting heavy particle candidate
4166  with $j_1$ and $j_2$ its subjets;
4167\item otherwise, redefine $j$ to be equal to $j_1$ and go back to step
4168  1.
4169\end{enumerate}
4170%
4171The tagger can be constructed with
4172\begin{lstlisting}
4173  #include "fastjet/tools/MassDropTagger.hh"
4174  // ...
4175  MassDropTagger mdtagger(double $\mu_\text{cut}$, double $y_\text{cut}$);
4176\end{lstlisting}
4177and applied using
4178\begin{lstlisting}
4179  PseudoJet tagged_jet = mdtagger(jet);
4180\end{lstlisting}
4181
4182%
4183This tagger will run with any jet that comes from a \CS. A warning
4184will be issued if the \CS is not based on the C/A algorithm.
4185%
4186If the \ttt{JetDefinition} used in the \CS involved a non-default
4187recombiner, that same recombiner will be used when joining the final
4188two prongs to form the boosted particle candidate.
4189%
4190
4191For a jet that is returned by the tagger and has the property that
4192\ttt{tagged\_jet != 0}, two enquiry functions can be used to return
4193the actual value of $\mu$ and $y$ for the clustering that corresponds
4194to the tagged structure:
4195\begin{lstlisting}
4196  tagged_jet.structure_of<MassDropTagger>.mu();
4197  tagged_jet.structure_of<MassDropTagger>.y();
4198\end{lstlisting}
4199
4200Note that in \cite{BDRS} the mass-drop element of the tagging was
4201followed by a filtering stage using $\min(0.3, R_{jj}/2)$ as the
4202reclustering radius and selecting the three hardest subjects. That can
4203be achieved with
4204\begin{lstlisting}
4205  vector<PseudoJet> tagged_pieces = tagged_jet.pieces();
4206  double Rfilt = min(0.3, 0.5 * pieces[0].delta_R(pieces[1]));
4207  PseudoJet filtered_tagged_jet = Filter(Rfilt, SelectorNHardest(3))(tagged_jet);
4208\end{lstlisting}
4209(It is also possible to use the \ttt{Rfilt\_dyn} option to the filter
4210discussed in section~\ref{sec:filtering}).
4211
4212A significantly updated version of the mass-drop tagger, modified as
4213in Ref.~\cite{Dasgupta:2013ihk}, is available as part of the
4214RecursiveTools \fjcontrib module (see section~\ref{sec:fjcontrib}).
4215
4216%......................................................................
4217\subsubsection{The Johns-Hopkins top tagger}
4218
4219The Johns Hopkins top tagger~\cite{Kaplan:2008ie} is a 3-pronged tagger
4220specifically designed to identify top quarks.
4221%
4222It recursively breaks a jet into pieces, finding up to 3 or 4 subjets
4223and then looking for a $W$ candidate among them.
4224%
4225The parameters used to identify the relevant subjets include a
4226momentum fraction cut and a minimal separation in Manhattan distance
4227($|\Delta y| + |\Delta \phi|$) between subjets obtained from a
4228declustering.
4229
4230%
4231The tagger will run with any jet that comes from a \CS, however
4232%
4233to conform with the original formulation of~\cite{Kaplan:2008ie}, the
4234\CS should be based on the C/A algorithm. A warning will be issued if
4235this is not the case.
4236%
4237If the \ttt{JetDefinition} used in the \CS involves a non-default
4238recombiner, that same recombiner will be used when joining the final
4239two prongs to form the boosted particle candidate.
4240%
4241The tagger can be used as follows:
4242\begin{lstlisting}
4243  #include "fastjet/tools/JHTopTagger.hh"
4244  // ...
4245  double delta_p = 0.10; // subjets must carry at least this fraction of original jet's $p_t$
4246  double delta_r = 0.19; // subjets must be separated by at least this Manhattan distance
4247  double cos_theta_W_max = 0.7; // the maximal allowed value of the W helicity angle
4248  JHTopTagger top_tagger(delta_p, delta_r, cos_theta_W_max);
4249  // indicate the acceptable range of top, W masses
4250  top_tagger.set_top_selector(SelectorMassRange(150,200));
4251  top_tagger.set_W_selector  (SelectorMassRange( 65, 95));
4252  // now try and tag a jet
4253  PseudoJet top_candidate = top_tagger(jet); // jet should come from a C/A clustering
4254  if (top_candidate != 0) { // successful tagging
4255    double top_mass = top_candidate.m();
4256    double W_mass   = top_candidate.structure_of<JHTopTagger>().W().m();
4257  }
4258\end{lstlisting}
4259Other information available through the
4260\ttt{structure\_of<JHTopTagger>()} call includes: \ttt{W1()} and
4261\ttt{W2()}, the harder and softer of the two $W$ subjets;
4262\ttt{non\_W()}, the part of the top that has not been identified with
4263a $W$ (i.e.\ the candidate for the $b$); and \ttt{cos\_theta\_W()}.
4264%
4265The \ttt{top\_candidate.pieces()} call will return 2 pieces, where the
4266first is the $W$ candidate (identical to
4267\ttt{structure\_of<JHTopTagger>().W()}), while the second is the
4268remainder of the top jet (i.e.\ \ttt{non\_W}).
4269%
4270
4271Note the above calls to \ttt{set\_top\_selector()} and
4272\ttt{set\_W\_selector()}. If these calls are not made, then the tagger
4273places no cuts on the top or $W$ candidate masses and it is then the
4274user's responsibility to verify that they are in a suitable range.
4275
4276Note further that  \ttt{JHTopTagger} does not derive directly from
4277\ttt{Transformer}, but from the
4278\ttt{fastjet::TopTaggerBase} class instead. This class (which itself derives
4279from \ttt{Transformer}) has been included to provide a proposed common
4280interface for all the top taggers. In particular, \ttt{TopTaggerBase} provides
4281(via the associated structure)
4282\begin{lstlisting}
4283  top_candidate.structure_of<TopTaggerBase>().W()
4284  top_candidate.structure_of<TopTaggerBase>().non_W()
4285\end{lstlisting}
4286and standardises the fact that the resulting top candidate is a \ttt{PseudoJet}
4287made of these two pieces.
4288
4289The benefits of the base class for top taggers will of course be more
4290evident once more than a single top tagger has been implemented.
4291
4292%......................................................................
4293\subsubsection{The Cambridge/Aachen subjet tagger}
4294
4295The Cambridge/Aachen subjet
4296tagger~\cite{Butterworth:2009qa}, originally implemented in a
42973-pronged context, is really a generic 2-body tagger, which can also be
4298used in a nested fashion to obtained multi-pronged tagging.
4299%
4300It can be obtained through the include
4301\begin{lstlisting}
4302  #include "fastjet/tools/CASubjetTagger.hh"
4303\end{lstlisting}
4304As it is less widely used than the taggers mentioned above, we refer
4305the user to the online doxygen documentation for further details.
4306
4307
4308%......................................................................
4309\subsubsection{The rest-frame $N$-subjettiness tagger}
4310
4311The rest-frame $N$-subjettiness
4312tagger~\cite{nsubtagger}, meant to identify a highly boosted colour
4313singlet particle decaying to $2$ partons, can be obtained through the include
4314\begin{lstlisting}
4315  #include "fastjet/tools/RestFrameNSubjettinessTagger.hh"
4316\end{lstlisting}
4317As it is less widely used than the taggers mentioned above, we refer
4318the user to the online doxygen documentation for further details.
4319
4320
4321
4322
4323%======================================================================
4324\section{Compilation notes}
4325
4326Compilation and installation make use of the standard
4327\begin{verbatim}
4328  % ./configure
4329  % make
4330  % make check
4331  % make install
4332\end{verbatim}
4333procedure. Explanations of available options (e.g.\ to select which
4334plugins are built or enable/disable python support) are given in the
4335\ttt{INSTALL} file in the top directory, and a list can also be
4336obtained running \ttt{./configure --help}.
4337
4338In order to access the \ttt{NlnN} strategy for the $k_t$ algorithm,
4339the \fastjet library needs to be compiled with support for the
4340Computational Geometry Algorithms Library \ttt{CGAL}~\cite{CGAL}. This
4341same strategy gives $N\ln N$ performance for Cambridge/Aachen and
4342$N^{3/2}$ performance for anti-$k_t$ (whose sequence for jet
4343clustering triggers a worst-case scenario for the underlying
4344computational geometry methods.)
4345%
4346CGAL can be enabled with the \verb|--enable-cgal| at the
4347\ttt{configure} stage.\footnote{Since version 4.9, \ttt{CGAL} can
4348  be used as a header-only library (this is the default from version
4349  5.0 of \ttt{CGAL}). In this case, \fastjet requires an installed
4350  version of CGAL as well as the \ttt{--enable-cgal-header-only}
4351  configure argument, see e.g.\ \href{https://doc.cgal.org/latest/Manual/usage.html\#section_headeronly}{section 4} of the \ttt{CGAL} manual.}
4352%
4353\ttt{CGAL} may be obtained in source form from
4354\url{http://www.cgal.org/} and is also available in binary form for
4355many common Linux distributions.
4356%
4357For CGAL versions 3.4 and higher, the user can specify
4358\verb|--with-cgaldir=...| if the CGAL files are not installed in a
4359standard location.\footnote{For events with near degeneracies in their
4360  Delaunay triangulation, issues have been found with versions 3.7 and
4361  3.8 of CGAL. We recommend the use of earlier or later versions.}
4362
4363The \ttt{NlnNCam} strategy does not require CGAL, since it is based on
4364a considerably simpler computational-geometry structure~\cite{Chan}.
4365
4366%======================================================================
4367\section{Python interface}
4368
4369As of version 3.3, \fastjet ships with a Python interface.
4370%
4371In version 3.3 this interface is to be considered at a beta-release
4372stage.
4373%
4374While we expect it to remain largely stable, some details may evolve
4375in future releases.
4376
4377%
4378Its compilation can be enabled at configure time with the option
4379\ttt{--enable-pyext}.
4380%
4381It includes access to much of the functionality in FastJet, except
4382plugins and certain features that are difficult to map to Python.
4383%
4384In particular templated types, nested classes and user-derived classes
4385are not currently supported (with a few exceptions, see below).
4386%
4387The Python interface was largely created automatically, using
4388SWIG~\cite{swig}.
4389%
4390The Python documentation was generated automatically using Doxygen and
4391the \ttt{doxy2swig} program~\cite{doxy2swig}.
4392
4393%----------------------------------------------------------------------
4394\subsection{Essential usage}
4395\label{sec:python-essential-usage}
4396
4397The following points are useful to keep in mind:
4398\begin{itemize}
4399\item You can pass a Python list such as \ttt{[PseudoJet0, PseudoJet1,
4400    ...]}  to any FastJet call that expects a vector of
4401  \ttt{PseudoJet}s.
4402
4403\item Any FastJet call that in C++ returns a vector of \ttt{PseudoJet}s will
4404  in Python return a tuple of \ttt{PseudoJet}s
4405
4406\item For many objects that provide definitions of some kind, a
4407  pythonic \ttt{\_\_str\_\_} call maps to \ttt{description()}.
4408
4409\item When combining selectors, \ttt{\&\&}, \ttt{||} and \ttt{!} in
4410  C++ map to \ttt{\&}, \ttt{|} and \ttt{\~} in Python.
4411
4412\item Any python variable \ttt{var} (which may be a simple variable or
4413  a more complicated object) can be associated with a \ttt{PseudoJet}
4414  \ttt{pj} using
4415  the \ttt{pj.set\_python\_info(var)} call; it can be retrieved with
4416  \ttt{pj.python\_info()}.
4417  %
4418  This is based on the C++ \ttt{PseudoJet} \ttt{user\_info}
4419  functionality described in Appendix~\ref{app:user-info}.
4420
4421\item Python functions can be used to create \fastjet\ \ttt{Selector}
4422  objects, using \ttt{SelectorPython(some\_python\_function)}. The
4423  function must accept a \ttt{PseudoJet} as its single argument and
4424  return \ttt{True} or \ttt{False}.
4425  %
4426  You can also supply a class, in which case it should implement a
4427  \ttt{\_\_call\_\_(self,particle)} member to indicate whether a
4428  particle passes the selector and a \ttt{\_\_str\_\_(self)} member
4429  for the description (see \ttt{example/python/06-selector.py}).
4430  %
4431
4432\item A Python class can also be used to construct a recombiner, which
4433  must have \ttt{preprocess(self,pa)}, \ttt{recombine(self,pa,pb)} and
4434  \ttt{\_\_str\_\_(self)} members, in analogy with the C++ structure,
4435  Appendix \ref{sec:recombiner} (with \ttt{\_\_str\_\_} providing the
4436  functionality of the C++ \ttt{description} member).
4437  %
4438  \ttt{preprocess(self,pa)} should (optionally) modify \ttt{pa}
4439  directly, while \ttt{recombine(self,pa,pb)} should return a new
4440  \ttt{PseudoJet}, resulting from the recombination of \ttt{pa} and
4441  \ttt{pb}.
4442  %
4443  You can then assign the python-based recombiner using a call such as
4444  \ttt{jet\_def.set\_python\_recombiner(python\_recombiner)}, cf.\
4445  example \ttt{example/python/07-recombiner.py}.
4446
4447\item When a \fastjet \ttt{Error} exception is thrown from C++, a
4448  corresponding \ttt{fastjet.Error(...)} exception is raised in
4449  Python.
4450  %
4451  This allows for graceful handling of exceptions, notably in
4452  an interactive Python session.
4453
4454\item Remember that Python uses references, e.g.\ \ttt{a = b} means
4455  that \ttt{a} is a reference to \ttt{b}. If you need to copy a
4456  \ttt{PseudoJet} \ttt{pj} with a view to altering it, do ``\ttt{pjcopy =
4457    PseudoJet(pj)}''.
4458\end{itemize}
4459
4460%----------------------------------------------------------------------
4461\subsection{Known issues as of version 3.3.x}
4462\label{sec:python-issues}
4463
4464\begin{itemize}
4465\item C++ enums are replaced by integers in Python.
4466  %
4467  This causes complications for some overloaded interfaces, notably
4468  that of \ttt{JetDefinition}, which takes a jet algorithm
4469  specification, followed by zero, one or two C++ \ttt{double} arguments
4470  (e.g.\ jet radius $R$ and the power $p$ of the generalised-$k_t$
4471  algorithm), then specifications of the recombination scheme and
4472  clustering strategy (both enums).
4473  %
4474  With Python the arguments corresponding to the C++ doubles
4475  \emph{must} be Python \ttt{float}s.
4476  %
4477  If instead they are integers, then they are interpreted as
4478  specifying the recombination scheme and clustering strategy.
4479
4480  As an alternative there are Python calls \texttt{JetDefinition0Param(...)},
4481  \texttt{JetDefinition1Param(...)},
4482  \texttt{JetDefinition2Param(...)}, which explicitly expect 0, 1 or 2
4483  parameters that are automatically converted to double.
4484
4485  This issue is relevant also if you write code for other users that
4486  takes the parameters as an argument and then passes them on to
4487  FastJet: you may want to either explicitly call the \ttt{NParam}
4488  versions, or explicitly convert the user parameters to \ttt{float}
4489  in your own code.
4490
4491\item For the \ttt{Selector::sift(jets, jets\_that\_pass,
4492    jets\_that\_fail)} C++ member, the last two arguments are
4493  references to \ttt{vector<PseudoJet>} objects.
4494  %
4495  In this case, it is not possible to use a Python list in place of
4496  those arguments.
4497  %
4498  Instead you should pass variables initialised to be \ttt{vectorPJ()}
4499  (which corresponds to the C++ \ttt{vector<PseudoJet>}).
4500
4501\item Plugins and \fjcontrib code do not yet have a Python interface,
4502  nor does \fjcore.
4503\end{itemize}
4504
4505
4506%----------------------------------------------------------------------
4507\subsection{A simple example}
4508\label{sec:python-example}
4509
4510A short example of Python usage is as follows:
4511%
4512\begin{lstlisting}[language=Python]
4513  from fastjet import *
4514  particles = []
4515  particles.append(PseudoJet(100.0, 0.0, 0.0, 100.0)) # px, py, pz, E
4516  particles.append(PseudoJet(150.0, 0.0, 0.0, 150.0))
4517
4518  R = 0.4
4519  jet_def = JetDefinition(antikt_algorithm, R)
4520
4521  jets = jet_def(particles)
4522
4523  print jet_def
4524  for jet in jets: print jet
4525\end{lstlisting}
4526Further examples are to be found in the \ttt{example/python/}
4527directory.
4528
4529%=======================================================================
4530\section{FJcore}
4531\label{sec:fjcore}
4532
4533The \ttt{fjcore} package provides a simple, compact way of accessing
4534the main \fastjet functionality.
4535%
4536It consists of just two files \ttt{fjcore.hh} and \ttt{fjcore.cc}.
4537%
4538A program can access the \ttt{fjcore} functionality by linking with
4539\ttt{fjcore.cc} instead of the full \fastjet library,
4540%  distributed separately from the
4541% full \fastjet package from \url{http://fastjet.fr}, are meant to provide easy access to these
4542% core functions, in the form of single files and without the need of a full
4543% \fastjet installation:
4544\begin{lstlisting}
4545    g++ main.cc fjcore.cc
4546\end{lstlisting}
4547where \ttt{main.cc} includes \ttt{fjcore.hh} rather than the usual
4548\fastjet headers.
4549%
4550Clustering results are identical to those obtained by linking to the
4551full \fastjet distribution.
4552
4553One of the main intended uses of \fjcore is to provide jet-finding
4554code that can be easily distributed with 3rd party code (e.g.\ it is
4555currently distributed with Pythia~8~\cite{Sjostrand:2007gs} and
4556MadGraph5\_aMC@NLO).
4557%
4558We emphasize that the \fastjet licensing conditions \emph{must} be
4559respected when incorporating \fjcore.
4560%
4561This includes a mention of \fjcore's GPL license in the third-party
4562package's own LICENSE or COPYING file.
4563%
4564Furthermore for interactive usage, the \fjcore banner may not be
4565removed.
4566%
4567This is because it contains crucial information, such as the \fjcore version
4568number, that users are expected to quote in their scientific
4569publications.
4570%
4571In order to make it possible for \ttt{fjcore} and the full \fastjet
4572(e.g.\ used in a separate user program) to coexist, the \fjcore
4573package uses the \ttt{fjcore} namespace instead of \ttt{fastjet}.
4574
4575In particular, \ttt{fjcore} provides:
4576\begin{itemize}
4577\item access to all native hadron-collider and $e^+e^-$ algorithms,
4578  $k_t$, anti-$k_t$, C/A.  For C/A, the $N\ln N$ method is available,
4579  while anti-$k_t$ and $k_t$ are limited to the $N^2$ one (still the
4580  fastest for $N < 100$k particles)
4581  \item access to selectors, for implementing cuts and selections
4582  \item access to all functionalities related to PseudoJets (e.g. a jet's
4583    structure or user-defined information)
4584\end{itemize}
4585Instead, it does \emph{not} provide:
4586\begin{itemize}
4587  \item jet-area functionality
4588  \item background estimation
4589  \item access to other algorithms via plugins
4590  \item interface to CGAL
4591  \item fastjet tools, e.g. filters, taggers
4592\end{itemize}
4593%
4594If these functionalities are needed, the full \fastjet installation must be
4595used. The code will be fully compatible, with the sole replacement of the
4596header files and of the \ttt{fjcore} namespace with the \ttt{fastjet} one.
4597
4598Note that the \fjcore package comes with a basic example
4599\ttt{01-basic.cc} as well as a fortran interface and an associated
4600example.
4601
4602The \fjcore package has been available since release 3.0.4 of
4603\fastjet, and tracks \fastjet versions.
4604%
4605It is available for download from the \url{http://fastjet.fr/} web
4606site.
4607
4608
4609%=======================================================================
4610\section{FastJet Contrib}
4611\label{sec:fjcontrib}
4612
4613The \fastjet update schedule is geared towards providing stability.
4614%
4615Typically, a minor (e.g.\ $3.0 \to 3.1$) release is made every two or
4616three years, and a new minor or major release may only become widely
4617adopted (notably by the experiments) a further year or two down the
4618line.
4619%
4620In comparison, the field of jet physics, especially jet substructure,
4621and the development of associated tools proceeds at a much faster pace.
4622
4623To accommodate this, part way through the 3.1 development cycle, in
46242013, \fastjet \contrib (\fjcontrib) was introduced.
4625%
4626This provides a home for a variety of contributed tools.
4627%
4628New tools from 3rd-party authors can usually be added in the space of
4629days or weeks, after some basic review of the interface, so far
4630usually carried out by the \fastjet authors.
4631%
4632Contents, instructions and information for contributing are provided
4633on the \fjcontrib web pages~\cite{fjcontrib},
4634\url{http://fastjet.hepforge.org/contrib/}.
4635%
4636
4637
4638
4639%======================================================================
4640\section*{Acknowledgements}
4641
4642Many people have provided bug reports, suggestions for development,
4643documentation and in some cases explicit code for plugin
4644algorithms. We would in particular like to thank
4645%
4646% The list below should be identical to that in the AUTHORS file,
4647% which is the master list
4648%
4649Vanya Belyaev,
4650Andy Buckley,
4651Timothy Chan,
4652Pierre-Antoine Delsart,
4653Olivier Devillers,
4654Robert Harris,
4655Joey Huston,
4656Sue Ann Koay,
4657Andreas Oehler,
4658Sal Rappoccio,
4659Juan Rojo,
4660Sebastian Sapeta,
4661Mike Seymour,
4662Jessie Shelton,
4663Lars Sonnenschein,
4664Hartmut Stadie,
4665Mark Sutton,
4666Jesse Thaler
4667Chris Vermilion,
4668Markus Wobisch.
4669
4670Since its inception, this project has been supported in part by grants
4671ANR-05-JCJC-0046-01, ANR-09-BLAN-0060 and ANR-10-CEXC-009-01 from the
4672French Agence Nationale de la Recherche, PITN-GA-2010-264564 from the
4673European Commission and DE-AC02-98CH10886 from the U.S.\ Department of
4674Energy.
4675
4676We would also like to thank the numerous institutes that have hosted
4677us for shorter or longer stays while \fastjet was being developed,
4678including the GGI in Florence, KITP at Santa Barbara, Rutgers
4679University and Brookhaven National Laboratory.
4680\appendix
4681
4682%======================================================================
4683\section{Clustering strategies and performance}
4684\label{app:strategies}
4685
4686The constructor for a \ttt{JetDefinition} can take a strategy argument
4687(cf.\ section~\ref{sec:JetDefinition}), which selects the algorithmic
4688``strategy'' to use while clustering.
4689%
4690It is an \ttt{enum} of type \ttt{Strategy} with relevant
4691values listed in table~\ref{tab:Strategies}.
4692%
4693Nearly all strategies are based on the factorisation of energy and
4694geometrical distance components of the $d_{ij}$
4695measure~\cite{fastjet}. In particular they involve the dynamic
4696maintenance of a nearest-neighbour graph for the geometrical
4697distances.  They apply equally well to any of the internally
4698implemented hadron-collider jet algorithms.
4699%
4700The two exceptions are: \ttt{NlnNCam}, which is based on a
4701computational geometry algorithm for dynamic maintenance of closest
4702pairs \cite{Chan} (rather than the more involved nearest neighbour
4703graph), and is suitable only for the Cambridge algorithm, whose
4704distance measure is purely geometrical; and
4705\ttt{N2MHTLazy9AntiKtSeparateGhosts}, intended specifically for area
4706calculations with the anti-$k_t$ algorithm (to be considered
4707preliminary in v3.1; it can also be used for passive area calculations
4708for other algorithms).
4709
4710%
4711\begin{table}[bt]
4712  \begin{center}
4713    \begin{tabular}{ll}\toprule
4714      \ttt{N2Plain} & Plain $N^2$ algorithm\\
4715      \ttt{N2Tiled} & Tiled $N^2$ algorithm\\
4716      \ttt{N2MinHeapTiled} & Tiled $N^2$ algorithm with a heap for
4717      tracking the min.\ of $d_{ij}$
4718      %(fastest for $400 \lesssim N \lesssim 15000$)\\
4719      \\
4720      \ttt{N2MHTLazy9} & Variant of \ttt{N2MinHeapTiled}, with
4721      ``lazy'' (see text) evaluation of \\ &
4722      distances to  particles in the set of $9=3\times3$ nearby
4723      tiles
4724      \\
4725      \ttt{N2MHTLazy25} & Like \ttt{N2MHTLazy9}, but uses tiles of
4726      size $R/2$ and a set of \\& $25=5\times5$ neighbours
4727      \\
4728      \ttt{N2MHTLazy9AntiKtSeparateGhosts} & Similar to
4729      \ttt{N2MHTLazy9}, but neglects ghost-ghost clusterings\\
4730      & (to be considered preliminary in FJ3.1)
4731      \\
4732      \ttt{NlnN} & Voronoi-based $N\ln N$ algorithm\\
4733      \ttt{NlnNCam} & Based on Chan's $N\ln N$ closest pairs
4734      algorithm, suitable only\\& for the Cambridge jet algorithm
4735      \\
4736      \ttt{Best} & Automatic selection of the best of these based on
4737      $N$ and $R$
4738      \\
4739      \ttt{BestFJ30} & Automatic strategy selection as was done in
4740      FastJet 3.0
4741      \\\bottomrule
4742    \end{tabular}
4743    \caption{The more interesting of the various algorithmic
4744      strategies for clustering. Other strategies are given in
4745      \ttt{JetDefinition.hh} --- however, strategies not
4746      listed in the above table may disappear in future releases.
4747      %
4748      For jet algorithms with spherical distance measures (those whose
4749      name starts with ``\ttt{ee\_}''), only the \ttt{N2Plain}
4750      strategy is available.
4751      %
4752      The $N$ range in which a given strategy is optimal depends on
4753      $R$ and on the rapidity extent of the particles.
4754      %
4755      See figure~\ref{fig:optimal-strategy} for details.
4756    }
4757    \label{tab:Strategies}
4758  \end{center}
4759\end{table}
4760
4761
4762The \ttt{N2Plain} strategy uses a ``nearest-neighbour heuristic''
4763\cite{Anderberg} approach to maintaining the geometrical
4764nearest-neighbour graph; \ttt{N2Tiled} tiles the $y-\phi$ cylinder
4765to limit the set of points over which nearest-neighbours are searched
4766for,%
4767\footnote{Tiling is a textbook approach in computational geometry,
4768  where it is often referred to as bucketing. It has been used also in
4769  certain cone jet algorithms, notably at trigger level and in
4770  \cite{Sonnenschein}.} %
4771and \ttt{N2MinHeapTiled} differs only in that it uses an $N\ln N$
4772(rather than $N^2$) data structure for maintaining in order the subset
4773of the $d_{ij}$ that involves nearest neighbours.
4774%
4775Both use tiles of size at least $R\times R$, and search for a
4776particle's nearest neighbours in the $3\times 3$ set of tiles centred
4777on that particle's own tile.
4778%
4779The \ttt{N2MHTLazy9} strategy is similar, however before considering a
4780neighbouring tile it establishes whether the edge of the tile is
4781closer than the particle's nearest same-tile neighbour.
4782%
4783If not, it skips the tile, hence the name ``lazy''.
4784%
4785The extra checks and bookkeeping introduce a speed penalty for
4786moderate $N$, but at large $N$ that is more than compensated for by
4787the fact that one searches for neighbours in a smaller set
4788of tiles.
4789%
4790The \ttt{N2MHTLazy25} strategy is almost identical except that it uses
4791a $5\times 5$ set of tiles of size at least $R/2$.
4792%
4793All the lazy algorithms are new in \fastjet 3.1.
4794%
4795The \ttt{NlnN} strategy uses CGAL's Delaunay Triangulation
4796\cite{CGAL} for the maintenance of the nearest-neighbour graph.
4797%
4798Note that $N \ln N$ performance is an \emph{expected} result, and
4799it holds in practice for the $k_t$ and Cambridge algorithms, while for
4800anti-$k_t$ and generalised-$k_t$ with $p<0$, hub-and-spoke (or
4801bicycle-wheel) type configurations emerge dynamically during the
4802clustering and these break the conditions needed for the expected
4803result to hold (this however has a significant impact only for $N
4804\gtrsim 10^5$; we believe that it leads to $N^{3/2}$ asymptotic time
4805for clustering).\footnote{%
4806  %
4807  In versions of \fastjet prior to 3.1.0, the $N \ln N$ strategy had
4808  the limitation that it could not be used in events with perfectly
4809  collinear particles.
4810  %
4811  This was related to the fact that the underlying computational geometry
4812  structures cannot cleanly accommodate multiple particles in the same
4813  location.
4814  %, because of the degeneracies that are induced.
4815  %
4816  As of version 3.1.0, this limitation has been eliminated.
4817}
4818
4819\begin{figure}[tp]
4820  \centering
4821  \includegraphics[width=0.32\textwidth]{figs/fj31-best-strategy-manual-akt}\hfill
4822  \includegraphics[width=0.32\textwidth]{figs/fj31-best-strategy-manual-cam}\hfill
4823  \includegraphics[width=0.32\textwidth]{figs/fj31-best-strategy-manual-kt}
4824  \caption{Transitions between fastest strategies in the plane of
4825    particle multiplicity $N$ and radius $R$.
4826    %
4827    The events consist of
4828    one hard scatter and a variable number pileup collisions, with
4829    particles accepted up to rapidity $|y|<5$.
4830    %
4831    To probe the small $N$
4832    region, only the $N$ hardest particles in the event are kept.
4833    %
4834    The red lines with symbols indicate the measured transitions,
4835    while the black solid lines are the approximate transitions used
4836    for the \texttt{Best} strategy.
4837    %
4838    The three plots are, from left to right, for the anti-$k_t$, C/A and
4839    $k_t$ algorithms.
4840  }
4841  \label{fig:optimal-strategy}
4842\end{figure}
4843
4844
4845Given the many strategies, it is not entirely trivial to select the
4846fastest one for any given event.
4847%
4848The optimal choice depends on the jet algorithm, its radius parameter,
4849the event multiplicity, and the way in which the particles are
4850distributed across the event (e.g.\ all concentrated at small
4851rapidities, or covering a large rapidity range).
4852%
4853Figure~\ref{fig:optimal-strategy} shows our determination of the
4854optimal strategy for different $R$ and $N$ for events covering
4855rapidities up to $|y|<5$.\footnote{The optimal transition to the
4856  \ttt{NlnNCam} strategy may depend strongly on the size of the
4857  cache.}
4858%
4859The solid black lines indicate the transitions encoded in the
4860``\ttt{Best}'' meta-strategy, which automatically selects one of the
4861actual strategies for execution.
4862%
4863Note that the choice of optimal strategy can to some extent depend
4864also on the processor, compiler version and optimisation flags.
4865%
4866Accordingly, the choices made in the \ttt{Best} strategy may not be
4867perfectly optimal on all systems.
4868
4869\begin{figure}[tp]
4870  \centering
4871  % NB: use of 3_0_1 in file naming is to ensure that we can drop the
4872  % file extension. That way both latex and pdflatex will find an
4873  % appropriate figure.
4874  %\includegraphics[width=0.7\textwidth]{figs/timings_best_3_0_1}
4875  \includegraphics[width=0.47\textwidth]{figs/fj31_timings_best_R04}\hfill
4876  \includegraphics[width=0.47\textwidth]{figs/fj31_timings_best_R12}
4877  \caption{
4878    Time required to perform the clustering of $N$ particles in
4879    \fastjet 3.1.0 with the \ttt{Best} strategy. The anti-$k_t$,
4880    $k_t$, and Cambridge/Aachen (C/A) native algorithms are shown for
4881    $R=0.4$ (left) and $R=1.2$ (right).
4882    %
4883    For comparison, the figure also includes the timings for the anti-$k_t$ algorithm
4884    in version 3.0.6 of \fastjet.
4885    %%
4886    % The timings were obtained on an Intel i5 760 processor with 8~MB of
4887    % cache.
4888    %% machine is talos
4889    The timings were obtained on an Intel Xeon X3360 processor with 6~MB of
4890    level-3 cache, running at 2.83GHz.
4891    %
4892    The code was compiled with \ttt{g++} version 4.4, using the \ttt{-O2}
4893    optimisation flag.
4894    %
4895    For small $N$, $N$ was varied by taking a single hard dijet event
4896    generated with Pythia~6~\cite{Sjostrand:2006za} and extracting the
4897    $N$ hardest particles.
4898    %%
4899    Large $N$ values were obtained by taking a single hard dijet event
4900    and adding simulated minimum-bias events to it.
4901    %%
4902    Particles are limited to rapidities $|y|<5$.
4903    %%
4904    The results include the time to extract the inclusive jets with
4905    $p_t > 5\GeV$ and sort them into decreasing $p_t$.
4906    %
4907    Note that timings observed in practice can differ from those given
4908    here for events with substantially different distributions of
4909    particles.
4910    %
4911  }
4912  \label{fig:timings}
4913\end{figure}
4914
4915Illustrative timings for the \ttt{Best} strategy are shown as a
4916function of $N$ in figure~\ref{fig:timings} for the anti-$k_t$, $k_t$
4917and the Cambridge/Aachen algorithms, with $R=0.4$ on the left and
4918$R=1.2$ on the right.
4919%
4920For comparison the figure also shows the timings for the anti-$k_t$
4921algorithm in \fastjet 3.0.6 and additionally for SISCone ($R=0.4$ only).
4922%
4923Kinks in the timings of the native algorithms are visible at the $N$
4924values where there is a switch from one strategy to another.
4925%
4926%There can be imperfections in this choice, e.g. as seen for the $k_t$
4927%algorithm near $N=20\,000$.
4928%
4929% While their impact is generally modest, depending on event structure
4930% there can be cases where a manual choice of strategy can have
4931% significant benefits.
4932%
4933The speed improvements from the strategies introduced in version
49343.1 set in starting with a couple of thousand (hundred) particles for
4935$R=0.4$ ($1.2$) and reach about a factor of ten improvement for
4936$N\simeq 10^5$ ($20\,000$); they also result in the transition to the
4937$N\ln N$ strategies occurring at somewhat larger $N$ than in version
49383.0, typically at or beyond $N=10^5$.
4939%
4940%
4941Taking $N=10^4$ particles as a reference (e.g.\ corresponding to moderate
4942$pp$ pileup plus ghosts for area subtraction\footnote{For the specific
4943  case of the anti-$k_t$ algorithm with ghosts, the
4944  \ttt{N2MHTLazy9AntiKtSeparateGhosts} can bring further benefits in
4945  this region.}), the improvement in speed is about a factor of $2$
4946for $R=0.4$ and $7$ for $R=1.2$.
4947
4948We note that there are a few places where there remains scope for
4949timing improvements.
4950%
4951In particular at low $N$ the overheads related to copying and sorting
4952a vector of \ttt{PseudoJet} objects are a relevant fraction of the
4953total time, and could be reduced.
4954%
4955Additionally, for the Cambridge/Aachen algorithm at moderate to large
4956$N$, the use of multiple grid sizes could bring some
4957benefit.
4958%
4959The improvements contained in the \ttt{N2MHTLazy9AntiKtSeparateGhosts}
4960strategy could be further extended to the \ttt{Lazy25} case and made
4961available automatically.
4962%
4963Finally the \ttt{Best} strategy selection could try to better take
4964into account the rapidity extent of the event, and special cases like
4965single-jet reclustering.
4966%
4967% for the anti-$k_t$ algorithm one can envisage $\order{1}$ improvements
4968% at moderate to large $N$ when $N$ is dominated by ghost particles,
4969% making use of the fact that for the anti-$k_t$ algorithm one may
4970% neglect the ghosts' self clustering in the determination of hard jets'
4971% areas.
4972%
4973Should users have applications where such improvements are
4974critical, they are encouraged to contact the \fastjet authors.
4975
4976%======================================================================
4977\section{User Info in PseudoJets}
4978\label{app:user-info}
4979
4980One method for associating extra user information with a
4981\ttt{PseudoJet} is via its user index
4982(section~\ref{sec:PseudoJet}). This is adequate for encoding simple
4983information. such as an input particle's barcode in a HepMC
4984event.
4985%
4986However, it can quickly show its limitations; for example, when
4987simulating pileup one might have several HepMC events and it is then
4988useful for each particle to additionally store information about which
4989HepMC event it comes from.
4990
4991A second method for supplementing a \PJ with extra user information is for
4992the user to derive a class from \ttt{PseudoJet::UserInfoBase} and
4993associate the \ttt{PseudoJet} with a pointer to an instance of that
4994class:
4995\begin{lstlisting}
4996  void set_user_info(UserInfoBase * user_info);
4997  const UserInfoBase* user_info_ptr() const;
4998\end{lstlisting}
4999The function \ttt{set\_user\_info(...)} transfers ownership of the
5000pointer to the \ttt{PseudoJet}.
5001%
5002This is achieved internally with the help of a shared pointer. Copies
5003of the \ttt{PseudoJet} then point to the same \ttt{user\_info}.
5004%
5005When the \ttt{PseudoJet} and all its copies go out of scope, the
5006\ttt{user\_info} is automatically deleted.
5007%
5008Since nearly all practical uses of \ttt{user\_info} require it
5009to be cast to the relevant derived class of  \ttt{UserInfoBase}, we also
5010provide the following member function for convenience:
5011\begin{lstlisting}
5012  template<class L> const L & user_info() const;
5013\end{lstlisting}
5014which explicitly performs the cast of the extra info to type \ttt{L}.
5015%
5016If the cast fails, or the user info has not been set, an error
5017will be thrown.\footnote{%
5018  For clustering with explicit ghosts, even if the particles being
5019  clustered have user information, the ghosts will not.
5020  %
5021  The user should take care therefore not to ask for user information
5022  about the ghosts, e.g.\ with the help of the \texttt{PseudoJet::is\_pure\_ghost()}
5023  or \texttt{PseudoJet::has\_user\_info<L>()} calls.
5024  %
5025  The \texttt{SelectorIsPureGhost()} can also be used for this purpose.
5026}
5027
5028The user may wonder why we have used shared pointers internally (i.e.\
5029have ownership transferred to the \ttt{PseudoJet}) rather than normal
5030pointers.
5031%
5032An example use case where the difference is important is if, for
5033example, one wishes to write a \ttt{Recombiner} that sets the
5034\ttt{user\_info} in the recombined \PJ.
5035%
5036Since this is likely to be new information, the \ttt{Recombiner} will
5037have to allocate some memory for it.
5038%
5039With a normal pointer, there is then no easy way to clean up that
5040memory when the \PJ is no longer relevant (e.g.\ because the \CS that
5041contains it has gone out of scope).
5042%
5043In contrast, with a shared pointer the memory is handled automatically.\footnote{
5044  The user may also wonder why we didn't simply write a templated
5045  version of \PJ in order to contain extra information.
5046  %
5047  The answer here is that to introduce a templated \PJ would imply
5048  that every other class in \fastjet should then also be templated.
5049}
5050
5051The shared pointer type in \fastjet is a template class called
5052\ttt{SharedPtr}, available through
5053%
5054\begin{lstlisting}
5055  #include "fastjet/SharedPtr.hh"
5056\end{lstlisting}
5057%
5058It behaves almost identically to the \ttt{C++0x} \ttt{shared\_ptr}.\footnote{
5059%
5060Internally it has been designed somewhat differently, in order
5061to limit the memory footprint of the \PJ that contains it. One
5062consequence of this is that dynamic casts of \ttt{SharedPtr}'s are not
5063supported.}
5064%
5065The end-user should not usually need to manipulate the
5066\ttt{SharedPtr}, though the \ttt{SharedPtr} to \ttt{user\_info} is
5067accessible through \PJ's \ttt{user\_info\_shared\_ptr()} member.
5068
5069An example of the usage might be the following. First you define a
5070class \ttt{MyInfo}, derived from \ttt{PseudoJet::UserInfo},
5071\begin{lstlisting}
5072  class MyInfo: public PseudoJet::UserInfoBase {
5073     MyInfo(int id) : _pdg_id(id);
5074     int pdg_id() const {return _pdg_id;}
5075     int _pdg_id;
5076  };
5077\end{lstlisting}
5078Then you might set the info as follows
5079\begin{lstlisting}
5080  PseudoJet particle(...);
5081  particle.set_user_info(new MyInfo(its_pdg_id));
5082\end{lstlisting}
5083and later access the PDG id through the function
5084\begin{lstlisting}
5085  particle.user_info<MyInfo>().pdg_id();
5086\end{lstlisting}
5087More advanced examples can be provided on request, including code that
5088helps handle particle classes from third party tools such as
5089Pythia~8~\cite{Sjostrand:2007gs}.
5090
5091%======================================================================
5092\section{Structural information for various kinds of \texttt{PseudoJet}}
5093\label{app:structure_table}
5094
5095\begin{table}[t]\centering
5096\begin{tabular}{lccccccc}
5097\toprule
5098  && particle & jet & jet (no CS) & constituent & \ttt{join(}$j_1,j_2$\ttt{)} & \ttt{join(}$p_1,p_2$\ttt{)} \\
5099\midrule
5100\ttt{has\_associated\_cs()}
5101                     && false   & true    &  true   & true    & false    & false   \\
5102\ttt{associated\_cs()}
5103                     && NULL    &  CS     &  NULL   &  CS     & NULL     & NULL    \\
5104\midrule
5105\ttt{has\_valid\_cs()}
5106                     && false   & true    &  false  & true    & false    & false   \\
5107\ttt{validated\_cs()}&& \throws &  CS     & \throws &  CS     & \throws  & \throws \\
5108\midrule
5109\ttt{has\_constituents()}
5110                     && false   & true    & true    & true    & true     & true    \\
5111\ttt{constituents()} && \throws & from CS & \throws & itself  & recurse  & pieces  \\
5112\midrule
5113\ttt{has\_pieces()}  && false   & true    & \throws & false   & true     & true    \\
5114\ttt{pieces()}       && \throws & parents & \throws & empty   & pieces   & pieces  \\
5115\midrule
5116\ttt{has\_parents(...)}
5117                     && \throws & from CS & \throws & from CS & \throws  & \throws \\
5118\ttt{has\_child(...)}&& \throws & from CS & \throws & from CS & \throws  & \throws \\
5119\ttt{contains(...)}  && \throws & from CS & \throws & from CS & \throws  & \throws \\
5120\bottomrule
5121\end{tabular}
5122\caption{summary of the behaviour obtained when requesting
5123  structural information from different kinds of \ttt{PseudoJet}. A
5124  particle (also $p_1,p_2$) is a \ttt{PseudoJet}
5125  constructed by the user, without structural information; a ``jet''
5126  (also $j_1,j_2$) is the output from a
5127  \ttt{ClusterSequence}; ``from CS'' means that the information is
5128  obtained from the associated \ttt{ClusterSequence}.
5129  %
5130  A ``jet (no CS)'' is one whose \ttt{ClusterSequence} has gone out of
5131  scope.
5132  %
5133  All other entries should be self-explanatory.}\label{tab:structure}
5134\end{table}
5135
5136Starting with \fastjet version 3.0, a \ttt{PseudoJet} can access
5137information about its structure, for example its constituents if it came
5138from a \ClusterSequence, or its pieces if it was the result of a
5139\ttt{join(...)} operation.
5140%
5141In this appendix, we summarise what the various structural access
5142methods will return for different types of \ttt{PseudoJet}s: input
5143particles, jets resulting from a clustering, etc.
5144%
5145Table \ref{tab:structure} provides the information for the most
5146commonly-used methods.
5147
5148Additionally, all the methods that access information related to the
5149clustering (\ttt{has\_partner()}, \ttt{is\_inside()},
5150\ttt{has\_exclusive\_subjets()}, \ttt{exclusive\_subjets()},
5151\ttt{n\_exclusive\_subjets()}, \ttt{exclusive\_subdmerge()}, and
5152\ttt{exclusive\_subdmerge\_max}) require the presence of an associated
5153cluster sequence and throw an error if none is available (except for
5154\ttt{has\_exclusive\_subjets()} which just returns \ttt{false}).
5155
5156For area-related calls, \ttt{has\_area()} will be \ttt{false} unless
5157the jet is obtained from a \ttt{ClusterSequenceAreaBase} or is a
5158composite jet made from such jets. All other area calls
5159(\ttt{validated\_csab()}, \ttt{area()}, \ttt{area\_error()},
5160\ttt{area\_4vector()}, \ttt{is\_pure\_ghost()}) will return the
5161information from the \ttt{ClusterSequenceAreaBase}, or from the pieces
5162in case of a composite jet. An error will be thrown if the jet does
5163not have area information.
5164
5165%......................................................................
5166\paragraph{Internal storage of structural information.}
5167%
5168The means by which information about a jet's structure is stored is
5169generally transparent to the user.
5170%
5171The main exception that arises is when the user wishes to create jets
5172with a new kind of structure, for example when writing boosted-object
5173taggers.
5174%
5175Here, we simply outline the approach adopted. For concrete usage
5176examples one can consult section~\ref{sec:transformers} and appendix \ref{sec:transformerdetails},
5177where we discuss transformers and taggers.
5178
5179To be able to efficiently access structural information, each \PJ has
5180a shared pointer to a class of type \ttt{fastjet::PseudoJetStructureBase}.
5181%
5182For plain {\PJ}s the pointer is null.
5183%
5184For {\PJ}s obtained from a \CS the pointer is to a class
5185\ttt{fastjet::ClusterSequenceStructure}, which derives from
5186\ttt{PseudoJetStructureBase}.
5187%
5188For {\PJ}s obtained from a \ttt{join(...)} operation, the pointer is
5189to a class \ttt{fastjet::CompositeJetStructure}, again derived from
5190\ttt{PseudoJetStructureBase}.
5191%
5192It is these classes that are responsible for answering structural
5193queries about the jet, such as returning its constituents, or
5194indicating whether it \ttt{has\_pieces()}.
5195%
5196Several calls are available for direct access to the internal structure
5197storage, among them
5198\begin{lstlisting}
5199  const PseudoJetStructureBase* structure_ptr() const;
5200  PseudoJetStructureBase*       structure_non_const_ptr();
5201  template<typename StructureType> const StructureType & structure() const;
5202  template<typename TaggerType> const TaggerType::StructureType & structure_of() const;
5203\end{lstlisting}
5204where the first two return simply the structure pointer, while the
5205last two cast the pointer to the desired derived structure type.
5206
5207
5208
5209%======================================================================
5210\section{Functions of a \texttt{PseudoJet}}
5211\label{app:function-of-pj}
5212
5213A concept that is new to \fastjet 3 is that of a
5214\ttt{fastjet::FunctionOfPseudoJet}.
5215%
5216Functions of \ttt{PseudoJet}s arise in many contexts: many
5217boosted-object taggers take a jet and return a modified version of a
5218jet; background subtraction does the same; so does a simple Lorentz
5219boost.
5220%
5221Other functions return a floating-point number associated
5222with the jet: for example jet shapes, but also the rescaling functions
5223used to provide local background estimates in
5224section~\ref{sec:BGE-positional}.
5225%
5226
5227To help provide a uniform interface for functions of a \PseudoJet,
5228\fastjet has the following template base class:
5229\begin{lstlisting}
5230  // a generic function of a PseudoJet
5231  template<typename TOut> class FunctionOfPseudoJet{
5232    // the action of the function (this _has_ to be overloaded in derived classes)
5233    virtual TOut result(const PseudoJet &pj) const = 0;
5234  };
5235\end{lstlisting}
5236Derived classes should implement the \ttt{result(...)} function.
5237%
5238In addition it is good practice to overload the \ttt{description()}
5239member,
5240\begin{lstlisting}
5241  virtual std::string description() const {return "";}
5242\end{lstlisting}
5243
5244Usage of a \ttt{FunctionOfPseudoJet} is simplest through the
5245\ttt{operator(...)} member functions
5246\begin{lstlisting}
5247  TOut operator()(const PseudoJet & pj) const;
5248  vector<TOut> operator()(const vector<PseudoJet> & pjs) const;
5249\end{lstlisting}
5250which just call \ttt{result(...)} either on the single jet, or
5251separately on each of the elements of the vector of
5252{\PseudoJet}s.\footnote{Having \ttt{result(...)} and
5253  \ttt{operator(...)} doing the same thing may seem redundant,
5254  however, it allows one to redefine only \ttt{result} in derived
5255  classes.  If we had had a virtual \ttt{operator(...)} instead, both
5256  the \ttt{PseudoJet} and \ttt{vector<PseudoJet>} versions would have
5257  had to be overloaded.}.
5258
5259The \ttt{FunctionOfPseudoJet} framework makes it straightforward to
5260pass functions of \ttt{PseudoJet}s as arguments. This is, e.g.,
5261used for the background rescalings in section~\ref{sec:BGE-positional},
5262which are just derived from \ttt{FunctionOfPseudoJet<double>}.
5263%
5264It is also used for the \ttt{Transformer}s of
5265section~\ref{sec:transformers}, which all derive from
5266\ttt{FunctionOfPseudoJet<PseudoJet>}.
5267%
5268The use of a class for these purposes, rather than a pointer to a
5269function, provides the advantage that the class can be initialised
5270with additional arguments.
5271
5272
5273\section{User-defined extensions of \fastjet}
5274
5275
5276
5277\subsection{External Recombination Schemes}
5278\label{sec:recombiner}
5279
5280A user who wishes to introduce a new recombination scheme may
5281do so by writing a class derived from \ttt{JetDefinition::Recombiner}:
5282\begin{lstlisting}
5283  class JetDefinition::Recombiner {
5284  public:
5285    /// return a textual description of the recombination scheme implemented here
5286    virtual std::string description() const = 0;
5287
5288    /// recombine pa and pb and put result into pab
5289    virtual void recombine(const PseudoJet & pa, const PseudoJet & pb,
5290                           PseudoJet & pab) const = 0;
5291
5292    /// routine called to preprocess each input jet (to make all input
5293    /// jets compatible with the scheme requirements (e.g. massless).
5294    virtual void preprocess(PseudoJet & p) const {};
5295
5296    /// a destructor to be replaced if necessary in derived classes...
5297    virtual ~Recombiner() {};
5298  };
5299\end{lstlisting}
5300A jet definition can then be constructed by providing a pointer to an
5301object derived from \ttt{JetDefinition::Recombiner} instead of the
5302\ttt{RecombinationScheme} index:
5303\begin{lstlisting}
5304  JetDefinition(JetAlgorithm jet_algorithm,
5305                double R,
5306                const JetDefinition::Recombiner * recombiner,
5307                Strategy strategy = Best);
5308\end{lstlisting}
5309%
5310The derived class \ttt{JetDefinition::DefaultRecombiner} is what is
5311used internally to implement the various recombination schemes if an
5312external \ttt{Recombiner} is not provided. It provides a useful
5313example of how to implement a new \ttt{Recombiner} class.
5314%
5315
5316The recombiner can also be set with a \ttt{set\_recombiner(...)} call.
5317%
5318If the recombiner has been created with a \ttt{new} statement and the
5319user does not wish to manage the deletion of the corresponding memory
5320when the \ttt{JetDefinition} (and any copies) using the recombiner
5321goes out of scope, then the user may wish to call the
5322\ttt{delete\_recombiner\_when\_unused()} function, which tells the
5323\ttt{JetDefinition} to acquire ownership of the pointer to the
5324recombiner and delete it when it is no longer needed.
5325
5326
5327%------------------------------------------------------
5328
5329
5330
5331\subsection{Implementation of a plugin jet algorithm}
5332\label{sec:new-plugin}
5333
5334%
5335The base class from which plugins derive has the following structure:
5336\begin{lstlisting}
5337  class JetDefinition::Plugin{
5338  public:
5339    /// returns a textual description of the jet-definition implemented in this plugin
5340    virtual std::string description() const = 0;
5341
5342    /// given a ClusterSequence that has been filled up with initial particles,
5343    /// the following function should fill up the rest of the ClusterSequence,
5344    /// using the following member functions of ClusterSequence:
5345    ///   - plugin_do_ij_recombination(...)
5346    ///   - plugin_do_iB_recombination(...)
5347    virtual void run_clustering(ClusterSequence &) const = 0;
5348
5349    /// a destructor to be replaced if necessary in derived classes...
5350    virtual ~Plugin() {};
5351
5352    //------- ignore what follows for simple usage! ---------
5353    /// returns true if passive areas can be efficiently determined by
5354    /// (a) setting the ghost_separation scale (see below)
5355    /// (b) clustering with many ghosts with $p_t$ $\ll$ ghost_separation_scale
5356    /// (c) counting how many ghosts end up in a given jet
5357    virtual bool supports_ghosted_passive_areas() const {return false;}
5358
5359    /// sets the ghost separation scale for passive area determinations
5360    /// in future runs (NB: const, so should set internal mutable var)
5361    virtual void set_ghost_separation_scale(double scale) const;
5362    virtual double ghost_separation_scale() const;
5363
5364  };
5365\end{lstlisting}
5366%
5367Any plugin class must define the \ttt{description} and
5368\ttt{run\_clustering} member functions. The former just returns a
5369textual description of the jet algorithm and its options (e.g.\ radius,
5370etc.), while the latter does the hard work of running the user's own
5371jet algorithm and transferring the information to the
5372\ttt{ClusterSequence} class. This is best illustrated with an example:
5373\begin{lstlisting}
5374using namespace fastjet;
5375
5376void CDFMidPointPlugin::run_clustering(ClusterSequence & clust_seq) {
5377
5378  // when run_clustering is called, the clust_seq.jets() has already been
5379  // filled with the initial particles
5380  const vector<PseudoJet> & initial_particles = clust_seq.jets();
5381
5382  // it is up to the user to do their own clustering on these initial particles
5383  // ...
5384\end{lstlisting}
5385Once the plugin has run its own clustering it must transfer the
5386information back to the \ttt{clust\_seq}. This is done by recording
5387mergings between pairs of particles or between a particle and the
5388beam. The new momenta are stored in the \ttt{clust\_seq.jets()}
5389vector, after the initial particles. Note though that the plugin is
5390not allowed to modify \ttt{clust\_seq.jets()} itself. Instead it must
5391tell \ttt{clust\_seq} what recombinations have occurred, via the
5392following (\ttt{ClusterSequence} member) functions
5393\begin{lstlisting}
5394  /// record the fact that there has been a recombination between jets()[jet_i]
5395  /// and jets()[jet_j], with the specified dij, and return the index (newjet_k)
5396  /// allocated to the new jet. The recombined PseudoJet is determined by
5397  /// applying the JetDefinition's recombiner to the two input jets.
5398  /// (By default E-scheme recombination, i.e. a 4-vector sum)
5399  void plugin_record_ij_recombination(int jet_i, int jet_j, double dij, int & newjet_k);
5400
5401  /// as for the simpler variant of plugin_record_ij_recombination, except
5402  /// that the new jet is attributed the momentum and user information of newjet
5403  void plugin_record_ij_recombination(int jet_i, int jet_j, double dij,
5404				      const PseudoJet & newjet, int & newjet_k);
5405
5406  /// record the fact that there has been a recombination between jets()[jet_i]
5407  /// and the "beam", with the specified diB; this jet will then be returned to
5408  /// the user when they request inclusive_jets() from the cluster sequence.
5409  void plugin_record_iB_recombination(int jet_i, double diB);
5410\end{lstlisting}
5411The \ttt{dij} recombination functions return the index
5412\ttt{newjet\_k} of the newly formed pseudojet. The plugin may need to
5413keep track of this index in order to specify subsequent
5414recombinations.
5415
5416Certain (cone) jet algorithms do not perform pairwise clustering ---
5417in these cases the plugin must invent a fictitious series of pairwise
5418recombinations that leads to the same final jets. Such jet algorithms
5419may also produce extra information that cannot be encoded in this way
5420(for example a list of stable cones), but to which one may still want
5421access. For this purpose, during \verb|run_clustering(...)|, the
5422plugin may call the \verb|ClusterSequence| member function:
5423\begin{lstlisting}
5424  inline void plugin_associate_extras(std::auto_ptr<ClusterSequence::Extras> extras);
5425\end{lstlisting}
5426where \verb|ClusterSequence::Extras| is an abstract base class, which
5427the plugin should derive from so as to provide the relevant information:
5428\begin{lstlisting}
5429  class ClusterSequence::Extras {
5430  public:
5431    virtual ~Extras() {}
5432    virtual std::string description() const;
5433  };
5434\end{lstlisting}
5435A method of \verb|ClusterSequence| then provides the user with access
5436to the extra information:
5437\begin{lstlisting}
5438  /// returns a pointer to the extras object (may be null) const
5439  ClusterSequence::Extras * extras() const;
5440\end{lstlisting}
5441The user should carry out a dynamic cast so as to convert the extras
5442back to the specific plugin extras class, as illustrated for
5443SISCone in section~\ref{sec:siscone-plugin}.
5444
5445Note that when calculating areas, the \ttt{extras()} member works
5446only for active areas with explicit ghosts and for Voronoi areas.
5447%
5448The reason for this is that other types of area first carry out a
5449clustering with explicit ghosts and then edit the
5450\ttt{ClusterSequence} to remove the information related to pure ghost
5451jets.
5452%
5453This modifies the internal indices of the jets, making it very
5454challenging, for example, for the \ttt{Extras} class to handle queries
5455about individual jets.
5456
5457%----------------------------------------------------------------------
5458\subsubsection{Building new sequential recombination algorithms}
5459\label{sec:new-seq-rec}
5460
5461To enable users to more easily build plugins for new sequential
5462recombination algorithms, \fastjet also provides several classes that
5463give access to implementations of dynamic nearest neighbour finding:
5464\begin{itemize}
5465\item A class \verb|NNH|, which provides users with access to an
5466  implementation of the nearest-neighbour heuristic for establishing
5467  and maintaining information about the closest pair of objects in a
5468  dynamic set of objects with generic distance measures (see
5469  \cite{EppsteinHierarchical} for an introduction to this and other
5470  generic algorithms). In good cases (e.g.\ C/A-like distances) this
5471  allows one to construct clustering that runs in $N^2$ time, though
5472  its worst case can be as bad as $N^3$ (e.g.\ anti-$k_t$).
5473%
5474\item A class \verb|NNFJN2Plain|, for distances that can be written in
5475  the form $d_{ij}= \min(x_i, x_j) D_{ij}$, $d_{iB} = x_i D_{iB}$,
5476  making use of the FastJet lemma and maintaining a nearest neighbour
5477  table for the $D_{ij}$ part of the distance measure.
5478  %
5479  Closely related code forms the basis of the internal \verb|N2Plain|
5480  strategy for the generalised-$k_t$ algorithms, where
5481  $x_i \equiv p_{ti}^{2p}$ and $D_{ij} \equiv \Delta R_{ij}^2/R^2$,
5482  $D_{iB} = 1$.
5483  %
5484  If $D_{ij}$ is geometrical, then the nearest-neighbour maintenance
5485  for the $D_{ij}$ can be done in $N^2$ time, ensuring an overall
5486  $N^2$ algorithm.
5487%
5488\item A class \verb|NNFJN2Tiled|. This is intended for problems with a
5489  cylindrical geometry.
5490  %
5491  The user specifies the tile size and then the algorithm facilitates
5492  clustering with distance measures of the form
5493  $d_{ij}= \min(x_i, x_j) D_{ij}$ (like \verb|NNFJN2Plain|), with
5494  the additional assumption that for a pair of particles $i$ and $j$
5495  on non-identical, non-neighbouring tiles, $D_{iB}, D_{jB} <D_{ij}$, so
5496  that $i$ and $j$ will never cluster with each other.
5497  %
5498  The code is closely related to that used for the internal
5499  \verb|N2Tiled| strategy for generalised-$k_t$ algorithms.
5500  %
5501  The asymptotic scaling is also $N^2$, but at high multiplicities the
5502  coefficient is usually significantly smaller than for
5503  \verb|NNFJN2Tiled|.
5504\end{itemize}
5505All three classes derive from \texttt{NNBase}.\footnote{The \ttt{NNBase},
5506  \ttt{NNFJN2Plain} and \ttt{NNFJN2Tiled} classes were introduced in
5507  version 3.2 of \fastjet.}
5508%
5509They are templated with an underlying (``BriefJet'') class, which
5510stores the minimal information for each particles so as to be able to
5511calculate interparticle and particle--beam distances.
5512%
5513The $\ee$ Cambridge plugin relies on the \verb|NNH| class, the
5514\ttt{JadePlugin} can use both \ttt{NNH} and \ttt{NNFJN2Plain}, while all
5515three \verb|NN***| classes are used in the VariableR contrib's plugin.
5516%
5517The interested user should consult those plugins for examples, and the
5518headers of the \verb|NN***| classes for more detailed information.
5519
5520
5521% To enable users to more easily build plugins for new sequential
5522% recombination algorithms, \fastjet also provides a class \verb|NNH|,
5523% which provides users with access to an implementation of the
5524% nearest-neighbour heuristic for establishing and maintaining
5525% information about the closest pair of objects in a dynamic set of
5526% objects (see \cite{EppsteinHierarchical} for an introduction to this
5527% and other generic algorithms).
5528% %
5529% In good cases (C/A-like) this allows one to construct clustering that runs in
5530% $N^2$ time, though its worst case can be as bad as $N^3$ (e.g.\ anti-$k_t$).
5531% %
5532% It is a templated class and the template argument should be a class
5533% that stores the minimal information for each jet so as to be able to
5534% calculate interjet distances.
5535% %
5536% It underlies the implementations of the Jade and $\ee$ Cambridge
5537% plugins.
5538% %
5539% The interested user should consult those codes for more information,
5540% as well as the header for the \verb|NNH| class.
5541
5542
5543
5544
5545%......................................................................
5546\subsection{Implementing new selectors}
5547\label{sec:new-selectors}
5548
5549Technically a \ttt{Selector} contains a shared pointer to a
5550\ttt{SelectorWorker}.
5551%
5552Classes derived from \ttt{SelectorWorker} actually do the work.
5553%
5554So, for example, the call to the function \ttt{SelectorAbsRapMax(2.5)}
5555first causes a new instance of the internal \ttt{SW\_AbsRapMax} class
5556to be constructed with the information that the limit on $|y|$
5557is 2.5 (\ttt{SW\_AbsRapMax} derives from \ttt{SelectorWorker}).
5558%
5559Then a \ttt{Selector} is constructed with a pointer to the
5560\ttt{SW\_AbsRapMax} object, and it is this \ttt{Selector} that is
5561returned to the user:
5562%
5563\begin{lstlisting}
5564  Selector SelectorAbsRapMax(double absrapmax) {
5565    return Selector(new SW_AbsRapMax(absrapmax));
5566  }
5567\end{lstlisting}
5568%
5569Since \ttt{Selector} is really nothing more than a shared pointer to
5570the \ttt{SW\_AbsRapMax} object, it is a lightweight object.
5571%
5572The fact that it's a shared pointer also means that it looks after
5573the memory management issues associated with the \ttt{SW\_AbsRapMax}
5574object.
5575
5576If a user wishes to implement a new selector, they should write a
5577class derived from \ttt{SelectorWorker}.
5578%
5579The base is defined with sensible defaults, so for simple usage, only
5580two \ttt{SelectorWorker} functions need to be overloaded:
5581\begin{lstlisting}
5582  /// returns true if a given object passes the selection criterion.
5583  pass(const PseudoJet & jet) const = 0;
5584
5585  /// returns a description of the worker
5586  virtual std::string description() const {return "missing description";}
5587\end{lstlisting}
5588For information on how to implement more advanced workers (for example
5589workers that do not apply jet-by-jet, or that take a reference), users
5590may wish to examine the extensive in-code documentation of
5591\ttt{SelectorWorker}, the implementation of the existing workers
5592and/or consult the authors.
5593%
5594A point to be aware of in the case of constructors that take a
5595reference is the need to implement the \ttt{SelectorWorker::copy()}
5596function.
5597
5598%......................................................................
5599\subsection{User-defined transformers}
5600\label{sec:transformerdetails}
5601
5602
5603
5604All transformers are derived from  the \ttt{Transformer} base class,
5605declared in the \ttt{fastjet/tools/Transformer.hh} header:
5606\begin{lstlisting}
5607  class Transformer : public FunctionOfPseudoJet<PseudoJet> {
5608  public:
5609    // the result of the Transformer acting on the PseudoJet.
5610    // this has to be overloaded in derived classes
5611    virtual PseudoJet result(const PseudoJet & original) const = 0;
5612
5613    // should be overloaded to return a description of the Transformer
5614    virtual std::string description() const = 0;
5615
5616    // information about the associated structure type
5617    typedef PseudoJetStructureBase StructureType;
5618
5619    // destructor is virtual so that it can be safely overloaded
5620    virtual ~Transformer(){}
5621  };
5622\end{lstlisting}
5623Relative to the \ttt{FunctionOfPseudoJet<PseudoJet>} (cf.\
5624appendix~\ref{app:function-of-pj}) from which it derives, the
5625\ttt{Transformer}'s main additional feature is that the jets resulting
5626from the transformation are generally expected to have standard
5627structural information, e.g.\ constituents, and will often have
5628supplemental structural information, which the \ttt{StructureType}
5629\ttt{typedef} helps access.
5630%
5631As for a \ttt{FunctionOfPseudoJet<PseudoJet>}, the action of a
5632\ttt{Transformer} is to be implemented in the \ttt{result(...)} member
5633function,
5634%
5635though typically it will be used through the \ttt{operator()}
5636function, as discussed in appendix~\ref{app:function-of-pj}.
5637
5638To help understand how to create user-defined transformers, it is
5639perhaps easiest to consider the example of a filtering/trimming class.
5640%
5641The simplest form of such a class is the following:%
5642\footnote{The actual \texttt{Filter} class is somewhat more elaborate
5643  than this, since it also handles areas, pileup subtraction and avoids
5644  reclustering when the jet and subjet definitions are C/A based.}
5645%
5646\begin{lstlisting}
5647  /// a simple class to carry out filtering and/or trimming
5648  class SimpleFilter: public Transformer {
5649  public:
5650    SimpleFilter(const JetDefinition & subjet_def, const Selector & selector) :
5651                                 _subjet_def(subjet_def), _selector(selector) {}
5652
5653    virtual std::string description() const {
5654      return "Filter that finds subjets with " + _subjet_def.description()
5655             + ", using a (" + _selector.description() + ") selector" ;}
5656
5657    virtual PseudoJet result(const PseudoJet & jet) const;
5658
5659    // CompositeJetStructure is the structural type associated with the
5660    // join operation that we use shall use to create the returned jet below
5661    typedef CompositeJetStructure StructureType;
5662
5663  private:
5664    JetDefinition _subjet_def;
5665    Selector      _selector;
5666  };
5667\end{lstlisting}
5668The function that does the work in this class is \ttt{result(...)}:
5669%
5670\begin{lstlisting}
5671  PseudoJet SimpleFilter::result(const PseudoJet & jet) const {
5672    // get the subjets
5673    ClusterSequence * cs = new ClusterSequence(jet.constituents(), _subjet_def);
5674    vector<PseudoJet> subjets = cs->inclusive_jets();
5675
5676    // signal that the cluster sequence should delete itself when
5677    // there are no longer any of its (sub)jets in scope anywhere
5678    cs->delete_self_when_unused();
5679
5680    // get the selected subjets
5681    vector<PseudoJet> selected_subjets = _selector(subjets);
5682    // join them using the same recombiner as was used in the subjet_def
5683    PseudoJet joined = join(selected_subjets, *_subjet_def.recombiner());
5684    return joined;
5685  }
5686\end{lstlisting}
5687This provides almost all the basic functionality that might be needed
5688from a filter, including access to the \ttt{pieces()} of the filtered
5689jet since it is formed with the \ttt{join(...)} function.
5690%
5691The one part that is potentially missing is that the user does not
5692have any way of accessing information about the subjets that were not
5693kept by the filter.
5694%
5695This requires adding to the structural information that underlies the
5696returned jet.
5697%
5698The \ttt{join(...)}  function creates a structure of type
5699\ttt{CompositeJetStructure}. There is also a templated version,
5700\ttt{join<ClassDerivedFromCompositeJetStructure>(...)}, which allows
5701the user to choose the structure created by the \ttt{join} function.
5702%
5703In this case we therefore create
5704\begin{lstlisting}
5705  #include "fastjet/CompositeJetStructure.hh"
5706  class SimpleFilterStructure: public CompositeJetStructure {
5707  public:
5708    // the form of constructor expected by the join<...> function
5709    SimpleFilterStructure(const vector<PseudoJet> & pieces,
5710                          const Recombiner *recombiner = 0) :
5711                                     CompositeJetStructure(pieces, recombiner) {}
5712    // provide access to the rejected subjets from the filtering
5713    const vector<PseudoJet> & rejected() const {return _rejected;}
5714  private:
5715    vector<PseudoJet> _rejected;
5716    friend class SimpleFilter;
5717  };
5718\end{lstlisting}
5719and then replace the last few lines of the
5720\ttt{SimpleFilter::result(...)} function with
5721\begin{lstlisting}
5722  // get the selected and rejected subjets
5723  vector<PseudoJet> selected_subjets, rejected_subjets;
5724  _selector.sift(subjets, selected_subjets, rejected_subjets);
5725
5726  // join the selected ones, now with a user-chosen structure
5727  PseudoJet joined = join<SimpleFilterStructure>(selected_subjets, *_subjet_def.recombiner());
5728
5729  // and then set the structure's additional elements
5730  SimpleFilterStructure * structure =
5731        	    static_cast<SimpleFilterStructure *>(joined.structure_non_const_ptr());
5732  structure->_rejected = rejected_subjets;
5733  return joined;
5734\end{lstlisting}
5735Finally, with the replacement of the \ttt{typedef} in the
5736\ttt{SimpleFilter} class with
5737\begin{lstlisting}
5738  typedef SimpleFilterStructure StructureType;
5739\end{lstlisting}
5740then on a jet returned by the \ttt{SimpleFilter} one can simply call
5741\begin{lstlisting}
5742  filtered_jet.structure_of<SimpleFilter>().rejected();
5743\end{lstlisting}
5744as with the fully fledged \ttt{Filter} of section~\ref{sec:filtering}.
5745
5746A second way of extending the structural information of an existing
5747jet is to ``wrap'' it. This can be done with the help of the
5748\ttt{WrappedStructure} class.
5749%
5750\begin{lstlisting}
5751  #include "fastjet/WrappedStructure.hh"
5752  /// a class to wrap and extend existing jet structures with information about
5753  /// "rejected" pieces
5754  class SimpleFilterWrappedStructure: public WrappedStructure {
5755  public:
5756    SimpleFilterWrappedStructure(const SharedPtr<PseudoJetStructureBase> & to_be_wrapped,
5757				 const vector<PseudoJet> & rejected_pieces) :
5758	       WrappedStructure(to_be_wrapped), _rejected(rejected_pieces) {}
5759
5760    const vector<PseudoJet> & rejected() const {return _rejected;}
5761  private:
5762    vector<PseudoJet> _rejected;
5763  };
5764\end{lstlisting}
5765The \ttt{WrappedStructure}'s constructor takes a \ttt{SharedPtr} to an
5766existing structure and simply redirects all standard structural
5767queries to that existing structure. A class derived from it can then
5768reimplement some of the standard queries, or implement non-standard
5769ones, as done above with the \ttt{rejected()} call.
5770%
5771To use the wrapped class one might proceed as in the following lines:
5772\begin{lstlisting}
5773  // create a jet with some existing structure
5774  PseudoJet joined = join(selected_subjets, *_subjet_def.recombiner());
5775  // create a new structure that wraps the existing one and supplements it with new info
5776  SharedPtr<PseudoJetStructureBase> structure(new
5777     SimpleFilterWrappedStructure(joined.structure_shared_ptr(), rejected_subjets));
5778  // assign the new structure to the original jet
5779  joined.set_structure_shared_ptr(structure);
5780\end{lstlisting}
5781The \ttt{SharedPtr}s ensure that memory allocated for the structural
5782information is released when no jet remains that refers to it.
5783%
5784For the above piece of code to be used in the \ttt{SimpleFilter} it
5785would then suffice to include a
5786\begin{lstlisting}
5787  typedef SimpleFilterWrappedStructure StructureType;
5788\end{lstlisting}
5789line in the \ttt{SimpleFilter} class definition.
5790
5791In choosing between the templated \ttt{join<...>} and
5792\ttt{WrappedStructure} approaches to providing advanced structural
5793information, two elements are worth considering: on one hand, the
5794\ttt{WrappedStructure} can be used to extend arbitrary structural
5795information; on the other, while \ttt{join<...>} is more limited in
5796its scope, it involves fewer pointer indirections when accessing
5797structural information and so may be marginally more efficient.
5798
5799
5800
5801%======================================================================
5802
5803\section{Error handling}
5804\label{sec:error-handling}
5805
5806\fastjet provides warning and error messages through the classes
5807\ttt{fastjet::LimitedWarning} and \ttt{fastjet::Error} respectively.
5808%
5809A user does not normally need to interact with them,
5810%
5811however, they do provide some customisation facilities, especially to
5812redirect and summarise their output.
5813
5814Each different kind of warning is written out a maximum number of
5815times (the current default is 5) before its output is suppressed. The
5816program is allowed to continue.
5817%
5818At the end of the run (or at any other stage) it is possible to obtain
5819a summary of all warnings encountered, both explicit or suppressed,
5820through the following static member function of the LimitedWarning
5821class:
5822\begin{lstlisting}
5823  #include "fastjet/LimitedWarning.hh"
5824  // ...
5825  cout << LimitedWarning::summary() << endl;
5826\end{lstlisting}
5827The throwing of an \ttt{Error} aborts the program. One can use
5828\begin{lstlisting}
5829  /// controls whether the error message (and the backtrace, if its printing is enabled)
5830  /// is printed out or not
5831  static void Error::set_print_errors(bool print_errors);
5832
5833  /// controls whether the backtrace is printed out with the error message or not.
5834  /// The default is "false".
5835  static void Error::set_print_backtrace(bool enabled);
5836\end{lstlisting}
5837to control whether an error message is printed (default = \ttt{true})
5838and whether a full backtrace is also given (default = \ttt{false}).
5839%
5840Switching off the printing of error messages can be useful, for
5841example, if the user expects to repeatedly catch \fastjet errors.
5842%
5843The \ttt{message()} member function can then be used to access the
5844specific error message.
5845
5846The output of both \ttt{LimitedWarning} and \ttt{Error}, which by default
5847goes to \ttt{std::cerr}, can be redirected to a file using their
5848\ttt{set\_default\_stream(std::ostream * ostr)} functions. For instance,
5849\begin{lstlisting}
5850  #include "fastjet/LimitedWarning.hh"
5851  #include "fastjet/Error.hh"
5852  #include <iostream>
5853  #include <fstream>
5854  // ...
5855  ostream * myerr = new ofstream("warnings-and-errors.txt");
5856  LimitedWarning::set_default_stream(myerr);
5857  Error::set_default_stream(myerr);
5858  Error::set_print_backtrace(true);
5859  // ...
5860  cout << LimitedWarning::summary() << endl;
5861
5862\end{lstlisting}
5863will send the output of both classes to the file
5864\ttt{warnings-and-errors.txt} (as well as provide the backtrace of
5865errors).
5866%
5867Note that the output of \ttt{LimitedWarning::summary()} will only be
5868present if the program did not abort earlier due to an error.
5869
5870With a suitable design of the output stream, the output redirection
5871facility can also be used by the user to record additional information
5872when an error or warning occurs, for example the event number.
5873%
5874One only \ttt{stream << string} type operation is performed for each
5875warning or error, so as to help with formatting in such cases.
5876
5877As well as performing output of warnings and errors, \fastjet also
5878outputs a banner the first time that clustering is performed.
5879%
5880If the user wishes to have the banner appear before the first
5881clustering (e.g.\ during the initialisation phase of their program),
5882they may call the static \ttt{ClusterSequence::print\_banner()}
5883function.
5884
5885%======================================================================
5886
5887\section{Evolution of FastJet across versions}
5888\label{sec:fastjet-history}
5889
5890\subsection{History}
5891Version 1 of \fastjet provided the first fast implementation of the
5892longitudinally invariant $k_t$ clustering~\cite{ktexcl,ktincl}, based
5893on the factorisation of momentum and geometry in that algorithm's
5894distance measure~\cite{fastjet}.
5895
5896
5897Version 2.0 brought
5898%
5899the implementation of the inclusive Cambridge/Aachen algorithm
5900\cite{CamOrig,CamWobisch} and of jet areas and background
5901estimation~\cite{cs,CSSAreas}; other changes include a new
5902interface,\footnote{The old one was retained through v2} and new
5903algorithmic strategies that could provide a factor of two improvement
5904in speed for events whose number $N$ of particles was $\sim 10^4$.
5905%
5906Choices of recombination schemes and plugins for external jet
5907algorithms were new features of version 2.1.
5908%
5909The initial set of plugins included SISCone~\cite{SISCone}, the CDF
5910midpoint~\cite{RunII-jet-physics} and JetClu~\cite{Abe:1991ui} cones
5911and PxCone~\cite{PxCone,Seymour:2006vv}.
5912%
5913The plugins helped provide a uniform interface to a range of different
5914jet algorithms and made it possible to overlay \fastjet features such as areas
5915onto the external jet algorithms.
5916%
5917Version 2.2 never made it beyond the beta-release stage, but
5918introduced a number of the features that eventually were released in 2.3.
5919%
5920The final 2.3 release included the anti-$k_t$ algorithm~\cite{antikt},
5921a broader set of area measures, improved access to background
5922estimation, means to navigate the ClusterSequence and a new build system
5923(GNU autotools).
5924%
5925%
5926Version 2.4 included the new version 2.0 of SISCone (including the
5927spherical variant), as well as
5928plugins to the \Dzero Run II cone, the ATLAS cone, the CMS cone,
5929TrackJet and a range of $e^+e^-$ algorithms, and also further tools to
5930help investigate jet substructure.
5931%
5932It also added a wrapper to \fastjet
5933allowing one to run SISCone and some of the sequential recombination
5934algorithms from Fortran programs.
5935
5936A major practical change in version 3.0 was that \ttt{PseudoJet}
5937acquired knowledge
5938(where relevant) about its underlying ClusterSequence, allowing one to
5939write {\em e.g.}  \ttt{jet.constituents()}
5940%
5941It also became possible to associate extra information with a
5942\ttt{PseudoJet} beyond just a user index.
5943%
5944It brought the first of a series of \fastjet tools to help with
5945advanced jet analyses, namely the \ttt{Selector} class, filters,
5946  pruners, taggers and new background estimation classes.
5947%
5948Version~3.0 also added the D0-Run I cone~\cite{Abbott:1997fc} plugin and
5949support for native jet algorithms to be run with $R>\pi/2$.
5950%
5951Version~3.1 gave significant speed improvements for multiplicities
5952from a few thousand up to a few hundred thousand and various other
5953small additions.
5954%
5955The period in between versions 3.0.0 and 3.1.0 also saw the first
5956releases of the \fjcore compact subset of \fastjet
5957(section~\ref{sec:fjcore}) and of the \fjcontrib project
5958(section~\ref{sec:fjcontrib}).
5959%
5960Version~3.2 exposed more of \fastjet's core clustering functionality
5961to third-party code (\ttt{NNFJN2Plain} and \ttt{NNFJN2Tiled} classes).
5962%
5963Version~3.3 brought a Python interface to \fastjet.
5964
5965%......................................................................
5966\subsection{Deprecated and removed features}
5967\label{sec:deprecated}
5968
5969While we generally aim to maintain backwards compatibility for
5970software written with old versions of \fastjet, there are occasions
5971where old interfaces or functionality no longer meet the standards that
5972are demanded of a program that is increasingly widely used.
5973%
5974Table~\ref{tab:deprecated} lists the cases where such considerations
5975have led us to deprecate and/or remove functionality.
5976%
5977Note that the series of ``CSAB'' methods marked as deprecated in
5978\fastjet~v3.2 are direct consequences of
5979CSAB::median\_pt\_per\_unit\_area() already being marked as deprecated in
5980v3.0.
5981
5982As of \fastjet~v3.2, whenever supported by the compiler, a
5983``deprecation'' message will be issued at compilation
5984time.\footnote{This is not available for all deprecated methods due
5985  to a bug with gcc 5.1 amd 5.2.}
5986
5987
5988\begin{table}
5989  \centering
5990  \begin{tabular}{lccl}\toprule
5991    Feature, class or include file
5992                    & Dep. & Rem.  & Suggested replacement\\\midrule
5993    FjClusterSequence.hh
5994                    & 2.0   & 3.0  & fastjet/ClusterSequence.hh\\
5995    FjPseudoJet.hh  & 2.0   & 3.0  & fastjet/PseudoJet.hh\\\midrule
5996    %----------------------------------------------------------------------
5997    CS::set\_jet\_finder(...)    & 2.1 & 3.0 & pass a JetDefinition to constructor\\
5998    CS::set\_jet\_algorithm(...) & 2.1 & 3.0 & pass a JetDefinition to constructor\\
5999    CS::CS(particles, R, ...)    & 2.1 & 3.0 & CS::CS(particles, jet\_def)\\
6000    JD(jet\_alg, R, strategy)    & 2.1 & --  & JD(jet\_alg, R, recomb\_scheme, strategy)\\
6001    \midrule
6002    %----------------------------------------------------------------------
6003    JetFinder       & 2.3    & --  & JetAlgorithm \\
6004    SISConePlugin.hh
6005                    & 2.3    & 3.0  & fastjet/SISConePlugin.hh (idem.\ other plugins)\\
6006    ActiveAreaSpec  & 2.3   &  --  & AreaDefinition \& GhostedAreaSpec\\
6007    ClusterSequenceWithArea
6008                    & 2.3   &  --  & ClusterSequenceArea\\\midrule
6009    %----------------------------------------------------------------------
6010    default $f=0.5$ in some cone plugins
6011                    & --    &  2.4 & include $f$ explicitly in constructor\\
6012    default $R=1$ in JetDefinition
6013                    & --    &  2.4 & include $R$ explicitly in constructor\\
6014    \midrule %------------------------------------------------------------
6015    RangeDefinition & 3.0   &  --  & Selector(s)        \\
6016    CircularRange   & 3.0   &  --  & SelectorCircle     \\
6017    CSAB::median\_pt\_per\_unit\_area(...)
6018                   & 3.0    & --   & BackgroundEstimator\\
6019    CSAB::parabolic\_pt\_per\_unit\_area(...)
6020                   & 3.0    & --   & BackgroundEstimator (cf.\ section \ref{sec:BGE-positional})\\
6021    GAS::set\_fj2\_placement(...)
6022                   & 3.0    & --   & use new default ghost placement instead\\
6023    \midrule %------------------------------------------------------------
6024    CS::plugin\_associate\_extras(auto\_ptr)
6025                   & 3.1    &  --  &
6026                   CS::plugin\_associate\_extras(Extras *)\\
6027    \midrule %------------------------------------------------------------
6028    SharedPtr::operator()
6029                   & 3.2    &  --  & SharedPtr::get()\\
6030    CSAB::median\_rho\_*()
6031                   & 3.2    &  --  & BackgroundEstimator\\
6032    CSAB::get\_median\_rho\_and\_sigma()
6033                   & 3.2    &  --  & BackgroundEstimator\\
6034    CSAB::subtracted\_jet()
6035                   & 3.2    &  --  & Subtractor\\
6036    CSAB::subtracted\_jets()
6037                   & 3.2    &  --  & Subtractor\\
6038    CSAB::subtracted\_pt()
6039                   & 3.2    &  --  & Subtractor\\
6040    \bottomrule %=========================================================
6041  \end{tabular}
6042  \caption{Summary of interfaces and features of earlier versions that have been
6043    deprecated and/or removed. For brevity we have used the following
6044    abbreviations: Dep. = version since which a feature has been
6045    deprecated, Rem. = version where removed, CS
6046    = ClusterSequence, JD = JetDefinition, CSAB = ClusterSequenceAreaBase, GAS =
6047    GhostedAreaSpec.
6048    \label{tab:deprecated}
6049  }
6050\end{table}
6051
6052As of version 3.1.0, the \ttt{FASTJET\_VERSION\_NUMBER} symbol can be
6053used to provide version-dependent code compilation, as discussed in
6054section~\ref{sec:version-information}.
6055
6056%......................................................................
6057\subsection{Backwards compatibility of background estimation facilities}
6058\label{sec:BGE-backwards}
6059
6060The \ttt{JetMedianBackgroundEstimator} and
6061\ttt{GridMedianBackgroundEstimator} classes are new to \fastjet 3.
6062%
6063In \fastjet versions 2.3 and 2.4, the background estimation tools were
6064instead integrated into the \ttt{ClusterSequenceAreaBase} class.
6065%
6066Rather than using selectors to specify the jets used in the background
6067estimation, they used the \ttt{RangeDefinition} class.
6068%
6069For the purpose of backwards compatibility, these facilities will
6070remain present in all 3.0.x versions.
6071%
6072Note that \ttt{ClusterSequenceAreaBase} now actually uses a selector
6073in its background estimation interface, and that a
6074\ttt{RangeDefinition} is automatically converted to a selector.
6075
6076An explicit argument in $\rho$-determination calls in \fastjet 2.4
6077concerned the choice between the use of scalar areas and the
6078transverse component of the 4-vector area in the denominator of
6079$p_t/A$.
6080%
6081The transverse component gives the more accurate $\rho$ determination
6082and that is now the default in \ttt{JetMedianBackgroundEstimator}.
6083%
6084The behaviour can be changed with a member function call of the form
6085\begin{lstlisting}
6086  set_use_area_4vector(false);
6087\end{lstlisting}
6088%
6089Finally, the calculation of $\sigma$ in \fastjet 2.x incorrectly
6090handled the limit of a small number of jets. This is now fixed in \fastjet 3, but
6091a call to
6092\ttt{set\_provide\_fj2\_sigma(true)} causes \ttt{JetMedianBackgroundEstimator}
6093to reproduce that behaviour.
6094
6095\fastjet 2.x also placed the ghosts differently, resulting in different
6096event-by-event rho estimates, and possibly a small systematic offset
6097(scaling as the square-root of the ghost area) when ghosts and
6098particles both covered identical (small) regions.
6099%
6100This offset is no longer present with the \fastjet 3 ghost placement.
6101%
6102If the old behaviour is needed, a call to a specific
6103\ttt{GhostedAreaSpec}'s \ttt{set\_fj2\_placement(true)} function
6104causes ghosts to placed as in the 2.x series.
6105
6106
6107
6108%======================================================================
6109\newpage
6110
6111\begin{thebibliography}{99}
6112
6113\bibitem{StermanWeinberg}
6114  G.~Sterman and S.~Weinberg,
6115  ``Jets From Quantum Chromodynamics,''
6116  Phys.\ Rev.\ Lett.\  {\bf 39} (1977) 1436.
6117  %%CITATION = PRLTA,39,1436;%%
6118
6119\bibitem{Moretti:1998qx}
6120  S.~Moretti, L.~Lonnblad and T.~Sjostrand,
6121   ``New and old jet clustering algorithms for electron positron events,''
6122  JHEP {\bf 9808} (1998) 001
6123  [arXiv:hep-ph/9804296].
6124  %% CITATION = JHEPA,9808,001;%%
6125
6126%\cite{Blazey:2000qt}
6127\bibitem{RunII-jet-physics}
6128  G.~C.~Blazey {\it et al.},
6129  % ``Run II jet physics,''
6130  hep-ex/0005012.
6131  %% CITATION = HEP-EX 0005012;%%
6132
6133\bibitem{Ellis:2007ib}
6134  S.~D.~Ellis, J.~Huston, K.~Hatakeyama, P.~Loch and M.~Tonnesmann,
6135  ``Jets in Hadron-Hadron Collisions,''
6136  Prog.\ Part.\ Nucl.\ Phys.\  {\bf 60} (2008) 484
6137  [arXiv:0712.2447 [hep-ph]].
6138  %%CITATION = PPNPD,60,484;%%
6139
6140\bibitem{Salam:2009jx}
6141  G.~P.~Salam,
6142  %``Towards Jetography,''
6143  Eur.\ Phys.\ J.\  {\bf C67 } (2010)  637-686
6144  [arXiv:0906.1833 [hep-ph]].
6145
6146
6147\bibitem{Ali:2010tw}
6148  A.~Ali, G.~Kramer,
6149  %``Jets and QCD: A Historical Review of the Discovery of the Quark and Gluon Jets and its Impact on QCD,''
6150  Eur.\ Phys.\ J.\  {\bf H36 } (2011)  245-326.
6151  [arXiv:1012.2288 [hep-ph]].
6152
6153\bibitem{GPLv2}
6154  \url{http://www.gnu.org/licenses/gpl-2.0.html}
6155
6156\bibitem{ktexcl}
6157  S.~Catani, Y.~L.~Dokshitzer, M.~H.~Seymour and B.~R.~Webber,
6158  %``Longitudinally invariant K(t) clustering algorithms for hadron hadron
6159  %collisions,''
6160  Nucl.\ Phys.\ B {\bf 406}  (1993)  187.
6161
6162\bibitem{ktincl}
6163  S.~D.~Ellis and D.~E.~Soper,
6164  %``Successive Combination Jet Algorithm For Hadron Collisions,''
6165  Phys.\ Rev.\ D {\bf 48} (1993) 3160
6166  %\prd{48}{1993}{3160}
6167  [hep-ph/9305266].
6168  %%CITATION = HEP-PH 9305266;%%
6169
6170\bibitem{fastjet}
6171  M.~Cacciari and G.~P.~Salam,
6172  %``Dispelling the N**3 myth for the k(t) jet-finder,''
6173  Phys.\ Lett.\ B {\bf 641} (2006) 57
6174  [hep-ph/0512210].
6175  %%CITATION = HEP-PH 0512210;%%
6176
6177\bibitem{KtClus}
6178  M. Seymour,
6179  \url{http://hepwww.rl.ac.uk/theory/seymour/ktclus/}.
6180
6181
6182\bibitem{KtJet}
6183  \url{http://hepforge.cedar.ac.uk/ktjet/};
6184  J.~M.~Butterworth, J.~P.~Couchman, B.~E.~Cox and B.~M.~Waugh,
6185  %``KtJet: A C++ implementation of the K(T) clustering algorithm,''
6186  Comput.\ Phys.\ Commun.\  {\bf 153}, 85 (2003)
6187  [hep-ph/0210022].
6188  %%CITATION = HEP-PH 0210022;%%
6189
6190\bibitem{CGAL}
6191%Andreas Fabri, Geert-Jan Giezeman, Lutz Kettner, Stefan Schirra and Sven Schonherr,
6192A.~Fabri {\it et al.},
6193%On the design of CGAL a computational geometry algorithms library
6194Softw.~Pract.~Exper.~ {\bf 30} (2000) 1167;
6195%Jean-Daniel Boissonnat, Olivier Devillers, Sylvain Pion, Monique Teillaud and Mariette Yvinec
6196J.-D.~Boissonnat {\it et al.},
6197% Triangulations in CGAL
6198Comp.~Geom.~{\bf 22} (2001) 5; \url{http://www.cgal.org/}
6199
6200\bibitem{antikt}
6201  M.~Cacciari, G.~P.~Salam and G.~Soyez,
6202  %``The anti-k_t jet clustering algorithm,''
6203  JHEP {\bf 0804} (2008) 063
6204  [arXiv:0802.1189 [hep-ph]].
6205  %%CITATION = ARXIV:0802.1189;%%
6206
6207\bibitem{Abdesselam:2010pt}
6208  A.~Abdesselam, E.~B.~Kuutmann, U.~Bitenc, G.~Brooijmans, J.~Butterworth, P.~Bruckman de Renstrom, D.~Buarque Franzosi, R.~Buckingham {\it et al.},
6209  %``Boosted objects: A Probe of beyond the Standard Model physics,''
6210  Eur.\ Phys.\ J.\  {\bf C71 } (2011)  1661.
6211  [arXiv:1012.5412 [hep-ph]].
6212
6213\bibitem{SpartyJet} P.A.~Delsart, K.~Geerlings, J.~Huston,
6214  B.~Martin and C.~Vermilion, SpartyJet,
6215  \url{http://projects.hepforge.org/spartyjet}
6216
6217\bibitem{CSSAreas}
6218  M.~Cacciari, G.~P.~Salam and G.~Soyez,
6219  %``The Catchment Area of Jets,''
6220  JHEP {\bf 0804} (2008) 005,
6221  [arXiv:0802.1188 [hep-ph]].
6222  %%CITATION = ARXIV:0802.1188;%%
6223
6224\bibitem{cs}
6225  M.~Cacciari and G.~P.~Salam,
6226  %``Pileup subtraction using jet areas,''
6227  Phys.\ Lett.\  B {\bf 659} (2008) 119
6228  [arXiv:0707.1378 [hep-ph]].
6229  %%CITATION = PHLTA,B659,119;%%
6230
6231\bibitem{Cacciari:2010te}
6232  M.~Cacciari, J.~Rojo, G.~P.~Salam, G.~Soyez,
6233  %``Jet Reconstruction in Heavy Ion Collisions,''
6234  Eur.\ Phys.\ J.\  {\bf C71 } (2011)  1539.
6235  [arXiv:1010.1759 [hep-ph]].
6236
6237%\cite{Buttar:2008jx}
6238\bibitem{Buttar:2008jx}
6239  C.~Buttar {\it et al.},
6240  %``Standard Model Handles and Candles Working Group: Tools and Jets Summary
6241  %Report,''
6242  arXiv:0803.0678 [hep-ph].
6243  %%CITATION = ARXIV:0803.0678;%%
6244
6245%\cite{Ellis:2009su}
6246\bibitem{Ellis:2009su}
6247  S.~D.~Ellis, C.~K.~Vermilion, J.~R.~Walsh,
6248  %``Techniques for improved heavy particle searches with jet substructure,''
6249  Phys.\ Rev.\  {\bf D80 } (2009)  051501.
6250  [arXiv:0903.5081 [hep-ph]].
6251
6252\bibitem{Bertolini:2013iqa}
6253  D.~Bertolini, T.~Chan and J.~Thaler,
6254  %``Jet Observables Without Jet Algorithms,''
6255  JHEP {\bf 1404} (2014) 013
6256  [arXiv:1310.7584 [hep-ph]];\\
6257  %%CITATION = ARXIV:1310.7584;%%
6258  %7 citations counted in INSPIRE as of 12 Sep 2014
6259  %
6260%\bibitem{Larkoski:2014uqa}
6261  A.~J.~Larkoski, D.~Neill and J.~Thaler,
6262  %``Jet Shapes with the Broadening Axis,''
6263  JHEP {\bf 1404} (2014) 017
6264  [arXiv:1401.2158 [hep-ph]];\\
6265  %%CITATION = ARXIV:1401.2158;%%
6266%
6267  G.~P.~Salam, unpublished.
6268
6269
6270\bibitem{CamOrig}
6271  Y.~L.~Dokshitzer, G.~D.~Leder, S.~Moretti and B.~R.~Webber,
6272  %``Better jet clustering algorithms,''
6273  JHEP {\bf 9708}, 001 (1997)
6274  [hep-ph/9707323];
6275  %%CITATION = HEP-PH 9707323;%%
6276
6277\bibitem{CamWobisch}
6278  M.~Wobisch and T.~Wengler,
6279   ``Hadronization corrections to jet cross sections in deep-inelastic
6280  %scattering,''
6281  arXiv:hep-ph/9907280;
6282  %%CITATION = HEP-PH 9907280;%%
6283  %\cite{Wobisch:2000dk}
6284%\bibitem{Wobisch:2000dk}
6285  M.~Wobisch,
6286   ``Measurement and QCD analysis of jet cross sections in deep-inelastic
6287  %positron proton collisions at s**(1/2) = 300-GeV,''
6288DESY-THESIS-2000-049.
6289%\href{http://www.slac.stanford.edu/spires/find/hep/www?r=desy-thesis-2000-049}{SPIRES entry}
6290
6291\bibitem{eekt}
6292  S.~Catani, Y.~L.~Dokshitzer, M.~Olsson, G.~Turnock and B.~R.~Webber,
6293  %``New clustering algorithm for multi - jet cross-sections in e+ e-
6294  %annihilation,''
6295  Phys.\ Lett.\ B {\bf 269}, 432 (1991);
6296
6297\bibitem{Lonnblad:1992qd}
6298  L.~Lonnblad,
6299  %``ARCLUS: A New jet clustering algorithm inspired by the color dipole model,''
6300  Z.\ Phys.\  {\bf C58 } (1993)  471-478.
6301
6302
6303\bibitem{SISCone}
6304  G.P.~Salam and G.~Soyez,
6305  %``A practical Seedless Infrared-Safe Cone jet algorithm,''
6306  JHEP {\bf 0705} 086 (2007),
6307  [arXiv:0704.0292 [hep-ph]];
6308  %%CITATION = arXiv:0704.0292;%%
6309standalone code available from \url{http://projects.hepforge.org/siscone}.
6310
6311
6312\bibitem{EHT}
6313  S.~D.~Ellis, J.~Huston and M.~Tonnesmann,
6314  %``On building better cone jet algorithms,''
6315in {\it Proc. of the APS/DPF/DPB Summer Study on the Future of
6316  Particle Physics (Snowmass 2001) } ed. N.~Graf, p. P513
6317%in {\it  the Proceedings of APS / DPF / DPB Summer Study on the
6318%Future of Particle Physics (Snowmass 2001), Snowmass, Colorado, 30
6319%Jun - 21 Jul 2001, pp P513}
6320  [hep-ph/0111434].
6321  %%CITATION = HEP-PH 0111434;%%
6322
6323\bibitem{TeV4LHC}
6324  TeV4LHC QCD Working Group {\it et al.},
6325  %``Tevatron-for-LHC report of the QCD working group,''
6326  hep-ph/0610012.
6327  %%CITATION = HEP-PH 0610012;%%
6328
6329\bibitem{Weinzierl:2011jx}
6330  S.~Weinzierl,
6331  %``The SISCone jet algorithm optimised for low particle multiplicities,''
6332  arXiv:1108.1934 [hep-ph].
6333
6334
6335\bibitem{CDFCones} The CDF code has been taken from \\
6336  \url{http://www.pa.msu.edu/~huston/Les_Houches_2005/JetClu+Midpoint-StandAlone.tgz}\,.
6337
6338\bibitem{Abe:1991ui}
6339  F.~Abe {\it et al.}  [CDF Collaboration],
6340  ``The Topology of three jet events in $\bar{p}p$ collisions at $\sqrt{s} =
6341  1.8$ TeV,''
6342  Phys.\ Rev.\ D {\bf 45} (1992) 1448.
6343  %%CITATION = PHRVA,D45,1448;%%
6344
6345\bibitem{Abbott:1997fc}
6346  B.~Abbott {\it et al.} [D0 Collaboration],
6347  %``Fixed cone jet definitions in D0 and R(sep),''
6348  FERMILAB-PUB-97-242-E.
6349
6350\bibitem{arXiv:1110.3771}
6351  V.~M.~Abazov {\it et al.} [D0 Collaboration],
6352  %``Measurement of the inclusive jet cross section in $p \bar {p}$ collisions at $\sqrt{s}=1.96$ TeV,''
6353  %Submitted to: Phys.Rev.D
6354  arXiv:1110.3771 [hep-ex].
6355
6356\bibitem{Seymour:2006vv}
6357  M.~H.~Seymour and C.~Tevlin,
6358  %``A comparison of two different jet algorithms for the top mass
6359  %reconstruction at the LHC,''
6360  JHEP {\bf 0611} (2006) 052
6361  [arXiv:hep-ph/0609100].
6362  %%CITATION = JHEPA,0611,052;%%
6363
6364\bibitem{PxCone} L.~A.~del~Pozo and M.~H.~Seymour, unpublished.
6365
6366\bibitem{Affolder:2001xt}
6367  T.~Affolder {\it et al.} [ CDF Collaboration ],
6368  %``Charged jet evolution and the underlying event in $p\bar{p}$ collisions at 1.8 TeV,''
6369  Phys.\ Rev.\  {\bf D65 } (2002)  092002.
6370
6371\bibitem{Bartel:1986ua}
6372  W.~Bartel {\it et al.}  [JADE Collaboration],
6373  %``Experimental Studies On Multi - Jet Production In E+ E- Annihilation At
6374  %Petra Energies,''
6375  Z.\ Phys.\ C {\bf 33} (1986) 23;
6376  %%CITATION = ZEPYA,C33,23;%%
6377
6378\bibitem{Bethke:1988zc}
6379  S.~Bethke {\it et al.}  [JADE Collaboration],
6380  %``Experimental Investigation Of The Energy Dependence Of The Strong Coupling
6381  %Strength,''
6382  Phys.\ Lett.\ B {\bf 213} (1988) 235.
6383  %%CITATION = PHLTA,B213,235;%%
6384
6385\bibitem{SpheriSISCone} G.~P.~Salam and G.~Soyez, April 2009,
6386  unpublished.
6387
6388\bibitem{Fortune}
6389  S.~Fortune,
6390  %''A sweepline algorithm for Voronoi diagrams,''
6391  Algorithmica {\bf 2} (1987) 1.
6392
6393\bibitem{Dasgupta:2007wa}
6394  M.~Dasgupta, L.~Magnea and G.~P.~Salam,
6395  %``Non-perturbative QCD effects in jets at hadron colliders,''
6396  JHEP {\bf 0802} (2008) 055
6397  [arXiv:0712.3014 [hep-ph]].
6398  %%CITATION = ARXIV:0712.3014;%%
6399  %90 citations counted in INSPIRE as of 04 Aug 2014
6400
6401\bibitem{Cacciari:2009dp}
6402  M.~Cacciari, G.~P.~Salam, S.~Sapeta,
6403  %``On the characterisation of the underlying event,''
6404  JHEP {\bf 1004 } (2010)  065.
6405  [arXiv:0912.4926 [hep-ph]].
6406
6407\bibitem{GridMedianLH} M.~Cacciari, G.~P.~Salam and G.~Soyez, contribution in
6408  preparation to proceedings of ``Workshop on TeV Colliders'', Les
6409  Houches, June 2011.
6410
6411\bibitem{Soyez:2012hv}
6412  G.~Soyez, G.~P.~Salam, J.~Kim, S.~Dutta and M.~Cacciari,
6413  %``Pileup subtraction for jet shapes,''
6414  Phys.\ Rev.\ Lett.\  {\bf 110} (2013) 16,  162001
6415  [arXiv:1211.2811 [hep-ph]].
6416  %%CITATION = ARXIV:1211.2811;%%
6417  %30 citations counted in INSPIRE as of 11 Aug 2014
6418
6419\bibitem{Krohn:2013lba}
6420  D.~Krohn, M.~D.~Schwartz, M.~Low and L.~T.~Wang,
6421  %``Jet Cleansing: Pileup Removal at High Luminosity,''
6422  arXiv:1309.4777 [hep-ph].
6423  %%CITATION = ARXIV:1309.4777;%%
6424  %9 citations counted in INSPIRE as of 12 Aug 2014
6425
6426\bibitem{Cacciari:2014jta}
6427  M.~Cacciari, G.~P.~Salam and G.~Soyez,
6428  %``On the use of charged-track information to subtract neutral pileup,''
6429  arXiv:1404.7353 [hep-ph].
6430  %%CITATION = ARXIV:1404.7353;%%
6431  %2 citations counted in INSPIRE as of 12 Aug 2014
6432
6433\bibitem{Berta:2014eza}
6434  P.~Berta, M.~Spousta, D.~W.~Miller and R.~Leitner,
6435  %``Particle-level pileup subtraction for jets and jet shapes,''
6436  JHEP {\bf 1406} (2014) 092
6437  [arXiv:1403.3108 [hep-ex]].
6438  %%CITATION = ARXIV:1403.3108;%%
6439  %4 citations counted in INSPIRE as of 12 Aug 2014
6440
6441
6442\bibitem{Cacciari:2014gra}
6443  M.~Cacciari, G.~P.~Salam and G.~Soyez,
6444  %``SoftKiller, a particle-level pileup removal method,''
6445  arXiv:1407.0408 [hep-ph].
6446  %%CITATION = ARXIV:1407.0408;%%
6447  %1 citations counted in INSPIRE as of 12 Aug 2014
6448
6449\bibitem{Bertolini:2014bba}
6450  D.~Bertolini, P.~Harris, M.~Low and N.~Tran,
6451  %``Pileup Per Particle Identification,''
6452  arXiv:1407.6013 [hep-ph].
6453  %%CITATION = ARXIV:1407.6013;%%
6454
6455
6456\bibitem{Cacciari:2012mu}
6457  M.~Cacciari, P.~Quiroga-Arias, G.~P.~Salam and G.~Soyez,
6458  %``Jet Fragmentation Function Moments in Heavy Ion Collisions,''
6459  Eur.\ Phys.\ J.\ C {\bf 73} (2013) 2319
6460  [arXiv:1209.6086 [hep-ph]].
6461  %%CITATION = ARXIV:1209.6086;%%
6462  %4 citations counted in INSPIRE as of 12 Aug 2014
6463
6464
6465\bibitem{BDRS}
6466  J.~M.~Butterworth, A.~R.~Davison, M.~Rubin and G.~P.~Salam,
6467  %``Jet substructure as a new Higgs search channel at the LHC,''
6468  Phys.\ Rev.\ Lett.\  {\bf 100} (2008) 242001
6469  [arXiv:0802.2470 [hep-ph]].
6470  %%CITATION = PRLTA,100,242001;%%
6471
6472\bibitem{trimming}
6473  D.~Krohn, J.~Thaler and L.~T.~Wang,
6474  %``Jet Trimming,''
6475  JHEP {\bf 1002} (2010) 084
6476  [arXiv:0912.1342 [hep-ph]].
6477  %%CITATION = JHEPA,1002,084;%%
6478
6479\bibitem{Kaplan:2008ie}
6480  D.~E.~Kaplan, K.~Rehermann, M.~D.~Schwartz, B.~Tweedie,
6481  %``Top Tagging: A Method for Identifying Boosted Hadronically Decaying Top Quarks,''
6482  Phys.\ Rev.\ Lett.\  {\bf 101 } (2008)  142001
6483  [arXiv:0806.0848 [hep-ph]].
6484
6485%\cite{Butterworth:2009qa}
6486\bibitem{Butterworth:2009qa}
6487  J.~M.~Butterworth, J.~R.~Ellis, A.~R.~Raklev, G.~P.~Salam,
6488  %``Discovering baryon-number violating neutralino decays at the LHC,''
6489  Phys.\ Rev.\ Lett.\  {\bf 103 } (2009)  241803.
6490  [arXiv:0906.0728 [hep-ph]].
6491
6492\bibitem{nsubtagger}
6493  J.~H.~Kim,
6494  %``Rest Frame Subjet Algorithm With SISCone Jet For Fully Hadronic Decaying
6495  %Higgs Search,''
6496  Phys.\ Rev.\  D {\bf 83} (2011) 011502
6497  [arXiv:1011.1493 [hep-ph]].
6498  %%CITATION = PHRVA,D83,011502;%%
6499
6500
6501\bibitem{Dasgupta:2013ihk}
6502  M.~Dasgupta, A.~Fregoso, S.~Marzani and G.~P.~Salam,
6503  %``Towards an understanding of jet substructure,''
6504  JHEP {\bf 1309} (2013) 029
6505  [arXiv:1307.0007 [hep-ph]].
6506  %%CITATION = ARXIV:1307.0007;%%
6507  %20 citations counted in INSPIRE as of 14 Aug 2014
6508
6509
6510\bibitem{Chan}
6511  T.~M.~Chan,
6512  ``Closest-point problems simplified on the RAM,''
6513  in Proc.\ 13th ACM-SIAM Symposium on Discrete Algorithms (SODA),
6514  p.~472 (2002).
6515
6516\bibitem{swig} \url{http://www.swig.org/}
6517
6518\bibitem{doxy2swig} \url{https://github.com/m7thon/doxy2swig/}
6519
6520\bibitem{Sjostrand:2007gs}
6521  T.~Sjostrand, S.~Mrenna, P.~Z.~Skands,
6522  %``A Brief Introduction to PYTHIA 8.1,''
6523  Comput.\ Phys.\ Commun.\  {\bf 178 } (2008)  852-867.
6524  [arXiv:0710.3820 [hep-ph]].
6525
6526\bibitem{fjcontrib} \fastjet \contrib, \url{http://fastjet.hepforge.org/contrib/}.
6527
6528
6529\bibitem{Anderberg}
6530  M.~R.~Anderberg,
6531  Cluster Analysis for Applications,
6532  (Number 19 in Probability and Mathematical Statistics, Academic
6533  Press, New York, 1973).
6534
6535
6536\bibitem{Sonnenschein}
6537  L.~Sonnenschein, Ph.D. Thesis, RWTH Aachen 2001; \\
6538  %% link verified GPS 2011-11-12
6539  \url{http://cmsdoc.cern.ch/documents/01/doc2001_025.ps.Z}
6540
6541\bibitem{Sjostrand:2006za}
6542  T.~Sjostrand, S.~Mrenna and P.~Skands,
6543  ``{\tt Pythia} 6.4 physics and manual,''
6544  JHEP {\bf 0605} (2006) 026,
6545  [arXiv:hep-ph/0603175].
6546  %%CITATION = JHEPA,0605,026;%%
6547
6548\bibitem{EppsteinHierarchical}
6549  %%David Eppstein
6550  D.~Eppstein
6551  %``Fast hierarchical clustering and other applications of dynamic
6552  %closest pairs,''
6553  J. Experimental Algorithmics {\bf 5} (2000) 1-23 [cs.DS/9912014].
6554\end{thebibliography}
6555
6556
6557
6558\end{document}
6559
6560
6561
6562%  LocalWords:  NNBase
6563