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
/****************************************************************************
 *
 * This is a part of HGCAL offline software.
 * Authors:
 *   Laurent Forthomme, CERN
 *   Pedro Silva, CERN
 *
 ****************************************************************************/

#include "DataFormats/HGCalDigi/interface/HGCalRawDataEmulatorInfo.h"

//-----------------------------------------------
// ECON-D emulator info
//-----------------------------------------------

HGCalECONDEmulatorInfo::HGCalECONDEmulatorInfo(bool obit,
                                               bool bbit,
                                               bool ebit,
                                               bool tbit,
                                               bool hbit,
                                               bool sbit,
                                               const std::vector<std::vector<bool> >& enabled_channels) {
  header_bits_[StatusBits::O] = obit;
  header_bits_[StatusBits::B] = bbit;
  header_bits_[StatusBits::E] = ebit;
  header_bits_[StatusBits::T] = tbit;
  header_bits_[StatusBits::H] = hbit;
  header_bits_[StatusBits::S] = sbit;
  for (const auto& ch_en : enabled_channels)
    erx_pois_.emplace_back(ch_en);
}

void HGCalECONDEmulatorInfo::clear() {
  header_bits_.reset();
  erx_pois_.clear();
}

void HGCalECONDEmulatorInfo::addERxChannelsEnable(const std::vector<bool>& erx_channels_poi) {
  erx_pois_.emplace_back(erx_channels_poi);
}

std::vector<bool> HGCalECONDEmulatorInfo::channelsEnabled(size_t ch_id) const {
  std::vector<bool> ch_en;
  ch_en.reserve(erx_pois_.size());
  for (const auto& erx_channels_poi : erx_pois_)
    ch_en.emplace_back(erx_channels_poi.at(ch_id));
  return ch_en;
}

HGCalECONDEmulatorInfo::HGCROCEventRecoStatus HGCalECONDEmulatorInfo::eventRecoStatus() const {
  return static_cast<HGCROCEventRecoStatus>(bitH() << 1 | bitT());
}

//-----------------------------------------------
// Capture block emulator info
//-----------------------------------------------

void HGCalCaptureBlockEmulatorInfo::addECONDEmulatedInfo(unsigned int econd_id,
                                                         const HGCalECONDEmulatorInfo& econd_info) {
  econd_info_[econd_id] = econd_info;
}

//-----------------------------------------------
// S-link emulator info
//-----------------------------------------------

void HGCalSlinkEmulatorInfo::addCaptureBlockEmulatedInfo(unsigned int cb_id,
                                                         const HGCalCaptureBlockEmulatorInfo& cb_info) {
  cb_info_[cb_id] = cb_info;
}

HGCalCaptureBlockEmulatorInfo& HGCalSlinkEmulatorInfo::captureBlockEmulatedInfo(unsigned int cb_id) {
  return cb_info_[cb_id];
}