FACT++  1.0
FAD.h
Go to the documentation of this file.
1 #ifndef FACT_FAD_H
2 #define FACT_FAD_H
3 
4 //---------------------------------------------------------------
5 //
6 // FAD internal structures
7 //
8 //---------------------------------------------------------------
9 
10 #define NTemp 4
11 #define NDAC 8
12 
13 typedef struct {
14 
16  uint16_t package_length;
17  uint16_t version_no;
18  uint16_t PLLLCK;
19 
20  uint16_t trigger_crc;
21  uint16_t trigger_type;
22  uint32_t trigger_id;
23 
24  uint32_t fad_evt_counter;
25  uint32_t REFCLK_frequency;
26 
27  uint16_t board_id;
28  uint8_t zeroes;
32 
33  uint64_t DNA;
34 
35  uint32_t time;
36  uint32_t runnumber;
37 
38  int16_t drs_temperature[NTemp];
39 
40  uint16_t dac[NDAC];
41 
42 } __attribute__((__packed__)) PEVNT_HEADER;
43 
44 typedef struct {
45 uint16_t id;
46 uint16_t start_cell;
47 uint16_t roi;
48 uint16_t filling;
49  int16_t adc_data[];
50 } __attribute__((__packed__)) PCHANNEL;
51 
52 
53 typedef struct {
54 uint16_t package_crc;
56 } __attribute__((__packed__)) PEVNT_FOOTER;
57 
58 #define NBOARDS 40 // max. number of boards
59 #define NPIX 1440 // max. number of pixels
60 #define NTMARK 160 // max. number of timeMarker signals
61 
62 //---------------------------------------------------------------
63 //
64 // Data structures
65 //
66 //---------------------------------------------------------------
67 
68 typedef struct _EVENT {
69  uint16_t Roi ; // #slices per pixel (same for all pixels)
70  uint16_t RoiTM ; // #slices per pixel (same for all tmarks) [ 0 or Roi ]
71  uint32_t EventNum ; // EventNumber as from FADs
72  uint32_t TriggerNum ; // EventNumber as from FTM
73  uint16_t TriggerType ; // Trigger Type from FTM
74 
75  uint32_t NumBoards ; // number of active boards included
76 
77  uint32_t PCTime ; // epoch
78  uint32_t PCUsec ; // micro-seconds
79 
80  uint32_t BoardTime[NBOARDS];//
81 
82  int16_t StartPix[NPIX]; // First Channel per Pixel (Pixels sorted according Software ID) ; -1 if not filled
83 
84  int16_t StartTM[NTMARK]; // First Channel for TimeMark (sorted Hardware ID) ; -1 if not filled
85 
86  int16_t Adc_Data[]; // final length defined by malloc ....
87 
88 } __attribute__((__packed__)) EVENT ;
89 
90 //---------------------------------------------------------------
91 
92 struct RUN_HEAD
93 {
94  uint32_t Version ;
95  uint32_t RunType ;
96  uint32_t RunTime ; //unix epoch for first event
97  uint32_t RunUsec ; //microseconds
98  uint16_t NBoard ; //#boards (always 40)
99  uint16_t NPix ; //#pixels (always 1440)
100  uint16_t NTm ; //#TM (always 160)
101  uint16_t Nroi ; //roi for pixels
102  uint16_t NroiTM ; //roi for TM <=0 if TM is empty
103 
104 //headers of all FAD-boards for first event ==> all FAD configs
105  PEVNT_HEADER FADhead[NBOARDS]; // [ NBoards ] sorted Board Headers (according Hardware ID)
106 
107  RUN_HEAD() : Version(1), RunType(-1), NBoard(NBOARDS), NPix(NPIX), NTm(NTMARK)
108  {
109  }
110 
111 
112 //do we also have info about FTM config we want to add here ???
113 } __attribute__((__packed__));
114 
115 
116 //---------------------------------------------------------------
117 
118 // FIXME: This doesn't neet to be here... it is inlcuded in all
119 // data processors
120 
121 #include <netinet/in.h>
122 
123 typedef struct {
124  struct sockaddr_in sockAddr ;
125  int sockDef ; //<0 not defined/ ==0 not to be used/ >0 used
126 } FACT_SOCK ; //internal to eventbuilder
127 
128 
129 //---------------------------------------------------------------
130 
131 typedef struct {
132  //info about (current state of) the buffer
133  uint32_t bufNew ; //# incomplete events in buffer (evtCtrl)
134  uint32_t bufEvt ; //# complete events in buffer (primaryQueue)
135  uint32_t bufWrite ; //# events in write queue (secondaryQueue)
136  uint32_t bufProc ; //# events in processing queue (processingQueue1)
137  uint32_t bufTot ; //# total events currently in buffer (this corresponds to totMem)
138 
139  uint64_t totMem; //# Bytes available in Buffer
140  uint64_t usdMem; //# Bytes currently used
141  uint64_t maxMem; //max # Bytes used during past cycle
142 
143  //rates
144  int32_t deltaT ; //time in milli-seconds for rates
145  int32_t rateNew ; //#New start events recieved
146  int32_t rateWrite ; //#Complete events written (or flushed)
147 
148  //connections
149  int8_t numConn[NBOARDS] ; //#connections per board (at the moment)
150  uint32_t rateBytes[NBOARDS]; //#Bytes read (counter)
151  int32_t relBytes[NBOARDS]; //#Bytes read this cycle **
152 
153  // ** // if counter and rates exist, do only update the rates in
154  // ** // real time;
155  // ** // counters will be updated only once per cycle based on rates
156 
157 } __attribute__((__packed__)) GUI_STAT ; //EventBuilder Status
158 
159 #endif
uint32_t RunTime
Definition: FAD.h:96
int16_t StartPix[NPIX]
Definition: FAD.h:82
uint16_t trigger_generator_prescaler
Definition: FAD.h:31
RUN_HEAD()
Definition: FAD.h:107
#define NBOARDS
Definition: FAD.h:58
uint16_t trigger_type
Definition: FAD.h:21
uint32_t bufTot
Definition: FAD.h:137
uint16_t NroiTM
Definition: FAD.h:102
PEVNT_HEADER FADhead[NBOARDS]
Definition: FAD.h:590
uint32_t RunType
Definition: FAD.h:95
uint16_t NTm
Definition: FAD.h:100
uint32_t PCTime
Definition: FAD.h:77
uint16_t trigger_crc
Definition: FAD.h:20
uint32_t time
Definition: FAD.h:35
uint32_t REFCLK_frequency
Definition: FAD.h:25
uint32_t bufWrite
Definition: FAD.h:135
uint8_t zeroes
Definition: FAD.h:28
int8_t adc_clock_phase_shift
Definition: FAD.h:29
uint32_t fad_evt_counter
Definition: FAD.h:24
uint16_t RoiTM
Definition: FAD.h:70
uint16_t TriggerType
Definition: FAD.h:73
uint64_t DNA
Definition: FAD.h:33
uint32_t bufEvt
Definition: FAD.h:134
Definition: FAD.h:123
uint16_t filling
Definition: FAD.h:48
uint32_t PCUsec
Definition: FAD.h:78
uint16_t number_of_triggers_to_generate
Definition: FAD.h:30
uint16_t PLLLCK
Definition: FAD.h:18
int32_t rateWrite
Definition: FAD.h:146
uint32_t runnumber
Definition: FAD.h:36
uint16_t Roi
Definition: FAD.h:69
int32_t rateNew
Definition: FAD.h:145
uint16_t package_crc
Definition: FAD.h:54
#define NPIX
Definition: FAD.h:59
uint16_t roi
Definition: FAD.h:47
Definition: FAD.h:68
Definition: FAD.h:92
uint16_t end_package_flag
Definition: FAD.h:55
uint32_t bufNew
Definition: FAD.h:133
uint32_t Version
Definition: FAD.h:94
uint32_t trigger_id
Definition: FAD.h:22
uint16_t package_length
Definition: FAD.h:16
uint64_t maxMem
Definition: FAD.h:141
uint32_t EventNum
Definition: FAD.h:71
int sockDef
Definition: FAD.h:125
int16_t Adc_Data[]
Definition: FAD.h:86
typedef __attribute__
uint16_t Nroi
Definition: FAD.h:101
uint32_t NumBoards
Definition: FAD.h:75
uint64_t usdMem
Definition: FAD.h:140
uint16_t NBoard
Definition: FAD.h:98
uint16_t start_cell
Definition: FAD.h:46
uint16_t version_no
Definition: FAD.h:17
uint32_t TriggerNum
Definition: FAD.h:72
#define NTMARK
Definition: FAD.h:60
uint32_t RunUsec
Definition: FAD.h:97
uint32_t BoardTime[NBOARDS]
Definition: FAD.h:80
uint16_t NPix
Definition: FAD.h:99
uint16_t board_id
Definition: FAD.h:27
uint16_t id
Definition: FAD.h:45
int16_t StartTM[NTMARK]
Definition: FAD.h:84
uint32_t bufProc
Definition: FAD.h:136
#define NTemp
Definition: FAD.h:10
uint64_t totMem
Definition: FAD.h:139
int32_t deltaT
Definition: FAD.h:144
#define NDAC
Definition: FAD.h:11
uint16_t start_package_flag
Definition: FAD.h:15