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 bool debug =false
 

Detailed Description

Author
A. Tumanov - Rice

Definition at line 22 of file CSCTMBData.h.

Constructor & Destructor Documentation

CSCTMBData::CSCTMBData ( )

Definition at line 17 of file CSCTMBData.cc.

18  : theOriginalBuffer(0),
19  theB0CLine( 0 ),
20  theE0FLine( 0 ),
21  theTMBHeader(2007, 0x50c3),
23  theTMBScopeIsPresent(false),
24  theTMBScope(0),
26  theTMBMiniScope(0),
30  size_( 0 ),
31  cWordCnt( 0 ),
32  theRPCDataIsPresent(false)
33 {
34 
35 
36 }
int sizeInWords() const
in 16-bit words
Definition: CSCCLCTData.h:46
unsigned theE0FLine
Definition: CSCTMBData.h:76
bool theRPCDataIsPresent
Definition: CSCTMBData.h:97
CSCTMBTrailer theTMBTrailer
Definition: CSCTMBData.h:93
unsigned short * theOriginalBuffer
Definition: CSCTMBData.h:72
bool theBlockedCFEBIsPresent
Definition: CSCTMBData.h:90
unsigned short size_
Definition: CSCTMBData.h:95
bool theTMBMiniScopeIsPresent
Definition: CSCTMBData.h:87
unsigned theB0CLine
Definition: CSCTMBData.h:75
CSCTMBHeader theTMBHeader
Definition: CSCTMBData.h:78
CSCTMBBlockedCFEB * theTMBBlockedCFEB
Definition: CSCTMBData.h:91
unsigned short cWordCnt
Definition: CSCTMBData.h:96
unsigned short int sizeInWords() const
Definition: CSCTMBHeader.h:100
CSCTMBMiniScope * theTMBMiniScope
Definition: CSCTMBData.h:88
bool theTMBScopeIsPresent
The TMB scope is not present in most of data hence its dynamic.
Definition: CSCTMBData.h:82
CSCTMBScope * theTMBScope
Definition: CSCTMBData.h:83
CSCCLCTData theCLCTData
Definition: CSCTMBData.h:79
CSCTMBData::CSCTMBData ( int  firmwareVersion,
int  firmwareRevision,
int  ncfebs = 5 
)

Definition at line 38 of file CSCTMBData.cc.

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

39  : theOriginalBuffer(0),
40  theB0CLine( 0 ),
41  theE0FLine( 0 ),
42  theTMBHeader(firmwareVersion, firmwareRevision),
44  theTMBScopeIsPresent(false),
45  theTMBScope(0),
47  theTMBMiniScope(0),
51  size_( 0 ),
52  cWordCnt( 0 ),
53  theRPCDataIsPresent(false)
54 {
55 
56  theTMBHeader.setNCFEBs(cfebs);
59 
60 
61 }
int sizeInWords() const
in 16-bit words
Definition: CSCCLCTData.h:46
unsigned theE0FLine
Definition: CSCTMBData.h:76
bool theRPCDataIsPresent
Definition: CSCTMBData.h:97
CSCTMBTrailer theTMBTrailer
Definition: CSCTMBData.h:93
unsigned short * theOriginalBuffer
Definition: CSCTMBData.h:72
bool theBlockedCFEBIsPresent
Definition: CSCTMBData.h:90
unsigned short size_
Definition: CSCTMBData.h:95
bool theTMBMiniScopeIsPresent
Definition: CSCTMBData.h:87
unsigned theB0CLine
Definition: CSCTMBData.h:75
void setNCFEBs(uint16_t ncfebs)
Definition: CSCTMBHeader.h:81
CSCTMBHeader theTMBHeader
Definition: CSCTMBData.h:78
CSCTMBBlockedCFEB * theTMBBlockedCFEB
Definition: CSCTMBData.h:91
unsigned short cWordCnt
Definition: CSCTMBData.h:96
unsigned short int sizeInWords() const
Definition: CSCTMBHeader.h:100
CSCTMBMiniScope * theTMBMiniScope
Definition: CSCTMBData.h:88
bool theTMBScopeIsPresent
The TMB scope is not present in most of data hence its dynamic.
Definition: CSCTMBData.h:82
CSCTMBScope * theTMBScope
Definition: CSCTMBData.h:83
CSCCLCTData theCLCTData
Definition: CSCTMBData.h:79
CSCTMBData::~CSCTMBData ( )

Definition at line 115 of file CSCTMBData.cc.

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

