36 #include "StFtpcRawWriter.hh"
37 #include "StMessMgr.h"
39 StFtpcRawWriter::StFtpcRawWriter(St_fcl_ftpcndx *ftpcndxIn,
40 St_fcl_ftpcsqndx *ftpcsqndxIn,
41 St_fcl_ftpcadc *ftpcadcIn,
42 const int inAsic2EastNotInverted)
45 ftpcsqndx=ftpcsqndxIn;
47 mAsic2EastNotInverted = inAsic2EastNotInverted;
49 ndx=ftpcndx->GetTable();
50 numNdx=ftpcndx->GetNRows();
51 maxNdx=ftpcndx->GetTableSize();
52 sqndx=ftpcsqndx->GetTable();
53 numSqndx=ftpcsqndx->GetNRows();
54 maxSqndx=ftpcsqndx->GetTableSize();
55 adc=ftpcadc->GetTable();
56 numAdc=ftpcadc->GetNRows();
57 maxAdc=ftpcadc->GetTableSize();
58 LOG_INFO <<
"FTPC RawWriter created with Asic2EastNotInverted = " << mAsic2EastNotInverted <<endm;
61 StFtpcRawWriter::~StFtpcRawWriter()
63 ftpcndx->SetNRows(numNdx);
64 ftpcsqndx->SetNRows(numSqndx);
65 ftpcadc->SetNRows(numAdc);
72 int StFtpcRawWriter::writeArray(
float *array,
88 float *cArray =
new float[numberPadrows
99 for (
int row=0; row<numberPadrows; row++) {
100 for (
int sec=0; sec<numberSectors; sec++) {
101 for (
int pad=0; pad<numberPads; pad++) {
102 for (
int bin=0; bin<numberTimebins; bin++) {
106 +numberTimebins*numberPads*sec
107 +numberTimebins*numberPads*numberSectors*row;
109 if (mAsic2EastNotInverted && (pad>63)&&(pad<96))
112 +numberTimebins*numberPads*sec
113 +numberTimebins*numberPads*numberSectors*row;
116 +numberTimebins*(numberPads-pad-1)
117 +numberTimebins*numberPads*sec
118 +numberTimebins*numberPads*numberSectors*row;
121 +numberTimebins*(numberPads-pad-1)
122 +numberTimebins*numberPads*(numberSectors-sec-1)
123 +numberTimebins*numberPads*numberSectors*row;
124 cArray[newi]=array[i];
131 Double_t th_high = 5;
133 Int_t minAboveLow = 2;
139 Int_t highReached = 0;
152 for (
int row=0; row<numberPadrows; row++) {
153 for (
int sec=0; sec<numberSectors; sec++) {
155 for (
int pad=0; pad<numberPads; pad++) {
158 for (
int bin=0; bin<numberTimebins; bin++) {
161 +numberTimebins*numberPads*sec
162 +numberTimebins*numberPads*numberSectors*row;
165 if((
int) cArray[i] < th_low) {
171 if((
int) cArray[i] >= th_low) {
177 for (
int t = bin; t < numberTimebins; t ++) {
180 +numberTimebins*numberPads*sec
181 +numberTimebins*numberPads*numberSectors*row;
182 if (cArray[s]>= th_low) nAboveLow++;
183 if (cArray[s]>= th_high) highReached = 1;
184 if (highReached && (nAboveLow >= minAboveLow)) {
188 if (cArray[s]< th_low) {
198 if (!valid_seq)
continue;
201 if(row>=10 && ndx[1].index==0) {
203 LOG_WARN <<
"ndx overflow!" << endm;
207 ndx[1].index=seq_index;
212 if(seq_flag == 0 || pixel_per_seq == 32) {
214 if(pixel_per_seq > 0) {
216 sqndx[seq_index++].index = (pixel_per_seq-1) + (start_pixel<<6);
219 if(seq_index >= maxSqndx) {
221 seq_index=maxSqndx -1;
222 LOG_WARN <<
"sqndx overflow!" << endm;
236 sqndx[seq_index-1].index += 32;
239 if(pad != last_pad+1) {
241 sqndx[seq_index++].index = 32768 + pad + 256*(6*row + sec);
243 if(seq_index >= maxSqndx) {
246 LOG_WARN <<
"sqndx overflow!" << endm;
254 adc[adc_index++].data=(char) cArray[i];
256 if(adc_index >= maxAdc) {
259 LOG_WARN <<
"adc overflow!" << endm;
278 if(pixel_per_seq > 0) {
280 sqndx[seq_index++].index = (pixel_per_seq-1) + (start_pixel<<6)+32;
284 numSqndx = seq_index;
288 LOG_ERROR <<
"Error! No sequences filled!" << endm;