File indexing completed on 2023-03-17 10:59:19
0001 #ifndef EventFilter_CSCRawToDigi_CSCCFEBTimeSlice_h
0002 #define EventFilter_CSCRawToDigi_CSCCFEBTimeSlice_h
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020 struct CSCCFEBDataWord {
0021 unsigned short adcCounts : 12;
0022 unsigned short adcOverflow : 1;
0023
0024 unsigned short controllerData : 1;
0025
0026
0027 unsigned short overlappedSampleFlag : 1;
0028
0029
0030 unsigned short errorstat : 1;
0031 };
0032
0033 #include <iostream>
0034 #include <cstring> //for bzero
0035
0036 struct CSCCFEBSCAControllerWord {
0037
0038
0039
0040
0041 explicit CSCCFEBSCAControllerWord(unsigned short frame);
0042 CSCCFEBSCAControllerWord() { bzero(this, 2); }
0043
0044 unsigned short trig_time : 8;
0045 unsigned short sca_blk : 4;
0046 unsigned short l1a_phase : 1;
0047 unsigned short lct_phase : 1;
0048 unsigned short sca_full : 1;
0049 unsigned short ts_flag : 1;
0050 };
0051
0052 class CSCCFEBTimeSlice {
0053 public:
0054 CSCCFEBTimeSlice();
0055
0056
0057 CSCCFEBDataWord *timeSample(int index) const { return (CSCCFEBDataWord *)(theSamples + index); }
0058
0059
0060
0061
0062
0063
0064 CSCCFEBDataWord *timeSample(int layer, int channel, bool isDCFEB = false) const;
0065
0066
0067 bool sixteenSamples() const {
0068 return timeSample(95)->controllerData;
0069 }
0070 unsigned sizeInWords() const { return 100; }
0071
0072
0073 CSCCFEBSCAControllerWord scaControllerWord(int layer) const;
0074
0075 void setControllerWord(const CSCCFEBSCAControllerWord &controllerWord);
0076
0077
0078
0079 bool check() const { return ((dummy == 0x7FFF) || ((dummy + crc) == 0x7FFF)); }
0080
0081 bool checkCRC() const { return crc == calcCRC(); }
0082
0083 unsigned calcCRC() const;
0084
0085
0086 void setCRC() {
0087 crc = calcCRC();
0088 dummy = 0x7FFF - crc;
0089 }
0090
0091 friend std::ostream &operator<<(std::ostream &os, const CSCCFEBTimeSlice &);
0092
0093
0094 unsigned get_crc() const { return crc; }
0095 unsigned get_n_free_sca_blocks() const { return n_free_sca_blocks; }
0096 unsigned get_lctpipe_count() const { return lctpipe_count; }
0097 unsigned get_lctpipe_full() const { return lctpipe_full; }
0098 unsigned get_l1pipe_full() const { return l1pipe_full; }
0099 unsigned get_lctpipe_empty() const { return lctpipe_empty; }
0100 unsigned get_l1pipe_empty() const { return l1pipe_empty; }
0101 unsigned get_buffer_warning() const { return buffer_warning; }
0102 unsigned get_buffer_count() const { return buffer_count; }
0103 unsigned get_L1A_number() const { return L1A_number; }
0104
0105 void set_L1Anumber(unsigned l1a) { L1A_number = l1a & 0x3F; }
0106
0107 private:
0108 unsigned short theSamples[96];
0109
0110
0111 unsigned crc : 16;
0112
0113
0114 unsigned n_free_sca_blocks : 4;
0115 unsigned lctpipe_count : 4;
0116 unsigned lctpipe_full : 1;
0117 unsigned l1pipe_full : 1;
0118 unsigned lctpipe_empty : 1;
0119 unsigned l1pipe_empty : 1;
0120 unsigned blank_space_1 : 4;
0121
0122
0123 unsigned buffer_warning : 1;
0124 unsigned buffer_count : 5;
0125 unsigned L1A_number : 6;
0126 unsigned blank_space_3 : 4;
0127
0128
0129 unsigned dummy : 16;
0130 };
0131
0132 #endif