// @(#) $Id$ // Author: Constantin Loizides //*-- Copyright & copy ALICE HLT Group /** \class AliL3VHDLClusterFinder
//____________________________________________________
// AliL3VHDLClusterFinder
//
// The current VHDL cluster finder for HLT
// Based on STAR L3
//
// Most important parameters:
// fThreshold - threshold for noise clusters
// fMatch - length in time for overlapping sequences
*/ #include "AliL3StandardIncludes.h" #include "AliL3RootTypes.h" #include "AliL3Logging.h" #include "AliL3AltroMemHandler.h" //#define VHDLDEBUG #include "AliL3VHDLClusterFinder.h" #if __GNUC__ == 3 using namespace std; #endif ClassImp(AliL3VHDLClusterFinder) AliL3VHDLClusterFinder::AliL3VHDLClusterFinder() { // default constructor fMatch = 4; fThreshold = 10; fMinMerge = 1; fNClusters=0; fXYErr = 0.2; fZErr = 0.3; fDeconvPad = kTRUE; fDeconvTime = kTRUE; fstdout = kFALSE; fcalcerr = kTRUE; Clear(); #ifdef VHDLDEBUG fdeb=fopen("vhdlclusterfinder.debug","w"); //fdeb=stderr; #endif } AliL3VHDLClusterFinder::~AliL3VHDLClusterFinder() { // destructor #ifdef VHDLDEBUG fclose(fdeb); #endif } void AliL3VHDLClusterFinder::ProcessDigits() { //Loop over data like the analyzer of the VHDL code const UChar_t kn=255; UShort_t rrow=0,rtime=0; UChar_t rpad=0,i=kn; UShort_t *charges=new UShort_t[kn]; fNClusters=0; fRow=0; fPad=0; Clear(); //loop over input data while(fAltromem.ReadSequence(rrow,rpad,rtime,i,&charges)){ #if 0 cout << "Padrow " << (int)rrow << " pad " << (int)rpad << " time " <<(int)rtime << " charges "; for(UChar_t ii=0;iilcharge)){ fSM=rtime-sl/2; MakeSequence(); ProcessSequence(); OutputMemory(); rtime=rtime-sl; falling=kFALSE; sl=0; fTC=0,fMT=0,fST=0; } else if(chargefMatch){ //no match IncRPointer(); //cluster finished continue; } else if(diff<-fMatch){ //no match break; //insert new cluster } else { //match found, merge it MergeSeq(); return; } } InsertSeq(); //start new cluster } void AliL3VHDLClusterFinder::MergeSeq() { // merges sequences #ifdef VHDLDEBUG fprintf(fdeb,"merged with Mean=%d TC=%d (new Merge=%d) %d %d\n",fSeqs[fPList[fRP]].fMean,fSeqs[fPList[fRP]].fTotalCharge,fSeqs[fPList[fRP]].fMerge+1,fRow,fPad); #endif if(fSeqs[fPList[fRP]].fRow!=fSeq.fRow){ LOG(AliL3Log::kWarning,"AliL3VHDLClusterFinder::","Memory Check") <<"Sequences can be merged on the same rows only."< fSeqs[fPList[fRP]].fLastCharge){ if(fSeqs[fPList[fRP]].fChargeFalling){ //The previous pad was falling IncRPointer(); InsertSeq(); //start a new cluster return; } } else fSeqs[fPList[fRP]].fChargeFalling = 1; fSeqs[fPList[fRP]].fLastCharge = fSeq.fTotalCharge; } fSeqs[fPList[fRP]].fMean=fSeq.fMean; //take the new mean fSeqs[fPList[fRP]].fLastPad=fSeq.fLastPad; fSeqs[fPList[fRP]].fTotalCharge+=fSeq.fTotalCharge; fSeqs[fPList[fRP]].fPad+=fSeq.fPad; fSeqs[fPList[fRP]].fTime+=fSeq.fTime; fSeqs[fPList[fRP]].fPad2+=fSeq.fPad2; fSeqs[fPList[fRP]].fTime2+=fSeq.fTime2; fSeqs[fPList[fRP]].fMerge+=1; fPList[fWP]=fPList[fRP]; fPList[fRP]=N_clmem; //mark it to be free IncRPointer(); IncWPointer(); } void AliL3VHDLClusterFinder::InsertSeq() { // inserts sequence #ifdef VHDLDEBUG fprintf(fdeb,"inserted %d %d\n",fRow,fPad); #endif NextFreeIndex(); //get next index fSeqs[fFirst]=fSeq; //store data fPList[fWP]=fFirst; //store index IncWPointer(); } void AliL3VHDLClusterFinder::OutputMemory() { // output memory? Float_t mtime=0,mpad=0; Float_t mtime2=0,mpad2=0; UInt_t tc,row,mno; if(fOP!=fFP){ //while(fOP!=fFP){ UInt_t index=fPList[fOP]; fPList[fOP]=N_clmem; //cout << fOP << " - " << fFP << " - " << index << endl; IncPointer(fOP); if(index>=N_clmem) return; //nothing to do //if(index>=N_clmem) continue; //nothing to do tc=fSeqs[index].fTotalCharge; mno=fSeqs[index].fMerge; row=fSeqs[index].fRow; if(tc!=0){ mtime=(Float_t)(fSeqs[index].fTime)/tc; mtime2=sqrt((Float_t)(fSeqs[index].fTime2)/tc-mtime*mtime); } if(tc!=0){ mpad=(Float_t)(fSeqs[index].fPad)/tc; mpad2=sqrt((Float_t)(fSeqs[index].fPad2)/tc-mpad*mpad); } if(mno=N) p=UShort_t(pp-N); else if(pp<0) p=UShort_t(pp+N); else p=UShort_t(pp); } void AliL3VHDLClusterFinder::IncRPointer(){ // increments pointer fRP IncPointer(fRP); } void AliL3VHDLClusterFinder::IncWPointer(){ // increments pointer fWP IncPointer(fWP); if(fWP==fOP){ LOG(AliL3Log::kWarning,"AliL3VHDLClusterFinder::IncWPointer","Memory Check") <<"Write pointer overwrites output pointer."<= fMaxNClusters) { LOG(AliL3Log::kError,"AliL3ClustFinder::WriteClusters","Cluster Finder") <