CMS 3D CMS Logo

List of all members | Public Types | Public Member Functions | Static Public Member Functions | Protected Attributes | Private Attributes
VFATFrame Class Reference

#include <VFATFrame.h>

Public Types

typedef uint16_t word
 

Public Member Functions

virtual bool channelActive (unsigned char channel) const
 
virtual bool checkCRC () const
 
bool checkFootprint () const
 
virtual std::vector< unsigned char > getActiveChannels () const
 
VFATFrame::word getBC () const
 Returns Bunch Crossing number (BC<11:0>). More...
 
VFATFrame::word getChipID () const
 Returns ChipID (ChipID<11:0>). More...
 
VFATFrame::word getCRC () const
 Returns the CRC. More...
 
VFATFrame::wordgetData ()
 
const VFATFrame::wordgetData () const
 
VFATFrame::word getEC () const
 Returns Event Counter (EV<7:0>). More...
 
VFATFrame::word getFlags () const
 Returns flags. More...
 
uint8_t getNumberOfClusters () const
 
bool isBCPresent () const
 Returns true if the BC word is present in the frame. More...
 
bool isCRCPresent () const
 Returns true if the CRC word is present in the frame. More...
 
bool isECPresent () const
 Returns true if the EC word is present in the frame. More...
 
bool isIDPresent () const
 Returns true if the ID word is present in the frame. More...
 
bool isNumberOfClustersPresent () const
 Returns true if the CRC word is present in the frame. More...
 
void Print (bool binary=false) const
 
void setDAQErrorFlags (uint8_t v)
 Sets DAQ error flags. More...
 
void setData (const word *_data)
 Copies a memory block to data buffer. More...
 
void setNumberOfClusters (uint8_t v)
 
void setPresenceFlags (uint8_t v)
 Sets presence flags. More...
 
 VFATFrame (const word *_data=nullptr)
 
 VFATFrame (const VFATFrame &copy)
 
virtual ~VFATFrame ()
 

Static Public Member Functions

static word calculateCRC (word crc_in, word dato)
 internaly used to check CRC More...
 

Protected Attributes

word data [12]
 

Private Attributes

uint8_t daqErrorFlags
 Error flag as given by certain versions of DAQ. More...
 
uint8_t numberOfClusters
 
uint8_t presenceFlags
 

Detailed Description

Representation of VFAT frame plus extra info added by DAQ.

Definition at line 19 of file VFATFrame.h.

Member Typedef Documentation

◆ word

typedef uint16_t VFATFrame::word

Definition at line 21 of file VFATFrame.h.

Constructor & Destructor Documentation

◆ VFATFrame() [1/2]

VFATFrame::VFATFrame ( const word _data = nullptr)

Definition at line 16 of file VFATFrame.cc.

References data, and setData().

17  : presenceFlags(15), // by default BC, EC, ID and CRC are present
18  daqErrorFlags(0), // by default, no DAQ error
19  numberOfClusters(0) // no clusters by default
20 {
21  if (_data)
22  setData(_data);
23  else
24  memset(data, 0, 12 * sizeof(word));
25 }
word data[12]
Definition: VFATFrame.h:123
uint64_t word
uint8_t daqErrorFlags
Error flag as given by certain versions of DAQ.
Definition: VFATFrame.h:135
uint8_t presenceFlags
Definition: VFATFrame.h:132
uint8_t numberOfClusters
Definition: VFATFrame.h:139
void setData(const word *_data)
Copies a memory block to data buffer.
Definition: VFATFrame.cc:27

◆ VFATFrame() [2/2]

VFATFrame::VFATFrame ( const VFATFrame copy)
inline

Definition at line 26 of file VFATFrame.h.

References filterCSVwithJSON::copy, daqErrorFlags, numberOfClusters, presenceFlags, and setData().

26  {
27  setData(copy.data);
28  presenceFlags = copy.presenceFlags;
29  daqErrorFlags = copy.daqErrorFlags;
30  numberOfClusters = copy.numberOfClusters;
31  }
uint8_t daqErrorFlags
Error flag as given by certain versions of DAQ.
Definition: VFATFrame.h:135
uint8_t presenceFlags
Definition: VFATFrame.h:132
uint8_t numberOfClusters
Definition: VFATFrame.h:139
void setData(const word *_data)
Copies a memory block to data buffer.
Definition: VFATFrame.cc:27

