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 | Friends
CSCTMBHeader Class Reference

#include <CSCTMBHeader.h>

Public Member Functions

void add (const std::vector< CSCCLCTDigi > &digis)
 these methods need more brains to figure which one goes first More...
 
void add (const std::vector< CSCCorrelatedLCTDigi > &digis)
 
void addALCT0 (const CSCALCTDigi &digi)
 
void addALCT1 (const CSCALCTDigi &digi)
 
void addCLCT0 (const CSCCLCTDigi &digi)
 Needed before data packing. More...
 
void addCLCT1 (const CSCCLCTDigi &digi)
 
void addCorrelatedLCT0 (const CSCCorrelatedLCTDigi &digi)
 
void addCorrelatedLCT1 (const CSCCorrelatedLCTDigi &digi)
 
uint16_t ALCTMatchTime () const
 
uint16_t ALCTOnly () const
 
uint16_t Bxn0Diff () const
 
uint16_t Bxn1Diff () const
 
uint16_t BXNCount () const
 
bool check () const
 
std::vector< CSCCLCTDigiCLCTDigis (uint32_t idlayer)
 returns CLCT digis More...
 
uint16_t CLCTOnly () const
 
std::vector< CSCCorrelatedLCTDigiCorrelatedLCTDigis (uint32_t idlayer) const
 returns CorrelatedLCT digis More...
 
 CSCTMBHeader (int firmwareVersion, int firmwareRevision)
 
 CSCTMBHeader (const CSCTMBStatusDigi &digi)
 
 CSCTMBHeader (const unsigned short *buf)
 
unsigned short * data ()
 
int FirmwareVersion () const
 
uint16_t L1ANumber () const
 
uint16_t NCFEBs () const
 
unsigned short int NHeaderFrames () const
 
uint16_t NTBins () const
 
void setEventInformation (const CSCDMBHeader &dmbHeader)
 fills fields like bxn and l1a More...
 
uint16_t sizeInBytes () const
 
unsigned short int sizeInWords () const
 
CSCTMBHeader2006 tmbHeader2006 () const
 
CSCTMBHeader2007 tmbHeader2007 () const
 will throw if the cast fails More...
 
uint16_t TMBMatch () const
 

Static Public Member Functions

static void selfTest ()
 tests that packing and unpacking give same results More...
 
static void setDebug (const bool value)
 

Private Attributes

int theFirmwareVersion
 
boost::shared_ptr
< CSCVTMBHeaderFormat
theHeaderFormat
 

Static Private Attributes

static bool debug = false
 

Friends

std::ostream & operator<< (std::ostream &os, const CSCTMBHeader &hdr)
 

Detailed Description

Definition at line 20 of file CSCTMBHeader.h.

Constructor & Destructor Documentation

CSCTMBHeader::CSCTMBHeader ( int  firmwareVersion,
int  firmwareRevision 
)

Definition at line 15 of file CSCTMBHeader.cc.

References theHeaderFormat.

15  :
17  theFirmwareVersion(firmwareVersion)
18 {
19  if(firmwareVersion == 2006)
20  {
21  theHeaderFormat = boost::shared_ptr<CSCVTMBHeaderFormat>(new CSCTMBHeader2006());
22  }
23  else if(firmwareVersion == 2007)
24  {
25  if(firmwareRevision >= 0x50c3)
26  {
27  theHeaderFormat = boost::shared_ptr<CSCVTMBHeaderFormat>(new CSCTMBHeader2007_rev0x50c3());
28  }
29  else
30  {
31  theHeaderFormat = boost::shared_ptr<CSCVTMBHeaderFormat>(new CSCTMBHeader2007());
32  }
33  }
34  else
35  {
36  edm::LogError("CSCTMBHeader|CSCRawToDigi") <<"failed to determine TMB firmware version!!";
37  }
38 }
int theFirmwareVersion
Definition: CSCTMBHeader.h:142
boost::shared_ptr< CSCVTMBHeaderFormat > theHeaderFormat
Definition: CSCTMBHeader.h:141
CSCTMBHeader::CSCTMBHeader ( const CSCTMBStatusDigi digi)
CSCTMBHeader::CSCTMBHeader ( const unsigned short *  buf)

