GRUTinizer
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
TRawBanks.h
Go to the documentation of this file.
1 #ifndef TRAWBANKS__H
2 #define TRAWBANKS__H
3 
4 //#include <cstdio>
5 //#include <iostream>
6 //#include <iomanip>
7 
8 //#include <stdint.h>
9 #include <Rtypes.h>
10 
11 // https:://gswg.lbl.gov/tiki-index.php?page=GEB+Headers
12 
13 #define MAX_INTPTS 16
14 #define MAX_PWID 256
15 #define MAX_LABRID 16
16 #define MQDC_ID 10
17 #define MTDC_ID 20
18 
19 // General Mesytec Stuff:
20 struct Mesy_Word{
21  // This is 2x16 bits = 32 bits. The MQDC talks in 32 bit words.
22  UShort_t tail;
23  UShort_t nose;
24 
25  bool isHeader() const { return((nose&0xff00)==0x4000); }
26  bool isData() const { return((nose&0xffc0)==0x0400); } // for QDC 0x0020 should also be 0. Left out for easy use.
27  bool isETS() const { return((nose&0xffff)==0x0480); }
28  bool isFILL() const { return(((nose&0xffff)==0) && ((tail&0xffff)==0)); }
29  bool isALLF() const { return(((nose&0xffff)==0xffff) && ((tail&0xffff)==0xffff)); }
30  bool isEOE() const { return(((nose&0xc000)==0xc000) && !(isALLF())); }
31 }__attribute__((__packed__));
32 
33 struct Mesy_Header{
34  UShort_t tail;
35  UShort_t nose;
36 
37  UShort_t format() const { return ((tail&0x8000)>>15); }
38  UShort_t size() const { return tail&0x0fff; }
39  UShort_t id() const { return nose&0x00ff; }
40  UShort_t res() const { return (tail&0x7000)>>12; }
41  bool isQDC() const { return(id()==MQDC_ID); }
42  bool isTDC() const { return(id()==MTDC_ID); }
43 }__attribute__((__packed__));
44 
45 struct Mesy_ETS{
46  UShort_t tail;
47  UShort_t nose;
48 
49  UShort_t ETS() const { return tail&0xffff; }
50 }__attribute__((__packed__));
51 
52 struct Mesy_FILL{
53  UShort_t tail;
54  UShort_t nose;
55 }__attribute__((__packed__));
56 
57 struct Mesy_EOE{
58  UInt_t data;
59 
60  Int_t TS() const { return data&0x3fffffff; }
61 }__attribute__((__packed__));
62 
63 // Mesytec QDC:
64 struct M_QDC_Data{
65  UShort_t tail;
66  UShort_t nose;
67 
68  UShort_t Chan() const { return nose&0x001f; }
69  UShort_t Charge() const { return tail&0x0fff; }
70  UShort_t isOOR() const { return (tail&0x4000)>>14; }
71 }__attribute__((__packed__));
72 
73 // Mesytec TDC:
74 struct M_TDC_Data{
75  UShort_t tail;
76  UShort_t nose;
77 
78  bool isTrig() const { return((nose&0x0020)>>5); }
79  UShort_t Chan() const { return nose&0x001f; }
80  UShort_t Time() const { return tail&0xffff; }
81 }__attribute__((__packed__));
82 
83 
84 
85 
86 
87 
88 
89 
90 
91 
92 
93 
94 
95 
96 
97 
98 
99 typedef struct { // HPGe Segment Hit Type 1;
100  Float_t x;
101  Float_t y;
102  Float_t z;
103  Float_t e; //fraction of the energy
104  Int_t seg;
105  Float_t seg_ener; //energy (cahrge) collected in the segment
106 }__attribute__((__packed__)) GEBInteractionPoint;
107 
108 friend std::ostream& operator<<(std::ostream& os, const GEBInteractionPoint &fSeg);
109 
110 typedef struct { // Decomposed GRETINA Data
111  Int_t type;
112  Int_t crystal_id;
113  Int_t num;
114  Float_t tot_e;
115  Int_t core_e[4];
116  Long_t timestamp;
117  Long_t trig_time;
118  Float_t t0;
119  Float_t cfd;
120  Float_t chisq;
121  Float_t norm_chisq;
122  Float_t baseline;
123  Float_t prestep;
124  Float_t poststep;
125  Int_t pad;
126  GEBInteractionPoint intpts[MAX_INTPTS];
127 }__attribute__((__packed__)) GEBBankType1;
128 
129 friend std::ostream& operator<<(std::ostream& os, const GEBBankType1 &bank);
130 
131 static UShort_t SwapShort(UShort_t datum);
132 
133 struct GEBMode3Head {
134  UShort_t a2;
135  UShort_t a1;
136  UShort_t lengthGA;
137  UShort_t board_id;
138  Int_t GetLength() const;
139  Int_t GetChannel() const;
140  Int_t GetVME() const;
141  Int_t GetCrystal() const;
142  Int_t GetHole() const;
143  Int_t GetSegmentId() const;
144  Int_t GetCrystalId() const;
145 }__attribute__((__packed__));
147 friend std::ostream& operator<<(std::ostream& os, const GEBMode3Head &head);
148 static void SwapMode3Head(GEBMode3Head &head);
150 //typedef struct {
151 struct GEBMode3Data {
152  UShort_t led_middle;
153  UShort_t led_low;
154  UShort_t energy_low;
155  UShort_t led_high;
156  UShort_t cfd_low;
157  UShort_t energy_high;
158  UShort_t cfd_high;
159  UShort_t cfd_middle;
160  UShort_t cfd_pt1_high;
161  UShort_t cfd_pt1_low;
162  UShort_t cfd_pt2_high;
163  UShort_t cfd_pt2_low;
164  Long_t GetLed() const;
165  Long_t GetCfd() const;
166  Int_t GetEnergy(GEBMode3Head&) const;
167 }__attribute__((__packed__));
169 friend std::ostream& operator<<(std::ostream& os, const GEBMode3Data &data);
170 static void SwapMode3Data(GEBMode3Data &data);
173  Int_t total_size;
174  UShort_t total_size2;
175  UShort_t S800_packet;
177  UShort_t S800_version;
179  ULong_t S800_timestamp;
185  Long_t GetEventNumber() const {
186  long temp = (long)S800_eventnumber_low;
187  temp += ((long)S800_eventnumber_middle) << 16;
188  temp += ((long)S800_eventnumber_high) << 32;
189  return temp;
190  }
191 
192 } __attribute__((__packed__));
194 friend std::ostream& operator<<(std::ostream& os, const GEBS800Header &head);
196 static Int_t GetS800Channel(UShort_t input) { return (input>>12); }
197 static Int_t GetS800Value(UShort_t input) { return (input&0x0fff); }
201  UShort_t trgger_pattern;
202  UShort_t channel_time[4];
204 } __attribute__((__packed__));
206 friend std::ostream& operator<<(std::ostream& os, const S800TriggerPacket &pack);
209  UShort_t value[4];
210  UShort_t number;
211 } __attribute__((__packed__));
213 friend std::ostream& operator<<(std::ostream& os, const S800TOFPacket &tof);
214 
216  UShort_t value[2][4];
217  UShort_t number;
218 } __attribute__((__packed__));
219 
220 // https://wikihost.nscl.msu.edu/S800Doc/doku.php?id=s800_version_0x0006
221 
223  UShort_t number;
224  UShort_t subid;
225  UShort_t value[16];
226 } __attribute__((__packed__));
227 
229  UShort_t id;
230  UShort_t number;
231  UShort_t subid;
233 } __attribute__((__packed__));
235 typedef struct {
236  Short_t pix_id; //int16_t
237  Short_t data_a; //int16_t
238  Short_t data_b; //int16_t
239  Short_t data_c; //int16_t
240  Short_t time; //int16_t
241 }__attribute__((__packed__)) PWHit;
242 
243 friend std::ostream& operator<<(std::ostream& os,const PWHit &hit);
244 
245 typedef struct{
246  PWHit hit[MAX_PWID];
247  Short_t nhits; //int16_t -> not actually part of the bank recorded to file.
248 }__attribute__((__packed__)) PWBank;
249 
250 friend std::ostream& operator<<(std::ostream& os,const PWBank &bank);
251 
252 typedef struct {
253  Short_t chan_id; //int16_t
254  Short_t value; //int16_t
255 }__attribute__((__packed__)) LaBrSeg;
256 
257 friend std::ostream& operator<<(std::ostream& os,const LaBrSeg &hit);
258 
259 typedef struct {
260  Short_t nenghits;
261  Short_t ntimhits;
262  LaBrSeg energy_hit[MAX_LABRID];
263  LaBrSeg time_hit[MAX_LABRID];
264 }__attribute__((__packed__)) LaBrBank;
265 
266 friend std::ostream& operator<<(std::ostream& os,const LaBrBank &bank);
267 
268 typedef struct RawHeader {
269  Int_t datum1;
270  Int_t datum2;
271 } __attribute__((__packed__)) RawHeader;
274 
275 typedef struct GEBHeader : public RawHeader {
276  Int_t type() { return datum1; } //Int_t type; //int32_t
277  Int_t size() { return datum2; } //int32_t
278  ClassDef(GEBHeader, 0);
279 } __attribute__((__packed__)) GEBHeader;
281 
282 typedef struct EVTHeader : public RawHeader {
283  Int_t size() { return datum1; } //Int_t size; //int32_t
284  Int_t type() { return datum2; } //Int_t type; //int32_t
285  ClassDef(EVTHeader, 0);
286 } __attribute__((__packed__)) EVTHeader;
287 
288 friend std::ostream& operator<<(std::ostream& os, const RawHeader &head);
289 
290 typedef struct TNSCLFragmentHeader {
291  long timestamp;
292  int sourceid;
294  int barrier;
295 } __attribute__((__packed__)) TNSCLFragmentHeader;
297 friend std::ostream& operator<<(std::ostream& os, const TNSCLFragmentHeader &head);
299 #endif