CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Types | Public Member Functions | Static Public Member Functions | Public 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 ()
 
VFATFrame::word getEC () const
 Returns Event Counter (EV<7:0>). More...
 
VFATFrame::word getFlags () const
 Returns flags. More...
 
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...
 
void Print (bool binary=false) const
 
void setData (const word *_data)
 Copies a memory block to data buffer. More...
 
 VFATFrame (const word *_data=NULL)
 
 VFATFrame (const VFATFrame &copy)
 
virtual ~VFATFrame ()
 

Static Public Member Functions

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

Public Attributes

word daqErrorFlags
 Error flag as given by certain versions of DAQ. More...
 
word data [12]
 
word presenceFlags
 

Detailed Description

Representation of VFAT frame plus extra info added by DAQ.

Definition at line 19 of file VFATFrame.h.

Member Typedef Documentation

typedef uint16_t VFATFrame::word

Definition at line 22 of file VFATFrame.h.

Constructor & Destructor Documentation

VFATFrame::VFATFrame ( const word _data = NULL)

Definition at line 18 of file VFATFrame.cc.

References data, and setData().

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

Definition at line 27 of file VFATFrame.h.

References daqErrorFlags, data, presenceFlags, and setData().

28  {
29  setData(copy.data);
32  }
word data[12]
Definition: VFATFrame.h:135
word presenceFlags
Definition: VFATFrame.h:142
word daqErrorFlags
Error flag as given by certain versions of DAQ.
Definition: VFATFrame.h:145
void setData(const word *_data)
Copies a memory block to data buffer.
Definition: VFATFrame.cc:30
virtual VFATFrame::~VFATFrame ( )
inlinevirtual

Definition at line 34 of file VFATFrame.h.

34 {}

Member Function Documentation

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

internaly used to check CRC

Definition at line 99 of file VFATFrame.cc.

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

Referenced by checkCRC().

100 {
101  word v = 0x0001;
102  word mask = 0x0001;
103  bool d=0;
104  word crc_temp = crc_in;
105  unsigned char datalen = 16;
106 
107  for (int i = 0; i < datalen; i++)
108  {
109  if (dato & v)
110  d = 1;
111  else
112  d = 0;
113 
114  if ((crc_temp & mask)^d)
115  crc_temp = crc_temp>>1 ^ 0x8408;
116  else
117  crc_temp = crc_temp>>1;
118 
119  v <<= 1;
120  }
121 
122  return crc_temp;
123 }
int i
Definition: DBlmapReader.cc:9
uint16_t word
Definition: VFATFrame.h:22
tuple d
Definition: ztail.py:151
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 109 of file VFATFrame.h.

References data.

110  {
111  return ( data[1 + (channel / 16)] & (1 << (channel % 16)) ) ? 1 : 0;
112  }
word data[12]
Definition: VFATFrame.h:135
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 78 of file VFATFrame.cc.

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

Referenced by Print(), and RawToDigiConverter::RunCommon().

79 {
80  // check DAQ error flags
81  if (daqErrorFlags != 0)
82  return false;
83 
84  // return true if CRC not present
85  if (! isCRCPresent())
86  return true;
87 
88  // compare CRC
89  word crc_fin = 0xffff;
90 
91  for (int i = 11; i >= 1; i--)
92  crc_fin = calculateCRC(crc_fin, data[i]);
93 
94  return (crc_fin == data[0]);
95 }
int i
Definition: DBlmapReader.cc:9
word data[12]
Definition: VFATFrame.h:135
uint16_t word
Definition: VFATFrame.h:22
static word calculateCRC(word crc_in, word dato)
internaly used to check CRC
Definition: VFATFrame.cc:99
word daqErrorFlags
Error flag as given by certain versions of DAQ.
Definition: VFATFrame.h:145
bool isCRCPresent() const
Returns true if the CRC word is present in the frame.
Definition: VFATFrame.h:93
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 62 of file VFATFrame.cc.

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

Referenced by Print(), and RawToDigiConverter::RunCommon().

