FastJet 3.0.2
ProtoJet.hpp
00001 #ifndef  D0RunIIconeJets_PROTOJET
00002 #define  D0RunIIconeJets_PROTOJET
00003 // ---------------------------------------------------------------------------
00004 // ProtoJet.hpp
00005 //
00006 // Created: 28-JUL-2000 Francois Touze (+ Laurent Duflot)
00007 //
00008 // Purpose: Implements a proto-jet object that is used as input by the 
00009 //   Improved Legacy Cone Algorithm split/merge algo.
00010 //
00011 // Modified:
00012 //    9-Aug-2000  Laurent Duflot
00013 //     + save the initial stable cone ET before split/merge
00014 //    1-May-2007 Lars Sonnenschein
00015 //    extracted from D0 software framework and modified to remove subsequent dependencies 
00016 //
00017 //
00018 // This file is distributed with FastJet under the terms of the GNU
00019 // General Public License (v2). Permission to do so has been granted
00020 // by Lars Sonnenschein and the D0 collaboration (see COPYING for
00021 // details)
00022 //
00023 // History of changes in FastJet compared tothe original version of
00024 // ProtoJet.hpp
00025 //
00026 // 2011-12-13  Gregory Soyez  <soyez@fastjet.fr>
00027 // 
00028 //        * added license information
00029 //
00030 // 2011-11-14  Gregory Soyez  <soyez@fastjet.fr>
00031 //
00032 //        * changed the name of a few parameters to avoid a gcc
00033 //          -Wshadow warning
00034 //
00035 // 2009-01-17  Gregory Soyez  <soyez@fastjet.fr>
00036 //
00037 //        * put the code in the fastjet::d0 namespace
00038 //
00039 // 2007-12-14  Gavin Salam  <salam@lpthe.jussieu.fr>
00040 // 
00041 //        * replaced make_pair by std::make_pair
00042 //
00043 // ---------------------------------------------------------------------------
00044  
00045 //#include "kinem_util/AnglesUtil.hpp"
00046 //#include "energycluster/ConeJetInfo.hpp"
00047 #include "ConeJetInfo.hpp"
00048 #include <list>
00049 #include <cmath>
00050 
00051 #include "inline_maths.h" //ls
00052 
00053 #include <fastjet/internal/base.hh>
00054 
00055 FASTJET_BEGIN_NAMESPACE
00056 
00057 namespace d0{
00058 
00059 using namespace inline_maths;
00060 using namespace D0RunIIconeJets_CONEJETINFO;
00061 
00062 
00063 inline float RD2(float y1,float phi1,float y2,float phi2) 
00064 {
00065   float dphi= delta_phi(phi1,phi2);
00066   return (y1-y2)*(y1-y2)+dphi*dphi; 
00067 }
00068 
00069 inline float RDelta(float y1,float phi1,float y2,float phi2) 
00070 {
00071   float dphi= delta_phi(phi1,phi2);
00072   return sqrt((y1-y2)*(y1-y2)+dphi*dphi); 
00073 }
00074 
00075 inline float P2y(float* p4vec) {
00076   return y(p4vec[3],p4vec[2]);
00077 }
00078 
00079 inline float P2phi(float* p4vec) {
00080   return phi(p4vec[0],p4vec[1]);
00081 }
00082 
00083 ///////////////////////////////////////////////////////////////////////////////
00084 template <class Item>
00085 class ProtoJet {
00086 
00087 public :
00088 
00089   ProtoJet(float seedET);
00090   ProtoJet(float seedET,float y,float phi);
00091   ProtoJet(const ProtoJet<Item>& pj);
00092   ~ProtoJet() {;}
00093 
00094   void addItem(const Item* tw); 
00095   void setJet(float y,float phi,float pT); 
00096   void updateJet();
00097   void erase();
00098 
00099   float y() const; 
00100   float phi() const;
00101   float pT() const;
00102   const ConeJetInfo & info() const;
00103   const std::list<const Item*>& LItems() const;
00104 
00105   void print(std::ostream &os) const;
00106 
00107   // actions to be taken when the jet is a stable cone
00108   void NowStable();
00109   // declare the jet to have been splitted
00110   void splitted(){_info.splitted();};
00111   // declare the jet to have been merged
00112   void merged(){_info.merged();};
00113 protected :
00114 
00115   std::list<const Item*> _LItems;
00116   float _y;
00117   float _phi;
00118   float _pT;
00119   ConeJetInfo _info;
00120 
00121 };
00122 ///////////////////////////////////////////////////////////////////////////////
00123 template<class Item>
00124 ProtoJet<Item>::ProtoJet(float seedET) : _LItems(), _info(seedET) {
00125     _y  = 0.0;
00126     _phi= 0.0;
00127     _pT = 0.0;
00128 }
00129 
00130 template<class Item>
00131 ProtoJet<Item>::ProtoJet(float seedET,float y_in,float phi_in) :  _LItems(), _info(seedET) { 
00132   _y  = y_in; 
00133   _phi= phi_in;
00134   _pT = 0.0;
00135 }
00136 
00137 template<class Item>
00138 ProtoJet<Item>::ProtoJet(const ProtoJet<Item>& pj): _y(pj._y), 
00139                                                     _phi(pj._phi), _pT(pj._pT),
00140                                                     _info(pj._info)
00141 { 
00142   typename std::list<const Item*>::const_iterator it;
00143   for(it = pj._LItems.begin(); it != pj._LItems.end(); ++it) { 
00144     _LItems.push_back(*it);
00145   }
00146 }
00147 
00148 template<class Item>
00149 void ProtoJet<Item>::addItem(const Item* tw) {
00150   _LItems.push_back(tw);
00151 }
00152 
00153 template<class Item>
00154 void ProtoJet<Item>::setJet(float y_in,float phi_in,float pT_in) {
00155   _y  = y_in;
00156   _phi= phi_in;
00157   _pT = pT_in;
00158 }
00159 
00160 template<class Item>
00161 void ProtoJet<Item>::updateJet() { 
00162   //float ETsum = 0.0;
00163   //float ysum  = 0.0;
00164   //float PHIsum= 0.0;
00165   float p[4] = {0.,0.,0.,0.};
00166   typename std::list<const Item*>::iterator it;
00167   for(it = _LItems.begin(); it != _LItems.end(); ++it) 
00168   {
00169     float pk[4];
00170     (*it)->p4vec(pk);
00171     //cout << "updateJet: px=" << pk[0] << " py=" << pk[1] << " pz=" << pk[2] << " E=" << pk[3] << endl; 
00172     for ( int i = 0; i < 4 ; ++i) p[i] += pk[i];
00173   }
00174   _y = P2y(p);
00175   _phi = P2phi(p);
00176   _pT = sqrt(p[0]*p[0] + p[1]*p[1]);
00177   if ( p[3] < 0. ) _pT = - _pT;
00178 
00179 }
00180 
00181 template<class Item>
00182 void ProtoJet<Item>::erase() {
00183   _LItems.erase(_LItems.begin(),_LItems.end());
00184   _y  = 0.0;
00185   _phi= 0.0;
00186   _pT = 0.0; 
00187   // _info is not modified in order to keep split/merge history
00188 }
00189 
00190 // actions to be taken when the jet is a stable cone
00191 template<class Item>
00192 void ProtoJet<Item>::NowStable() {
00193   _info.initialET(_pT);
00194 }
00195 
00196 template<class Item>
00197 void ProtoJet<Item>::print(std::ostream& os) const {
00198   os<<"y phi Et = ("<<_y<<", "<<_phi<<", "<<this->_Et<<")"<<std::endl;
00199   os<< " members= " << std::endl;
00200   typename std::list<const Item*>::const_iterator i;
00201   for(i = _LItems.begin(); i != _LItems.end(); ++i)
00202     (*i)->print(os);
00203   os << std::endl;
00204 }
00205 
00206 template<class Item>
00207 inline float ProtoJet<Item>::y() const{
00208   return _y;
00209 }
00210 
00211 template<class Item>
00212 inline float ProtoJet<Item>::phi() const{
00213   return _phi;
00214 }
00215 
00216 template<class Item>
00217 inline float ProtoJet<Item>::pT() const{
00218   return _pT;
00219 }
00220 template<class Item>
00221 inline const ConeJetInfo & ProtoJet<Item>::info() const{
00222   return _info;
00223 }
00224 
00225 template<class Item>   
00226 inline const std::list<const Item*>& ProtoJet<Item>::LItems() const{
00227   return _LItems;
00228 }
00229 ///////////////////////////////////////////////////////////////////////////////
00230 
00231 }  // namespace d0
00232 
00233 FASTJET_END_NAMESPACE
00234 
00235 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends