CMS 3D CMS Logo

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...
 
CSCCLCTDataclctData ()
 
 CSCTMBData ()
 
 CSCTMBData (int firmwareVersion, int firmwareRevision, int ncfebs=5)
 
 CSCTMBData (const uint16_t *buf)
 
 CSCTMBData (const CSCTMBData &data)
 
short unsigned int CWordCnt () const
 
int getCRC () 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
 
CSCCLCTData theCLCTData
 
unsigned theE0FLine
 
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  theTMBScopeIsPresent(false),
28  theTMBScope(nullptr),
30  theTMBMiniScope(nullptr),
32  theTMBBlockedCFEB(nullptr),
34  size_( 0 ),
35  cWordCnt( 0 ),
36  theRPCDataIsPresent(false)
37 {
38 
39 
40 }
int sizeInWords() const
in 16-bit words
Definition: CSCCLCTData.h:46
unsigned theE0FLine
Definition: CSCTMBData.h:79
bool theRPCDataIsPresent
Definition: CSCTMBData.h:104
CSCTMBTrailer theTMBTrailer
Definition: CSCTMBData.h:96
bool theBlockedCFEBIsPresent
Definition: CSCTMBData.h:93
unsigned short size_
Definition: CSCTMBData.h:102
bool theTMBMiniScopeIsPresent
Definition: CSCTMBData.h:90
unsigned theB0CLine
Definition: CSCTMBData.h:78
CSCTMBHeader theTMBHeader
Definition: CSCTMBData.h:81
CSCTMBBlockedCFEB * theTMBBlockedCFEB
Definition: CSCTMBData.h:94
const uint16_t * theOriginalBuffer
Definition: CSCTMBData.h:75
unsigned short cWordCnt
Definition: CSCTMBData.h:103
unsigned short int sizeInWords() const
Definition: CSCTMBHeader.h:111
CSCTMBMiniScope * theTMBMiniScope
Definition: CSCTMBData.h:91
bool theTMBScopeIsPresent
The TMB scope is not present in most of data hence its dynamic.
Definition: CSCTMBData.h:85
CSCTMBScope * theTMBScope
Definition: CSCTMBData.h:86
CSCCLCTData theCLCTData
Definition: CSCTMBData.h:82
CSCTMBData::CSCTMBData ( int  firmwareVersion,
int  firmwareRevision,
int  ncfebs = 5 
)

Definition at line 42 of file CSCTMBData.cc.

References CSCTMBHeader::setNCFEBs(), CSCCLCTData::sizeInWords(), CSCTMBHeader::sizeInWords(), theCLCTData, theTMBHeader, and theTMBTrailer.

43  : theOriginalBuffer(nullptr),
44  theB0CLine( 0 ),
45  theE0FLine( 0 ),
46  theTMBHeader(firmwareVersion, firmwareRevision),
48  theTMBScopeIsPresent(false),
49  theTMBScope(nullptr),
51  theTMBMiniScope(nullptr),
53  theTMBBlockedCFEB(nullptr),
55  size_( 0 ),
56  cWordCnt( 0 ),
57  theRPCDataIsPresent(false)
58 {
59 
60  theTMBHeader.setNCFEBs(cfebs);
63 
64 
65 }
int sizeInWords() const
in 16-bit words
Definition: CSCCLCTData.h:46
unsigned theE0FLine
Definition: CSCTMBData.h:79
bool theRPCDataIsPresent
Definition: CSCTMBData.h:104
CSCTMBTrailer theTMBTrailer
Definition: CSCTMBData.h:96
bool theBlockedCFEBIsPresent
Definition: CSCTMBData.h:93
unsigned short size_
Definition: CSCTMBData.h:102
bool theTMBMiniScopeIsPresent
Definition: CSCTMBData.h:90
unsigned theB0CLine
Definition: CSCTMBData.h:78
void setNCFEBs(uint16_t ncfebs)
Definition: CSCTMBHeader.h:92
CSCTMBHeader theTMBHeader
Definition: CSCTMBData.h:81
CSCTMBBlockedCFEB * theTMBBlockedCFEB
Definition: CSCTMBData.h:94
const uint16_t * theOriginalBuffer
Definition: CSCTMBData.h:75
unsigned short cWordCnt
Definition: CSCTMBData.h:103
unsigned short int sizeInWords() const
Definition: CSCTMBHeader.h:111
CSCTMBMiniScope * theTMBMiniScope
Definition: CSCTMBData.h:91
bool theTMBScopeIsPresent
The TMB scope is not present in most of data hence its dynamic.
Definition: CSCTMBData.h:85
CSCTMBScope * theTMBScope
Definition: CSCTMBData.h:86
CSCCLCTData theCLCTData
Definition: CSCTMBData.h:82
CSCTMBData::~CSCTMBData ( )

