CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
L1GctProcessor.h
Go to the documentation of this file.
1 
2 #ifndef L1GCTPROCESSOR_H_
3 #define L1GCTPROCESSOR_H_
4 
20 #include <vector>
21 
23 public:
25  virtual ~L1GctProcessor(){};
26 
28  inline void reset() {
29  m_bxStart = 0;
30  m_numOfBx = 1;
31  m_bx = 0;
34  setupObjects();
35  }
36 
38  virtual void fetchInput() = 0;
39 
41  virtual void process() = 0;
42 
44  inline void setBxRange(const int firstBx, const int numberOfBx) {
45  m_bxStart = firstBx;
46  m_numOfBx = numberOfBx;
48  }
49 
51  inline void setNextBx(const int bxnum) {
52  if ((bxnum - m_bxStart >= 0) && (bxnum - m_bxStart < m_numOfBx)) {
53  m_bx = bxnum;
54  } else {
55  m_bx = 0;
56  }
58  setupObjects();
59  }
60 
62  bool setupOk() const { return true; }
63 
65  void setVerbose() { m_verbose = true; }
66  void setTerse() { m_verbose = false; }
67 
68 protected:
70  virtual void resetProcessor() = 0;
71  virtual void resetPipelines() = 0;
72 
74  virtual void setupObjects() = 0;
75 
77  inline int bxMin() const { return m_bxStart; }
78  inline int bxMax() const { return (m_bxStart + m_numOfBx - 1); }
79  inline int numOfBx() const { return m_numOfBx; }
80  inline int bxAbs() const { return m_bx; }
81  inline int bxRel() const { return (m_bx - m_bxStart); }
82 
83  template <class T>
84  struct Pipeline {
85  std::vector<T> contents;
86  unsigned entriesPerBx;
87 
89  Pipeline(const unsigned size) : contents(size), entriesPerBx(size) {}
90 
91  void resize(const unsigned size) { entriesPerBx = size; }
92 
93  void reset(const unsigned nBx) {
94  contents.clear();
95  contents.resize(nBx * entriesPerBx);
96  }
97 
98  void store(const T& thisBx, const int bxNum) { contents.at(bxNum) = thisBx; }
99 
100  void store(const std::vector<T>& thisBx, const int bxNum) {
101  unsigned pos = entriesPerBx * bxNum;
102  for (unsigned i = 0; i < entriesPerBx; i++) {
103  contents.at(pos++) = thisBx.at(i);
104  }
105  }
106  };
107 
109  bool m_verbose;
110 
111 private:
113  int m_bx;
117 };
118 
119 #endif
void reset()
complete reset of processor
virtual ~L1GctProcessor()
bool setupOk() const
Method to check the setup for this processor. Returns true by default.
Pipeline(const unsigned size)
void store(const T &thisBx, const int bxNum)
bool m_verbose
Flag to control output messages.
int bxRel() const
int bxMin() const
Support for multiple beam crossing operation.
void store(const std::vector< T > &thisBx, const int bxNum)
int numOfBx() const
ABC for a GCT trigger data processing unit.
void setVerbose()
control output messages
void resize(const unsigned size)
void setBxRange(const int firstBx, const int numberOfBx)
define the bunch crossing range to process
virtual void process()=0
process the data and set outputs
int bxMax() const
void reset(const unsigned nBx)
virtual void resetPipelines()=0
int bxAbs() const
virtual void resetProcessor()=0
Separate reset methods for the processor itself and any data stored in pipelines. ...
void setNextBx(const int bxnum)
clear input data buffers and process a new bunch crossing
std::vector< T > contents
long double T
virtual void setupObjects()=0
Initialise inputs with null objects for the correct bunch crossing if required.
int m_bx
Support for multiple beam crossing operation.
tuple size
Write out results.
virtual void fetchInput()=0
set the input buffers