]> git.uio.no Git - u/mrichter/AliRoot.git/blob - JETAN/fastjet/fastjet/CircularRange.hh
added pdet-ppart over ppart histogram for detector response
[u/mrichter/AliRoot.git] / JETAN / fastjet / fastjet / CircularRange.hh
1 //STARTHEADER
2 // $Id: CircularRange.hh 1502 2009-04-06 10:33:14Z salam $
3 //
4 // Copyright (c) 2005-2006, Matteo Cacciari and Gavin Salam
5 //
6 //----------------------------------------------------------------------
7 // This file is part of FastJet.
8 //
9 //  FastJet is free software; you can redistribute it and/or modify
10 //  it under the terms of the GNU General Public License as published by
11 //  the Free Software Foundation; either version 2 of the License, or
12 //  (at your option) any later version.
13 //
14 //  The algorithms that underlie FastJet have required considerable
15 //  development and are described in hep-ph/0512210. If you use
16 //  FastJet as part of work towards a scientific publication, please
17 //  include a citation to the FastJet paper.
18 //
19 //  FastJet is distributed in the hope that it will be useful,
20 //  but WITHOUT ANY WARRANTY; without even the implied warranty of
21 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
22 //  GNU General Public License for more details.
23 //
24 //  You should have received a copy of the GNU General Public License
25 //  along with FastJet; if not, write to the Free Software
26 //  Foundation, Inc.:
27 //      59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
28 //----------------------------------------------------------------------
29 //ENDHEADER
30
31
32 #ifndef __FASTJET_CIRCULARRANGE_HH__
33 #define __FASTJET_CIRCULARRANGE_HH__
34
35 #include "fastjet/RangeDefinition.hh"
36 #include "fastjet/Error.hh"
37
38 namespace fastjet {      // defined in fastjet/internal/base.hh
39
40 class CircularRange : public fastjet::RangeDefinition {
41 public:
42   /// constructor
43   CircularRange() {_set_invalid_rapphi();}
44   
45   /// initialise CircularRange with a jet
46   CircularRange(const fastjet::PseudoJet & jet, double distance) {
47                 _distance = distance;
48                 _rapjet = jet.rap();
49                 _phijet = jet.phi();
50                 _total_area = fastjet::pi*_distance*_distance;  }
51
52   /// initialise CircularRange with a (rap,phi) point
53   CircularRange(double rap, double phi, double distance) {
54                 _distance = distance;
55                 _rapjet = rap;
56                 _phijet = phi;
57                 _total_area = fastjet::pi*_distance*_distance;  }
58
59   /// initialise CircularRange with just the radius parameter
60   CircularRange(double distance) {
61                 _set_invalid_rapphi();
62                 _distance = distance;
63                 _total_area = fastjet::pi*_distance*_distance;  }
64   
65   /// destructor
66   virtual ~CircularRange() {}
67   
68   /// return description of range
69   virtual inline std::string description() const {
70     std::ostringstream ostr;
71     ostr << "CircularRange: within distance "<< _distance << " of given jet or point." ;
72     return ostr.str(); }
73
74   /// returns true since this range is localizable (i.e. set_position
75   /// does something meaningful)
76   virtual inline bool is_localizable() const { return true; }
77   
78   /// return bool according to whether (rap,phi) is in range
79   virtual inline bool is_in_range(double rap, double phi) const {
80      if (! _rapphi_are_valid()) {
81        throw Error("Circular range used without a center having being defined (use set_position())");
82      }
83      double deltaphi = _phijet - phi;
84      if ( deltaphi > pi) { deltaphi -= twopi; }
85      else if ( deltaphi < -pi) { deltaphi += twopi; }
86      bool inrange = ( (rap-_rapjet)*(rap-_rapjet) +
87                 deltaphi*deltaphi <= _distance*_distance );
88      return inrange; }
89
90   /// return the minimal and maximal rapidity of this range
91   virtual inline void get_rap_limits(double & rapmin, double & rapmax) const {
92      rapmin = _rapjet - _distance;
93      rapmax = _rapjet + _distance; }
94
95 private:
96   double _distance;
97
98   /// value for phi that marks it as invalid
99   const static double _invalid_phi = -1000.0;
100   /// set internal phi so as to mark things as invalid
101   void _set_invalid_rapphi() {_phijet = _invalid_phi;}
102   /// true if rap,phi are valid (tests only phi)
103   bool _rapphi_are_valid() const {return _phijet != _invalid_phi;}
104
105 };
106
107 } // fastjet namespace 
108
109 #endif // __FASTJET_CIRCULARRANGE_HH__