FastJet 3.0.2
CircularRange.hh
00001 //STARTHEADER
00002 // $Id: CircularRange.hh 2577 2011-09-13 15:11:38Z salam $
00003 //
00004 // Copyright (c) 2005-2011, Matteo Cacciari, Gavin P. Salam and Gregory Soyez
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, see <http://www.gnu.org/licenses/>.
00026 //----------------------------------------------------------------------
00027 //ENDHEADER
00028 
00029 
00030 #ifndef __FASTJET_CIRCULARRANGE_HH__
00031 #define __FASTJET_CIRCULARRANGE_HH__
00032 
00033 #include "fastjet/RangeDefinition.hh"
00034 #include "fastjet/Error.hh"
00035 
00036 // for backwards compatibility: one should now use SelectorCircle,
00037 // defined in fastjet/Selector.hh, instead CircularRange
00038 #warning This file includes fastjet/CircularRange.hh, \
00039 a deprecated FastJet header provided only for backward compatibility. \
00040 This is not guaranteed to work in future releases of FastJet. \
00041 From FastJet 3.0 onwards, please consider using Selector, defined in \
00042 fastjet/Selector.hh, instead of RangeDefinition and, in particular, \
00043 SelectorCircle instead of CircularRange.
00044 
00045 FASTJET_BEGIN_NAMESPACE      // defined in fastjet/internal/base.hh
00046 
00047 class CircularRange : public fastjet::RangeDefinition {
00048 public:
00049   /// constructor
00050   CircularRange() {_set_invalid_rapphi();}
00051   
00052   /// initialise CircularRange with a jet
00053   CircularRange(const fastjet::PseudoJet & jet, double distance) {
00054                 _distance = distance;
00055                 _rapjet = jet.rap();
00056                 _phijet = jet.phi();
00057                 _total_area = fastjet::pi*_distance*_distance;  }
00058 
00059   /// initialise CircularRange with a (rap,phi) point
00060   CircularRange(double rap, double phi, double distance) {
00061                 _distance = distance;
00062                 _rapjet = rap;
00063                 _phijet = phi;
00064                 _total_area = fastjet::pi*_distance*_distance;  }
00065 
00066   /// initialise CircularRange with just the radius parameter
00067   CircularRange(double distance) {
00068                 _set_invalid_rapphi();
00069                 _distance = distance;
00070                 _total_area = fastjet::pi*_distance*_distance;  }
00071   
00072   /// destructor
00073   virtual ~CircularRange() {}
00074   
00075   /// return description of range
00076   virtual inline std::string description() const {
00077     std::ostringstream ostr;
00078     ostr << "CircularRange: within distance "<< _distance << " of given jet or point." ;
00079     return ostr.str(); }
00080 
00081   /// returns true since this range is localizable (i.e. set_position
00082   /// does something meaningful)
00083   virtual inline bool is_localizable() const { return true; }
00084   
00085   /// return bool according to whether (rap,phi) is in range
00086   virtual inline bool is_in_range(double rap, double phi) const {
00087      if (! _rapphi_are_valid()) {
00088        throw Error("Circular range used without a center having being defined (use set_position())");
00089      }
00090      double deltaphi = _phijet - phi;
00091      if ( deltaphi > pi) { deltaphi -= twopi; }
00092      else if ( deltaphi < -pi) { deltaphi += twopi; }
00093      bool inrange = ( (rap-_rapjet)*(rap-_rapjet) +
00094                 deltaphi*deltaphi <= _distance*_distance );
00095      return inrange; }
00096 
00097   /// return the minimal and maximal rapidity of this range
00098   virtual inline void get_rap_limits(double & rapmin, double & rapmax) const {
00099      rapmin = _rapjet - _distance;
00100      rapmax = _rapjet + _distance; }
00101 
00102 private:
00103   double _distance;
00104 
00105   /// value for phi that marks it as invalid
00106   const static double _invalid_phi = -1000.0;
00107   /// set internal phi so as to mark things as invalid
00108   void _set_invalid_rapphi() {_phijet = _invalid_phi;}
00109   /// true if rap,phi are valid (tests only phi)
00110   bool _rapphi_are_valid() const {return _phijet != _invalid_phi;}
00111 };
00112 
00113 FASTJET_END_NAMESPACE
00114 
00115 #endif // __FASTJET_CIRCULARRANGE_HH__
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends