00001
00002
00003 #ifndef STETAPHICELL_H
00004 #define STETAPHICELL_H
00005
00006 #include "StProtoJet.h"
00007
00008 #include <vector>
00009 #include <list>
00010 #include <iostream>
00011
00012 double deltaphi(double p1, double p2);
00013
00014 class StEtaPhiCell {
00015
00016 public:
00017
00018 typedef std::list<StProtoJet> JetList;
00019 typedef StProtoJet::FourVecList FourList;
00020 typedef std::list<StEtaPhiCell*> CellList;
00021
00022 StEtaPhiCell();
00023 StEtaPhiCell(double etaMin, double etaMax, double phiMin, double phiMax);
00024 virtual ~StEtaPhiCell();
00025
00026 virtual StEtaPhiCell* clone() const = 0;
00027
00028 bool isSamePosition(const StEtaPhiCell& other) const {
00029 return (mEtaMin == other.mEtaMin
00030 && mEtaMax == other.mEtaMax
00031 && mPhiMin == other.mPhiMin
00032 && mPhiMax == other.mPhiMax);
00033 }
00034
00035 virtual double eT() const { return mEt; }
00036
00037 StProtoJet& protoJet() {return mProtoJet;}
00038
00039 bool empty() const {return mProtoJet.size() == 0;}
00040
00041 void setNtimesUsed(int v) { mNtimesUsed = v; }
00042 int nTimesUsed() const { return mNtimesUsed; }
00043
00044 const StProtoJet& centroid();
00045
00046 double eta() const { return (mEtaMax+mEtaMin)/2.; }
00047 double phi() const { return (mPhiMax+mPhiMin)/2.; }
00048
00049 virtual void clear();
00050
00051 void setEt(double v) { mEt = v; }
00052 double Et() const { return mEt; }
00053
00054 void update() {
00055 protoJet().update();
00056 mEt = protoJet().eT();
00057 }
00058
00059 CellList& cellList() { return mCells; }
00060 const CellList& cellList() const { return mCells; }
00061
00062 virtual void addCell(StEtaPhiCell* cell);
00063
00064 virtual void addProtoJet(const StProtoJet&);
00065
00066 double distance(const StEtaPhiCell& rhs) const;
00067
00068 protected:
00069
00070 int mNtimesUsed;
00071 double mEt;
00072 bool mUpToDate;
00073 CellList mCells;
00074 StProtoJet mProtoJet;
00075
00076 private:
00077
00078 double deltaPhi(const StEtaPhiCell& rhs) const { return deltaphi( phi(), rhs.phi() ); }
00079 double deltaEta(const StEtaPhiCell& rhs) const { return eta()-rhs.eta(); }
00080
00081 friend std::ostream& operator<<(std::ostream& os, const StEtaPhiCell& cell);
00082 friend struct PostMergeUpdater;
00083
00084 double mEtaMin;
00085 double mEtaMax;
00086 double mPhiMin;
00087 double mPhiMax;
00088
00089 StProtoJet mCentroid;
00090
00091 };
00092
00093 struct StJetEtCellEtGreaterThan {
00094
00095 bool operator()(StEtaPhiCell* lhs, StEtaPhiCell* rhs)
00096 {
00097 return lhs->eT() > rhs->eT();
00098 }
00099
00100 };
00101
00102 inline std::ostream& operator<<(std::ostream& os, const StEtaPhiCell& cell)
00103 {
00104 os <<"eta: "<<cell.eta()<<"\tphi: "<<cell.phi()<<"\tet: "<<cell.eT()
00105
00106 <<"\tcells:"<< std::endl;
00107 const StEtaPhiCell::CellList& l = cell.cellList();
00108 for (StEtaPhiCell::CellList::const_iterator it=l.begin(); it!=l.end(); ++it) {
00109 std::cout <<**it;
00110 }
00111
00112 return os;
00113 }
00114
00115 #endif // STETAPHICELL_H