◆ ~VFATFrame()

virtual VFATFrame::~VFATFrame ( )
inlinevirtual

Definition at line 33 of file VFATFrame.h.

33 {}

Member Function Documentation

◆ calculateCRC()

VFATFrame::word VFATFrame::calculateCRC ( VFATFrame::word  crc_in,
VFATFrame::word  dato 
)
static

internaly used to check CRC

Definition at line 80 of file VFATFrame.cc.

References ztail::d, mps_fire::i, gpuClustering::pixelStatus::mask, and findQualityFiles::v.

Referenced by checkCRC(), and CTPPSTotemDataFormatter::formatRawData().

80  {
81  word v = 0x0001;
82  word mask = 0x0001;
83  bool d = false;
84  word crc_temp = crc_in;
85  unsigned char datalen = 16;
86 
87  for (int i = 0; i < datalen; i++) {
88  if (dato & v)
89  d = true;
90  else
91  d = false;
92 
93  if ((crc_temp & mask) ^ d)
94  crc_temp = crc_temp >> 1 ^ 0x8408;
95  else
96  crc_temp = crc_temp >> 1;
97 
98  v <<= 1;
99  }
100 
101  return crc_temp;
102 }
constexpr uint32_t mask
Definition: gpuClustering.h:24
uint64_t word
d
Definition: ztail.py:151

◆ channelActive()

virtual bool VFATFrame::channelActive ( unsigned char  channel) const
inlinevirtual

Checks if channel number 'channel' was active. Returns positive number if it was active, 0 otherwise.

Definition at line 95 of file VFATFrame.h.

References data, and funct::true.

95  {
96  return (data[1 + (channel / 16)] & (1 << (channel % 16))) ? true : false;
97  }
word data[12]
Definition: VFATFrame.h:123

◆ checkCRC()

bool VFATFrame::checkCRC ( ) const
virtual

Checks the validity of frame (CRC and daqErrorFlags). Returns false if daqErrorFlags is non-zero. Returns false if the CRC is present and invalid.

Definition at line 62 of file VFATFrame.cc.

References calculateCRC(), daqErrorFlags, data, mps_fire::i, and isCRCPresent().

Referenced by Print().

62  {
63  // check DAQ error flags
64  if (daqErrorFlags != 0)
65  return false;
66 
67  // return true if CRC not present
68  if (!isCRCPresent())
69  return true;
70 
71  // compare CRC
72  word crc_fin = 0xffff;
73 
74  for (int i = 11; i >= 1; i--)
75  crc_fin = calculateCRC(crc_fin, data[i]);
76 
77  return (crc_fin == data[0]);
78 }
word data[12]
Definition: VFATFrame.h:123
uint64_t word
uint8_t daqErrorFlags
Error flag as given by certain versions of DAQ.
Definition: VFATFrame.h:135
bool isCRCPresent() const
Returns true if the CRC word is present in the frame.
Definition: VFATFrame.h:70
static word calculateCRC(word crc_in, word dato)
internaly used to check CRC
Definition: VFATFrame.cc:80

◆ checkFootprint()

bool VFATFrame::checkFootprint ( ) const

Checks the fixed bits in the frame. Returns false if any of the groups (in BC, EC and ID words) is present but wrong.

Definition at line 49 of file VFATFrame.cc.

References data, isBCPresent(), isECPresent(), and isIDPresent().

Referenced by Print().

49  {
50  if (isIDPresent() && (data[9] & 0xF000) != 0xE000)
51  return false;
52 
53  if (isECPresent() && (data[10] & 0xF000) != 0xC000)
54  return false;
55 
56  if (isBCPresent() && (data[11] & 0xF000) != 0xA000)
57  return false;
58 
59  return true;
60 }
word data[12]
Definition: VFATFrame.h:123
bool isBCPresent() const
Returns true if the BC word is present in the frame.
Definition: VFATFrame.h:61
bool isECPresent() const
Returns true if the EC word is present in the frame.
Definition: VFATFrame.h:64
bool isIDPresent() const
Returns true if the ID word is present in the frame.
Definition: VFATFrame.h:67

◆ getActiveChannels()

