CMS 3D CMS Logo

List of all members | Public Member Functions | Static Public Attributes | Private Attributes
gem::VFATdata Class Reference

#include <VFATdata.h>

Public Member Functions

uint8_t b1010 () const
 v2 More...
 
uint8_t b1100 () const
 
uint8_t b1110 () const
 
uint16_t bc () const
 
uint16_t checkCRC ()
 
uint16_t chipID () const
 
uint16_t crc () const
 
uint16_t crc_cal (uint16_t crc_in, uint16_t dato)
 
uint8_t crcCheck () const
 
uint8_t ec () const
 
uint8_t flag () const
 
uint64_t get_fw () const
 
uint64_t get_sw () const
 
uint64_t get_tw () const
 
uint8_t header () const
 v3 More...
 
uint64_t lsData () const
 
uint64_t msData () const
 
int phi () const
 
uint8_t position () const
 
uint8_t quality ()
 quality flag - bit: 0 good, 1 crc fail, 2 b1010 fail, 3 b1100 fail, 4 b1110 More...
 
void read_fw (uint64_t word)
 Read first word from the block. More...
 
void read_sw (uint64_t word)
 Read second word from the block. More...
 
void read_tw (uint64_t word)
 Read third word from the block. More...
 
void setPhi (int i)
 
void setVersion (int i)
 
bool vc () const
 
int version () const
 
 VFATdata ()
 
 VFATdata (const int vfatVer, const uint16_t BC, const uint32_t EC, const uint16_t chipID, const uint64_t lsDatas, const uint64_t msDatas)
 
uint16_t vfatId () const
 
 ~VFATdata ()
 

Static Public Attributes

static const int nChannels = 128
 
static const int sizeChipID = 12
 

Private Attributes

uint64_t fw_
 phi position of vfat in chamber More...
 
int phiPos_
 vfat version More...
 
uint64_t sw_
 
uint64_t tw_
 
int ver_
 

Detailed Description

Definition at line 48 of file VFATdata.h.

Constructor & Destructor Documentation

◆ VFATdata() [1/2]

VFATdata::VFATdata ( )

Definition at line 5 of file VFATdata.cc.

5 : ver_(0), phiPos_(0), fw_(0), sw_(0), tw_(0) {}

◆ VFATdata() [2/2]

VFATdata::VFATdata ( const int  vfatVer,
const uint16_t  BC,
const uint32_t  EC,
const uint16_t  chipID,
const uint64_t  lsDatas,
const uint64_t  msDatas 
)

Definition at line 7 of file VFATdata.cc.

12  {
13  // this constructor only used for packing sim digis
14  VFATfirst fw{0};
15  VFATsecond sw{0};
16  VFATthird tw{0};
17 
18  fw.header = 0x1E;
19 
20  if (vfatVer == 3) {
21  fw.bc = BC;
22  fw.ec = EC;
23  fw.pos = chipID;
24  } else {
25  fw.chipID = chipID;
26  fw.b1110 = 14;
27  fw.b1100 = 12;
28  fw.b1010 = 10;
29  fw.ecV2 = EC;
30  fw.bcV2 = BC;
31  }
32 
33  sw.lsData1 = lsDatas >> 48;
34  tw.lsData2 = lsDatas & 0x0000ffffffffffff;
35 
36  fw.msData1 = msDatas >> 48;
37  sw.msData2 = msDatas & 0x0000ffffffffffff;
38  ver_ = vfatVer;
39 
40  fw_ = fw.word;
41  sw_ = sw.word;
42  tw_ = tw.word;
43  // checkCRC only works after words are set
44  // checkCRC not yet implemented for v3
45  tw.crc = checkCRC();
46  // once crc is found, save new third word
47  tw_ = tw.word;
48 }

References checkCRC(), chipID(), fw_, sw_, tw_, and ver_.

◆ ~VFATdata()

gem::VFATdata::~VFATdata ( )
inline

Definition at line 58 of file VFATdata.h.

58 {}

Member Function Documentation

◆ b1010()

uint8_t gem::VFATdata::b1010 ( ) const
inline

v2

Definition at line 108 of file VFATdata.h.

108 { return VFATfirst{fw_}.b1010; }

References fw_.

◆ b1100()

uint8_t gem::VFATdata::b1100 ( ) const
inline

