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 VFATFrame &copy)
 
 VFATFrame (const word *_data=nullptr)
 
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 18 of file VFATFrame.h.

Member Typedef Documentation

◆ word

typedef uint16_t VFATFrame::word

Definition at line 25 of file VFATFrame.h.

Constructor & Destructor Documentation

◆ VFATFrame() [1/2]

VFATFrame::VFATFrame ( const word _data = nullptr)

Definition at line 15 of file VFATFrame.cc.

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));

References data, and setData().

◆ VFATFrame() [2/2]

VFATFrame::VFATFrame ( const VFATFrame copy)
inline

Definition at line 30 of file VFATFrame.h.

33  {}
34 

◆ ~VFATFrame()

virtual VFATFrame::~VFATFrame ( )
inlinevirtual

Definition at line 37 of file VFATFrame.h.

References data.

Member Function Documentation

◆ calculateCRC()

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

internaly used to check CRC

Definition at line 79 of file VFATFrame.cc.

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;

References ztail::d, mps_fire::i, and findQualityFiles::v.

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

◆ 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 99 of file VFATFrame.h.

110  :

◆ 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 61 of file VFATFrame.cc.

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]);

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

Referenced by Print().

◆ 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 48 of file VFATFrame.cc.

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;

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

Referenced by Print().

◆ 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 28 of file VFATFrame.cc.

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;

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

◆ getBC()

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

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

Definition at line 47 of file VFATFrame.h.

References data.

Referenced by Print().

◆ getChipID()

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

Returns ChipID (ChipID<11:0>).

Definition at line 56 of file VFATFrame.h.

58 { presenceFlags = v; }

References presenceFlags, and findQualityFiles::v.

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

◆ getCRC()

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

Returns the CRC.

Definition at line 59 of file VFATFrame.h.

61 { return presenceFlags & 0x1; }

References presenceFlags.

Referenced by Print().

◆ getData() [1/2]

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

◆ getData() [2/2]

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

Definition at line 44 of file VFATFrame.h.

References data.

◆ getEC()

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

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

Definition at line 50 of file VFATFrame.h.

References data.

Referenced by Print().

◆ getFlags()

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

Returns flags.

Definition at line 53 of file VFATFrame.h.

References data.

Referenced by Print().

◆ 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 86 of file VFATFrame.h.

95 {

◆ isBCPresent()

bool VFATFrame::isBCPresent ( ) const
inline

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

Definition at line 65 of file VFATFrame.h.

67 { return presenceFlags & 0x4; }

References presenceFlags.

Referenced by checkFootprint().

◆ isCRCPresent()

bool VFATFrame::isCRCPresent ( ) const
inline

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

Definition at line 74 of file VFATFrame.h.

76 { daqErrorFlags = v; }

References daqErrorFlags, and findQualityFiles::v.

Referenced by checkCRC().

◆ isECPresent()

bool VFATFrame::isECPresent ( ) const
inline

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

Definition at line 68 of file VFATFrame.h.

70 { return presenceFlags & 0x8; }

References presenceFlags.

Referenced by checkFootprint().

◆ isIDPresent()

bool VFATFrame::isIDPresent ( ) const
inline

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

Definition at line 71 of file VFATFrame.h.

73 { return presenceFlags & 0x10; }

References presenceFlags.

Referenced by checkFootprint().

◆ isNumberOfClustersPresent()

bool VFATFrame::isNumberOfClustersPresent ( ) const
inline

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

Definition at line 77 of file VFATFrame.h.

78 { numberOfClusters = v; }

References numberOfClusters, and findQualityFiles::v.

◆ Print()

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

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

Definition at line 103 of file VFATFrame.cc.

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  }

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

◆ setDAQErrorFlags()

void VFATFrame::setDAQErrorFlags ( uint8_t  v)
inline

Sets DAQ error flags.

Definition at line 80 of file VFATFrame.h.

82 { return numberOfClusters; }

◆ setData()

void VFATFrame::setData ( const word _data)

Copies a memory block to data buffer.

Definition at line 26 of file VFATFrame.cc.

References data.

Referenced by VFATFrame().

◆ setNumberOfClusters()

void VFATFrame::setNumberOfClusters ( uint8_t  v)
inline

Definition at line 82 of file VFATFrame.h.

