CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
List of all members | Public Member Functions | Static Public Member Functions | Private Attributes | Static Private Attributes
CSCTMBData Class Reference

#include <CSCTMBData.h>

Public Member Functions

std::bitset< 22 > calCRC22 (const std::vector< std::bitset< 16 > > &datain)
 
bool checkSize () const
 sees if the size adds up to the word count More...
 
CSCComparatorDatacomparatorData ()
 
 CSCTMBData ()
 
 CSCTMBData (int firmwareVersion, int firmwareRevision, int ncfebs=5)
 
 CSCTMBData (const uint16_t *buf)
 
 CSCTMBData (const CSCTMBData &data)
 
short unsigned int CWordCnt () const
 
CSCGEMDatagemData () const
 
int getCRC () const
 
bool hasGEM () const
 
bool hasRPC () const
 check this before using RPC More...
 
bool hasTMBBlockedCFEB () const
 check this before TMB Block CFEB More...
 
bool hasTMBMiniScope () const
 check this before using TMB mini scope More...
 
bool hasTMBScope () const
 check this before using TMB Scope More...
 
std::bitset< 22 > nextCRC22_D16 (const std::bitset< 16 > &D, const std::bitset< 22 > &C)
 
boost::dynamic_bitset pack ()
 not const because it sets size int TMBTrailer More...
 
CSCRPCDatarpcData ()
 
const unsigned short size () const
 
CSCTMBBlockedCFEBtmbBlockedCFEB () const
 
int TMBCRCcalc ()
 
CSCTMBHeadertmbHeader ()
 
CSCTMBMiniScopetmbMiniScope () const
 
CSCTMBScopetmbScope () const
 
CSCTMBTrailertmbTrailer ()
 
int UnpackTMB (const uint16_t *buf)
 
 ~CSCTMBData ()
 

Static Public Member Functions

static void selfTest ()
 tests packing More...
 
static void setDebug (const bool value)
 

Private Attributes

unsigned short cWordCnt
 
unsigned short size_
 
unsigned theB0CLine
 
bool theBlockedCFEBIsPresent
 
CSCComparatorData theComparatorData
 
unsigned theE0FLine
 
CSCGEMDatatheGEMData
 
bool theGEMDataIsPresent
 
const uint16_t * theOriginalBuffer
 
CSCRPCData theRPCData
 
bool theRPCDataIsPresent
 
CSCTMBBlockedCFEBtheTMBBlockedCFEB
 
CSCTMBHeader theTMBHeader
 
CSCTMBMiniScopetheTMBMiniScope
 
bool theTMBMiniScopeIsPresent
 
CSCTMBScopetheTMBScope
 
bool theTMBScopeIsPresent
 The TMB scope is not present in most of data hence its dynamic. More...
 
CSCTMBTrailer theTMBTrailer
 

Static Private Attributes

static std::atomic< bool > debug {false}
 

Detailed Description

Author
A. Tumanov - Rice

Definition at line 25 of file CSCTMBData.h.

Constructor & Destructor Documentation

CSCTMBData::CSCTMBData ( )

Definition at line 21 of file CSCTMBData.cc.

22  : theOriginalBuffer(nullptr),
23  theB0CLine(0),
24  theE0FLine(0),
25  theTMBHeader(2007, 0x50c3),
27  theGEMData(nullptr),
28  theTMBScopeIsPresent(false),
29  theTMBScope(nullptr),
31  theTMBMiniScope(nullptr),
33  theTMBBlockedCFEB(nullptr),
35  size_(0),
36  cWordCnt(0),
37  theRPCDataIsPresent(false),
38  theGEMDataIsPresent(false) {}
unsigned theE0FLine
Definition: CSCTMBData.h:77
bool theRPCDataIsPresent
Definition: CSCTMBData.h:103
CSCTMBTrailer theTMBTrailer
Definition: CSCTMBData.h:95
CSCGEMData * theGEMData
Definition: CSCTMBData.h:82
bool theBlockedCFEBIsPresent
Definition: CSCTMBData.h:92
unsigned short size_
Definition: CSCTMBData.h:101
bool theTMBMiniScopeIsPresent
Definition: CSCTMBData.h:89
unsigned theB0CLine
Definition: CSCTMBData.h:76
bool theGEMDataIsPresent
Definition: CSCTMBData.h:104
int sizeInWords() const
in 16-bit words
CSCTMBHeader theTMBHeader
Definition: CSCTMBData.h:79
CSCTMBBlockedCFEB * theTMBBlockedCFEB
Definition: CSCTMBData.h:93
const uint16_t * theOriginalBuffer
Definition: CSCTMBData.h:73
unsigned short cWordCnt
Definition: CSCTMBData.h:102
unsigned short int sizeInWords() const
Definition: CSCTMBHeader.h:103
CSCComparatorData theComparatorData
Definition: CSCTMBData.h:80
CSCTMBMiniScope * theTMBMiniScope
Definition: CSCTMBData.h:90
bool theTMBScopeIsPresent
The TMB scope is not present in most of data hence its dynamic.
Definition: CSCTMBData.h:84
CSCTMBScope * theTMBScope
Definition: CSCTMBData.h:85
CSCTMBData::CSCTMBData ( int  firmwareVersion,
int  firmwareRevision,
int  ncfebs = 5 
)

Definition at line 40 of file CSCTMBData.cc.

References CSCTMBHeader::setNCFEBs(), CSCComparatorData::sizeInWords(), CSCTMBHeader::sizeInWords(), theComparatorData, theTMBHeader, and theTMBTrailer.