std::vector< unsigned char > VFATFrame::getActiveChannels ( ) const
virtual

Returns list of active channels. It's more efficient than the channelActive(char) for events with low channel occupancy.

Definition at line 29 of file VFATFrame.cc.

References ewkTauDQM_cfi::channels, data, mps_fire::i, gpuClustering::pixelStatus::mask, and hltrates_dqm_sourceclient-live_cfg::offset.

29  {
30  std::vector<unsigned char> channels;
31 
32  for (int i = 0; i < 8; i++) {
33  // quick check
34  if (!data[1 + i])
35  continue;
36 
37  // go throug bits
38  word mask;
39  char offset;
40  for (mask = 1 << 15, offset = 15; mask; mask >>= 1, offset--) {
41  if (data[1 + i] & mask)
42  channels.push_back(i * 16 + offset);
43  }
44  }
45 
46  return channels;
47 }
word data[12]
Definition: VFATFrame.h:123
constexpr uint32_t mask
Definition: gpuClustering.h:24
uint64_t word

◆ getBC()

VFATFrame::word VFATFrame::getBC ( ) const
inline

Returns Bunch Crossing number (BC<11:0>).

Definition at line 43 of file VFATFrame.h.

References data.

Referenced by Print().

43 { return data[11] & 0x0FFF; }
word data[12]
Definition: VFATFrame.h:123

◆ getChipID()

VFATFrame::word VFATFrame::getChipID ( ) const
inline

Returns ChipID (ChipID<11:0>).

Definition at line 52 of file VFATFrame.h.

References data.

Referenced by VFATFrameCollection::GetFrameByIndexID(), and Print().

52 { return data[9] & 0x0FFF; }
word data[12]
Definition: VFATFrame.h:123

◆ getCRC()

VFATFrame::word VFATFrame::getCRC ( ) const
inline

Returns the CRC.

Definition at line 55 of file VFATFrame.h.

References data.

Referenced by Print().

55 { return data[0]; }
word data[12]
Definition: VFATFrame.h:123

◆ getData() [1/2]

VFATFrame::word* VFATFrame::getData ( void  )
inline

Definition at line 38 of file VFATFrame.h.

References data.

Referenced by pps::RawDataUnpacker::processOptoRxFrameSerial(), and RawToDigiConverter::run().

38 { return data; }
word data[12]
Definition: VFATFrame.h:123

◆ getData() [2/2]

const VFATFrame::word* VFATFrame::getData ( void  ) const
inline

Definition at line 40 of file VFATFrame.h.

References data.

40 { return data; }
word data[12]
Definition: VFATFrame.h:123

◆ getEC()

VFATFrame::word VFATFrame::getEC ( ) const
inline

Returns Event Counter (EV<7:0>).

Definition at line 46 of file VFATFrame.h.

References data.

Referenced by Print().

46 { return (data[10] & 0x0FF0) >> 4; }
word data[12]
Definition: VFATFrame.h:123

◆ getFlags()

VFATFrame::word VFATFrame::getFlags ( ) const
inline

Returns flags.

Definition at line 49 of file VFATFrame.h.

References data.

Referenced by Print().

49 { return data[10] & 0x000F; }
word data[12]
Definition: VFATFrame.h:123

◆ getNumberOfClusters()

uint8_t VFATFrame::getNumberOfClusters ( ) const
inline

Returns the number of clusters as given by the "0xD0 frame". Returns 0, if not available.

Definition at line 82 of file VFATFrame.h.

References numberOfClusters.

82 { return numberOfClusters; }
uint8_t numberOfClusters
Definition: VFATFrame.h:139

◆ isBCPresent()

bool VFATFrame::isBCPresent ( ) const
inline

Returns true if the BC word is present in the frame.

Definition at line 61 of file VFATFrame.h.

References presenceFlags.

Referenced by checkFootprint().

61 { return presenceFlags & 0x1; }
uint8_t presenceFlags
Definition: VFATFrame.h:132

◆ isCRCPresent()

bool VFATFrame::isCRCPresent ( ) const
inline

Returns true if the CRC word is present in the frame.

Definition at line 70 of file VFATFrame.h.

References presenceFlags.

Referenced by checkCRC().

