56 #include "StDaqLib/GENERIC/EventReader.hh"
58 #define MAKE_THE_DAMNED_COMPILER_SILENT
61 using namespace OLDEVP;
66 cout <<
"Constructing TPCV1P0_ZS_SR" << endl;
71 memset((
char *)adcd_p, 0,
sizeof(adcd_p));
72 memset((
char *)adcx_p, 0,
sizeof(adcx_p));
73 memset((
char *)seqd_p, 0,
sizeof(seqd_p));
76 int TPCV1P0_ZS_SR::initialize()
81 for (row=0; row<TPC_PADROWS; row++) {
82 Row_array[row].pad = &Pad_array[row][0];
83 Row_array[row].npads = 0;
84 for (
int pad=0; pad<TPC_MAXPADS; pad++) {
85 Pad_array[row][pad].nseq=0;
86 Pad_array[row][pad].seq= (
Sequence *)0;
92 for(rcb = 0; rcb < 6; rcb++)
94 for(
int mz = 0; mz < 3; mz++)
96 adcd_p[rcb][mz] = detector->getBankTPCADCD(sector,rcb,mz);
97 if ((
void *)adcd_p[rcb][mz] != NULL) {
101 adcx_p[rcb][mz] = detector->getBankTPCADCX(sector,rcb,mz);
102 if ((
void *)adcx_p[rcb][mz] != NULL) {
106 seqd_p[rcb][mz] = detector->getBankTPCSEQD(sector,rcb,mz);
107 if ((
void *)seqd_p[rcb][mz] != NULL) {
120 for( rcb = 0; rcb < 6; rcb++) {
121 for(
int mz = 0; mz < 3; mz++) {
122 if (seqd_p[rcb][mz] == (classname(Bank_TPCSEQD) *)NULL)
continue;
123 printf(
"TPCSEQD found sector %d RB%d MZ%d\n",sector+1,rcb+1,mz+1);
124 int padrow=-1, pad=-1, lastbin=-2, oldstart=0;
125 int len = seqd_p[rcb][mz]->header.BankLength - (
sizeof(
Bank_Header)/4);
126 int numseq = (4*len)/
sizeof(
short);
129 for (
int i=0; i<numseq; i++) {
130 if (seqd_p[rcb][mz]->sequence[i]<0) {
131 padrow = (seqd_p[rcb][mz]->sequence[i]>>8)& 0x7f;
132 pad = (seqd_p[rcb][mz]->sequence[i])& 0xff;
134 Row_array[padrow-1].npads++;
138 if (padrow <0 || pad <0) {
139 printf(
"encountered bad SEQD bank RB %d, Mezz %d\n", rcb+1, mz+1);
142 unsigned short work = seqd_p[rcb][mz]->sequence[i];
144 int len = work & 0x1f;
145 if (start >= oldstart) {
146 if (start>lastbin+1) Pad_array[padrow-1][pad-1].nseq++;
148 lastbin = start+len-1;
152 Row_array[padrow-1].npads++;
158 printf(
"new pad detected with bit 5 clear!\n");
170 for (row=0; row<TPC_PADROWS; row++) {
172 for (
int pad=0; pad<TPC_MAXPADS; pad++) {
173 int nseq = Pad_array[row][pad].nseq;
176 if (Pad_array[row][pad].seq==NULL) {
177 cout <<
"failed to malloc() Sequence structures " << endl;
187 for(rcb = 0; rcb < 6; rcb++) {
188 for(
int mz = 0; mz < 3; mz++) {
189 if (seqd_p[rcb][mz] == (classname(Bank_TPCSEQD) *)NULL)
continue;
190 int padrow=-1, pad=-1, lastbin=-2, pad_seq, oldstart = 0;
191 int len = seqd_p[rcb][mz]->header.BankLength - (
sizeof(
Bank_Header)/4);
192 int numseq = (4*len)/
sizeof(
short);
193 u_char *adc_locn = (u_char *)adcd_p[rcb][mz]->ADC;
194 for (
int i=0; i<numseq; i++) {
195 if (seqd_p[rcb][mz]->sequence[i]<0) {
196 padrow = (seqd_p[rcb][mz]->sequence[i]>>8)& 0x7f;
197 pad = (seqd_p[rcb][mz]->sequence[i])& 0xff;
203 unsigned short work = seqd_p[rcb][mz]->sequence[i];
205 int len = work & 0x1f;
206 if (start >= oldstart) {
208 if (start>lastbin+1) {
209 Pad_array[padrow-1][pad-1].seq[pad_seq].startTimeBin = start;
210 Pad_array[padrow-1][pad-1].seq[pad_seq].Length = len;
211 Pad_array[padrow-1][pad-1].seq[pad_seq].FirstAdc = adc_locn;
216 Pad_array[padrow-1][pad-1].seq[pad_seq].Length += len;
219 lastbin = start+len-1;
228 printf(
"new pad detected with bit 5 clear!\n");
238 TPCV1P0_ZS_SR::~TPCV1P0_ZS_SR()
240 cout <<
"Deleting TPCV1P0_ZS_SR" << endl;
242 for (
int row=0; row<TPC_PADROWS; row++) {
243 for (
int pad=0; pad<TPC_MAXPADS; pad++) {
244 void *memaddr = Pad_array[row][pad].seq;
245 if (memaddr) free(memaddr);
250 int TPCV1P0_ZS_SR::getPadList(
int PadRow, u_char **padList)
254 if (PadRow == 0 || PadRow > TPC_PADROWS)
return -1;
258 for(pad=1; pad<=TPC_MAXPADS; pad++)
260 if (Pad_array[PadRow-1][pad-1].nseq) padlist[PadRow-1][npad++] = pad;
263 *padList = &padlist[PadRow-1][0];
268 int TPCV1P0_ZS_SR::getSequences(
int PadRow,
int Pad,
int *nSeq,
271 *nSeq = Pad_array[PadRow-1][Pad-1].nseq;
272 *SeqData = Pad_array[PadRow-1][Pad-1].seq;
276 int TPCV1P0_ZS_SR::getFeeSequences(
int Fee,
int Pin,
int *nSeq,
279 unsigned short PadRow = row_vs_fee[Fee][Pin];
280 unsigned short Pad = pad_vs_fee[Fee][Pin];
281 *nSeq = Pad_array[PadRow-1][Pad-1].nseq;
282 *SeqData = Pad_array[PadRow-1][Pad-1].seq;
287 int TPCV1P0_ZS_SR::getSpacePts(
int PadRow,
int *nSpacePts,
SpacePt **SpacePts)
289 cout <<
"getSpacePoints() method not implemented" <<endl;
294 int TPCV1P0_ZS_SR::MemUsed()