41  : theOriginalBuffer(nullptr),
42  theB0CLine(0),
43  theE0FLine(0),
44  theTMBHeader(firmwareVersion, firmwareRevision),
46  theGEMData(nullptr),
47  theTMBScopeIsPresent(false),
48  theTMBScope(nullptr),
50  theTMBMiniScope(nullptr),
52  theTMBBlockedCFEB(nullptr),
54  size_(0),
55  cWordCnt(0),
56  theRPCDataIsPresent(false),
57  theGEMDataIsPresent(false) {
58  theTMBHeader.setNCFEBs(cfebs);
61 }
unsigned theE0FLine
Definition: CSCTMBData.h:77
bool theRPCDataIsPresent
Definition: CSCTMBData.h:103
CSCTMBTrailer theTMBTrailer
Definition: CSCTMBData.h:95
CSCGEMData * theGEMData
Definition: CSCTMBData.h:82
bool theBlockedCFEBIsPresent
Definition: CSCTMBData.h:92
unsigned short size_
Definition: CSCTMBData.h:101
bool theTMBMiniScopeIsPresent
Definition: CSCTMBData.h:89
unsigned theB0CLine
Definition: CSCTMBData.h:76
bool theGEMDataIsPresent
Definition: CSCTMBData.h:104
int sizeInWords() const
in 16-bit words
void setNCFEBs(uint16_t ncfebs)
Definition: CSCTMBHeader.h:74
CSCTMBHeader theTMBHeader
Definition: CSCTMBData.h:79
CSCTMBBlockedCFEB * theTMBBlockedCFEB
Definition: CSCTMBData.h:93
const uint16_t * theOriginalBuffer
Definition: CSCTMBData.h:73
unsigned short cWordCnt
Definition: CSCTMBData.h:102
unsigned short int sizeInWords() const
Definition: CSCTMBHeader.h:103
CSCComparatorData theComparatorData
Definition: CSCTMBData.h:80
CSCTMBMiniScope * theTMBMiniScope
Definition: CSCTMBData.h:90
bool theTMBScopeIsPresent
The TMB scope is not present in most of data hence its dynamic.
Definition: CSCTMBData.h:84
CSCTMBScope * theTMBScope
Definition: CSCTMBData.h:85
CSCTMBData::~CSCTMBData ( )

Definition at line 123 of file CSCTMBData.cc.

References theBlockedCFEBIsPresent, theGEMData, theGEMDataIsPresent, theTMBBlockedCFEB, theTMBMiniScope, theTMBMiniScopeIsPresent, theTMBScope, and theTMBScopeIsPresent.

123  {
124  if (theTMBScopeIsPresent) {
125  delete theTMBScope;
126  theTMBScopeIsPresent = false;
127  }
128 
130  delete theTMBMiniScope;
131  theTMBMiniScopeIsPresent = false;
132  }
133 
135  delete theTMBBlockedCFEB;
136  theBlockedCFEBIsPresent = false;
137  }
138 
139  if (theGEMDataIsPresent) {
140  delete theGEMData;
141  theGEMDataIsPresent = false;
142  }
143 }
CSCGEMData * theGEMData
Definition: CSCTMBData.h:82
bool theBlockedCFEBIsPresent
Definition: CSCTMBData.h:92
bool theTMBMiniScopeIsPresent
Definition: CSCTMBData.h:89
bool theGEMDataIsPresent
Definition: CSCTMBData.h:104
CSCTMBBlockedCFEB * theTMBBlockedCFEB
Definition: CSCTMBData.h:93
CSCTMBMiniScope * theTMBMiniScope
Definition: CSCTMBData.h:90
bool theTMBScopeIsPresent
The TMB scope is not present in most of data hence its dynamic.
Definition: CSCTMBData.h:84
CSCTMBScope * theTMBScope
Definition: CSCTMBData.h:85
CSCTMBData::CSCTMBData ( const uint16_t *  buf)

Definition at line 63 of file CSCTMBData.cc.

References size_, and UnpackTMB().

65  theTMBHeader(2007, 0x50c3),
67  theGEMData(nullptr),
68  theTMBScopeIsPresent(false),
69  theTMBScope(nullptr),
71  theTMBMiniScope(nullptr),
73  theTMBBlockedCFEB(nullptr),
75  theRPCDataIsPresent(false),
76  theGEMDataIsPresent(false) {
77  size_ = UnpackTMB(buf);
78 }
bool theRPCDataIsPresent
Definition: CSCTMBData.h:103
CSCTMBTrailer theTMBTrailer
Definition: CSCTMBData.h:95
CSCGEMData * theGEMData
Definition: CSCTMBData.h:82
bool theBlockedCFEBIsPresent
Definition: CSCTMBData.h:92
unsigned short size_
Definition: CSCTMBData.h:101
bool theTMBMiniScopeIsPresent
Definition: CSCTMBData.h:89
bool theGEMDataIsPresent
Definition: CSCTMBData.h:104
int sizeInWords() const
in 16-bit words
CSCTMBHeader theTMBHeader
Definition: CSCTMBData.h:79
CSCTMBBlockedCFEB * theTMBBlockedCFEB
Definition: CSCTMBData.h:93
const uint16_t * theOriginalBuffer
Definition: CSCTMBData.h:73
unsigned short int sizeInWords() const
Definition: CSCTMBHeader.h:103
CSCComparatorData theComparatorData
Definition: CSCTMBData.h:80
CSCTMBMiniScope * theTMBMiniScope
Definition: CSCTMBData.h:90
bool theTMBScopeIsPresent
The TMB scope is not present in most of data hence its dynamic.
Definition: CSCTMBData.h:84
CSCTMBScope * theTMBScope
Definition: CSCTMBData.h:85
int UnpackTMB(const uint16_t *buf)
Definition: CSCTMBData.cc:173
CSCTMBData::CSCTMBData ( const CSCTMBData data)

Definition at line 82 of file CSCTMBData.cc.