70 { return presenceFlags & 0x8; }
uint8_t presenceFlags
Definition: VFATFrame.h:132

◆ isECPresent()

bool VFATFrame::isECPresent ( ) const
inline

Returns true if the EC word is present in the frame.

Definition at line 64 of file VFATFrame.h.

References presenceFlags.

Referenced by checkFootprint().

64 { return presenceFlags & 0x2; }
uint8_t presenceFlags
Definition: VFATFrame.h:132

◆ isIDPresent()

bool VFATFrame::isIDPresent ( ) const
inline

Returns true if the ID word is present in the frame.

Definition at line 67 of file VFATFrame.h.

References presenceFlags.

Referenced by checkFootprint().

67 { return presenceFlags & 0x4; }
uint8_t presenceFlags
Definition: VFATFrame.h:132

◆ isNumberOfClustersPresent()

bool VFATFrame::isNumberOfClustersPresent ( ) const
inline

Returns true if the CRC word is present in the frame.

Definition at line 73 of file VFATFrame.h.

References presenceFlags.

73 { return presenceFlags & 0x10; }
uint8_t presenceFlags
Definition: VFATFrame.h:132

◆ Print()

void VFATFrame::Print ( bool  binary = false) const

Prints the frame. If binary is true, binary format is used.

Definition at line 104 of file VFATFrame.cc.

References checkCRC(), checkFootprint(), daqErrorFlags, data, getBC(), getChipID(), getCRC(), getEC(), getFlags(), mps_fire::i, dqmiolumiharvest::j, gpuClustering::pixelStatus::mask, presenceFlags, and w().

104  {
105  if (binary) {
106  for (int i = 0; i < 12; i++) {
107  const word &w = data[11 - i];
108  word mask = (1 << 15);
109  for (int j = 0; j < 16; j++) {
110  if (w & mask)
111  printf("1");
112  else
113  printf("0");
114  mask = (mask >> 1);
115  if ((j + 1) % 4 == 0)
116  printf("|");
117  }
118  printf("\n");
119  }
120  } else {
121  printf("ID = %03x, BC = %04u, EC = %03u, flags = %2u, CRC = %04x ",
122  getChipID(),
123  getBC(),
124  getEC(),
125  getFlags(),
126  getCRC());
127 
128  if (checkCRC())
129  printf("( OK), footprint ");
130  else
131  printf("(FAIL), footprint ");
132 
133  if (checkFootprint())
134  printf(" OK");
135  else
136  printf("FAIL");
137 
138  printf(", frame = %04x|%04x|%04x|", data[11], data[10], data[9]);
139  for (int i = 8; i > 0; i--)
140  printf("%04x", data[i]);
141  printf("|%04x", data[0]);
142 
143  printf(", presFl=%x", presenceFlags);
144  printf(", daqErrFl=%x", daqErrorFlags);
145 
146  printf("\n");
147  }
148 }
virtual bool checkCRC() const
Definition: VFATFrame.cc:62
word data[12]
Definition: VFATFrame.h:123
VFATFrame::word getEC() const
Returns Event Counter (EV<7:0>).
Definition: VFATFrame.h:46
T w() const
bool checkFootprint() const
Definition: VFATFrame.cc:49
VFATFrame::word getCRC() const
Returns the CRC.
Definition: VFATFrame.h:55
VFATFrame::word getFlags() const
Returns flags.
Definition: VFATFrame.h:49
constexpr uint32_t mask
Definition: gpuClustering.h:24
uint64_t word
uint8_t daqErrorFlags
Error flag as given by certain versions of DAQ.
Definition: VFATFrame.h:135
uint8_t presenceFlags
Definition: VFATFrame.h:132
VFATFrame::word getChipID() const
Returns ChipID (ChipID<11:0>).
Definition: VFATFrame.h:52
VFATFrame::word getBC() const
Returns Bunch Crossing number (BC<11:0>).
Definition: VFATFrame.h:43

◆ setDAQErrorFlags()

void VFATFrame::setDAQErrorFlags ( uint8_t  v)
inline

Sets DAQ error flags.

Definition at line 76 of file VFATFrame.h.

References daqErrorFlags, and findQualityFiles::v.

76 { daqErrorFlags = v; }
uint8_t daqErrorFlags
Error flag as given by certain versions of DAQ.
Definition: VFATFrame.h:135