first determine the format

Definition at line 44 of file CSCTMBHeader.cc.

References theFirmwareVersion, and theHeaderFormat.

46 {
48  if (buf[0]==0xDB0C) {
49  theFirmwareVersion=2007;
50  theHeaderFormat = boost::shared_ptr<CSCVTMBHeaderFormat>(new CSCTMBHeader2007(buf));
51  if(theHeaderFormat->firmwareRevision() >= 0x50c3)
52  {
53  theHeaderFormat = boost::shared_ptr<CSCVTMBHeaderFormat>(new CSCTMBHeader2007_rev0x50c3(buf));
54  }
55  }
56  else if (buf[0]==0x6B0C) {
57  theFirmwareVersion=2006;
58  theHeaderFormat = boost::shared_ptr<CSCVTMBHeaderFormat>(new CSCTMBHeader2006(buf));
59  }
60  else {
61  edm::LogError("CSCTMBHeader|CSCRawToDigi") <<"failed to determine TMB firmware version!!";
62  }
63 }
int theFirmwareVersion
Definition: CSCTMBHeader.h:142
boost::shared_ptr< CSCVTMBHeaderFormat > theHeaderFormat
Definition: CSCTMBHeader.h:141

Member Function Documentation

void CSCTMBHeader::add ( const std::vector< CSCCLCTDigi > &  digis)

these methods need more brains to figure which one goes first

Definition at line 99 of file CSCTMBHeader.cc.

References addCLCT0(), and addCLCT1().

Referenced by CSCEventData::add().

100 {
101  // sort???
102  if(digis.size() > 0) addCLCT0(digis[0]);
103  if(digis.size() > 1) addCLCT1(digis[1]);
104 }
void addCLCT1(const CSCCLCTDigi &digi)
Definition: CSCTMBHeader.h:115
void addCLCT0(const CSCCLCTDigi &digi)
Needed before data packing.
Definition: CSCTMBHeader.h:114
void CSCTMBHeader::add ( const std::vector< CSCCorrelatedLCTDigi > &  digis)

Definition at line 106 of file CSCTMBHeader.cc.

References addCorrelatedLCT0(), and addCorrelatedLCT1().

107 {
108  // sort???
109  if(digis.size() > 0) addCorrelatedLCT0(digis[0]);
110  if(digis.size() > 1) addCorrelatedLCT1(digis[1]);
111 }
void addCorrelatedLCT0(const CSCCorrelatedLCTDigi &digi)
Definition: CSCTMBHeader.h:118
void addCorrelatedLCT1(const CSCCorrelatedLCTDigi &digi)
Definition: CSCTMBHeader.h:121
void CSCTMBHeader::addALCT0 ( const CSCALCTDigi digi)
inline

Definition at line 116 of file CSCTMBHeader.h.

References theHeaderFormat.

116 {theHeaderFormat->addALCT0(digi);}
boost::shared_ptr< CSCVTMBHeaderFormat > theHeaderFormat
Definition: CSCTMBHeader.h:141
void CSCTMBHeader::addALCT1 ( const CSCALCTDigi digi)
inline

Definition at line 117 of file CSCTMBHeader.h.

References theHeaderFormat.

117 {theHeaderFormat->addALCT1(digi);}
boost::shared_ptr< CSCVTMBHeaderFormat > theHeaderFormat
Definition: CSCTMBHeader.h:141
void CSCTMBHeader::addCLCT0 ( const CSCCLCTDigi digi)
inline

Needed before data packing.

for data packing

Definition at line 114 of file CSCTMBHeader.h.

References theHeaderFormat.

Referenced by add(), and selfTest().

114 {theHeaderFormat->addCLCT0(digi);}
boost::shared_ptr< CSCVTMBHeaderFormat > theHeaderFormat
Definition: CSCTMBHeader.h:141
void CSCTMBHeader::addCLCT1 ( const CSCCLCTDigi digi)
inline