82 { return numberOfClusters; }

References numberOfClusters.

◆ setPresenceFlags()

void VFATFrame::setPresenceFlags ( uint8_t  v)
inline

Sets presence flags.

Definition at line 62 of file VFATFrame.h.

64 { return presenceFlags & 0x2; }

References presenceFlags.

Member Data Documentation

◆ daqErrorFlags

uint8_t VFATFrame::daqErrorFlags
private

Error flag as given by certain versions of DAQ.

Definition at line 139 of file VFATFrame.h.

Referenced by checkCRC(), isCRCPresent(), and Print().

◆ 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 127 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(), checkCRC(), checkFootprint(), confdb.HLTProcess::customize(), confdb.HLTProcess::dump(), confdb.HLTProcess::fixPrescales(), data_sources.json_list::get_members(), getActiveChannels(), getBC(), 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::runL1Emulator(), setData(), confdb.HLTProcess::specificCustomize(), cuy.FindIssue::startElement(), edmStreamStallGrapher.Stack::update(), confdb.HLTProcess::updateMessageLogger(), VFATFrame(), 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 143 of file VFATFrame.h.

Referenced by isNumberOfClustersPresent(), and setNumberOfClusters().

◆ 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 136 of file VFATFrame.h.

Referenced by getChipID(), getCRC(), isBCPresent(), isECPresent(), isIDPresent(), Print(), and setPresenceFlags().

mps_fire.i
i
Definition: mps_fire.py:428
VFATFrame::checkCRC
virtual bool checkCRC() const
Definition: VFATFrame.cc:61
VFATFrame::checkFootprint
bool checkFootprint() const
Definition: VFATFrame.cc:48
VFATFrame::isCRCPresent
bool isCRCPresent() const
Returns true if the CRC word is present in the frame.
Definition: VFATFrame.h:74
findQualityFiles.v
v
Definition: findQualityFiles.py:179
word
uint64_t word
Definition: CTPPSTotemDataFormatter.cc:29
VFATFrame::getFlags
VFATFrame::word getFlags() const
Returns flags.
Definition: VFATFrame.h:53
VFATFrame::numberOfClusters
uint8_t numberOfClusters
Definition: VFATFrame.h:143
VFATFrame::getBC
VFATFrame::word getBC() const
Returns Bunch Crossing number (BC<11:0>).
Definition: VFATFrame.h:47
w
const double w
Definition: UKUtility.cc:23
VFATFrame::data
word data[12]
Definition: VFATFrame.h:127
VFATFrame::isBCPresent
bool isBCPresent() const
Returns true if the BC word is present in the frame.
Definition: VFATFrame.h:65
VFATFrame::getChipID
VFATFrame::word getChipID() const
Returns ChipID (ChipID<11:0>).
Definition: VFATFrame.h:56
VFATFrame::getCRC
VFATFrame::word getCRC() const
Returns the CRC.
Definition: VFATFrame.h:59
VFATFrame::isECPresent
bool isECPresent() const
Returns true if the EC word is present in the frame.
Definition: VFATFrame.h:68
VFATFrame::getEC
VFATFrame::word getEC() const
Returns Event Counter (EV<7:0>).
Definition: VFATFrame.h:50
VFATFrame::isIDPresent
bool isIDPresent() const
Returns true if the ID word is present in the frame.
Definition: VFATFrame.h:71
VFATFrame::calculateCRC
static word calculateCRC(word crc_in, word dato)
internaly used to check CRC
Definition: VFATFrame.cc:79
ewkTauDQM_cfi.channels
channels
Definition: ewkTauDQM_cfi.py:14
VFATFrame::daqErrorFlags
uint8_t daqErrorFlags
Error flag as given by certain versions of DAQ.
Definition: VFATFrame.h:139
ztail.d
d
Definition: ztail.py:151
VFATFrame::presenceFlags
uint8_t presenceFlags
Definition: VFATFrame.h:136
dqmiolumiharvest.j
j
Definition: dqmiolumiharvest.py:66
hltrates_dqm_sourceclient-live_cfg.offset
offset
Definition: hltrates_dqm_sourceclient-live_cfg.py:82
VFATFrame::setData
void setData(const word *_data)
Copies a memory block to data buffer.
Definition: VFATFrame.cc:26