CTPPSPixelROC

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 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102
#ifndef PPSObjects_PixelROC_H
#define PPSObjects_PixelROC_H

#include "CondFormats/Serialization/interface/Serializable.h"

#include "CondFormats/PPSObjects/interface/CTPPSPixelIndices.h"

#include <cstdint>
#include <string>

/** \class PixelROC
 * Represents ReadOut Chip of DetUnit. 
 * Converts pixel coordinates from Local (in ROC) to Global (in DetUnit).
 * The Local coordinates are double column (dcol) and pixel index in dcol.
 * The Global coordinates are row and column in DetUnit.
 */

class CTPPSPixelROC {
public:
  CTPPSPixelROC() : theDetUnit(0), theIdDU(0), theIdLk(0) {}

  ~CTPPSPixelROC() {}

  /// ctor with DetUnit id,
  /// ROC number in DU (given by token passage),
  /// ROC number in Link (given by token passage),
  CTPPSPixelROC(uint32_t du, int idInDU, int idLk);

  void setParameters(uint32_t du, int idInDU, int idLk) {
    theDetUnit = du;
    theIdDU = idInDU;
    theIdLk = idLk;
  }

  /// return the DetUnit to which this ROC belongs to.
  uint32_t rawId() const { return theDetUnit; }

  /// id of this ROC in DetUnit etermined by token path
  unsigned int idInDetUnit() const { return theIdDU; }

  /// id of this ROC in parent Link.
  unsigned int idInLink() const { return theIdLk; }

  std::pair<int, int> toLocal(const std::pair<int, int> &modulePixel) const {
    int rocPixelRow, rocPixelColumn, idDU;
    int modulePixelRow = modulePixel.first;
    int modulePixelColumn = modulePixel.second;

    theIndices.transformToROC(modulePixelColumn, modulePixelRow, idDU, rocPixelColumn, rocPixelRow);

    std::pair<int, int> rocPixel;
    rocPixel = std::make_pair(rocPixelRow, rocPixelColumn);

    return rocPixel;
  }

  std::pair<int, int> toGlobal(const std::pair<int, int> &rocPixel) const {
    int modulePixelRow = -1;
    int modulePixelColumn = -1;
    int rocPixelRow = rocPixel.first;
    int rocPixelColumn = rocPixel.second;

    theIndices.transformToModule(rocPixelColumn, rocPixelRow, theIdDU, modulePixelColumn, modulePixelRow);

    std::pair<int, int> modulePixel;
    modulePixel = std::make_pair(modulePixelRow, modulePixelColumn);

    return modulePixel;
  }

  std::pair<int, int> toGlobalfromDcol(const std::pair<int, int> &rocPixel) const {
    int modulePixelRow = -1;
    int modulePixelColumn = -1;
    int rocDcol = rocPixel.first;
    int rocPxl = rocPixel.second;

    int rocPixelRow;
    int rocPixelColumn;

    theIndices.convertDcolToCol(rocDcol, rocPxl, rocPixelColumn, rocPixelRow);

    theIndices.transformToModule(rocPixelColumn, rocPixelRow, theIdDU, modulePixelColumn, modulePixelRow);

    std::pair<int, int> modulePixel;
    modulePixel = std::make_pair(modulePixelRow, modulePixelColumn);

    return modulePixel;
  }

  /// printout for debug
  std::string print(int depth = 0) const;

private:
  uint32_t theDetUnit;
  unsigned int theIdDU, theIdLk;

  CTPPSPixelIndices theIndices;

  COND_SERIALIZABLE;
};

#endif