//</pre>
*/
+
ClassImp(AliL3VHDLClusterFinder)
AliL3VHDLClusterFinder::AliL3VHDLClusterFinder()
UShort_t rrow=0,rtime=0;
UChar_t rpad=0,i=n;
UShort_t *charges=new UShort_t[n];
- Int_t tc=0,mp=0,mt=0,sp=0,st=0;
fNClusters=0;
fRow=0;
//loop over input data
while(fAltromem.ReadSequence(rrow,rpad,rtime,i,&charges)){
- tc=0;mp=0;mt=0;sp=0;st=0;
#if 0
cout << "Padrow " << (int)rrow << " pad " << (int)rpad << " time " <<(int)rtime << " charges ";
for(UChar_t ii=0;ii<i;ii++) cout << (int)charges[ii] << " ";
fNRow=rrow;
fNPad=rpad;
+ fTC=0,fMT=0,fST=0;
//calculate sequence values
- //no deconvulution so far
- for(UChar_t ii=0;ii<i;ii++){
- tc+=charges[ii];
- mt+=(rtime-ii)*charges[ii];
- st+=(rtime-ii)*(rtime-ii)*charges[ii];
+ if(fDeconvTime){
+ UChar_t ii=0;
+ Int_t sl=0;
+ Int_t charge=0,lcharge=0;
+ Bool_t falling=kFALSE;
+ while(ii<i){
+ charge=charges[ii];
+ if((falling)&&(charge>lcharge)){
+ fSM=rtime-sl/2;
+ MakeSequence();
+ ProcessSequence();
+ OutputMemory();
+
+ rtime=rtime-sl;
+ falling=kFALSE;
+ sl=0;
+ fTC=0,fMT=0,fST=0;
+ } else if(charge<lcharge) falling=kTRUE;
+
+ fTC+=charge;
+ fMT+=(rtime-sl)*charge;
+ fST+=(rtime-sl)*(rtime-sl)*charge;
+ sl++;
+ ii++;
+ lcharge=charge;
+ } //end loop over sequence
+ fSM=rtime-sl/2;
+ } else { /* no deconvolution */
+ for(UChar_t ii=0;ii<i;ii++){
+ fTC+=charges[ii];
+ fMT+=(rtime-ii)*charges[ii];
+ fST+=(rtime-ii)*(rtime-ii)*charges[ii];
+ }
+ fSM=rtime-i/2;
}
- mp=rpad*tc;
- sp=rpad*rpad*tc;
-
- fSeq.fTotalCharge=tc;
- fSeq.fPad=mp;
- fSeq.fTime=mt;
- fSeq.fPad2=sp;
- fSeq.fTime2=st;
- fSeq.fMean=0;
- //if(tc!=0) fSeq.fMean=mt/tc;
- if(tc!=0) fSeq.fMean=rtime-i/2;
- fSeq.fMerge=0;
- fSeq.fRow=rrow;
- fSeq.fLastPad=rpad;
-
- //work on this sequence
+
+ MakeSequence();
ProcessSequence();
- //output one cluster
- OutputMemory();
+ OutputMemory();
#ifdef DEBUG
fflush(fdeb);
while(fOP!=fFP) OutputMemory();
}
+void AliL3VHDLClusterFinder::MakeSequence(){
+ if(!fTC) return;
+
+ Int_t mp=fNPad*fTC;
+ Int_t sp=fNPad*fNPad*fTC;
+
+ fSeq.fTotalCharge=fTC;
+ fSeq.fPad=mp;
+ fSeq.fTime=fMT;
+ fSeq.fPad2=sp;
+ fSeq.fTime2=fST;
+ fSeq.fMean=0;
+ fSeq.fMean=fSM;
+ fSeq.fMerge=0;
+ fSeq.fRow=fNRow;
+ fSeq.fLastPad=fNPad;
+ fSeq.fChargeFalling=0;
+ if(fDeconvPad) fSeq.fLastCharge=fTC;
+ else fSeq.fLastCharge=0;
+}
+
void AliL3VHDLClusterFinder::ProcessSequence()
{
if(fNRow!=fRow) FlushMemory();
void AliL3VHDLClusterFinder::CompareSeq()
{
-
while(fRP!=fEP){
Int_t diff=fSeqs[fPList[fRP]].fMean-fSeq.fMean;
continue;
} else if(diff<-fMatch){ //no match
break; //insert new cluster
- }
- else { //match found, merge it
+ } else { //match found, merge it
MergeSeq();
return;
}
LOG(AliL3Log::kWarning,"AliL3VHDLClusterFinder::","Memory Check")
<<"Sequences can be merged on consecutive pads only."<<ENDLOG;
}
+
+ if(fDeconvPad){
+ if(fSeq.fTotalCharge > 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;
UInt_t fMerge; //number of merges
UShort_t fRow; //row of cluster
UShort_t fLastPad; //last pad on merge
- //UInt_t fChargeFalling; //for deconvolution
- //UInt_t fLastCharge; //for deconvolution
+ UInt_t fChargeFalling; //for deconvolution
+ UInt_t fLastCharge; //for deconvolution
};
typedef struct VHDLClusterData VCData;
#define N_clmem 5000
-class AliL3VHDLClusterFinder {
-
+class AliL3VHDLClusterFinder
+{
private:
AliL3AltroMemHandler fAltromem; //!
VCData fSeq; //!
UShort_t fRP,fWP,fOP,fEP,fFP; //pointer in ringbuffer
UShort_t fLast,fFirst; //free area in memory
- Bool_t fDeconvTime; //not used for now
+ Int_t fTC; //totalcharge
+ Int_t fMT; //mean in time
+ Int_t fST; //sigma in time
+ Int_t fSM; //seq. mean
+
+ Bool_t fDeconvTime;
Bool_t fDeconvPad;
Bool_t fstdout;
Bool_t fcalcerr;
void CompareSeq();
void MergeSeq();
void InsertSeq();
+ void MakeSequence();
void ProcessSequence();
//void WriteClusters(Int_t n_clusters,ClusterData *list);