23 #include "StSstStripList.hh"
24 #include "StSpaListNoise.hh"
25 #include "StMessMgr.h"
27 StSstStripList::StSstStripList()
34 StSstStripList::~StSstStripList()
52 {
return ptr->getNextStrip(); }
55 {
return ptr->getPrevStrip(); }
58 {
return mFirstStrip; }
61 {
return mLastStrip; }
63 StSstStrip* StSstStripList::getStrip(Int_t idStrip)
68 if(currentStrip->getNStrip()==idStrip)
return currentStrip;
69 currentStrip=next(currentStrip);
71 LOG_INFO <<
"No match in getStrip"<<endm;
75 Int_t StSstStripList::getSize()
76 {
return mListLength; }
78 Int_t StSstStripList::addNewStrip(
StSstStrip *ptr)
80 if (ptr->getNStrip() == 0)
return 0;
90 ptr->setPrevStrip(mLastStrip);
92 mLastStrip->setNextStrip(ptr);
99 Int_t StSstStripList::removeStrip(
StSstStrip *ptr)
101 if (!getSize())
return 0;
118 mFirstStrip = ptAfter;
119 ptAfter->setPrevStrip(0);
129 mLastStrip = ptBefore;
130 ptBefore->setNextStrip(0);
137 ptBefore->setNextStrip(ptAfter);
138 ptAfter->setPrevStrip(ptBefore);
150 StSstStrip *ptrTemp =
new StSstStrip(ptr1->getNStrip(), ptr1->getDigitSig(), ptr1->getSigma(),ptr1->getPedestal());
151 for(Int_t ii=0;ii<5;ii++) {
152 ptrTemp->setIdMcHit(ptr1->getIdMcHit(ii),ii);
153 ptrTemp->setIdMcTrack(ptr1->getIdMcTrack(ii),ii);
154 ptrTemp->setIdHit(ptr1->getIdHit(ii),ii);
157 ptr1->setNStrip(ptr2->getNStrip());
158 ptr1->setDigitSig(ptr2->getDigitSig());
159 ptr1->setPedestal(ptr2->getPedestal());
160 ptr1->setSigma(ptr2->getSigma());
161 ptr1->setNHits(ptr2->getNHits());
162 ptr1->setAnalogSig(ptr2->getAnalogSig());
163 ptr1->setMcStrip(ptr2->getMcStrip());
164 for(
int i= 0 ;i <5 ; i++)
166 ptr1->setIdHit(ptr2->getIdHit(i),i);
167 ptr1->setIdMcTrack(ptr2->getIdMcTrack(i),i);
168 ptr1->setIdMcHit(ptr2->getIdMcHit(i),i);
171 ptr2->setNStrip(ptrTemp->getNStrip());
172 ptr2->setDigitSig(ptrTemp->getDigitSig());
173 ptr2->setPedestal(ptrTemp->getPedestal());
174 ptr2->setSigma(ptrTemp->getSigma());
175 ptr2->setNHits(ptrTemp->getNHits());
176 ptr2->setAnalogSig(ptrTemp->getAnalogSig());
177 ptr2->setMcStrip(ptrTemp->getMcStrip());
178 for(
int i= 0 ;i <5 ; i++)
180 ptr2->setIdHit(ptrTemp->getIdHit(i),i);
181 ptr2->setIdMcTrack(ptrTemp->getIdMcTrack(i),i);
182 ptr2->setIdMcHit(ptrTemp->getIdMcHit(i),i);
187 void StSstStripList::sortStrip()
189 Int_t localSize=getSize();
190 if (localSize<2)
return;
193 ptCurr = next(ptCurr);
194 for ( ; ptCurr!=0 ; )
200 while ((ptB1 != first())&&(is_cont))
203 if (ptB2->getNStrip() > ptB1->getNStrip())
205 exchangeTwoStrips(ptB1,ptB2);
213 ptCurr = next(ptCurr);
220 int* StSstStripList::getListAdc(Int_t idStrip, Int_t sizeCluster)
223 int* localListAdc =
new int[sizeCluster];
225 if(CurrentStrip->getNStrip() == idStrip){
228 if(CurrentStrip!=last()){
229 CurrentStrip = next(CurrentStrip);
232 if (!CurrentStrip)
return localListAdc;
234 for (iStrip=0; iStrip<sizeCluster;iStrip++)
236 localListAdc[iStrip]=CurrentStrip->getDigitSig();
237 CurrentStrip = next(CurrentStrip);
243 void StSstStripList::setPedestalSigma(Int_t iStrip, Int_t iPedestal, Int_t iSigma,
StSstDynamicControl *dynamicControl)
245 const Int_t NAdcChannel = 1 << (dynamicControl->getnbitEncoding());
248 const Float_t conversionFactor = 1.;
250 while((currentStrip) && (currentStrip->getNStrip()!=iStrip))
251 currentStrip=next(currentStrip);
255 Float_t sigmaAdc = iSigma*conversionFactor;
256 if (sigmaAdc<NAdcChannel) currentStrip->setSigma(sigmaAdc);
257 else currentStrip->setSigma(NAdcChannel-1);
258 if (iPedestal<NAdcChannel) currentStrip->setPedestal(iPedestal);
259 else currentStrip->setPedestal(NAdcChannel-1);
264 Int_t StSstStripList::isSorted()
269 while(ptr1 != last())
272 if (ptr1->getNStrip()>ptr2->getNStrip())
return 0;
278 StSstStripList::StSstStripList(
const StSstStripList & originalStripList)
280 mListLength = originalStripList.mListLength;
281 mFirstStrip = originalStripList.mFirstStrip;
282 mLastStrip = originalStripList.mLastStrip;
287 mListLength = originalStripList.mListLength;
288 mFirstStrip = originalStripList.mFirstStrip;
289 mLastStrip = originalStripList.mLastStrip;
294 void StSstStripList::updateStrip(
StSstStrip *ptr)
296 Int_t localSize = getSize();
303 while ((stripScan != last())&&(stripScan->getNStrip()!=ptr->getNStrip())) stripScan = next(stripScan);
304 if (stripScan->getNStrip()!=ptr->getNStrip())
311 Int_t dum = stripScan->getNHits();
312 Float_t tmpSig = stripScan->getAnalogSig();
313 stripScan->setNHits(dum+1);
314 stripScan->setAnalogSig(ptr->getAnalogSig()+tmpSig) ;
317 if(ptr->getAnalogSig()>tmpSig){
318 stripScan->setIdHit(ptr->getIdHit(0), 0);
319 stripScan->setIdMcHit(ptr->getIdMcHit(0), 0);
320 stripScan->setIdMcTrack(ptr->getIdMcTrack(0), 0);
323 stripScan->setIdMcTrack(stripScan->getIdMcTrack(0), 0);
324 stripScan->setIdHit(stripScan->getIdHit(0),0);
325 stripScan->setIdMcHit(stripScan->getIdMcHit(0),0);
342 while (pt2&&((pt2->getNStrip())!=(pt1->getNStrip())))
344 pt2 = ptr->next(pt2);
354 adcCount = pt2->getNoiseValue();
355 pt1->setDigitSig(adcCount);
363 if (pt2->getNStrip() < 0)
366 pt2 = ptr->next(pt2);
367 ptr->removeNoise(tmpNoise);
372 addNewStrip(tmpStrip);
373 pt2 = ptr->next(pt2);