00001 //STARTHEADER 00002 // $Id: Dnn4piCylinder.hh 431 2007-01-20 10:44:55Z salam $ 00003 // 00004 // Copyright (c) 2005-2006, Matteo Cacciari and Gavin Salam 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, write to the Free Software 00026 // Foundation, Inc.: 00027 // 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00028 //---------------------------------------------------------------------- 00029 //ENDHEADER 00030 00031 00032 #ifndef DROP_CGAL // in case we do not have the code for CGAL 00033 #ifndef __FASTJET_DNN4PICYLINDER_HH__ 00034 #define __FASTJET_DNN4PICYLINDER_HH__ 00035 00036 #include "fastjet/internal/DynamicNearestNeighbours.hh" 00037 #include "fastjet/internal/DnnPlane.hh" 00038 #include "fastjet/internal/numconsts.hh" 00039 00040 FASTJET_BEGIN_NAMESPACE // defined in fastjet/internal/base.hh 00041 00045 class Dnn4piCylinder : public DynamicNearestNeighbours { 00046 public: 00048 Dnn4piCylinder() {} 00049 00053 Dnn4piCylinder(const std::vector<EtaPhi> &, const bool & verbose = false ); 00054 00057 int NearestNeighbourIndex(const int & ii) const ; 00058 00061 double NearestNeighbourDistance(const int & ii) const ; 00062 00066 bool Valid(const int & index) const; 00067 00068 void RemoveAndAddPoints(const std::vector<int> & indices_to_remove, 00069 const std::vector<EtaPhi> & points_to_add, 00070 std::vector<int> & indices_added, 00071 std::vector<int> & indices_of_updated_neighbours); 00072 00073 ~Dnn4piCylinder(); 00074 00075 private: 00076 00077 bool _verbose; 00078 00079 // NB: we define POINTERS here because the initialisation gave 00080 // us problems (things crashed!), perhaps because in practice 00081 // we were making a copy without being careful and defining 00082 // a proper copy constructor. 00083 DnnPlane * _DNN1, * _DNN2; 00084 00087 inline EtaPhi _remap_phi(const EtaPhi & point) { 00088 double phi = point.second; 00089 if (phi < pi) { phi += twopi ;} 00090 return EtaPhi(point.first, phi);} 00091 00092 }; 00093 00094 00095 // here follow some inline implementations of the simpler of the 00096 // functions defined above 00097 00098 inline int Dnn4piCylinder::NearestNeighbourIndex(const int & current) const { 00099 return (_DNN1->NearestNeighbourDistance(current) < 00100 _DNN2->NearestNeighbourDistance(current)) ? 00101 _DNN1->NearestNeighbourIndex(current) : 00102 _DNN2->NearestNeighbourIndex(current) ; 00103 } 00104 00105 inline double Dnn4piCylinder::NearestNeighbourDistance(const int & current) const { 00106 return (_DNN1->NearestNeighbourDistance(current) < 00107 _DNN2->NearestNeighbourDistance(current)) ? 00108 _DNN1->NearestNeighbourDistance(current) : 00109 _DNN2->NearestNeighbourDistance(current) ; 00110 } 00111 00112 inline bool Dnn4piCylinder::Valid(const int & index) const { 00113 return (_DNN1->Valid(index) && _DNN2->Valid(index)); 00114 } 00115 00116 00117 inline Dnn4piCylinder::~Dnn4piCylinder() { 00118 delete _DNN1; 00119 delete _DNN2; 00120 } 00121 00122 00123 FASTJET_END_NAMESPACE 00124 00125 #endif // __FASTJET_DNN4PICYLINDER_HH__ 00126 #endif // DROP_CGAL