Definition at line 119 of file CSCTMBData.cc.

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

119  {
120  if (theTMBScopeIsPresent) {
121  delete theTMBScope;
122  theTMBScopeIsPresent = false;
123  }
124 
126  delete theTMBMiniScope;
127  theTMBMiniScopeIsPresent = false;
128  }
129 
131  delete theTMBBlockedCFEB;
132  theBlockedCFEBIsPresent = false;
133  }
134 }
bool theBlockedCFEBIsPresent
Definition: CSCTMBData.h:93
bool theTMBMiniScopeIsPresent
Definition: CSCTMBData.h:90
CSCTMBBlockedCFEB * theTMBBlockedCFEB
Definition: CSCTMBData.h:94
CSCTMBMiniScope * theTMBMiniScope
Definition: CSCTMBData.h:91
bool theTMBScopeIsPresent
The TMB scope is not present in most of data hence its dynamic.
Definition: CSCTMBData.h:85
CSCTMBScope * theTMBScope
Definition: CSCTMBData.h:86
CSCTMBData::CSCTMBData ( const uint16_t *  buf)

Definition at line 67 of file CSCTMBData.cc.

References size_, and UnpackTMB().

68  : theOriginalBuffer(buf),
69  theTMBHeader(2007, 0x50c3),
71  theTMBScopeIsPresent(false),
72  theTMBScope(nullptr),
74  theTMBMiniScope(nullptr),
76  theTMBBlockedCFEB(nullptr),
78  theRPCDataIsPresent(false){
79  size_ = UnpackTMB(buf);
80 }
int sizeInWords() const
in 16-bit words
Definition: CSCCLCTData.h:46
bool theRPCDataIsPresent
Definition: CSCTMBData.h:104
CSCTMBTrailer theTMBTrailer
Definition: CSCTMBData.h:96
bool theBlockedCFEBIsPresent
Definition: CSCTMBData.h:93
unsigned short size_
Definition: CSCTMBData.h:102
bool theTMBMiniScopeIsPresent
Definition: CSCTMBData.h:90
CSCTMBHeader theTMBHeader
Definition: CSCTMBData.h:81
CSCTMBBlockedCFEB * theTMBBlockedCFEB
Definition: CSCTMBData.h:94
const uint16_t * theOriginalBuffer
Definition: CSCTMBData.h:75
unsigned short int sizeInWords() const
Definition: CSCTMBHeader.h:111
CSCTMBMiniScope * theTMBMiniScope
Definition: CSCTMBData.h:91
bool theTMBScopeIsPresent
The TMB scope is not present in most of data hence its dynamic.
Definition: CSCTMBData.h:85
CSCTMBScope * theTMBScope
Definition: CSCTMBData.h:86
int UnpackTMB(const uint16_t *buf)
Definition: CSCTMBData.cc:165
CSCCLCTData theCLCTData
Definition: CSCTMBData.h:82
CSCTMBData::CSCTMBData ( const CSCTMBData data)

Definition at line 84 of file CSCTMBData.cc.

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

84  :
93  size_(data.size_), cWordCnt(data.cWordCnt),
95 {
97  theTMBScope = new CSCTMBScope(*(data.theTMBScope));
98  }
99  else {
100  theTMBScope = nullptr;
101  }
102 
105  }
106  else {
107  theTMBMiniScope = nullptr;
108  }
109 
112  }
113  else {
114  theTMBBlockedCFEB = nullptr;
115  }
116 
117 }
unsigned theE0FLine
Definition: CSCTMBData.h:79
bool theRPCDataIsPresent
Definition: CSCTMBData.h:104
CSCTMBTrailer theTMBTrailer
Definition: CSCTMBData.h:96
bool theBlockedCFEBIsPresent
Definition: CSCTMBData.h:93
unsigned short size_
Definition: CSCTMBData.h:102
bool theTMBMiniScopeIsPresent
Definition: CSCTMBData.h:90
unsigned theB0CLine
Definition: CSCTMBData.h:78
CSCRPCData theRPCData
Definition: CSCTMBData.h:83
CSCTMBHeader theTMBHeader
Definition: CSCTMBData.h:81
CSCTMBBlockedCFEB * theTMBBlockedCFEB
Definition: CSCTMBData.h:94
const uint16_t * theOriginalBuffer
Definition: CSCTMBData.h:75
unsigned short cWordCnt
Definition: CSCTMBData.h:103
CSCTMBMiniScope * theTMBMiniScope
Definition: CSCTMBData.h:91
bool theTMBScopeIsPresent
The TMB scope is not present in most of data hence its dynamic.
Definition: CSCTMBData.h:85
CSCTMBScope * theTMBScope
Definition: CSCTMBData.h:86
CSCCLCTData theCLCTData
Definition: CSCTMBData.h:82