References theBlockedCFEBIsPresent, theGEMData, theGEMDataIsPresent, theTMBBlockedCFEB, theTMBMiniScope, theTMBMiniScopeIsPresent, theTMBScope, and theTMBScopeIsPresent.

84  theB0CLine(data.theB0CLine),
85  theE0FLine(data.theE0FLine),
88  theRPCData(data.theRPCData),
89  theGEMData(data.theGEMData),
94  size_(data.size_),
95  cWordCnt(data.cWordCnt),
99  theTMBScope = new CSCTMBScope(*(data.theTMBScope));
100  } else {
101  theTMBScope = nullptr;
102  }
103 
106  } else {
107  theTMBMiniScope = nullptr;
108  }
109 
112  } else {
113  theTMBBlockedCFEB = nullptr;
114  }
115 
116  if (theGEMDataIsPresent) {
117  theGEMData = new CSCGEMData(*(data.theGEMData));
118  } else {
119  theGEMData = nullptr;
120  }
121 }
unsigned theE0FLine
Definition: CSCTMBData.h:77
bool theRPCDataIsPresent
Definition: CSCTMBData.h:103
CSCTMBTrailer theTMBTrailer
Definition: CSCTMBData.h:95
CSCGEMData * theGEMData
Definition: CSCTMBData.h:82
bool theBlockedCFEBIsPresent
Definition: CSCTMBData.h:92
unsigned short size_
Definition: CSCTMBData.h:101
bool theTMBMiniScopeIsPresent
Definition: CSCTMBData.h:89
unsigned theB0CLine
Definition: CSCTMBData.h:76
CSCRPCData theRPCData
Definition: CSCTMBData.h:81
bool theGEMDataIsPresent
Definition: CSCTMBData.h:104
CSCTMBHeader theTMBHeader
Definition: CSCTMBData.h:79
CSCTMBBlockedCFEB * theTMBBlockedCFEB
Definition: CSCTMBData.h:93
const uint16_t * theOriginalBuffer
Definition: CSCTMBData.h:73
unsigned short cWordCnt
Definition: CSCTMBData.h:102
CSCComparatorData theComparatorData
Definition: CSCTMBData.h:80
CSCTMBMiniScope * theTMBMiniScope
Definition: CSCTMBData.h:90
bool theTMBScopeIsPresent
The TMB scope is not present in most of data hence its dynamic.
Definition: CSCTMBData.h:84
CSCTMBScope * theTMBScope
Definition: CSCTMBData.h:85

Member Function Documentation

std::bitset< 22 > CSCTMBData::calCRC22 ( const std::vector< std::bitset< 16 > > &  datain)

Definition at line 398 of file CSCTMBData.cc.

References mps_fire::i, and nextCRC22_D16().

Referenced by pack(), and TMBCRCcalc().

398  {
399  std::bitset<22> CRC;
400  CRC.reset();
401  for (unsigned int i = 0; i < datain.size() - 3; ++i) {
402  CRC = nextCRC22_D16(datain[i], CRC);
403  }
404  return CRC;
405 }
std::bitset< 22 > nextCRC22_D16(const std::bitset< 16 > &D, const std::bitset< 22 > &C)
Definition: CSCTMBData.cc:425
bool CSCTMBData::checkSize ( ) const

sees if the size adds up to the word count

Definition at line 393 of file CSCTMBData.cc.

Referenced by UnpackTMB().

393  {
394  // sum up all the components and see if they have the size indicated in the TMBTrailer
395  return true;
396 }
CSCComparatorData* CSCTMBData::comparatorData ( )
inline

Definition at line 41 of file CSCTMBData.h.

References theComparatorData.

Referenced by CSCEventData::add(), CSCEventData::comparatorData(), and pack().

41 { return &theComparatorData; }
CSCComparatorData theComparatorData
Definition: CSCTMBData.h:80
short unsigned int CSCTMBData::CWordCnt ( ) const
inline

Definition at line 36 of file CSCTMBData.h.

References cWordCnt.

36 { return cWordCnt; }
unsigned short cWordCnt
Definition: CSCTMBData.h:102
CSCGEMData * CSCTMBData::gemData ( ) const

Definition at line 419 of file CSCTMBData.cc.

References theGEMData, and theGEMDataIsPresent.

419  {
420  if (!theGEMDataIsPresent)
421  throw("No GEM Data in this chamber");
422  return theGEMData;
423 }
CSCGEMData * theGEMData
Definition: CSCTMBData.h:82
bool theGEMDataIsPresent
Definition: CSCTMBData.h:104
int CSCTMBData::getCRC ( ) const
inline

Definition at line 37 of file CSCTMBData.h.

References CSCTMBTrailer::crc22(), and theTMBTrailer.

37 { return theTMBTrailer.crc22(); }
CSCTMBTrailer theTMBTrailer
Definition: CSCTMBData.h:95
unsigned int crc22() const
bool CSCTMBData::hasGEM ( ) const
inline

Definition at line 55 of file CSCTMBData.h.

References theGEMDataIsPresent.

55 { return theGEMDataIsPresent; }
bool theGEMDataIsPresent
Definition: CSCTMBData.h:104
bool CSCTMBData::hasRPC ( ) const
inline

check this before using RPC

Definition at line 53 of file CSCTMBData.h.

References theRPCDataIsPresent.

53 { return theRPCDataIsPresent; }
bool theRPCDataIsPresent
Definition: CSCTMBData.h:103
bool CSCTMBData::hasTMBBlockedCFEB ( ) const
inline

check this before TMB Block CFEB

Definition at line 49 of file CSCTMBData.h.

References theBlockedCFEBIsPresent.

49 { return theBlockedCFEBIsPresent; }
bool theBlockedCFEBIsPresent
Definition: CSCTMBData.h:92
bool CSCTMBData::hasTMBMiniScope ( ) const
inline

