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 (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:40
unsigned theE0FLine
Definition: CSCTMBData.h:75
bool theRPCDataIsPresent
Definition: CSCTMBData.h:96
CSCTMBTrailer theTMBTrailer
Definition: CSCTMBData.h:92
unsigned short * theOriginalBuffer
Definition: CSCTMBData.h:71
bool theBlockedCFEBIsPresent
Definition: CSCTMBData.h:89
unsigned short size_
Definition: CSCTMBData.h:94
bool theTMBMiniScopeIsPresent
Definition: CSCTMBData.h:86
unsigned theB0CLine
Definition: CSCTMBData.h:74
CSCTMBHeader theTMBHeader
Definition: CSCTMBData.h:77
CSCTMBBlockedCFEB * theTMBBlockedCFEB
Definition: CSCTMBData.h:90
unsigned short cWordCnt
Definition: CSCTMBData.h:95
unsigned short int sizeInWords() const
Definition: CSCTMBHeader.h:93
CSCTMBMiniScope * theTMBMiniScope
Definition: CSCTMBData.h:87
bool theTMBScopeIsPresent
The TMB scope is not present in most of data hence its dynamic.
Definition: CSCTMBData.h:81
CSCTMBScope * theTMBScope
Definition: CSCTMBData.h:82
CSCCLCTData theCLCTData
Definition: CSCTMBData.h:78
CSCTMBData::~CSCTMBData ( )

Definition at line 91 of file CSCTMBData.cc.

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

91  {
93  delete theTMBScope;
94  theTMBScopeIsPresent = false;
95  }
96 
98  delete theTMBMiniScope;
100  }
101 
103  delete theTMBBlockedCFEB;
104  theBlockedCFEBIsPresent = false;
105  }
106 }
bool theBlockedCFEBIsPresent
Definition: CSCTMBData.h:89
bool theTMBMiniScopeIsPresent
Definition: CSCTMBData.h:86
CSCTMBBlockedCFEB * theTMBBlockedCFEB
Definition: CSCTMBData.h:90
CSCTMBMiniScope * theTMBMiniScope
Definition: CSCTMBData.h:87
bool theTMBScopeIsPresent
The TMB scope is not present in most of data hence its dynamic.
Definition: CSCTMBData.h:81
CSCTMBScope * theTMBScope
Definition: CSCTMBData.h:82
CSCTMBData::CSCTMBData ( unsigned short *  buf)

Definition at line 39 of file CSCTMBData.cc.

References size_, and UnpackTMB().

40  : theOriginalBuffer(buf),
41  theTMBHeader(2007, 0x50c3),
43  theTMBScopeIsPresent(false),
44  theTMBScope(0),
46  theTMBMiniScope(0),
50  theRPCDataIsPresent(false){
51  size_ = UnpackTMB(buf);
52 }
int sizeInWords() const
in 16-bit words
Definition: CSCCLCTData.h:40
bool theRPCDataIsPresent
Definition: CSCTMBData.h:96
CSCTMBTrailer theTMBTrailer
Definition: CSCTMBData.h:92
unsigned short * theOriginalBuffer
Definition: CSCTMBData.h:71
bool theBlockedCFEBIsPresent
Definition: CSCTMBData.h:89
unsigned short size_
Definition: CSCTMBData.h:94
bool theTMBMiniScopeIsPresent
Definition: CSCTMBData.h:86
CSCTMBHeader theTMBHeader
Definition: CSCTMBData.h:77
CSCTMBBlockedCFEB * theTMBBlockedCFEB
Definition: CSCTMBData.h:90
unsigned short int sizeInWords() const
Definition: CSCTMBHeader.h:93
CSCTMBMiniScope * theTMBMiniScope
Definition: CSCTMBData.h:87
bool theTMBScopeIsPresent
The TMB scope is not present in most of data hence its dynamic.
Definition: CSCTMBData.h:81
CSCTMBScope * theTMBScope
Definition: CSCTMBData.h:82
CSCCLCTData theCLCTData
Definition: CSCTMBData.h:78
int UnpackTMB(unsigned short *buf)
Definition: CSCTMBData.cc:137
CSCTMBData::CSCTMBData ( const CSCTMBData data)

Definition at line 56 of file CSCTMBData.cc.

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