Member Function Documentation

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

Definition at line 365 of file CSCTMBData.cc.

References mps_fire::i, and nextCRC22_D16().

Referenced by pack(), rpcData(), and TMBCRCcalc().

366 {
367  std::bitset<22> CRC;
368  CRC.reset();
369  for(unsigned int i=0;i<datain.size()-3;++i)
370  {
371  CRC=nextCRC22_D16(datain[i],CRC);
372  }
373  return CRC;
374 }
std::bitset< 22 > nextCRC22_D16(const std::bitset< 16 > &D, const std::bitset< 22 > &C)
Definition: CSCTMBData.cc:396
bool CSCTMBData::checkSize ( ) const

sees if the size adds up to the word count

Definition at line 359 of file CSCTMBData.cc.

Referenced by UnpackTMB().

360 {
361  // sum up all the components and see if they have the size indicated in the TMBTrailer
362  return true;
363 }
CSCCLCTData* CSCTMBData::clctData ( )
inline

Definition at line 43 of file CSCTMBData.h.

References theCLCTData.

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

43 {return &theCLCTData;}
CSCCLCTData theCLCTData
Definition: CSCTMBData.h:82
short unsigned int CSCTMBData::CWordCnt ( ) const
inline

Definition at line 38 of file CSCTMBData.h.

References cWordCnt.

38 {return cWordCnt;}
unsigned short cWordCnt
Definition: CSCTMBData.h:103
int CSCTMBData::getCRC ( ) const
inline

Definition at line 39 of file CSCTMBData.h.

References CSCTMBTrailer::crc22(), and theTMBTrailer.

39 {return theTMBTrailer.crc22();}
CSCTMBTrailer theTMBTrailer
Definition: CSCTMBData.h:96
unsigned int crc22() const
bool CSCTMBData::hasRPC ( ) const
inline

check this before using RPC

Definition at line 55 of file CSCTMBData.h.

References theRPCDataIsPresent.

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

check this before TMB Block CFEB

Definition at line 51 of file CSCTMBData.h.

References theBlockedCFEBIsPresent, and tmbBlockedCFEB().

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

check this before using TMB mini scope

Definition at line 48 of file CSCTMBData.h.

References theTMBMiniScopeIsPresent, and tmbMiniScope().

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

check this before using TMB Scope

Definition at line 45 of file CSCTMBData.h.

References theTMBScopeIsPresent, and tmbScope().

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

Definition at line 396 of file CSCTMBData.cc.

Referenced by calCRC22(), and rpcData().

398 {
399  std::bitset<22> NewCRC;
400 
401  NewCRC[ 0] = D[ 0] ^ C[ 6];
402  NewCRC[ 1] = D[ 1] ^ D[ 0] ^ C[ 6] ^ C[ 7];
403  NewCRC[ 2] = D[ 2] ^ D[ 1] ^ C[ 7] ^ C[ 8];
404  NewCRC[ 3] = D[ 3] ^ D[ 2] ^ C[ 8] ^ C[ 9];
405  NewCRC[ 4] = D[ 4] ^ D[ 3] ^ C[ 9] ^ C[10];
406  NewCRC[ 5] = D[ 5] ^ D[ 4] ^ C[10] ^ C[11];
407  NewCRC[ 6] = D[ 6] ^ D[ 5] ^ C[11] ^ C[12];
408  NewCRC[ 7] = D[ 7] ^ D[ 6] ^ C[12] ^ C[13];
409  NewCRC[ 8] = D[ 8] ^ D[ 7] ^ C[13] ^ C[14];
410  NewCRC[ 9] = D[ 9] ^ D[ 8] ^ C[14] ^ C[15];
411  NewCRC[10] = D[10] ^ D[ 9] ^ C[15] ^ C[16];
412  NewCRC[11] = D[11] ^ D[10] ^ C[16] ^ C[17];
413  NewCRC[12] = D[12] ^ D[11] ^ C[17] ^ C[18];
414  NewCRC[13] = D[13] ^ D[12] ^ C[18] ^ C[19];
415  NewCRC[14] = D[14] ^ D[13] ^ C[19] ^ C[20];
416  NewCRC[15] = D[15] ^ D[14] ^ C[20] ^ C[21];
417  NewCRC[16] = D[15] ^ C[ 0] ^ C[21];
418  NewCRC[17] = C[ 1];
419  NewCRC[18] = C[ 2];
420  NewCRC[19] = C[ 3];
421  NewCRC[20] = C[ 4];
422  NewCRC[21] = C[ 5];
423 
424  return NewCRC;
425 }
DecomposeProduct< arg, typename Div::arg > D
Definition: Factorize.h:152
boost::dynamic_bitset CSCTMBData::pack ( )

