FastJet  3.1.3
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Modules Pages
01-basic.cc
Go to the documentation of this file.
1 //----------------------------------------------------------------------
2 /// \file
3 /// \page Example01 01 - basic usage example
4 ///
5 /// fastjet basic example program:
6 /// simplest illustration of the usage of the basic classes:
7 /// fastjet::PseudoJet, fastjet::JetDefinition and
8 /// fastjet::ClusterSequence
9 ///
10 /// run it with : ./01-basic < data/single-event.dat
11 ///
12 /// Source code: 01-basic.cc
13 //----------------------------------------------------------------------
14 
15 //STARTHEADER
16 // $Id: 01-basic.cc 2684 2011-11-14 07:41:44Z soyez $
17 //
18 // Copyright (c) 2005-2011, Matteo Cacciari, Gavin P. Salam and Gregory Soyez
19 //
20 //----------------------------------------------------------------------
21 // This file is part of FastJet.
22 //
23 // FastJet is free software; you can redistribute it and/or modify
24 // it under the terms of the GNU General Public License as published by
25 // the Free Software Foundation; either version 2 of the License, or
26 // (at your option) any later version.
27 //
28 // The algorithms that underlie FastJet have required considerable
29 // development and are described in hep-ph/0512210. If you use
30 // FastJet as part of work towards a scientific publication, please
31 // include a citation to the FastJet paper.
32 //
33 // FastJet is distributed in the hope that it will be useful,
34 // but WITHOUT ANY WARRANTY; without even the implied warranty of
35 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
36 // GNU General Public License for more details.
37 //
38 // You should have received a copy of the GNU General Public License
39 // along with FastJet. If not, see <http://www.gnu.org/licenses/>.
40 //----------------------------------------------------------------------
41 //ENDHEADER
42 
43 #include "fastjet/ClusterSequence.hh"
44 #include <iostream> // needed for io
45 #include <cstdio> // needed for io
46 
47 using namespace std;
48 
49 /// an example program showing how to use fastjet
50 int main(){
51 
52  // read in input particles
53  //----------------------------------------------------------
54  vector<fastjet::PseudoJet> input_particles;
55 
56  double px, py , pz, E;
57  while (cin >> px >> py >> pz >> E) {
58  // create a fastjet::PseudoJet with these components and put it onto
59  // back of the input_particles vector
60  input_particles.push_back(fastjet::PseudoJet(px,py,pz,E));
61  }
62 
63 
64  // create a jet definition:
65  // a jet algorithm with a given radius parameter
66  //----------------------------------------------------------
67  double R = 0.6;
69 
70 
71  // run the jet clustering with the above jet definition
72  //----------------------------------------------------------
73  fastjet::ClusterSequence clust_seq(input_particles, jet_def);
74 
75 
76  // get the resulting jets ordered in pt
77  //----------------------------------------------------------
78  double ptmin = 5.0;
79  vector<fastjet::PseudoJet> inclusive_jets = sorted_by_pt(clust_seq.inclusive_jets(ptmin));
80 
81 
82  // tell the user what was done
83  // - the description of the algorithm used
84  // - extract the inclusive jets with pt > 5 GeV
85  // show the output as
86  // {index, rap, phi, pt}
87  //----------------------------------------------------------
88  cout << "Ran " << jet_def.description() << endl;
89 
90  // label the columns
91  printf("%5s %15s %15s %15s\n","jet #", "rapidity", "phi", "pt");
92 
93  // print out the details for each jet
94  for (unsigned int i = 0; i < inclusive_jets.size(); i++) {
95  printf("%5u %15.8f %15.8f %15.8f\n",
96  i, inclusive_jets[i].rap(), inclusive_jets[i].phi(),
97  inclusive_jets[i].perp());
98  }
99 
100  return 0;
101 }
deals with clustering
std::vector< PseudoJet > inclusive_jets(const double ptmin=0.0) const
return a vector of all jets (in the sense of the inclusive algorithm) with pt >= ptmin.
int main()
an example program showing how to use fastjet
Definition: 01-basic.cc:50
std::string description() const
return a textual description of the current jet definition
like the k_t but with distance measures dij = min(1/kti^2,1/ktj^2) Delta R_{ij}^2 / R^2 diB = 1/kti^2...
Class to contain pseudojets, including minimal information of use to jet-clustering routines...
Definition: PseudoJet.hh:67
class that is intended to hold a full definition of the jet clusterer