Definition at line 109 of file VFATdata.h.

109 { return VFATfirst{fw_}.b1100; }

References fw_.

◆ b1110()

uint8_t gem::VFATdata::b1110 ( ) const
inline

Definition at line 110 of file VFATdata.h.

110 { return VFATfirst{fw_}.b1110; }

References fw_.

◆ bc()

uint16_t gem::VFATdata::bc ( ) const
inline

Definition at line 79 of file VFATdata.h.

79  {
80  if (ver_ == 2)
81  return VFATfirst{fw_}.bcV2;
82  return VFATfirst{fw_}.bc;
83  }

References fw_, and ver_.

Referenced by geometryXMLparser.Alignable::covariance(), GEMVFATStatus::GEMVFATStatus(), and GEMVfatStatusDigi::GEMVfatStatusDigi().

◆ checkCRC()

uint16_t VFATdata::checkCRC ( )

Definition at line 86 of file VFATdata.cc.

86  {
87  uint16_t vfatBlockWords[12];
88  vfatBlockWords[11] = ((0x000f & VFATfirst{fw_}.b1010) << 12) | VFATfirst{fw_}.bcV2;
89  vfatBlockWords[10] =
90  ((0x000f & VFATfirst{fw_}.b1100) << 12) | ((0x00ff & VFATfirst{fw_}.ecV2) << 4) | (0x000f & VFATfirst{fw_}.flag);
91  vfatBlockWords[9] = ((0x000f & VFATfirst{fw_}.b1110) << 12) | VFATfirst{fw_}.chipID;
92  vfatBlockWords[8] = (0xffff000000000000 & msData()) >> 48;
93  vfatBlockWords[7] = (0x0000ffff00000000 & msData()) >> 32;
94  vfatBlockWords[6] = (0x00000000ffff0000 & msData()) >> 16;
95  vfatBlockWords[5] = (0x000000000000ffff & msData());
96  vfatBlockWords[4] = (0xffff000000000000 & lsData()) >> 48;
97  vfatBlockWords[3] = (0x0000ffff00000000 & lsData()) >> 32;
98  vfatBlockWords[2] = (0x00000000ffff0000 & lsData()) >> 16;
99  vfatBlockWords[1] = (0x000000000000ffff & lsData());
100 
101  uint16_t crc_fin = 0xffff;
102  for (int i = 11; i >= 1; i--) {
103  crc_fin = crc_cal(crc_fin, vfatBlockWords[i]);
104  }
105  return crc_fin;
106 }

References crc_cal(), fw_, mps_fire::i, lsData(), and msData().

Referenced by quality(), and VFATdata().

◆ chipID()

uint16_t gem::VFATdata::chipID ( ) const
inline

Definition at line 112 of file VFATdata.h.

112 { return VFATfirst{fw_}.chipID; }

References fw_.

Referenced by VFATdata().

◆ crc()

uint16_t gem::VFATdata::crc ( ) const
inline

Definition at line 113 of file VFATdata.h.

113 { return VFATthird{tw_}.crc; }

References tw_.

◆ crc_cal()

uint16_t VFATdata::crc_cal ( uint16_t  crc_in,
uint16_t  dato 
)

Definition at line 66 of file VFATdata.cc.

66  {
67  uint16_t v = 0x0001;
68  uint16_t mask = 0x0001;
69  uint16_t d = 0x0000;
70  uint16_t crc_temp = crc_in;
71  unsigned char datalen = 16;
72  for (int i = 0; i < datalen; i++) {
73  if (dato & v)
74  d = 0x0001;
75  else
76  d = 0x0000;
77  if ((crc_temp & mask) ^ d)
78  crc_temp = crc_temp >> 1 ^ 0x8408;
79  else
80  crc_temp = crc_temp >> 1;
81  v <<= 1;
82  }
83  return crc_temp;
84 }

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

Referenced by checkCRC().

◆ crcCheck()

uint8_t gem::VFATdata::crcCheck ( ) const
inline

Definition at line 105 of file VFATdata.h.

105 { return VFATfirst{fw_}.vc; } // to be removed

References fw_.

◆ ec()

uint8_t gem::VFATdata::ec ( ) const
inline

Definition at line 84 of file VFATdata.h.

