File indexing completed on 2025-08-03 08:20:38
0001 #ifndef __ONCSSUB_IDTPCFEEV3_H__
0002 #define __ONCSSUB_IDTPCFEEV3_H__
0003
0004 #include "oncsSubevent.h"
0005 #include <vector>
0006 #include <set>
0007 #include <algorithm>
0008 #include <functional>
0009
0010 #ifndef __CINT__
0011 class WINDOWSEXPORT oncsSub_idtpcfeev3 : public oncsSubevent_w2 {
0012 #else
0013 class oncsSub_idtpcfeev3 : public oncsSubevent_w2 {
0014 #endif
0015
0016 public:
0017 oncsSub_idtpcfeev3( subevtdata_ptr);
0018 ~oncsSub_idtpcfeev3();
0019
0020
0021 int iValue(const int ch, const int sample);
0022 int iValue(const int ,const char * what);
0023
0024
0025 long long lValue(const int channel, const char *what) ;
0026
0027 void dump ( OSTREAM& os = COUT) ;
0028
0029
0030 protected:
0031 int tpc_decode ();
0032
0033 static const unsigned short MAGIC_KEY_0 = 0xfe;
0034 static const unsigned short MAGIC_KEY_1 = 0x00;
0035
0036 static const unsigned short FEE_MAGIC_KEY = 0xba00;
0037 static const unsigned short GTM_MAGIC_KEY = 0xbb00;
0038 static const unsigned short GTM_LVL1_ACCEPT_MAGIC_KEY = 0xbbf0;
0039 static const unsigned short GTM_ENDAT_MAGIC_KEY = 0xbbf1;
0040
0041 static const unsigned short MAX_FEECOUNT = 26;
0042 static const unsigned short MAX_CHANNELS = 8*32;
0043 static const unsigned short HEADER_LENGTH = 5;
0044
0045 unsigned short reverseBits(const unsigned short x) const;
0046 unsigned short crc16(const unsigned int fee, const unsigned int index, const int l) const;
0047
0048
0049 int find_header ( const unsigned int xx, const std::vector<unsigned short> &orig);
0050 int decode_gtm_data(unsigned short gtm[16]);
0051
0052 int _broken;
0053
0054 int _is_decoded;
0055
0056 struct sampa_waveform {
0057 unsigned short fee;
0058 unsigned short pkt_length;
0059 unsigned short channel;
0060 unsigned short sampa_channel;
0061 unsigned short sampa_address;
0062 unsigned int bx_timestamp;
0063 std::vector<unsigned short> waveform;
0064 unsigned short adc_length;
0065 unsigned short checksum;
0066 bool valid;
0067 };
0068
0069 struct gtm_payload {
0070 unsigned short pkt_type;
0071 bool is_endat;
0072 bool is_lvl1;
0073 unsigned long long bco;
0074 unsigned int lvl1_count;
0075 unsigned int endat_count;
0076 unsigned long long last_bco;
0077 unsigned char modebits;
0078 };
0079
0080
0081
0082
0083
0084
0085 struct bco_compare {
0086 bool operator() (const sampa_waveform *lhs, const sampa_waveform *rhs) const
0087 {
0088 return ( lhs->bx_timestamp <= rhs->bx_timestamp );
0089 }
0090 };
0091
0092
0093
0094 typedef std::multiset< sampa_waveform* , bco_compare> waveform_set;
0095
0096
0097 waveform_set waveforms;
0098
0099
0100 std::vector<sampa_waveform*> waveform_vector;
0101
0102 int cacheIterator(const int n);
0103
0104 int _last_requested_element;
0105 sampa_waveform* _last_requested_waveform;
0106
0107 std::vector<unsigned short> fee_data[MAX_FEECOUNT];
0108
0109 std::vector<gtm_payload *> gtm_data;
0110
0111 };
0112
0113
0114 #endif