Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-30 10:06:45

0001 //FJSTARTHEADER
0002 // $Id$
0003 //
0004 // Copyright (c) 2005-2021, 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 
0032 #ifndef DROP_CGAL // in case we do not have the code for CGAL
0033 #ifndef __FASTJET_DNN4PICYLINDER_HH__
0034 #define __FASTJET_DNN4PICYLINDER_HH__
0035 
0036 #include "fastjet/internal/DynamicNearestNeighbours.hh"
0037 #include "fastjet/internal/DnnPlane.hh"
0038 #include "fastjet/internal/numconsts.hh"
0039 
0040 FASTJET_BEGIN_NAMESPACE      // defined in fastjet/internal/base.hh
0041 
0042 /// \if internal_doc
0043 /// @ingroup internal
0044 /// \class Dnn4piCylinder
0045 /// class derived from DynamicNearestNeighbours that provides an
0046 /// implementation for the surface of cylinder (using two copies of
0047 /// DnnPlane, one running from 0--2pi, the other from pi--3pi).
0048 /// \endif
0049 class Dnn4piCylinder : public DynamicNearestNeighbours {
0050  public:
0051   /// empty initaliser
0052   Dnn4piCylinder() {}
0053 
0054   /// Initialiser from a set of points on an Eta-Phi plane, where
0055   /// eta can have an arbitrary ranges and phi must be in range
0056   /// 0 <= phi < 2pi
0057   Dnn4piCylinder(const std::vector<EtaPhi> &, const bool & verbose = false );
0058 
0059   /// Returns the index of  the nearest neighbour of point labelled
0060   /// by ii (assumes ii is valid)
0061   int NearestNeighbourIndex(const int ii) const ;
0062 
0063   /// Returns the distance to the nearest neighbour of point labelled
0064   /// by index ii (assumes ii is valid)
0065   double NearestNeighbourDistance(const int ii) const ;
0066 
0067   /// Returns true iff the given index corresponds to a point that
0068   /// exists in the DNN structure (meaning that it has been added, and
0069   /// not removed in the meantime)
0070   bool Valid(const int index) const;
0071 
0072   void RemoveAndAddPoints(const std::vector<int> & indices_to_remove,
0073               const std::vector<EtaPhi> & points_to_add,
0074               std::vector<int> & indices_added,
0075               std::vector<int> & indices_of_updated_neighbours);
0076 
0077   ~Dnn4piCylinder();
0078 
0079  private:
0080 
0081   bool _verbose;
0082 
0083   // NB: we define POINTERS here because the initialisation gave
0084   //     us problems (things crashed!), perhaps because in practice
0085   //     we were making a copy without being careful and defining
0086   //     a proper copy constructor.
0087   DnnPlane * _DNN1, * _DNN2;
0088 
0089   /// given a phi value in the 0--2pi range return one 
0090   /// in the pi--3pi range.
0091   inline EtaPhi _remap_phi(const EtaPhi & point) {
0092     double phi = point.second;
0093     if (phi < pi) { phi += twopi ;}
0094     return EtaPhi(point.first, phi);}
0095 
0096 };
0097 
0098 
0099 // here follow some inline implementations of the simpler of the
0100 // functions defined above
0101 
0102 inline int Dnn4piCylinder::NearestNeighbourIndex(const int current) const {
0103   return (_DNN1->NearestNeighbourDistance(current) < 
0104       _DNN2->NearestNeighbourDistance(current)) ? 
0105     _DNN1->NearestNeighbourIndex(current) : 
0106     _DNN2->NearestNeighbourIndex(current) ; 
0107 }
0108 
0109 inline double Dnn4piCylinder::NearestNeighbourDistance(const int current) const {
0110   return (_DNN1->NearestNeighbourDistance(current) < 
0111       _DNN2->NearestNeighbourDistance(current)) ? 
0112     _DNN1->NearestNeighbourDistance(current) : 
0113     _DNN2->NearestNeighbourDistance(current) ; 
0114 }
0115 
0116 inline bool Dnn4piCylinder::Valid(const int index) const {
0117   return (_DNN1->Valid(index) && _DNN2->Valid(index));
0118 }
0119 
0120 
0121 inline Dnn4piCylinder::~Dnn4piCylinder() {
0122   delete _DNN1; 
0123   delete _DNN2;
0124 }
0125 
0126 
0127 FASTJET_END_NAMESPACE
0128 
0129 #endif //  __FASTJET_DNN4PICYLINDER_HH__
0130 #endif //  DROP_CGAL