115  {
116  if (theTMBScopeIsPresent) {
117  delete theTMBScope;
118  theTMBScopeIsPresent = false;
119  }
120 
122  delete theTMBMiniScope;
123  theTMBMiniScopeIsPresent = false;
124  }
125 
127  delete theTMBBlockedCFEB;
128  theBlockedCFEBIsPresent = false;
129  }
130 }
bool theBlockedCFEBIsPresent
Definition: CSCTMBData.h:90
bool theTMBMiniScopeIsPresent
Definition: CSCTMBData.h:87
CSCTMBBlockedCFEB * theTMBBlockedCFEB
Definition: CSCTMBData.h:91
CSCTMBMiniScope * theTMBMiniScope
Definition: CSCTMBData.h:88
bool theTMBScopeIsPresent
The TMB scope is not present in most of data hence its dynamic.
Definition: CSCTMBData.h:82
CSCTMBScope * theTMBScope
Definition: CSCTMBData.h:83
CSCTMBData::CSCTMBData ( unsigned short *  buf)

Definition at line 63 of file CSCTMBData.cc.

References size_, and UnpackTMB().

64  : theOriginalBuffer(buf),
65  theTMBHeader(2007, 0x50c3),
67  theTMBScopeIsPresent(false),
68  theTMBScope(0),
70  theTMBMiniScope(0),
74  theRPCDataIsPresent(false){
75  size_ = UnpackTMB(buf);
76 }
int sizeInWords() const
in 16-bit words
Definition: CSCCLCTData.h:46
bool theRPCDataIsPresent
Definition: CSCTMBData.h:97
CSCTMBTrailer theTMBTrailer
Definition: CSCTMBData.h:93
unsigned short * theOriginalBuffer
Definition: CSCTMBData.h:72
bool theBlockedCFEBIsPresent
Definition: CSCTMBData.h:90
unsigned short size_
Definition: CSCTMBData.h:95
bool theTMBMiniScopeIsPresent
Definition: CSCTMBData.h:87
CSCTMBHeader theTMBHeader
Definition: CSCTMBData.h:78
CSCTMBBlockedCFEB * theTMBBlockedCFEB
Definition: CSCTMBData.h:91
unsigned short int sizeInWords() const
Definition: CSCTMBHeader.h:100
CSCTMBMiniScope * theTMBMiniScope
Definition: CSCTMBData.h:88
bool theTMBScopeIsPresent
The TMB scope is not present in most of data hence its dynamic.
Definition: CSCTMBData.h:82
CSCTMBScope * theTMBScope
Definition: CSCTMBData.h:83
CSCCLCTData theCLCTData
Definition: CSCTMBData.h:79
int UnpackTMB(unsigned short *buf)
Definition: CSCTMBData.cc:161
CSCTMBData::CSCTMBData ( const CSCTMBData data)

Definition at line 80 of file CSCTMBData.cc.

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

80  :
89  size_(data.size_), cWordCnt(data.cWordCnt),
91 {
93  theTMBScope = new CSCTMBScope(*(data.theTMBScope));
94  }
95  else {
96  theTMBScope = 0;
97  }
98 
101  }
102  else {
103  theTMBMiniScope = 0;
104  }
105 
108  }
109  else {
110  theTMBBlockedCFEB = 0;
111  }
112 
113 }
unsigned theE0FLine
Definition: CSCTMBData.h:76
bool theRPCDataIsPresent
Definition: CSCTMBData.h:97
CSCTMBTrailer theTMBTrailer
Definition: CSCTMBData.h:93
unsigned short * theOriginalBuffer
Definition: CSCTMBData.h:72
bool theBlockedCFEBIsPresent
Definition: CSCTMBData.h:90
unsigned short size_
Definition: CSCTMBData.h:95
bool theTMBMiniScopeIsPresent
Definition: CSCTMBData.h:87
unsigned theB0CLine
Definition: CSCTMBData.h:75
CSCRPCData theRPCData
Definition: CSCTMBData.h:80
CSCTMBHeader theTMBHeader
Definition: CSCTMBData.h:78
CSCTMBBlockedCFEB * theTMBBlockedCFEB
Definition: CSCTMBData.h:91
unsigned short cWordCnt
Definition: CSCTMBData.h:96
CSCTMBMiniScope * theTMBMiniScope
Definition: CSCTMBData.h:88
bool theTMBScopeIsPresent
The TMB scope is not present in most of data hence its dynamic.
Definition: CSCTMBData.h:82
CSCTMBScope * theTMBScope
Definition: CSCTMBData.h:83
CSCCLCTData theCLCTData
Definition: CSCTMBData.h:79

Member Function Documentation

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

Definition at line 366 of file CSCTMBData.cc.

References i, and nextCRC22_D16().

Referenced by pack(), and TMBCRCcalc().

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

sees if the size adds up to the word count

Definition at line 360 of file CSCTMBData.cc.

Referenced by UnpackTMB().

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

Definition at line 40 of file CSCTMBData.h.