63 {
64  if (isIDPresent() && (data[9] & 0xF000) != 0xE000)
65  return false;
66 
67  if (isECPresent() && (data[10] & 0xF000) != 0xC000)
68  return false;
69 
70  if (isBCPresent() && (data[11] & 0xF000) != 0xA000)
71  return false;
72 
73  return true;
74 }
word data[12]
Definition: VFATFrame.h:135
bool isECPresent() const
Returns true if the EC word is present in the frame.
Definition: VFATFrame.h:81
bool isBCPresent() const
Returns true if the BC word is present in the frame.
Definition: VFATFrame.h:75
bool isIDPresent() const
Returns true if the ID word is present in the frame.
Definition: VFATFrame.h:87
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 37 of file VFATFrame.cc.

References data, i, and hltrates_dqm_sourceclient-live_cfg::offset.

Referenced by RawToDigiConverter::Run().

38 {
39  std::vector<unsigned char> channels;
40 
41  for (int i = 0; i < 8; i++)
42  {
43  // quick check
44  if (!data[1 + i])
45  continue;
46 
47  // go throug bits
48  word mask;
49  char offset;
50  for (mask = 1 << 15, offset = 15; mask; mask >>= 1, offset--)
51  {
52  if (data[1 + i] & mask)
53  channels.push_back( i * 16 + offset );
54  }
55  }
56 
57  return channels;
58 }
int i
Definition: DBlmapReader.cc:9
word data[12]
Definition: VFATFrame.h:135
uint16_t word
Definition: VFATFrame.h:22
VFATFrame::word VFATFrame::getBC ( ) const
inline

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

Definition at line 45 of file VFATFrame.h.

References data.

Referenced by Print().

46  {
47  return data[11] & 0x0FFF;
48  }
word data[12]
Definition: VFATFrame.h:135
VFATFrame::word VFATFrame::getChipID ( ) const
inline

Returns ChipID (ChipID<11:0>).

Definition at line 63 of file VFATFrame.h.

References data.

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

64  {
65  return data[9] & 0x0FFF;
66  }
word data[12]
Definition: VFATFrame.h:135
VFATFrame::word VFATFrame::getCRC ( ) const
inline

Returns the CRC.

Definition at line 69 of file VFATFrame.h.

References data.

Referenced by Print().

70  {
71  return data[0];
72  }
word data[12]
Definition: VFATFrame.h:135
VFATFrame::word* VFATFrame::getData ( void  )
inline

Definition at line 39 of file VFATFrame.h.

References data.

Referenced by RawDataUnpacker::ProcessOptoRxFrameSerial(), and RawDataUnpacker::ProcessVFATDataParallel().

40  {
41  return data;
42  }
word data[12]
Definition: VFATFrame.h:135
VFATFrame::word VFATFrame::getEC ( ) const
inline

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

Definition at line 51 of file VFATFrame.h.

References data.

Referenced by Print().

52  {
53  return (data[10] & 0x0FF0) >> 4;
54  }
word data[12]
Definition: VFATFrame.h:135
VFATFrame::word VFATFrame::getFlags ( ) const
inline

Returns flags.

Definition at line 57 of file VFATFrame.h.

References data.

Referenced by Print().

58  {
59  return data[10] & 0x000F;
60  }
word data[12]
Definition: VFATFrame.h:135
bool VFATFrame::isBCPresent ( ) const
inline

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

Definition at line 75 of file VFATFrame.h.

References presenceFlags.

Referenced by checkFootprint().

76  {
77  return presenceFlags & 0x1;
78  }
word presenceFlags
Definition: VFATFrame.h:142
bool VFATFrame::isCRCPresent ( ) const
inline

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

Definition at line 93 of file VFATFrame.h.

References presenceFlags.

Referenced by checkCRC().

94  {
95  return presenceFlags & 0x8;
96  }
word presenceFlags
Definition: VFATFrame.h:142
bool VFATFrame::isECPresent ( ) const
inline

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

Definition at line 81 of file VFATFrame.h.

References presenceFlags.

Referenced by checkFootprint().

82  {
83  return presenceFlags & 0x2;
84  }
word presenceFlags
Definition: VFATFrame.h:142
bool VFATFrame::isIDPresent ( ) const
inline

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

Definition at line 87 of file VFATFrame.h.

References presenceFlags.

Referenced by checkFootprint(), and RawToDigiConverter::RunCommon().

