DigHitDetId.hh 2.23 KB
Newer Older
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
#ifndef DigHitDetId_HH
#define DigHitDetId_HH

#include <iostream>
#include <cstdint>

#include "EcDetId.hh"

class DigHitDetId : public EcDetId {
public:
  DigHitDetId() : EcDetId() {
  }

  DigHitDetId(uint32_t d) : EcDetId(d) {
  }

  DigHitDetId(const DigHitDetId &d) : EcDetId(d.fDetId) {
  }

  DigHitDetId(const EcDetId &d, unsigned sc) : EcDetId(d) {
    fDetId|=sc;
  }

  DigHitDetId(unsigned e, unsigned l, unsigned w, unsigned sc)
    : EcDetId(e,l,w) {
    fDetId|=sc;
  }

  ~DigHitDetId() {
  }

  void detId(unsigned e, unsigned l, unsigned w, unsigned sc) {
    assert(sc<512);
    EcDetId::detId(e,l,w);
    fDetId|=sc;
  }

  unsigned sensorCell() const {
    return (fDetId&0x000001ff);
  }

  unsigned reserved() const {
    return (fDetId&0x00001e00)>>9;
  }

  void setSensorCell(uint32_t sc) {
    assert(sc<512);
    fDetId&=0xfffffe00;
    fDetId|=sc;
  }

  bool operator==(const DigHitDetId &r) const {
    return r.fDetId==fDetId;
  }

  bool operator!=(const DigHitDetId &r) const {
    return r.fDetId!=fDetId;
  }
  /*
  void selected(bool b) {
    setFlag(b);
  }

  bool isSelected() const {
    return flag();
  }

  bool selected() const {
    return flag();
  }
  */

  bool daqSelected() const {
    return (fDetId&0x00000200)!=0;
  }

  void daqSelected(bool f) {
    if(f) fDetId|=0x00000200;
    else  fDetId&=0xfffffdff;
  }

82 83 84 85 86 87 88 89 90
  bool pbxSelected() const {
    return (fDetId&0x00001000)!=0;
  }

  void pbxSelected(bool f) {
    if(f) fDetId|=0x00001000;
    else  fDetId&=0xffffefff;
  }

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
  bool tpgSelected() const {
    return (fDetId&0x00000400)!=0;
  }

  void tpgSelected(bool f) {
    if(f) fDetId|=0x00000400;
    else  fDetId&=0xfffffbff;
  }

  bool valid() const {
    return (fDetId&0x00000800)==0;
  }

  bool invalid() const {
    return (fDetId&0x00000800)!=0;
  }

  void invalid(bool f) {
    if(f) fDetId|=0x00000800;
    else  fDetId&=0xfffff7ff;
  }

  void print() const {
    std::cout << "DigHitDetId::print() 0x"
	      << std::hex << fDetId << std::dec << " = E"
	      << endcap() << "/L"
	      << layer() << "/W" 
	      << wafer() << "/SC" 
	      << sensorCell() << "/Flags"
	      << (daqSelected()?" Daq":"")
	      << (tpgSelected()?" Tpg":"")
	      << (invalid()?" Inv":"")
	      << std::endl;
  }
};

#endif