check this before using TMB mini scope

Definition at line 46 of file CSCTMBData.h.

References theTMBMiniScopeIsPresent.

46 { return theTMBMiniScopeIsPresent; }
bool theTMBMiniScopeIsPresent
Definition: CSCTMBData.h:89
bool CSCTMBData::hasTMBScope ( ) const
inline

check this before using TMB Scope

Definition at line 43 of file CSCTMBData.h.

References theTMBScopeIsPresent.

43 { return theTMBScopeIsPresent; }
bool theTMBScopeIsPresent
The TMB scope is not present in most of data hence its dynamic.
Definition: CSCTMBData.h:84
std::bitset< 22 > CSCTMBData::nextCRC22_D16 ( const std::bitset< 16 > &  D,
const std::bitset< 22 > &  C 
)

Definition at line 425 of file CSCTMBData.cc.

Referenced by calCRC22().

425  {
426  std::bitset<22> NewCRC;
427 
428  NewCRC[0] = D[0] ^ C[6];
429  NewCRC[1] = D[1] ^ D[0] ^ C[6] ^ C[7];
430  NewCRC[2] = D[2] ^ D[1] ^ C[7] ^ C[8];
431  NewCRC[3] = D[3] ^ D[2] ^ C[8] ^ C[9];
432  NewCRC[4] = D[4] ^ D[3] ^ C[9] ^ C[10];
433  NewCRC[5] = D[5] ^ D[4] ^ C[10] ^ C[11];
434  NewCRC[6] = D[6] ^ D[5] ^ C[11] ^ C[12];
435  NewCRC[7] = D[7] ^ D[6] ^ C[12] ^ C[13];
436  NewCRC[8] = D[8] ^ D[7] ^ C[13] ^ C[14];
437  NewCRC[9] = D[9] ^ D[8] ^ C[14] ^ C[15];
438  NewCRC[10] = D[10] ^ D[9] ^ C[15] ^ C[16];
439  NewCRC[11] = D[11] ^ D[10] ^ C[16] ^ C[17];
440  NewCRC[12] = D[12] ^ D[11] ^ C[17] ^ C[18];
441  NewCRC[13] = D[13] ^ D[12] ^ C[18] ^ C[19];
442  NewCRC[14] = D[14] ^ D[13] ^ C[19] ^ C[20];
443  NewCRC[15] = D[15] ^ D[14] ^ C[20] ^ C[21];
444  NewCRC[16] = D[15] ^ C[0] ^ C[21];
445  NewCRC[17] = C[1];
446  NewCRC[18] = C[2];
447  NewCRC[19] = C[3];
448  NewCRC[20] = C[4];
449  NewCRC[21] = C[5];
450 
451  return NewCRC;
452 }
DecomposeProduct< arg, typename Div::arg > D
Definition: Factorize.h:141
boost::dynamic_bitset CSCTMBData::pack ( )

not const because it sets size int TMBTrailer

this method is for digi2raw

Definition at line 454 of file CSCTMBData.cc.

References bitset_utilities::append(), calCRC22(), comparatorData(), CSCComparatorData::data(), CSCTMBTrailer::data(), CSCTMBHeader::data(), mps_fire::i, mps_fire::result, CSCTMBTrailer::setCRC(), CSCComparatorData::sizeInWords(), CSCTMBTrailer::sizeInWords(), CSCTMBHeader::sizeInWords(), theComparatorData, theTMBHeader, theTMBTrailer, tmbTrailer(), and bitset_utilities::ushortToBitset().

Referenced by CSCEventData::pack().

454  {
455  boost::dynamic_bitset<> result =
457  boost::dynamic_bitset<> comparatorData =
459  result = bitset_utilities::append(result, comparatorData);
460  boost::dynamic_bitset<> newResult = result;
461  // theTMBTrailer.setCRC(TMBCRCcalc());
462 
463  boost::dynamic_bitset<> tmbTrailer =
465  result = bitset_utilities::append(result, tmbTrailer);
466 
467  // now convert to a vector<bitset<16>>, so we can calculate the crc
468  std::vector<std::bitset<16> > wordVector;
469  // try to tune so it stops before the e0f line
470  for (unsigned pos = 0; pos < result.size() - 16; pos += 16) {
471  std::bitset<16> word;
472  for (int i = 0; i < 16; ++i) {
473  word[i] = result[pos + i];
474  }
475  wordVector.push_back(word);
476  }
477  theTMBTrailer.setCRC(calCRC22(wordVector).to_ulong());
479  newResult = bitset_utilities::append(newResult, tmbTrailer);
480 
481  return newResult;
482 }
CSCTMBTrailer * tmbTrailer()
Definition: CSCTMBData.h:51
CSCTMBTrailer theTMBTrailer
Definition: CSCTMBData.h:95
boost::dynamic_bitset append(const boost::dynamic_bitset<> &bs1, const boost::dynamic_bitset<> &bs2)
this method takes two bitsets bs1 and bs2 and returns result of bs2 appended to the end of bs1 ...
int sizeInWords() const
in 16-bit frames
Definition: CSCTMBTrailer.h:42
unsigned short * data()
Definition: CSCTMBTrailer.h:43
tuple result
Definition: mps_fire.py:311
int sizeInWords() const
in 16-bit words
std::bitset< 22 > calCRC22(const std::vector< std::bitset< 16 > > &datain)
Definition: CSCTMBData.cc:398
uint64_t word
CSCTMBHeader theTMBHeader
Definition: CSCTMBData.h:79
unsigned short * data()
Definition: CSCTMBHeader.h:107
void setCRC(int crc)
unsigned short int sizeInWords() const
Definition: CSCTMBHeader.h:103
CSCComparatorData theComparatorData
Definition: CSCTMBData.h:80
CSCComparatorData * comparatorData()
Definition: CSCTMBData.h:41
boost::dynamic_bitset ushortToBitset(const unsigned int numberOfBits, unsigned short *buf)
this method takes numberOfBits bits from unsigned short * array and returns them in the bitset obj...
unsigned short * data()
CSCRPCData* CSCTMBData::rpcData ( )
inline