References theCLCTData.

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

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

Definition at line 35 of file CSCTMBData.h.

References cWordCnt.

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

Definition at line 36 of file CSCTMBData.h.

References CSCTMBTrailer::crc22(), and theTMBTrailer.

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

check this before using RPC

Definition at line 52 of file CSCTMBData.h.

References theRPCDataIsPresent.

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

check this before TMB Block CFEB

Definition at line 48 of file CSCTMBData.h.

References theBlockedCFEBIsPresent.

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

check this before using TMB mini scope

Definition at line 45 of file CSCTMBData.h.

References theTMBMiniScopeIsPresent.

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

check this before using TMB Scope

Definition at line 42 of file CSCTMBData.h.

References theTMBScopeIsPresent.

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

Definition at line 397 of file CSCTMBData.cc.

Referenced by calCRC22().

399 {
400  std::bitset<22> NewCRC;
401 
402  NewCRC[ 0] = D[ 0] ^ C[ 6];
403  NewCRC[ 1] = D[ 1] ^ D[ 0] ^ C[ 6] ^ C[ 7];
404  NewCRC[ 2] = D[ 2] ^ D[ 1] ^ C[ 7] ^ C[ 8];
405  NewCRC[ 3] = D[ 3] ^ D[ 2] ^ C[ 8] ^ C[ 9];
406  NewCRC[ 4] = D[ 4] ^ D[ 3] ^ C[ 9] ^ C[10];
407  NewCRC[ 5] = D[ 5] ^ D[ 4] ^ C[10] ^ C[11];
408  NewCRC[ 6] = D[ 6] ^ D[ 5] ^ C[11] ^ C[12];
409  NewCRC[ 7] = D[ 7] ^ D[ 6] ^ C[12] ^ C[13];
410  NewCRC[ 8] = D[ 8] ^ D[ 7] ^ C[13] ^ C[14];
411  NewCRC[ 9] = D[ 9] ^ D[ 8] ^ C[14] ^ C[15];
412  NewCRC[10] = D[10] ^ D[ 9] ^ C[15] ^ C[16];
413  NewCRC[11] = D[11] ^ D[10] ^ C[16] ^ C[17];
414  NewCRC[12] = D[12] ^ D[11] ^ C[17] ^ C[18];
415  NewCRC[13] = D[13] ^ D[12] ^ C[18] ^ C[19];
416  NewCRC[14] = D[14] ^ D[13] ^ C[19] ^ C[20];
417  NewCRC[15] = D[15] ^ D[14] ^ C[20] ^ C[21];
418  NewCRC[16] = D[15] ^ C[ 0] ^ C[21];
419  NewCRC[17] = C[ 1];
420  NewCRC[18] = C[ 2];
421  NewCRC[19] = C[ 3];
422  NewCRC[20] = C[ 4];
423  NewCRC[21] = C[ 5];
424 
425  return NewCRC;
426 }
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 429 of file CSCTMBData.cc.

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

430 {
431  boost::dynamic_bitset<> result = bitset_utilities::ushortToBitset(theTMBHeader.sizeInWords()*16,
432  theTMBHeader.data());
433  boost::dynamic_bitset<> clctData = bitset_utilities::ushortToBitset(theCLCTData.sizeInWords()*16,
434  theCLCTData.data());
435  result = bitset_utilities::append(result,clctData);
436  boost::dynamic_bitset<> newResult = result;
437 // theTMBTrailer.setCRC(TMBCRCcalc());
438 
440  theTMBTrailer.data());
441  result = bitset_utilities::append(result,tmbTrailer);
442 
443  // now convert to a vector<bitset<16>>, so we can calculate the crc
444  std::vector<std::bitset<16> > wordVector;
445  // try to tune so it stops before the e0f line
446  for(unsigned pos = 0; pos < result.size()-16; pos += 16)
447  {
448  std::bitset<16> word;
449  for(int i = 0; i < 16; ++i)
450  {
451  word[i] = result[pos+i];
452  }
453  wordVector.push_back(word);
454  }
455  theTMBTrailer.setCRC(calCRC22(wordVector).to_ulong());
457  theTMBTrailer.data());
458  newResult = bitset_utilities::append(newResult, tmbTrailer);
459 
460  return newResult;
461 }
int sizeInWords() const
in 16-bit words
Definition: CSCCLCTData.h:46
CSCTMBTrailer * tmbTrailer()
Definition: CSCTMBData.h:50
CSCCLCTData * clctData()
Definition: CSCTMBData.h:40
int i
Definition: DBlmapReader.cc:9
CSCTMBTrailer theTMBTrailer
Definition: CSCTMBData.h:93
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:366
CSCTMBHeader theTMBHeader
Definition: CSCTMBData.h:78
unsigned short * data()
Definition: CSCCLCTData.h:44
tuple result
Definition: query.py:137
unsigned short * data()
Definition: CSCTMBHeader.h:106
void setCRC(int crc)
unsigned short int sizeInWords() const
Definition: CSCTMBHeader.h:100
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:79
CSCRPCData* CSCTMBData::rpcData ( )
inline

