Main Page | Namespace List | Class Hierarchy | Class List | Directories | File List | Namespace Members | Class Members | File Members

PseudoJet.hh

Go to the documentation of this file.
00001 //STARTHEADER
00002 // $Id: PseudoJet.hh 331 2006-10-09 16:47:53Z 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 // NB: to do at some point
00033 //     - add += and *= operators
00034 
00035 #ifndef __FASTJET_PSEUDOJET_HH__
00036 #define __FASTJET_PSEUDOJET_HH__
00037 
00038 #include<valarray>
00039 #include<vector>
00040 #include<cassert>
00041 #include "fastjet/internal/numconsts.hh"
00042 
00043 FASTJET_BEGIN_NAMESPACE      // defined in fastjet/internal/base.hh
00044 
00045 //using namespace std;
00046 
00049 const double MaxRap = 1e5;
00050 
00053 class PseudoJet {
00054  public:
00055   PseudoJet() {};
00057   PseudoJet(const double px, const double py, const double pz, const double E);
00059   template <class L> PseudoJet(const L & some_four_vector) ;
00060 
00061   // first "const double &" says that result is a reference to the
00062   // stored value and that we will not change that stored value.
00063   //
00064   // second "const" says that "this" will not be modified by these
00065   // functions.
00066   inline double E()   const {return _E;};
00067   inline double e()   const {return _E;}; // like CLHEP
00068   inline double px()  const {return _px;};
00069   inline double py()  const {return _py;};
00070   inline double pz()  const {return _pz;};
00071 
00073   inline const double phi() const {return phi_02pi();};
00074 
00076   inline const double phi_std()  const {
00077     return _phi > pi ? _phi-twopi : pi;};
00078 
00080   inline const double phi_02pi() const {return _phi;};
00081 
00084   inline double rap() const {return _rap;};
00085 
00087   inline double rapidity() const {return _rap;}; // like CLHEP
00088 
00090   inline double kt2() const {return _kt2;};
00092   inline double perp2() const {return _kt2;};  // like CLHEP
00094   inline double  perp() const {return sqrt(_kt2);};    // like CLHEP
00096   inline double  m2() const {return (_E+_pz)*(_E-_pz)-_kt2;};    
00098   double operator () (int i) const ; 
00100   inline double operator [] (int i) const { return (*this)(i); }; // this too
00101 
00102   // taken from CLHEP
00103   enum { X=0, Y=1, Z=2, T=3, NUM_COORDINATES=4, SIZE=NUM_COORDINATES };
00104 
00105 
00108   inline const int & cluster_hist_index() const {return _cluster_hist_index;};
00110   inline void set_cluster_hist_index(const int index) {_cluster_hist_index = index;};
00111 
00113   inline const int & user_index() const {return _user_index;};
00115   inline void set_user_index(const int index) {_user_index = index;};
00116 
00119   std::valarray<double> four_mom() const;
00120 
00122   double kt_distance(const PseudoJet & other) const;
00123 
00125   double plain_distance(const PseudoJet & other) const;
00126 
00128   //friend inline double 
00129   //  kt_distance(const PseudoJet & jet1, const PseudoJet & jet2) { 
00130   //                                      return jet1.kt_distance(jet2);};
00131 
00133   inline double beam_distance() const {return _kt2;};
00134 
00135 
00136   void operator*=(double);
00137   void operator/=(double);
00138   void operator+=(const PseudoJet &);
00139   void operator-=(const PseudoJet &);
00140 
00141  private: 
00142   // NB: following order must be kept for things to behave sensibly...
00143   double _px,_py,_pz,_E;
00144   double _phi, _rap, _kt2; 
00145   int    _cluster_hist_index, _user_index;
00146   void _finish_init();
00147   //vertex_type * vertex0, vertex1;
00148 };
00149 
00150 
00151 //----------------------------------------------------------------------
00152 // routines for basic binary operations
00153 
00154 PseudoJet operator+(const PseudoJet &, const PseudoJet &);
00155 PseudoJet operator-(const PseudoJet &, const PseudoJet &);
00156 PseudoJet operator*(double, const PseudoJet &);
00157 PseudoJet operator*(const PseudoJet &, double);
00158 PseudoJet operator/(const PseudoJet &, double);
00159 
00160 
00161 
00162 //----------------------------------------------------------------------
00163 // Routines to do with providing sorted arrays of vectors.
00164 
00166 std::vector<PseudoJet> sorted_by_pt(const std::vector<PseudoJet> & jets);
00167 
00169 std::vector<PseudoJet> sorted_by_rapidity(const std::vector<PseudoJet> & jets);
00170 
00172 std::vector<PseudoJet> sorted_by_E(const std::vector<PseudoJet> & jets);
00173 
00174 //----------------------------------------------------------------------
00175 // some code to help sorting
00176 
00179 void sort_indices(std::vector<int> & indices, 
00180                   const std::vector<double> & values);
00181 
00186 template<class T> std::vector<T> objects_sorted_by_values(const std::vector<T> & objects, 
00187                                               const std::vector<double> & values);
00188 
00190 class IndexedSortHelper {
00191 public:
00192   inline IndexedSortHelper (const std::vector<double> * reference_values) {
00193     _ref_values = reference_values;
00194   };
00195   inline int operator() (const int & i1, const int & i2) const {
00196     return  (*_ref_values)[i1] < (*_ref_values)[i2];
00197   };
00198 private:
00199   const std::vector<double> * _ref_values;
00200 };
00201 
00202 
00203 //----------------------------------------------------------------------
00205 // NB: do not know if it really needs to be inline, but when it wasn't
00206 //     linking failed with g++ (who knows what was wrong...)
00207 template <class L> inline  PseudoJet::PseudoJet(const L & some_four_vector) {
00208 
00209   _px = some_four_vector[0];
00210   _py = some_four_vector[1];
00211   _pz = some_four_vector[2];
00212   _E  = some_four_vector[3];
00213   this->_finish_init();
00214 };
00215 
00216 
00224 
00225 
00226 FASTJET_END_NAMESPACE
00227 
00228 #endif // __FASTJET_PSEUDOJET_HH__

Generated on Thu Oct 12 17:36:34 2006 for fastjet by  doxygen 1.4.2