56  :
65  size_(data.size_), cWordCnt(data.cWordCnt),
67 {
69  theTMBScope = new CSCTMBScope(*(data.theTMBScope));
70  }
71  else {
72  theTMBScope = 0;
73  }
74 
77  }
78  else {
79  theTMBMiniScope = 0;
80  }
81 
84  }
85  else {
87  }
88 
89 }
unsigned theE0FLine
Definition: CSCTMBData.h:75
bool theRPCDataIsPresent
Definition: CSCTMBData.h:96
CSCTMBTrailer theTMBTrailer
Definition: CSCTMBData.h:92
unsigned short * theOriginalBuffer
Definition: CSCTMBData.h:71
bool theBlockedCFEBIsPresent
Definition: CSCTMBData.h:89
unsigned short size_
Definition: CSCTMBData.h:94
bool theTMBMiniScopeIsPresent
Definition: CSCTMBData.h:86
unsigned theB0CLine
Definition: CSCTMBData.h:74
CSCRPCData theRPCData
Definition: CSCTMBData.h:79
CSCTMBHeader theTMBHeader
Definition: CSCTMBData.h:77
CSCTMBBlockedCFEB * theTMBBlockedCFEB
Definition: CSCTMBData.h:90
unsigned short cWordCnt
Definition: CSCTMBData.h:95
CSCTMBMiniScope * theTMBMiniScope
Definition: CSCTMBData.h:87
bool theTMBScopeIsPresent
The TMB scope is not present in most of data hence its dynamic.
Definition: CSCTMBData.h:81
CSCTMBScope * theTMBScope
Definition: CSCTMBData.h:82
CSCCLCTData theCLCTData
Definition: CSCTMBData.h:78

Member Function Documentation

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

Definition at line 341 of file CSCTMBData.cc.

References i, and nextCRC22_D16().

Referenced by pack(), and TMBCRCcalc().

342 {
343  std::bitset<22> CRC;
344  CRC.reset();
345  for(unsigned int i=0;i<datain.size()-3;++i)
346  {
347  CRC=nextCRC22_D16(datain[i],CRC);
348  }
349  return CRC;
350 }
int i
Definition: DBlmapReader.cc:9
std::bitset< 22 > nextCRC22_D16(const std::bitset< 16 > &D, const std::bitset< 22 > &C)
Definition: CSCTMBData.cc:372
bool CSCTMBData::checkSize ( ) const

sees if the size adds up to the word count

Definition at line 335 of file CSCTMBData.cc.

Referenced by UnpackTMB().

336 {
337  // sum up all the components and see if they have the size indicated in the TMBTrailer
338  return true;
339 }
CSCCLCTData* CSCTMBData::clctData ( )
inline

Definition at line 39 of file CSCTMBData.h.

References theCLCTData.

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

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

Definition at line 34 of file CSCTMBData.h.

References cWordCnt.

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

Definition at line 35 of file CSCTMBData.h.

References CSCTMBTrailer::crc22(), and theTMBTrailer.

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

check this before using RPC

Definition at line 51 of file CSCTMBData.h.

References theRPCDataIsPresent.

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

check this before TMB Block CFEB

Definition at line 47 of file CSCTMBData.h.

References theBlockedCFEBIsPresent.

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

check this before using TMB mini scope

Definition at line 44 of file CSCTMBData.h.

References theTMBMiniScopeIsPresent.

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

check this before using TMB Scope

Definition at line 41 of file CSCTMBData.h.

References theTMBScopeIsPresent.

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

Definition at line 372 of file CSCTMBData.cc.

Referenced by calCRC22().