not const because it sets size int TMBTrailer

this method is for digi2raw

Definition at line 428 of file CSCTMBData.cc.

References bitset_utilities::append(), calCRC22(), clctData(), CSCCLCTData::data(), CSCTMBTrailer::data(), CSCTMBHeader::data(), mps_fire::i, mps_fire::result, CSCTMBTrailer::setCRC(), CSCCLCTData::sizeInWords(), CSCTMBTrailer::sizeInWords(), CSCTMBHeader::sizeInWords(), theCLCTData, theTMBHeader, theTMBTrailer, tmbTrailer(), and bitset_utilities::ushortToBitset().

Referenced by pyrootRender.interactiveRender::draw(), CSCEventData::pack(), and rpcData().

429 {
430  boost::dynamic_bitset<> result = bitset_utilities::ushortToBitset(theTMBHeader.sizeInWords()*16,
431  theTMBHeader.data());
432  boost::dynamic_bitset<> clctData = bitset_utilities::ushortToBitset(theCLCTData.sizeInWords()*16,
433  theCLCTData.data());
434  result = bitset_utilities::append(result,clctData);
435  boost::dynamic_bitset<> newResult = result;
436 // theTMBTrailer.setCRC(TMBCRCcalc());
437 
439  theTMBTrailer.data());
440  result = bitset_utilities::append(result,tmbTrailer);
441 
442  // now convert to a vector<bitset<16>>, so we can calculate the crc
443  std::vector<std::bitset<16> > wordVector;
444  // try to tune so it stops before the e0f line
445  for(unsigned pos = 0; pos < result.size()-16; pos += 16)
446  {
447  std::bitset<16> word;
448  for(int i = 0; i < 16; ++i)
449  {
450  word[i] = result[pos+i];
451  }
452  wordVector.push_back(word);
453  }
454  theTMBTrailer.setCRC(calCRC22(wordVector).to_ulong());
456  theTMBTrailer.data());
457  newResult = bitset_utilities::append(newResult, tmbTrailer);
458 
459  return newResult;
460 }
int sizeInWords() const
in 16-bit words
Definition: CSCCLCTData.h:46
CSCTMBTrailer * tmbTrailer()
Definition: CSCTMBData.h:53
CSCCLCTData * clctData()
Definition: CSCTMBData.h:43
CSCTMBTrailer theTMBTrailer
Definition: CSCTMBData.h:96
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:47
unsigned short * data()
Definition: CSCTMBTrailer.h:48
std::bitset< 22 > calCRC22(const std::vector< std::bitset< 16 > > &datain)
Definition: CSCTMBData.cc:365
CSCTMBHeader theTMBHeader
Definition: CSCTMBData.h:81
unsigned short * data()
Definition: CSCCLCTData.h:44
unsigned short * data()
Definition: CSCTMBHeader.h:117
void setCRC(int crc)
unsigned short int sizeInWords() const
Definition: CSCTMBHeader.h:111
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...
CSCCLCTData theCLCTData
Definition: CSCTMBData.h:82
CSCRPCData* CSCTMBData::rpcData ( )
inline

Definition at line 56 of file CSCTMBData.h.

References patCaloMETCorrections_cff::C, calCRC22(), nextCRC22_D16(), pack(), selfTest(), theRPCData, and TMBCRCcalc().

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

tests packing

Definition at line 463 of file CSCTMBData.cc.

References cscClassPackerCompare().