Definition at line 53 of file CSCTMBData.h.

References theRPCData.

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

tests packing

Definition at line 464 of file CSCTMBData.cc.

References cscClassPackerCompare().

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

Definition at line 34 of file CSCTMBData.h.

References debug, and relativeConstraints::value.

Referenced by CSCDCCUnpacker::CSCDCCUnpacker().

34 {debug = value;}
static bool debug
Definition: CSCTMBData.h:94
const unsigned short CSCTMBData::size ( void  ) const
inline

Definition at line 37 of file CSCTMBData.h.

References size_.

Referenced by CSCEventData::unpack_data().

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

Definition at line 390 of file CSCTMBData.cc.

References theBlockedCFEBIsPresent, and theTMBBlockedCFEB.

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

Definition at line 143 of file CSCTMBData.cc.

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

143  {
144  std::vector<std::bitset<16> > theTotalTMBData(theE0FLine+1-theB0CLine);
145  unsigned i = 0;
146  for (unsigned int line=theB0CLine; line<theE0FLine+1;++line) {
147  theTotalTMBData[i] = std::bitset<16>(theOriginalBuffer[line]);
148  ++i;
149  }
150  if ( theTotalTMBData.size() > 0 ) {
151  std::bitset<22> CRC=calCRC22(theTotalTMBData);
152  LogTrace("CSCTMBData|CSCRawToDigi") << " Test here " << CRC.to_ulong();
153  return CRC.to_ulong();
154  }
155  else {
156  LogTrace("CSCTMBData|CSCRawToDigi") << "theTotalTMBData doesn't exist";
157  return 0;
158  }
159 }
unsigned theE0FLine
Definition: CSCTMBData.h:76
int i
Definition: DBlmapReader.cc:9
unsigned short * theOriginalBuffer
Definition: CSCTMBData.h:72
unsigned theB0CLine
Definition: CSCTMBData.h:75
std::bitset< 22 > calCRC22(const std::vector< std::bitset< 16 > > &datain)
Definition: CSCTMBData.cc:366
#define LogTrace(id)
CSCTMBHeader* CSCTMBData::tmbHeader ( )
inline
CSCTMBMiniScope & CSCTMBData::tmbMiniScope ( ) const

Definition at line 383 of file CSCTMBData.cc.

References theTMBMiniScope, and theTMBMiniScopeIsPresent.

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

Definition at line 377 of file CSCTMBData.cc.

References theTMBScope, and theTMBScopeIsPresent.

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

Definition at line 50 of file CSCTMBData.h.

References theTMBTrailer.

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

50 {return &theTMBTrailer;}
CSCTMBTrailer theTMBTrailer
Definition: CSCTMBData.h:93
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 161 of file CSCTMBData.cc.

References CSCCLCTData::check(), CSCTMBHeader::check(), checkSize(), 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().

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

Member Data Documentation

unsigned short CSCTMBData::cWordCnt
private

Definition at line 96 of file CSCTMBData.h.

Referenced by CWordCnt().

bool CSCTMBData::debug =false
staticprivate
unsigned short CSCTMBData::size_
private

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

Referenced by TMBCRCcalc(), and UnpackTMB().

bool CSCTMBData::theBlockedCFEBIsPresent
private

Definition at line 90 of file CSCTMBData.h.

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

CSCCLCTData CSCTMBData::theCLCTData
private

Definition at line 79 of file CSCTMBData.h.

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

unsigned CSCTMBData::theE0FLine
private

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

Referenced by TMBCRCcalc().

CSCRPCData CSCTMBData::theRPCData
private

Definition at line 80 of file CSCTMBData.h.

Referenced by rpcData(), and UnpackTMB().

bool CSCTMBData::theRPCDataIsPresent
private

Definition at line 97 of file CSCTMBData.h.

Referenced by hasRPC(), and UnpackTMB().

CSCTMBBlockedCFEB* CSCTMBData::theTMBBlockedCFEB
private

Definition at line 91 of file CSCTMBData.h.

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

CSCTMBHeader CSCTMBData::theTMBHeader
private

Definition at line 78 of file CSCTMBData.h.

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

CSCTMBMiniScope* CSCTMBData::theTMBMiniScope
private

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

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

CSCTMBScope* CSCTMBData::theTMBScope
private

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

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

CSCTMBTrailer CSCTMBData::theTMBTrailer
private

Definition at line 93 of file CSCTMBData.h.

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