FastJet  3.1.3
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Modules Pages
JadePlugin.cc
1 //FJSTARTHEADER
2 // $Id: JadePlugin.cc 3433 2014-07-23 08:17:03Z salam $
3 //
4 // Copyright (c) 2007-2014, Matteo Cacciari, Gavin P. Salam and Gregory Soyez
5 //
6 //----------------------------------------------------------------------
7 // This file is part of FastJet.
8 //
9 // FastJet is free software; you can redistribute it and/or modify
10 // it under the terms of the GNU General Public License as published by
11 // the Free Software Foundation; either version 2 of the License, or
12 // (at your option) any later version.
13 //
14 // The algorithms that underlie FastJet have required considerable
15 // development. They are described in the original FastJet paper,
16 // hep-ph/0512210 and in the manual, arXiv:1111.6097. If you use
17 // FastJet as part of work towards a scientific publication, please
18 // quote the version you use and include a citation to the manual and
19 // optionally also to hep-ph/0512210.
20 //
21 // FastJet is distributed in the hope that it will be useful,
22 // but WITHOUT ANY WARRANTY; without even the implied warranty of
23 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24 // GNU General Public License for more details.
25 //
26 // You should have received a copy of the GNU General Public License
27 // along with FastJet. If not, see <http://www.gnu.org/licenses/>.
28 //----------------------------------------------------------------------
29 //FJENDHEADER
30 
31 // fastjet stuff
32 #include "fastjet/ClusterSequence.hh"
33 #include "fastjet/JadePlugin.hh"
34 #include <iostream>
35 //#include "fastjet/internal/ClusterSequence_N2.icc"
36 #include "fastjet/NNH.hh"
37 
38 // other stuff
39 #include <vector>
40 #include <sstream>
41 #include <limits>
42 
43 
44 
45 
46 using namespace std;
47 
48 FASTJET_BEGIN_NAMESPACE // defined in fastjet/internal/base.hh
49 
50 
51 //----------------------------------------------------------------------
52 /// class to help run a JADE algorithm
53 class JadeBriefJet {
54 public:
55  void init(const PseudoJet & jet) {
56  double norm = 1.0/sqrt(jet.modp2());
57  nx = jet.px() * norm;
58  ny = jet.py() * norm;
59  nz = jet.pz() * norm;
60  rt2E = sqrt(2.0)*jet.E();
61  }
62 
63  double distance(const JadeBriefJet * jet) const {
64  double dij = 1 - nx*jet->nx
65  - ny*jet->ny
66  - nz*jet->nz;
67  dij *= rt2E*jet->rt2E;
68  return dij;
69  }
70 
71  double beam_distance() const {
72  return numeric_limits<double>::max();
73  }
74 
75 private:
76  double rt2E, nx, ny, nz;
77 };
78 
79 
80 //----------------------------------------------------------------------
81 string JadePlugin::description () const {
82  ostringstream desc;
83  desc << "e+e- JADE algorithm plugin";
84  return desc.str();
85 }
86 
87 //----------------------------------------------------------------------
88 void JadePlugin::run_clustering(ClusterSequence & cs) const {
89  int njets = cs.jets().size();
90  NNH<JadeBriefJet> nnh(cs.jets());
91 
92  // if testing against Hoeth's implementation, need to rescale the
93  // dij by Q^2.
94  //double Q2 = cs.Q2();
95 
96  while (njets > 0) {
97  int i, j, k;
98  double dij = nnh.dij_min(i, j);
99 
100  if (j >= 0) {
101  cs.plugin_record_ij_recombination(i, j, dij, k);
102  nnh.merge_jets(i, j, cs.jets()[k], k);
103  } else {
104  double diB = cs.jets()[i].E()*cs.jets()[i].E(); // get new diB
106  nnh.remove_jet(i);
107  }
108  njets--;
109  }
110 }
111 
112 FASTJET_END_NAMESPACE // defined in fastjet/internal/base.hh
double dij_min(int &iA, int &iB)
return the dij_min and indices iA, iB, for the corresponding jets.
Definition: NNH.hh:224
const std::vector< PseudoJet > & jets() const
allow the user to access the internally stored _jets() array, which contains both the initial particl...
double norm(const VPoint p)
norm of a vector
Definition: Voronoi.hh:155
deals with clustering
Help solve closest pair problems with generic interparticle and beam distance.
Definition: NNH.hh:113
void plugin_record_ij_recombination(int jet_i, int jet_j, double dij, int &newjet_k)
record the fact that there has been a recombination between jets()[jet_i] and jets()[jet_k], with the specified dij, and return the index (newjet_k) allocated to the new jet, whose momentum is assumed to be the 4-vector sum of that of jet_i and jet_j
void plugin_record_iB_recombination(int jet_i, double diB)
record the fact that there has been a recombination between jets()[jet_i] and the beam...