StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
TPCV1P0.Banks.cxx
1 /***************************************************************************
2  * $Id: TPCV1P0.Banks.cxx,v 1.3 2007/12/24 06:04:31 fine Exp $
3  * Author: M.W. Shculz, Jeff Landgraf and M.J. LeVine
4  ***************************************************************************
5  * Description: Overrides (mostly for the swap functions,
6  * print functions of each bank)
7  *
8  *
9  * change log
10  *
11  ***************************************************************************
12  * $Log: TPCV1P0.Banks.cxx,v $
13  * Revision 1.3 2007/12/24 06:04:31 fine
14  * introduce OLDEVP namespace to allow ole and new EVP library concurrently
15  *
16  * Revision 1.2 1999/07/02 04:43:22 levine
17  * Many changes -
18  * navigates to head of TPCP bank independent of position.
19  * move declarations out of loops where they were upsetting some compilers
20  * suppress output from class libraries with run-time switch EventReader.verbose
21  * added TPCV2P0_CPP_SR::getAsicParams()
22  *
23  *
24  **************************************************************************/
25 #include <assert.h>
26 
27 #include "StDaqLib/GENERIC/swaps.hh"
28 #include "TPCV1P0.Banks.hh"
29 
30 using namespace OLDEVP;
31 
32 int classname(Bank_TPCRBP)::swap()
33 {
34  // get bank length
35  int words = header.BankLength;
36  int iret = swap_raw(header.ByteOrder,&words,1);
37 
38  // returns zero means none needed
39  if(!iret) return(0);
40  // returns negative means error
41  if(iret < 0) return iret;
42 
43  // swap body first (only mz get swapped)
44  iret = swap_raw(header.ByteOrder,(INT32 *)Mz,sizeof(Mz)/4);
45  assert(iret > 0);
46 
47  // swap the header
48  iret = header.swap();
49 
50  return iret;
51 }
52 
53 int classname(Bank_TPCADCD)::swap()
54 {
55  return header.swap(); // nothing to swap in the data
56 }
57 
58 int classname(Bank_TPCADCR)::swap()
59 {
60  return header.swap();
61 }
62 
63 int classname(Bank_TPCPADK)::swap()
64 {
65  // Get length
66  int words = header.BankLength;
67  int iret = swap_raw(header.ByteOrder,&words,1);
68 
69  if(!iret) return 0;
70  if(iret < 0) return iret;
71 
72  // Swap body
73  iret = swap_raw(header.ByteOrder,&bpADC,6);
74  assert(iret>0);
75 
76  // Swap header
77  return header.swap();
78 }
79 
80 int classname(Bank_TPCCPPR)::swap()
81 {
82  // get number of words
83  int words = header.BankLength;
84  int iret = swap_raw(header.ByteOrder,&words,1);
85 
86  if(!iret) return 0;
87  if(iret<0) return iret;
88 
89  // swap body
90  iret = swap_short(header.ByteOrder,(INT32 *)entry,12288);
91  assert(iret>0);
92 
93  // swap header
94  return header.swap();
95 }
96 
97 int classname(Bank_TPCSEQD)::swap()
98 {
99  int words = header.BankLength;
100  int iret = swap_raw(header.ByteOrder,&words,1);
101 
102  if(!iret) return 0;
103  if(iret < 0) return iret;
104 
105  words -= (sizeof(header)/4);
106  swap_short(header.ByteOrder,(INT32 *)sequence,words);
107  assert(iret>0);
108 
109  iret = header.swap();
110  return iret;
111 }
112 
113 int classname(Bank_TPCCFGR)::swap()
114 {
115  return header.swap();
116 }
117 
118 int classname(Bank_TPCBADR)::swap()
119 {
120  return header.swap();
121 }
122 
123 int classname(Bank_TPCPEDR)::swap()
124 {
125  int iret = swap_raw(header.ByteOrder,&NumEvents,1);
126  if(iret <= 0) return iret;
127 
128  return header.swap();
129 }
130 
131 int classname(Bank_TPCRMSR)::swap()
132 {
133  int iret = swap_raw(header.ByteOrder,&NumEvents,1);
134  if(iret <= 0) return iret;
135 
136  return header.swap();
137 }
138 
139 int classname(Bank_TPCGAINR)::swap()
140 {
141  int iret = swap_raw(header.ByteOrder,&NumEvents,2);
142  if(iret <= 0) return iret;
143 
144  // if no swapping neccessary, already returned
145  // if iret not 1 then can't untangle shorts
146  if(iret != 1) return -1;
147 
148  // we know we want to swap the first two bytes of every GAINR entry
149  // but we can't use swap_short, which really swaps words of shorts
150 
151  // get the header swapping out of the way first
152  iret = header.swap();
153  assert(iret == 1);
154 
155  char *curr = (char *)Gain;
156  for(int i = 0; i < TPC_MZPADS; i++)
157  {
158  char temp=curr[0];
159  curr[0] = curr[1];
160  curr[1] = temp;
161  curr += 4;
162  }
163  return iret;
164 }
165 
166 
167 
168 
169 
170