StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
FTPV1P0.Banks.cxx
1 /***************************************************************************
2  * $Id: FTPV1P0.Banks.cxx,v 1.2 2007/12/24 06:04:12 fine Exp $
3  * Author: M.W. Shculz, Jeff Landgraf, M.J. LeVine, H.Klay, H.Huemmler
4  ***************************************************************************
5  * Description: Overrides (mostly for the swap functions,
6  * print functions of each bank)
7  *
8  *
9  * change log
10  *
11  ***************************************************************************
12  * $Log: FTPV1P0.Banks.cxx,v $
13  * Revision 1.2 2007/12/24 06:04:12 fine
14  * introduce OLDEVP namespace to allow ole and new EVP library concurrently
15  *
16  * Revision 1.1 2000/01/18 18:01:19 levine
17  * Hummler's implementaiton of FTPC reader. Note that method
18  *
19  * FTPV1P0_ZS_SR::getFeeSequences(int Fee, int Pin, int *nSeq,
20  * Sequence **SeqData)
21  *
22  * causes exit() since the required #include file has not yet been
23  * (correctly) implemented.
24  *
25  *
26  *
27  **************************************************************************/
28 #include <assert.h>
29 
30 #include "StDaqLib/GENERIC/swaps.hh"
31 #include "FTPV1P0.Banks.hh"
32 using namespace OLDEVP;
33 
34 /*--------------FTP IMPLEMENTATION-------------------*/
35 
36 int classname(Bank_FTPRBP)::swap()
37 {
38  // get bank length
39  int words = header.BankLength;
40  int iret = swap_raw(header.ByteOrder,&words,1);
41 
42  // returns zero means none needed
43  if(!iret) return(0);
44  // returns negative means error
45  if(iret < 0) return iret;
46 
47  // swap body first (only sectors get swapped)
48  iret = swap_raw(header.ByteOrder,(INT32 *)Sector,sizeof(Sector)/4);
49  assert(iret > 0);
50 
51  // swap the header
52  iret = header.swap();
53 
54  return iret;
55 }
56 
57 int classname(Bank_FTPADCD)::swap()
58 {
59  return header.swap(); // nothing to swap in the data
60 }
61 
62 int classname(Bank_FTPADCR)::swap()
63 {
64  return header.swap();
65 }
66 
67 int classname(Bank_FTPPADK)::swap()
68 {
69  // Get length
70  int words = header.BankLength;
71  int iret = swap_raw(header.ByteOrder,&words,1);
72 
73  if(!iret) return 0;
74  if(iret < 0) return iret;
75 
76  // Swap body
77  iret = swap_raw(header.ByteOrder,&bpADC,6);
78  assert(iret>0);
79 
80  // Swap header
81  return header.swap();
82 }
83 
84 int classname(Bank_FTPCPPR)::swap()
85 {
86  // get number of words
87  int words = header.BankLength;
88  int iret = swap_raw(header.ByteOrder,&words,1);
89 
90  if(!iret) return 0;
91  if(iret<0) return iret;
92 
93  // swap body
94  iret = swap_short(header.ByteOrder,(INT32 *)entry,10240);
95  assert(iret>0);
96 
97  // swap header
98  return header.swap();
99 }
100 
101 int classname(Bank_FTPSEQD)::swap()
102 {
103  int words = header.BankLength;
104  int iret = swap_raw(header.ByteOrder,&words,1);
105 
106  if(!iret) return 0;
107  if(iret < 0) return iret;
108 
109  words -= (sizeof(header)/4);
110  swap_short(header.ByteOrder,(INT32 *)sequence,words);
111  assert(iret>0);
112 
113  iret = header.swap();
114  return iret;
115 }
116 
117 int classname(Bank_FTPCFGR)::swap()
118 {
119  return header.swap();
120 }
121 
122 int classname(Bank_FTPBADR)::swap()
123 {
124  return header.swap();
125 }
126 
127 int classname(Bank_FTPPEDR)::swap()
128 {
129  int iret = swap_raw(header.ByteOrder,&NumEvents,1);
130  if(iret <= 0) return iret;
131 
132  return header.swap();
133 }
134 
135 int classname(Bank_FTPRMSR)::swap()
136 {
137  int iret = swap_raw(header.ByteOrder,&NumEvents,1);
138  if(iret <= 0) return iret;
139 
140  return header.swap();
141 }
142 
143 int classname(Bank_FTPGAINR)::swap()
144 {
145  int iret = swap_raw(header.ByteOrder,&NumEvents,2);
146  if(iret <= 0) return iret;
147 
148  // if no swapping neccessary, already returned
149  // if iret not 1 then can't untangle shorts
150  if(iret != 1) return -1;
151 
152  // we know we want to swap the first two bytes of every GAINR entry
153  // but we can't use swap_short, which really swaps words of shorts
154 
155  // get the header swapping out of the way first
156  iret = header.swap();
157  assert(iret == 1);
158 
159  char *curr = (char *)Gain;
160  for(int i = 0; i < FTP_MZPADS; i++)
161  {
162  char temp=curr[0];
163  curr[0] = curr[1];
164  curr[1] = temp;
165  curr += 4;
166  }
167  return iret;
168 }