374 {
375  std::bitset<22> NewCRC;
376 
377  NewCRC[ 0] = D[ 0] ^ C[ 6];
378  NewCRC[ 1] = D[ 1] ^ D[ 0] ^ C[ 6] ^ C[ 7];
379  NewCRC[ 2] = D[ 2] ^ D[ 1] ^ C[ 7] ^ C[ 8];
380  NewCRC[ 3] = D[ 3] ^ D[ 2] ^ C[ 8] ^ C[ 9];
381  NewCRC[ 4] = D[ 4] ^ D[ 3] ^ C[ 9] ^ C[10];
382  NewCRC[ 5] = D[ 5] ^ D[ 4] ^ C[10] ^ C[11];
383  NewCRC[ 6] = D[ 6] ^ D[ 5] ^ C[11] ^ C[12];
384  NewCRC[ 7] = D[ 7] ^ D[ 6] ^ C[12] ^ C[13];
385  NewCRC[ 8] = D[ 8] ^ D[ 7] ^ C[13] ^ C[14];
386  NewCRC[ 9] = D[ 9] ^ D[ 8] ^ C[14] ^ C[15];
387  NewCRC[10] = D[10] ^ D[ 9] ^ C[15] ^ C[16];
388  NewCRC[11] = D[11] ^ D[10] ^ C[16] ^ C[17];
389  NewCRC[12] = D[12] ^ D[11] ^ C[17] ^ C[18];
390  NewCRC[13] = D[13] ^ D[12] ^ C[18] ^ C[19];
391  NewCRC[14] = D[14] ^ D[13] ^ C[19] ^ C[20];
392  NewCRC[15] = D[15] ^ D[14] ^ C[20] ^ C[21];
393  NewCRC[16] = D[15] ^ C[ 0] ^ C[21];
394  NewCRC[17] = C[ 1];
395  NewCRC[18] = C[ 2];
396  NewCRC[19] = C[ 3];
397  NewCRC[20] = C[ 4];
398  NewCRC[21] = C[ 5];
399 
400  return NewCRC;
401 }
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 404 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().

405 {
406  boost::dynamic_bitset<> result = bitset_utilities::ushortToBitset(theTMBHeader.sizeInWords()*16,
407  theTMBHeader.data());
408  boost::dynamic_bitset<> clctData = bitset_utilities::ushortToBitset(theCLCTData.sizeInWords()*16,
409  theCLCTData.data());
410  result = bitset_utilities::append(result,clctData);
411  boost::dynamic_bitset<> newResult = result;
412 // theTMBTrailer.setCRC(TMBCRCcalc());
413 
415  theTMBTrailer.data());
416  result = bitset_utilities::append(result,tmbTrailer);
417 
418  // now convert to a vector<bitset<16>>, so we can calculate the crc
419  std::vector<std::bitset<16> > wordVector;
420  // try to tune so it stops before the e0f line
421  for(unsigned pos = 0; pos < result.size()-16; pos += 16)
422  {
423  std::bitset<16> word;
424  for(int i = 0; i < 16; ++i)
425  {
426  word[i] = result[pos+i];
427  }
428  wordVector.push_back(word);
429  }
430  theTMBTrailer.setCRC(calCRC22(wordVector).to_ulong());
432  theTMBTrailer.data());
433  newResult = bitset_utilities::append(newResult, tmbTrailer);
434 
435  return newResult;
436 }
int sizeInWords() const
in 16-bit words
Definition: CSCCLCTData.h:40
CSCTMBTrailer * tmbTrailer()
Definition: CSCTMBData.h:49
CSCCLCTData * clctData()
Definition: CSCTMBData.h:39
int i
Definition: DBlmapReader.cc:9
CSCTMBTrailer theTMBTrailer
Definition: CSCTMBData.h:92
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:341
CSCTMBHeader theTMBHeader
Definition: CSCTMBData.h:77
unsigned short * data()
Definition: CSCCLCTData.h:38
tuple result
Definition: query.py:137
unsigned short * data()
Definition: CSCTMBHeader.h:99
void setCRC(int crc)
unsigned short int sizeInWords() const
Definition: CSCTMBHeader.h:93
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:78
CSCRPCData* CSCTMBData::rpcData ( )
inline

Definition at line 52 of file CSCTMBData.h.

References theRPCData.

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

tests packing

Definition at line 439 of file CSCTMBData.cc.

References cscClassPackerCompare().

440 {
441  CSCTMBData tmbData;
442  cscClassPackerCompare(tmbData);
443 }
bool cscClassPackerCompare(T &t)
static void CSCTMBData::setDebug ( const bool  value)
inlinestatic

Definition at line 33 of file CSCTMBData.h.

References debug, and relativeConstraints::value.

Referenced by CSCDCCUnpacker::CSCDCCUnpacker().

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

Definition at line 36 of file CSCTMBData.h.

References size_.

Referenced by CSCEventData::unpack_data().

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

Definition at line 365 of file CSCTMBData.cc.

References theBlockedCFEBIsPresent, and theTMBBlockedCFEB.

