CSCLabel

CSCReadoutMapping

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 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155
#ifndef CondFormats_CSCReadoutMapping_h
#define CondFormats_CSCReadoutMapping_h

/** 
 * \class CSCReadoutMapping
 * \author Tim Cox
 * Abstract class to define mapping between CSC readout hardware ids and other labels.
 *
 * Defines the ids and labels in the mapping and supplies translation interface.
 * A derived class must define how hardware labels map to a unique integer.
 * A derived, concrete, class must define from where the mapping information comes.
 */

//@@ FIXME This whole design would better suit a Factory/Builder pattern

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

#include "DataFormats/MuonDetId/interface/CSCDetId.h"
#include <vector>
#include <map>

class CSCReadoutMapping {
public:
  /// Default constructor
  CSCReadoutMapping();

  /// Destructor
  virtual ~CSCReadoutMapping();

  /**
   * Instead of a set of vectors of int use one vector of a set of ints
   */
  struct CSCLabel {
    CSCLabel() {}
    CSCLabel(int endcap,
             int station,
             int ring,
             int chamber,
             int vmecrate,
             int dmb,
             int tmb,
             int tsector,
             int cscid,
             int ddu,
             int dcc)
        : endcap_(endcap),
          station_(station),
          ring_(ring),
          chamber_(chamber),
          vmecrate_(vmecrate),
          dmb_(dmb),
          tmb_(tmb),
          tsector_(tsector),
          cscid_(cscid),
          ddu_(ddu),
          dcc_(dcc) {}
    ~CSCLabel() {}

    int endcap_;
    int station_;
    int ring_;
    int chamber_;
    int vmecrate_;
    int dmb_;
    int tmb_;
    int tsector_;
    int cscid_;
    int ddu_;
    int dcc_;

    COND_SERIALIZABLE;
  };

  /**
    * Return CSCDetId for layer corresponding to readout ids vme, tmb, and dmb for given endcap
    * and layer no. 1-6, or for chamber if no layer no. supplied.
    * Args: endcap = 1 (+z), 2 (-z), station, vme crate number, dmb slot number, tmb slot number, 
    * cfeb number (so we can identify ME1a/b within ME11), layer number
    */
  // layer at end so it can have default arg
  CSCDetId detId(int endcap, int station, int vmecrate, int dmb, int tmb, int cfeb, int layer = 0) const;

  /** 
    * Return chamber label corresponding to readout ids vme, tmb and dmb for given endcap
    *  endcap = 1 (+z), 2 (-z), station, vme crate number, dmb slot number, tmb slot number.
    */
  int chamber(int endcap, int station, int vmecrate, int dmb, int tmb) const;

  ///returns hardware ids given chamber id
  CSCLabel findHardwareId(const CSCDetId&) const;
  ///returns vmecrate given CSCDetId
  int crate(const CSCDetId&) const;
  ///returns dmbId given CSCDetId
  int dmbId(const CSCDetId&) const;
  ///returns DCC# given CSCDetId
  int dccId(const CSCDetId&) const;
  ///returns DDU# given CSCDetId
  int dduId(const CSCDetId&) const;

  /**
    * Add one record of info to mapping
    */
  void addRecord(int endcap,
                 int station,
                 int ring,
                 int chamber,
                 int vmecrate,
                 int dmb,
                 int tmb,
                 int tsector,
                 int cscid,
                 int ddu,
                 int dcc);

  /**
     * Set debug printout flag
     */
  void setDebugV(bool dbg) { debugV_ = dbg; }

  /**
     * Status of debug printout flag
     */
  bool debugV(void) const { return debugV_; }

  /**
     * Return class name
     */
  const std::string& myName(void) const { return myName_; }

private:
  /**
     * Build a unique integer out of the readout electronics labels.
     *
     * In general this must depend on endcap and station, as well as
     * vme crate number and dmb slot number. And possibly tmb slot?
     */
  virtual int hwId(int endcap, int station, int vme, int dmb, int tmb) const = 0;

  /**
     * Build a unique integer out of chamber labels.
     *
     * We'll probably use rawId of CSCDetId... You know it makes sense!
     */
  int swId(int endcap, int station, int ring, int chamber) const;

  std::string myName_ COND_TRANSIENT;
  bool debugV_ COND_TRANSIENT;
  std::vector<CSCLabel> mapping_;
  std::map<int, int> hw2sw_ COND_TRANSIENT;
  std::map<int, CSCLabel> sw2hw_;

  COND_SERIALIZABLE;
};

#endif