88  {
89  return presenceFlags & 0x4;
90  }
word presenceFlags
Definition: VFATFrame.h:142
void VFATFrame::Print ( bool  binary = false) const

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

Definition at line 127 of file VFATFrame.cc.

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

128 {
129  if (binary)
130  {
131  for (int i = 0; i < 12; i++)
132  {
133  const word &w = data[11 - i];
134  word mask = (1 << 15);
135  for (int j = 0; j < 16; j++)
136  {
137  if (w & mask)
138  printf("1");
139  else
140  printf("0");
141  mask = (mask >> 1);
142  if ((j + 1) % 4 == 0)
143  printf("|");
144  }
145  printf("\n");
146  }
147  } else {
148  printf("ID = %03x, BC = %04u, EC = %03u, flags = %2u, CRC = %04x ", getChipID(), getBC(), getEC(), getFlags(), getCRC());
149 
150  if (checkCRC())
151  printf("( OK), footprint ");
152  else
153  printf("(FAIL), footprint ");
154 
155  if (checkFootprint())
156  printf(" OK");
157  else
158  printf("FAIL");
159 
160  printf(", frame = %04x|%04x|%04x|", data[11], data[10], data[9]);
161  for (int i = 8; i > 0; i--)
162  printf("%04x", data[i]);
163  printf("|%04x", data[0]);
164 
165  printf(", presFl=%x", presenceFlags);
166  printf(", daqErrFl=%x", daqErrorFlags);
167 
168  printf("\n");
169  }
170 }
int i
Definition: DBlmapReader.cc:9
word data[12]
Definition: VFATFrame.h:135
VFATFrame::word getFlags() const
Returns flags.
Definition: VFATFrame.h:57
const double w
Definition: UKUtility.cc:23
VFATFrame::word getBC() const
Returns Bunch Crossing number (BC&lt;11:0&gt;).
Definition: VFATFrame.h:45
word presenceFlags
Definition: VFATFrame.h:142
uint16_t word
Definition: VFATFrame.h:22
bool checkFootprint() const
Definition: VFATFrame.cc:62
virtual bool checkCRC() const
Definition: VFATFrame.cc:78
int j
Definition: DBlmapReader.cc:9
VFATFrame::word getCRC() const
Returns the CRC.
Definition: VFATFrame.h:69
VFATFrame::word getEC() const
Returns Event Counter (EV&lt;7:0&gt;).
Definition: VFATFrame.h:51
word daqErrorFlags
Error flag as given by certain versions of DAQ.
Definition: VFATFrame.h:145
VFATFrame::word getChipID() const
Returns ChipID (ChipID&lt;11:0&gt;).
Definition: VFATFrame.h:63
void VFATFrame::setData ( const word _data)

Copies a memory block to data buffer.

Definition at line 30 of file VFATFrame.cc.

References data.

Referenced by VFATFrame().

31 {
32  memcpy(data, _data, 24);
33 }
word data[12]
Definition: VFATFrame.h:135

Member Data Documentation

word VFATFrame::daqErrorFlags

Error flag as given by certain versions of DAQ.

Definition at line 145 of file VFATFrame.h.

Referenced by checkCRC(), Print(), RawDataUnpacker::ProcessVFATDataParallel(), and VFATFrame().

word VFATFrame::data[12]
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 135 of file VFATFrame.h.

Referenced by cuy.FindIssue::__init__(), data_sources.node::__str__(), confdb.HLTProcess::_fix_parameter(), 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(), 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::overrideGlobalTag(), confdb.HLTProcess::overrideL1MenuXml(), confdb.HLTProcess::overrideOutput(), confdb.HLTProcess::overrideParameters(), confdb.HLTProcess::overrideProcessName(), Print(), confdb.HLTProcess::runL1Emulator(), setData(), confdb.HLTProcess::specificCustomize(), confdb.HLTProcess::updateMessageLogger(), and VFATFrame().

word VFATFrame::presenceFlags

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)

Definition at line 142 of file VFATFrame.h.

Referenced by isBCPresent(), isCRCPresent(), isECPresent(), isIDPresent(), Print(), RawDataUnpacker::ProcessVFATDataParallel(), and VFATFrame().