Fork me on GitHub

source: git/external/fastjet/plugins/CDFCones/Centroid.hh@ 5af205e

Last change on this file since 5af205e was d7d2da3, checked in by pavel <pavel@…>, 12 years ago

move branches/ModularDelphes to trunk

  • Property mode set to 100644
File size: 2.2 KB
Line 
1#ifndef _CENTROID_HH_
2#define _CENTROID_HH_
3
4//----------------------------------------------------------------------
5// This file distributed with FastJet has been obtained from
6// http://www.pa.msu.edu/~huston/Les_Houches_2005/JetClu+Midpoint-StandAlone.tgz
7//
8// Permission to distribute it with FastJet has been granted by Joey
9// Huston (see the COPYING file in the main FastJet directory for
10// details).
11// Changes from the original file are listed below.
12//----------------------------------------------------------------------
13
14// History of changes compared to the original Centroid.hh file
15//
16// 2009-01-17 Gregory Soyez <soyez@fastjet.fr>
17//
18// * put the code in the fastjet::cdf namespace
19//
20// 2008-01-15 Gregory Soyez <soyez@fastjet.fr>
21//
22// * fixed issues with compilation under VC (definition of M_PI)
23//
24// 2006-09-24 Gavin Salam <salam@lpthe.jussieu.fr>
25//
26// * added JetClu+MidPoint to FastJet
27
28#include <cmath>
29
30#ifndef M_PI
31#define M_PI 3.141592653589793238462643383279502884197
32#endif
33
34#include <fastjet/internal/base.hh>
35
36FASTJET_BEGIN_NAMESPACE
37
38namespace cdf{
39
40class Centroid
41{
42 public:
43
44 double Et,eta,phi;
45
46 Centroid(): Et(0), eta(0), phi(0) {}
47 Centroid(double centroidEt, double centroidEta, double centroidPhi): Et(centroidEt), eta(centroidEta), phi(centroidPhi) {}
48 Centroid(const Centroid& c): Et(c.Et), eta(c.eta), phi(c.phi) {}
49 void add(Centroid c)
50 {
51 double newEt = Et + c.Et;
52 eta = (Et*eta + c.Et*c.eta)/newEt;
53 double dPhi = c.phi - phi;
54 if(dPhi > M_PI)
55 dPhi -= 2*M_PI;
56 else if(dPhi < -M_PI)
57 dPhi += 2*M_PI;
58 phi += dPhi*c.Et/newEt;
59 while(phi < 0)
60 phi += 2*M_PI;
61 while(phi >= 2*M_PI)
62 phi -= 2*M_PI;
63 Et = newEt;
64 }
65 void subtract(Centroid c)
66 {
67 double newEt = Et - c.Et;
68 eta = (Et*eta - c.Et*c.eta)/newEt;
69 double dPhi = c.phi - phi;
70 if(dPhi > M_PI)
71 dPhi -= 2*M_PI;
72 else if(dPhi < -M_PI)
73 dPhi += 2*M_PI;
74 phi -= dPhi*c.Et/newEt;
75 while(phi < 0)
76 phi += 2*M_PI;
77 while(phi >= 2*M_PI)
78 phi -= 2*M_PI;
79 Et = newEt;
80 }
81 bool isEqual(Centroid c)
82 {
83 return Et == c.Et && eta == c.eta && phi == c.phi;
84 }
85};
86
87} // namespace cdf
88
89FASTJET_END_NAMESPACE
90
91#endif
Note: See TracBrowser for help on using the repository browser.