366 {
367  if (!theBlockedCFEBIsPresent) throw("No TMB Blocked CFEB in this chamber");
368  return * theTMBBlockedCFEB;
369 }
bool theBlockedCFEBIsPresent
Definition: CSCTMBData.h:89
CSCTMBBlockedCFEB * theTMBBlockedCFEB
Definition: CSCTMBData.h:90
int CSCTMBData::TMBCRCcalc ( )

Definition at line 119 of file CSCTMBData.cc.

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

119  {
120  std::vector<std::bitset<16> > theTotalTMBData(theE0FLine+1-theB0CLine);
121  unsigned i = 0;
122  for (unsigned int line=theB0CLine; line<theE0FLine+1;++line) {
123  theTotalTMBData[i] = std::bitset<16>(theOriginalBuffer[line]);
124  ++i;
125  }
126  if ( theTotalTMBData.size() > 0 ) {
127  std::bitset<22> CRC=calCRC22(theTotalTMBData);
128  LogTrace("CSCTMBData|CSCRawToDigi") << " Test here " << CRC.to_ulong();
129  return CRC.to_ulong();
130  }
131  else {
132  LogTrace("CSCTMBData|CSCRawToDigi") << "theTotalTMBData doesn't exist";
133  return 0;
134  }
135 }
unsigned theE0FLine
Definition: CSCTMBData.h:75
int i
Definition: DBlmapReader.cc:9
unsigned short * theOriginalBuffer
Definition: CSCTMBData.h:71
unsigned theB0CLine
Definition: CSCTMBData.h:74
std::bitset< 22 > calCRC22(const std::vector< std::bitset< 16 > > &datain)
Definition: CSCTMBData.cc:341
#define LogTrace(id)
CSCTMBHeader* CSCTMBData::tmbHeader ( )
inline
CSCTMBMiniScope & CSCTMBData::tmbMiniScope ( ) const

Definition at line 358 of file CSCTMBData.cc.

References theTMBMiniScope, and theTMBMiniScopeIsPresent.

359 {
360  if (!theTMBMiniScopeIsPresent) throw("No TMBScope in this chamber");
361  return * theTMBMiniScope;
362 }
bool theTMBMiniScopeIsPresent
Definition: CSCTMBData.h:86
CSCTMBMiniScope * theTMBMiniScope
Definition: CSCTMBData.h:87
CSCTMBScope & CSCTMBData::tmbScope ( ) const

Definition at line 352 of file CSCTMBData.cc.

References theTMBScope, and theTMBScopeIsPresent.

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

Definition at line 49 of file CSCTMBData.h.

References theTMBTrailer.

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

49 {return &theTMBTrailer;}
CSCTMBTrailer theTMBTrailer
Definition: CSCTMBData.h:92
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 137 of file CSCTMBData.cc.

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

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

Member Data Documentation

unsigned short CSCTMBData::cWordCnt
private

Definition at line 95 of file CSCTMBData.h.

Referenced by CWordCnt().

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

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

Referenced by TMBCRCcalc(), and UnpackTMB().

bool CSCTMBData::theBlockedCFEBIsPresent
private

Definition at line 89 of file CSCTMBData.h.

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

CSCCLCTData CSCTMBData::theCLCTData
private

Definition at line 78 of file CSCTMBData.h.

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

unsigned CSCTMBData::theE0FLine
private

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

Referenced by TMBCRCcalc().

CSCRPCData CSCTMBData::theRPCData
private

Definition at line 79 of file CSCTMBData.h.

Referenced by rpcData(), and UnpackTMB().

bool CSCTMBData::theRPCDataIsPresent
private

Definition at line 96 of file CSCTMBData.h.

Referenced by hasRPC(), and UnpackTMB().

CSCTMBBlockedCFEB* CSCTMBData::theTMBBlockedCFEB
private

Definition at line 90 of file CSCTMBData.h.

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

CSCTMBHeader CSCTMBData::theTMBHeader
private

Definition at line 77 of file CSCTMBData.h.

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

CSCTMBMiniScope* CSCTMBData::theTMBMiniScope
private

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

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

CSCTMBScope* CSCTMBData::theTMBScope
private

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

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

CSCTMBTrailer CSCTMBData::theTMBTrailer
private

Definition at line 92 of file CSCTMBData.h.

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