FastJet 3.0.1
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 // History of changes in FastJet compared tothe original version of
00019 // ProtoJet.hpp
00020 //
00021 // 2011-11-14  Gregory Soyez  <soyez@fastjet.fr>
00022 //
00023 //        * changed the name of a few parameters to avoid a gcc
00024 //          -Wshadow warning
00025 //
00026 // 2009-01-17  Gregory Soyez  <soyez@fastjet.fr>
00027 //
00028 //        * put the code in the fastjet::d0 namespace
00029 //
00030 // 2007-12-14  Gavin Salam  <salam@lpthe.jussieu.fr>
00031 // 
00032 //        * replaced make_pair by std::make_pair
00033  
00034 //#include "kinem_util/AnglesUtil.hpp"
00035 //#include "energycluster/ConeJetInfo.hpp"
00036 #include "ConeJetInfo.hpp"
00037 #include <list>
00038 #include <cmath>
00039 
00040 #include "inline_maths.h" //ls
00041 
00042 #include <fastjet/internal/base.hh>
00043 
00044 FASTJET_BEGIN_NAMESPACE
00045 
00046 namespace d0{
00047 
00048 using namespace inline_maths;
00049 using namespace D0RunIIconeJets_CONEJETINFO;
00050 
00051 
00052 inline float RD2(float y1,float phi1,float y2,float phi2) 
00053 {
00054   float dphi= delta_phi(phi1,phi2);
00055   return (y1-y2)*(y1-y2)+dphi*dphi; 
00056 }
00057 
00058 inline float RDelta(float y1,float phi1,float y2,float phi2) 
00059 {
00060   float dphi= delta_phi(phi1,phi2);
00061   return sqrt((y1-y2)*(y1-y2)+dphi*dphi); 
00062 }
00063 
00064 inline float P2y(float* p4vec) {
00065   return y(p4vec[3],p4vec[2]);
00066 }
00067 
00068 inline float P2phi(float* p4vec) {
00069   return phi(p4vec[0],p4vec[1]);
00070 }
00071 
00072 ///////////////////////////////////////////////////////////////////////////////
00073 template <class Item>
00074 class ProtoJet {
00075 
00076 public :
00077 
00078   ProtoJet(float seedET);
00079   ProtoJet(float seedET,float y,float phi);
00080   ProtoJet(const ProtoJet<Item>& pj);
00081   ~ProtoJet() {;}
00082 
00083   void addItem(const Item* tw); 
00084   void setJet(float y,float phi,float pT); 
00085   void updateJet();
00086   void erase();
00087 
00088   float y() const; 
00089   float phi() const;
00090   float pT() const;
00091   const ConeJetInfo & info() const;
00092   const std::list<const Item*>& LItems() const;
00093 
00094   void print(std::ostream &os) const;
00095 
00096   // actions to be taken when the jet is a stable cone
00097   void NowStable();
00098   // declare the jet to have been splitted
00099   void splitted(){_info.splitted();};
00100   // declare the jet to have been merged
00101   void merged(){_info.merged();};
00102 protected :
00103 
00104   std::list<const Item*> _LItems;
00105   float _y;
00106   float _phi;
00107   float _pT;
00108   ConeJetInfo _info;
00109 
00110 };
00111 ///////////////////////////////////////////////////////////////////////////////
00112 template<class Item>
00113 ProtoJet<Item>::ProtoJet(float seedET) : _LItems(), _info(seedET) {
00114     _y  = 0.0;
00115     _phi= 0.0;
00116     _pT = 0.0;
00117 }
00118 
00119 template<class Item>
00120 ProtoJet<Item>::ProtoJet(float seedET,float y_in,float phi_in) :  _LItems(), _info(seedET) { 
00121   _y  = y_in; 
00122   _phi= phi_in;
00123   _pT = 0.0;
00124 }
00125 
00126 template<class Item>
00127 ProtoJet<Item>::ProtoJet(const ProtoJet<Item>& pj): _y(pj._y), 
00128                                                     _phi(pj._phi), _pT(pj._pT),
00129                                                     _info(pj._info)
00130 { 
00131   typename std::list<const Item*>::const_iterator it;
00132   for(it = pj._LItems.begin(); it != pj._LItems.end(); ++it) { 
00133     _LItems.push_back(*it);
00134   }
00135 }
00136 
00137 template<class Item>
00138 void ProtoJet<Item>::addItem(const Item* tw) {
00139   _LItems.push_back(tw);
00140 }
00141 
00142 template<class Item>
00143 void ProtoJet<Item>::setJet(float y_in,float phi_in,float pT_in) {
00144   _y  = y_in;
00145   _phi= phi_in;
00146   _pT = pT_in;
00147 }
00148 
00149 template<class Item>
00150 void ProtoJet<Item>::updateJet() { 
00151   //float ETsum = 0.0;
00152   //float ysum  = 0.0;
00153   //float PHIsum= 0.0;
00154   float p[4] = {0.,0.,0.,0.};
00155   typename std::list<const Item*>::iterator it;
00156   for(it = _LItems.begin(); it != _LItems.end(); ++it) 
00157   {
00158     float pk[4];
00159     (*it)->p4vec(pk);
00160     //cout << "updateJet: px=" << pk[0] << " py=" << pk[1] << " pz=" << pk[2] << " E=" << pk[3] << endl; 
00161     for ( int i = 0; i < 4 ; ++i) p[i] += pk[i];
00162   }
00163   _y = P2y(p);
00164   _phi = P2phi(p);
00165   _pT = sqrt(p[0]*p[0] + p[1]*p[1]);
00166   if ( p[3] < 0. ) _pT = - _pT;
00167 
00168 }
00169 
00170 template<class Item>
00171 void ProtoJet<Item>::erase() {
00172   _LItems.erase(_LItems.begin(),_LItems.end());
00173   _y  = 0.0;
00174   _phi= 0.0;
00175   _pT = 0.0; 
00176   // _info is not modified in order to keep split/merge history
00177 }
00178 
00179 // actions to be taken when the jet is a stable cone
00180 template<class Item>
00181 void ProtoJet<Item>::NowStable() {
00182   _info.initialET(_pT);
00183 }
00184 
00185 template<class Item>
00186 void ProtoJet<Item>::print(std::ostream& os) const {
00187   os<<"y phi Et = ("<<_y<<", "<<_phi<<", "<<this->_Et<<")"<<std::endl;
00188   os<< " members= " << std::endl;
00189   typename std::list<const Item*>::const_iterator i;
00190   for(i = _LItems.begin(); i != _LItems.end(); ++i)
00191     (*i)->print(os);
00192   os << std::endl;
00193 }
00194 
00195 template<class Item>
00196 inline float ProtoJet<Item>::y() const{
00197   return _y;
00198 }
00199 
00200 template<class Item>
00201 inline float ProtoJet<Item>::phi() const{
00202   return _phi;
00203 }
00204 
00205 template<class Item>
00206 inline float ProtoJet<Item>::pT() const{
00207   return _pT;
00208 }
00209 template<class Item>
00210 inline const ConeJetInfo & ProtoJet<Item>::info() const{
00211   return _info;
00212 }
00213 
00214 template<class Item>   
00215 inline const std::list<const Item*>& ProtoJet<Item>::LItems() const{
00216   return _LItems;
00217 }
00218 ///////////////////////////////////////////////////////////////////////////////
00219 
00220 }  // namespace d0
00221 
00222 FASTJET_END_NAMESPACE
00223 
00224 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends