FastJet 3.0.2
|
00001 //STARTHEADER 00002 // $Id: Dnn4piCylinder.hh 2577 2011-09-13 15:11:38Z salam $ 00003 // 00004 // Copyright (c) 2005-2011, Matteo Cacciari, Gavin P. Salam and Gregory Soyez 00005 // 00006 //---------------------------------------------------------------------- 00007 // This file is part of FastJet. 00008 // 00009 // FastJet is free software; you can redistribute it and/or modify 00010 // it under the terms of the GNU General Public License as published by 00011 // the Free Software Foundation; either version 2 of the License, or 00012 // (at your option) any later version. 00013 // 00014 // The algorithms that underlie FastJet have required considerable 00015 // development and are described in hep-ph/0512210. If you use 00016 // FastJet as part of work towards a scientific publication, please 00017 // include a citation to the FastJet paper. 00018 // 00019 // FastJet is distributed in the hope that it will be useful, 00020 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00021 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00022 // GNU General Public License for more details. 00023 // 00024 // You should have received a copy of the GNU General Public License 00025 // along with FastJet. If not, see <http://www.gnu.org/licenses/>. 00026 //---------------------------------------------------------------------- 00027 //ENDHEADER 00028 00029 00030 #ifndef DROP_CGAL // in case we do not have the code for CGAL 00031 #ifndef __FASTJET_DNN4PICYLINDER_HH__ 00032 #define __FASTJET_DNN4PICYLINDER_HH__ 00033 00034 #include "fastjet/internal/DynamicNearestNeighbours.hh" 00035 #include "fastjet/internal/DnnPlane.hh" 00036 #include "fastjet/internal/numconsts.hh" 00037 00038 FASTJET_BEGIN_NAMESPACE // defined in fastjet/internal/base.hh 00039 00040 /// \if internal_doc 00041 /// @ingroup internal 00042 /// \class Dnn4piCylinder 00043 /// class derived from DynamicNearestNeighbours that provides an 00044 /// implementation for the surface of cylinder (using two copies of 00045 /// DnnPlane, one running from 0--2pi, the other from pi--3pi). 00046 /// \endif 00047 class Dnn4piCylinder : public DynamicNearestNeighbours { 00048 public: 00049 /// empty initaliser 00050 Dnn4piCylinder() {} 00051 00052 /// Initialiser from a set of points on an Eta-Phi plane, where 00053 /// eta can have an arbitrary ranges and phi must be in range 00054 /// 0 <= phi < 2pi 00055 Dnn4piCylinder(const std::vector<EtaPhi> &, const bool & verbose = false ); 00056 00057 /// Returns the index of the nearest neighbour of point labelled 00058 /// by ii (assumes ii is valid) 00059 int NearestNeighbourIndex(const int & ii) const ; 00060 00061 /// Returns the distance to the nearest neighbour of point labelled 00062 /// by index ii (assumes ii is valid) 00063 double NearestNeighbourDistance(const int & ii) const ; 00064 00065 /// Returns true iff the given index corresponds to a point that 00066 /// exists in the DNN structure (meaning that it has been added, and 00067 /// not removed in the meantime) 00068 bool Valid(const int & index) const; 00069 00070 void RemoveAndAddPoints(const std::vector<int> & indices_to_remove, 00071 const std::vector<EtaPhi> & points_to_add, 00072 std::vector<int> & indices_added, 00073 std::vector<int> & indices_of_updated_neighbours); 00074 00075 ~Dnn4piCylinder(); 00076 00077 private: 00078 00079 bool _verbose; 00080 00081 // NB: we define POINTERS here because the initialisation gave 00082 // us problems (things crashed!), perhaps because in practice 00083 // we were making a copy without being careful and defining 00084 // a proper copy constructor. 00085 DnnPlane * _DNN1, * _DNN2; 00086 00087 /// given a phi value in the 0--2pi range return one 00088 /// in the pi--3pi range. 00089 inline EtaPhi _remap_phi(const EtaPhi & point) { 00090 double phi = point.second; 00091 if (phi < pi) { phi += twopi ;} 00092 return EtaPhi(point.first, phi);} 00093 00094 }; 00095 00096 00097 // here follow some inline implementations of the simpler of the 00098 // functions defined above 00099 00100 inline int Dnn4piCylinder::NearestNeighbourIndex(const int & current) const { 00101 return (_DNN1->NearestNeighbourDistance(current) < 00102 _DNN2->NearestNeighbourDistance(current)) ? 00103 _DNN1->NearestNeighbourIndex(current) : 00104 _DNN2->NearestNeighbourIndex(current) ; 00105 } 00106 00107 inline double Dnn4piCylinder::NearestNeighbourDistance(const int & current) const { 00108 return (_DNN1->NearestNeighbourDistance(current) < 00109 _DNN2->NearestNeighbourDistance(current)) ? 00110 _DNN1->NearestNeighbourDistance(current) : 00111 _DNN2->NearestNeighbourDistance(current) ; 00112 } 00113 00114 inline bool Dnn4piCylinder::Valid(const int & index) const { 00115 return (_DNN1->Valid(index) && _DNN2->Valid(index)); 00116 } 00117 00118 00119 inline Dnn4piCylinder::~Dnn4piCylinder() { 00120 delete _DNN1; 00121 delete _DNN2; 00122 } 00123 00124 00125 FASTJET_END_NAMESPACE 00126 00127 #endif // __FASTJET_DNN4PICYLINDER_HH__ 00128 #endif // DROP_CGAL