Back to home page

EIC code displayed by LXR

 
 

    


Warning, file /include/fastjet/internal/Dnn4piCylinder.hh was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

0001 //FJSTARTHEADER
0002 // $Id$
0003 //
0004 // Copyright (c) 2005-2025, Matteo Cacciari, Gavin P. Salam and Gregory Soyez
0005 //
0006 //----------------------------------------------------------------------
0007 // This file is part of FastJet.
0008 //
0009 //  FastJet is free software; you can redistribute it and/or modify
0010 //  it under the terms of the GNU General Public License as published by
0011 //  the Free Software Foundation; either version 2 of the License, or
0012 //  (at your option) any later version.
0013 //
0014 //  The algorithms that underlie FastJet have required considerable
0015 //  development. They are described in the original FastJet paper,
0016 //  hep-ph/0512210 and in the manual, arXiv:1111.6097. If you use
0017 //  FastJet as part of work towards a scientific publication, please
0018 //  quote the version you use and include a citation to the manual and
0019 //  optionally also to hep-ph/0512210.
0020 //
0021 //  FastJet is distributed in the hope that it will be useful,
0022 //  but WITHOUT ANY WARRANTY; without even the implied warranty of
0023 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
0024 //  GNU General Public License for more details.
0025 //
0026 //  You should have received a copy of the GNU General Public License
0027 //  along with FastJet. If not, see <http://www.gnu.org/licenses/>.
0028 //----------------------------------------------------------------------
0029 //FJENDHEADER
0030 
0031 #include "fastjet/config.h"
0032 
0033 #ifndef DROP_CGAL // in case we do not have the code for CGAL
0034 #ifndef __FASTJET_DNN4PICYLINDER_HH__
0035 #define __FASTJET_DNN4PICYLINDER_HH__
0036 
0037 #include "fastjet/internal/DynamicNearestNeighbours.hh"
0038 #include "fastjet/internal/DnnPlane.hh"
0039 #include "fastjet/internal/numconsts.hh"
0040 
0041 FASTJET_BEGIN_NAMESPACE      // defined in fastjet/internal/base.hh
0042 
0043 /// \if internal_doc
0044 /// @ingroup internal
0045 /// \class Dnn4piCylinder
0046 /// class derived from DynamicNearestNeighbours that provides an
0047 /// implementation for the surface of cylinder (using two copies of
0048 /// DnnPlane, one running from 0--2pi, the other from pi--3pi).
0049 /// \endif
0050 class Dnn4piCylinder : public DynamicNearestNeighbours {
0051  public:
0052   /// empty initaliser
0053   Dnn4piCylinder() {}
0054 
0055   /// Initialiser from a set of points on an Eta-Phi plane, where
0056   /// eta can have an arbitrary ranges and phi must be in range
0057   /// 0 <= phi < 2pi
0058   Dnn4piCylinder(const std::vector<EtaPhi> &, const bool & verbose = false );
0059 
0060   /// Returns the index of  the nearest neighbour of point labelled
0061   /// by ii (assumes ii is valid)
0062   int NearestNeighbourIndex(const int ii) const ;
0063 
0064   /// Returns the distance to the nearest neighbour of point labelled
0065   /// by index ii (assumes ii is valid)
0066   double NearestNeighbourDistance(const int ii) const ;
0067 
0068   /// Returns true iff the given index corresponds to a point that
0069   /// exists in the DNN structure (meaning that it has been added, and
0070   /// not removed in the meantime)
0071   bool Valid(const int index) const;
0072 
0073   void RemoveAndAddPoints(const std::vector<int> & indices_to_remove,
0074               const std::vector<EtaPhi> & points_to_add,
0075               std::vector<int> & indices_added,
0076               std::vector<int> & indices_of_updated_neighbours);
0077 
0078   ~Dnn4piCylinder();
0079 
0080  private:
0081 
0082   bool _verbose;
0083 
0084   // NB: we define POINTERS here because the initialisation gave
0085   //     us problems (things crashed!), perhaps because in practice
0086   //     we were making a copy without being careful and defining
0087   //     a proper copy constructor.
0088   DnnPlane * _DNN1, * _DNN2;
0089 
0090   /// given a phi value in the 0--2pi range return one 
0091   /// in the pi--3pi range.
0092   inline EtaPhi _remap_phi(const EtaPhi & point) {
0093     double phi = point.second;
0094     if (phi < pi) { phi += twopi ;}
0095     return EtaPhi(point.first, phi);}
0096 
0097 };
0098 
0099 
0100 // here follow some inline implementations of the simpler of the
0101 // functions defined above
0102 
0103 inline int Dnn4piCylinder::NearestNeighbourIndex(const int current) const {
0104   return (_DNN1->NearestNeighbourDistance(current) < 
0105       _DNN2->NearestNeighbourDistance(current)) ? 
0106     _DNN1->NearestNeighbourIndex(current) : 
0107     _DNN2->NearestNeighbourIndex(current) ; 
0108 }
0109 
0110 inline double Dnn4piCylinder::NearestNeighbourDistance(const int current) const {
0111   return (_DNN1->NearestNeighbourDistance(current) < 
0112       _DNN2->NearestNeighbourDistance(current)) ? 
0113     _DNN1->NearestNeighbourDistance(current) : 
0114     _DNN2->NearestNeighbourDistance(current) ; 
0115 }
0116 
0117 inline bool Dnn4piCylinder::Valid(const int index) const {
0118   return (_DNN1->Valid(index) && _DNN2->Valid(index));
0119 }
0120 
0121 
0122 inline Dnn4piCylinder::~Dnn4piCylinder() {
0123   delete _DNN1; 
0124   delete _DNN2;
0125 }
0126 
0127 
0128 FASTJET_END_NAMESPACE
0129 
0130 #endif //  __FASTJET_DNN4PICYLINDER_HH__
0131 #endif //  DROP_CGAL