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
/** \file
 *
 *
 * \author M.Schmitt, Northwestern
 */
#include "DataFormats/CSCDigi/interface/CSCStripDigi.h"
#include "DataFormats/CSCDigi/interface/CSCConstants.h"
#include "FWCore/MessageLogger/interface/MessageLogger.h"
#include <iostream>
#include <cstdint>

// Comparison
bool CSCStripDigi::operator==(const CSCStripDigi& digi) const {
  if (getStrip() != digi.getStrip())
    return false;
  if (getADCCounts().size() != digi.getADCCounts().size())
    return false;
  if (getADCCounts() != digi.getADCCounts())
    return false;
  return true;
}

/// Get the CFEB number. Counts from 0.
// originally defined in EventFilter/CSCRawToDigi/src/CSCComparatorData.cc
int CSCStripDigi::getCFEB() const { return (strip - 1) / CSCConstants::NUM_STRIPS_PER_CFEB; }

void CSCStripDigi::setADCCounts(const std::vector<int>& vADCCounts) {
  bool badVal = false;
  for (int i = 0; i < (int)vADCCounts.size(); i++) {
    if (vADCCounts[i] < 1)
      badVal = true;
  }
  if (!badVal) {
    ADCCounts = vADCCounts;
  } else {
    std::vector<int> ZeroCounts(8, 0);
    ADCCounts = ZeroCounts;
  }
}

// Debug
void CSCStripDigi::print() const {
  std::ostringstream ost;
  ost << "CSCStripDigi | strip " << getStrip() << " | ADCCounts ";
  for (int i = 0; i < (int)getADCCounts().size(); i++) {
    ost << getADCCounts()[i] << " ";
  }
  ost << " | Overflow ";
  for (int i = 0; i < (int)getADCOverflow().size(); i++) {
    ost << getADCOverflow()[i] << " ";
  }
  ost << " | Overlapped ";
  for (int i = 0; i < (int)getOverlappedSample().size(); i++) {
    ost << getOverlappedSample()[i] << " ";
  }
  ost << " | L1APhase ";
  for (int i = 0; i < (int)getL1APhase().size(); i++) {
    ost << getL1APhase()[i] << " ";
  }
  edm::LogVerbatim("CSCDigi") << ost.str();
}

std::ostream& operator<<(std::ostream& o, const CSCStripDigi& digi) {
  o << " " << digi.getStrip();
  for (size_t i = 0; i < digi.getADCCounts().size(); ++i) {
    o << " " << (digi.getADCCounts())[i];
  }
  return o;
}