test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
CSCTMBHeader.h
Go to the documentation of this file.
1 #ifndef CSCTMBHeader_h
2 #define CSCTMBHeader_h
3 
5 
6 #include <iosfwd>
7 #include <vector>
14 #include <boost/shared_ptr.hpp>
15 #ifndef LOCAL_UNPACK
16 #include <atomic>
17 #endif
18 class CSCDMBHeader;
19 struct CSCTMBHeader2006;
20 struct CSCTMBHeader2007;
22 struct CSCTMBHeader2013;
23 
24 
25 class CSCTMBHeader {
26 
27  public:
28  CSCTMBHeader(int firmwareVersion, int firmwareRevision);
29  CSCTMBHeader(const CSCTMBStatusDigi & digi);
30  CSCTMBHeader(const unsigned short * buf);
31 
33  void setEventInformation(const CSCDMBHeader & dmbHeader)
34  {
35  theHeaderFormat->setEventInformation(dmbHeader);
36  }
37 
38  int FirmwareVersion() const {return theFirmwareVersion;}
39  int FirmwareRevision() const {return theHeaderFormat->firmwareRevision();}
40 
41 
42  uint16_t BXNCount() const {
43  return theHeaderFormat->BXNCount();
44  }
45  uint16_t ALCTMatchTime() const {
46  return theHeaderFormat->ALCTMatchTime();
47  }
48  uint16_t CLCTOnly() const {
49  return theHeaderFormat->CLCTOnly();
50  }
51  uint16_t ALCTOnly() const {
52  return theHeaderFormat->ALCTOnly();
53  }
54  uint16_t TMBMatch() const {
55  return theHeaderFormat->TMBMatch();
56  }
57 
58  uint16_t Bxn0Diff() const {
59  return theHeaderFormat->Bxn0Diff();
60  }
61  uint16_t Bxn1Diff() const {
62  return theHeaderFormat->Bxn1Diff();
63  }
64 
65  uint16_t L1ANumber() const {
66  return theHeaderFormat->L1ANumber();
67  }
68 
69  uint16_t sizeInBytes() const {
70  return theHeaderFormat->sizeInWords()*2;
71  }
72 
78 
79  uint16_t NTBins() const {
80  return theHeaderFormat->NTBins();
81  }
82  uint16_t NCFEBs() const {
83  return theHeaderFormat->NCFEBs();
84  }
85 
86  uint16_t syncError() const { return theHeaderFormat->syncError();}
87  uint16_t syncErrorCLCT() const { return theHeaderFormat->syncErrorCLCT();}
88  uint16_t syncErrorMPC0() const { return theHeaderFormat->syncErrorMPC0();}
89  uint16_t syncErrorMPC1() const { return theHeaderFormat->syncErrorMPC1();}
90 
91 
92  void setNCFEBs(uint16_t ncfebs) {
93  theHeaderFormat->setNCFEBs(ncfebs);
94  }
95 
96 
98  std::vector<CSCCLCTDigi> CLCTDigis(uint32_t idlayer)
99  {
100  return theHeaderFormat->CLCTDigis(idlayer);
101  }
102 
104  std::vector<CSCCorrelatedLCTDigi> CorrelatedLCTDigis(uint32_t idlayer) const
105  {
106  return theHeaderFormat->CorrelatedLCTDigis(idlayer);
107  }
108 
111  unsigned short int sizeInWords() const {return theHeaderFormat->sizeInWords();}
112 
113  unsigned short int NHeaderFrames() const {
114  return theHeaderFormat->NHeaderFrames();
115  }
116 
117  unsigned short * data() {
118  return theHeaderFormat->data();
119  }
120 
122  static void setDebug(const bool value) {debug = value;}
123 
124  bool check() const {
125  return theHeaderFormat->check();
126  }
127 
129  //void setChamberId(const CSCDetId & detId) {theChamberId = detId;}
130 
132  void addCLCT0(const CSCCLCTDigi & digi) {theHeaderFormat->addCLCT0(digi);}
133  void addCLCT1(const CSCCLCTDigi & digi) {theHeaderFormat->addCLCT1(digi);}
134  void addALCT0(const CSCALCTDigi & digi) {theHeaderFormat->addALCT0(digi);}
135  void addALCT1(const CSCALCTDigi & digi) {theHeaderFormat->addALCT1(digi);}
137  theHeaderFormat->addCorrelatedLCT0(digi);
138  }
140  theHeaderFormat->addCorrelatedLCT1(digi);
141  }
142 
144  void add(const std::vector<CSCCLCTDigi> & digis);
145  void add(const std::vector<CSCCorrelatedLCTDigi> & digis);
146 
147 
149  static void selfTest();
150 
151  friend std::ostream & operator<<(std::ostream & os, const CSCTMBHeader & hdr);
152 
153 private:
154 
155  //void swapCLCTs(CSCCLCTDigi& digi1, CSCCLCTDigi& digi2);
156 
157 #ifdef LOCAL_UNPACK
158  static bool debug;
159 #else
160  static std::atomic<bool> debug;
161 #endif
162 
163  boost::shared_ptr<CSCVTMBHeaderFormat> theHeaderFormat;
165 
166 };
167 
168 #endif
169 
uint16_t BXNCount() const
Definition: CSCTMBHeader.h:42
void setEventInformation(const CSCDMBHeader &dmbHeader)
fills fields like bxn and l1a
Definition: CSCTMBHeader.h:33
CSCTMBHeader2007 tmbHeader2007() const
will throw if the cast fails
uint16_t NTBins() const
Definition: CSCTMBHeader.h:79
int FirmwareRevision() const
Definition: CSCTMBHeader.h:39
unsigned short int NHeaderFrames() const
Definition: CSCTMBHeader.h:113
int theFirmwareVersion
Definition: CSCTMBHeader.h:164
uint16_t syncErrorCLCT() const
Definition: CSCTMBHeader.h:87
uint16_t CLCTOnly() const
Definition: CSCTMBHeader.h:48
uint16_t L1ANumber() const
Definition: CSCTMBHeader.h:65
uint16_t syncErrorMPC0() const
Definition: CSCTMBHeader.h:88
std::vector< CSCCorrelatedLCTDigi > CorrelatedLCTDigis(uint32_t idlayer) const
returns CorrelatedLCT digis
Definition: CSCTMBHeader.h:104
uint16_t Bxn1Diff() const
Definition: CSCTMBHeader.h:61
void addCorrelatedLCT0(const CSCCorrelatedLCTDigi &digi)
Definition: CSCTMBHeader.h:136
void add(const std::vector< CSCCLCTDigi > &digis)
these methods need more brains to figure which one goes first
void addCorrelatedLCT1(const CSCCorrelatedLCTDigi &digi)
Definition: CSCTMBHeader.h:139
uint16_t NCFEBs() const
Definition: CSCTMBHeader.h:82
void addCLCT1(const CSCCLCTDigi &digi)
Definition: CSCTMBHeader.h:133
boost::shared_ptr< CSCVTMBHeaderFormat > theHeaderFormat
Definition: CSCTMBHeader.h:163
void setNCFEBs(uint16_t ncfebs)
Definition: CSCTMBHeader.h:92
uint16_t syncErrorMPC1() const
Definition: CSCTMBHeader.h:89
static void setDebug(const bool value)
Definition: CSCTMBHeader.h:122
static void selfTest()
tests that packing and unpacking give same results
uint16_t syncError() const
Definition: CSCTMBHeader.h:86
unsigned short * data()
Definition: CSCTMBHeader.h:117
uint16_t ALCTOnly() const
Definition: CSCTMBHeader.h:51
uint16_t Bxn0Diff() const
Definition: CSCTMBHeader.h:58
static std::atomic< bool > debug
Definition: CSCTMBHeader.h:160
friend std::ostream & operator<<(std::ostream &os, const CSCTMBHeader &hdr)
uint16_t ALCTMatchTime() const
Definition: CSCTMBHeader.h:45
unsigned short int sizeInWords() const
Definition: CSCTMBHeader.h:111
uint16_t sizeInBytes() const
Definition: CSCTMBHeader.h:69
std::vector< CSCCLCTDigi > CLCTDigis(uint32_t idlayer)
returns CLCT digis
Definition: CSCTMBHeader.h:98
CSCTMBHeader2006 tmbHeader2006() const
CSCTMBHeader2007_rev0x50c3 tmbHeader2007_rev0x50c3() const
void addCLCT0(const CSCCLCTDigi &digi)
Needed before data packing.
Definition: CSCTMBHeader.h:132
bool check() const
Definition: CSCTMBHeader.h:124
uint16_t TMBMatch() const
Definition: CSCTMBHeader.h:54
int FirmwareVersion() const
Definition: CSCTMBHeader.h:38
void addALCT1(const CSCALCTDigi &digi)
Definition: CSCTMBHeader.h:135
CSCTMBHeader(int firmwareVersion, int firmwareRevision)
Definition: CSCTMBHeader.cc:20
CSCTMBHeader2013 tmbHeader2013() const
void addALCT0(const CSCALCTDigi &digi)
Definition: CSCTMBHeader.h:134