136 #include "StMessMgr.h"
137 #include "StSequence.hh"
138 #include "StMCTruth.h"
139 #include "StDAQMaker/StSVTReader.h"
140 #include "StSvtClassLibrary/StSvtHybridData.hh"
141 #include "StSvtClassLibrary/StSvtHybridBadAnodes.hh"
142 #include "StSvtAnalysis.hh"
144 int Compare_Point (
const void *,
const void *);
146 StSvtAnalysis::StSvtAnalysis(
int TotalNumberOfHybrids)
149 mHybridRawData = NULL;
150 mHybridCluster = NULL;
161 mNumPixels = 0, mPeakADC = 0, mSumAdc = 0;
162 mMom0 = 0, mNeff = 0;
163 mDriftMom1 = 0, mAnodeMom1 = 0;
164 mDriftMom2 = 0, mAnodeMom2 = 0; mMom0 = 0, mNeff = 0;
165 mX_err=72., mY_err=75.;
169 setArrays(TotalNumberOfHybrids);
173 void StSvtAnalysis::setMemory()
178 mMaxClu = (mMaxClu)? mMaxClu*2 : 500;
183 void StSvtAnalysis::setArrays(
int TotalNumberOfHybrids)
186 m_countBadAn = malloc_matrix_d (TotalNumberOfHybrids+1, 240+2);
187 m_countBadTb = malloc_matrix_d (TotalNumberOfHybrids+1, 128+1);
189 if (m_countBadAn == NULL || m_countBadTb == NULL) {
190 cout<<
"You have a bad error assigning memory for counting bad SVT pixels"<<endl;
191 if (m_countBadAn==NULL) free_matrix_d(m_countBadAn, 240+2);
192 if (m_countBadTb==NULL) free_matrix_d(m_countBadTb, 128+1);
195 m_Pixels = malloc_matrix_d (240+2, 128+2);
196 m_Shadow = malloc_matrix_d (240+2, 128+2);
197 m_Raw = malloc_matrix_d (240+2, 128+2);
199 if (m_Pixels == NULL || m_Shadow == NULL || m_Raw == NULL) {
200 cout<<
"You have a fatal error in assigning memory in the cluster finder"<<endl;
201 if (m_Pixels) free_matrix_d (m_Pixels, 240+2);
202 if (m_Shadow) free_matrix_d (m_Shadow, 240+2);
203 if (m_Raw) free_matrix_d (m_Raw , 240+2);
206 for (
int i1=0;i1<242;i1++) {
207 for (
int j1=0;j1<130;j1++) {
208 m_Pixels[i1][j1] = 0;
209 m_Shadow[i1][j1] = 0;
217 StSvtAnalysis::~StSvtAnalysis()
225 int NumberOfHybrids,
int PedOffset )
230 mHybridData = hybAdjData;
231 mHybridRawData = hybRawData;
232 mHybridCluster = hybClu;
233 mPedOffset = PedOffset;
234 mSvtBadAnode = BadAnodes;
236 mNumOfClusters = mHybridCluster->getNumberOfClusters();
237 if (mNumOfClusters>mMaxClu) setMemory();
241 {
for (
int i=0; i<NumberOfHybrids; i++) {
242 {
for (
int j=0; j<242; j++) m_countBadAn[i][j] = 0;}
243 {
for (
int j=0; j<129; j++) m_countBadTb[i][j] = 0;}
249 void StSvtAnalysis::FirstAndLastAnodes()
252 int actualAn = 0, actualan = 0, mem = 0;
254 if (mNumOfClusters>mMaxClu) setMemory();
256 for(
int clu = 0; clu < mNumOfClusters; clu++)
260 mNumOfMembers = mHybridCluster->getNumberOfMembers(clu);
261 aux->mInfo = mHybridCluster->getCluMemInfo(clu);
266 aux->mCluFirstAnode = aux->mInfo[mem].actualAnode;
267 aux->mCluLastAnode = aux->mCluFirstAnode;
271 {
for(
int j = 1; j<mNumOfMembers ; j++)
273 actualAn = aux->mInfo[mem].actualAnode;
274 actualan = aux->mInfo[j].actualAnode;
276 if(actualAn < actualan)
277 aux->mCluFirstAnode = actualAn;
280 aux->mCluFirstAnode= actualan;
286 {
for(
int j = 1; j<mNumOfMembers ; j++)
288 actualAn = aux->mInfo[mem].actualAnode;
289 actualan = aux->mInfo[j].actualAnode;
291 if(actualAn > actualan)
292 aux->mCluLastAnode = actualAn;
296 aux->mCluLastAnode = actualan;
306 void StSvtAnalysis::CluFirstTimeBin()
309 int status , Seq, SeqStart = 0, seqStart = 0;
310 int listAn = 0, mseq = 0, mem;
313 if (mNumOfClusters>mMaxClu) setMemory();
315 for(
int clu = 0; clu < mNumOfClusters; clu++)
318 aux->mInfo = mHybridCluster->getCluMemInfo(clu);
319 mNumOfMembers = mHybridCluster->getNumberOfMembers(clu);
325 listAn = aux->mInfo[mem].listAnode;
326 mseq = aux->mInfo[mem].seq;
328 status = mHybridData->getListSequences(listAn,Seq,mSvtSequence);
329 aux->mCluFirstTimeBin = mSvtSequence[mseq].startTimeBin;
333 for(
int j = 1; j< mNumOfMembers; j++)
335 listAn = aux->mInfo[mem].listAnode;
336 mseq = aux->mInfo[mem].seq;
337 status = mHybridData->getListSequences(listAn,Seq,mSvtSequence);
338 SeqStart = mSvtSequence[mseq].startTimeBin;
340 listAn = aux->mInfo[j].listAnode;
341 mseq = aux->mInfo[j].seq;
342 status = mHybridData->getListSequences(listAn,Seq,mSvtSequence);
343 seqStart = mSvtSequence[mseq].startTimeBin;
345 if(SeqStart <= seqStart)
346 aux->mCluFirstTimeBin = SeqStart;
349 aux->mCluFirstTimeBin = seqStart;
358 void StSvtAnalysis::CluLastTimeBin()
361 int status , Seq, SeqStart = 0, SeqLength = 0, SeqEnd = 0, seqEnd = 0;
362 int listAn = 0, mseq = 0, mem;
365 if (mNumOfClusters>mMaxClu) setMemory();
367 for(
int clu = 0; clu < mNumOfClusters; clu++)
369 mAux[clu].mInfo = mHybridCluster->getCluMemInfo(clu);
370 mNumOfMembers = mHybridCluster->getNumberOfMembers(clu);
376 listAn = mAux[clu].mInfo[mem].listAnode;
377 mseq = mAux[clu].mInfo[mem].seq;
378 status = mHybridData->getListSequences(listAn,Seq,mSvtSequence);
379 SeqStart = mSvtSequence[mseq].startTimeBin;
380 SeqLength = mSvtSequence[mseq].length;
381 SeqEnd = SeqStart + SeqLength - 1;
382 mAux[clu].mCluLastTimeBin = SeqEnd;
386 for(
int j = 1; j< mNumOfMembers ; j++){
387 listAn = mAux[clu].mInfo[mem].listAnode;
388 mseq = mAux[clu].mInfo[mem].seq;
389 status = mHybridData->getListSequences(listAn,Seq,mSvtSequence);
391 SeqStart = mSvtSequence[mseq].startTimeBin;
392 SeqLength = mSvtSequence[mseq].length;
393 SeqEnd = SeqStart + SeqLength - 1;
395 listAn = mAux[clu].mInfo[j].listAnode;
396 mseq = mAux[clu].mInfo[j].seq;
397 status = mHybridData->getListSequences(listAn,Seq,mSvtSequence);
399 SeqStart = mSvtSequence[mseq].startTimeBin;
400 SeqLength = mSvtSequence[mseq].length;
401 seqEnd = SeqStart + SeqLength - 1;
404 mAux[clu].mCluLastTimeBin = SeqEnd;
406 mAux[clu].mCluLastTimeBin = seqEnd;
414 void StSvtAnalysis::MomentAnalysis(){
422 if (m_hybIndex==6) m_SvtEvt++;
427 if(mNumOfClusters > mMaxClu) setMemory();
429 m_clu = mNumOfClusters-1;
431 for(
int clu = 0; clu < mNumOfClusters; clu++){
443 void StSvtAnalysis::LoadAnodeGains()
468 for (
int i=0;i<433;i++){
469 for (
int j=0;j<241;j++){
478 void StSvtAnalysis::calcMoments(
int clu){
479 int listAn , actualAn, numAnodes;
480 int mseq, Seq, stTimeBin, len;
484 mNumPixels = 0, mPeakADC = 0,mSumAdc = 0, mHitId=0;
485 mDriftMom1 = 0, mAnodeMom1 = 0, mDriftMom2 = 0, mAnodeMom2 = 0, mMom0 = 0, mNeff = 0;
487 int igt3=0, peakPosAn=0, peakPosTim=0, peakMem=0, peakPixel=0;
489 aux->mInfo = mHybridCluster->getCluMemInfo(clu);
490 mNumOfMembers = mHybridCluster->getNumberOfMembers(clu);
492 numAnodes = GetLastAnode(clu)-GetFirstAnode(clu)+1;
495 for(
int mem = 0; mem < mNumOfMembers; mem++) {
496 listAn = aux->mInfo[mem].listAnode;
497 mseq = aux->mInfo[mem].seq;
498 actualAn = aux->mInfo[mem].actualAnode;
500 mHybridData->getListSequences(listAn,Seq,mSvtSequence);
501 stTimeBin = mSvtSequence[mseq].startTimeBin;
502 len = mSvtSequence[mseq].length;
503 adc = mSvtSequence[mseq].firstAdc;
504 for(
int j = 0; j < len; j++) {
506 if (ADC==0 || ADC==255) ADC=ADC;
507 else ADC=ADC-mPedOffset;
509 ADC=ADC*mAnodeGain[m_hybIndex][actualAn];
512 mPeakADC=(int)ADC; peakPosAn=actualAn; peakPosTim=stTimeBin+j; peakMem=mem; peakPixel=j;
515 if (ADC>1 && ADC<4000 && (stTimeBin+j)>=0 && (stTimeBin+j)<128 && actualAn>0 && actualAn<=240){
518 mDriftMom1 += ADC * (stTimeBin + j + 0.5);
519 mAnodeMom1 += ADC * (actualAn - 0.5);
520 mDriftMom2 += ADC * (stTimeBin + j + 0.5) * (stTimeBin + j + 0.5);
521 mAnodeMom2 += ADC * (actualAn - 0.5) * (actualAn - 0.5);
522 mNeff += (int)(ADC * ADC);
534 if(numAnodes == 1 || numAnodes == 2){
536 oneOrTwoAnodeMoments(clu, peakPosTim);
540 finalMoments(clu, numAnodes);
541 newCluster(clu, numAnodes,igt3);
545 void StSvtAnalysis::oneOrTwoAnodeMoments(
int clu,
int peakPosTim)
553 iAst = GetFirstAnode(clu); iAend = GetLastAnode(clu);
556 if (iAst>1 && iAend<240 && peakPosTim>0 && peakPosTim<127){
557 for (
int i=iAst-1; i<=iAend+1; i++)
560 if (i==iAst || i==iAend)
continue;
561 for (
int j=peakPosTim-1; j<=peakPosTim+1; j++)
563 ADC = (float)m_Raw[i][j];
564 ADC=ADC*mAnodeGain[m_hybIndex][i];
566 if (ADC>0 && ADC<mPeakADC/2){
568 mDriftMom1 += ADC * (j+0.5);
569 mAnodeMom1 += ADC * (i-0.5);
570 mDriftMom2 += ADC * (j+0.5) * (j+0.5);
571 mAnodeMom2 += ADC * (i-0.5) * (i-0.5);
572 mNeff += int(ADC * ADC);
581 void StSvtAnalysis::finalMoments(
int clu,
int numAnodes)
586 mMom0 = (double)mSumAdc;
587 mDriftMom1 = (double)mDriftMom1/mSumAdc;
588 mAnodeMom1 = (double)mAnodeMom1/mSumAdc;
589 mDriftMom2 = ::sqrt((
double)mDriftMom2/mSumAdc - mDriftMom1*mDriftMom1);
590 mAnodeMom2 = ::sqrt((
double)mAnodeMom2/mSumAdc - mAnodeMom1*mAnodeMom1);
591 if (mDriftMom2>1000 || mDriftMom2<0 || mAnodeMom2>1000 || mAnodeMom2<0)
593 mDriftMom2 = -999; mAnodeMom2 = -999; mNeff = 0;
598 double Neff = (double) mSumAdc*mSumAdc/mNeff;
601 mDriftMom2 = mDriftMom2 * ::sqrt( (
double(mNeff)/(mNeff-1)) );
602 mAnodeMom2 = mAnodeMom2 * ::sqrt( (
double(mNeff)/(mNeff-1)) );
603 if (mDriftMom2!=0) mY_err = 260.e-4*mDriftMom2/::sqrt(
double(mNeff));
604 if (mAnodeMom2!=0) mX_err = 250.e-4*mAnodeMom2/::sqrt(
double(mNeff));
607 if (numAnodes==1 && mAnodeMom2==0) mAnodeMom2=0.288;
608 if ( (GetLastTimeBin(clu)-GetFirstTimeBin(clu))==0 && mDriftMom2==0) mDriftMom2=0.288;
625 void StSvtAnalysis::newCluster(
int clu,
int numAnodes,
int igt3)
629 static int iRows=1, iCols=1;
633 aux->mCluDeconvID = clu;
634 aux->mCluCharge = mMom0;
636 aux->m_oneortwo_flag = mMyflag;
637 aux->mMeanClusterTimeBin = mDriftMom1;
638 aux->mMeanClusterAnode = mAnodeMom1;
639 aux->mSecondMomClusterTimeBin = mDriftMom2;
640 aux->mSecondMomClusterAnode = mAnodeMom2;
641 aux->mCluXCov = 1.*mX_err*mX_err;
642 aux->mCluYCov = 4.*mY_err*mX_err;
643 aux->mCluPeakAdc = mPeakADC;
644 aux->mCluNumPixels = mNumPixels;
645 aux->mCluNumAnodes = numAnodes;
646 aux->mHybridNum = m_hybIndex;
649 for (
int i1=0;i1<iRows;i1++)
651 for (
int j1=0;j1<iCols;j1++)
653 m_Pixels[i1][j1] = 0;
654 m_Shadow[i1][j1] = 0;
660 iRows = mAux[clu].mCluLastAnode - mAux[clu].mCluFirstAnode +1+2;
661 iCols = mAux[clu].mCluLastTimeBin - mAux[clu].mCluFirstTimeBin +1+2;
663 Fill_Pixel_Array(clu);
664 iQual = CatagorizeCluster(iRows,iCols,igt3,clu);
666 aux->mCluFlag = mHitId;
667 if (mHitId==0 && m_deconv==1) iRetu = Deconvolve_Cluster(iRows, iCols, clu);
669 if( (
int)(.5+mAnodeMom1) > 0 && (
int)(.5+mAnodeMom1) <= 241 )
670 m_countBadAn[m_hybIndex][(int)(.5+mAnodeMom1)]++;
671 if( (
int)(.5+mDriftMom1) >= 0 && (
int)(.5+mDriftMom1) <= 128)
672 m_countBadTb[m_hybIndex][(int)(.5+mDriftMom1)]++;
680 int StSvtAnalysis:: CatagorizeCluster(
int iRows,
int iCols,
int igt3,
int clu)
687 int i, iUnderBkt, iWrgBkt;
690 int d_bkt=0, d_sig=0;
692 static int iNumCat = 0;
699 if ((m_hybIndex==293 && (mAnodeMom1>195 && mAnodeMom1<205) && (mDriftMom1>80 && mDriftMom1<100)) ||
700 (m_hybIndex==416 && (mAnodeMom1>195 && mAnodeMom1<203) && (mDriftMom1>85 && mDriftMom1<100)) ||
701 (m_hybIndex==416 && (mAnodeMom1>195 && mAnodeMom1<203) && (mDriftMom1>110 && mDriftMom1<125)) ) {
711 if (aux->mCluNumAnodes ==1){
712 if(aux->mCluPeakAdc < 11) iQual = 11;
713 if(aux->mCluNumPixels >10) iQual = 10;
722 int secondary_peak_after=0;
723 int secondary_peak_before=0;
724 int member_high_limit=0;
725 int member_low_limit=0;
726 for (
int i1=0;i1<iRows;i1++){
729 for (
int j1=m_col_p;j1<iCols-1;j1++){
730 if (m_Pixels[i1][j1+1] > (m_Pixels[i1][j1]+my_noise)) secondary_peak_after++;
732 for (
int j2=m_col_p;j2>0;j2--){
733 if (m_Pixels[i1][j2-1] > (m_Pixels[i1][j2]+my_noise)) secondary_peak_before++;
736 if (secondary_peak_after>0) iQual=13;
737 if (secondary_peak_before>0) iQual=15;
741 fThres = -0.03*(float)m_adc_p;
744 while (iUnderBkt==127 && i!=iCols-1)
746 if ( (m_Pixels[m_row_p][i]+m_Pixels[m_row_p][i+1])/2. < fThres) iUnderBkt = i;
751 fThres = -0.3*(float)m_adc_p;
754 while (iWrgBkt==0 && i!=1)
756 if ( (m_Pixels[m_row_p][i]+m_Pixels[m_row_p][i-1])/2. < fThres) iWrgBkt = i;
762 if (iWrgBkt>=1) { iQual += 16; m_nWrkBkt++;}
763 if (igt3<3 && (aux->mCluCharge<15 || aux->mCluNumPixels<4)) { iQual += 32; m_nGt8++; }
764 if ((aux->mSecondMomClusterTimeBin>4*aux->mSecondMomClusterAnode &&
765 aux->mSecondMomClusterAnode <1 && aux->mSecondMomClusterAnode>0) ||
766 (aux->mSecondMomClusterAnode >4*aux->mSecondMomClusterTimeBin &&
767 aux->mSecondMomClusterTimeBin<1 && aux->mSecondMomClusterTimeBin>0) )
768 { iQual += 64; m_nSig++; }
770 if ( (aux->mSecondMomClusterTimeBin>6*aux->mSecondMomClusterAnode) ||
771 (aux->mSecondMomClusterAnode>6*aux->mSecondMomClusterTimeBin) )
772 { iQual += 65; m_nSig++; }
777 if (iUnderBkt>m_col_p-2){
781 fCut = fabs(1.15*aux->mSecondMomClusterTimeBin - aux->mSecondMomClusterAnode);
782 if ( (fCut<=0.5 && aux->mSecondMomClusterAnode<1.25 && aux->mSecondMomClusterTimeBin<1.25) ||
783 (aux->mSecondMomClusterAnode<0.5 && aux->mSecondMomClusterTimeBin<0.5))
788 if (aux->mCluNumAnodes>1 && (d_sig==1 || (aux->mCluCharge>80 && d_bkt==1))) m_deconv = 1;
801 int StSvtAnalysis::Deconvolve_Cluster(
int iRows,
int iCols,
int clu)
811 Peaks = Find_Peaks(iRows, iCols, &iNumPeaks);
812 if (Peaks==NULL)
return 0;
813 if (iNumPeaks==0) iNumPeaks=1;
815 if (Peaks && iNumPeaks>1)
817 iRetu = Fit_Peaks(iRows, iCols, iNumPeaks, Peaks, clu);
818 if (iRetu==0)
return 0;
831 POINT* StSvtAnalysis::Find_Peaks (
int iRows,
int iCols,
int *iNumPeaks)
834 static POINT Peaks[10];
838 Array =
new POINT[(iRows+2) * (iCols+2)];
846 for (i=1; i<iRows-1; i++)
847 for (j=1; j<iCols-1; j++)
851 Array[k].val = m_Pixels[i][j];
856 qsort (Array, k,
sizeof (
POINT), Compare_Point);
861 for (i = 0; i < k && *iNumPeaks <10; i++)
867 if (m_Shadow[x][y] == 0 && m_Pixels[x][y] > 6)
869 Peaks[*iNumPeaks].x = x;
870 Peaks[*iNumPeaks].y = y;
871 Peaks[*iNumPeaks].val = Array[i].val;
872 Peaks[*iNumPeaks].error = Array[i].error;
873 if ((valley=IsValidPeak (iRows, iCols, Peaks, *iNumPeaks)))
875 Peaks[*iNumPeaks].error = valley;
877 if (*iNumPeaks==2) Peaks[0].error = Peaks[1].error;
898 int Compare_Point (
const void *a,
const void *b)
900 return (
int)(
static_cast<const POINT*
>(b)->val - static_cast<const POINT*>(a)->val);
916 float StSvtAnalysis::IsValidPeak(
int iRows,
int iCols,
POINT *Peaks,
int iNumPeaks)
918 int Px = Peaks[iNumPeaks].x, Py = Peaks[iNumPeaks].y, i;
920 float val=0, peak=1, valley=0;
923 for (i = 0; i < iNumPeaks; i++)
928 dx = Peaks[i].x - Px;
929 dy = Peaks[i].y - Py;
932 fSlope = (float) dx / (
float) dy;
936 peak = valley = val = (float) m_Pixels[Px][Py];
941 while (dx!=0 || dy!=0)
944 dy = (int)(dx /fSlope);
947 if (dy>0) dy--;
if (dy<0) dy++;
949 val = m_Pixels[Px + dx][Py + dy];
951 if (val<valley && val!=0 && val!=1) valley = val;
963 if (valley>0.75*peak)
return 0;
975 else if (pval>=0.2 && pval<0.5)
990 int StSvtAnalysis::Fit_Peaks(
int iRows,
int iCols,
int iNumPeaks,
POINT *Peaks,
int clu)
999 int iFirstAnode, iFirstTime;
1001 mAux[clu].mCluFlag += 128;
1003 CovX = mAux[clu].mCluXCov;
1004 CovY = mAux[clu].mCluYCov;
1005 MomX = mAux[clu].mSecondMomClusterAnode;
1006 MomY = mAux[clu].mSecondMomClusterTimeBin;
1008 iFirstAnode = mAux[clu].mCluFirstAnode-1;
1009 iFirstTime = mAux[clu].mCluFirstTimeBin-1;
1011 for (i = 0; i < iNumPeaks; i++)
1013 if (Peaks[i].x < 0 || Peaks[i].x > iRows)
1015 if (Peaks[i].y < 0 || Peaks[i].y > iCols)
1018 iSum1 = iSum = iX = iY = 0;
1019 for (j = Peaks[i].x - 1; j <= Peaks[i].x + 1; j++)
1021 for (k = Peaks[i].y - 1; k <= Peaks[i].y + 1; k++)
1023 iSum1 += m_Pixels[j][k];
1024 if (m_Pixels[j][k]>0)
1026 iSum += m_Pixels[j][k];
1027 iX += (j) * m_Pixels[j][k];
1028 iY += (k) * m_Pixels[j][k];
1033 if (iSum1 <=0)
continue;
1036 if (m_clu>mMaxClu) setMemory();
1038 fX = (double) iX / iSum;
1039 fY = (double) iY / iSum;
1041 mAux[m_clu].mCluID = m_clu;
1042 mAux[m_clu].mCluDeconvID = clu;
1043 mAux[m_clu].mMeanClusterAnode = fX + iFirstAnode+0.5;
1044 mAux[m_clu].mMeanClusterTimeBin = fY + iFirstTime+0.5;
1045 mAux[m_clu].mCluPeakAdc = (int)Peaks[i].val;
1046 mAux[m_clu].mCluCharge = iSum;
1047 mAux[m_clu].mCluFlag = 2;
1048 mAux[m_clu].mSecondMomClusterTimeBin = MomX;
1049 mAux[m_clu].mSecondMomClusterAnode = MomY;
1051 mAux[m_clu].mCluXCov = ::sqrt(2.)*CovX*Peaks[i].error;
1052 mAux[m_clu].mCluYCov = ::sqrt(2.)*CovY*Peaks[i].error;
1053 mAux[m_clu].mCluNumPixels = 9999;
1054 mAux[m_clu].mCluNumAnodes = 9999;
1070 int StSvtAnalysis::BlockOut (
int x,
int y)
1073 m_Shadow[x-1][y-1] = 1;
1074 m_Shadow[x-1][ y ] = 1;
1075 m_Shadow[x-1][y+1] = 1;
1077 m_Shadow[ x ][y-1] = 1;
1078 m_Shadow[ x ][ y ] = 1;
1079 m_Shadow[ x ][y+1] = 1;
1081 m_Shadow[x+1][y-1] = 1;
1082 m_Shadow[x+1][ y ] = 1;
1083 m_Shadow[x+1][y+1] = 1;
1094 int** StSvtAnalysis::malloc_matrix_d (
int iRows,
int iCols)
1096 int **Array =
new int*[iRows];
1097 int *buf =
new int[iRows*iCols];
1098 memset(buf,0,
sizeof(
int)*iRows*iCols);
1099 for (
int i = 0; i < iRows; i++){Array[i] = buf; buf+=iCols;}
1113 void StSvtAnalysis::free_matrix_d (
int *Array[],
int )
1126 int StSvtAnalysis::Fill_Pixel_Array(
int clu)
1130 int listAn, mseq, actualAn, stTimeBin, len, Seq;
1139 mAux[clu].mInfo = mHybridCluster->getCluMemInfo(clu);
1140 mNumOfMembers = mHybridCluster->getNumberOfMembers(clu);
1144 for(
int mem = 0; mem < mNumOfMembers; mem++)
1146 listAn = mAux[clu].mInfo[mem].listAnode;
1147 mseq = mAux[clu].mInfo[mem].seq;
1148 actualAn = mAux[clu].mInfo[mem].actualAnode;
1150 mHybridData->getListSequences(listAn,Seq,mSvtSequence);
1151 stTimeBin = mSvtSequence[mseq].startTimeBin;
1152 adc = mSvtSequence[mseq].firstAdc;
1154 len = mSvtSequence[mseq].length + 1-1;
1155 iRow = actualAn - mAux[clu].mCluFirstAnode + 1;
1156 iCol = stTimeBin - mAux[clu].mCluFirstTimeBin + 1;
1160 for (
int j=0; j<len; j++) {
1161 if (iRow<1 || iCol+j<1 || iRow>240 || iCol+j>128) {
1162 cout<<
"Problem in Fill Pixel Array. iRow: " << iRow <<
" iCol: " << iCol+j<<endl;
1166 (val==0 || val==255) ? val=val : val=val-mPedOffset;
1167 m_Pixels[iRow][iCol+j] =val;
1178 int StSvtAnalysis::FillRawAdc()
1182 int numAnodes,actualAn,numOfSeq,seqStart,seqLength;
1191 numAnodes = mHybridRawData->getAnodeList(anodeList);
1195 for(
int an = 0; an < numAnodes; an++) {
1196 actualAn = anodeList[an];
1198 if(mSvtBadAnode->isBadAnode(actualAn))
continue;
1199 mHybridRawData->getListSequences(an,numOfSeq,svtSequence);
1200 for(
int seq = 0; seq < numOfSeq; seq++) {
1201 seqStart = svtSequence[seq].startTimeBin;
1202 seqLength = svtSequence[seq].length;
1203 adc = svtSequence[seq].firstAdc;
1204 for (
int j=0; j<seqLength; j++) {
1206 (ADC==0 || ADC==255) ? ADC=ADC : ADC=ADC-mPedOffset;
1207 m_Raw[actualAn][seqStart+j] = ADC;
1224 void StSvtAnalysis::ClearRawAdc()
1226 for (
int i1=0;i1<242;i1++) {
1227 for (
int j1=0;j1<130;j1++) {
1234 void StSvtAnalysis::SetBadAnTb(
int nClus)
1241 for (
int i=0; i<nClus; i++) {
1242 iHyb = mAux[i].mHybridNum;
1243 iAn = (int)(.5+mAux[i].mMeanClusterAnode);
1244 iTb = (int)(.5+mAux[i].mMeanClusterTimeBin);
1245 if( iAn >=1 && iAn < 242){
1246 if (m_countBadAn[iHyb][iAn]>4) {mAux[i].mCluFlag += 4;}
1248 if( iTb >=0 && iTb < 129){
1249 if (m_countBadTb[iHyb][iTb]>4) {mAux[i].mCluFlag += 4;}
1256 void StSvtAnalysis::SetHybIndex(
int index)
1261 int StSvtAnalysis::GetnSvtClu()
1266 int StSvtAnalysis::GetCluID(
int clu)
1268 return mAux[clu].mCluID;
1271 int StSvtAnalysis::GetCluDeconvID(
int clu)
1273 return mAux[clu].mCluDeconvID;
1276 int StSvtAnalysis::GetFirstAnode(
int clu)
1278 return mAux[clu].mCluFirstAnode;
1281 int StSvtAnalysis::GetLastAnode(
int clu)
1283 return mAux[clu].mCluLastAnode;
1286 int StSvtAnalysis::GetFirstTimeBin(
int clu)
1288 return mAux[clu].mCluFirstTimeBin;
1291 int StSvtAnalysis::GetLastTimeBin(
int clu)
1293 return mAux[clu].mCluLastTimeBin;
1297 int StSvtAnalysis::GetCluFlag(
int clu)
1299 return mAux[clu].mCluFlag;
1302 double StSvtAnalysis::GetCluCharge(
int clu)
1304 return mAux[clu].mCluCharge;
1307 int StSvtAnalysis::GetDeconvFlag(
int clu)
1312 double StSvtAnalysis::GetMeanClusterAnode(
int clu)
1314 return mAux[clu].mMeanClusterAnode;
1317 double StSvtAnalysis::GetMeanClusterTimeBin(
int clu)
1319 return mAux[clu].mMeanClusterTimeBin;
1322 double StSvtAnalysis::GetSecondMomClusterAnode(
int clu)
1324 return mAux[clu].mSecondMomClusterAnode;
1327 double StSvtAnalysis::GetSecondMomClusterTimeBin(
int clu)
1329 return mAux[clu].mSecondMomClusterTimeBin;
1332 double StSvtAnalysis::GetCluXCov(
int clu)
1334 return mAux[clu].mCluXCov;
1337 double StSvtAnalysis::GetCluYCov(
int clu)
1339 return mAux[clu].mCluYCov;
1342 int StSvtAnalysis::GetCluPeakAdc(
int clu)
1344 return mAux[clu].mCluPeakAdc;
1347 int StSvtAnalysis::GetCluNumPixels(
int clu)
1349 return mAux[clu].mCluNumPixels;
1352 int StSvtAnalysis::GetCluNumAnodes(
int clu)
1354 return mAux[clu].mCluNumAnodes;
1357 int StSvtAnalysis::GetTruth(
int clu)
1359 return mAux[clu].mTruth;
1361 int StSvtAnalysis::return_oneortwoanode_flag(
int clu)
1363 return mAux[clu].m_oneortwo_flag;
1365 void StSvtAnalysis::updateTruth()
1369 int listAn = 0, mseq = 0, mem;
1372 for(
int clu = 0; clu < mNumOfClusters; clu++)
1375 if (!aux->mInfo)
continue;
1376 mNumOfMembers = mHybridCluster->getNumberOfMembers(clu);
1380 for(
int j = 0; j< mNumOfMembers; j++){
1381 listAn = aux->mInfo[mem].listAnode;
1382 mseq = aux->mInfo[mem].seq;
1383 status = mHybridData->getListTruth(listAn,nTru,truList);
1384 if (!truList)
return;
1385 pivo.Add(truList[mseq]);
1387 aux->mTruth = int(pivo.Get());