Fork me on GitHub

source: git/external/fastjet/internal/ClosestPair2DBase.hh@ 8a58fff

ImprovedOutputFile Timing dual_readout llp
Last change on this file since 8a58fff was 1d208a2, checked in by Pavel Demin <pavel.demin@…>, 8 years ago

update FastJet library to 3.2.1 and Nsubjettiness library to 2.2.4

  • Property mode set to 100644
File size: 4.7 KB
Line 
1//FJSTARTHEADER
2// $Id: ClosestPair2DBase.hh 4049 2016-03-03 13:45:47Z salam $
3//
4// Copyright (c) 2005-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#ifndef __FASTJET_CLOSESTPAIR2DBASE__HH__
32#define __FASTJET_CLOSESTPAIR2DBASE__HH__
33
34#include<vector>
35#include "fastjet/internal/base.hh"
36
37FASTJET_BEGIN_NAMESPACE // defined in fastjet/internal/base.hh
38
39//----------------------------------------------------------------------
40/// \if internal_doc
41/// @ingroup internal
42/// \class Coord2D
43/// class for representing 2d coordinates and carrying out some basic
44/// operations on them
45/// \endif
46class Coord2D {
47public:
48 double x, y;
49
50 Coord2D() : x(0.0), y(0.0) {};
51
52 Coord2D(double a, double b): x(a), y(b) {};
53
54 /// return the vector difference between two coordinates
55 Coord2D operator-(const Coord2D & other) const {
56 return Coord2D(x - other.x, y - other.y);};
57
58 /// return the vector sum between two coordinates
59 Coord2D operator+(const Coord2D & other) const {
60 return Coord2D(x + other.x, y + other.y);};
61
62 /// return the product of the coordinate with the factor
63 Coord2D operator*(double factor) const {return Coord2D(factor*x,factor*y);};
64 friend Coord2D operator*(double factor, const Coord2D & coord) {
65 return Coord2D(factor*coord.x,factor*coord.y);
66 }
67
68 /// division of each component of coordinate
69 Coord2D operator/(double divisor) const {
70 return Coord2D(x / divisor, y / divisor);};
71
72 /// return the squared distance between two coordinates
73 friend double distance2(const Coord2D & a, const Coord2D & b) {
74 double dx = a.x - b.x, dy = a.y-b.y;
75 return dx*dx+dy*dy;
76 };
77 /// return the squared distance between two coordinates
78 double distance2(const Coord2D & b) const {
79 double dx = x - b.x, dy = y-b.y;
80 return dx*dx+dy*dy;
81 };
82};
83
84
85//----------------------------------------------------------------------
86/// \if internal_doc
87/// @ingroup internal
88/// \class ClosestPair2DBase
89/// abstract base class for finding closest pairs in 2D
90/// \endif
91class ClosestPair2DBase {
92public:
93 /// provides the IDs of the closest pair as well as the squared
94 /// distance between them
95 virtual void closest_pair(unsigned int & ID1, unsigned int & ID2,
96 double & distance2) const = 0;
97
98 /// removes the entry labelled by ID from the object;
99 virtual void remove(unsigned int ID) = 0;
100
101 /// inserts the position into the closest pair structure and returns the
102 /// ID that has been allocated for the object.
103 virtual unsigned int insert(const Coord2D & position) = 0;
104
105 /// replaces the specified ID1 and ID2 with something at a new position
106 /// assuming that ID1 and ID2 are in sequence wrt position; it returns
107 /// the ID of the new object...
108 virtual unsigned int replace(unsigned int ID1, unsigned int ID2,
109 const Coord2D & position) {
110 remove(ID1);
111 remove(ID2);
112 unsigned new_ID = insert(position);
113 return(new_ID);
114 };
115
116 /// replaces IDs_to_remove with points at the new_positions
117 /// indicating the IDs allocated to the new points in new_IDs
118 virtual void replace_many(const std::vector<unsigned int> & IDs_to_remove,
119 const std::vector<Coord2D> & new_positions,
120 std::vector<unsigned int> & new_IDs) {
121 for(unsigned i = 0; i < IDs_to_remove.size(); i++) {
122 remove(IDs_to_remove[i]);}
123 new_IDs.resize(0);
124 for(unsigned i = 0; i < new_positions.size(); i++) {
125 new_IDs.push_back(insert(new_positions[i]));}
126 }
127
128 virtual unsigned int size() = 0;
129
130 virtual ~ClosestPair2DBase() {};
131
132};
133
134
135FASTJET_END_NAMESPACE
136
137#endif // __FASTJET_CLOSESTPAIR2DBASE__HH__
Note: See TracBrowser for help on using the repository browser.