00001
00002 #ifndef RIVET_TrackJet_HH
00003 #define RIVET_TrackJet_HH
00004
00005 #include "Rivet/Projection.hh"
00006 #include "Rivet/Projections/FinalState.hh"
00007 #include "Rivet/RivetCLHEP.hh"
00008
00009
00010
00011
00012
00013 namespace Rivet {
00014
00015 namespace {
00016
00017 inline double pT2(const LorentzVector& lv) {
00018 return lv.x()*lv.x() + lv.y()*lv.y();
00019 }
00020
00021
00022 inline double pT(const LorentzVector& lv) {
00023 return sqrt(pT2(lv));
00024 }
00025 }
00026
00027
00028
00029 class TrackJet : public Projection {
00030 public:
00031
00032
00033
00034
00035
00036
00037 inline TrackJet(FinalState& fsp)
00038 : _fsproj(&fsp)
00039 {
00040 addProjection(fsp);
00041 }
00042
00043
00044 typedef list<LorentzVector> Tracks;
00045
00046
00047 public:
00048
00049
00050 class Jet {
00051 public:
00052
00053 inline Jet() {
00054 clear();
00055 }
00056
00057
00058 typedef vector<LorentzVector>::iterator iterator;
00059
00060
00061 typedef vector<LorentzVector>::const_iterator const_iterator;
00062
00063
00064 inline iterator begin() {
00065 return _particles.begin();
00066 }
00067
00068
00069 inline iterator end() {
00070 return _particles.end();
00071 }
00072
00073
00074 inline const_iterator begin() const {
00075 return _particles.begin();
00076 }
00077
00078
00079 inline const_iterator end() const {
00080 return _particles.end();
00081 }
00082
00083
00084 inline vector<LorentzVector>& getParticles() {
00085 return _particles;
00086 }
00087
00088
00089 inline const vector<LorentzVector>& getParticles() const {
00090 return _particles;
00091 }
00092
00093
00094 inline Jet setParticles(vector<LorentzVector> particles) {
00095 _particles = particles;
00096 _resetCaches();
00097 return *this;
00098 }
00099
00100
00101 inline Jet addParticle(LorentzVector particle) {
00102 _particles.push_back(particle);
00103 _resetCaches();
00104 return *this;
00105 }
00106
00107
00108 inline Jet clear() {
00109 _particles.clear();
00110 _resetCaches();
00111 return *this;
00112 }
00113
00114
00115
00116 inline double getPtWeightedPhi() const {
00117 if (_ptWeightedPhi < 0) {
00118 double ptwphi(0.0), ptsum(0.0);
00119 for (const_iterator p = this->begin(); p != this->end(); ++p) {
00120 double pt = pT(*p);
00121 ptwphi += pt * p->phi();
00122 ptsum += pt;
00123 }
00124 _totalPt = ptsum;
00125 _ptWeightedPhi = ptwphi / getPtSum();
00126 }
00127 return _ptWeightedPhi;
00128 }
00129
00130
00131 inline double getPtSum() const {
00132 if (_totalPt < 0) {
00133 double ptsum(0.0);
00134 for (const_iterator p = this->begin(); p != this->end(); ++p) {
00135 ptsum += pT(*p);
00136 }
00137 _totalPt = ptsum;
00138 }
00139 return _totalPt;
00140 }
00141
00142
00143 inline size_t getNumParticles() const {
00144 return _particles.size();
00145 }
00146
00147
00148 private:
00149
00150
00151 inline Jet _resetCaches() {
00152 _totalPt = -1.0;
00153 _ptWeightedPhi = -1.0;
00154 return *this;
00155 }
00156
00157
00158 vector<LorentzVector> _particles;
00159
00160
00161 mutable double _ptWeightedPhi;
00162
00163
00164 mutable double _totalPt;
00165 };
00166
00167
00168
00169 typedef vector<Jet> Jets;
00170
00171
00172 public:
00173
00174 inline string getName() const {
00175 return "TrackJet";
00176 }
00177
00178
00179 inline Jets& getJets() {
00180 return _jets;
00181 }
00182
00183
00184 inline const Jets& getJets() const {
00185 return _jets;
00186 }
00187
00188 protected:
00189
00190
00191
00192 void project(const Event& e);
00193
00194
00195 int compare(const Projection& p) const;
00196
00197 private:
00198
00199
00200 FinalState* _fsproj;
00201
00202
00203 Jets _jets;
00204
00205 private:
00206
00207
00208
00209
00210 };
00211
00212
00213
00214 namespace {
00215
00216 inline bool compareVecsByPt(const LorentzVector& first, const LorentzVector& second) {
00217 return pT2(first) > pT2(second);
00218 }
00219
00220
00221 inline bool compareJetsByPt(const TrackJet::Jet& first, const TrackJet::Jet& second) {
00222 return first.getPtSum() > second.getPtSum();
00223 }
00224 }
00225
00226
00227
00228 }
00229
00230 #endif