00001 00002 #ifndef L1GCTPROCESSOR_H_ 00003 #define L1GCTPROCESSOR_H_ 00004 00020 #include <vector> 00021 00022 class L1GctProcessor { 00023 00024 public: 00025 00026 L1GctProcessor() : m_verbose(false), m_bx(0), m_bxStart(0), m_numOfBx(1) {}; 00027 virtual ~L1GctProcessor() {}; 00028 00030 inline void reset() { 00031 m_bxStart = 0; 00032 m_numOfBx = 1; 00033 m_bx = 0; 00034 resetPipelines(); 00035 resetProcessor(); 00036 setupObjects(); 00037 } 00038 00040 virtual void fetchInput() = 0; 00041 00043 virtual void process() = 0; 00044 00046 inline void setBxRange(const int firstBx, const int numberOfBx) { 00047 m_bxStart = firstBx; 00048 m_numOfBx = numberOfBx; 00049 resetPipelines(); 00050 } 00051 00053 inline void setNextBx(const int bxnum) { 00054 if ( (bxnum-m_bxStart >= 0) && (bxnum-m_bxStart < m_numOfBx) ) { 00055 m_bx = bxnum; 00056 } else { 00057 m_bx = 0; 00058 } 00059 resetProcessor(); 00060 setupObjects(); 00061 } 00062 00064 bool setupOk() const { return true; } 00065 00067 void setVerbose() { m_verbose = true; } 00068 void setTerse() { m_verbose = false; } 00069 00070 protected: 00071 00073 virtual void resetProcessor() = 0; 00074 virtual void resetPipelines() = 0; 00075 00077 virtual void setupObjects() = 0; 00078 00080 inline int bxMin() const { return m_bxStart; } 00081 inline int bxMax() const { return (m_bxStart + m_numOfBx - 1); } 00082 inline int numOfBx() const { return m_numOfBx; } 00083 inline int bxAbs() const { return m_bx; } 00084 inline int bxRel() const { return (m_bx - m_bxStart); } 00085 00086 template <class T> 00087 struct Pipeline { 00088 00089 std::vector<T> contents; 00090 unsigned entriesPerBx; 00091 00092 Pipeline() : contents(1), entriesPerBx(1) {} 00093 Pipeline(const unsigned size) : contents(size), entriesPerBx(size) {} 00094 00095 void resize(const unsigned size) { 00096 entriesPerBx = size; 00097 } 00098 00099 void reset(const unsigned nBx) { 00100 contents.clear(); 00101 contents.resize(nBx*entriesPerBx); 00102 } 00103 00104 void store(const T& thisBx, const int bxNum) { 00105 contents.at(bxNum) = thisBx; 00106 } 00107 00108 void store(const std::vector<T>& thisBx, const int bxNum) { 00109 unsigned pos = entriesPerBx*bxNum; 00110 for (unsigned i=0; i<entriesPerBx; i++) { 00111 contents.at(pos++) = thisBx.at(i); 00112 } 00113 } 00114 }; 00115 00117 bool m_verbose; 00118 00119 private: 00121 int m_bx; 00123 int m_bxStart; 00124 int m_numOfBx; 00125 }; 00126 00127 #endif