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