-//Author: Anders Strand Vestbo
-//Last Modified: 17.08.2001
+//$Id$
+
+// Author: Anders Vestbo <mailto:vestbo@fi.uib.no>
+//*-- Copyright © ASV
#include <iostream.h>
+#include <math.h>
#include "AliL3Logging.h"
#include "AliL3ClustFinderNew.h"
#include "AliL3DigitData.h"
#include "AliL3Transform.h"
#include "AliL3SpacePointData.h"
+#include "AliL3MemHandler.h"
+
+//_____________________________________________________________
+// AliL3ClustFinderNew
+//
+// The current cluster finder for HLT
+// Based on STAR L3
ClassImp(AliL3ClustFinderNew)
{
fMatch = 4;
fThreshold =10;
-}
-
-AliL3ClustFinderNew::AliL3ClustFinderNew(AliL3Transform *transform)
-{
- fTransform = transform;
- fMatch = 4;
- fThreshold =10;
+ fDeconvPad = kTRUE;
+ fDeconvTime = kTRUE;
}
AliL3ClustFinderNew::~AliL3ClustFinderNew()
fCurrentPatch = patch;
fFirstRow = firstrow;
fLastRow = lastrow;
+ fDeconvTime = kTRUE;
+ fDeconvPad = kTRUE;
}
void AliL3ClustFinderNew::InitSlice(Int_t slice,Int_t patch,Int_t nmaxpoints)
tmp += size;
tempPt = (AliL3DigitRowData*)tmp;
}
+ LOG(AliL3Log::kInformational,"AliL3ClustFinderNew::WriteClusters","Space points")
+ <<"Cluster finder found "<<fNClusters<<" clusters in slice "<<fCurrentSlice
+ <<" patch "<<fCurrentPatch<<ENDLOG;
}
-
-
void AliL3ClustFinderNew::ProcessRow(AliL3DigitRowData *tempPt)
{
if(data[bin].fPad != last_pad)
{
//This is a new pad
- last_pad = data[bin].fPad;
//Switch:
if(currentPt == pad2)
}
n_previous = n_current;
n_current = 0;
+ if(bin[data].fPad != last_pad+1)
+ {
+ //this happens if there is a pad with no signal.
+ n_previous = n_current = 0;
+ }
+ last_pad = data[bin].fPad;
}
Bool_t new_cluster = kTRUE;
UInt_t seq_charge=0,seq_average=0;
+ UInt_t last_charge=0,last_was_falling=0;
+ Int_t new_bin=-1;
+ if(fDeconvTime)
+ {
+ redo: //This is a goto.
+ if(new_bin > -1)
+ {
+ bin = new_bin;
+ new_bin = -1;
+ }
+
+ last_charge=0;
+ last_was_falling = 0;
+ }
+
+
while(1) //Loop over current sequence
{
+ if(data[bin].fTime >= AliL3Transform::GetNTimeBins())
+ {
+ LOG(AliL3Log::kFatal,"AliL3ClustFinderNew::ProcessRow","Digits")
+ <<"Timebin out of range "<<(Int_t)data[bin].fTime<<ENDLOG;
+ break;
+ }
+
//Get the current ADC-value
UInt_t charge = data[bin].fCharge;
+
+ if(fDeconvTime)
+ {
+ //Check if the last pixel in the sequence is smaller than this
+ if(charge > last_charge)
+ {
+ if(last_was_falling)
+ {
+ new_bin = bin;
+ break;
+ }
+ }
+ else last_was_falling = 1; //last pixel was larger than this
+ last_charge = charge;
+ }
+
//Sum the total charge of this sequence
seq_charge += charge;
- //printf("starting sequence pad %d time %d\n",data[bin].fPad,data[bin].fTime);
seq_average += data[bin].fTime*charge;
//Check where to stop:
if(seq_charge)
seq_mean = seq_average/seq_charge;
else
- printf("AliL3ClustFinderNew : NO CHARGE!!!\n");
+ {
+ LOG(AliL3Log::kFatal,"AliL3ClustFinderNew::ProcessRow","Data")
+ <<"Error in data given to the cluster finder"<<ENDLOG;
+ seq_mean = 1;
+ seq_charge = 1;
+ }
//Calculate mean in pad direction:
Int_t pad_mean = seq_charge*data[bin].fPad;
if(difference <= fMatch)//There is a match here!!
{
+
+ ClusterData *local = previousPt[p];
+ if(fDeconvPad)
+ {
+ if(seq_charge > local->fLastCharge)
+ {
+ if(local->fChargeFalling)//The previous pad was falling
+ {
+ break;//create a new cluster
+ }
+ }
+ else
+ local->fChargeFalling = 1;
+ local->fLastCharge = seq_charge;
+ }
+
//Don't create a new cluster, because we found a match
new_cluster = kFALSE;
//Update cluster on current pad with the matching one:
- currentPt[n_current] = previousPt[p];
-
- currentPt[n_current]->fTotalCharge += seq_charge;
- currentPt[n_current]->fPad += pad_mean;
- currentPt[n_current]->fTime += seq_average;
- currentPt[n_current]->fMean = seq_mean;
- currentPt[n_current]->fFlags++; //means we have more than one pad
+ //currentPt[n_current] = previousPt[p];
+
+ local->fTotalCharge += seq_charge;
+ local->fPad += pad_mean;
+ local->fTime += seq_average;
+ local->fMean = seq_mean;
+ local->fFlags++; //means we have more than one pad
+
+ currentPt[n_current] = local;
n_current++;
-
break;
}//Checking for match at previous pad
}//Loop over results on previous pad.
{
//Start a new cluster. Add it to the clusterlist, and update
//the list of pointers to clusters in current pad.
- //->will be previous pad on next pad.
+ //current pad will be previous pad on next pad.
//Add to the clusterlist:
ClusterData *tmp = &clusterlist[n_total];
tmp->fTime = seq_average;
tmp->fMean = seq_mean;
tmp->fFlags = 0; //flags for 1 pad clusters
-
+ if(fDeconvPad)
+ {
+ tmp->fChargeFalling = 0;
+ tmp->fLastCharge = seq_charge;
+ }
+
//Update list of pointers to previous pad:
currentPt[n_current] = &clusterlist[n_total];
n_total++;
n_current++;
}
+ if(fDeconvTime)
+ if(new_bin >= 0) goto redo;
+
}//Loop over digits on this padrow
WriteClusters(n_total,clusterlist);
-
-
}
void AliL3ClustFinderNew::WriteClusters(Int_t n_clusters,ClusterData *list)
{
if(!list[j].fFlags) continue; //discard 1 pad clusters
if(list[j].fTotalCharge < fThreshold) continue; //noise cluster
- Float_t xyz[3];
-
+
+ Float_t xyz[3];
Float_t fpad=(Float_t)list[j].fPad/(Float_t)list[j].fTotalCharge;
Float_t ftime=(Float_t)list[j].fTime/(Float_t)list[j].fTotalCharge;
- //printf("padrow %d number of pads %d totalcharge %d\n",fCurrentRow,list[j].fFlags,list[j].fTotalCharge);
- fTransform->Slice2Sector(fCurrentSlice,fCurrentRow,thissector,thisrow);
- fTransform->Raw2Local(xyz,thissector,thisrow,fpad,ftime);
+
+ //cout<<"WriteCluster: padrow "<<fCurrentRow<<" pad "<<fpad<<" time "<<ftime<<" charge "<<list[j].fTotalCharge<<endl;
+
+ AliL3Transform::Slice2Sector(fCurrentSlice,fCurrentRow,thissector,thisrow);
+ AliL3Transform::Raw2Local(xyz,thissector,thisrow,fpad,ftime);
if(xyz[0]==0) LOG(AliL3Log::kError,"AliL3ClustFinder","Cluster Finder")
<<AliL3Log::kDec<<"Zero cluster"<<ENDLOG;
if(fNClusters >= fMaxNClusters)
LOG(AliL3Log::kError,"AliL3ClustFinder::WriteClusters","Cluster Finder")
<<AliL3Log::kDec<<"Too many clusters"<<ENDLOG;
return;
- }
+ }
+ fSpacePointData[counter].fCharge = list[j].fTotalCharge;
fSpacePointData[counter].fX = xyz[0];
fSpacePointData[counter].fY = xyz[1];
fSpacePointData[counter].fZ = xyz[2];
fSpacePointData[counter].fXYErr = fXYErr;
fSpacePointData[counter].fZErr = fZErr;
fSpacePointData[counter].fID = counter
- +((fCurrentSlice&0x7f)<<25)+((fCurrentPatch&0x7)<<22);//uli
-
-
+ +((fCurrentSlice&0x7f)<<25)+((fCurrentPatch&0x7)<<22);//Uli
+#ifdef do_mc
+ Int_t trackID[3];
+ GetTrackID((Int_t)rint(fpad),(Int_t)rint(ftime),trackID);
+ //cout<<"padrow "<<fCurrentRow<<" pad "<<(Int_t)rint(fpad)<<" time "<<(Int_t)rint(ftime)<<" Trackid "<<trackID[0]<<endl;
+ fSpacePointData[counter].fTrackID[0] = trackID[0];
+ fSpacePointData[counter].fTrackID[1] = trackID[1];
+ fSpacePointData[counter].fTrackID[2] = trackID[2];
+#endif
fNClusters++;
counter++;
-
}
+}
+#ifdef do_mc
+void AliL3ClustFinderNew::GetTrackID(Int_t pad,Int_t time,Int_t *trackID)
+{
+ AliL3DigitRowData *rowPt = (AliL3DigitRowData*)fDigitRowData;
+
+ trackID[0]=trackID[1]=trackID[2]=-2;
+ //cout<<"Looking for pad "<<pad<<" time "<<time<<endl;
+ for(Int_t i=fFirstRow; i<=fLastRow; i++)
+ {
+ if(rowPt->fRow < (UInt_t)fCurrentRow)
+ {
+ AliL3MemHandler::UpdateRowPointer(rowPt);
+ continue;
+ }
+ AliL3DigitData *digPt = (AliL3DigitData*)rowPt->fDigitData;
+ for(UInt_t j=0; j<rowPt->fNDigit; j++)
+ {
+ Int_t cpad = digPt[j].fPad;
+ Int_t ctime = digPt[j].fTime;
+ if(cpad != pad) continue;
+ if(ctime != time) continue;
+ //if(cpad != pad && ctime != ctime) continue;
+ //cout<<"Reading row "<<fCurrentRow<<" pad "<<cpad<<" time "<<ctime<<" trackID "<<digPt[j].fTrackID[0]<<endl;
+ trackID[0] = digPt[j].fTrackID[0];
+ trackID[1] = digPt[j].fTrackID[1];
+ trackID[2] = digPt[j].fTrackID[2];
+ break;
+ //cout<<"Reading trackID "<<trackID[0]<<endl;
+ }
+ break;
+ }
+
}
+#endif