Definition at line 54 of file CSCTMBData.h.

References theRPCData.

54 { return &theRPCData; }
CSCRPCData theRPCData
Definition: CSCTMBData.h:81
void CSCTMBData::selfTest ( )
static

tests packing

Definition at line 484 of file CSCTMBData.cc.

References cscClassPackerCompare().

484  {
485  CSCTMBData tmbData;
486  cscClassPackerCompare(tmbData);
487 }
bool cscClassPackerCompare(T &t)
static void CSCTMBData::setDebug ( const bool  value)
inlinestatic

Definition at line 35 of file CSCTMBData.h.

References debug, and relativeConstraints::value.

Referenced by CSCDCCUnpacker::CSCDCCUnpacker().

35 { debug = value; }
static std::atomic< bool > debug
Definition: CSCTMBData.h:99
const unsigned short CSCTMBData::size ( void  ) const
inline

Definition at line 38 of file CSCTMBData.h.

References size_.

Referenced by ntupleDataFormat._Collection::__iter__(), ntupleDataFormat._Collection::__len__(), and CSCEventData::unpack_data().

38 { return size_; }
unsigned short size_
Definition: CSCTMBData.h:101
CSCTMBBlockedCFEB& CSCTMBData::tmbBlockedCFEB ( ) const
int CSCTMBData::TMBCRCcalc ( )

Definition at line 156 of file CSCTMBData.cc.

References calCRC22(), mps_fire::i, geometryCSVtoXML::line, LogTrace, theB0CLine, theE0FLine, and theOriginalBuffer.

156  {
157  std::vector<std::bitset<16> > theTotalTMBData(theE0FLine + 1 - theB0CLine);
158  unsigned i = 0;
159  for (unsigned int line = theB0CLine; line < theE0FLine + 1; ++line) {
160  theTotalTMBData[i] = std::bitset<16>(theOriginalBuffer[line]);
161  ++i;
162  }
163  if (!theTotalTMBData.empty()) {
164  std::bitset<22> CRC = calCRC22(theTotalTMBData);
165  LogTrace("CSCTMBData|CSCRawToDigi") << " Test here " << CRC.to_ulong();
166  return CRC.to_ulong();
167  } else {
168  LogTrace("CSCTMBData|CSCRawToDigi") << "theTotalTMBData doesn't exist";
169  return 0;
170  }
171 }
unsigned theE0FLine
Definition: CSCTMBData.h:77
unsigned theB0CLine
Definition: CSCTMBData.h:76
#define LogTrace(id)
std::bitset< 22 > calCRC22(const std::vector< std::bitset< 16 > > &datain)
Definition: CSCTMBData.cc:398
const uint16_t * theOriginalBuffer
Definition: CSCTMBData.h:73
CSCTMBHeader* CSCTMBData::tmbHeader ( )
inline
CSCTMBMiniScope & CSCTMBData::tmbMiniScope ( ) const

Definition at line 413 of file CSCTMBData.cc.

References theTMBMiniScope, and theTMBMiniScopeIsPresent.

413  {
415  throw("No TMBScope in this chamber");
416  return *theTMBMiniScope;
417 }
bool theTMBMiniScopeIsPresent
Definition: CSCTMBData.h:89
CSCTMBMiniScope * theTMBMiniScope
Definition: CSCTMBData.h:90
CSCTMBScope & CSCTMBData::tmbScope ( ) const

Definition at line 407 of file CSCTMBData.cc.

References theTMBScope, and theTMBScopeIsPresent.

407  {
409  throw("No TMBScope in this chamber");
410  return *theTMBScope;
411 }
bool theTMBScopeIsPresent
The TMB scope is not present in most of data hence its dynamic.
Definition: CSCTMBData.h:84
CSCTMBScope * theTMBScope
Definition: CSCTMBData.h:85
CSCTMBTrailer* CSCTMBData::tmbTrailer ( )
inline

Definition at line 51 of file CSCTMBData.h.

References theTMBTrailer.

Referenced by pack(), and cscdqm::EventProcessor::processCSC().

51 { return &theTMBTrailer; }
CSCTMBTrailer theTMBTrailer
Definition: CSCTMBData.h:95
int CSCTMBData::UnpackTMB ( const uint16_t *  buf)

determine 2007 or 2006 version

assumes that buf starts at the tmb data this is not true if something is wrong in the data before TMB - then we skip the whole event

Handling of enabled GEM fibers is not yet properly implemented in the firmware

Now Find the miniscope

end for the mini scope

Now Find the blocked CFEB DiStrips List Format

end for the blocked CFEB DiStrips List Format

Definition at line 173 of file CSCTMBData.cc.

References CSCComparatorData::check(), CSCTMBHeader::check(), checkSize(), TauDecayModes::dec, findLine(), CSCTMBHeader::FirmwareVersion(), geometryCSVtoXML::line, LogTrace, CSCTMBHeader::NCFEBs(), CSCTMBHeader::NTBins(), CSCGEMData::sizeInWords(), CSCRPCData::sizeInWords(), CSCComparatorData::sizeInWords(), CSCTMBTrailer::sizeInWords(), CSCTMBHeader::sizeInWords(), theB0CLine, theBlockedCFEBIsPresent, theComparatorData, theE0FLine, theGEMData, theGEMDataIsPresent, theRPCData, theRPCDataIsPresent, theTMBBlockedCFEB, theTMBHeader, theTMBMiniScope, theTMBMiniScopeIsPresent, theTMBScope, theTMBScopeIsPresent, and theTMBTrailer.

