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