84  {
85  if (ver_ == 2)
86  return VFATfirst{fw_}.ecV2;
87  return VFATfirst{fw_}.ec;
88  }

References fw_, and ver_.

Referenced by GEMVFATStatus::GEMVFATStatus(), and GEMVfatStatusDigi::GEMVfatStatusDigi().

◆ flag()

uint8_t gem::VFATdata::flag ( ) const
inline

Definition at line 111 of file VFATdata.h.

111 { return VFATfirst{fw_}.flag; }

References fw_.

Referenced by GEMVfatStatusDigi::GEMVfatStatusDigi().

◆ get_fw()

uint64_t gem::VFATdata::get_fw ( ) const
inline

Definition at line 62 of file VFATdata.h.

62 { return fw_; }

References fw_.

◆ get_sw()

uint64_t gem::VFATdata::get_sw ( ) const
inline

Definition at line 66 of file VFATdata.h.

66 { return sw_; }

References sw_.

◆ get_tw()

uint64_t gem::VFATdata::get_tw ( ) const
inline

Definition at line 70 of file VFATdata.h.

70 { return tw_; }

References tw_.

◆ header()

uint8_t gem::VFATdata::header ( ) const
inline

v3

Definition at line 102 of file VFATdata.h.

102 { return VFATfirst{fw_}.header; }

References fw_.

Referenced by GEMVFATStatus::GEMVFATStatus().

◆ lsData()

uint64_t gem::VFATdata::lsData ( ) const
inline

Definition at line 76 of file VFATdata.h.

76 { return uint64_t(VFATsecond{sw_}.lsData1) << 48 | VFATthird{tw_}.lsData2; }

References sw_, and tw_.

Referenced by checkCRC().

◆ msData()

uint64_t gem::VFATdata::msData ( ) const
inline

Definition at line 77 of file VFATdata.h.

77 { return uint64_t(VFATfirst{fw_}.msData1) << 48 | VFATsecond{sw_}.msData2; }

References fw_, and sw_.

Referenced by checkCRC().

◆ phi()

int gem::VFATdata::phi ( ) const
inline

Definition at line 74 of file VFATdata.h.

74 { return phiPos_; }

References phiPos_.

Referenced by Particle.Particle::__str__(), GEMVfatStatusDigi::GEMVfatStatusDigi(), and ntupleDataFormat.Track::phiPull().

◆ position()

uint8_t gem::VFATdata::position ( ) const
inline

Definition at line 104 of file VFATdata.h.

104 { return VFATfirst{fw_}.pos; }

References fw_.

◆ quality()

uint8_t VFATdata::quality ( )

quality flag - bit: 0 good, 1 crc fail, 2 b1010 fail, 3 b1100 fail, 4 b1110

Definition at line 50 of file VFATdata.cc.

50  {
51  uint8_t q = 0;
52  if (ver_ == 2) {
53  if (VFATthird{tw_}.crc != checkCRC())
54  q = 1;
55  if (VFATfirst{fw_}.b1010 != 10)
56  q |= 1UL << 1;
57  if (VFATfirst{fw_}.b1100 != 12)
58  q |= 1UL << 2;
59  if (VFATfirst{fw_}.b1110 != 14)
60  q |= 1UL << 3;
61  }
62  // quality test not yet implemented in v3
63  return q;
64 }

References checkCRC(), fw_, submitPVResolutionJobs::q, tw_, and ver_.

Referenced by GEMVfatStatusDigi::GEMVfatStatusDigi().

◆ read_fw()

void gem::VFATdata::read_fw ( uint64_t  word)
inline

Read first word from the block.

Definition at line 61 of file VFATdata.h.

61 { fw_ = word; }

References fw_.

◆ read_sw()

void gem::VFATdata::read_sw ( uint64_t  word)
inline

Read second word from the block.

Definition at line 65 of file VFATdata.h.

65 { sw_ = word; }

References sw_.

◆ read_tw()

void gem::VFATdata::read_tw ( uint64_t  word)
inline

Read third word from the block.

Definition at line 69 of file VFATdata.h.

69 { tw_ = word; }

References tw_.

◆ setPhi()

void gem::VFATdata::setPhi ( int  i)
inline

Definition at line 73 of file VFATdata.h.

73 { phiPos_ = i; }

