]>
Commit | Line | Data |
---|---|---|
370be031 | 1 | //STARTHEADER |
2 | // $Id: Dnn4piCylinder.hh 431 2007-01-20 10:44:55Z salam $ | |
3 | // | |
4 | // Copyright (c) 2005-2006, Matteo Cacciari and Gavin Salam | |
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 | ||
32 | #ifndef DROP_CGAL // in case we do not have the code for CGAL | |
33 | #ifndef __FASTJET_DNN4PICYLINDER_HH__ | |
34 | #define __FASTJET_DNN4PICYLINDER_HH__ | |
35 | ||
36 | #include "fastjet/internal/DynamicNearestNeighbours.hh" | |
37 | #include "fastjet/internal/DnnPlane.hh" | |
38 | #include "fastjet/internal/numconsts.hh" | |
39 | ||
40 | namespace fastjet { // defined in fastjet/internal/base.hh | |
41 | ||
42 | /// class derived from DynamicNearestNeighbours that provides an | |
43 | /// implementation for the surface of cylinder (using two copies of | |
44 | /// DnnPlane, one running from 0--2pi, the other from pi--3pi). | |
45 | class Dnn4piCylinder : public DynamicNearestNeighbours { | |
46 | public: | |
47 | /// empty initaliser | |
48 | Dnn4piCylinder() {} | |
49 | ||
50 | /// Initialiser from a set of points on an Eta-Phi plane, where | |
51 | /// eta can have an arbitrary ranges and phi must be in range | |
52 | /// 0 <= phi < 2pi | |
53 | Dnn4piCylinder(const std::vector<EtaPhi> &, const bool & verbose = false ); | |
54 | ||
55 | /// Returns the index of the nearest neighbour of point labelled | |
56 | /// by ii (assumes ii is valid) | |
57 | int NearestNeighbourIndex(const int & ii) const ; | |
58 | ||
59 | /// Returns the distance to the nearest neighbour of point labelled | |
60 | /// by index ii (assumes ii is valid) | |
61 | double NearestNeighbourDistance(const int & ii) const ; | |
62 | ||
63 | /// Returns true iff the given index corresponds to a point that | |
64 | /// exists in the DNN structure (meaning that it has been added, and | |
65 | /// not removed in the meantime) | |
66 | bool Valid(const int & index) const; | |
67 | ||
68 | void RemoveAndAddPoints(const std::vector<int> & indices_to_remove, | |
69 | const std::vector<EtaPhi> & points_to_add, | |
70 | std::vector<int> & indices_added, | |
71 | std::vector<int> & indices_of_updated_neighbours); | |
72 | ||
73 | ~Dnn4piCylinder(); | |
74 | ||
75 | private: | |
76 | ||
77 | bool _verbose; | |
78 | ||
79 | // NB: we define POINTERS here because the initialisation gave | |
80 | // us problems (things crashed!), perhaps because in practice | |
81 | // we were making a copy without being careful and defining | |
82 | // a proper copy constructor. | |
83 | DnnPlane * _DNN1, * _DNN2; | |
84 | ||
85 | /// given a phi value in the 0--2pi range return one | |
86 | /// in the pi--3pi range. | |
87 | inline EtaPhi _remap_phi(const EtaPhi & point) { | |
88 | double phi = point.second; | |
89 | if (phi < pi) { phi += twopi ;} | |
90 | return EtaPhi(point.first, phi);} | |
91 | ||
92 | }; | |
93 | ||
94 | ||
95 | // here follow some inline implementations of the simpler of the | |
96 | // functions defined above | |
97 | ||
98 | inline int Dnn4piCylinder::NearestNeighbourIndex(const int & current) const { | |
99 | return (_DNN1->NearestNeighbourDistance(current) < | |
100 | _DNN2->NearestNeighbourDistance(current)) ? | |
101 | _DNN1->NearestNeighbourIndex(current) : | |
102 | _DNN2->NearestNeighbourIndex(current) ; | |
103 | } | |
104 | ||
105 | inline double Dnn4piCylinder::NearestNeighbourDistance(const int & current) const { | |
106 | return (_DNN1->NearestNeighbourDistance(current) < | |
107 | _DNN2->NearestNeighbourDistance(current)) ? | |
108 | _DNN1->NearestNeighbourDistance(current) : | |
109 | _DNN2->NearestNeighbourDistance(current) ; | |
110 | } | |
111 | ||
112 | inline bool Dnn4piCylinder::Valid(const int & index) const { | |
113 | return (_DNN1->Valid(index) && _DNN2->Valid(index)); | |
114 | } | |
115 | ||
116 | ||
117 | inline Dnn4piCylinder::~Dnn4piCylinder() { | |
118 | delete _DNN1; | |
119 | delete _DNN2; | |
120 | } | |
121 | ||
122 | ||
123 | } // fastjet namespace | |
124 | ||
125 | #endif // __FASTJET_DNN4PICYLINDER_HH__ | |
126 | #endif // DROP_CGAL |