Definition at line 115 of file CSCTMBHeader.h.

References theHeaderFormat.

Referenced by add(), and selfTest().

115 {theHeaderFormat->addCLCT1(digi);}
boost::shared_ptr< CSCVTMBHeaderFormat > theHeaderFormat
Definition: CSCTMBHeader.h:141
void CSCTMBHeader::addCorrelatedLCT0 ( const CSCCorrelatedLCTDigi digi)
inline

Definition at line 118 of file CSCTMBHeader.h.

References theHeaderFormat.

Referenced by add(), and selfTest().

118  {
119  theHeaderFormat->addCorrelatedLCT0(digi);
120  }
boost::shared_ptr< CSCVTMBHeaderFormat > theHeaderFormat
Definition: CSCTMBHeader.h:141
void CSCTMBHeader::addCorrelatedLCT1 ( const CSCCorrelatedLCTDigi digi)
inline

Definition at line 121 of file CSCTMBHeader.h.

References theHeaderFormat.

Referenced by add(), and selfTest().

121  {
122  theHeaderFormat->addCorrelatedLCT1(digi);
123  }
boost::shared_ptr< CSCVTMBHeaderFormat > theHeaderFormat
Definition: CSCTMBHeader.h:141
uint16_t CSCTMBHeader::ALCTMatchTime ( ) const
inline

Definition at line 39 of file CSCTMBHeader.h.

References theHeaderFormat.

Referenced by CSCOfflineMonitor::doBXMonitor(), CSCValidation::doTimeMonitoring(), and cscdqm::EventProcessor::processCSC().

39  {
40  return theHeaderFormat->ALCTMatchTime();
41  }
boost::shared_ptr< CSCVTMBHeaderFormat > theHeaderFormat
Definition: CSCTMBHeader.h:141
uint16_t CSCTMBHeader::ALCTOnly ( ) const
inline

Definition at line 45 of file CSCTMBHeader.h.

References theHeaderFormat.

Referenced by cscdqm::EventProcessor::processCSC().

45  {
46  return theHeaderFormat->ALCTOnly();
47  }
boost::shared_ptr< CSCVTMBHeaderFormat > theHeaderFormat
Definition: CSCTMBHeader.h:141
uint16_t CSCTMBHeader::Bxn0Diff ( ) const
inline

Definition at line 52 of file CSCTMBHeader.h.

References theHeaderFormat.

Referenced by cscdqm::EventProcessor::processCSC().

52  {
53  return theHeaderFormat->Bxn0Diff();
54  }
boost::shared_ptr< CSCVTMBHeaderFormat > theHeaderFormat
Definition: CSCTMBHeader.h:141
uint16_t CSCTMBHeader::Bxn1Diff ( ) const
inline

Definition at line 55 of file CSCTMBHeader.h.

References theHeaderFormat.

Referenced by cscdqm::EventProcessor::processCSC().

55  {
56  return theHeaderFormat->Bxn1Diff();
57  }
boost::shared_ptr< CSCVTMBHeaderFormat > theHeaderFormat
Definition: CSCTMBHeader.h:141
uint16_t CSCTMBHeader::BXNCount ( ) const
inline

Definition at line 36 of file CSCTMBHeader.h.

References theHeaderFormat.

Referenced by CSCOfflineMonitor::doBXMonitor(), CSCValidation::doTimeMonitoring(), and cscdqm::EventProcessor::processCSC().

36  {
37  return theHeaderFormat->BXNCount();
38  }
boost::shared_ptr< CSCVTMBHeaderFormat > theHeaderFormat
Definition: CSCTMBHeader.h:141
bool CSCTMBHeader::check ( ) const
inline

Definition at line 106 of file CSCTMBHeader.h.

References theHeaderFormat.

Referenced by CSCTMBData::UnpackTMB().

