DcolPxid

LocalPixel

RocRowCol

Macros

Line Code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44
#ifndef CondFormats_SiPixelObjects_LocalPixel_H
#define CondFormats_SiPixelObjects_LocalPixel_H

namespace sipixelobjects {

  /// identify pixel inside single ROC
  class LocalPixel {
  public:
    static const int numRowsInRoc = 80;
    static const int numColsInRoc = 52;

    /// row and collumn in ROC representation
    struct RocRowCol {
      int rocRow, rocCol;
      bool valid() const { return (0 <= rocRow) & (rocRow < numRowsInRoc) & (0 <= rocCol) & (rocCol < numColsInRoc); }
    };

    /// double collumn and pixel ID in double collumn representation
    struct DcolPxid {
      int dcol, pxid;
      bool valid() const { return ((0 <= dcol) & (dcol < 26) & (2 <= pxid) & (pxid < 162)); }
    };

    LocalPixel(const DcolPxid& pixel) {
      thePixel.rocRow = numRowsInRoc - pixel.pxid / 2;
      thePixel.rocCol = pixel.dcol * 2 + pixel.pxid % 2;
    }

    LocalPixel(const RocRowCol& pixel) : thePixel(pixel) {}

    int dcol() const { return thePixel.rocCol / 2; }
    int pxid() const { return 2 * (numRowsInRoc - thePixel.rocRow) + (thePixel.rocCol % 2); }

    int rocRow() const { return thePixel.rocRow; }
    int rocCol() const { return thePixel.rocCol; }

    bool valid() const { return thePixel.valid(); }

  private:
    RocRowCol thePixel;
  };
}  // namespace sipixelobjects

#endif