File indexing completed on 2025-01-18 09:57:13
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025 #ifndef __FASTJET_CONTRIB_EVENTSTORAGE_HH__
0026 #define __FASTJET_CONTRIB_EVENTSTORAGE_HH__
0027
0028 #include "fastjet/PseudoJet.hh"
0029 #include <sstream>
0030
0031 FASTJET_BEGIN_NAMESPACE
0032
0033 namespace jwj {
0034
0035
0036
0037
0038
0039
0040
0041
0042
0043
0044
0045
0046
0047
0048
0049
0050
0051
0052
0053
0054
0055
0056 class ParticleStorage {
0057
0058 private:
0059
0060 PseudoJet _pj;
0061 double _rap,_phi,_pt,_m,_px,_py,_pt_in_Rjet,_pt_in_Rsub,_m_in_Rjet,_weight;
0062 bool _includeParticle;
0063 std::vector<unsigned int> _neighbors;
0064
0065 public:
0066
0067 ParticleStorage(){}
0068
0069
0070
0071
0072
0073 ParticleStorage(const PseudoJet & myParticle): _pj(myParticle),_rap(myParticle.rap()),_phi(myParticle.phi()),_pt(myParticle.pt()),_m(myParticle.m()),_px(myParticle.px()), _py(myParticle.py()),_pt_in_Rjet(0.0),_pt_in_Rsub(0.0),_m_in_Rjet(0.0),_weight(0.0),_includeParticle(false) {}
0074 ~ParticleStorage(){}
0075
0076
0077 const PseudoJet & pseudoJet() const {return _pj;}
0078 const double & rap() const {return _rap;}
0079 const double & phi() const {return _phi;}
0080 const double & pt() const {return _pt;}
0081 const double & m() const {return _m;}
0082 const double & px() const {return _px;}
0083 const double & py() const {return _py;}
0084
0085
0086 double deltaRsq(const ParticleStorage & other) const;
0087
0088
0089
0090
0091
0092 void set_pt_in_Rjet(const double & pt_in_Rjet) {_pt_in_Rjet=pt_in_Rjet;}
0093 const double & pt_in_Rjet() const {return _pt_in_Rjet;}
0094
0095
0096 void set_pt_in_Rsub(const double & pt_in_Rsub) {_pt_in_Rsub=pt_in_Rsub;}
0097 const double & pt_in_Rsub() const {return _pt_in_Rsub;}
0098
0099
0100 void set_m_in_Rjet(const double & m_in_Rjet) {_m_in_Rjet=m_in_Rjet;}
0101 const double & m_in_Rjet() const {return _m_in_Rjet;}
0102
0103
0104 void set_weight(const double & weight) {_weight=weight;}
0105 const double & weight() const {return _weight;}
0106
0107
0108 void set_includeParticle(const bool & includeParticle) {_includeParticle=includeParticle;}
0109 const bool & includeParticle() const {return _includeParticle;}
0110
0111
0112 void set_neighbors(const std::vector<unsigned int> & neighbors) {_neighbors=neighbors;}
0113 const std::vector<unsigned int> & neighbors() const {return _neighbors;}
0114
0115 };
0116
0117
0118
0119
0120
0121
0122
0123
0124
0125
0126
0127
0128
0129
0130
0131
0132 class LocalStorage {
0133
0134 private:
0135
0136 double _Rjet;
0137 double _ptcut;
0138
0139 public:
0140
0141 LocalStorage() : _Rjet(0.0) {
0142
0143 _rapmax = 10.0;
0144 }
0145
0146
0147 void establishStorage(const std::vector<ParticleStorage> & myParticles, double Rjet, double ptcut);
0148
0149
0150 const std::vector<unsigned int> & getStorageFor(const ParticleStorage & myParticle) const;
0151
0152
0153 bool aboveCutFor(const ParticleStorage & myParticle);
0154
0155 private:
0156
0157
0158 std::vector<std::vector<std::vector<unsigned int> > > _regionStorage;
0159
0160
0161 std::vector<std::vector<bool> > _aboveCutBool;
0162
0163 double _rapmax;
0164 int _maxRapIndex;
0165 double _rapSpread;
0166 int _maxPhiIndex;
0167 double _phiSpread;
0168
0169
0170 int getRapIndex(const ParticleStorage & myParticle) const;
0171 int getPhiIndex(const ParticleStorage & myParticle) const;
0172
0173
0174 double getSumPt(const std::vector<ParticleStorage> & Particles, const std::vector<unsigned int> myIds) const;
0175
0176 };
0177
0178
0179
0180
0181
0182
0183
0184
0185
0186
0187
0188
0189
0190
0191
0192 class EventStorage {
0193
0194 private:
0195
0196 double _Rjet,_ptcut,_Rsub,_fcut;
0197 std::vector<unsigned int> _ids;
0198 std::vector<ParticleStorage> _storage;
0199 bool _useLocalStorage;
0200 bool _storeNeighbors, _storeMass;
0201
0202 public:
0203
0204 EventStorage(){}
0205
0206
0207 EventStorage(double Rjet, double ptcut, double Rsub, double fcut, bool useLocalStorage=true, bool storeNeighbors=true, bool storeMass=false):
0208 _Rjet(Rjet), _ptcut(ptcut), _Rsub(Rsub), _fcut(fcut), _useLocalStorage(useLocalStorage), _storeNeighbors(storeNeighbors), _storeMass(storeMass) {}
0209
0210
0211
0212
0213
0214 EventStorage(double Rjet, double ptcut, bool useLocalStorage=true, bool storeNeighbors=true, bool storeMass=false):
0215 _Rjet(Rjet), _ptcut(ptcut), _Rsub(Rjet), _fcut(1.0), _useLocalStorage(useLocalStorage), _storeNeighbors(storeNeighbors), _storeMass(storeMass) {}
0216 ~EventStorage() {}
0217
0218
0219 void establishStorage(const std::vector<PseudoJet> & particles){
0220 _establishBasicStorage(particles);
0221 _establishDerivedStorage();
0222 }
0223
0224
0225 unsigned int size() const {return _storage.size();}
0226 const double & Rjet() const {return _Rjet;}
0227 const double & ptcut() const {return _ptcut;}
0228 const double & Rsub() const {return _Rsub;}
0229 const double & fcut() const {return _fcut;}
0230 const bool & storeNeighbors() const {return _storeNeighbors;}
0231 const bool & storeMass() const {return _storeMass;}
0232
0233
0234 ParticleStorage operator[](const unsigned int i) const {return _storage[i];}
0235
0236
0237 std::vector<PseudoJet> particles_near_to(const unsigned int id) const {
0238 std::vector<unsigned int> neighbors=_storage[id].neighbors();
0239 std::vector<PseudoJet> answer;
0240 for(unsigned int i=0; i<neighbors.size(); i++) answer.push_back(_storage[neighbors[i]].pseudoJet());
0241 return answer;
0242 }
0243
0244
0245 std::string parameterString() const {
0246 std::stringstream stream;
0247 stream << "R_jet=" << _Rjet << ", pT_cut=" << _ptcut << ", R_sub=" << _Rsub <<", fcut=" << _fcut;
0248 return stream.str();
0249 }
0250 std::string description() const {
0251 return "Event Storage with "+parameterString();
0252 }
0253
0254 private:
0255
0256 void _establishBasicStorage(const std::vector<PseudoJet> & particles);
0257 void _establishDerivedStorage();
0258 void _get_local_info(const unsigned int id, const std::vector<unsigned int>* myLocalRegion, double & pt_in_Rjet, double & pt_in_Rsub, double & m_in_Rjet, std::vector<unsigned int> & neighbors) const;
0259
0260 };
0261
0262 }
0263
0264 FASTJET_END_NAMESPACE
0265
0266 #endif