106  {
107  return theHeaderFormat->check();
108  }
boost::shared_ptr< CSCVTMBHeaderFormat > theHeaderFormat
Definition: CSCTMBHeader.h:141
std::vector<CSCCLCTDigi> CSCTMBHeader::CLCTDigis ( uint32_t  idlayer)
inline

returns CLCT digis

Definition at line 80 of file CSCTMBHeader.h.

References theHeaderFormat.

Referenced by cscdqm::EventProcessor::processCSC(), selfTest(), and CSCEventData::selfTest().

81  {
82  return theHeaderFormat->CLCTDigis(idlayer);
83  }
boost::shared_ptr< CSCVTMBHeaderFormat > theHeaderFormat
Definition: CSCTMBHeader.h:141
uint16_t CSCTMBHeader::CLCTOnly ( ) const
inline

Definition at line 42 of file CSCTMBHeader.h.

References theHeaderFormat.

Referenced by cscdqm::EventProcessor::processCSC().

42  {
43  return theHeaderFormat->CLCTOnly();
44  }
boost::shared_ptr< CSCVTMBHeaderFormat > theHeaderFormat
Definition: CSCTMBHeader.h:141
std::vector<CSCCorrelatedLCTDigi> CSCTMBHeader::CorrelatedLCTDigis ( uint32_t  idlayer) const
inline

returns CorrelatedLCT digis

Definition at line 86 of file CSCTMBHeader.h.

References theHeaderFormat.

Referenced by selfTest(), and CSCEventData::selfTest().

87  {
88  return theHeaderFormat->CorrelatedLCTDigis(idlayer);
89  }
boost::shared_ptr< CSCVTMBHeaderFormat > theHeaderFormat
Definition: CSCTMBHeader.h:141
unsigned short* CSCTMBHeader::data ( )
inline

Definition at line 99 of file CSCTMBHeader.h.

References theHeaderFormat.

Referenced by cuy.FindIssue::__init__(), CSCTMBData::pack(), and selfTest().

99  {
100  return theHeaderFormat->data();
101  }
boost::shared_ptr< CSCVTMBHeaderFormat > theHeaderFormat
Definition: CSCTMBHeader.h:141
int CSCTMBHeader::FirmwareVersion ( ) const
inline

Definition at line 33 of file CSCTMBHeader.h.

References theFirmwareVersion.

33 {return theFirmwareVersion;}
int theFirmwareVersion
Definition: CSCTMBHeader.h:142
uint16_t CSCTMBHeader::L1ANumber ( ) const
inline

Definition at line 59 of file CSCTMBHeader.h.

References theHeaderFormat.

Referenced by cscdqm::EventProcessor::processCSC().

59  {
60  return theHeaderFormat->L1ANumber();
61  }
boost::shared_ptr< CSCVTMBHeaderFormat > theHeaderFormat
Definition: CSCTMBHeader.h:141
uint16_t CSCTMBHeader::NCFEBs ( ) const
inline

Definition at line 74 of file CSCTMBHeader.h.

References theHeaderFormat.

Referenced by CSCTMBData::UnpackTMB().

74  {
75  return theHeaderFormat->NCFEBs();
76  }
boost::shared_ptr< CSCVTMBHeaderFormat > theHeaderFormat
Definition: CSCTMBHeader.h:141
unsigned short int CSCTMBHeader::NHeaderFrames ( ) const
inline

Definition at line 95 of file CSCTMBHeader.h.

References theHeaderFormat.

95  {
96  return theHeaderFormat->NHeaderFrames();
97  }
boost::shared_ptr< CSCVTMBHeaderFormat > theHeaderFormat
Definition: CSCTMBHeader.h:141
uint16_t CSCTMBHeader::NTBins ( ) const
inline

Definition at line 71 of file CSCTMBHeader.h.

References theHeaderFormat.

Referenced by CSCTMBData::UnpackTMB().

71  {
72  return theHeaderFormat->NTBins();
73  }
boost::shared_ptr< CSCVTMBHeaderFormat > theHeaderFormat
Definition: CSCTMBHeader.h:141
void CSCTMBHeader::selfTest ( )
static

