HGCalUnpacker

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 149 150 151 152 153 154
/****************************************************************************
 *
 * Unpacker to decode HGCal raw data from SLinks
 * Authors:
 *   Yulun Miao, Northwestern University
 *   Huilin Qu, CERN
 *   Laurent Forthomme, CERN
 *
 ****************************************************************************/

#ifndef EventFilter_HGCalRawToDigi_HGCalUnpacker_h
#define EventFilter_HGCalRawToDigi_HGCalUnpacker_h

#include "DataFormats/HGCalDigi/interface/HGCalRawDataDefinitions.h"
#include "DataFormats/FEDRawData/interface/FEDRawData.h"
#include "DataFormats/HGCalDigi/interface/HGCalDigiHost.h"
#include "DataFormats/HGCalDigi/interface/HGCalECONDPacketInfoHost.h"
#include "CondFormats/HGCalObjects/interface/HGCalMappingModuleIndexer.h"
#include "CondFormats/HGCalObjects/interface/HGCalConfiguration.h"
#include "FWCore/Utilities/interface/Exception.h"
#include "EventFilter/HGCalRawToDigi/interface/UnpackerTools.h"

#include <cstdint>
#include <functional>
#include <vector>

class HGCalUnpacker {
public:
  HGCalUnpacker() = default;

  // TODO @hqucms
  // define what is needed as `config`
  // HGCalUnpacker(HGCalUnpackerConfig config);

  uint16_t parseFEDData(unsigned fedId,
                        const FEDRawData& fed_data,
                        const HGCalMappingModuleIndexer& moduleIndexer,
                        const HGCalConfiguration& config,
                        hgcaldigi::HGCalDigiHost& digis,
                        hgcaldigi::HGCalECONDPacketInfoHost& econdPacketInfo,
                        bool headerOnlyMode = false);

private:
  constexpr static uint8_t tctp_[16] = {
      0b00, 0b00, 0b01, 0b00, 0b00, 0b00, 0b00, 0b00, 0b10, 0b10, 0b10, 0b10, 0b11, 0b11, 0b11, 0b11};

  constexpr static uint32_t adcm1Mask_[16] = {0b1111111111,
                                              0b0000000000,
                                              0b1111111111,
                                              0b0000000000,
                                              0b1111111111,
                                              0b1111111111,
                                              0b1111111111,
                                              0b1111111111,
                                              0b1111111111,
                                              0b1111111111,
                                              0b1111111111,
                                              0b1111111111,
                                              0b1111111111,
                                              0b1111111111,
                                              0b1111111111,
                                              0b1111111111};
  constexpr static uint32_t adcm1Shift_[16] = {
      18,
      28,
      18,
      0,
      20,
      20,
      20,
      20,
      20,
      20,
      20,
      20,
      20,
      20,
      20,
      20,
  };

  constexpr static uint32_t adcShift_[16] = {8, 18, 8, 18, 10, 10, 10, 10, 10, 10, 10, 10, 0, 0, 0, 0};
  constexpr static uint32_t adcMask_[16] = {0b1111111111,
                                            0b1111111111,
                                            0b1111111111,
                                            0b1111111111,
                                            0b1111111111,
                                            0b1111111111,
                                            0b1111111111,
                                            0b1111111111,
                                            0b1111111111,
                                            0b1111111111,
                                            0b1111111111,
                                            0b1111111111,
                                            0b0000000000,
                                            0b0000000000,
                                            0b0000000000,
                                            0b0000000000};

  constexpr static uint32_t totShift_[16] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 10, 10, 10};
  constexpr static uint32_t totMask_[16] = {0b0000000000,
                                            0b0000000000,
                                            0b0000000000,
                                            0b0000000000,
                                            0b0000000000,
                                            0b0000000000,
                                            0b0000000000,
                                            0b0000000000,
                                            0b0000000000,
                                            0b0000000000,
                                            0b0000000000,
                                            0b0000000000,
                                            0b1111111111,
                                            0b1111111111,
                                            0b1111111111,
                                            0b1111111111};

  constexpr static uint32_t toaShift_[16] = {0, 0, 0, 8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
  constexpr static uint32_t toaMask_[16] = {0b0000000000,
                                            0b0000000000,
                                            0b0000000000,
                                            0b1111111111,
                                            0b1111111111,
                                            0b1111111111,
                                            0b1111111111,
                                            0b1111111111,
                                            0b1111111111,
                                            0b1111111111,
                                            0b1111111111,
                                            0b1111111111,
                                            0b1111111111,
                                            0b1111111111,
                                            0b1111111111,
                                            0b1111111111};
  constexpr static uint16_t flags_[16] = {hgcal::DIGI_FLAG::ZS_ToA,
                                          hgcal::DIGI_FLAG::ZS_ToA_ADCm1,
                                          hgcal::DIGI_FLAG::ZS_ToA,
                                          hgcal::DIGI_FLAG::ZS_ADCm1,
                                          hgcal::DIGI_FLAG::FULL_READOUT,
                                          hgcal::DIGI_FLAG::FULL_READOUT,
                                          hgcal::DIGI_FLAG::FULL_READOUT,
                                          hgcal::DIGI_FLAG::FULL_READOUT,
                                          hgcal::DIGI_FLAG::Invalid,
                                          hgcal::DIGI_FLAG::Invalid,
                                          hgcal::DIGI_FLAG::Invalid,
                                          hgcal::DIGI_FLAG::Invalid,
                                          hgcal::DIGI_FLAG::FULL_READOUT,
                                          hgcal::DIGI_FLAG::FULL_READOUT,
                                          hgcal::DIGI_FLAG::FULL_READOUT,
                                          hgcal::DIGI_FLAG::FULL_READOUT};
  constexpr static uint32_t erxBodyBits_[16] = {24, 16, 24, 24, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32};
};

#endif