Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
oncsSub_idtpcfeev3.h
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file oncsSub_idtpcfeev3.h
1 #ifndef __ONCSSUB_IDTPCFEEV3_H__
2 #define __ONCSSUB_IDTPCFEEV3_H__
3 
4 #include "oncsSubevent.h"
5 #include <vector>
6 #include <set>
7 #include <algorithm>
8 #include <functional>
9 
10 #ifndef __CINT__
12 #else
13 class oncsSub_idtpcfeev3 : public oncsSubevent_w2 {
14 #endif
15 
16 public:
19 
21  int iValue(const int ch, const int sample);
22  int iValue(const int ,const char * what);
23 
25  long long lValue(const int channel, const char *what) ;
26 
27  void dump ( OSTREAM& os = COUT) ;
28 
29 
30 protected:
31  int tpc_decode ();
32 
33  static const unsigned short MAGIC_KEY_0 = 0xfe;
34  static const unsigned short MAGIC_KEY_1 = 0x00;
35 
36  static const unsigned short FEE_MAGIC_KEY = 0xba00;
37  static const unsigned short GTM_MAGIC_KEY = 0xbb00;
38  static const unsigned short GTM_LVL1_ACCEPT_MAGIC_KEY = 0xbbf0;
39  static const unsigned short GTM_ENDAT_MAGIC_KEY = 0xbbf1;
40 
41  static const unsigned short MAX_FEECOUNT = 26; // that many FEEs
42  static const unsigned short MAX_CHANNELS = 8*32; // that many channels per FEE
43  static const unsigned short HEADER_LENGTH = 7;
44 
45  unsigned short reverseBits(const unsigned short x) const;
46  unsigned short crc16(const unsigned int fee, const unsigned int index, const int l) const;
47 
48  // int find_header ( std::vector<unsigned short>::const_iterator &itr, const std::vector<unsigned short> &orig);
49  int find_header ( const unsigned int xx, const std::vector<unsigned short> &orig);
50  int decode_gtm_data(unsigned short gtm[16]);
51 
52  int _broken;
53 
55 
56  struct sampa_waveform {
57  unsigned short fee;
58  unsigned short pkt_length;
59  unsigned short channel;
60  unsigned short sampa_channel;
61  unsigned short sampa_address;
62  unsigned int bx_timestamp;
63  std::vector<unsigned short> waveform;
64  unsigned short adc_length;
65  unsigned short checksum;
66  bool valid;
67  };
68 
69  struct gtm_payload {
70  unsigned short pkt_type;
71  bool is_endat;
72  bool is_lvl1;
73  unsigned long long bco;
74  unsigned int lvl1_count;
75  unsigned int endat_count;
76  unsigned long long last_bco;
77  unsigned char modebits;
78  };
79 
80  // once vector per possible channel 16 cards * 256 channels
81  //std::vector<sampa_waveform *> waveform_vector[MAX_FEECOUNT * MAX_CHANNELS];
82 
83  // our sort functional
84 
85 struct bco_compare {
86  bool operator() (const sampa_waveform *lhs, const sampa_waveform *rhs) const
87  {
88  return ( lhs->bx_timestamp <= rhs->bx_timestamp );
89  }
90 };
91 
92 
93 
94  typedef std::multiset< sampa_waveform* , bco_compare> waveform_set;
95  //typedef waveform_set::iterator wf_iter;
96 
98  // waveform_set waveforms[MAX_FEECOUNT * MAX_CHANNELS];
99 
100  std::vector<sampa_waveform*> waveform_vector;
101 
102  int cacheIterator(const int n);
103 
106 
107  std::vector<unsigned short> fee_data[MAX_FEECOUNT];
108 
109  std::vector<gtm_payload *> gtm_data;
110 
111 };
112 
113 
114 #endif /* __ONCSSUB_IDTPCFEEV3_H__ */