fastjet 2.4.5
CircularRange.hh
Go to the documentation of this file.
00001 //STARTHEADER
00002 // $Id: CircularRange.hh 1502 2009-04-06 10:33:14Z 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 __FASTJET_CIRCULARRANGE_HH__
00033 #define __FASTJET_CIRCULARRANGE_HH__
00034 
00035 #include "fastjet/RangeDefinition.hh"
00036 #include "fastjet/Error.hh"
00037 
00038 FASTJET_BEGIN_NAMESPACE      // defined in fastjet/internal/base.hh
00039 
00040 class CircularRange : public fastjet::RangeDefinition {
00041 public:
00043   CircularRange() {_set_invalid_rapphi();}
00044   
00046   CircularRange(const fastjet::PseudoJet & jet, double distance) {
00047                 _distance = distance;
00048                 _rapjet = jet.rap();
00049                 _phijet = jet.phi();
00050                 _total_area = fastjet::pi*_distance*_distance;  }
00051 
00053   CircularRange(double rap, double phi, double distance) {
00054                 _distance = distance;
00055                 _rapjet = rap;
00056                 _phijet = phi;
00057                 _total_area = fastjet::pi*_distance*_distance;  }
00058 
00060   CircularRange(double distance) {
00061                 _set_invalid_rapphi();
00062                 _distance = distance;
00063                 _total_area = fastjet::pi*_distance*_distance;  }
00064   
00066   virtual ~CircularRange() {}
00067   
00069   virtual inline std::string description() const {
00070     std::ostringstream ostr;
00071     ostr << "CircularRange: within distance "<< _distance << " of given jet or point." ;
00072     return ostr.str(); }
00073 
00076   virtual inline bool is_localizable() const { return true; }
00077   
00079   virtual inline bool is_in_range(double rap, double phi) const {
00080      if (! _rapphi_are_valid()) {
00081        throw Error("Circular range used without a center having being defined (use set_position())");
00082      }
00083      double deltaphi = _phijet - phi;
00084      if ( deltaphi > pi) { deltaphi -= twopi; }
00085      else if ( deltaphi < -pi) { deltaphi += twopi; }
00086      bool inrange = ( (rap-_rapjet)*(rap-_rapjet) +
00087                 deltaphi*deltaphi <= _distance*_distance );
00088      return inrange; }
00089 
00091   virtual inline void get_rap_limits(double & rapmin, double & rapmax) const {
00092      rapmin = _rapjet - _distance;
00093      rapmax = _rapjet + _distance; }
00094 
00095 private:
00096   double _distance;
00097 
00099   const static double _invalid_phi = -1000.0;
00101   void _set_invalid_rapphi() {_phijet = _invalid_phi;}
00103   bool _rapphi_are_valid() const {return _phijet != _invalid_phi;}
00104 
00105 };
00106 
00107 FASTJET_END_NAMESPACE
00108 
00109 #endif // __FASTJET_CIRCULARRANGE_HH__
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines