Hall-D Software  alpha
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
disData.h
Go to the documentation of this file.
1 /*
2  * disData.h
3  *
4 */
5 
6 #ifndef disDataH_INCLUDED
7 #define disDataH_INCLUDED
8 
9 static const char sccsid_disDataH[] = "@(#)disData.h\t5.7\tCreated 12/11/97 15:27:54, \tcompiled "__DATE__;
10 
11 #include <rectypes.h>
12 
13 /********************************************
14 
15 An event will look like this:
16 
17 ---------------------------------------------
18 event header itape_header_t
19  ----------------------------------
20  group1 group_header_t
21  data
22  ----------------------------------
23  group2 group_header_t
24  data
25  ----------------------------------
26  ...
27  ----------------------------------
28  groupN group_header_t
29  data
30 ---------------------------------------------
31 
32 Assigned group numbers:
33 
34  RANGE SUBSYSTEM OWNER
35 
36  0 - 99 - reserved for debugging purposes C.Olchanski
37  100 - 199 - TCYL data structures C.Olchanski
38  200 - 299 - LGD data structures Rob
39  300 - 399 - CSI data structures ND?
40  400 - 499 - MPS modules C.Olchanski
41  500 - 599 - magnet DVMs C.Olchanski
42 
43 **********************************************************************/
44 
45 /*
46  * Note: This file is used to automatically generate little <--> big
47  * endian data conversion routines. For each data group,
48  * it needs to know the data type and the include file
49  * where the data type is defined.
50  *
51  * Therefore each data group should be defined using the following
52  * format:
53  *
54  * #define GROUP_XXX NUM ** header.h:type_t - user comments **
55  *
56  *
57  * There exist "special" predefined types and header files that can be used
58  * when there is no "real" data type or header file corresponding
59  * to the data group:
60  *
61  * NOCONVERT_t --- a data type that does not need endian conversion,
62  * for example an array of char.
63  * INTARRAY_t --- a data type that should be converted as an array
64  * of 32-bit integers, for example the raw data group.
65  *
66 */
67 
68 
69 #define GROUP_DELETED 0 /* groups deleted with data_removeGroup() disData.h:NOCONVERT_t */
70 #define GROUP_RAW 1 /* raw data group, see rawData.h, INTARRAY_t */
71 
72 #define GROUP_TIME0_TDCS 30 /* time zero for this event (time pedestal) (itypes.h:tdc_values_t) */
73 #define GROUP_TRIGGER_TDCS 40 /* trigger signals timing tdcs (itypes.h:tdc_values_t) */
74 #define GROUP_TRIGGER_TDCS_COMP 41 /* itypes.h:tdc_values_t - Has only c1,c2,and c3 */
75 #define GROUP_SCALERS 50 /* scaler_values_t in itypes.h */
76 #define GROUP_LATCHES 52 /* latch_values_t in itypes.h */
77 
78 #define GROUP_MISC_ADCS 54 /* itypes.h:adc_values_t */
79 #define GROUP_DIBBUK 55 /* dibbuk_data_t, see dibbuk2.h and rawUnpack.c:unpack_dibbuk() */
80 #define GROUP_EVBV_ENCODERS 56 /* itypes.h:adc_values_t */
81 #define GROUP_TEMP_PROBES 57 /* itypes.h:adc_values_t */
82 #define GROUP_DIBBUKnfs 58 /* dibbuk2nfs.h:dibbuk2nfs_t dibbuk data read through NFS */
83 
84 #define GROUP_BOSSUMMARY 61 /* bosSummaryRecord_t, see bosSummary.h */
85 
86 #define GROUP_VETO_HITS 71 /* adc_hits_t in itypes.h */
87 #define GROUP_VETO_BITMAP 72 /* vetoCounters_t in itypes.h */
88 
89 /*#define GROUP_TCYL 100*/
90 #define GROUP_TCYL_ADCS 110 /* itypes.h:adc_values_t */
91 #define GROUP_TCYL_TDCS 111 /* itypes.h:tdc_values_t */
92 #define GROUP_TCYL_COORS_A 120 /* tcyl.h:tcylHits_t */
93 #define GROUP_TCYL_COORS_B 121 /* tcyl.h:tcylHits_t */
94 #define GROUP_TCYL_COORS_C 122 /* tcyl.h:tcylHits_t */
95 #define GROUP_TCYL_COORS_D 123 /* tcyl.h:tcylHits_t */
96 #define GROUP_TCYL_COORS GROUP_TCYL_COORS_A
97 #define GROUP_TCYL_PATREC 130 /* tcyl.h:tcylPatrec_hits_t */
98 #define GROUP_TCYL_TRACKS 140 /* tcyl.h:tcylTracks_t */
99 #define GROUP_TCYL_TRACKCOV 141 /* tcyl.h:tcylTracksCov_t (covariance matrices for TCYL tracks) */
100 
101 /*#define GROUP_LGD 200*/
102 #define GROUP_LGD_MCHITS 209 /* lgdCluster.h:lgd_hits_t */
103 #define GROUP_LGD_ADCS 210 /* itypes.h:adc_values_t */
104  /* These are defined in lgdCluster.h */
105 #define GROUP_LGD_HITS 211 /* lgdCluster.h:lgd_hits_t -- this group duplicates GROUP_LGD_ENG below */
106 #define GROUP_LGD_HITS2 212 /* itypes.h:adc_hits_t */
107 #define GROUP_LGD_SHOWER_MC 213 /* LgdShowerLibrary.h:lgd_showerHits_t */
108 
109 #define GROUP_LGD_ROCS 240 /* itypes.h:lgd_roc_t */
110 #define GROUP_LGD_MAM 241 /* itypes.h:lgd_mam_t */
111 
112 #define GROUP_LGD_CLUSTERS 252 /* lgdCluster.h:lgd_clusters_t */
113 #define GROUP_LGD_CLUSTER_HITS 253 /* lgdCluster.h:lgd_hits_t */
114 #define GROUP_LGD_ENCODERS 254 /* itypes.h:adc_values_t */
115 #define GROUP_LGD_CLUSTER_HITS2 255 /* itypes.h:adc_hits_t */
116 #define GROUP_LGD_CLUSTERS_MC 256 /* lgdCluster.h:lgd_clusters_t -- generated by montecarlo */
117 
118 #define GROUP_NN_CLUSTERS 260 /* lgdCluster.h:lgd_clusters_t */
119 #define GROUP_NN_CLUSTER_HITS 261 /* lgdCluster.h:lgd_hits_t */
120 
121 
122 /*#define GROUP_CSI 300*/
123 #define GROUP_CSI_ADCS 310 /* itypes.h:adc_values_t */
124 #define GROUP_CSI_SCALERS 311 /* itypes.h:scaler_values_t */
125 #define GROUP_CSI_HITS 312 /* itypes.h:csi_hits_t */
126 #define GROUP_CSI_CLUSTERS 313 /* CsI.h:csi_clusters_t*/
127 #define GROUP_CSI_PACKED 314 /* CsI.h:csi_packed_adcs_t */
128 #define GROUP_CSI_TAGS 315 /* tags for the CsI blocks. csi_tags_t from itypes.h */
129 #define GROUP_CSI_TDCS 316 /* itypes.h:tdc_values_t */
130 
131 /* General MPS PWC group */
132 
133 #define GROUP_PWC_PLANES 401 /* pwc_planes_t, see itypes.h for definitions */
134 #define GROUP_PWC_HITS 402 /* pwc_hits_t, see itypes.h for definitions */
135 
136 /* Beam PWCs */
137 
138 #define GROUP_BEAMPWC_PLANES 411 /* pwc_planes_t, see itypes.h for definitions */
139 #define GROUP_BEAMPWC_HITS 412 /* pwc_hits_t, see itypes.h for definitions */
140 
141 /* Beam Hodoscopes */
142 
143 #define GROUP_BEAMHODO_TDCS 415 /* tdc_values_t, itypes.h */
144 
145 #define GROUP_BEAMHODO_PLANES 414 /* pwc_planes_t, see itypes.h for definitions */
146 #define GROUP_BEAMHODO_HITS 416 /* pwc_hits_t, see itypes.h for definitions */
147 
148 /* The BEAMSCINT groups are a misnomer- the correct name is 'BEAMHODO' */
149 
150 #define GROUP_BEAMSCINT_TDCS GROUP_BEAMHODO_TDCS
151 #define GROUP_BEAMSCINT_PLANES GROUP_BEAMHODO_PLANES
152 #define GROUP_BEAMSCINT_HITS GROUP_BEAMHODO_HITS
153 
154 #define GROUP_TPX123_PLANES 421 /* pwc_planes_t, see itypes.h for definitions */
155 #define GROUP_TPX123_HITS 422 /* pwc_hits_t, see itypes.h for definitions */
156 
157 #define GROUP_MPSDC_PLANES 431 /* mpsdc_planes_t, see itypes.h for definitions */
158 #define GROUP_MPSDC_HITS 432 /* mpsdc_hits_t, see itypes.h for definitions */
159 #define GROUP_MPSDC_COMP 433 /* mpsdc_comp_t see itypes.h */
160 
161 #define GROUP_TDX4_TDCS 461 /* tdc_values_t see itypes.h */
162 
163 #define GROUP_COORS 471 /* saved chamber hits, disData.h:INTARRAY_t */
164 
165 #define GROUP_DVMS 511 /* adc_values_t see itypes.h */
166 
167 #define GROUP_C9_ADCS 551 /* adc_values_t see itypes.h */
168 #define GROUP_C9_TDCS 552 /* tdc_values_t see itypes.h */
169 #define GROUP_C9_HITS 553 /* adc_hits_t see itypes.h */
170 #define GROUP_C9_COOKED_HITS 556 /* adc_hits_t, better def'n of hit.
171  note: fvalue = no. of photons,
172  negative number = don't know. */
173 #define GROUP_C9_MC_HITS 554 /* adc_hits_t see itypes.h */
174 #define GROUP_NOTC9H9 555 /* c9.h: notc9h9_hits_t */
175 #define GROUP_H9_ADCS 561 /* adc_values_t see itypes.h */
176 #define GROUP_H9_TDCS 562 /* tdc_values_t see itypes.h */
177 #define GROUP_H9_HITS 563 /* adc_hits_t see itypes.h */
178 #define GROUP_H9_MC_HITS 564 /* adc_hits_t see itypes.h */
179 
180 /* MonteCarlo */
181 
182 #define GROUP_MC_TRIGGERMASK 601 /* mcTriggerMask.h: mcTriggerMask_t */
183 
184 /* Analysis */
185 
186 #define GROUP_MONTECARLO_EVENT 700 /* event_t with SAGE Monte Carlo event, see cstruct.h */
187 
188 #define GROUP_BEAM_RECORD 710 /* see: mpsX.h BeamRec_t */
189 /*#define GROUP_BEAM_TRACKCOV 711*/ /* beam track covariance matrix: see: beam.h BeamCov_t */
190 
191 /*
192  * The TRACKS groups below are the reconstructed tracks
193  * before the vertex is located
194 */
195 
196 #define GROUP_MONTECARLO_TRACKS 721 /* tracks_t (see tracking.h) */
197 #define GROUP_TRACKS 722 /* tracks_t (see tracking.h) */
198 #define GROUP_HTR_TRACKS 723 /* tracks_t (see tracking.h), see the HTR package */
199 
200 #define GROUP_TrackPositions 724 /* trackPositions_t (see trackPositions.h) */
201 
202 /* Pattern recognition groups:
203  GROUP_PATREC - output of the pattern recognition program
204  GROUP_PATREC_TRK - output of the geometry reconstruction program
205  GROUP_PATREC_HTR - output of the HTR geometry package
206 */
207 
208 #define GROUP_MONTECARLO_PATREC 731 /* trackHits_t (see tracking.h) */
209 #define GROUP_PATREC 732 /* regular pattern recognition data, trackHits_t (see tracking.h) */
210 #define GROUP_PATREC_TRK 733 /* patrec after fitting, trackHits_t (see tracking.h) */
211 #define GROUP_PATREC_HTR 734 /* patrec from HTR, trackHits_t (see tracking.h) */
212 #define GROUP_PATREC_PROJ 735 /* patrec projected tracks, patrecProjTracks_t (see tracking.h) */
213 #define GROUP_PATREC_BEAM 736 /* patrec from beam chambers, trackHits_t (see tracking.h) */
214 
215 /*
216  * The GEO groups are the output of the geometry reconstruction program
217  *
218  * Note, that the GEO_TRACKS use the vertex as one more measurement
219 */
220 
221 #define GROUP_GEO_MC_TRACKS 741 /* geo_tracks_rec_t (see tracking.h) */
222 #define GROUP_GEO_TRACKS 742 /* geo_tracks_rec_t (see tracking.h) */
223 
224 #define GROUP_GEO_MC_VERTICES 751 /* geo_vertices_rec_t (see tracking.h) */
225 #define GROUP_GEO_VERTICES 752 /* geo_vertices_rec_t (see tracking.h) */
226 
227 /* Event Summary Records */
228 
229 #define GROUP_ESR_NPRONG 801 /* esr_nprong_t (see esr.h) */
230 #define GROUP_ESR_NPARTICLE 802 /* esr_nparticle_t (see esr.h) */
231 #define GROUP_ESR_VETO 803 /* esrVeto_t (see veto.h) */
232 #define GROUP_NDESR_VETO GROUP_ESR_VETO
233 
234 
235 #define GROUP_EVENT_WEIGHTS 804 /* EventWeights_t (esr.h) used by PWA */
236 #define GROUP_PWA_AMPLITUDES 805 /* amplitudes_t (esr.h) used by PWA */
237 #define GROUP_ESR_NPARTICLE_MC 806 /* esr_nparticle_t (see esr.h) */
238 #define GROUP_ESR_VERTICES 807 /* esr_vertices_t (see esr.h) */
239 
240 #define GROUP_ESR_COMPRESSED 808 /* esr_compressed_t (see esr.h) */
241 #define GROUP_ESR_GENERIC 809 /* generic_t (see esr.h) */
242 
243 #define GROUP_ESR_VERTICES_MC 810 /* esr_vertices_t (see esr.h) */
244 
245 #define GROUP_ESR_BEFORE_SQUAW 811 /* esr_nparticle_t (see esr.h) */
246 #define GROUP_ESR_NPARTICLE_ALL 812 /* esr_nparticle_t (see esr.h) */
247 
248 #define GROUP_SQUAW_SVFITS 840 /* svfits_t (see squaw.h) */
249 #define GROUP_SQUAW_SVPULLS 841 /* svpulls_t (see squaw.h) */
250 #define GROUP_SQUAW_SV 842 /* sqfits_t (see squaw97.h) */
251 #define GROUP_SQUAW_SVP 843 /* sqpulls_t (see squaw97.h) */
252 
253 #define GROUP_SQUAW_MVFITS 850 /* mvfits_t (see squaw.h) */
254 #define GROUP_SQUAW_MVPULLS 851 /* mvpulls_t (see squaw.h) */
255 #define GROUP_SQUAW_MV 852 /* sqfits_t (see squaw97.h) */
256 #define GROUP_SQUAW_MVP 853 /* sqpulls_t (see squaw97.h) */
257 
258 
259 #ifdef mips
260 #define TRANSCOMPUTERCODE 1
261 #endif
262 
263 #ifndef TRANSCOMPUTERCODE
264 #define TRANSCOMPUTERCODE 123
265 #endif
266 
267 #include <ntypes.h>
268 
269 typedef struct
270 {
271  uint32 length; /* record length in bytes */
272  uint32 type; /* should always be TYPE_ITAPE */
277  int32 eventNo; /* 0-BOS, (-1)-EOS, others- events number */
278  uint16 eventType; /* event type (decoded latch word) */
279  int16 trigger; /* trigger: 0: BOS, 1-6: events, -1: EOS */
280  int32 time; /* time as returned by time() */
281  uint32 latch; /* virtual latch word */
283 
284 typedef struct
285 {
289 
290 
291 /*
292  * 'data_newItape' will fill initialize an empty itape
293 */
294 
295 int data_newItape(void* itape);
296 
297 /*
298  * 'data_getGroup' returns the pointer to the group data or NULL
299 */
300 
301 void* data_getGroup(const void*buf,uint32 group);
302 
303 unsigned long data_getGroupSize(const void*buf,uint32 group);
304 
305 /*
306  * 'data_getGroupHeader' returns thr pointer to the group header or NULL
307 */
308 
309 group_header_t* data_getGroupHeader(const void*buf,uint32 type);
310 
311 void* data_addGroup(void* buffer,int bufsize,uint32 group,uint32 length);
312 
313 group_header_t* data_addGroup_header(void* buffer,int bufsize,
314  uint32 group,uint32 length);
315 
316 /*
317  * 'data_renameGroup' will rename a given group. The return value is:
318  * 0: success, non 0: error.
319 */
320 
321 int data_renameGroup(void* event,int oldName,int newName);
322 
323 /*
324  * 'data_removeGroup' returns 0 if group found and removed, 1 otherwise
325  * the space occupied by the removed group is not deallocated and is lost
326  * until 'data_clean' is called to compact the itape
327 */
328 
329 int data_removeGroup(void* buffer,uint32 groupName);
330 
331 
332 int data_removeAllgroups(void* buffer); /* returns 1 */
333 int data_saveGroups(void* buffer,int nsave,int *isave); /* returns 1 */
334 
335 /*
336  * returns the address of the end of used space inside the buffer
337 */
338 
339 void* data_getAdr(const void*buffer);
340 
341 /*
342  * 'data_clean' removes the unused parts of the itape created by the 'removeGroup' functions
343  *
344  * NOTICE: this call moves data inside the itape and therefore all pointers
345  * into the itape (for example, pointers returned by 'getGroup')
346  * become invalid.
347 */
348 
349 int data_clean(void* buffer);
350 
351 /*
352  * Calculates a new CRC for the itape
353 */
354 
355 int data_addCRC(void*buffer);
356 
357 /*
358  * Check the CRC. If it is broken, return 1, otherwise, return 0
359 */
360 
361 int data_checkCRC(const void*buffer);
362 int data_checkCRC1(const void*buffer,int bufferLength);
363 
364 /*
365  * perform big <--> little endian conversion
366 */
367 
368 int endian_convertItape(void *itape,int itapeLength);
369 
370 /* tmask() is used to check the trigger word in the itape against a trigger mask.
371  The trigger word is an integer from -1 to 6 set by the DAQ code in the master SSP
372  according to the trigger latch. It corresponds to the 8 possible triggers
373  implemented in the E852 DAQ system.
374 
375  To find out which trigger latch values correspond to which trigger, see the DAQinit
376  database (default.db, current.db, the currently selected db, etc...).
377 
378  Each bit in the trigger mask selects one of the triggers:
379 
380  bit 0 (0x01) - trigger -1 - EOS
381  bit 1 (0x02) - trigger 0 - BOS
382  bit 2 (0x04) - trigger 1
383  bit 3 (0x08) - trigger 2
384  bit 4 (0x10) - trigger 3
385  bit 5 (0x20) - trigger 4
386  bit 6 (0x40) - trigger 5
387  bit 7 (0x80) - trigger 6
388 */
389 
390 int tmask(unsigned long mask,unsigned long trigger);
391 
392 /*
393  * To extract an event from a spill in shared memory
394 */
395 
396 void* data_getItape(const void*buffer,const void**nextItape);
397 
398 /*
399  * The 'data_listGroups' function will return-
400  * in 'ngroups' - number of groups in the event
401  * in 'groupsList' - a pointer to the array of groups
402  * in 'groupsSize' - a pointer to the array of their lengths
403  *
404  * All the three arguments can be NULL if the returned information is not needed
405  * The arrays should be free'ed after use
406 */
407 
408 int data_listGroups(const void*event,int*ngroups,int **groupsList,int **groupsSize);
409 
410 #endif
411 /* end file */
int data_newItape(void *itape)
int int32
Definition: ntypes.h:49
int data_checkCRC(const void *buffer)
int32 runNo
Definition: disData.h:275
unsigned short uint16
Definition: ntypes.h:57
uint16 eventType
Definition: disData.h:278
void * data_getAdr(const void *buffer)
int endian_convertItape(void *itape, int itapeLength)
void * data_addGroup(void *buffer, int bufsize, uint32 group, uint32 length)
int data_listGroups(const void *event, int *ngroups, int **groupsList, int **groupsSize)
uint32 length
Definition: disData.h:286
int32 time
Definition: disData.h:280
uint32 type
Definition: disData.h:272
unsigned long data_getGroupSize(const void *buf, uint32 group)
int data_saveGroups(void *buffer, int nsave, int *isave)
int32 eventNo
Definition: disData.h:277
uint32 type
Definition: disData.h:287
uint32 ngroups
Definition: disData.h:274
static const char sccsid_disDataH[]
Definition: disData.h:9
uint32 transComputerCode
Definition: disData.h:273
uint32 spillNo
Definition: disData.h:276
void * data_getItape(const void *buffer, const void **nextItape)
group_header_t * data_addGroup_header(void *buffer, int bufsize, uint32 group, uint32 length)
void * data_getGroup(const void *buf, uint32 group)
int data_removeGroup(void *buffer, uint32 groupName)
short int16
Definition: ntypes.h:56
int data_removeAllgroups(void *buffer)
int data_clean(void *buffer)
int16 trigger
Definition: disData.h:279
uint32 latch
Definition: disData.h:281
group_header_t * data_getGroupHeader(const void *buf, uint32 type)
int tmask(unsigned long mask, unsigned long trigger)
int data_checkCRC1(const void *buffer, int bufferLength)
int data_addCRC(void *buffer)
int data_renameGroup(void *event, int oldName, int newName)
uint32 length
Definition: disData.h:271
unsigned int uint32
Definition: ntypes.h:50