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
#include "DataFormats/GEMDigi/interface/GEMCoPadDigi.h"
#include <iostream>

GEMCoPadDigi::GEMCoPadDigi(uint8_t roll, GEMPadDigi f, GEMPadDigi s) : roll_(roll), first_(f), second_(s) {}

GEMCoPadDigi::GEMCoPadDigi() : roll_(0), first_(GEMPadDigi()), second_(GEMPadDigi()) {}

// Comparison
bool GEMCoPadDigi::operator==(const GEMCoPadDigi& digi) const {
  return digi.first() == first_ and digi.second() == second_ and digi.roll() == roll_;
}

// Comparison
bool GEMCoPadDigi::operator!=(const GEMCoPadDigi& digi) const {
  return digi.first() != first_ or digi.second() != second_ or digi.roll() != roll_;
}

bool GEMCoPadDigi::isValid() const { return first_.isValid() and second_.isValid(); }

int GEMCoPadDigi::pad(int l) const {
  if (l == 1)
    return first_.pad();
  else if (l == 2)
    return second_.pad();
  else
    return -99;  // invalid
}

int GEMCoPadDigi::bx(int l) const {
  if (l == 1)
    return first_.bx();
  else if (l == 2)
    return second_.bx();
  else
    return -99;  // invalid
}

void GEMCoPadDigi::print() const {
  std::cout << "Roll " << roll_ << ", pad1 " << first_.pad() << " bx1 " << first_.bx() << ", Pad2 " << second_.pad()
            << " bx2 " << second_.bx() << std::endl;
}

std::ostream& operator<<(std::ostream& o, const GEMCoPadDigi& digi) {
  return o << "Roll: " << digi.roll() << " layer1:" << digi.first() << ", layer2:" << digi.second();
}