CMS 3D CMS Logo

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

#include <VFATFrame.h>

Inheritance diagram for VFATFrame:
DiamondVFATFrame

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...
 
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 ()
 

Protected Attributes

word data [12]
 

Static Private Member Functions

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

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

typedef uint16_t VFATFrame::word

Definition at line 22 of file VFATFrame.h.

Constructor & Destructor Documentation

VFATFrame::VFATFrame ( const word _data = nullptr)

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  numberOfClusters(0) // no clusters by default
22 {
23  if (_data)
24  setData(_data);
25  else
26  memset(data, 0, 12 * sizeof(word));
27 }
word data[12]
Definition: VFATFrame.h:168
uint16_t word
Definition: VFATFrame.h:22
uint8_t daqErrorFlags
Error flag as given by certain versions of DAQ.
Definition: VFATFrame.h:179
uint8_t presenceFlags
Definition: VFATFrame.h:176
uint8_t numberOfClusters
Definition: VFATFrame.h:183
void setData(const word *_data)
Copies a memory block to data buffer.
Definition: VFATFrame.cc:31
VFATFrame::VFATFrame ( const VFATFrame copy)
inline

Definition at line 26 of file VFATFrame.h.

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

27  {
28  setData(copy.data);
32 
33  }
word data[12]
Definition: VFATFrame.h:168
uint8_t daqErrorFlags
Error flag as given by certain versions of DAQ.
Definition: VFATFrame.h:179
uint8_t presenceFlags
Definition: VFATFrame.h:176
uint8_t numberOfClusters
Definition: VFATFrame.h:183
void setData(const word *_data)
Copies a memory block to data buffer.
Definition: VFATFrame.cc:31
virtual VFATFrame::~VFATFrame ( )
inlinevirtual

Definition at line 35 of file VFATFrame.h.

References setData().

35 {}

Member Function Documentation

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

internaly used to check CRC

Definition at line 100 of file VFATFrame.cc.

References edmIntegrityCheck::d, mps_fire::i, RecoTauDiscriminantConfiguration::mask, and findQualityFiles::v.

Referenced by checkCRC().

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

References data, getActiveChannels(), and Print().

143  {
144  return ( data[1 + (channel / 16)] & (1 << (channel % 16)) ) ? true : false;
145  }
word data[12]
Definition: VFATFrame.h:168
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 79 of file VFATFrame.cc.

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

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

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

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

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

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

References data, mps_fire::i, RecoTauDiscriminantConfiguration::mask, and PFRecoTauDiscriminationByIsolation_cfi::offset.

Referenced by channelActive(), and RawToDigiConverter::Run().

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

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

Definition at line 46 of file VFATFrame.h.

References data.

Referenced by Print().

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

Returns ChipID (ChipID<11:0>).

Definition at line 64 of file VFATFrame.h.

References data.

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

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

Returns the CRC.

Definition at line 70 of file VFATFrame.h.

References data.

Referenced by Print().

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

Definition at line 40 of file VFATFrame.h.

References data.

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

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

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

Definition at line 52 of file VFATFrame.h.

References data.

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

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

Returns flags.

Definition at line 58 of file VFATFrame.h.

References data.

Referenced by Print().

59  {
60  return data[10] & 0x000F;
61  }
word data[12]
Definition: VFATFrame.h:168
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 125 of file VFATFrame.h.

References checkCRC(), checkFootprint(), and numberOfClusters.

Referenced by RawToDigiConverter::RunCommon().

126  {
127  return numberOfClusters;
128  }
uint8_t numberOfClusters
Definition: VFATFrame.h:183
bool VFATFrame::isBCPresent ( ) const
inline

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

Definition at line 83 of file VFATFrame.h.

References presenceFlags.

Referenced by checkFootprint().

84  {
85  return presenceFlags & 0x1;
86  }
uint8_t presenceFlags
Definition: VFATFrame.h:176
bool VFATFrame::isCRCPresent ( ) const
inline

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

Definition at line 101 of file VFATFrame.h.

References presenceFlags.

Referenced by checkCRC().

102  {
103  return presenceFlags & 0x8;
104  }
uint8_t presenceFlags
Definition: VFATFrame.h:176
bool VFATFrame::isECPresent ( ) const
inline

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

Definition at line 89 of file VFATFrame.h.

References presenceFlags.

Referenced by checkFootprint().

90  {
91  return presenceFlags & 0x2;
92  }
uint8_t presenceFlags
Definition: VFATFrame.h:176
bool VFATFrame::isIDPresent ( ) const
inline

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

Definition at line 95 of file VFATFrame.h.

References presenceFlags.

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

96  {
97  return presenceFlags & 0x4;
98  }
uint8_t presenceFlags
Definition: VFATFrame.h:176
bool VFATFrame::isNumberOfClustersPresent ( ) const
inline

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

Definition at line 107 of file VFATFrame.h.

References presenceFlags.

Referenced by RawToDigiConverter::RunCommon().

108  {
109  return presenceFlags & 0x10;
110  }
uint8_t presenceFlags
Definition: VFATFrame.h:176
void VFATFrame::Print ( bool  binary = false) const

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

Definition at line 128 of file VFATFrame.cc.

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

Referenced by channelActive().

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

Sets DAQ error flags.

Definition at line 113 of file VFATFrame.h.

References daqErrorFlags, and findQualityFiles::v.

Referenced by ctpps::RawDataUnpacker::ProcessVFATDataParallel().

114  {
115  daqErrorFlags = v;
116  }
uint8_t daqErrorFlags
Error flag as given by certain versions of DAQ.
Definition: VFATFrame.h:179
void VFATFrame::setData ( const word _data)

Copies a memory block to data buffer.

Definition at line 31 of file VFATFrame.cc.

References data.

Referenced by VFATFrame(), and ~VFATFrame().

32 {
33  memcpy(data, _data, 24);
34 }
word data[12]
Definition: VFATFrame.h:168
void VFATFrame::setNumberOfClusters ( uint8_t  v)
inline

Definition at line 118 of file VFATFrame.h.

References numberOfClusters, and findQualityFiles::v.

Referenced by ctpps::RawDataUnpacker::ProcessVFATDataParallel().

119  {
121  }
uint8_t numberOfClusters
Definition: VFATFrame.h:183
void VFATFrame::setPresenceFlags ( uint8_t  v)
inline

Sets presence flags.

Definition at line 77 of file VFATFrame.h.

References presenceFlags, and findQualityFiles::v.

Referenced by ctpps::RawDataUnpacker::ProcessVFATDataParallel().

78  {
79  presenceFlags = v;
80  }
uint8_t presenceFlags
Definition: VFATFrame.h:176

Member Data Documentation

uint8_t VFATFrame::daqErrorFlags
private

Error flag as given by certain versions of DAQ.

Definition at line 179 of file VFATFrame.h.

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

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 168 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(), DiamondVFATFrame::getHptdcErrorFlag(), DiamondVFATFrame::getLeadingEdgeTime(), DiamondVFATFrame::getMultihit(), confdb.HLTProcess::getRawConfigurationFromDB(), DiamondVFATFrame::getThresholdVoltage(), DiamondVFATFrame::getTrailingEdgeTime(), 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(), and VFATFrame().

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

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

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

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