References mps_fire::i, and phiPos_.

◆ setVersion()

void gem::VFATdata::setVersion ( int  i)
inline

Definition at line 95 of file VFATdata.h.

95 { ver_ = i; }

References mps_fire::i, and ver_.

◆ vc()

bool gem::VFATdata::vc ( ) const
inline

Definition at line 103 of file VFATdata.h.

103 { return VFATfirst{fw_}.vc; }

References fw_.

Referenced by GEMVFATStatus::GEMVFATStatus().

◆ version()

int gem::VFATdata::version ( ) const
inline

Definition at line 96 of file VFATdata.h.

96 { return ver_; }

References ver_.

Referenced by validation.Sample::datasetpattern(), validation.Sample::filename(), and GEMVFATStatus::GEMVFATStatus().

◆ vfatId()

uint16_t gem::VFATdata::vfatId ( ) const
inline

Definition at line 89 of file VFATdata.h.

89  {
90  if (ver_ == 2)
91  return VFATfirst{fw_}.chipID;
92  return VFATfirst{fw_}.pos;
93  }

References fw_, and ver_.

Member Data Documentation

◆ fw_

uint64_t gem::VFATdata::fw_
private

phi position of vfat in chamber

Definition at line 125 of file VFATdata.h.

Referenced by b1010(), b1100(), b1110(), bc(), checkCRC(), chipID(), crcCheck(), ec(), flag(), get_fw(), header(), msData(), position(), quality(), read_fw(), vc(), VFATdata(), and vfatId().

◆ nChannels

const int gem::VFATdata::nChannels = 128
static

Definition at line 118 of file VFATdata.h.

◆ phiPos_

int gem::VFATdata::phiPos_
private

vfat version

Definition at line 123 of file VFATdata.h.

Referenced by phi(), and setPhi().

◆ sizeChipID

const int gem::VFATdata::sizeChipID = 12
static

Definition at line 119 of file VFATdata.h.

◆ sw_

uint64_t gem::VFATdata::sw_
private

Definition at line 126 of file VFATdata.h.

Referenced by get_sw(), lsData(), msData(), read_sw(), and VFATdata().

◆ tw_

uint64_t gem::VFATdata::tw_
private

Definition at line 127 of file VFATdata.h.

Referenced by crc(), get_tw(), lsData(), quality(), read_tw(), and VFATdata().

◆ ver_

int gem::VFATdata::ver_
private

Definition at line 122 of file VFATdata.h.

Referenced by bc(), ec(), quality(), setVersion(), version(), VFATdata(), and vfatId().

mps_fire.i
i
Definition: mps_fire.py:428
gem::VFATdata::checkCRC
uint16_t checkCRC()
Definition: VFATdata.cc:86
gem::VFATfirst
VFAT data structure - 3 words of 64 bits each.
Definition: VFATdata.h:8
gem::VFATdata::phiPos_
int phiPos_
vfat version
Definition: VFATdata.h:123
findQualityFiles.v
v
Definition: findQualityFiles.py:179
gem::VFATdata::msData
uint64_t msData() const
Definition: VFATdata.h:77
word
uint64_t word
Definition: CTPPSTotemDataFormatter.cc:29
gem::VFATdata::tw_
uint64_t tw_
Definition: VFATdata.h:127
gem::VFATdata::ver_
int ver_
Definition: VFATdata.h:122
gem::VFATdata::chipID
uint16_t chipID() const
Definition: VFATdata.h:112
fw
Definition: estimate_field.h:12
submitPVResolutionJobs.q
q
Definition: submitPVResolutionJobs.py:84
gem::VFATdata::crc_cal
uint16_t crc_cal(uint16_t crc_in, uint16_t dato)
Definition: VFATdata.cc:66
gem::VFATdata::lsData
uint64_t lsData() const
Definition: VFATdata.h:76
gem::VFATsecond
Definition: VFATdata.h:33
gem::VFATdata::fw_
uint64_t fw_
phi position of vfat in chamber
Definition: VFATdata.h:125
cond::uint64_t
unsigned long long uint64_t
Definition: Time.h:13
ztail.d
d
Definition: ztail.py:151
gem::VFATthird
Definition: VFATdata.h:40
gem::VFATdata::sw_
uint64_t sw_
Definition: VFATdata.h:126