47 #include <sys/types.h>
52 #include "StDaqLib/GENERIC/EventReader.hh"
53 #include "StDAQReader.h"
54 #include "StTPCReader.h"
57 StTPCReader::StTPCReader(
StDAQReader *daqr,
char mergeSequences)
59 mMergeSequences=mergeSequences;
64 fZeroSuppressedReader = 0;
67 fPedestalRMSReader = 0;
70 fBadChannelReader = 0;
74 int StTPCReader::Update()
79 int StTPCReader::empty()
81 if(!fTPCImpReader) Update();
82 return (!fTPCImpReader);
85 StTPCReader::~StTPCReader()
89 int StTPCReader::close()
91 delete fZeroSuppressedReader; fZeroSuppressedReader = 0;
92 delete fADCRawReader ; fADCRawReader = 0;
93 delete fPedestalReader ; fPedestalReader = 0;
94 delete fPedestalRMSReader; fPedestalRMSReader = 0;
95 delete fGainReader; fGainReader = 0;
96 delete fCPPReader; fCPPReader = 0;
97 delete fBadChannelReader; fBadChannelReader = 0;
98 delete fTPCImpReader; fTPCImpReader = 0;
104 int StTPCReader::setSector(
int sector)
106 if (fTPCImpReader && sector == fSector)
return 0;
108 delete fZeroSuppressedReader; fZeroSuppressedReader = 0;
109 delete fADCRawReader ; fADCRawReader = 0;
110 delete fPedestalReader ; fPedestalReader = 0;
111 delete fPedestalRMSReader; fPedestalRMSReader = 0;
112 delete fGainReader; fGainReader = 0;
113 delete fCPPReader; fCPPReader = 0;
114 delete fBadChannelReader; fBadChannelReader = 0;
116 if (!fTPCImpReader || sector == -1) {
117 delete fTPCImpReader;
119 fTPCImpReader = ::getDetectorReader(fDAQReader->getEventReader(),fDAQReader->getTPCVersion());
122 if(!fTPCImpReader)
return 1;
123 ptrTPCP=fTPCImpReader->motherPointerBank;
124 if (sector == -1)
return 0;
129 assert(fTPCImpReader);
130 assert( fSector<90 && (mMergeSequences==1||mMergeSequences==0) );
131 fZeroSuppressedReader = fTPCImpReader->getZeroSuppressedReader(fSector+100*mMergeSequences);
132 fADCRawReader = fTPCImpReader->getADCRawReader(fSector);
133 fPedestalReader = fTPCImpReader->getPedestalReader(fSector);
134 fPedestalRMSReader = fTPCImpReader->getPedestalRMSReader(fSector);
135 fGainReader = fTPCImpReader->getGainReader(fSector);
136 fCPPReader = fTPCImpReader->getCPPReader(fSector);
137 fBadChannelReader = fTPCImpReader->getBadChannelReader(fSector);
144 int StTPCReader::getMaxPad(
int padrow)
const
146 const unsigned char PADS[45] = {
147 88, 96,104,112,118,126,134,142,150,
148 158,166,174,182, 98,100,102,104,106,
149 106,108,110,112,112,114,116,118,120,
150 122,122,124,126,128,128,130,132,134,
151 136,138,138,140,142,144,144,144,144};
153 assert(padrow>0 && padrow <=45);
154 return PADS[padrow-1];
158 int StTPCReader::getPadList(
int Sector,
int PadRow,
unsigned char *&padList)
160 if (setSector(Sector))
return -1;
161 if (!fZeroSuppressedReader)
return -1;
162 return fZeroSuppressedReader->getPadList(PadRow, &padList);
165 int StTPCReader::getSequences(
int Sector,
int PadRow,
int Pad,
int &nSeq,
168 if (setSector(Sector))
return -1;
169 nSeq = 0; SeqData = 0;
170 if (!fZeroSuppressedReader)
return -1;
172 int iret = fZeroSuppressedReader->getSequences(PadRow,Pad,&nSeq,&seq);
179 int StTPCReader::getRawADC(
int Sector,
int PadRow,
int Pad,
int &nArray,
180 unsigned char *&Array)
182 if (setSector(Sector))
return -1;
184 if (!fADCRawReader)
return -1;
185 return fADCRawReader->getSequences(PadRow,Pad,&nArray,&Array);
188 int StTPCReader::getPedestals(
int Sector,
int PadRow,
int Pad,
int &nArray,
189 unsigned char *&Array)
191 if (setSector(Sector))
return -1;
193 if (!fPedestalReader)
return -1;
194 return fPedestalReader->getSequences(PadRow,Pad,&nArray,&Array);
197 int StTPCReader::getRMSPedestals(
int Sector,
int PadRow,
int Pad,
int &nArray,
198 unsigned char *&Array)
200 if (setSector(Sector))
return -1;
202 if (!fPedestalRMSReader)
return -1;
203 return fPedestalRMSReader->getSequences(PadRow,Pad,&nArray,&Array);
206 int StTPCReader::getGain(
int Sector,
int PadRow,
int Pad,
TPCGain *&gain)
208 if (setSector(Sector))
return -1;
210 if (!fGainReader)
return -1;
212 int iret = fGainReader->getGain(PadRow,Pad,&gainqq);
218 int StTPCReader::getClusters(
int Sector,
int PadRow,
int Pad,
int &nClusters,
221 if (setSector(Sector))
return -1;
222 nClusters=0; clusters=0;
223 if (!fCPPReader)
return -1;
225 int iret = fCPPReader->getClusters(PadRow,Pad,&nClusters,&clustersqq);
231 int StTPCReader::IsBad(
int Sector,
int PadRow,
int Pad)
233 if (setSector(Sector))
return -1;
234 if (!fBadChannelReader)
return -1;
235 return fBadChannelReader->IsBad(PadRow,Pad);
238 void StTPCReader::SetSequenceMerging (
char mergeSequences)
240 mMergeSequences=mergeSequences;