FastJet 3.0beta1
|
00001 //STARTHEADER 00002 // $Id: Dnn4piCylinder.hh 1761 2010-09-16 10:43:18Z soyez $ 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 00042 /// \if internal_doc 00043 /// @ingroup internal 00044 /// \class Dnn4piCylinder 00045 /// class derived from DynamicNearestNeighbours that provides an 00046 /// implementation for the surface of cylinder (using two copies of 00047 /// DnnPlane, one running from 0--2pi, the other from pi--3pi). 00048 /// \endif 00049 class Dnn4piCylinder : public DynamicNearestNeighbours { 00050 public: 00051 /// empty initaliser 00052 Dnn4piCylinder() {} 00053 00054 /// Initialiser from a set of points on an Eta-Phi plane, where 00055 /// eta can have an arbitrary ranges and phi must be in range 00056 /// 0 <= phi < 2pi 00057 Dnn4piCylinder(const std::vector<EtaPhi> &, const bool & verbose = false ); 00058 00059 /// Returns the index of the nearest neighbour of point labelled 00060 /// by ii (assumes ii is valid) 00061 int NearestNeighbourIndex(const int & ii) const ; 00062 00063 /// Returns the distance to the nearest neighbour of point labelled 00064 /// by index ii (assumes ii is valid) 00065 double NearestNeighbourDistance(const int & ii) const ; 00066 00067 /// Returns true iff the given index corresponds to a point that 00068 /// exists in the DNN structure (meaning that it has been added, and 00069 /// not removed in the meantime) 00070 bool Valid(const int & index) const; 00071 00072 void RemoveAndAddPoints(const std::vector<int> & indices_to_remove, 00073 const std::vector<EtaPhi> & points_to_add, 00074 std::vector<int> & indices_added, 00075 std::vector<int> & indices_of_updated_neighbours); 00076 00077 ~Dnn4piCylinder(); 00078 00079 private: 00080 00081 bool _verbose; 00082 00083 // NB: we define POINTERS here because the initialisation gave 00084 // us problems (things crashed!), perhaps because in practice 00085 // we were making a copy without being careful and defining 00086 // a proper copy constructor. 00087 DnnPlane * _DNN1, * _DNN2; 00088 00089 /// given a phi value in the 0--2pi range return one 00090 /// in the pi--3pi range. 00091 inline EtaPhi _remap_phi(const EtaPhi & point) { 00092 double phi = point.second; 00093 if (phi < pi) { phi += twopi ;} 00094 return EtaPhi(point.first, phi);} 00095 00096 }; 00097 00098 00099 // here follow some inline implementations of the simpler of the 00100 // functions defined above 00101 00102 inline int Dnn4piCylinder::NearestNeighbourIndex(const int & current) const { 00103 return (_DNN1->NearestNeighbourDistance(current) < 00104 _DNN2->NearestNeighbourDistance(current)) ? 00105 _DNN1->NearestNeighbourIndex(current) : 00106 _DNN2->NearestNeighbourIndex(current) ; 00107 } 00108 00109 inline double Dnn4piCylinder::NearestNeighbourDistance(const int & current) const { 00110 return (_DNN1->NearestNeighbourDistance(current) < 00111 _DNN2->NearestNeighbourDistance(current)) ? 00112 _DNN1->NearestNeighbourDistance(current) : 00113 _DNN2->NearestNeighbourDistance(current) ; 00114 } 00115 00116 inline bool Dnn4piCylinder::Valid(const int & index) const { 00117 return (_DNN1->Valid(index) && _DNN2->Valid(index)); 00118 } 00119 00120 00121 inline Dnn4piCylinder::~Dnn4piCylinder() { 00122 delete _DNN1; 00123 delete _DNN2; 00124 } 00125 00126 00127 FASTJET_END_NAMESPACE 00128 00129 #endif // __FASTJET_DNN4PICYLINDER_HH__ 00130 #endif // DROP_CGAL