11 #include "StSsdUtil/StSsdPackage.hh"
13 #include "StSsdUtil/StSsdCluster.hh"
14 #include "StSsdUtil/StSsdClusterControl.h"
19 Int_t maxMatcheds = control->getClusterTreat();
20 mNPackage = rNPackage;
25 for(Int_t i=0;i<maxMatcheds;i++) mMatcheds[i]=0;
26 mKind =
new char[2*maxMatcheds+1];
32 StSsdPackage::StSsdPackage(Int_t rNPackage, Int_t rNMatched)
34 mNPackage = rNPackage;
35 mListLengthM = rNMatched;
39 for(Int_t i=0;i<rNMatched;i++) mMatcheds[i]=0;
40 mKind =
new char[2*rNMatched+1];
46 StSsdPackage::StSsdPackage(
const StSsdPackage & originalPackage)
49 mNPackage = originalPackage.mNPackage;
50 mListLengthM = originalPackage.mListLengthM;
51 mFirstMatched = originalPackage.mFirstMatched;
52 mLastMatched = originalPackage.mLastMatched;
54 for(i=0;i<mListLengthM;i++) mMatcheds[i] = originalPackage.mMatcheds[i];
55 mKind =
new char[2*mListLengthM+1];
56 for(i=0;i<2*mListLengthM+1;i++) mKind[i] = originalPackage.mKind[i];
57 mPrevPackage = originalPackage.mPrevPackage;
58 mNextPackage = originalPackage.mNextPackage;
61 StSsdPackage::~StSsdPackage()
70 mNPackage = originalPackage.mNPackage;
71 mListLengthM = originalPackage.mListLengthM;
72 mFirstMatched = originalPackage.mFirstMatched;
73 mLastMatched = originalPackage.mLastMatched;
74 for(i=0;i<mListLengthM;i++) mMatcheds[i] = originalPackage.mMatcheds[i];
75 for(i=0;i<2*mListLengthM+1;i++) mKind[i] = originalPackage.mKind[i];
76 mPrevPackage = originalPackage.mPrevPackage;
77 mNextPackage = originalPackage.mNextPackage;
83 {
return ptr->getNextCluster(); }
86 {
return ptr->getPrevCluster(); }
89 {
return mFirstMatched; }
92 {
return mLastMatched; }
94 void StSsdPackage::purgePackage()
104 if (this->mListLengthM == ptr->mListLengthM)
106 this->mFirstMatched = ptr->mFirstMatched;
107 this->mLastMatched = ptr->mLastMatched;
108 strcpy(this->mKind, ptr->mKind);
109 for(Int_t i = 0;i < this->mListLengthM;i++)
110 { this->mMatcheds[i] = ptr->mMatcheds[i]; }
113 cout<<
"Problem to transfer matched clusters (not enough room) !!\n";
116 void StSsdPackage::setNPackage(Int_t rNPackage)
117 { this->mNPackage = rNPackage; }
119 void StSsdPackage::setKind(
char *rKind)
120 { this->mKind = rKind ; }
122 void StSsdPackage::setPrevPackage(
StSsdPackage *rPrevPackage)
123 { this->mPrevPackage = rPrevPackage ; }
125 void StSsdPackage::setNextPackage(
StSsdPackage *rNextPackage)
126 { this->mNextPackage = rNextPackage ; }
128 Int_t StSsdPackage::getNPackage()
129 {
return this->mNPackage; }
131 StSsdCluster* StSsdPackage::getMatched(Int_t numMatched)
133 if (numMatched>mListLengthM)
return 0;
134 return this->mMatcheds[numMatched];
137 char* StSsdPackage::getKind()
138 {
return this->mKind; }
141 {
return this->mPrevPackage; }
144 {
return this->mNextPackage; }
147 Int_t StSsdPackage::addNewMatched(
StSsdCluster *ptr, Int_t maxMatcheds)
149 if ( (!ptr) || (mListLengthM == maxMatcheds) )
return 0;
150 if (mListLengthM == 0)
159 mMatcheds[mListLengthM] = ptr;
164 Int_t StSsdPackage::addKindPackage(Int_t numMatched, Int_t rSide, Int_t maxMatcheds)
166 if ( (!this->getSize()) || (mListLengthM == maxMatcheds))
return 0;
167 mKind[2*(this->mListLengthM-1)]=
char(48+numMatched);
170 mKind[2*(this->mListLengthM)-1]=
'p';
171 mKind[2*(this->mListLengthM)]=
'\0';
175 mKind[2*(this->mListLengthM)-1]=
'n';
176 mKind[2*(this->mListLengthM)]=
'\0';
183 if (!this->getSize())
return 0;
192 this->mFirstMatched = 0;
193 this->mLastMatched = 0;
194 this->mListLengthM = 0;
200 this->mFirstMatched = ptAfter;
201 ptAfter->setPrevCluster(0);
202 this->mListLengthM--;
211 this->mLastMatched = ptBefore;
212 ptBefore->setNextCluster(0);
213 this->mListLengthM--;
219 ptBefore->setNextCluster(ptAfter);
220 ptAfter->setPrevCluster(ptBefore);
221 this->mListLengthM--;
234 ptr1->setNCluster(ptr2->getNCluster()) ;
235 ptr1->setFirstStrip(ptr2->getFirstStrip()) ;
236 ptr1->setClusterSize(ptr2->getClusterSize());
237 ptr1->setTotAdc(ptr2->getTotAdc());
238 ptr1->setFirstAdc(ptr2->getFirstAdc());
239 ptr1->setLastAdc(ptr2->getLastAdc());
240 ptr1->setTotNoise(ptr2->getTotNoise());
241 ptr1->setFlag(ptr2->getFlag());
243 ptr2->setNCluster(ptrTmp->getNCluster()) ;
244 ptr2->setFirstStrip(ptrTmp->getFirstStrip()) ;
245 ptr2->setClusterSize(ptrTmp->getClusterSize());
246 ptr2->setTotAdc(ptrTmp->getTotAdc());
247 ptr2->setFirstAdc(ptrTmp->getFirstAdc());
248 ptr2->setLastAdc(ptrTmp->getLastAdc());
249 ptr2->setTotNoise(ptrTmp->getTotNoise());
250 ptr2->setFlag(ptrTmp->getFlag());
254 void StSsdPackage::sortMatched()
256 Int_t localSize=this->getSize();
257 if (localSize<2)
return;
260 ptCurr = this->next(ptCurr);
261 for ( ; ptCurr!=0 ; )
267 while ((ptB1 != this->first())&&(isCont))
269 ptB2 = this->prev(ptB1);
270 if (ptB2->getFirstStrip() > ptB1->getFirstStrip())
272 this->exchangeTwoMatcheds(ptB1,ptB2);
280 ptCurr = this->next(ptCurr);
286 void StSsdPackage::renumMatched()
288 Int_t CurrentListSize = this->getSize();
289 if (!CurrentListSize)
return;
291 for (Int_t i = 0; i < CurrentListSize; i++)
293 CurrCluster->setNCluster(i);
294 CurrCluster = this->next(CurrCluster);
299 Int_t StSsdPackage::getSize()
300 {
return mListLengthM; }
302 Int_t StSsdPackage::isSorted()
307 while(ptr1 != this->last())
309 ptr2 = this->next(ptr1);
310 if (ptr1->getFirstStrip()>ptr2->getFirstStrip())
return 0;
311 ptr1 = this->next(ptr1);