FastJet  3.1.3
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Modules Pages
JetDistances.hh
1 //----------------------------------------------------------------------
2 // This file distributed with FastJet has been obtained from SpartyJet
3 // v2.20.0 by Pierre-Antoine Delsart, Kurtis L. Geerlings, Joey
4 // Huston, Brian T. Martin and Chris Vermilion
5 // For details, see http://www.pa.msu.edu/~huston/SpartyJet/
6 // http://projects.hepforge.org/spartyjet/
7 //
8 // Changes from the original file are listed below.
9 //----------------------------------------------------------------------
10 
11 // History of changes from the original JetDistance.hh file in
12 // SpartyJet v2.20
13 //
14 // 2009-01-15 Gregory Soyez <soyez@fastjet.fr>
15 //
16 // * put the code in the fastjet::atlas namespace
17 
18 #ifndef JETUTIL_JETDISTANCES_H
19 #define JETUTIL_JETDISTANCES_H
20 
21 
22 #include "Jet.hh"
23 
24 #include <cmath>
25 
26 #include <fastjet/internal/base.hh>
27 
28 FASTJET_BEGIN_NAMESPACE
29 
30 namespace atlas {
31 
32 struct JetDistances {
33 
34 
35  // distance in eta
36  inline static double deltaEta(const Jet& jet1, const Jet& jet2)
37  { return jet1.eta() - jet2.eta(); }
38  inline static double deltaEta(const Jet* jet1,
39  const Jet* jet2)
40  { return jet1->eta() - jet2->eta(); }
41  inline static double deltaEta(const double eta1,
42  const double eta2)
43  { return (eta1 - eta2); }
44 
45 
46 
47  inline static double deltaPhi(const Jet& jet1,
48  const Jet& jet2)
49  {
50  return fixedPhi(jet1.phi() - jet2.phi());
51  }
52  inline static double deltaPhi(const Jet* jet1,
53  const Jet* jet2)
54  {
55  return fixedPhi(jet1->phi()-jet2->phi());
56  }
57  inline static double deltaPhi(const double phi1,
58  const double phi2)
59  {
60  return fixedPhi( phi1 - phi2 );
61  }
62 
63 
64  // distance in (eta,phi)
65  inline static double deltaR(const Jet& jet1,
66  const Jet& jet2)
67  { return sqrt( deltaEta(jet1,jet2) * deltaEta(jet1,jet2) +
68  deltaPhi(jet1,jet2) * deltaPhi(jet1,jet2) ); }
69  inline static double deltaR(const Jet* jet1,
70  const Jet* jet2)
71  { return sqrt( deltaEta(jet1,jet2) * deltaEta(jet1,jet2) +
72  deltaPhi(jet1,jet2) * deltaPhi(jet1,jet2) ); }
73 
74  inline static double deltaR(const double eta1, const double phi1,
75  const double eta2, const double phi2 )
76  { return sqrt( deltaEta(eta1,eta2) * deltaEta(eta1,eta2) +
77  deltaPhi(phi1,phi2) * deltaPhi(phi1,phi2) ); }
78 
79 
80 
81  // phi convention enforcement
82  inline static double fixedPhi(double aPhi)
83  {
84  while ( aPhi < -M_PI )
85  {
86  aPhi += 2.*M_PI;
87  }
88  while ( aPhi > M_PI )
89  {
90  aPhi -= 2.*M_PI;
91  }
92  return aPhi;
93  }
94 
95 };
96 
97 } // namespace atlas
98 
99 FASTJET_END_NAMESPACE
100 #endif