tests that packing and unpacking give same results

Definition at line 134 of file CSCTMBHeader.cc.

References addCLCT0(), addCLCT1(), addCorrelatedLCT0(), addCorrelatedLCT1(), CLCTDigis(), CorrelatedLCTDigis(), gather_cfg::cout, cscPackerCompare(), data(), debug, DetId::rawId(), and relativeConstraints::station.

135 {
136  static bool debug = false;
137 
138  // tests packing and unpacking
139  for(int station = 1; station <= 4; ++station) {
140  for(int iendcap = 1; iendcap <= 2; ++iendcap) {
141  CSCDetId detId(iendcap, station, 1, 1, 0);
142 
143  // the next-to-last is the BX, which only gets
144  // saved in two bits and must be the same for clct0 and clct1.
145  //CSCCLCTDigi clct0(1, 1, 4, 0, 0, 30, 3, 0, 1); // valid for 2006
146  // In 2007 firmware, there are no distrips, so the 4th argument (strip
147  // type) should always be set to 1 (halfstrips).
148  CSCCLCTDigi clct0(1, 1, 4, 1, 0, 30, 4, 2, 1); // valid for 2007
149  CSCCLCTDigi clct1(1, 1, 2, 1, 1, 31, 1, 2, 2);
150 
151  // BX of LCT (8th argument) is 1-bit word (the least-significant bit
152  // of ALCT's bx).
153  CSCCorrelatedLCTDigi lct0(1, 1, 2, 10, 98, 5, 0, 1, 0, 0, 0, 0);
154  CSCCorrelatedLCTDigi lct1(2, 1, 2, 20, 15, 9, 1, 0, 0, 0, 0, 0);
155 
156  CSCTMBHeader tmbHeader(2007, 0x50c3);
157  tmbHeader.addCLCT0(clct0);
158  tmbHeader.addCLCT1(clct1);
159  tmbHeader.addCorrelatedLCT0(lct0);
160  tmbHeader.addCorrelatedLCT1(lct1);
161  std::vector<CSCCLCTDigi> clcts = tmbHeader.CLCTDigis(detId.rawId());
162  // guess they got reordered
163  assert(cscPackerCompare(clcts[0],clct0));
164  assert(cscPackerCompare(clcts[1],clct1));
165  if (debug) {
166  std::cout << "Match for: " << clct0 << "\n";
167  std::cout << " " << clct1 << "\n \n";
168  }
169 
170  std::vector<CSCCorrelatedLCTDigi> lcts = tmbHeader.CorrelatedLCTDigis(detId.rawId());
171  assert(cscPackerCompare(lcts[0], lct0));
172  assert(cscPackerCompare(lcts[1], lct1));
173  if (debug) {
174  std::cout << "Match for: " << lct0 << "\n";
175  std::cout << " " << lct1 << "\n";
176  }
177 
178  // try packing and re-packing, to make sure they're the same
179  unsigned short int * data = tmbHeader.data();
180  CSCTMBHeader newHeader(data);
181  clcts = newHeader.CLCTDigis(detId.rawId());
182  assert(cscPackerCompare(clcts[0],clct0));
183  assert(cscPackerCompare(clcts[1],clct1));
184  lcts = newHeader.CorrelatedLCTDigis(detId.rawId());
185  assert(cscPackerCompare(lcts[0], lct0));
186  assert(cscPackerCompare(lcts[1], lct1));
187 
188 
189  }
190  }
191 }
static bool debug
Definition: CSCTMBHeader.h:139
unsigned short * data()
Definition: CSCTMBHeader.h:99
bool cscPackerCompare(const T &t1, const T &t2)
tuple cout
Definition: gather_cfg.py:121
static void CSCTMBHeader::setDebug ( const bool  value)
inlinestatic

turns on/off debug flag for this class

Definition at line 104 of file CSCTMBHeader.h.

References debug, and relativeConstraints::value.

Referenced by CSCDCCUnpacker::CSCDCCUnpacker().

