ATLAS Offline Software
JetDistances.h
Go to the documentation of this file.
1 // Dear emacs, this is -*- c++ -*-
2 
3 /*
4  Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
5 */
6 
7 #ifndef JETUTIL_JETDISTANCES_H
8 #define JETUTIL_JETDISTANCES_H
9 // //
12 
13 #include <cmath>
14 
15 
16 namespace jet {
17  namespace JetDistances {
18 
19  // phi convention enforcement
20  inline static double fixedPhi(double aPhi)
21  {
22  while ( aPhi < -M_PI )
23  {
24  aPhi += 2.*M_PI;
25  }
26  while ( aPhi > M_PI )
27  {
28  aPhi -= 2.*M_PI;
29  }
30  return aPhi;
31  }
32 
33 
34  template<class PARTICLE>
35  inline static double deltaEta(const PARTICLE& jet1,
36  const PARTICLE& jet2)
37  { return jet1.eta() - jet2.eta(); }
38 
39  inline static double deltaEta(const double eta1,
40  const double eta2)
41  { return (eta1 - eta2); }
42 
43  template<class PARTICLE>
44  inline static double deltaPhi(const PARTICLE& jet1,
45  const PARTICLE& jet2)
46  {
47  return fixedPhi(jet1.phi() - jet2.phi());
48  }
49 
50 
51  inline static double deltaPhi(const double phi1,
52  const double phi2)
53  {
54  return fixedPhi( phi1 - phi2 );
55  }
56 
57 
58  template<class PARTICLE>
59  inline static double deltaR2(const PARTICLE& jet1,
60  const PARTICLE& jet2){
61  return ( deltaEta(jet1,jet2) * deltaEta(jet1,jet2) +
62  deltaPhi(jet1,jet2) * deltaPhi(jet1,jet2) );
63  }
64 
65  inline static double deltaR2(const double eta1, const double phi1,
66  const double eta2, const double phi2 ) {
67  return ( deltaEta(eta1,eta2) * deltaEta(eta1,eta2) +
68  deltaPhi(phi1,phi2) * deltaPhi(phi1,phi2) );
69  }
70 
71  template<class PARTICLE>
72  inline static double deltaR(const PARTICLE& jet1,
73  const PARTICLE& jet2){
74  return sqrt( deltaR2(jet1, jet2) );
75  }
76 
77  inline static double deltaR(const double eta1, const double phi1,
78  const double eta2, const double phi2 ) {
79  return sqrt( deltaR2(eta1, phi1, eta2, phi2) );
80  }
81 
82 
83 
84  } // namespace JetDistances
85 
86 } // namespace jet
87 
88 #endif
ParticleGun_SamplingFraction.eta2
eta2
Definition: ParticleGun_SamplingFraction.py:96
M_PI
#define M_PI
Definition: ActiveFraction.h:11
xAOD::eta1
setEt setPhi setE277 setWeta2 eta1
Definition: TrigEMCluster_v1.cxx:41
jet
Definition: JetCalibTools_PlotJESFactors.cxx:23