CMS 3D CMS Logo

HGCDataFrame.h
Go to the documentation of this file.
1 #ifndef DIGIHGCAL_HGCDATAFRAME_H
2 #define DIGIHGCAL_HGCDATAFRAME_H
3 
4 #include <vector>
5 #include <ostream>
6 #include <iostream>
7 
13 template <class D, class S>
14 class HGCDataFrame {
15 public:
19  typedef D key_type;
20 
25  HGCDataFrame(const D& id) : id_(id), maxSampleSize_(15) { data_.resize(maxSampleSize_); }
26 
30  const D& id() const { return id_; }
31 
35  int size() const { return data_.size() & 0xf; }
36 
40  void resize(size_t s) { data_.resize(s); }
41 
45  const S& operator[](int i) const { return data_[i]; }
46  const S& sample(int i) const { return data_[i]; }
47  void setSample(int i, const S& sample) {
48  if (i < (int)data_.size())
49  data_[i] = sample;
50  }
51  void print(std::ostream& out = std::cout) {
52  for (size_t i = 0; i < data_.size(); i++) {
53  out << "[" << i << "] ";
54  data_[i].print(out);
55  }
56  }
57  const std::vector<S>& data() const { return data_; }
58  void setData(const std::vector<S>& d) { data_ = d; }
59 
60 private:
61  //collection of samples
62  std::vector<S> data_;
63 
64  // det id for this data frame
65  D id_;
66 
67  //number of samples and maximum available
69 };
70 
71 #endif
int size() const
total number of samples in the digi
Definition: HGCDataFrame.h:35
size_t maxSampleSize_
Definition: HGCDataFrame.h:68
const S & sample(int i) const
Definition: HGCDataFrame.h:46
const S & operator[](int i) const
assess/set specific samples
Definition: HGCDataFrame.h:45
void print(std::ostream &out=std::cout)
Definition: HGCDataFrame.h:51
const std::vector< S > & data() const
Definition: HGCDataFrame.h:57
void resize(size_t s)
allow to set size
Definition: HGCDataFrame.h:40
const D & id() const
det id
Definition: HGCDataFrame.h:30
D key_type
key to sort the collection
Definition: HGCDataFrame.h:19
HGCDataFrame(const D &id)
Definition: HGCDataFrame.h:25
std::vector< S > data_
Definition: HGCDataFrame.h:62
d
Definition: ztail.py:151
DecomposeProduct< arg, typename Div::arg > D
Definition: Factorize.h:141
Readout digi for HGC.
Definition: HGCDataFrame.h:14
void setData(const std::vector< S > &d)
Definition: HGCDataFrame.h:58
void setSample(int i, const S &sample)
Definition: HGCDataFrame.h:47
HGCDataFrame()
CTOR.
Definition: HGCDataFrame.h:24