◆ setData()

void VFATFrame::setData ( const word _data)

Copies a memory block to data buffer.

Definition at line 27 of file VFATFrame.cc.

References data.

Referenced by VFATFrame().

27 { memcpy(data, _data, 24); }
word data[12]
Definition: VFATFrame.h:123

◆ setNumberOfClusters()

void VFATFrame::setNumberOfClusters ( uint8_t  v)
inline

Definition at line 78 of file VFATFrame.h.

References numberOfClusters, and findQualityFiles::v.

◆ setPresenceFlags()

void VFATFrame::setPresenceFlags ( uint8_t  v)
inline

Sets presence flags.

Definition at line 58 of file VFATFrame.h.

References presenceFlags, and findQualityFiles::v.

Member Data Documentation

◆ daqErrorFlags

uint8_t VFATFrame::daqErrorFlags
private

Error flag as given by certain versions of DAQ.

Definition at line 135 of file VFATFrame.h.

Referenced by checkCRC(), Print(), setDAQErrorFlags(), and VFATFrame().

◆ data

word VFATFrame::data[12]
protected

Raw data frame as sent by electronics. The container is organized as follows (reversed Figure 8 at page 23 of VFAT2 manual):

* buffer index   content       size
* ---------------------------------------------------------------
*   0            CRC           16 bits
*   1->8         Channel data  128 bits, channel 0 first
*   9            ChipID        4 constant bits (1110) + 12 bits
*   10           EC, Flags     4 constant bits (1100) + 8, 4 bits
*   11           BC            4 constant bits (1010) + 12 bits
* 

Definition at line 123 of file VFATFrame.h.

Referenced by data_sources.node::__str__(), confdb.HLTProcess::_fix_parameter(), confdb.HLTProcess::addEras(), confdb.HLTProcess::addGlobalOptions(), confdb.HLTProcess::append_filenames(), data_sources.json_list::as_dicts(), data_sources.json_list::as_table(), confdb.HLTProcess::build_source(), channelActive(), checkCRC(), checkFootprint(), confdb.HLTProcess::customize(), confdb.HLTProcess::dump(), confdb.HLTProcess::fixPrescales(), data_sources.json_list::get_members(), getActiveChannels(), getBC(), getChipID(), getCRC(), getData(), getEC(), getFlags(), confdb.HLTProcess::getRawConfigurationFromDB(), confdb.HLTProcess::instrumentDQM(), confdb.HLTProcess::instrumentOpenMode(), confdb.HLTProcess::instrumentTiming(), data_sources.json_list::last(), confdb.HLTProcess::loadAdditionalConditions(), confdb.HLTProcess::loadCff(), confdb.HLTProcess::loadSetupCff(), confdb.HLTProcess::overrideGlobalTag(), confdb.HLTProcess::overrideL1MenuXml(), confdb.HLTProcess::overrideOutput(), confdb.HLTProcess::overrideParameters(), confdb.HLTProcess::overrideProcessName(), Print(), confdb.HLTProcess::removeElementFromSequencesTasksAndPaths(), confdb.HLTProcess::runL1Emulator(), setData(), confdb.HLTProcess::specificCustomize(), cuy.FindIssue::startElement(), edmStreamStallGrapher.Stack::update(), confdb.HLTProcess::updateMessageLogger(), and VFATFrame().

◆ numberOfClusters

uint8_t VFATFrame::numberOfClusters
private

Number of clusters. Only available in cluster mode and if the number of clusters exceeds a limit (10).

Definition at line 139 of file VFATFrame.h.

Referenced by getNumberOfClusters(), setNumberOfClusters(), and VFATFrame().

◆ presenceFlags

uint8_t VFATFrame::presenceFlags
private

Flag indicating the presence of various components. bit 1: "BC word" (buffer index 11) bit 2: "EC word" (buffer index 10) bit 3: "ID word" (buffer index 9) bit 4: "CRC word" (buffer index 0) bit 5: "number of clusters word" (prefix 0xD0)

Definition at line 132 of file VFATFrame.h.

Referenced by isBCPresent(), isCRCPresent(), isECPresent(), isIDPresent(), isNumberOfClustersPresent(), Print(), setPresenceFlags(), and VFATFrame().