CMS 3D CMS Logo

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>
8 #include <memory>
15 
16 #ifndef LOCAL_UNPACK
17 #include <atomic>
18 #endif
19 class CSCDMBHeader;
20 struct CSCTMBHeader2006;
21 struct CSCTMBHeader2007;
23 struct CSCTMBHeader2013;
24 
25 class CSCTMBHeader {
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) { theHeaderFormat->setEventInformation(dmbHeader); }
33 
34  int FirmwareVersion() const { return theFirmwareVersion; }
35  int FirmwareRevision() const { return theHeaderFormat->firmwareRevision(); }
36 
37  uint16_t BXNCount() const { return theHeaderFormat->BXNCount(); }
38  uint16_t ALCTMatchTime() const { return theHeaderFormat->ALCTMatchTime(); }
39  uint16_t CLCTOnly() const { return theHeaderFormat->CLCTOnly(); }
40  uint16_t ALCTOnly() const { return theHeaderFormat->ALCTOnly(); }
41  uint16_t TMBMatch() const { return theHeaderFormat->TMBMatch(); }
42 
43  uint16_t Bxn0Diff() const { return theHeaderFormat->Bxn0Diff(); }
44  uint16_t Bxn1Diff() const { return theHeaderFormat->Bxn1Diff(); }
45 
46  uint16_t L1ANumber() const { return theHeaderFormat->L1ANumber(); }
47 
48  uint16_t sizeInBytes() const { return theHeaderFormat->sizeInWords() * 2; }
49 
55 
56  uint16_t NTBins() const { return theHeaderFormat->NTBins(); }
57  uint16_t NCFEBs() const { return theHeaderFormat->NCFEBs(); }
58 
59  uint16_t syncError() const { return theHeaderFormat->syncError(); }
60  uint16_t syncErrorCLCT() const { return theHeaderFormat->syncErrorCLCT(); }
61  uint16_t syncErrorMPC0() const { return theHeaderFormat->syncErrorMPC0(); }
62  uint16_t syncErrorMPC1() const { return theHeaderFormat->syncErrorMPC1(); }
63 
64  void setNCFEBs(uint16_t ncfebs) { theHeaderFormat->setNCFEBs(ncfebs); }
65 
67  std::vector<CSCCLCTDigi> CLCTDigis(uint32_t idlayer) { return theHeaderFormat->CLCTDigis(idlayer); }
68 
70  std::vector<CSCCorrelatedLCTDigi> CorrelatedLCTDigis(uint32_t idlayer) const {
71  return theHeaderFormat->CorrelatedLCTDigis(idlayer);
72  }
73 
76  unsigned short int sizeInWords() const { return theHeaderFormat->sizeInWords(); }
77 
78  unsigned short int NHeaderFrames() const { return theHeaderFormat->NHeaderFrames(); }
79 
80  unsigned short* data() { return theHeaderFormat->data(); }
81 
83  static void setDebug(const bool value) { debug = value; }
84 
85  bool check() const { return theHeaderFormat->check(); }
86 
88  //void setChamberId(const CSCDetId & detId) {theChamberId = detId;}
89 
91  void addCLCT0(const CSCCLCTDigi& digi) { theHeaderFormat->addCLCT0(digi); }
92  void addCLCT1(const CSCCLCTDigi& digi) { theHeaderFormat->addCLCT1(digi); }
93  void addALCT0(const CSCALCTDigi& digi) { theHeaderFormat->addALCT0(digi); }
94  void addALCT1(const CSCALCTDigi& digi) { theHeaderFormat->addALCT1(digi); }
95  void addCorrelatedLCT0(const CSCCorrelatedLCTDigi& digi) { theHeaderFormat->addCorrelatedLCT0(digi); }
96  void addCorrelatedLCT1(const CSCCorrelatedLCTDigi& digi) { theHeaderFormat->addCorrelatedLCT1(digi); }
97 
99  void add(const std::vector<CSCCLCTDigi>& digis);
100  void add(const std::vector<CSCCorrelatedLCTDigi>& digis);
101 
103  static void selfTest();
104 
105  friend std::ostream& operator<<(std::ostream& os, const CSCTMBHeader& hdr);
106 
107 private:
108  //void swapCLCTs(CSCCLCTDigi& digi1, CSCCLCTDigi& digi2);
109 
110 #ifdef LOCAL_UNPACK
111  static bool debug;
112 #else
113  static std::atomic<bool> debug;
114 #endif
115 
116  std::shared_ptr<CSCVTMBHeaderFormat> theHeaderFormat;
118 };
119 
120 #endif
uint16_t BXNCount() const
Definition: CSCTMBHeader.h:37
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:56
int FirmwareRevision() const
Definition: CSCTMBHeader.h:35
unsigned short int NHeaderFrames() const
Definition: CSCTMBHeader.h:78
int theFirmwareVersion
Definition: CSCTMBHeader.h:117
uint16_t syncErrorCLCT() const
Definition: CSCTMBHeader.h:60
uint16_t CLCTOnly() const
Definition: CSCTMBHeader.h:39
uint16_t L1ANumber() const
Definition: CSCTMBHeader.h:46
uint16_t syncErrorMPC0() const
Definition: CSCTMBHeader.h:61
std::vector< CSCCorrelatedLCTDigi > CorrelatedLCTDigis(uint32_t idlayer) const
returns CorrelatedLCT digis
Definition: CSCTMBHeader.h:70
std::shared_ptr< CSCVTMBHeaderFormat > theHeaderFormat
Definition: CSCTMBHeader.h:116
uint16_t Bxn1Diff() const
Definition: CSCTMBHeader.h:44
void addCorrelatedLCT0(const CSCCorrelatedLCTDigi &digi)
Definition: CSCTMBHeader.h:95
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:96
uint16_t NCFEBs() const
Definition: CSCTMBHeader.h:57
void addCLCT1(const CSCCLCTDigi &digi)
Definition: CSCTMBHeader.h:92
void setNCFEBs(uint16_t ncfebs)
Definition: CSCTMBHeader.h:64
uint16_t syncErrorMPC1() const
Definition: CSCTMBHeader.h:62
static void setDebug(const bool value)
Definition: CSCTMBHeader.h:83
static void selfTest()
tests that packing and unpacking give same results
uint16_t syncError() const
Definition: CSCTMBHeader.h:59
unsigned short * data()
Definition: CSCTMBHeader.h:80
uint16_t ALCTOnly() const
Definition: CSCTMBHeader.h:40
uint16_t Bxn0Diff() const
Definition: CSCTMBHeader.h:43
static std::atomic< bool > debug
Definition: CSCTMBHeader.h:113
friend std::ostream & operator<<(std::ostream &os, const CSCTMBHeader &hdr)
Definition: value.py:1
uint16_t ALCTMatchTime() const
Definition: CSCTMBHeader.h:38
unsigned short int sizeInWords() const
Definition: CSCTMBHeader.h:76
uint16_t sizeInBytes() const
Definition: CSCTMBHeader.h:48
std::vector< CSCCLCTDigi > CLCTDigis(uint32_t idlayer)
returns CLCT digis
Definition: CSCTMBHeader.h:67
CSCTMBHeader2006 tmbHeader2006() const
CSCTMBHeader2007_rev0x50c3 tmbHeader2007_rev0x50c3() const
void addCLCT0(const CSCCLCTDigi &digi)
Needed before data packing.
Definition: CSCTMBHeader.h:91
bool check() const
Definition: CSCTMBHeader.h:85
uint16_t TMBMatch() const
Definition: CSCTMBHeader.h:41
int FirmwareVersion() const
Definition: CSCTMBHeader.h:34
void addALCT1(const CSCALCTDigi &digi)
Definition: CSCTMBHeader.h:94
CSCTMBHeader(int firmwareVersion, int firmwareRevision)
Definition: CSCTMBHeader.cc:20
CSCTMBHeader2013 tmbHeader2013() const
void addALCT0(const CSCALCTDigi &digi)
Definition: CSCTMBHeader.h:93