24 #include "StSsdStripList.hh"
25 #include "StSpaListNoise.hh"
28 StSsdStripList::StSsdStripList()
35 StSsdStripList::~StSsdStripList()
53 {
return ptr->getNextStrip(); }
56 {
return ptr->getPrevStrip(); }
59 {
return mFirstStrip; }
62 {
return mLastStrip; }
64 StSsdStrip* StSsdStripList::getStrip(Int_t idStrip)
69 if(currentStrip->getNStrip()==idStrip)
return currentStrip;
70 currentStrip=next(currentStrip);
72 cout<<
"No match in getStrip"<<endl;
76 Int_t StSsdStripList::getSize()
77 {
return mListLength; }
79 Int_t StSsdStripList::addNewStrip(
StSsdStrip *ptr)
81 if (ptr->getNStrip() == 0)
return 0;
91 ptr->setPrevStrip(mLastStrip);
93 mLastStrip->setNextStrip(ptr);
100 Int_t StSsdStripList::removeStrip(
StSsdStrip *ptr)
102 if (!getSize())
return 0;
119 mFirstStrip = ptAfter;
120 ptAfter->setPrevStrip(0);
130 mLastStrip = ptBefore;
131 ptBefore->setNextStrip(0);
138 ptBefore->setNextStrip(ptAfter);
139 ptAfter->setPrevStrip(ptBefore);
151 StSsdStrip *ptrTemp =
new StSsdStrip(ptr1->getNStrip(), ptr1->getDigitSig(), ptr1->getSigma(),ptr1->getPedestal());
152 for(Int_t ii=0;ii<5;ii++) {
153 ptrTemp->setIdMcHit(ptr1->getIdMcHit(ii),ii);
154 ptrTemp->setIdMcTrack(ptr1->getIdMcTrack(ii),ii);
155 ptrTemp->setIdHit(ptr1->getIdHit(ii),ii);
163 ptr1->setNStrip(ptr2->getNStrip());
164 ptr1->setDigitSig(ptr2->getDigitSig());
165 ptr1->setPedestal(ptr2->getPedestal());
166 ptr1->setSigma(ptr2->getSigma());
167 ptr1->setNHits(ptr2->getNHits());
168 ptr1->setAnalogSig(ptr2->getAnalogSig());
169 ptr1->setMcStrip(ptr2->getMcStrip());
170 for(
int i= 0 ;i <5 ; i++)
172 ptr1->setIdHit(ptr2->getIdHit(i),i);
173 ptr1->setIdMcTrack(ptr2->getIdMcTrack(i),i);
174 ptr1->setIdMcHit(ptr2->getIdMcHit(i),i);
182 ptr2->setNStrip(ptrTemp->getNStrip());
183 ptr2->setDigitSig(ptrTemp->getDigitSig());
184 ptr2->setPedestal(ptrTemp->getPedestal());
185 ptr2->setSigma(ptrTemp->getSigma());
186 ptr2->setNHits(ptrTemp->getNHits());
187 ptr2->setAnalogSig(ptrTemp->getAnalogSig());
188 ptr2->setMcStrip(ptrTemp->getMcStrip());
189 for(
int i= 0 ;i <5 ; i++)
191 ptr2->setIdHit(ptrTemp->getIdHit(i),i);
192 ptr2->setIdMcTrack(ptrTemp->getIdMcTrack(i),i);
193 ptr2->setIdMcHit(ptrTemp->getIdMcHit(i),i);
198 void StSsdStripList::sortStrip()
200 Int_t localSize=getSize();
201 if (localSize<2)
return;
204 ptCurr = next(ptCurr);
205 for ( ; ptCurr!=0 ; )
211 while ((ptB1 != first())&&(is_cont))
214 if (ptB2->getNStrip() > ptB1->getNStrip())
216 exchangeTwoStrips(ptB1,ptB2);
224 ptCurr = next(ptCurr);
231 int* StSsdStripList::getListAdc(Int_t idStrip, Int_t sizeCluster)
234 int* localListAdc =
new int[sizeCluster];
235 while((CurrentStrip->getNStrip()!=idStrip)&&(CurrentStrip)) CurrentStrip = next(CurrentStrip);
236 if (!CurrentStrip)
return localListAdc;
238 for (iStrip=0; iStrip<sizeCluster;iStrip++)
240 localListAdc[iStrip]=CurrentStrip->getDigitSig();
241 CurrentStrip = next(CurrentStrip);
247 void StSsdStripList::setPedestalSigma(Int_t iStrip, Int_t iPedestal, Int_t iSigma,
StSsdDynamicControl *dynamicControl)
249 const Int_t NAdcChannel = 1 << (dynamicControl->getnbitEncoding());
251 const Float_t conversionFactor = 1./16.;
253 while((currentStrip) && (currentStrip->getNStrip()!=iStrip))
254 currentStrip=next(currentStrip);
258 Float_t sigmaAdc = iSigma*conversionFactor;
259 if (sigmaAdc<NAdcChannel) currentStrip->setSigma(sigmaAdc);
260 else currentStrip->setSigma(NAdcChannel-1);
261 if (iPedestal<NAdcChannel) currentStrip->setPedestal(iPedestal);
262 else currentStrip->setPedestal(NAdcChannel-1);
267 Int_t StSsdStripList::isSorted()
272 while(ptr1 != last())
275 if (ptr1->getNStrip()>ptr2->getNStrip())
return 0;
281 StSsdStripList::StSsdStripList(
const StSsdStripList & originalStripList)
283 mListLength = originalStripList.mListLength;
284 mFirstStrip = originalStripList.mFirstStrip;
285 mLastStrip = originalStripList.mLastStrip;
290 mListLength = originalStripList.mListLength;
291 mFirstStrip = originalStripList.mFirstStrip;
292 mLastStrip = originalStripList.mLastStrip;
297 void StSsdStripList::updateStrip(
StSsdStrip *ptr)
299 Int_t localSize = getSize();
306 while ((stripScan != last())&&(stripScan->getNStrip()!=ptr->getNStrip())) stripScan = next(stripScan);
307 if (stripScan->getNStrip()!=ptr->getNStrip())
314 Int_t dum = stripScan->getNHits();
315 Float_t tmpSig = stripScan->getAnalogSig();
316 stripScan->setNHits(dum+1);
317 stripScan->setAnalogSig(ptr->getAnalogSig()+tmpSig) ;
320 if(ptr->getAnalogSig()>tmpSig){
321 stripScan->setIdHit(ptr->getIdHit(0), 0);
322 stripScan->setIdMcHit(ptr->getIdMcHit(0), 0);
323 stripScan->setIdMcTrack(ptr->getIdMcTrack(0), 0);
326 stripScan->setIdMcTrack(stripScan->getIdMcTrack(0), 0);
327 stripScan->setIdHit(stripScan->getIdHit(0),0);
328 stripScan->setIdMcHit(stripScan->getIdMcHit(0),0);
338 Int_t size2 = list->getSize();
339 if (!size2)
return this;
344 for (i=0 ; i < size2 ; i++)
348 st2 = list->next(st2);
362 while (pt2&&((pt2->getNStrip())!=(pt1->getNStrip())))
364 pt2 = ptr->next(pt2);
374 adcCount = pt2->getNoiseValue();
375 pt1->setDigitSig(adcCount);
383 if (pt2->getNStrip() < 0)
386 pt2 = ptr->next(pt2);
387 ptr->removeNoise(tmpNoise);
392 addNewStrip(tmpStrip);
393 pt2 = ptr->next(pt2);