StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
SVTV1P0.Banks.cxx
1 /***************************************************************************
2  *
3  * $Id: SVTV1P0.Banks.cxx,v 1.8 2009/09/23 16:13:03 fine Exp $
4  *
5  * Author: Marcelo Munhoz, J. Schambach
6  ***************************************************************************
7  *
8  * Description: Overrides (mostly for the swap functions,
9  * print functions of each bank)
10  *
11  ***************************************************************************
12  *
13  * $Log: SVTV1P0.Banks.cxx,v $
14  * Revision 1.8 2009/09/23 16:13:03 fine
15  * fix pointer arithmetics and cpu type
16  *
17  * Revision 1.7 2007/12/24 06:04:27 fine
18  * introduce OLDEVP namespace to allow ole and new EVP library concurrently
19  *
20  * Revision 1.6 2004/03/01 18:05:47 fisyak
21  * Account for new place for rts.h, add osf
22  *
23  * Revision 1.5 2003/10/28 20:53:38 perev
24  * Linux ==> __linux__
25  *
26  * Revision 1.4 2003/09/02 17:55:32 perev
27  * gcc 3.2 updates + WarnOff
28  *
29  * Revision 1.3 2001/04/18 19:47:24 ward
30  * StDaqLib/SVT stuff from Jo Schambach.
31  *
32  * Revision 1.2 2000/09/30 16:14:31 fisyak
33  * Add hp
34  *
35  * Revision 1.1 2000/06/06 18:08:31 jml
36  * Initial version of SVT Readers (author: marcello munholz, helen caines)
37  *
38  *
39  **************************************************************************/
40 #include <assert.h>
41 #include <Stiostream.h>
42 
43 #include "StDaqLib/GENERIC/swaps.hh"
44 #include "SVTV1P0.Banks.hh"
45 
46 using namespace OLDEVP;
47 
48 int classname(Bank_SVTRBP)::swap()
49 {
50  // get bank length
51  int words = header.BankLength;
52  int iret = swap_raw(header.ByteOrder,&words,1);
53 
54  // returns zero means none needed
55  if(!iret) return(0);
56  // returns negative means error
57  if(iret < 0) return iret;
58 
59  // swap body first (only mz get swapped)
60  iret = swap_raw(header.ByteOrder,(INT32 *)Mz,sizeof(Mz)/4);
61  assert(iret > 0);
62 
63  // swap the header
64  iret = header.swap();
65 
66  return iret;
67 }
68 
69 int classname(Bank_SVTADCD)::swap()
70 {
71  return header.swap(); // nothing to swap in the data
72 }
73 
74 int classname(Bank_SVTADCR)::swap()
75 {
76  return header.swap();
77 }
78 
79 int classname(Bank_SVTANODK)::swap()
80 {
81  // Get length
82  int words = header.BankLength;
83 
84  int iret = swap_raw(header.ByteOrder,&words,1);
85 
86  // if(!iret) return 0;
87 
88 #if defined (sparc) || defined (__hpux)
89  if(!iret) {
90  return 0;
91  }
92  else if(iret < 0)
93  return iret;
94  else
95  iret = swap_raw(header.ByteOrder,&bpADC,12);
96 #elif defined(__i386__) || defined(__osf__) || defined(__x86_64__)
97  if(!iret)
98  return 0;
99  else if(iret < 0)
100  return iret;
101  else
102  iret = swap_raw(header.ByteOrder,&bpADC,12);
103 #else
104 #error "Unknown machine type"
105 #endif
106 
107  // if(iret < 0) return iret;
108 
109  // Swap body
110  // iret = swap_raw(header.ByteOrder,&bpADC,nWordsToSwap);
111  assert(iret>0);
112 
113  // Swap header
114  return header.swap();
115 }
116 
117 int classname(Bank_SVTCPPR)::swap()
118 {
119  // get number of words
120  int words = header.BankLength;
121  int iret = swap_raw(header.ByteOrder,&words,1);
122 
123  if(!iret) return 0;
124  if(iret<0) return iret;
125 
126  // swap body
127  iret = swap_short(header.ByteOrder,(INT32 *)entry,12288);
128  assert(iret>0);
129 
130  // swap header
131  return header.swap();
132 }
133 
134 int classname(Bank_SVTSEQD)::swap()
135 {
136  int words = header.BankLength;
137  int iret = swap_raw(header.ByteOrder,&words,1);
138 
139  if(!iret) return 0;
140  if(iret < 0) return iret;
141 
142  words -= (sizeof(header)/4);
143  swap_short(header.ByteOrder,(INT32 *)sequence,words);
144  assert(iret>0);
145 
146  iret = header.swap();
147  return iret;
148 }
149 
150 int classname(Bank_SVTCFGR)::swap()
151 {
152  return header.swap();
153 }
154 
155 int classname(Bank_SVTBADR)::swap()
156 {
157  return header.swap();
158 }
159 
160 int classname(Bank_SVTPEDR)::swap()
161 {
162  int iret = swap_raw(header.ByteOrder,&NumEvents,1);
163  if(iret <= 0) return iret;
164 
165  return header.swap();
166 }
167 
168 int classname(Bank_SVTRMSR)::swap()
169 {
170  int iret = swap_raw(header.ByteOrder,&NumEvents,1);
171  if(iret <= 0) return iret;
172 
173  return header.swap();
174 }
175 
176 int classname(Bank_SVTGAINR)::swap()
177 {
178  int iret = swap_raw(header.ByteOrder,&NumEvents,2);
179  if(iret <= 0) return iret;
180 
181  // if no swapping neccessary, already returned
182  // if iret not 1 then can't untangle shorts
183  if(iret != 1) return -1;
184 
185  // we know we want to swap the first two bytes of every GAINR entry
186  // but we can't use swap_short, which really swaps words of shorts
187 
188  // get the header swapping out of the way first
189  iret = header.swap();
190  assert(iret == 1);
191 
192  char *curr = (char *)Gain;
193  for(int i = 0; i < SVT_MZANODES; i++)
194  {
195  char temp=curr[0];
196  curr[0] = curr[1];
197  curr[1] = temp;
198  curr += 4;
199  }
200  return iret;
201 }
202 
203 
204 int classname(Bank_SVTMZCLD)::swap()
205 {
206  int iret = swap_raw(header.ByteOrder,&NumHybrids,1);
207  if(iret <= 0) return iret;
208 
209  int nsp = 0;
210  int *word = &NumHybrids;
211  word++; //bump to first instance of PadRow
212  for (int i=0; i<NumHybrids; i++){
213  swap_raw(header.ByteOrder,word,2);
214  nsp = word[1];
215  word+=2; //point to first cluster
216  swap_short(header.ByteOrder,word,2*nsp);
217  word+=2*nsp; //bump past clusters
218  }
219 
220  return header.swap();
221 }
222 
223 
224 
225