Referenced by rpcData().

464 {
465  CSCTMBData tmbData;
466  cscClassPackerCompare(tmbData);
467 }
bool cscClassPackerCompare(T &t)
static void CSCTMBData::setDebug ( const bool  value)
inlinestatic

Definition at line 37 of file CSCTMBData.h.

References debug, and relativeConstraints::value.

Referenced by CSCDCCUnpacker::CSCDCCUnpacker().

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

Definition at line 40 of file CSCTMBData.h.

References size_.

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

40 {return size_;}
unsigned short size_
Definition: CSCTMBData.h:102
CSCTMBBlockedCFEB & CSCTMBData::tmbBlockedCFEB ( ) const

Definition at line 389 of file CSCTMBData.cc.

References theBlockedCFEBIsPresent, and theTMBBlockedCFEB.

Referenced by hasTMBBlockedCFEB().

390 {
391  if (!theBlockedCFEBIsPresent) throw("No TMB Blocked CFEB in this chamber");
392  return * theTMBBlockedCFEB;
393 }
bool theBlockedCFEBIsPresent
Definition: CSCTMBData.h:93
CSCTMBBlockedCFEB * theTMBBlockedCFEB
Definition: CSCTMBData.h:94
int CSCTMBData::TMBCRCcalc ( )

Definition at line 147 of file CSCTMBData.cc.

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

Referenced by rpcData().

147  {
148  std::vector<std::bitset<16> > theTotalTMBData(theE0FLine+1-theB0CLine);
149  unsigned i = 0;
150  for (unsigned int line=theB0CLine; line<theE0FLine+1;++line) {
151  theTotalTMBData[i] = std::bitset<16>(theOriginalBuffer[line]);
152  ++i;
153  }
154  if ( !theTotalTMBData.empty() ) {
155  std::bitset<22> CRC=calCRC22(theTotalTMBData);
156  LogTrace("CSCTMBData|CSCRawToDigi") << " Test here " << CRC.to_ulong();
157  return CRC.to_ulong();
158  }
159  else {
160  LogTrace("CSCTMBData|CSCRawToDigi") << "theTotalTMBData doesn't exist";
161  return 0;
162  }
163 }
unsigned theE0FLine
Definition: CSCTMBData.h:79
unsigned theB0CLine
Definition: CSCTMBData.h:78
std::bitset< 22 > calCRC22(const std::vector< std::bitset< 16 > > &datain)
Definition: CSCTMBData.cc:365
const uint16_t * theOriginalBuffer
Definition: CSCTMBData.h:75
#define LogTrace(id)
CSCTMBHeader* CSCTMBData::tmbHeader ( )
inline
CSCTMBMiniScope & CSCTMBData::tmbMiniScope ( ) const

Definition at line 382 of file CSCTMBData.cc.

References theTMBMiniScope, and theTMBMiniScopeIsPresent.

Referenced by hasTMBMiniScope().

383 {
384  if (!theTMBMiniScopeIsPresent) throw("No TMBScope in this chamber");
385  return * theTMBMiniScope;
386 }
bool theTMBMiniScopeIsPresent
Definition: CSCTMBData.h:90
CSCTMBMiniScope * theTMBMiniScope
Definition: CSCTMBData.h:91
CSCTMBScope & CSCTMBData::tmbScope ( ) const

Definition at line 376 of file CSCTMBData.cc.

References theTMBScope, and theTMBScopeIsPresent.

Referenced by hasTMBScope().

377 {
378  if (!theTMBScopeIsPresent) throw("No TMBScope in this chamber");
379  return * theTMBScope;
380 }
bool theTMBScopeIsPresent
The TMB scope is not present in most of data hence its dynamic.
Definition: CSCTMBData.h:85
CSCTMBScope * theTMBScope
Definition: CSCTMBData.h:86
CSCTMBTrailer* CSCTMBData::tmbTrailer ( )
inline

Definition at line 53 of file CSCTMBData.h.

References theTMBTrailer.

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

53 {return &theTMBTrailer;}
CSCTMBTrailer theTMBTrailer
Definition: CSCTMBData.h:96
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

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 165 of file CSCTMBData.cc.

