19 #include "StSstUtil/StSstPackage.hh"
21 #include "StSstUtil/StSstCluster.hh"
22 #include "StSstUtil/StSstClusterControl.h"
24 #include "StMessMgr.h"
28 Int_t maxMatcheds = control->getClusterTreat();
29 mNPackage = rNPackage;
34 for(Int_t i=0;i<maxMatcheds;i++) mMatcheds[i]=0;
35 mKind =
new char[2*maxMatcheds+1];
41 StSstPackage::StSstPackage(Int_t rNPackage, Int_t rNMatched)
43 mNPackage = rNPackage;
44 mListLengthM = rNMatched;
48 for(Int_t i=0;i<rNMatched;i++) mMatcheds[i]=0;
49 mKind =
new char[2*rNMatched+1];
55 StSstPackage::StSstPackage(
const StSstPackage & originalPackage)
58 mNPackage = originalPackage.mNPackage;
59 mListLengthM = originalPackage.mListLengthM;
60 mFirstMatched = originalPackage.mFirstMatched;
61 mLastMatched = originalPackage.mLastMatched;
63 for(i=0;i<mListLengthM;i++) mMatcheds[i] = originalPackage.mMatcheds[i];
64 mKind =
new char[2*mListLengthM+1];
65 for(i=0;i<2*mListLengthM+1;i++) mKind[i] = originalPackage.mKind[i];
66 mPrevPackage = originalPackage.mPrevPackage;
67 mNextPackage = originalPackage.mNextPackage;
70 StSstPackage::~StSstPackage()
79 mNPackage = originalPackage.mNPackage;
80 mListLengthM = originalPackage.mListLengthM;
81 mFirstMatched = originalPackage.mFirstMatched;
82 mLastMatched = originalPackage.mLastMatched;
83 for(i=0;i<mListLengthM;i++) mMatcheds[i] = originalPackage.mMatcheds[i];
84 for(i=0;i<2*mListLengthM+1;i++) mKind[i] = originalPackage.mKind[i];
85 mPrevPackage = originalPackage.mPrevPackage;
86 mNextPackage = originalPackage.mNextPackage;
92 {
return ptr->getNextCluster(); }
95 {
return ptr->getPrevCluster(); }
98 {
return mFirstMatched; }
101 {
return mLastMatched; }
103 void StSstPackage::purgePackage()
113 if (this->mListLengthM == ptr->mListLengthM)
115 this->mFirstMatched = ptr->mFirstMatched;
116 this->mLastMatched = ptr->mLastMatched;
117 strcpy(this->mKind, ptr->mKind);
118 for(Int_t i = 0;i < this->mListLengthM;i++)
119 { this->mMatcheds[i] = ptr->mMatcheds[i]; }
122 LOG_INFO<<
"Problem to transfer matched clusters (not enough room) !! "<< endm;
125 void StSstPackage::setNPackage(Int_t rNPackage)
126 { this->mNPackage = rNPackage; }
128 void StSstPackage::setKind(
char *rKind)
129 { this->mKind = rKind ; }
131 void StSstPackage::setPrevPackage(
StSstPackage *rPrevPackage)
132 { this->mPrevPackage = rPrevPackage ; }
134 void StSstPackage::setNextPackage(
StSstPackage *rNextPackage)
135 { this->mNextPackage = rNextPackage ; }
137 Int_t StSstPackage::getNPackage()
138 {
return this->mNPackage; }
140 StSstCluster* StSstPackage::getMatched(Int_t numMatched)
142 if (numMatched>mListLengthM)
return 0;
143 return this->mMatcheds[numMatched];
146 char* StSstPackage::getKind()
147 {
return this->mKind; }
150 {
return this->mPrevPackage; }
153 {
return this->mNextPackage; }
156 Int_t StSstPackage::addNewMatched(
StSstCluster *ptr, Int_t maxMatcheds)
158 if ( (!ptr) || (mListLengthM == maxMatcheds) )
return 0;
159 if (mListLengthM == 0)
168 mMatcheds[mListLengthM] = ptr;
173 Int_t StSstPackage::addKindPackage(Int_t numMatched, Int_t rSide, Int_t maxMatcheds)
175 if ( (!this->getSize()) || (mListLengthM == maxMatcheds))
return 0;
176 mKind[2*(this->mListLengthM-1)]=
char(48+numMatched);
179 mKind[2*(this->mListLengthM)-1]=
'p';
180 mKind[2*(this->mListLengthM)]=
'\0';
184 mKind[2*(this->mListLengthM)-1]=
'n';
185 mKind[2*(this->mListLengthM)]=
'\0';
192 if (!this->getSize())
return 0;
201 this->mFirstMatched = 0;
202 this->mLastMatched = 0;
203 this->mListLengthM = 0;
209 this->mFirstMatched = ptAfter;
210 ptAfter->setPrevCluster(0);
211 this->mListLengthM--;
220 this->mLastMatched = ptBefore;
221 ptBefore->setNextCluster(0);
222 this->mListLengthM--;
228 ptBefore->setNextCluster(ptAfter);
229 ptAfter->setPrevCluster(ptBefore);
230 this->mListLengthM--;
240 ptr1->copyTo(ptrTemp);
242 ptrTemp->copyTo(ptr2);
246 void StSstPackage::sortMatched()
248 Int_t localSize=this->getSize();
249 if (localSize<2)
return;
252 ptCurr = this->next(ptCurr);
253 for ( ; ptCurr!=0 ; )
259 while ((ptB1 != this->first())&&(isCont))
261 ptB2 = this->prev(ptB1);
262 if (ptB2->getFirstStrip() > ptB1->getFirstStrip())
264 this->exchangeTwoMatcheds(ptB1,ptB2);
272 ptCurr = this->next(ptCurr);
278 void StSstPackage::renumMatched()
280 Int_t CurrentListSize = this->getSize();
281 if (!CurrentListSize)
return;
283 for (Int_t i = 0; i < CurrentListSize; i++)
285 CurrCluster->setNCluster(i);
286 CurrCluster = this->next(CurrCluster);
291 Int_t StSstPackage::getSize()
292 {
return mListLengthM; }
294 Int_t StSstPackage::isSorted()
299 while(ptr1 != this->last())
301 ptr2 = this->next(ptr1);
302 if (ptr1->getFirstStrip()>ptr2->getFirstStrip())
return 0;
303 ptr1 = this->next(ptr1);