FastJet  3.2.0
JadeDistanceTagger.cc
1 //STARTHEADER
2 // $Id: MassDropTagger.cc 2138 2011-05-16 18:56:46Z soyez $
3 //
4 // Copyright (c) 2005-2011, Matteo Cacciari, Gavin 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 and are described in hep-ph/0512210. If you use
16 // FastJet as part of work towards a scientific publication, please
17 // include a citation to the FastJet paper.
18 //
19 // FastJet is distributed in the hope that it will be useful,
20 // but WITHOUT ANY WARRANTY; without even the implied warranty of
21 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 // GNU General Public License for more details.
23 //
24 // You should have received a copy of the GNU General Public License
25 // along with FastJet; if not, write to the Free Software
26 // Foundation, Inc.:
27 // 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
28 //----------------------------------------------------------------------
29 //ENDHEADER
30 
31 #include <fastjet/tools/JadeDistanceTagger.hh>
32 #include <sstream>
33 
34 FASTJET_BEGIN_NAMESPACE
35 
36 using namespace std;
37 
38 //----------------------------------------------------------------------
39 // JadeDistanceTagger implementation
40 //----------------------------------------------------------------------
41 
42 //------------------------------------------------------------------------
43 // description of the tagger
44 string JadeDistanceTagger::description() const{
45  ostringstream oss;
46  oss << "JadeDistanceTagger with mdrop=" << _mdrop << " and mcut=" << _mcut;
47  return oss.str();
48 }
49 
50 
51 //------------------------------------------------------------------------
52 // the tagging itself
53 // - jet the PseudoJet to tag
54 PseudoJet JadeDistanceTagger::apply(const PseudoJet & jet) const{
55  // search the subjets with the mass drop and mass cut parameters
56  vector<PseudoJet> subjets;
57  _recursively_find_subjets(jet,subjets);
58 
59  // stupidly make sure we have at least 2!
60  if (subjets.size()<2) return join(PseudoJet(0.0,0.0,0.0,0.0));
61 
62  // among all possible pairs, maximise the (modified) Jade distance
63  double dmax=0.0;
64  unsigned int i1=0, i2=0;
65  for (unsigned int it1=0; it1<subjets.size(); it1++){
66  const PseudoJet & j1 = subjets[it1];
67  double pt1 = j1.perp();
68  for (unsigned int it2=it1+1; it2<subjets.size(); it2++){
69  const PseudoJet & j2 = subjets[it2];
70  double d = j1.squared_distance(j2);
71  d = pt1*j2.perp()*d*d; // could improve slightly by store the pt... or using the ^2
72 
73  if (d>dmax){ i1 = it1; i1=it2; dmax=d;}
74  }
75  }
76  const PseudoJet & j1 = subjets[i1];
77  const PseudoJet & j2 = subjets[i2];
78 
79  // apply the filter
80  PseudoJet result = join<StructureType>(j1,j2);
81  result.extra_properties<JadeDistanceTagger>()._mdrop
82  = max(j1.m(), j2.m())/jet.m();
83  result.extra_properties<JadeDistanceTagger>()._jade_distance = dmax;
84  return result;
85 }
86 
87 
88 //------------------------------------------------------------------------
89 void JadeDistanceTagger::_recursively_find_subjets(const PseudoJet &jet,
90  vector<PseudoJet> &subjets) const{
91  // check if we should simply keep it
92  PseudoJet j1, j2;
93 
94  if ((jet.m()<_mcut) || (!jet.has_parents(j1, j2))){
95  subjets.push_back(jet);
96  return;
97  }
98 
99  // make j1 the more massive jet
100  if (j1.m() < j2.m()) std::swap(j1,j2);
101 
102  if (j1.m() < _mdrop*jet.m())
103  _recursively_find_subjets(j2, subjets);
104 
105  _recursively_find_subjets(j1, subjets);
106 }
107 
108 FASTJET_END_NAMESPACE
109 
Class that helps perform 2-pronged boosted tagging searching the clustring with maximal Jade distance...
virtual bool has_parents(PseudoJet &parent1, PseudoJet &parent2) const
check if it is the product of a recombination, in which case return the 2 parents through the &#39;parent...
Definition: PseudoJet.cc:547
double squared_distance(const PseudoJet &other) const
returns squared cylinder (rap-phi) distance between this jet and another
Definition: PseudoJet.hh:186
double perp() const
returns the scalar transverse momentum
Definition: PseudoJet.hh:143
double m() const
returns the invariant mass (If m2() is negative then -sqrt(-m2()) is returned, as in CLHEP) ...
Definition: PseudoJet.hh:945
Class to contain pseudojets, including minimal information of use to jet-clustering routines...
Definition: PseudoJet.hh:67