69 #include "StSvtClusterFinder.hh"
70 #include "StSvtClassLibrary/StSvtHybridData.hh"
71 #include "StSequence.hh"
75 StSvtClusterFinder::StSvtClusterFinder()
88 for ( i=0; i<8000; i++)
89 for ( j=0; j<500; j++)
92 for ( i=0; i<240; i++)
95 for ( j=0; j<128; j++)
99 for ( i=0; i<500; i++)
106 StSvtClusterFinder::~StSvtClusterFinder()
113 mNumOfAnodes = hdata->getAnodeList(mAnolist);
117 void StSvtClusterFinder::ClusterFinder()
124 for(
int mAnode = 0; mAnode<mNumOfAnodes; mAnode++)
126 hybdata->getListSequences(mAnode,mSequence,sequence);
129 mNumSeq[mAnode] = mSequence;
130 for(
int mSeq = 0; mSeq < mSequence; mSeq++)
133 if(mSeqFlag[mAnode][mSeq] == 0)
134 getClusterMembers(mAnode,mSeq);
138 mNumOfClusters = cluIndex;
143 void StSvtClusterFinder::getClusterMembers(
int& mAnode,
int &mSeq)
145 int members, memCount , breakAn = 0, status;
146 int mSeqStart, mSeqLength, mSeqEnd;
148 int mRightFlagCounter = 0;
149 int mLeftFlagCounter = 0;
153 mCluster[cluIndex-1][memCount] = 1000*mAnode + mSeq;
156 mContainer1[0] = mCluster[cluIndex-1][memCount];
157 mSeqFlag[mAnode][mSeq] = 1;
163 for(
int mem = 0; mem < members ; mem++)
165 mAnode = mContainer1[mem]/1000;
166 mSeq = mContainer1[mem]%1000;
168 mContainer1[mem] = 0;
170 status = hybdata->getListSequences(mAnode,mSequence,sequence);
172 mSeqStart = sequence[mSeq].startTimeBin;
173 mSeqLength = sequence[mSeq].length;
174 mSeqEnd = mSeqStart + mSeqLength - 1;
176 mRightFlagCounter = getSeqOnRight(mAnode,mSeqStart, mSeqEnd, memCount, newMem);
177 mLeftFlagCounter = getSeqOnLeft(mAnode,breakAn,mSeqStart, mSeqEnd, memCount, newMem);
180 if((mem == members - 1) && newMem!=0)
183 mRightFlagCounter = 0;
184 mLeftFlagCounter = 0;
193 for(mem = 0; mem < members && j<newMem; mem++)
195 mContainer1[mem] = mContainer2[j];
199 for( j = 0; j < newMem; j++)
207 else if((mem == members - 1) && newMem==0)
211 mNumOfCluMem[cluIndex-1] = memCount;
213 if( memCount == 1 && mSeqLength==1){
228 status = hybdata->getListSequences(mAnode,mSequence,sequence);
237 int StSvtClusterFinder::getSeqOnRight(
int mAnode,
int mSeqStart,
int mSeqEnd,
int& memCount,
int& newmem)
239 int mRightAnode = 0, mRightSequence = 0, rightFlagCounter = 0, status;
240 int mRightSeqStart, mRightSeqLength, mRightSeqEnd;
242 mRightAnode = mAnode + 1;
243 if(mRightAnode != 240)
245 status = hybdata->getListSequences(mRightAnode,mRightSequence,sequence);
247 for(
int mRightSeq = 0; mRightSeq < mRightSequence ; mRightSeq++)
249 if(mAnolist[mAnode] == 240)
252 if(mAnolist[mRightAnode] != mAnolist[mAnode] + 1)
255 mRightSeqStart = sequence[mRightSeq].startTimeBin;
256 mRightSeqLength = sequence[mRightSeq].length;
257 mRightSeqEnd = mRightSeqStart + mRightSeqLength - 1;
261 if(mSeqFlag[mRightAnode][mRightSeq] == 0)
263 if(mRightSeqStart == mSeqStart)
265 mCluster[cluIndex-1][memCount] = 1000*mRightAnode + mRightSeq;
266 mSeqFlag[mRightAnode][mRightSeq] = 1;
267 mContainer2[newmem] = mCluster[cluIndex-1][memCount];
273 if((mRightSeqStart < mSeqStart)&&(mRightSeqEnd >= mSeqStart - 1))
275 mCluster[cluIndex-1][memCount] = 1000*mRightAnode + mRightSeq;
276 mSeqFlag[mRightAnode][mRightSeq] = 1;
277 mContainer2[newmem] = mCluster[cluIndex-1][memCount];
283 if((mRightSeqStart > mSeqStart)&&(mRightSeqStart <= mSeqEnd + 1))
285 mCluster[cluIndex-1][memCount] = 1000*mRightAnode + mRightSeq;
286 mSeqFlag[mRightAnode][mRightSeq] = 1;
287 mContainer2[newmem] = mCluster[cluIndex-1][memCount];
305 return rightFlagCounter;
311 int StSvtClusterFinder::getSeqOnLeft(
int mAnode,
int& breakAn,
int mSeqStart,
int mSeqEnd,
int& memCount,
int& newmem)
313 int mLeftAnode = 0, mLeftSequence = 0, leftFlagCounter = 0, status;
314 int mLeftSeqStart, mLeftSeqLength, mLeftSeqEnd;
316 mLeftAnode = mAnode - 1;
320 status = hybdata->getListSequences(mLeftAnode,mLeftSequence,sequence);
322 for(
int mLeftSeq = 0; mLeftSeq < mLeftSequence ; mLeftSeq++)
324 if(mAnolist[mAnode] == 1)
330 if(mAnolist[mLeftAnode] != mAnolist[mAnode] - 1)
336 mLeftSeqStart = sequence[mLeftSeq].startTimeBin;
337 mLeftSeqLength = sequence[mLeftSeq].length;
338 mLeftSeqEnd = mLeftSeqStart + mLeftSeqLength - 1;
341 if(mSeqFlag[mLeftAnode][mLeftSeq] == 0)
345 if(mLeftSeqStart == mSeqStart)
347 mCluster[cluIndex-1][memCount] = 1000*mLeftAnode + mLeftSeq;
348 mSeqFlag[mLeftAnode][mLeftSeq] = 1;
349 mContainer2[newmem] = mCluster[cluIndex-1][memCount];
355 if((mLeftSeqStart < mSeqStart) && (mLeftSeqEnd >= mSeqStart - 1))
357 mCluster[cluIndex-1][memCount] = 1000*mLeftAnode + mLeftSeq;
358 mSeqFlag[mLeftAnode][mLeftSeq] = 1;
359 mContainer2[newmem] = mCluster[cluIndex-1][memCount];
365 if((mLeftSeqStart > mSeqStart) && (mLeftSeqStart <= mSeqEnd + 1))
367 mCluster[cluIndex-1][memCount] = 1000*mLeftAnode + mLeftSeq;
368 mSeqFlag[mLeftAnode][mLeftSeq] = 1;
369 mContainer2[newmem] = mCluster[cluIndex-1][memCount];
385 return leftFlagCounter;
391 void StSvtClusterFinder::SetHybIndex(
int index)
396 int StSvtClusterFinder::ClusterIndex()
398 return mNumOfClusters;
401 int StSvtClusterFinder::ClusterMembers(
int clu)
403 return mNumOfCluMem[clu];
406 int StSvtClusterFinder::ClusterListAnode(
int clu,
int mem)
408 return mCluster[clu][mem]/1000;
411 int StSvtClusterFinder::ClusterSequence(
int clu,
int mem)
413 return mCluster[clu][mem]%1000;
417 int StSvtClusterFinder::ClusterActualAnode(
int listAn)
419 return mAnolist[listAn];
425 void StSvtClusterFinder::ResetContainers()
445 for ( i=0; i< mNumOfClusters; i++)
446 for ( j=0; j< mNumOfCluMem[i]; j++)
451 {
for(
int i = 0; i<mNumOfAnodes; i++)
452 for( j=0; j<mNumSeq[i];j++)