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

Date:
2012/01/10 17:06:31
Revision:
1.32
Author
A. Tumanov - Rice

Definition at line 22 of file CSCTMBData.h.

Constructor & Destructor Documentation

CSCTMBData::CSCTMBData ( )

Definition at line 19 of file CSCTMBData.cc.

20  : theOriginalBuffer(0),
21  theB0CLine( 0 ),
22  theE0FLine( 0 ),
23  theTMBHeader(2007, 0x50c3),
25  theTMBScopeIsPresent(false),
26  theTMBScope(0),
28  theTMBMiniScope(0),
32  size_( 0 ),
33  cWordCnt( 0 ),
34  theRPCDataIsPresent(false)
35 {
36 
37 
38 }
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 93 of file CSCTMBData.cc.

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

93  {
95  delete theTMBScope;
96  theTMBScopeIsPresent = false;
97  }
98 
100  delete theTMBMiniScope;
101  theTMBMiniScopeIsPresent = false;
102  }
103 
105  delete theTMBBlockedCFEB;
106  theBlockedCFEBIsPresent = false;
107  }
108 }
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 41 of file CSCTMBData.cc.

References size_, and UnpackTMB().

42  : theOriginalBuffer(buf),
43  theTMBHeader(2007, 0x50c3),
45  theTMBScopeIsPresent(false),
46  theTMBScope(0),
48  theTMBMiniScope(0),
52  theRPCDataIsPresent(false){
53  size_ = UnpackTMB(buf);
54 }
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:139
CSCTMBData::CSCTMBData ( const CSCTMBData data)

Definition at line 58 of file CSCTMBData.cc.

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

58  :
67  size_(data.size_), cWordCnt(data.cWordCnt),
69 {
71  theTMBScope = new CSCTMBScope(*(data.theTMBScope));
72  }
73  else {
74  theTMBScope = 0;
75  }
76 
79  }
80  else {
81  theTMBMiniScope = 0;
82  }
83 
86  }
87  else {
89  }
90 
91 }
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 343 of file CSCTMBData.cc.

References i, and nextCRC22_D16().

Referenced by pack(), and TMBCRCcalc().

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

sees if the size adds up to the word count

Definition at line 337 of file CSCTMBData.cc.

Referenced by UnpackTMB().

338 {
339  // sum up all the components and see if they have the size indicated in the TMBTrailer
340  return true;
341 }
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 374 of file CSCTMBData.cc.

Referenced by calCRC22().

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

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

407 {
408  boost::dynamic_bitset<> result = bitset_utilities::ushortToBitset(theTMBHeader.sizeInWords()*16,
409  theTMBHeader.data());
410  boost::dynamic_bitset<> clctData = bitset_utilities::ushortToBitset(theCLCTData.sizeInWords()*16,
411  theCLCTData.data());
412  result = bitset_utilities::append(result,clctData);
413  boost::dynamic_bitset<> newResult = result;
414 // theTMBTrailer.setCRC(TMBCRCcalc());
415 
417  theTMBTrailer.data());
418  result = bitset_utilities::append(result,tmbTrailer);
419 
420  // now convert to a vector<bitset<16>>, so we can calculate the crc
421  std::vector<std::bitset<16> > wordVector;
422  // try to tune so it stops before the e0f line
423  for(unsigned pos = 0; pos < result.size()-16; pos += 16)
424  {
425  std::bitset<16> word;
426  for(int i = 0; i < 16; ++i)
427  {
428  word[i] = result[pos+i];
429  }
430  wordVector.push_back(word);
431  }
432  theTMBTrailer.setCRC(calCRC22(wordVector).to_ulong());
434  theTMBTrailer.data());
435  newResult = bitset_utilities::append(newResult, tmbTrailer);
436 
437  return newResult;
438 }
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:343
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 441 of file CSCTMBData.cc.

References cscClassPackerCompare().

442 {
443  CSCTMBData tmbData;
444  cscClassPackerCompare(tmbData);
445 }
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 367 of file CSCTMBData.cc.

References theBlockedCFEBIsPresent, and theTMBBlockedCFEB.

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

Definition at line 121 of file CSCTMBData.cc.

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

121  {
122  std::vector<std::bitset<16> > theTotalTMBData(theE0FLine+1-theB0CLine);
123  unsigned i = 0;
124  for (unsigned int line=theB0CLine; line<theE0FLine+1;++line) {
125  theTotalTMBData[i] = std::bitset<16>(theOriginalBuffer[line]);
126  ++i;
127  }
128  if ( theTotalTMBData.size() > 0 ) {
129  std::bitset<22> CRC=calCRC22(theTotalTMBData);
130  LogTrace("CSCTMBData|CSCRawToDigi") << " Test here " << CRC.to_ulong();
131  return CRC.to_ulong();
132  }
133  else {
134  LogTrace("CSCTMBData|CSCRawToDigi") << "theTotalTMBData doesn't exist";
135  return 0;
136  }
137 }
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:343
#define LogTrace(id)
CSCTMBHeader* CSCTMBData::tmbHeader ( )
inline
CSCTMBMiniScope & CSCTMBData::tmbMiniScope ( ) const

Definition at line 360 of file CSCTMBData.cc.

References theTMBMiniScope, and theTMBMiniScopeIsPresent.

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

Definition at line 354 of file CSCTMBData.cc.

References theTMBScope, and theTMBScopeIsPresent.

355 {
356  if (!theTMBScopeIsPresent) throw("No TMBScope in this chamber");
357  return * theTMBScope;
358 }
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 139 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().

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

Member Data Documentation

unsigned short CSCTMBData::cWordCnt
private

Definition at line 95 of file CSCTMBData.h.

Referenced by CWordCnt().

bool CSCTMBData::debug =false
staticprivate

Definition at line 93 of file CSCTMBData.h.

Referenced by setDebug().

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