DnnPlane.hh

Go to the documentation of this file.
00001 //STARTHEADER
00002 // $Id: DnnPlane.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 
00034 #ifndef __FASTJET_DNNPLANE_HH__
00035 #define __FASTJET_DNNPLANE_HH__
00036 
00037 #include "fastjet/internal/Triangulation.hh"
00038 #include "fastjet/internal/DynamicNearestNeighbours.hh"
00039 
00040 FASTJET_BEGIN_NAMESPACE      // defined in fastjet/internal/base.hh
00041 
00042 
00045 class DnnPlane : public DynamicNearestNeighbours {
00046  public:
00048   DnnPlane() {}
00049 
00052   DnnPlane(const std::vector<EtaPhi> &, const bool & verbose = false );
00053 
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 
00074   EtaPhi etaphi(const int i) const;
00076   double eta(const int i) const;
00078   double phi(const int i) const;
00079 
00080  private:
00081 
00084   struct SuperVertex {
00085     Vertex_handle vertex; // NULL indicates inexistence...
00086     double NNdistance;
00087     int NNindex;
00088     // later on for cylinder put a second vertex?
00089   };
00090 
00091   std::vector<SuperVertex> _supervertex;
00092   //set<Vertex_handle> _vertex_set;
00093   bool _verbose;
00094 
00095   static const bool _crash_on_coincidence = true;
00096   //static const bool _crash_on_coincidence = false;
00097 
00098   Triangulation _TR; 
00099 
00102   inline double _euclid_distance(const Point& p1, const Point& p2) const {
00103     double distx= p1.x()-p2.x();
00104     double disty= p1.y()-p2.y();
00105     return distx*distx+disty*disty;
00106   }
00107 
00108   //---------------------------------------------------------------------- 
00111   void _SetNearest(const int & j);
00112 
00113   //----------------------------------------------------------------------
00123   void _SetAndUpdateNearest(const int & j, 
00124                             std::vector<int> & indices_of_updated_neighbours);
00125 
00129   void _CrashIfVertexPresent(const Vertex_handle & vertex, 
00130                              const int & its_index);
00131 
00132 };
00133 
00134 
00135 // here follow some inline implementations of the simpler of the
00136 // functions defined above
00137 
00138 inline int DnnPlane::NearestNeighbourIndex(const int & ii) const {
00139   return _supervertex[ii].NNindex;}
00140 
00141 inline double DnnPlane::NearestNeighbourDistance(const int & ii) const {
00142   return _supervertex[ii].NNdistance;}
00143 
00144 inline bool DnnPlane::Valid(const int & index) const {
00145   if (index >= 0 && index < static_cast<int>(_supervertex.size())) {
00146     return (_supervertex[index].vertex != NULL);} else {return false;} }
00147 
00148 inline EtaPhi DnnPlane::etaphi(const int i) const {
00149   Point * p = & (_supervertex[i].vertex->point());
00150   return EtaPhi(p->x(),p->y()); }
00151 
00152 inline double DnnPlane::eta(const int i) const {
00153   return _supervertex[i].vertex->point().x(); }
00154 
00155 inline double DnnPlane::phi(const int i) const {
00156   return _supervertex[i].vertex->point().y(); }
00157 
00158 
00159 FASTJET_END_NAMESPACE
00160 
00161 #endif //  __FASTJET_DNNPLANE_HH__
00162 
00163 #endif // DROP_CGAL

Generated on Tue Dec 18 17:05:02 2007 for fastjet by  doxygen 1.5.2