test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros 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...
 
CSCCLCTDataclctData ()
 
 CSCTMBData ()
 
 CSCTMBData (int firmwareVersion, int firmwareRevision, int ncfebs=5)
 
 CSCTMBData (unsigned short *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 (unsigned short *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
 
unsigned short * 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(0),
23  theB0CLine( 0 ),
24  theE0FLine( 0 ),
25  theTMBHeader(2007, 0x50c3),
27  theTMBScopeIsPresent(false),
28  theTMBScope(0),
30  theTMBMiniScope(0),
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
unsigned short * theOriginalBuffer
Definition: CSCTMBData.h:75
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
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(0),
44  theB0CLine( 0 ),
45  theE0FLine( 0 ),
46  theTMBHeader(firmwareVersion, firmwareRevision),
48  theTMBScopeIsPresent(false),
49  theTMBScope(0),
51  theTMBMiniScope(0),
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
unsigned short * theOriginalBuffer
Definition: CSCTMBData.h:75
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
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 ( unsigned short *  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(0),
74  theTMBMiniScope(0),
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
unsigned short * theOriginalBuffer
Definition: CSCTMBData.h:75
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
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
int UnpackTMB(unsigned short *buf)
Definition: CSCTMBData.cc:165
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 = 0;
101  }
102 
105  }
106  else {
107  theTMBMiniScope = 0;
108  }
109 
112  }
113  else {
114  theTMBBlockedCFEB = 0;
115  }
116 
117 }
unsigned theE0FLine
Definition: CSCTMBData.h:79
bool theRPCDataIsPresent
Definition: CSCTMBData.h:104
CSCTMBTrailer theTMBTrailer
Definition: CSCTMBData.h:96
unsigned short * theOriginalBuffer
Definition: CSCTMBData.h:75
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
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 370 of file CSCTMBData.cc.

References i, and nextCRC22_D16().

Referenced by pack(), and TMBCRCcalc().

371 {
372  std::bitset<22> CRC;
373  CRC.reset();
374  for(unsigned int i=0;i<datain.size()-3;++i)
375  {
376  CRC=nextCRC22_D16(datain[i],CRC);
377  }
378  return CRC;
379 }
int i
Definition: DBlmapReader.cc:9
std::bitset< 22 > nextCRC22_D16(const std::bitset< 16 > &D, const std::bitset< 22 > &C)
Definition: CSCTMBData.cc:401
bool CSCTMBData::checkSize ( ) const

sees if the size adds up to the word count

Definition at line 364 of file CSCTMBData.cc.

Referenced by UnpackTMB().

365 {
366  // sum up all the components and see if they have the size indicated in the TMBTrailer
367  return true;
368 }
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.

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.

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.

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

Referenced by calCRC22().

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

not const because it sets size int TMBTrailer

this method is for digi2raw

Definition at line 433 of file CSCTMBData.cc.

References bitset_utilities::append(), calCRC22(), clctData(), CSCCLCTData::data(), CSCTMBTrailer::data(), CSCTMBHeader::data(), 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(), and CSCEventData::pack().

434 {
435  boost::dynamic_bitset<> result = bitset_utilities::ushortToBitset(theTMBHeader.sizeInWords()*16,
436  theTMBHeader.data());
437  boost::dynamic_bitset<> clctData = bitset_utilities::ushortToBitset(theCLCTData.sizeInWords()*16,
438  theCLCTData.data());
439  result = bitset_utilities::append(result,clctData);
440  boost::dynamic_bitset<> newResult = result;
441 // theTMBTrailer.setCRC(TMBCRCcalc());
442 
444  theTMBTrailer.data());
445  result = bitset_utilities::append(result,tmbTrailer);
446 
447  // now convert to a vector<bitset<16>>, so we can calculate the crc
448  std::vector<std::bitset<16> > wordVector;
449  // try to tune so it stops before the e0f line
450  for(unsigned pos = 0; pos < result.size()-16; pos += 16)
451  {
452  std::bitset<16> word;
453  for(int i = 0; i < 16; ++i)
454  {
455  word[i] = result[pos+i];
456  }
457  wordVector.push_back(word);
458  }
459  theTMBTrailer.setCRC(calCRC22(wordVector).to_ulong());
461  theTMBTrailer.data());
462  newResult = bitset_utilities::append(newResult, tmbTrailer);
463 
464  return newResult;
465 }
int sizeInWords() const
in 16-bit words
Definition: CSCCLCTData.h:46
CSCTMBTrailer * tmbTrailer()
Definition: CSCTMBData.h:53
CSCCLCTData * clctData()
Definition: CSCTMBData.h:43
int i
Definition: DBlmapReader.cc:9
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
tuple result
Definition: mps_fire.py:84
std::bitset< 22 > calCRC22(const std::vector< std::bitset< 16 > > &datain)
Definition: CSCTMBData.cc:370
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 theRPCData.

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

tests packing

Definition at line 468 of file CSCTMBData.cc.

References cscClassPackerCompare().

469 {
470  CSCTMBData tmbData;
471  cscClassPackerCompare(tmbData);
472 }
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 ntuple._Collection::__iter__(), ntuple._Collection::__len__(), and CSCEventData::unpack_data().

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

Definition at line 394 of file CSCTMBData.cc.

References theBlockedCFEBIsPresent, and theTMBBlockedCFEB.

395 {
396  if (!theBlockedCFEBIsPresent) throw("No TMB Blocked CFEB in this chamber");
397  return * theTMBBlockedCFEB;
398 }
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(), i, geometryCSVtoXML::line, LogTrace, theB0CLine, theE0FLine, and theOriginalBuffer.

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.size() > 0 ) {
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
int i
Definition: DBlmapReader.cc:9
unsigned short * theOriginalBuffer
Definition: CSCTMBData.h:75
unsigned theB0CLine
Definition: CSCTMBData.h:78
std::bitset< 22 > calCRC22(const std::vector< std::bitset< 16 > > &datain)
Definition: CSCTMBData.cc:370
#define LogTrace(id)
CSCTMBHeader* CSCTMBData::tmbHeader ( )
inline
CSCTMBMiniScope & CSCTMBData::tmbMiniScope ( ) const

Definition at line 387 of file CSCTMBData.cc.

References theTMBMiniScope, and theTMBMiniScopeIsPresent.

388 {
389  if (!theTMBMiniScopeIsPresent) throw("No TMBScope in this chamber");
390  return * theTMBMiniScope;
391 }
bool theTMBMiniScopeIsPresent
Definition: CSCTMBData.h:90
CSCTMBMiniScope * theTMBMiniScope
Definition: CSCTMBData.h:91
CSCTMBScope & CSCTMBData::tmbScope ( ) const

Definition at line 381 of file CSCTMBData.cc.

References theTMBScope, and theTMBScopeIsPresent.

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

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

unsigned short* 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().