L1MuGMTExtendedCand

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
//-------------------------------------------------
//
/**  \class L1MuGMTExtendedCand
 *
 *   L1 Global Muon Trigger Extended Candidate.
 *
 *   This is a GMT candidate with extended information 
 *   that will be sent to Readout.
 * 
 *   This candidates contains extra information such 
 *   as sort rank and indices of the contributing muons.
*/
//
//
//   Author :
//   H. Sakulin                  HEPHY Vienna
//
//   Migrated to CMSSW:
//   I. Mikulec
//
//--------------------------------------------------
#ifndef DataFormatsL1GlobalMuonTrigger_L1MuGMTExtendedCand_h
#define DataFormatsL1GlobalMuonTrigger_L1MuGMTExtendedCand_h

//---------------
// C++ Headers --
//---------------

#include <iosfwd>
#include <string>

//----------------------
// Base Class Headers --
//----------------------

#include "DataFormats/L1GlobalMuonTrigger/interface/L1MuGMTCand.h"

//------------------------------------
// Collaborating Class Declarations --
//------------------------------------

//              ---------------------
//              -- Class Interface --
//              ---------------------

class L1MuGMTExtendedCand : public L1MuGMTCand {
public:
  /// constructor
  L1MuGMTExtendedCand();

  /// constructor
  L1MuGMTExtendedCand(unsigned data, unsigned rank, int bx = 0);

  /// copy constructor
  L1MuGMTExtendedCand(const L1MuGMTExtendedCand&);

  /// assignment operator
  L1MuGMTExtendedCand& operator=(const L1MuGMTExtendedCand&) = default;

  /// destructor
  ~L1MuGMTExtendedCand() override;

  /// reset muon candidate
  void reset();

  //
  // Getters
  //

  /// get rank
  unsigned int rank() const { return m_rank; }

  /// get index of contributing DT/CSC muon
  unsigned getDTCSCIndex() const { return readDataField(IDXDTCSC_START, IDXDTCSC_LENGTH); }

  /// get index of contributing RPC muon
  unsigned getRPCIndex() const { return readDataField(IDXRPC_START, IDXRPC_LENGTH); }

  /// get forward bit (true=forward, false=barrel)
  bool isFwd() const { return readDataField(FWDBIT_START, FWDBIT_LENGTH) == 1; }

  /// get RPC bit (true=RPC, false = DT/CSC or matched)
  bool isRPC() const { return readDataField(ISRPCBIT_START, ISRPCBIT_LENGTH) == 1; }

  /// set rank
  void setRank(unsigned int rank) { m_rank = rank; }

  /// get detector bits
  /// 1=rpc, 2=dtbx, 4=csc, 3=rpc+dtbx, 5=rpc+csc
  /// supported for backward compatibility only
  unsigned int detector() const;

  //
  // Setters
  //

  /// set index of contributing DT/CSC muon
  void setDTCSCIndex(unsigned int idxdtcsc) { writeDataField(IDXDTCSC_START, IDXDTCSC_LENGTH, idxdtcsc); }

  /// set index of contributing RPC muon
  void setRPCIndex(unsigned int idxrpc) { writeDataField(IDXRPC_START, IDXRPC_LENGTH, idxrpc); }

  /// set forward bit (1=forward, 0=barrel)
  void setFwdBit(unsigned int fwdbit) { writeDataField(FWDBIT_START, FWDBIT_LENGTH, fwdbit); }

  /// set RPC bit (1=RPC, 0=DT/CSC or matched)
  void setRPCBit(unsigned int rpcbit) { writeDataField(ISRPCBIT_START, ISRPCBIT_LENGTH, rpcbit); }

  /// equal operator
  bool operator==(const L1MuGMTExtendedCand&) const;

  /// unequal operator
  bool operator!=(const L1MuGMTExtendedCand&) const;

  /// print parameters of muon candidate
  void print() const;

  /// output stream operator
  friend std::ostream& operator<<(std::ostream&, const L1MuGMTExtendedCand&);

  /// define a rank for muon candidates
  static bool compareRank(const L1MuGMTExtendedCand* first, const L1MuGMTExtendedCand* second) {
    unsigned int rank_f = (first) ? first->rank() : 0;
    unsigned int rank_s = (second) ? second->rank() : 0;
    return rank_f > rank_s;
  }

  /// define a rank for muon candidates
  static bool rankRef(const L1MuGMTExtendedCand& first, const L1MuGMTExtendedCand& second) {
    unsigned int rank_f = first.rank();
    unsigned int rank_s = second.rank();
    return rank_f > rank_s;
  }

private:
  unsigned int m_rank;

  enum { IDXDTCSC_START = 26 };
  enum { IDXDTCSC_LENGTH = 2 };  // Bit  26:27 DT/CSC muon index
  enum { IDXRPC_START = 28 };
  enum { IDXRPC_LENGTH = 2 };  // Bit  28:29 RPC muon index
  enum { FWDBIT_START = 30 };
  enum { FWDBIT_LENGTH = 1 };  // Bit  30    fwd bit
  enum { ISRPCBIT_START = 31 };
  enum { ISRPCBIT_LENGTH = 1 };  // Bit  31    isRPC bit
};

#endif