Referenced by CSCTMBData().

173  {
175  unsigned short int firmwareVersion = 0;
176  unsigned short int firmwareRevision = 0;
177  int Ntbins = 0;
178  int NRPCtbins = 0; // Number of RPC tbins
179  int NGEMtbins = 0; // Number of GEM tbins
180  int NGEMEnabled = 0; // Number of Enabled GEM Fibers
181  int GEMFibersMask = 0;
182  bool isGEMfirmware = false;
183 
184  int b0cLine = 0;
185 
188  if (buf[b0cLine] == 0xdb0c) {
189  firmwareVersion = 2007;
190  firmwareRevision = buf[b0cLine + 7] & 0x7fff;
191  Ntbins = buf[b0cLine + 19] & 0xF8;
192  if ((firmwareRevision < 0x4000) /* New Run3 (O)TMB firmware revision format */
193  && (((firmwareRevision >> 9) & 0x2) == 0x2))
194  isGEMfirmware = true;
195 
196  if (isGEMfirmware) {
197  GEMFibersMask = buf[b0cLine + 36] & 0xf; // GEM enabled fibers 4-bits mask
199  // for (int i = 0; i < 4; i++)
200  // NGEMEnabled += (buf[b0cLine + 36] >> i) & 0x1; // Get number of enabled GEM fibers
201  NGEMEnabled = 4; // Currently always assume that all 4 fibers are enabled
202  NGEMtbins = (buf[b0cLine + 36] >> 5) & 0x1F; // Get GEM tbins
203  }
204  // } else {
205  {
206  NRPCtbins = (buf[b0cLine + 36] >> 5) & 0x1F; // Get RPC tbins
207  }
208  } else if (buf[b0cLine] == 0x6b0c) {
209  firmwareVersion = 2006;
210  Ntbins = buf[b0cLine + 1] & 0x1f;
211  NRPCtbins = Ntbins;
212  } else {
213  LogTrace("CSCTMBData|CSCRawToDigi") << "+++ Can't find b0C flag";
214  }
215 
216  if ((firmwareVersion == 2007) &&
217  (!(((buf[b0cLine] & 0xFFFF) == 0xDB0C) && ((buf[b0cLine + 1] & 0xf000) == 0xD000) &&
218  ((buf[b0cLine + 2] & 0xf000) == 0xD000) && ((buf[b0cLine + 3] & 0xf000) == 0xD000)))) {
219  LogTrace("CSCTMBData|CSCRawToDigi") << "+++ CSCTMBData warning: error in header in 2007 format!";
220  }
221 
222  int MaxSizeRPC = 1 + NRPCtbins * 2 * 4 + 1;
223  int MaxSizeGEM = 1 + NGEMEnabled * NGEMtbins * 4 + 1;
224  //int MaxSizeScope = 5;
225  int e0bLine = -1;
226  switch (firmwareVersion) {
227  case 2007:
228  e0bLine = 42; //last word of header2007
229  break;
230  case 2006:
231  e0bLine = 26; //last word of header in 2006 format
232  break;
233  default:
234  edm::LogError("CSCTMBData|CSCRawToDigi") << "+++ undetermined firmware format - cant find e0bLine";
235  }
236 
238 
239  if (!theTMBHeader.check()) {
240  LogTrace("CSCTMBData|CSCRawToDigi") << "+++ CSCTMBData warning: Bad TMB header e0bLine=" << std::hex
241  << buf[e0bLine];
242  return 0;
243  }
244 
245  int currentPosition = theTMBHeader.sizeInWords();
246  int theFirmwareVersion = theTMBHeader.FirmwareVersion();
247 
249  CSCComparatorData(theTMBHeader.NCFEBs(), theTMBHeader.NTBins(), buf + e0bLine + 1, theFirmwareVersion);
250 
251  if (!theComparatorData.check()) {
252  LogTrace("CSCTMBData|CSCRawToDigi") << "+++ CSCTMBData warning: Bad CLCT data";
253  } else {
254  currentPosition += theComparatorData.sizeInWords();
255  }
256 
257  // look for RPC data
258  int b04Line = currentPosition;
259 
260  if (buf[b04Line] == 0x6b04) {
261  // we need an e04 line to calculate the size
262  int e04Line = findLine(buf, 0x6e04, currentPosition, currentPosition + MaxSizeRPC);
263  if (e04Line != -1) {
264  theRPCDataIsPresent = true;
265  theRPCData = CSCRPCData(buf + b04Line, e04Line - b04Line + 1);
266  currentPosition += theRPCData.sizeInWords();
267  } else {
268  LogTrace("CSCTMBData|CSCRawToDigi") << "CSCTMBData::corrupt RPC data! Failed to find end! ";
269  return 0;
270  }
271  }
272 
273  // look for GEM data
274  int c04Line = currentPosition;
275 
276  if (buf[c04Line] == 0x6c04) {
277  // we need an d04 line to calculate the size
278  int d04Line = findLine(buf, 0x6d04, currentPosition, currentPosition + MaxSizeGEM);
279  if (d04Line != -1) {
280  theGEMDataIsPresent = true;
281  theGEMData = new CSCGEMData(buf + c04Line, d04Line - c04Line + 1, GEMFibersMask);
282  if (theGEMData != nullptr)
283  currentPosition += theGEMData->sizeInWords();
284  } else {
285  LogTrace("CSCTMBData|CSCRawToDigi") << "CSCTMBData::corrupt GEM data! Failed to find end! ";
286  return 0;
287  }
288  }
289 
290  int TotTMBReadout = 0;
291  switch (firmwareVersion) {
292  case 2007:
293  if (theGEMDataIsPresent) {
294  TotTMBReadout = 43 + Ntbins * 6 * 5 + 1 + NGEMEnabled * NGEMtbins * 4 + 2 + 8 * 256 + 8;
295  } else {
296  TotTMBReadout = 43 + Ntbins * 6 * 5 + 1 + NRPCtbins * 2 * 4 + 2 + 8 * 256 + 8;
297  };
298  break;
299  case 2006:
300  TotTMBReadout =
301  27 + Ntbins * 6 * 5 + 1 + NRPCtbins * 2 * 4 + 2 + 8 * 256 + 8; //see tmb2004 manual (version v2p06) page54.
302  break;
303  default:
304  edm::LogError("CSCTMBData|CSCRawToDigi") << "can't find TotTMBReadout - unknown firmware version!";
305  break;
306  }
307 
308  //std::cout << " !!!TMB Scope!!! " << std::endl;
309  if (buf[currentPosition] == 0x6b05) {
310  int b05Line = currentPosition;
311  LogTrace("CSCTMBData|CSCRawToDigi") << "found scope!";
312  int e05Line = findLine(buf, 0x6e05, currentPosition, TotTMBReadout - currentPosition);
313  if (e05Line != -1) {
314  theTMBScopeIsPresent = true;
315  theTMBScope = new CSCTMBScope(buf, b05Line, e05Line);
316  // The size of the TMB scope data can vary, and I see no good reasons
317  // not to determine it dynamically. -SV, 5 Nov 2008.
318  //currentPosition+=theTMBScope->sizeInWords();
319  currentPosition += (e05Line - b05Line + 1);
320  } else {
321  LogTrace("CSCTMBData|CSCRawToDigi") << "+++ CSCTMBData warning: found 0x6b05 line, but not 0x6e05! +++";
322  }
323  }
324 
326  if (buf[currentPosition] == 0x6b07) {
327  int Line6b07 = currentPosition;
328  LogTrace("CSCTMBData") << " TMBData ---> Begin of MiniScope found ";
329  int Line6E07 = findLine(buf, 0x6E07, currentPosition, TotTMBReadout - currentPosition);
330  if (Line6E07 != -1) {
331  LogTrace("CSCTMBData") << " TMBData --> End of MiniScope found " << Line6E07 - Line6b07 + 1 << " words ";
333  theTMBMiniScope = new CSCTMBMiniScope(buf, Line6b07, Line6E07);
334  currentPosition += (Line6E07 - Line6b07 + 1);
335  } else {
336  LogTrace("CSCTMBData") << "+++ CSCTMBData warning MiniScope!: found 0x6b07 line, but not 0x6e07! +++";
337  }
338  }
340 
342  if (buf[currentPosition] == 0x6BCB) {
343  int Line6BCB = currentPosition;
344  LogTrace("CSCTMBData") << " TMBData ---> Begin of Blocked CFEB found ";
345  int Line6ECB = findLine(buf, 0x6ECB, currentPosition, TotTMBReadout - currentPosition);
346  if (Line6ECB != -1) {
347  LogTrace("CSCTMBData") << " TMBData --> End of Blocked CFEB found " << Line6ECB - Line6BCB + 1 << " words ";
349  theTMBBlockedCFEB = new CSCTMBBlockedCFEB(buf, Line6BCB, Line6ECB);
350  currentPosition += (Line6ECB - Line6BCB + 1);
351  } else {
352  LogTrace("CSCTMBData") << "+++ CSCTMBData warning Blocked CFEB!: found 0x6BCB line, but not 0x6ECB! +++";
353  }
354  }
356 
357  int maxLine = findLine(buf, 0xde0f, currentPosition, TotTMBReadout - currentPosition);
358  if (maxLine == -1) {
359  LogTrace("CSCTMBData|CSCRawToDigi") << "+++ CSCTMBData warning: No e0f line!";
360  return 0;
361  }
362 
363  //Now for CRC check put this information into bitset
364 
365  theB0CLine = b0cLine;
366  theE0FLine = maxLine;
367 
368  // finally, the trailer
369  int e0cLine = findLine(buf, 0x6e0c, currentPosition, maxLine);
370  if (e0cLine == -1) {
371  LogTrace("CSCTMBData|CSCRawToDigi") << "+++ CSCTMBData warning: No e0c line!";
372  } else {
373  theTMBTrailer = CSCTMBTrailer(buf + e0cLine, firmwareVersion);
374  LogTrace("CSCTMBData|CSCRawToDigi") << "TMB trailer size: " << theTMBTrailer.sizeInWords();
375  }
376 
377  checkSize();
378 
379  // Dump of TMB; format proposed by JK.
380 #ifdef TMBDUMP
381  LogTrace("CSCTMBData") << "Dump of TMB data:";
382  for (int line = b0cLine; line <= maxLine + 3; line++) {
383  LogTrace("CSCTMBData") << "Adr= " << std::setw(4) << line << " Data= " << std::setfill('0') << std::setw(5)
384  << std::uppercase << std::hex << buf[line] << std::dec << std::endl;
385  }
386 #endif
387 
388  // size, since we count from 0 and have one more trailer word
389  // there are sometimes multiple "de0f" lines in trailer, so key on "6e0c"
390  return e0cLine - b0cLine + theTMBTrailer.sizeInWords();
391 } //UnpackTMB
unsigned theE0FLine
Definition: CSCTMBData.h:77
bool theRPCDataIsPresent
Definition: CSCTMBData.h:103
uint16_t NTBins() const
Definition: CSCTMBHeader.h:66
CSCTMBTrailer theTMBTrailer
Definition: CSCTMBData.h:95
CSCGEMData * theGEMData
Definition: CSCTMBData.h:82
bool theBlockedCFEBIsPresent
Definition: CSCTMBData.h:92
bool theTMBMiniScopeIsPresent
Definition: CSCTMBData.h:89
int sizeInWords() const
in 16-bit frames
Definition: CSCTMBTrailer.h:42
unsigned theB0CLine
Definition: CSCTMBData.h:76
CSCRPCData theRPCData
Definition: CSCTMBData.h:81
Log< level::Error, false > LogError
bool theGEMDataIsPresent
Definition: CSCTMBData.h:104
#define LogTrace(id)
uint16_t NCFEBs() const
Definition: CSCTMBHeader.h:67
int sizeInWords() const
in 16-bit words
CSCTMBHeader theTMBHeader
Definition: CSCTMBData.h:79
CSCTMBBlockedCFEB * theTMBBlockedCFEB
Definition: CSCTMBData.h:93
int sizeInWords()
Definition: CSCRPCData.h:21
unsigned short int sizeInWords() const
Definition: CSCTMBHeader.h:103
int sizeInWords() const
Definition: CSCGEMData.h:21
CSCComparatorData theComparatorData
Definition: CSCTMBData.h:80
CSCTMBMiniScope * theTMBMiniScope
Definition: CSCTMBData.h:90
bool theTMBScopeIsPresent
The TMB scope is not present in most of data hence its dynamic.
Definition: CSCTMBData.h:84
bool check() const
Definition: CSCTMBHeader.h:112
CSCTMBScope * theTMBScope
Definition: CSCTMBData.h:85
int findLine(const uint16_t *buf, uint16_t marker, int first, int maxToDo)
Definition: CSCTMBData.cc:147
int FirmwareVersion() const
Definition: CSCTMBHeader.h:40
bool checkSize() const
sees if the size adds up to the word count
Definition: CSCTMBData.cc:393

