StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
RecHeaderFormats.hh
1 /***************************************************************************
2  * $Id: RecHeaderFormats.hh,v 1.12 2013/08/08 12:19:19 jeromel Exp $
3  * Author: M.W. Schulz, Jeff Landgraf, M.J. LeVine
4  ***************************************************************************
5  * Description: Bank header formats common to all detectors in STAR:
6  * declarations and definitions
7  *
8  * change log
9  * 03-Jun-99 MJL add Pointer RICH to DATAP
10  * 23-Jun-99 MJL reinstate Pointer TRG to DATAP (deleted accidentally)
11  *
12  ***************************************************************************
13  * $Log: RecHeaderFormats.hh,v $
14  * Revision 1.12 2013/08/08 12:19:19 jeromel
15  * Missing header
16  *
17  * Revision 1.11 2012/06/11 16:38:35 fisyak
18  * std namespace, remove clash with rtsSystems.h
19  *
20  * Revision 1.10 2007/12/24 06:04:17 fine
21  * introduce OLDEVP namespace to allow ole and new EVP library concurrently
22  *
23  * Revision 1.9 2003/05/22 20:53:31 perev
24  * method added to remove unprintef chars
25  *
26  * Revision 1.8 2002/12/09 18:54:23 ward
27  * EMC stuff from Subhassis.
28  *
29  * Revision 1.7 2002/01/17 18:29:55 jeromel
30  * After I looked at the code, corrections from Akio (pass2).
31  *
32  * Revision 1.6 2002/01/17 17:29:26 jeromel
33  *
34  * Files: CVS: DetectorReader.cxx EventReader.cxx EventReader.hh CVS: RecHeaderFormats.hh CVS: ----------------------------------------------------------------------
35  * Modifications for FPD support
36  *
37  * Revision 1.5 2001/06/26 17:01:42 jcs
38  * set FTP_TIMEBINS to correct number of FTPC timebins
39  *
40  * Revision 1.4 2000/01/19 16:20:22 levine
41  * #define FTP_MZPADS suppiled in this version
42  *
43  * Revision 1.3 1999/07/02 04:37:42 levine
44  * Many changes - see change logs in individual programs
45  *
46  *
47  **************************************************************************/
48 #include <ctype.h>
49 #include <cstring>
50 
51 
52 #ifndef RECHEADERFORMATS_HH
53 #define RECHEADERFORMATS_HH
54 
55 typedef int INT32; // WORD according to data format
56 typedef short INT16; // SHORT according to data format
57 
58 
59 #define TPC_SECTORS 24
60 #define TPC_TIMEBINS 512
61 #define TPC_PADROWS 45
62 #define TPC_MAXPADS 182
63 #define TPC_MZPADS 384
64 #define TPC_MXSEQUENCE 31
65 
66 #define FTP_SECTORS 60
67 #define FTP_TIMEBINS 256
68 #define FTP_PADROWS 2
69 #define FTP_MAXPADS 160
70 #define FTP_MZPADS 320
71 #define FTP_MXSEQUENCE 31
72 
73 namespace OLDEVP {
74 char *name2str(char *type);
75 void dump_data(char *buffer, int size, int width = 8);
76 }
77 
79 {
80  char BankType[8]; // padded with trailing nulls
81  INT32 BankLength; // Logical Record Header + Body
82  INT32 RunNumber;
83  INT32 FormatVersion; // 65536*major + minor version #
84  INT32 ByteOrder; // 0x04030201 (or it should be)
85  INT32 reserved1;
86  INT32 reserved2;
87  INT32 reserved3;
88  INT32 CRC;
89 
90  int swap();
91  void print();
92 };
93 
95 {
96  Logical_Record_Header header;
97  INT32 RecordLength; // From LRH to end of record including all banks
98  INT32 BlockingFactor; // # of events / logical record
99  char RecordType[8]; // Right Padded with spaces
100  INT32 CRC; // For Logical Record Header???
101 
102  int swap(); // Swap swaps. The CRC is not automatically recalc.
103  void set_CRC(); // Sets the CRC -- make sure the byte order has
104  // is 0x04030201 before using this function
105  // otherwise your CRC is byte reversed
106  int test_CRC(); // This swaps only a copy of the bank. This must be
107  // tested before swapping the actual bank
108  // The actual swapping treats shorts/bytes different
109  // than words and removes info needed to match up the
110  // CRC. The proper procedure is:
111 
112  // 1. test_CRC()
113  // 2. swap()
114  // 3. set_CRC() ....
115  void print(int level=0);
116 };
117 
119 {
120  char BankType[8];
121  INT32 BankLength; // Total length in words including header
122  INT32 BankId;
123  INT32 FormatVersion; // Format version, encoded as for LRH
124  INT32 ByteOrder; // 0x04030201
125  INT32 FormatNumber; // Bank dependent
126  INT32 Token;
127  INT32 reserved1;
128  INT32 CRC; // Whole bank minus this word
129 
130  int swap();
131  void print();
132  const char *bankTypeString() const
133  { static char buf[20];size_t i;
134  for (i=0; (i<sizeof(BankType))&&(isprint(BankType[i]));i++) {buf[i]=BankType[i];}
135  buf[i]=0; return buf;
136  }
137 };
138 
139 struct Bank
140 {
141  Bank_Header header;
142 
143  void set_CRC();
144  int test_CRC();
145  int swap();
146  void print(int level=0);
147  const char *bankTypeString() const {return header.bankTypeString();}
148 };
149 
150 struct Pointer // Used repeatedly
151 {
152  INT32 offset;
153  INT32 length;
154 };
155 
156 // Default swap
157 struct Bank_DATAP : public Bank
158 {
159  INT32 EventLength; // From first header word of DATAP
160  INT32 Time;
161  INT32 EventNumber; // unique within run
162  INT32 TriggerWord;
163  INT32 TriggerInWord;
164  INT32 DetectorPresence; // 0-TPC, 1-SVT, 2-TOF, 3-EMC, 4-FPD
165  // 5-FTPC, 6-PMD, 7-RICH, 8-Trig
166  // 9-L3
167  Pointer TPC; // Offsets from first word of DATAP
168  Pointer SVT;
169  Pointer TOF;
170  Pointer EMC;
171 // Pointer PMD;
172  Pointer EXTY_ID; // clash with rtsSystems.h DET_ID "EXT_ID" points to DATAPX if it exists! ( Addedd by Susanta for PMD 6th Nov, 2002 )
173  Pointer FPD;
174  Pointer FTPC;
175  Pointer RICH;
176  Pointer TRG;
177  Pointer L3;
178  INT32 reserved[102];
179 };
180 
181 // some unavoidable detector-specific definitions:
182 //
183 
184 // Next Struct Bank_DATAPX is added by Susanta for PMD on 6th Nov, 2002.
185 struct Bank_DATAPX : public Bank
186 {
187  Pointer EXT_DET[22]; // EXT_DET[2] = PMD
188 };
189 struct ASIC_params
190  // these params used to emulate ASIC behavior in the reader
191 {
192  unsigned char thresh_lo;
193  unsigned char thresh_hi;
194  unsigned char n_seq_lo;
195  unsigned char n_seq_hi;
196 };
197 
198 
199 
200 #endif