Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 12:53:23

0001 #ifndef DIGIFTL_FTLDATAFRAMET_H
0002 #define DIGIFTL_FTLDATAFRAMET_H
0003 
0004 #include <vector>
0005 #include <ostream>
0006 #include <iostream>
0007 
0008 /**
0009    @class FTLDataFrameT
0010    @short Readout digi for HGC
0011 */
0012 
0013 template <class D, class S, class DECODE>
0014 class FTLDataFrameT {
0015 public:
0016   /**
0017      @short key to sort the collection
0018   */
0019   typedef D key_type;
0020 
0021   /**
0022      @short CTOR
0023   */
0024   FTLDataFrameT() : id_(0), maxSampleSize_(15) { data_.resize(maxSampleSize_); }
0025   FTLDataFrameT(const D& id) : id_(id), maxSampleSize_(15) { data_.resize(maxSampleSize_); }
0026   FTLDataFrameT(const FTLDataFrameT& o) : data_(o.data_), id_(o.id_), maxSampleSize_(o.maxSampleSize_) {}
0027 
0028   /**
0029     @short det id
0030   */
0031   const D& id() const { return id_; }
0032 
0033   /**
0034    @short row
0035    */
0036   const int row() const { return DECODE::row(id_, data_); }
0037 
0038   /**
0039    @short column
0040    */
0041   const int column() const { return DECODE::col(id_, data_); }
0042 
0043   /** 
0044     @short total number of samples in the digi 
0045   */
0046   int size() const { return data_.size() & 0xf; }
0047 
0048   /**
0049      @short allow to set size
0050    */
0051   void resize(size_t s) { data_.resize(s); }
0052 
0053   /**
0054      @short assess/set specific samples
0055   */
0056   const S& operator[](int i) const { return data_[i]; }
0057   const S& sample(int i) const { return data_[i]; }
0058   void setSample(int i, const S& sample) {
0059     if (i < (int)data_.size())
0060       data_[i] = sample;
0061   }
0062   void print(std::ostream& out = std::cout) {
0063     for (size_t i = 0; i < data_.size(); i++) {
0064       out << "[" << i << "] ";
0065       data_[i].print(out);
0066     }
0067   }
0068 
0069 private:
0070   //collection of samples
0071   std::vector<S> data_;
0072 
0073   // det id for this data frame
0074   D id_;
0075 
0076   //number of samples and maximum available
0077   size_t maxSampleSize_;
0078 };
0079 
0080 #endif