References CSCCLCTData::check(), CSCTMBHeader::check(), checkSize(), TauDecayModes::dec, findLine(), CSCTMBHeader::FirmwareVersion(), mps_splice::line, LogTrace, CSCTMBHeader::NCFEBs(), CSCTMBHeader::NTBins(), CSCRPCData::sizeInWords(), CSCCLCTData::sizeInWords(), CSCTMBTrailer::sizeInWords(), CSCTMBHeader::sizeInWords(), theB0CLine, theBlockedCFEBIsPresent, theCLCTData, theE0FLine, theRPCData, theRPCDataIsPresent, theTMBBlockedCFEB, theTMBHeader, theTMBMiniScope, theTMBMiniScopeIsPresent, theTMBScope, theTMBScopeIsPresent, and theTMBTrailer.

Referenced by CSCTMBData().

165  {
167  unsigned short int firmwareVersion=0;
168  int Ntbins = 0 ;
169  int NRPCtbins = 0; // =VB= number of RPC tbins
170 
171  int b0cLine=0;
172 
175  if (buf[b0cLine]==0xdb0c) {
176  firmwareVersion=2007;
177  Ntbins = buf[b0cLine+19]&0xF8;
178  NRPCtbins = (buf[b0cLine+36]>>5)&0x1F; // =VB= get RPC tbins
179  }
180  else if (buf[b0cLine]==0x6b0c) {
181  firmwareVersion=2006;
182  Ntbins = buf[b0cLine+1]&0x1f ;
183  NRPCtbins = Ntbins;
184  }
185  else {
186  LogTrace("CSCTMBData|CSCRawToDigi") << "+++ Can't find b0C flag";
187  }
188 
189  if ((firmwareVersion==2007)&&(!(((buf[b0cLine]&0xFFFF)==0xDB0C)&&((buf[b0cLine+1]&0xf000)==0xD000)
190  &&((buf[b0cLine+2]&0xf000)==0xD000)&&((buf[b0cLine+3]&0xf000)==0xD000)))){
191  LogTrace("CSCTMBData|CSCRawToDigi") << "+++ CSCTMBData warning: error in header in 2007 format!";
192  }
193 
194  int MaxSizeRPC = 1+NRPCtbins*2*4+1;
195  //int MaxSizeScope = 5;
196  int e0bLine =-1;
197  switch (firmwareVersion) {
198  case 2007:
199  e0bLine = 42; //last word of header2007
200  break;
201  case 2006:
202  e0bLine = 26; //last word of header in 2006 format
203  break;
204  default:
205  edm::LogError("CSCTMBData|CSCRawToDigi") << "+++ undetermined firmware format - cant find e0bLine";
206  }
207 
209 
210  if(!theTMBHeader.check()) {
211  LogTrace("CSCTMBData|CSCRawToDigi") << "+++ CSCTMBData warning: Bad TMB header e0bLine=" << std::hex << buf[e0bLine];
212  return 0;
213  }
214 
215  int currentPosition = theTMBHeader.sizeInWords();
216  int theFirmwareVersion = theTMBHeader.FirmwareVersion();
217 
218  theCLCTData = CSCCLCTData(theTMBHeader.NCFEBs(), theTMBHeader.NTBins(), buf+e0bLine+1, theFirmwareVersion);
219 
220  if(!theCLCTData.check()) {
221  LogTrace("CSCTMBData|CSCRawToDigi") << "+++ CSCTMBData warning: Bad CLCT data";
222  }
223  else {
224  currentPosition+=theCLCTData.sizeInWords();
225  }
226 
227  //int i = currentPosition-1;
228  //printf ( "%04x %04x %04x %04x\n",buf[i+3],buf[i+2],buf[i+1],buf[i] ) ;
229 
230 
231  // look for RPC
232  int b04Line = currentPosition;
233 
234  if(buf[b04Line]==0x6b04) {
235  // we need an e04 line to calculate the size
236  int e04Line = findLine(buf, 0x6e04, currentPosition, currentPosition+MaxSizeRPC);
237  if(e04Line != -1) {
238  theRPCDataIsPresent = true;
239  theRPCData = CSCRPCData(buf+b04Line, e04Line-b04Line+1);
240  currentPosition+=theRPCData.sizeInWords();
241  }
242  else {
243  LogTrace("CSCTMBData|CSCRawToDigi") << "CSCTMBData::corrupt RPC data! Failed to find end! ";
244  return 0;
245  }
246  }
247 
248  int TotTMBReadout=0;
249  switch (firmwareVersion) {
250  case 2007:
251  TotTMBReadout= 43+Ntbins*6*5+1+NRPCtbins*2*4+2+8*256+8;
252  break;
253  case 2006:
254  TotTMBReadout= 27+Ntbins*6*5+1+NRPCtbins*2*4+2+8*256+8; //see tmb2004 manual (version v2p06) page54.
255  break;
256  default:
257  edm::LogError("CSCTMBData|CSCRawToDigi") << "can't find TotTMBReadout - unknown firmware version!";
258  break;
259  }
260 
261 //std::cout << " !!!TMB Scope!!! " << std::endl;
262  if (buf[currentPosition]==0x6b05) {
263  int b05Line = currentPosition;
264  LogTrace("CSCTMBData|CSCRawToDigi") << "found scope!";
265  int e05Line = findLine(buf, 0x6e05, currentPosition, TotTMBReadout-currentPosition);
266  if(e05Line != -1){
267  theTMBScopeIsPresent = true;
268  theTMBScope = new CSCTMBScope(buf,b05Line, e05Line);
269  // The size of the TMB scope data can vary, and I see no good reasons
270  // not to determine it dynamically. -SV, 5 Nov 2008.
271  //currentPosition+=theTMBScope->sizeInWords();
272  currentPosition+=(e05Line-b05Line+1);
273  }
274  else {
275  LogTrace("CSCTMBData|CSCRawToDigi")
276  << "+++ CSCTMBData warning: found 0x6b05 line, but not 0x6e05! +++";
277  }
278  }
279 
281  if (buf[currentPosition]==0x6b07){
282  int Line6b07 = currentPosition;
283  LogTrace("CSCTMBData") << " TMBData ---> Begin of MiniScope found " ;
284  int Line6E07 = findLine(buf, 0x6E07, currentPosition, TotTMBReadout-currentPosition);
285  if(Line6E07 !=-1){
286  LogTrace("CSCTMBData") << " TMBData --> End of MiniScope found " << Line6E07-Line6b07+1 << " words ";
288  theTMBMiniScope = new CSCTMBMiniScope(buf, Line6b07, Line6E07);
289  currentPosition += (Line6E07-Line6b07+1);
290  }
291  else {
292  LogTrace("CSCTMBData")
293  << "+++ CSCTMBData warning MiniScope!: found 0x6b07 line, but not 0x6e07! +++";
294  }
295  }
297 
299  if (buf[currentPosition]==0x6BCB){
300  int Line6BCB = currentPosition;
301  LogTrace("CSCTMBData") << " TMBData ---> Begin of Blocked CFEB found " ;
302  int Line6ECB = findLine(buf, 0x6ECB, currentPosition, TotTMBReadout-currentPosition);
303  if(Line6ECB !=-1){
304  LogTrace("CSCTMBData") << " TMBData --> End of Blocked CFEB found " << Line6ECB-Line6BCB+1 << " words ";
306  theTMBBlockedCFEB = new CSCTMBBlockedCFEB(buf, Line6BCB, Line6ECB);
307  currentPosition += (Line6ECB-Line6BCB+1);
308  }
309  else {
310  LogTrace("CSCTMBData")
311  << "+++ CSCTMBData warning Blocked CFEB!: found 0x6BCB line, but not 0x6ECB! +++";
312  }
313  }
315 
316  int maxLine = findLine(buf, 0xde0f, currentPosition, TotTMBReadout-currentPosition);
317  if(maxLine == -1)
318  {
319  LogTrace("CSCTMBData|CSCRawToDigi") << "+++ CSCTMBData warning: No e0f line!";
320  return 0;
321  }
322 
323  //Now for CRC check put this information into bitset
324 
325  theB0CLine = b0cLine;
326  theE0FLine = maxLine;
327 
328  // finally, the trailer
329  int e0cLine = findLine(buf, 0x6e0c, currentPosition, maxLine);
330  if (e0cLine == -1)
331  {
332  LogTrace("CSCTMBData|CSCRawToDigi") << "+++ CSCTMBData warning: No e0c line!";
333  }
334  else
335  {
336  theTMBTrailer = CSCTMBTrailer(buf+e0cLine, firmwareVersion);
337  LogTrace("CSCTMBData|CSCRawToDigi")
338  << "TMB trailer size: " << theTMBTrailer.sizeInWords();
339  }
340 
341  checkSize();
342 
343  // Dump of TMB; format proposed by JK.
344 #ifdef TMBDUMP
345  LogTrace("CSCTMBData") << "Dump of TMB data:";
346  for (int line = b0cLine; line <= maxLine+3; line++) {
347  LogTrace("CSCTMBData")
348  << "Adr= " << std::setw(4) << line
349  << " Data= " << std::setfill('0') << std::setw(5)
350  << std::uppercase << std::hex << buf[line] << std::dec << std::endl;
351  }
352 #endif
353 
354  // size, since we count from 0 and have one more trailer word
355  // there are sometimes multiple "de0f" lines in trailer, so key on "6e0c"
356  return e0cLine-b0cLine+theTMBTrailer.sizeInWords();
357 } //UnpackTMB
int sizeInWords() const
in 16-bit words
Definition: CSCCLCTData.h:46
unsigned theE0FLine
Definition: CSCTMBData.h:79
bool theRPCDataIsPresent
Definition: CSCTMBData.h:104
uint16_t NTBins() const
Definition: CSCTMBHeader.h:79
CSCTMBTrailer theTMBTrailer
Definition: CSCTMBData.h:96
bool theBlockedCFEBIsPresent
Definition: CSCTMBData.h:93
bool theTMBMiniScopeIsPresent
Definition: CSCTMBData.h:90
int sizeInWords() const
in 16-bit frames
Definition: CSCTMBTrailer.h:47
unsigned theB0CLine
Definition: CSCTMBData.h:78
CSCRPCData theRPCData
Definition: CSCTMBData.h:83
uint16_t NCFEBs() const
Definition: CSCTMBHeader.h:82
CSCTMBHeader theTMBHeader
Definition: CSCTMBData.h:81
CSCTMBBlockedCFEB * theTMBBlockedCFEB
Definition: CSCTMBData.h:94
int sizeInWords()
Definition: CSCRPCData.h:22
#define LogTrace(id)
unsigned short int sizeInWords() const
Definition: CSCTMBHeader.h:111
CSCTMBMiniScope * theTMBMiniScope
Definition: CSCTMBData.h:91
bool theTMBScopeIsPresent
The TMB scope is not present in most of data hence its dynamic.
Definition: CSCTMBData.h:85
bool check() const
Definition: CSCCLCTData.cc:359
bool check() const
Definition: CSCTMBHeader.h:124
CSCTMBScope * theTMBScope
Definition: CSCTMBData.h:86
int findLine(const uint16_t *buf, uint16_t marker, int first, int maxToDo)
Definition: CSCTMBData.cc:138
int FirmwareVersion() const
Definition: CSCTMBHeader.h:38
bool checkSize() const
sees if the size adds up to the word count
Definition: CSCTMBData.cc:359
CSCCLCTData theCLCTData
Definition: CSCTMBData.h:82

