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 537 2007-04-02 18:16: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 // 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 <cmath>
00042 #include "fastjet/internal/numconsts.hh"
00043 
00044 FASTJET_BEGIN_NAMESPACE      // defined in fastjet/internal/base.hh
00045 
00046 //using namespace std;
00047 
00050 const double MaxRap = 1e5;
00051 
00054 class PseudoJet {
00055  public:
00056   PseudoJet() {};
00058   PseudoJet(const double px, const double py, const double pz, const double E);
00060   template <class L> PseudoJet(const L & some_four_vector) ;
00061 
00062   // first "const double &" says that result is a reference to the
00063   // stored value and that we will not change that stored value.
00064   //
00065   // second "const" says that "this" will not be modified by these
00066   // functions.
00067   inline double E()   const {return _E;};
00068   inline double e()   const {return _E;}; // like CLHEP
00069   inline double px()  const {return _px;};
00070   inline double py()  const {return _py;};
00071   inline double pz()  const {return _pz;};
00072 
00074   inline const double phi() const {return phi_02pi();};
00075 
00077   inline const double phi_std()  const {
00078     return _phi > pi ? _phi-twopi : _phi;};
00079 
00081   inline const double phi_02pi() const {return _phi;};
00082 
00085   inline double rap() const {return _rap;};
00086 
00088   inline double rapidity() const {return _rap;}; // like CLHEP
00089 
00091   inline double kt2() const {return _kt2;};
00093   inline double perp2() const {return _kt2;};  // like CLHEP
00095   inline double  perp() const {return sqrt(_kt2);};    // like CLHEP
00097   inline double  m2() const {return (_E+_pz)*(_E-_pz)-_kt2;};    
00099   inline double mperp2() const {return (_E+_pz)*(_E-_pz);};
00101   inline double mperp() const {return sqrt(std::abs(mperp2()));};
00104   inline double  m() const;    
00106   double operator () (int i) const ; 
00108   inline double operator [] (int i) const { return (*this)(i); }; // this too
00109 
00110   // taken from CLHEP
00111   enum { X=0, Y=1, Z=2, T=3, NUM_COORDINATES=4, SIZE=NUM_COORDINATES };
00112 
00113 
00116   PseudoJet & boost(const PseudoJet & prest);
00119   PseudoJet & unboost(const PseudoJet & prest);
00120 
00123   inline const int & cluster_hist_index() const {return _cluster_hist_index;};
00125   inline void set_cluster_hist_index(const int index) {_cluster_hist_index = index;};
00126 
00128   inline const int cluster_sequence_history_index() const {
00129     return cluster_hist_index();};
00132   inline void set_cluster_sequence_history_index(const int index) {
00133     set_cluster_hist_index(index);};
00134 
00135 
00137   inline const int & user_index() const {return _user_index;};
00139   inline void set_user_index(const int index) {_user_index = index;};
00140 
00143   std::valarray<double> four_mom() const;
00144 
00146   double kt_distance(const PseudoJet & other) const;
00147 
00149   double plain_distance(const PseudoJet & other) const;
00152   inline double squared_distance(const PseudoJet & other) const {
00153     return plain_distance(other);};
00154 
00156   //friend inline double 
00157   //  kt_distance(const PseudoJet & jet1, const PseudoJet & jet2) { 
00158   //                                      return jet1.kt_distance(jet2);};
00159 
00161   inline double beam_distance() const {return _kt2;};
00162 
00163 
00164   void operator*=(double);
00165   void operator/=(double);
00166   void operator+=(const PseudoJet &);
00167   void operator-=(const PseudoJet &);
00168 
00169  private: 
00170   // NB: following order must be kept for things to behave sensibly...
00171   double _px,_py,_pz,_E;
00172   double _phi, _rap, _kt2; 
00173   int    _cluster_hist_index, _user_index;
00174   void _finish_init();
00175   //vertex_type * vertex0, vertex1;
00176 };
00177 
00178 
00179 //----------------------------------------------------------------------
00180 // routines for basic binary operations
00181 
00182 PseudoJet operator+(const PseudoJet &, const PseudoJet &);
00183 PseudoJet operator-(const PseudoJet &, const PseudoJet &);
00184 PseudoJet operator*(double, const PseudoJet &);
00185 PseudoJet operator*(const PseudoJet &, double);
00186 PseudoJet operator/(const PseudoJet &, double);
00187 
00189 bool have_same_momentum(const PseudoJet &, const PseudoJet &);
00190 
00191 //----------------------------------------------------------------------
00192 // Routines to do with providing sorted arrays of vectors.
00193 
00195 std::vector<PseudoJet> sorted_by_pt(const std::vector<PseudoJet> & jets);
00196 
00198 std::vector<PseudoJet> sorted_by_rapidity(const std::vector<PseudoJet> & jets);
00199 
00201 std::vector<PseudoJet> sorted_by_E(const std::vector<PseudoJet> & jets);
00202 
00203 //----------------------------------------------------------------------
00204 // some code to help sorting
00205 
00208 void sort_indices(std::vector<int> & indices, 
00209                   const std::vector<double> & values);
00210 
00215 template<class T> std::vector<T> objects_sorted_by_values(const std::vector<T> & objects, 
00216                                               const std::vector<double> & values);
00217 
00219 class IndexedSortHelper {
00220 public:
00221   inline IndexedSortHelper (const std::vector<double> * reference_values) {
00222     _ref_values = reference_values;
00223   };
00224   inline int operator() (const int & i1, const int & i2) const {
00225     return  (*_ref_values)[i1] < (*_ref_values)[i2];
00226   };
00227 private:
00228   const std::vector<double> * _ref_values;
00229 };
00230 
00231 
00232 //----------------------------------------------------------------------
00234 // NB: do not know if it really needs to be inline, but when it wasn't
00235 //     linking failed with g++ (who knows what was wrong...)
00236 template <class L> inline  PseudoJet::PseudoJet(const L & some_four_vector) {
00237 
00238   _px = some_four_vector[0];
00239   _py = some_four_vector[1];
00240   _pz = some_four_vector[2];
00241   _E  = some_four_vector[3];
00242   this->_finish_init();
00243   // some default values for these two indices
00244   set_cluster_hist_index(-1);
00245   set_user_index(-1);
00246 }
00247 
00248 
00256 
00257 // taken literally from CLHEP
00258 inline double PseudoJet::m() const {
00259   double mm = m2();
00260   return mm < 0.0 ? -std::sqrt(-mm) : std::sqrt(mm);
00261 }
00262 
00263 
00264 FASTJET_END_NAMESPACE
00265 
00266 #endif // __FASTJET_PSEUDOJET_HH__

Generated on Mon Apr 2 20:57:48 2007 for fastjet by  doxygen 1.4.2