Member Data Documentation

unsigned short CSCTMBData::cWordCnt
private

Definition at line 102 of file CSCTMBData.h.

Referenced by CWordCnt().

std::atomic< bool > CSCTMBData::debug {false}
staticprivate
unsigned short CSCTMBData::size_
private

Definition at line 101 of file CSCTMBData.h.

Referenced by CSCTMBData(), and size().

unsigned CSCTMBData::theB0CLine
private

CRC calc needs to know where 0x6B0C and 0x6E0F lines were we want to put off CRC calc until needed

Definition at line 76 of file CSCTMBData.h.

Referenced by TMBCRCcalc(), and UnpackTMB().

bool CSCTMBData::theBlockedCFEBIsPresent
private

Definition at line 92 of file CSCTMBData.h.

Referenced by CSCTMBData(), hasTMBBlockedCFEB(), UnpackTMB(), and ~CSCTMBData().

CSCComparatorData CSCTMBData::theComparatorData
private

Definition at line 80 of file CSCTMBData.h.

Referenced by comparatorData(), CSCTMBData(), pack(), and UnpackTMB().

unsigned CSCTMBData::theE0FLine
private

Definition at line 77 of file CSCTMBData.h.

Referenced by TMBCRCcalc(), and UnpackTMB().

CSCGEMData* CSCTMBData::theGEMData
private