Member Data Documentation

unsigned short CSCTMBData::cWordCnt
private

Definition at line 103 of file CSCTMBData.h.

Referenced by CWordCnt().

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

Definition at line 102 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 78 of file CSCTMBData.h.

Referenced by TMBCRCcalc(), and UnpackTMB().

bool CSCTMBData::theBlockedCFEBIsPresent
private

Definition at line 93 of file CSCTMBData.h.

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

CSCCLCTData CSCTMBData::theCLCTData
private

Definition at line 82 of file CSCTMBData.h.

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

unsigned CSCTMBData::theE0FLine
private

Definition at line 79 of file CSCTMBData.h.

Referenced by TMBCRCcalc(), and UnpackTMB().

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 75 of file CSCTMBData.h.

Referenced by TMBCRCcalc().

CSCRPCData CSCTMBData::theRPCData
private

Definition at line 83 of file CSCTMBData.h.

Referenced by rpcData(), and UnpackTMB().

bool CSCTMBData::theRPCDataIsPresent
private

Definition at line 104 of file CSCTMBData.h.

Referenced by hasRPC(), and UnpackTMB().

CSCTMBBlockedCFEB* CSCTMBData::theTMBBlockedCFEB
private

Definition at line 94 of file CSCTMBData.h.

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

CSCTMBHeader CSCTMBData::theTMBHeader
private

Definition at line 81 of file CSCTMBData.h.

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

CSCTMBMiniScope* CSCTMBData::theTMBMiniScope
private

Definition at line 91 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 90 of file CSCTMBData.h.

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

CSCTMBScope* CSCTMBData::theTMBScope
private

Definition at line 86 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 85 of file CSCTMBData.h.

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

CSCTMBTrailer CSCTMBData::theTMBTrailer
private

Definition at line 96 of file CSCTMBData.h.

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