Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 12:54:28

0001 #ifndef DATAFORMATS_PHASE2TRACKERCLUSTER_PHASE2TRACKERCLUSTER1D_H
0002 #define DATAFORMATS_PHASE2TRACKERCLUSTER_PHASE2TRACKERCLUSTER1D_H
0003 
0004 #include <cstdint>
0005 
0006 #include "DataFormats/Common/interface/DetSetVectorNew.h"
0007 
0008 #include "DataFormats/Phase2TrackerDigi/interface/Phase2TrackerDigi.h"
0009 
0010 class Phase2TrackerCluster1D {
0011 public:
0012   Phase2TrackerCluster1D() : data_(0) {}
0013   Phase2TrackerCluster1D(unsigned int row, unsigned int col, unsigned int size)
0014       : firstDigi_(row, col), data_((size & 0x7fff)) {}
0015   Phase2TrackerCluster1D(unsigned int row, unsigned int col, unsigned int size, unsigned int threshold)
0016       : firstDigi_(row, col), data_(((threshold & 0x1) << 15) | (size & 0x7fff)) {}
0017   Phase2TrackerCluster1D(const Phase2TrackerDigi& firstDigi, unsigned int size)
0018       : firstDigi_(firstDigi), data_((size & 0x7fff)) {}
0019   Phase2TrackerCluster1D(const Phase2TrackerDigi& firstDigi, unsigned int size, unsigned int threshold)
0020       : firstDigi_(firstDigi), data_(((threshold & 0x1) << 15) | (size & 0x7fff)) {}
0021 
0022   const Phase2TrackerDigi& firstDigi() const { return firstDigi_; }
0023   unsigned int firstStrip() const { return firstDigi_.strip(); }
0024   unsigned int firstRow() const { return firstDigi_.row(); }
0025   unsigned int edge() const { return firstDigi_.edge(); }
0026   unsigned int column() const { return firstDigi_.column(); }
0027   uint16_t size() const { return (data_ & 0x7fff); }
0028   uint16_t threshold() const { return ((data_ >> 15) & 0x1); }
0029   float center() const { return float(firstStrip()) + 0.5f * size(); }
0030   std::pair<float, float> barycenter() const { return std::make_pair(column(), center()); }
0031 
0032 private:
0033   Phase2TrackerDigi firstDigi_;
0034   uint16_t data_;
0035 };
0036 
0037 inline bool operator<(const Phase2TrackerCluster1D& one, const Phase2TrackerCluster1D& other) {
0038   return one.firstStrip() < other.firstStrip();
0039 }
0040 
0041 typedef edmNew::DetSetVector<Phase2TrackerCluster1D> Phase2TrackerCluster1DCollectionNew;
0042 
0043 #endif