Definition at line 82 of file CSCTMBData.h.

Referenced by CSCTMBData(), gemData(), UnpackTMB(), and ~CSCTMBData().

bool CSCTMBData::theGEMDataIsPresent
private

Definition at line 104 of file CSCTMBData.h.

Referenced by CSCTMBData(), gemData(), hasGEM(), UnpackTMB(), and ~CSCTMBData().

const uint16_t* CSCTMBData::theOriginalBuffer
private

@ not sure what this means for simulation. I keep this around so we can calculate CRCs

Definition at line 73 of file CSCTMBData.h.

Referenced by TMBCRCcalc().

CSCRPCData CSCTMBData::theRPCData
private

Definition at line 81 of file CSCTMBData.h.

Referenced by rpcData(), and UnpackTMB().

bool CSCTMBData::theRPCDataIsPresent
private

Definition at line 103 of file CSCTMBData.h.

Referenced by hasRPC(), and UnpackTMB().

CSCTMBBlockedCFEB* CSCTMBData::theTMBBlockedCFEB
private

Definition at line 93 of file CSCTMBData.h.

Referenced by CSCTMBData(), UnpackTMB(), and ~CSCTMBData().

CSCTMBHeader CSCTMBData::theTMBHeader
private

Definition at line 79 of file CSCTMBData.h.

Referenced by CSCTMBData(), pack(), tmbHeader(), and UnpackTMB().

CSCTMBMiniScope* CSCTMBData::theTMBMiniScope
private

Definition at line 90 of file CSCTMBData.h.

Referenced by CSCTMBData(), tmbMiniScope(), UnpackTMB(), and ~CSCTMBData().

bool CSCTMBData::theTMBMiniScopeIsPresent
private

The TMB MiniScope must presen in every event, hovewer make it dynamic as for the main scope

Definition at line 89 of file CSCTMBData.h.

Referenced by CSCTMBData(), hasTMBMiniScope(), tmbMiniScope(), UnpackTMB(), and ~CSCTMBData().

CSCTMBScope* CSCTMBData::theTMBScope
private

Definition at line 85 of file CSCTMBData.h.

Referenced by CSCTMBData(), tmbScope(), UnpackTMB(), and ~CSCTMBData().

bool CSCTMBData::theTMBScopeIsPresent
private

The TMB scope is not present in most of data hence its dynamic.

Definition at line 84 of file CSCTMBData.h.

Referenced by CSCTMBData(), hasTMBScope(), tmbScope(), UnpackTMB(), and ~CSCTMBData().

CSCTMBTrailer CSCTMBData::theTMBTrailer
private

Definition at line 95 of file CSCTMBData.h.

Referenced by CSCTMBData(), getCRC(), pack(), tmbTrailer(), and UnpackTMB().