104 {debug = value;}
static bool debug
Definition: CSCTMBHeader.h:139
void CSCTMBHeader::setEventInformation ( const CSCDMBHeader dmbHeader)
inline

fills fields like bxn and l1a

Definition at line 28 of file CSCTMBHeader.h.

References theHeaderFormat.

Referenced by CSCEventData::checkTMBClasses(), and CSCEventData::setEventInformation().

29  {
30  theHeaderFormat->setEventInformation(dmbHeader);
31  }
boost::shared_ptr< CSCVTMBHeaderFormat > theHeaderFormat
Definition: CSCTMBHeader.h:141
uint16_t CSCTMBHeader::sizeInBytes ( ) const
inline

Definition at line 63 of file CSCTMBHeader.h.

References theHeaderFormat.

63  {
64  return theHeaderFormat->sizeInWords()*2;
65  }
boost::shared_ptr< CSCVTMBHeaderFormat > theHeaderFormat
Definition: CSCTMBHeader.h:141
unsigned short int CSCTMBHeader::sizeInWords ( ) const
inline

in 16-bit words. Add olne because we include beginning(b0c) and end (e0c) flags

Definition at line 93 of file CSCTMBHeader.h.

References theHeaderFormat.

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

93 {return theHeaderFormat->sizeInWords();}
boost::shared_ptr< CSCVTMBHeaderFormat > theHeaderFormat
Definition: CSCTMBHeader.h:141
CSCTMBHeader2006 CSCTMBHeader::tmbHeader2006 ( ) const

Definition at line 124 of file CSCTMBHeader.cc.

References edm::hlt::Exception, query::result, and theHeaderFormat.

124  {
125  CSCTMBHeader2006 * result = dynamic_cast<CSCTMBHeader2006 *>(theHeaderFormat.get());
126  if(result == 0)
127  {
128  throw cms::Exception("Could not get 2006 TMB header format");
129  }
130  return *result;
131 }
boost::shared_ptr< CSCVTMBHeaderFormat > theHeaderFormat
Definition: CSCTMBHeader.h:141
tuple result
Definition: query.py:137
CSCTMBHeader2007 CSCTMBHeader::tmbHeader2007 ( ) const

will throw if the cast fails

Definition at line 114 of file CSCTMBHeader.cc.

References edm::hlt::Exception, query::result, and theHeaderFormat.

114  {
115  CSCTMBHeader2007 * result = dynamic_cast<CSCTMBHeader2007 *>(theHeaderFormat.get());
116  if(result == 0)
117  {
118  throw cms::Exception("Could not get 2007 TMB header format");
119  }
120  return *result;
121 }
boost::shared_ptr< CSCVTMBHeaderFormat > theHeaderFormat
Definition: CSCTMBHeader.h:141
tuple result
Definition: query.py:137
uint16_t CSCTMBHeader::TMBMatch ( ) const
inline

Definition at line 48 of file CSCTMBHeader.h.

References theHeaderFormat.

Referenced by cscdqm::EventProcessor::processCSC().

48  {
49  return theHeaderFormat->TMBMatch();
50  }
boost::shared_ptr< CSCVTMBHeaderFormat > theHeaderFormat
Definition: CSCTMBHeader.h:141

Friends And Related Function Documentation

std::ostream& operator<< ( std::ostream &  os,
const CSCTMBHeader hdr 
)
friend

Definition at line 194 of file CSCTMBHeader.cc.

194  {
195  hdr.theHeaderFormat->print(os);
196  return os;
197 }
boost::shared_ptr< CSCVTMBHeaderFormat > theHeaderFormat
Definition: CSCTMBHeader.h:141

Member Data Documentation

bool CSCTMBHeader::debug = false
staticprivate
int CSCTMBHeader::theFirmwareVersion
private

Definition at line 142 of file CSCTMBHeader.h.

Referenced by CSCTMBHeader(), and FirmwareVersion().

boost::shared_ptr<CSCVTMBHeaderFormat> CSCTMBHeader::theHeaderFormat
private