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 class CSCTMBHeader2006;
20 class CSCTMBHeader2007;
21 class CSCTMBHeader2013;
22 
23 
24 class CSCTMBHeader {
25 
26  public:
27  CSCTMBHeader(int firmwareVersion, int firmwareRevision);
28  CSCTMBHeader(const CSCTMBStatusDigi & digi);
29  CSCTMBHeader(const unsigned short * buf);
30 
32  void setEventInformation(const CSCDMBHeader & dmbHeader)
33  {
34  theHeaderFormat->setEventInformation(dmbHeader);
35  }
36 
37  int FirmwareVersion() const {return theFirmwareVersion;}
38  int FirmwareRevision() const {return theHeaderFormat->firmwareRevision();}
39 
40 
41  uint16_t BXNCount() const {
42  return theHeaderFormat->BXNCount();
43  }
44  uint16_t ALCTMatchTime() const {
45  return theHeaderFormat->ALCTMatchTime();
46  }
47  uint16_t CLCTOnly() const {
48  return theHeaderFormat->CLCTOnly();
49  }
50  uint16_t ALCTOnly() const {
51  return theHeaderFormat->ALCTOnly();
52  }
53  uint16_t TMBMatch() const {
54  return theHeaderFormat->TMBMatch();
55  }
56 
57  uint16_t Bxn0Diff() const {
58  return theHeaderFormat->Bxn0Diff();
59  }
60  uint16_t Bxn1Diff() const {
61  return theHeaderFormat->Bxn1Diff();
62  }
63 
64  uint16_t L1ANumber() const {
65  return theHeaderFormat->L1ANumber();
66  }
67 
68  uint16_t sizeInBytes() const {
69  return theHeaderFormat->sizeInWords()*2;
70  }
71 
76 
77  uint16_t NTBins() const {
78  return theHeaderFormat->NTBins();
79  }
80  uint16_t NCFEBs() const {
81  return theHeaderFormat->NCFEBs();
82  }
83 
84  void setNCFEBs(uint16_t ncfebs) {
85  theHeaderFormat->setNCFEBs(ncfebs);
86  }
87 
88 
90  std::vector<CSCCLCTDigi> CLCTDigis(uint32_t idlayer)
91  {
92  return theHeaderFormat->CLCTDigis(idlayer);
93  }
94 
96  std::vector<CSCCorrelatedLCTDigi> CorrelatedLCTDigis(uint32_t idlayer) const
97  {
98  return theHeaderFormat->CorrelatedLCTDigis(idlayer);
99  }
100 
103  unsigned short int sizeInWords() const {return theHeaderFormat->sizeInWords();}
104 
105  unsigned short int NHeaderFrames() const {
106  return theHeaderFormat->NHeaderFrames();
107  }
108 
109  unsigned short * data() {
110  return theHeaderFormat->data();
111  }
112 
114  static void setDebug(const bool value) {debug = value;}
115 
116  bool check() const {
117  return theHeaderFormat->check();
118  }
119 
121  //void setChamberId(const CSCDetId & detId) {theChamberId = detId;}
122 
124  void addCLCT0(const CSCCLCTDigi & digi) {theHeaderFormat->addCLCT0(digi);}
125  void addCLCT1(const CSCCLCTDigi & digi) {theHeaderFormat->addCLCT1(digi);}
126  void addALCT0(const CSCALCTDigi & digi) {theHeaderFormat->addALCT0(digi);}
127  void addALCT1(const CSCALCTDigi & digi) {theHeaderFormat->addALCT1(digi);}
129  theHeaderFormat->addCorrelatedLCT0(digi);
130  }
132  theHeaderFormat->addCorrelatedLCT1(digi);
133  }
134 
136  void add(const std::vector<CSCCLCTDigi> & digis);
137  void add(const std::vector<CSCCorrelatedLCTDigi> & digis);
138 
139 
141  static void selfTest();
142 
143  friend std::ostream & operator<<(std::ostream & os, const CSCTMBHeader & hdr);
144 
145 private:
146 
147  //void swapCLCTs(CSCCLCTDigi& digi1, CSCCLCTDigi& digi2);
148 
149 #ifdef LOCAL_UNPACK
150  static bool debug;
151 #else
152  static std::atomic<bool> debug;
153 #endif
154 
155  boost::shared_ptr<CSCVTMBHeaderFormat> theHeaderFormat;
157 
158 };
159 
160 #endif
161 
uint16_t BXNCount() const
Definition: CSCTMBHeader.h:41
void setEventInformation(const CSCDMBHeader &dmbHeader)
fills fields like bxn and l1a
Definition: CSCTMBHeader.h:32
CSCTMBHeader2007 tmbHeader2007() const
will throw if the cast fails
uint16_t NTBins() const
Definition: CSCTMBHeader.h:77
int FirmwareRevision() const
Definition: CSCTMBHeader.h:38
unsigned short int NHeaderFrames() const
Definition: CSCTMBHeader.h:105
int theFirmwareVersion
Definition: CSCTMBHeader.h:156
uint16_t CLCTOnly() const
Definition: CSCTMBHeader.h:47
uint16_t L1ANumber() const
Definition: CSCTMBHeader.h:64
std::vector< CSCCorrelatedLCTDigi > CorrelatedLCTDigis(uint32_t idlayer) const
returns CorrelatedLCT digis
Definition: CSCTMBHeader.h:96
uint16_t Bxn1Diff() const
Definition: CSCTMBHeader.h:60
void addCorrelatedLCT0(const CSCCorrelatedLCTDigi &digi)
Definition: CSCTMBHeader.h:128
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:131
uint16_t NCFEBs() const
Definition: CSCTMBHeader.h:80
void addCLCT1(const CSCCLCTDigi &digi)
Definition: CSCTMBHeader.h:125
boost::shared_ptr< CSCVTMBHeaderFormat > theHeaderFormat
Definition: CSCTMBHeader.h:155
void setNCFEBs(uint16_t ncfebs)
Definition: CSCTMBHeader.h:84
static void setDebug(const bool value)
Definition: CSCTMBHeader.h:114
static void selfTest()
tests that packing and unpacking give same results
unsigned short * data()
Definition: CSCTMBHeader.h:109
uint16_t ALCTOnly() const
Definition: CSCTMBHeader.h:50
uint16_t Bxn0Diff() const
Definition: CSCTMBHeader.h:57
static std::atomic< bool > debug
Definition: CSCTMBHeader.h:152
friend std::ostream & operator<<(std::ostream &os, const CSCTMBHeader &hdr)
uint16_t ALCTMatchTime() const
Definition: CSCTMBHeader.h:44
unsigned short int sizeInWords() const
Definition: CSCTMBHeader.h:103
uint16_t sizeInBytes() const
Definition: CSCTMBHeader.h:68
std::vector< CSCCLCTDigi > CLCTDigis(uint32_t idlayer)
returns CLCT digis
Definition: CSCTMBHeader.h:90
CSCTMBHeader2006 tmbHeader2006() const
void addCLCT0(const CSCCLCTDigi &digi)
Needed before data packing.
Definition: CSCTMBHeader.h:124
bool check() const
Definition: CSCTMBHeader.h:116
uint16_t TMBMatch() const
Definition: CSCTMBHeader.h:53
int FirmwareVersion() const
Definition: CSCTMBHeader.h:37
void addALCT1(const CSCALCTDigi &digi)
Definition: CSCTMBHeader.h:127
CSCTMBHeader(int firmwareVersion, int firmwareRevision)
Definition: CSCTMBHeader.cc:20
CSCTMBHeader2013 tmbHeader2013() const
void addALCT0(const CSCALCTDigi &digi)
Definition: CSCTMBHeader.h:126