-//Author: Anders Strand Vestbo
-//Last Modified: 28.6.01
+// @(#) $Id$
-#include <math.h>
-#include <TH2.h>
-#include <time.h>
+// Author: Anders Vestbo <mailto:vestbo@fi.uib.no>
+//*-- Copyright © ALICE HLT Group
-#include <TFile.h>
-#include <TTree.h>
+#include "AliL3StandardIncludes.h"
-#include "AliTPCParam.h"
-#include "AliSimDigits.h"
-
-#include "AliL3Histogram.h"
#include "AliL3Logging.h"
-#include "AliL3Defs.h"
-#include "AliL3Transform.h"
#include "AliL3HoughTransformer.h"
-#include "AliL3HoughTrack.h"
-#include "AliL3TrackArray.h"
+#include "AliL3MemHandler.h"
+#include "AliL3Transform.h"
#include "AliL3DigitData.h"
+#include "AliL3HistogramAdaptive.h"
+
+#if GCCVERSION == 3
+using namespace std;
+#endif
+
+//_____________________________________________________________
+// AliL3HoughTransformer
+//
+// Hough transformation class
+//
ClassImp(AliL3HoughTransformer)
AliL3HoughTransformer::AliL3HoughTransformer()
{
//Default constructor
-
+ fParamSpace = 0;
+ fDoMC = kFALSE;;
+ fEtaOverlap=kFALSE;
+#ifdef do_mc
+ fTrackID = 0;
+#endif
}
+AliL3HoughTransformer::AliL3HoughTransformer(Int_t slice,Int_t patch,Int_t n_eta_segments,Bool_t DoEtaOverlap,Bool_t DoMC) : AliL3HoughBaseTransformer(slice,patch,n_eta_segments)
+{
+ //Normal constructor
+ fParamSpace = 0;
+ fDoMC = kFALSE;
+ fEtaOverlap = DoEtaOverlap;
+ fDoMC=kFALSE;
+ if(DoMC==kTRUE)
+ {
+ if(patch==0)
+ fDoMC = kTRUE;
+ else
+ fDoMC = kFALSE;
+ }
+#ifdef do_mc
+ fTrackID = 0;
+#endif
+}
-AliL3HoughTransformer::AliL3HoughTransformer(Int_t slice,Int_t patch,Float_t *etarange)
+AliL3HoughTransformer::~AliL3HoughTransformer()
{
- //Constructor
-
- fTransform = new AliL3Transform();
+ DeleteHistograms();
+#ifdef do_mc
+ if(fTrackID)
+ {
+ for(Int_t i=0; i<GetNEtaSegments(); i++)
+ {
+ if(!fTrackID[i]) continue;
+ delete fTrackID[i];
+ }
+ delete [] fTrackID;
+ }
+#endif
+}
+
+void AliL3HoughTransformer::DeleteHistograms()
+{
+ if(!fParamSpace)
+ return;
+ for(Int_t i=0; i<GetNEtaSegments(); i++)
+ {
+ if(!fParamSpace[i]) continue;
+ delete fParamSpace[i];
+ }
+ delete [] fParamSpace;
+}
- fEtaMin = etarange[0];
- fEtaMax = etarange[1];
- fSlice = slice;
- fPatch = patch;
- fNumOfPadRows=NRowsSlice;
+void AliL3HoughTransformer::CreateHistograms(Int_t nxbin,Double_t pt_min,
+ Int_t nybin,Double_t phimin,Double_t phimax)
+{
+ //Create the histograms (parameter space).
+ //These are 2D histograms, span by kappa (curvature of track) and phi0 (emission angle with x-axis).
+ //The arguments give the range and binning;
+ //nxbin = #bins in kappa
+ //nybin = #bins in phi0
+ //pt_min = mimium Pt of track (corresponding to maximum kappa)
+ //phi_min = mimimum phi0 (degrees)
+ //phi_max = maximum phi0 (degrees)
+
+ Double_t x = AliL3Transform::GetBFact()*AliL3Transform::GetBField()/pt_min;
+ Double_t torad = AliL3Transform::Pi()/180;
+ CreateHistograms(nxbin,-1.*x,x,nybin,phimin*torad,phimax*torad);
}
-AliL3HoughTransformer::AliL3HoughTransformer(Int_t slice,Int_t patch,Double_t *etarange,Int_t n_eta_segments)
+void AliL3HoughTransformer::CreateHistograms(Int_t nxbin,Double_t xmin,Double_t xmax,
+ Int_t nybin,Double_t ymin,Double_t ymax)
{
- fTransform = new AliL3Transform();
- if(etarange)
+ fParamSpace = new AliL3Histogram*[GetNEtaSegments()];
+
+ Char_t histname[256];
+ for(Int_t i=0; i<GetNEtaSegments(); i++)
{
- //assumes you want to look at a given etaslice only
- fEtaMin = etarange[0];
- fEtaMax = etarange[1];
+ sprintf(histname,"paramspace_%d",i);
+ //fParamSpace[i] = new AliL3HistogramAdaptive(histname,0.1,1.5,0.05,nybin,ymin,ymax);
+ fParamSpace[i] = new AliL3Histogram(histname,"",nxbin,xmin,xmax,nybin,ymin,ymax);
}
- else
+
+#ifdef do_mc
+ if(fDoMC)
{
- //transform in all etaslices
- fEtaMin = 0;
- fEtaMax = slice < 18 ? 0.9 : -0.9;
+ AliL3Histogram *hist = fParamSpace[0];
+ Int_t ncells = (hist->GetNbinsX()+2)*(hist->GetNbinsY()+2);
+ cout<<"Transformer: Allocating "<<GetNEtaSegments()*ncells*sizeof(TrackIndex)<<" bytes to fTrackID"<<endl;
+ fTrackID = new TrackIndex*[GetNEtaSegments()];
+ for(Int_t i=0; i<GetNEtaSegments(); i++)
+ fTrackID[i] = new TrackIndex[ncells];
+ }
+#endif
+}
+
+void AliL3HoughTransformer::Reset()
+{
+ //Reset all the histograms
+
+ if(!fParamSpace)
+ {
+ LOG(AliL3Log::kWarning,"AliL3HoughTransformer::Reset","Histograms")
+ <<"No histograms to reset"<<ENDLOG;
+ return;
}
- fNumEtaSegments = n_eta_segments;
- fSlice = slice;
- fPatch = patch;
- fNumOfPadRows = NRowsSlice;
- fNRowsInPatch = NRows[fPatch][1]-NRows[fPatch][0] + 1;
- fBinTableBounds = (fNRowsInPatch+1)*(MaxNPads+1);
- fNDigitRowData = 0;
- fDigitRowData = 0;
- fHistoPt = 0;
+ for(Int_t i=0; i<GetNEtaSegments(); i++)
+ fParamSpace[i]->Reset();
+#ifdef do_mc
+ if(fDoMC)
+ {
+ AliL3Histogram *hist = fParamSpace[0];
+ Int_t ncells = (hist->GetNbinsX()+2)*(hist->GetNbinsY()+2);
+ for(Int_t i=0; i<GetNEtaSegments(); i++)
+ memset(fTrackID[i],0,ncells*sizeof(TrackIndex));
+ }
+#endif
}
+Int_t AliL3HoughTransformer::GetEtaIndex(Double_t eta)
+{
+ //Return the histogram index of the corresponding eta.
-AliL3HoughTransformer::~AliL3HoughTransformer()
+ Double_t etaslice = (GetEtaMax() - GetEtaMin())/GetNEtaSegments();
+ Double_t index = (eta-GetEtaMin())/etaslice;
+ return (Int_t)index;
+}
+
+void AliL3HoughTransformer::GetEtaIndexes(Double_t eta,Int_t *indexes)
{
- //Destructor
- if(fBinTable)
+ //Return histogram indexes in case of overlapping etaslices.
+
+ Double_t etaslice = (GetEtaMax() - GetEtaMin())/GetNEtaSegments();
+ Int_t index = (Int_t)((eta-GetEtaMin())/etaslice);
+ if(index%2 == 0)
{
- for(Int_t i=0; i<fBinTableBounds; i++)
- delete [] fBinTable[i];
- delete [] fBinTable;
+ indexes[0] = index;
+ indexes[1] = index - 1;
}
- if(fEtaIndex)
- delete [] fEtaIndex;
- if(fTrackTable)
+ else
{
- for(Int_t i=0; i<fNumEtaSegments; i++)
- delete [] fTrackTable[i];
- delete [] fTrackTable;
+ indexes[0] = index - 1;
+ indexes[1] = index;
}
- if(fTransform)
- delete fTransform;
-
-
}
-void AliL3HoughTransformer::SetInputData(UInt_t ndigits,AliL3DigitRowData *ptr)
+inline AliL3Histogram *AliL3HoughTransformer::GetHistogram(Int_t eta_index)
{
- fNDigitRowData = ndigits;
- fDigitRowData = ptr;
+ if(!fParamSpace || eta_index >= GetNEtaSegments() || eta_index < 0)
+ return 0;
+ if(!fParamSpace[eta_index])
+ return 0;
+ return fParamSpace[eta_index];
}
-void AliL3HoughTransformer::InitTables()
+Double_t AliL3HoughTransformer::GetEta(Int_t eta_index,Int_t slice)
{
- //Create LUT for the circle transform.
- //the actual transformation is done in TransformTables.
-
- AliL3Histogram *hist = fHistoPt;
-
- Int_t nbinsy = hist->GetNbinsY();
-
- fBinTable = new Int_t*[fBinTableBounds];
- Int_t index;
+ Double_t eta_slice = (GetEtaMax()-GetEtaMin())/GetNEtaSegments();
+ Double_t eta=0;
+ if(fEtaOverlap)
+ {
+ Int_t index = eta_index + 1;
+ eta=(Double_t)((index)*eta_slice);
+ }
+ else
+ eta=(Double_t)((eta_index+0.5)*eta_slice);
+ return eta;
+}
- Double_t etaslice = fEtaMax/fNumEtaSegments;
-
- Int_t etabounds = (MaxNPads+1)*(fNRowsInPatch+1)*(MaxNTimeBins+1);
- fEtaIndex = new Int_t[etabounds];
- for(Int_t i=0; i<etabounds; i++)
- fEtaIndex[i] = -1;
-
- fTrackTable = new Char_t*[fNumEtaSegments];
- for(Int_t i=0; i<fNumEtaSegments; i++)
+void AliL3HoughTransformer::TransformCircle()
+{
+ //Transform the input data with a circle HT.
+ //The function loops over all the data, and transforms each pixel with the equations:
+ //
+ //kappa = 2/R*sin(phi - phi0)
+ //
+ //where R = sqrt(x*x +y*y), and phi = arctan(y/x)
+ //
+ //Each pixel then transforms into a curve in the (kappa,phi0)-space. In order to find
+ //which histogram in which the pixel should be transformed, the eta-value is calculated
+ //and the proper histogram index is found by GetEtaIndex(eta).
+
+
+ AliL3DigitRowData *tempPt = GetDataPointer();
+ if(!tempPt)
{
- fTrackTable[i] = new Char_t[fBinTableBounds];
- for(Int_t j=0; j<fBinTableBounds; j++)
- fTrackTable[i][j] = 0;
+ LOG(AliL3Log::kError,"AliL3HoughTransformer::TransformCircle","Data")
+ <<"No input data "<<ENDLOG;
+ return;
}
- for(Int_t r=NRows[fPatch][0]; r<=NRows[fPatch][1]; r++)
+ //Loop over the padrows:
+ for(Int_t i=AliL3Transform::GetFirstRow(GetPatch()); i<=AliL3Transform::GetLastRow(GetPatch()); i++)
{
- Int_t prow = r - NRows[fPatch][0];
+ //Get the data on this padrow:
+ AliL3DigitData *digPt = tempPt->fDigitData;
+ if(i != (Int_t)tempPt->fRow)
+ {
+ cerr<<"AliL3HoughTransform::TransformCircle : Mismatching padrow numbering "<<i<<" "<<(Int_t)tempPt->fRow<<endl;
+ continue;
+ }
- for(Int_t p=0; p<fTransform->GetNPads(r); p++)
+ //Loop over the data on this padrow:
+ for(UInt_t j=0; j<tempPt->fNDigit; j++)
{
- Float_t xyz[3];
+ UShort_t charge = digPt[j].fCharge;
+ UChar_t pad = digPt[j].fPad;
+ UShort_t time = digPt[j].fTime;
+ if((Int_t)charge <= GetLowerThreshold() || (Int_t)charge > GetUpperThreshold())
+ continue;
+
Int_t sector,row;
- for(Int_t t=0; t<fTransform->GetNTimeBins(); t++)
+ Float_t xyz[3];
+
+ //Transform data to local cartesian coordinates:
+ AliL3Transform::Slice2Sector(GetSlice(),i,sector,row);
+ AliL3Transform::Raw2Local(xyz,sector,row,(Int_t)pad,(Int_t)time);
+
+ //Calculate the eta:
+ Double_t eta = AliL3Transform::GetEta(xyz);
+
+ //Get the corresponding index, which determines which histogram to fill:
+ Int_t eta_index = GetEtaIndex(eta);
+
+ if(eta_index < 0 || eta_index >= GetNEtaSegments())
+ continue;
+
+ //Get the correct histogrampointer:
+ AliL3Histogram *hist = fParamSpace[eta_index];
+ if(!hist)
{
- fTransform->Slice2Sector(fSlice,r,sector,row);
- fTransform->Raw2Local(xyz,sector,row,p,t);
- Double_t eta = fTransform->GetEta(xyz);
- if(eta < fEtaMin || eta > fEtaMax) continue;
- Int_t ind = (prow<<17) + (p<<9) + t;
- if(fEtaIndex[ind]>=0)
- printf("AliL3HoughTransformer::InitTables : Overlapping indexes in eta!!\n");
- Int_t eta_index = (Int_t)(eta/etaslice);
- if(eta_index < 0 || eta_index > fNumEtaSegments)
- continue;
- fEtaIndex[ind] = eta_index;
-
+ cerr<<"AliL3HoughTransformer::TransformCircle : Error getting histogram in index "<<eta_index<<endl;
+ continue;
}
- Double_t r_pix = sqrt(xyz[0]*xyz[0]+xyz[1]*xyz[1]);
- Double_t phi_pix = fTransform->GetPhi(xyz);
- index = (prow<<8) + p;
- fBinTable[index] = new Int_t[nbinsy+1];
+ //Do the transformation:
+ Float_t R = sqrt(xyz[0]*xyz[0] + xyz[1]*xyz[1]);
+ Float_t phi = AliL3Transform::GetPhi(xyz);
+ //Fill the histogram along the phirange
for(Int_t b=hist->GetFirstYbin(); b<=hist->GetLastYbin(); b++)
{
- Double_t phi0 = hist->GetBinCenterY(b);
- Double_t kappa = 2*sin(phi_pix-phi0)/r_pix;
- Int_t bin = hist->FindBin(kappa,phi0);
- if(fBinTable[index][b]!=0)
- printf("AliL3HoughTransformer::InitTables : Overlapping indexes %d %d b %d\n",fBinTable[index][b],index,b);
- fBinTable[index][b] = bin;
+ Float_t phi0 = hist->GetBinCenterY(b);
+ Float_t kappa = 2*sin(phi - phi0)/R;
+ hist->Fill(kappa,phi0,charge);
+ //hist->Fill(kappa,phi0,1);
+#ifdef do_mc
+ if(fDoMC)
+ {
+ Int_t bin = hist->FindBin(kappa,phi0);
+ for(Int_t t=0; t<3; t++)
+ {
+ Int_t label = digPt[j].fTrackID[t];
+ if(label < 0) break;
+ UInt_t c;
+ for(c=0; c<MaxTrack; c++)
+ if(fTrackID[eta_index][bin].fLabel[c] == label || fTrackID[eta_index][bin].fNHits[c] == 0)
+ break;
+ if(c == MaxTrack-1) cerr<<"AliL3HoughTransformer::TransformCircle : Array reached maximum!! "<<c<<endl;
+ fTrackID[eta_index][bin].fLabel[c] = label;
+ fTrackID[eta_index][bin].fNHits[c]++;
+ }
+ }
+#endif
}
}
-
+
+ //Move the data pointer to the next padrow:
+ AliL3MemHandler::UpdateRowPointer(tempPt);
}
-
}
-void AliL3HoughTransformer::TransformTables(AliL3Histogram **histos,AliL3Histogram **images)
+
+struct Digit {
+ Int_t row;
+ Double_t r;
+ Double_t phi;
+ Int_t charge;
+ Digit *next;
+};
+struct EtaContainer {
+ Digit *first;
+ Digit *last;
+};
+void AliL3HoughTransformer::TransformCircleC(Int_t *row_range,Int_t every)
{
- //Transform all the pixels while reading, and fill the corresponding histograms.
- //Transform is done using LUT created in InitTables.
- //fTrackTable : table telling whether a specific pixel is active (nonzero):
- //fTrackTable = 0 -> no track
- //fTrackindex > 0 -> track present
- //fTrackindex = -1 -> track has been removed (already found)
- //fEtaIndex : table storing the etaindex -> used to find correct histogram to fill
- //fBinTable : table storing all the bins to fill for each nonzero pixel
-
- Int_t eta_index;
- AliL3DigitRowData *tempPt = (AliL3DigitRowData*)fDigitRowData;
- AliL3Histogram *hist;
+ //Circle transform, using combinations of every 2 points lying
+ //on different padrows and within the same etaslice.
+ AliL3DigitRowData *tempPt = GetDataPointer();
if(!tempPt)
+ LOG(AliL3Log::kError,"AliL3HoughTransformer::TransformCircleC","Data")
+ <<"No input data "<<ENDLOG;
+
+ Int_t minrow = AliL3Transform::GetFirstRow(GetPatch());
+ Int_t maxrow = AliL3Transform::GetLastRow(GetPatch());
+ if(row_range)
{
- LOG(AliL3Log::kError,"AliL3HoughTransformer::TransformTables","data")<<
- "Zero datapointer"<<ENDLOG;
- return;
+ minrow = row_range[0];
+ maxrow = row_range[1];
+ if(minrow < AliL3Transform::GetFirstRow(GetPatch()) || minrow >= AliL3Transform::GetLastRow(GetPatch()))
+ minrow = AliL3Transform::GetFirstRow(GetPatch());
+ if(maxrow < AliL3Transform::GetFirstRow(GetPatch()) || maxrow >= AliL3Transform::GetLastRow(GetPatch()))
+ maxrow = AliL3Transform::GetLastRow(GetPatch());
+ if(minrow > maxrow || maxrow==minrow)
+ {
+ cerr<<"AliL3HoughTransformer::TransformCircleC : Bad row range "<<minrow<<" "<<maxrow<<endl;
+ return;
+ }
}
+ else
+ {
+ minrow = AliL3Transform::GetFirstRow(GetPatch());
+ maxrow = AliL3Transform::GetLastRow(GetPatch());
+ }
+
+ Int_t counter=0;
+ for(Int_t i=AliL3Transform::GetFirstRow(GetPatch()); i<=AliL3Transform::GetLastRow(GetPatch()); i++)
+ {
+ counter += tempPt->fNDigit;
+ AliL3MemHandler::UpdateRowPointer(tempPt);
+ }
+
+ Int_t bound = (GetNEtaSegments()+1)*(AliL3Transform::GetNRows(GetPatch())+1);
+ EtaContainer *etaPt = new EtaContainer[bound];
+ memset(etaPt,0,bound*sizeof(EtaContainer));
+
+ Digit *digits = new Digit[counter];
+ cout<<"Allocating "<<counter*sizeof(Digit)<<" bytes to digitsarray"<<endl;
+ memset(digits,0,counter*sizeof(Digit));
- Int_t out_count=0,tot_count=0;
- Int_t index,ind;
-
- for(Int_t i=NRows[fPatch][0]; i<=NRows[fPatch][1]; i++)
+ Int_t sector,row,tot_charge,pad,time,charge;
+ Double_t r1,r2,phi1,phi2,eta,kappa,phi_0;
+ Float_t xyz[3];
+
+ counter=0;
+ tempPt = GetDataPointer();
+
+ cout<<"Calculating digits in patch "<<GetPatch()<<endl;
+ for(Int_t i=AliL3Transform::GetFirstRow(GetPatch()); i<=AliL3Transform::GetLastRow(GetPatch()); i++)
{
- Int_t prow = i - NRows[fPatch][0];
- AliL3DigitData *bins = tempPt->fDigitData;
- for(UInt_t dig=0; dig<tempPt->fNDigit; dig++)
+ AliL3DigitData *digPt = tempPt->fDigitData;
+ for(UInt_t di=0; di<tempPt->fNDigit; di++)
{
- index = (prow<<8) + bins[dig].fPad;
- ind = (prow<<17) + (bins[dig].fPad<<9) + bins[dig].fTime;
- eta_index = fEtaIndex[ind];
- if(eta_index < 0) continue; //pixel out of etarange
-
- if(fTrackTable[eta_index][index]<0) continue; //this pixel has already been removed.
- fTrackTable[eta_index][index]++; //this pixel is now marked as active (it is nonzero)
+ charge = digPt[di].fCharge;
+ pad = digPt[di].fPad;
+ time = digPt[di].fTime;
+ AliL3Transform::Slice2Sector(GetSlice(),i,sector,row);
+ AliL3Transform::Raw2Local(xyz,sector,row,(Int_t)pad,(Int_t)time);
+ eta = AliL3Transform::GetEta(xyz);
- tot_count++;
- hist = histos[eta_index];
-
- if(images)
+ digits[counter].row = i;
+ digits[counter].r = sqrt(xyz[0]*xyz[0] + xyz[1]*xyz[1]);
+ digits[counter].phi = atan2(xyz[1],xyz[0]);
+ digits[counter].charge = charge;
+
+ if(!fEtaOverlap)
{
- //Display the transformed images.
- AliL3Histogram *image = images[eta_index];
- Float_t xyz_local[3];
- Int_t sector,row;
- fTransform->Slice2Sector(fSlice,i,sector,row);
- fTransform->Raw2Local(xyz_local,sector,row,bins[dig].fPad,bins[dig].fTime);
- image->Fill(xyz_local[0],xyz_local[1],bins[dig].fCharge);
+ Int_t eta_index = GetEtaIndex(eta);
+
+ Int_t index = (GetNEtaSegments()+1)*(i-AliL3Transform::GetFirstRow(GetPatch())) + eta_index;
+
+ if(index > 0 && index < bound)
+ {
+ if(etaPt[index].first == 0)
+ etaPt[index].first = &digits[counter];
+ else
+ (etaPt[index].last)->next = &digits[counter];
+ etaPt[index].last = &digits[counter];
+ }
}
-
- if(!hist)
+ else
{
- printf("Error getting histogram!\n");
- continue;
+ Int_t eta_index[2];
+ GetEtaIndexes(eta,eta_index);
+ Int_t index[2];
+ index[0] = (GetNEtaSegments()+1)*(i-AliL3Transform::GetFirstRow(GetPatch())) + eta_index[0];
+ index[1] = (GetNEtaSegments()+1)*(i-AliL3Transform::GetFirstRow(GetPatch())) + eta_index[1];
+ if(index[0] == index[1])
+ {
+ cerr<<"Same etaindexes "<<index[0]<<" "<<index[1]<<endl;
+ exit(5);
+ }
+
+ Int_t ind = index[0];
+ if(ind > 0 && ind < bound)
+ {
+ if(etaPt[ind].first == 0)
+ etaPt[ind].first = &digits[counter];
+ else
+ (etaPt[ind].last)->next = &digits[counter];
+ etaPt[ind].last = &digits[counter];
+ }
+
+ ind = index[1];
+ if(ind > 0 && ind < bound)
+ {
+ if(etaPt[ind].first == 0)
+ etaPt[ind].first = &digits[counter];
+ else
+ (etaPt[ind].last)->next = &digits[counter];
+ etaPt[ind].last = &digits[counter];
+ }
}
- for(Int_t p=hist->GetFirstYbin(); p<=hist->GetLastYbin(); p++)
- hist->AddBinContent(fBinTable[index][p],bins[dig].fCharge);
-
- }
-
- Byte_t *tmp = (Byte_t*)tempPt;
- Int_t size = sizeof(AliL3DigitRowData) + tempPt->fNDigit*sizeof(AliL3DigitData);
- tmp += size;
- tempPt = (AliL3DigitRowData*)tmp;
- }
-
-}
-void AliL3HoughTransformer::WriteTables()
-{
- //Write the tables to asci files.
+ counter++;
+ }
+ AliL3MemHandler::UpdateRowPointer(tempPt);
+ }
- AliL3Histogram *hist = fHistoPt;
- Char_t name[100];
- sprintf(name,"histogram_table_%d.txt",fPatch);
- FILE *file = fopen(name,"w");
+ cout<<"Doing the combinatorics"<<endl;
- Int_t etabounds = (MaxNPads+1)*(fNRowsInPatch+1)*(MaxNTimeBins+1);
- for(Int_t i=0; i<etabounds; i++)
- {
- if(fEtaIndex[i]<0) continue;
- fprintf(file,"%d %d\n",i,fEtaIndex[i]);
- }
- fclose(file);
+ Digit *dPt1,*dPt2;
- sprintf(name,"bin_table_%d.txt",fPatch);
- FILE *file2 = fopen(name,"w");
- for(Int_t i=0; i<fBinTableBounds; i++)
+ for(Int_t e=0; e<GetNEtaSegments(); e++)
{
- if(!fBinTable[i]) continue;
- fprintf(file2,"%d ",i);
- for(Int_t j=hist->GetFirstYbin(); j<=hist->GetLastYbin(); j++)
+ for(Int_t i=minrow; i<=maxrow; i+=every)
{
- fprintf(file2,"%d ",fBinTable[i][j]);
- }
- fprintf(file2,"\n");
- }
- fclose(file2);
-}
-
-Double_t AliL3HoughTransformer::CpuTime()
-{
- return (Double_t)(clock()) / CLOCKS_PER_SEC;
-}
-
-/*
-void AliL3HoughTransformer::InitTemplates(TH2F *hist)
-{
-
- AliL3Digits *pixel;
-
- Int_t ymin = hist->GetYaxis()->GetFirst();
- Int_t ymax = hist->GetYaxis()->GetLast();
- Int_t nbinsy = hist->GetNbinsY();
-
- fIndex = new Int_t*[fNDigits];
- for(Int_t i=0; i<fNDigits; i++)
- fIndex[i] = new Int_t[nbinsy+1];
-
- Int_t sector,row;
-
- for(Int_t padrow = NRows[fPatch][0]; padrow <= NRows[fPatch][1]; padrow++)
- {
-
- for(pixel=(AliL3Digits*)fRowContainer[padrow].first; pixel!=0; pixel=(AliL3Digits*)pixel->nextRowPixel)
- {
- Float_t xyz[3];
- fTransform->Slice2Sector(fSlice,padrow,sector,row);
- fTransform->Raw2Local(xyz,sector,row,pixel->fPad,pixel->fTime);
+ Int_t index1 = (GetNEtaSegments()+1)*(i-AliL3Transform::GetFirstRow(GetPatch())) + e;
- Double_t r_pix = sqrt(xyz[0]*xyz[0]+xyz[1]*xyz[1]);
-
- Double_t phi_pix = fTransform->GetPhi(xyz);
- Int_t index = pixel->fIndex;
- if(index >= fNDigits)
- printf("AliL3HoughTransformer::InitTemplates : Index error! %d\n",index);
- for(Int_t p=ymin; p<=ymax; p++)
+ for(dPt1 = (Digit*)etaPt[index1].first; dPt1 != 0; dPt1 = (Digit*)dPt1->next)
{
-
- Double_t phi0 = hist->GetYaxis()->GetBinCenter(p);
- Double_t kappa = 2*sin(phi_pix-phi0)/r_pix;
- //printf("kappa %f phi0 %f\n",kappa,phi0);
- Int_t bin = hist->FindBin(kappa,phi0);
- if(fIndex[index][p]!=0)
- printf("AliL3HoughTransformer::InitTemplates : Overlapping indexes\n");
- fIndex[index][p] = bin;
+ for(Int_t j=i+every; j<=maxrow; j+=every)
+ {
+ Int_t index2 = (GetNEtaSegments()+1)*(j-AliL3Transform::GetFirstRow(GetPatch())) + e;
+
+ for(dPt2 = (Digit*)etaPt[index2].first; dPt2 != 0; dPt2 = (Digit*)dPt2->next)
+ {
+ if(dPt1->row == dPt2->row)
+ {
+ cerr<<"same row; indexes "<<index1<<" "<<index2<<endl;
+ exit(5);
+ }
+
+ //Get the correct histogrampointer:
+ AliL3Histogram *hist = fParamSpace[e];
+ if(!hist)
+ {
+ printf("AliL3HoughTransformer::TransformCircleC() : No histogram at index %d\n",i);
+ continue;
+ }
+
+ //Do the transform:
+ r1 = dPt1->r;
+ phi1 = dPt1->phi;
+ r2 = dPt2->r;
+ phi2 = dPt2->phi;
+ phi_0 = atan( (r2*sin(phi1)-r1*sin(phi2))/(r2*cos(phi1)-r1*cos(phi2)) );
+ kappa = 2*sin(phi2-phi_0)/r2;
+ tot_charge = dPt1->charge + dPt2->charge;
+ hist->Fill(kappa,phi_0,tot_charge);
+
+ }
+ }
}
}
}
-
-}
+ cout<<"done"<<endl;
+ delete [] etaPt;
+ delete [] digits;
-void AliL3HoughTransformer::Transform2Circle(TH2F *hist,Int_t eta_index)
-{
- //Transformation is done with respect to local coordinates in slice.
- //Transform every pixel into whole phirange, using parametrisation:
- //kappa = 2*sin(phi-phi0)/R
- //Assumes you run InitTemplates first!!!!
+}
- AliL3Digits *pix1;
-
- Int_t nbinsy = hist->GetNbinsY();
+void AliL3HoughTransformer::TransformLine(Int_t *row_range,Float_t *phirange)
+{
+ //Do a line transform on the data.
- Int_t totsignal=0,vol_index;
- if(fNumEtaSegments==1)
- eta_index=0; //only looking in one etaslice.
- for(Int_t padrow = NRows[fPatch][0]; padrow <= NRows[fPatch][1]; padrow++)
+ AliL3DigitRowData *tempPt = GetDataPointer();
+ if(!tempPt)
{
- vol_index = eta_index*fNumOfPadRows + padrow;
- //for(pix1=(AliL3Digits*)fRowContainer[padrow].first; pix1!=0; pix1=(AliL3Digits*)pix1->nextRowPixel)
- for(pix1=(AliL3Digits*)fVolume[vol_index].first; pix1!=0; pix1=(AliL3Digits*)pix1->fNextVolumePixel)
+ LOG(AliL3Log::kError,"AliL3HoughTransformer::TransformLine","Data")
+ <<"No input data "<<ENDLOG;
+ return;
+ }
+
+ Int_t minrow = AliL3Transform::GetFirstRow(GetPatch());
+ Int_t maxrow = AliL3Transform::GetLastRow(GetPatch());
+ if(row_range)
+ {
+ minrow = row_range[0];
+ maxrow = row_range[1];
+ if(minrow < AliL3Transform::GetFirstRow(GetPatch()) || minrow >= AliL3Transform::GetLastRow(GetPatch()))
+ minrow = AliL3Transform::GetFirstRow(GetPatch());
+ if(maxrow < AliL3Transform::GetFirstRow(GetPatch()) || maxrow >= AliL3Transform::GetLastRow(GetPatch()))
+ maxrow = AliL3Transform::GetLastRow(GetPatch());
+ if(minrow > maxrow || maxrow==minrow)
{
- Float_t xyz[3];
- fTransform->Raw2Global(xyz,2,padrow,pix1->fPad,pix1->fTime);
- Double_t eta = fTransform->GetEta(xyz);
- if(eta < fEtaMin || eta > fEtaMax)
- printf("\n Eta OUT OF RANGE\n");
-
- Short_t signal = pix1->fCharge;
- Int_t index = pix1->fIndex;
- if(index < 0) continue; //This pixel has been removed.
- totsignal += signal;
- for(Int_t p=0; p <= nbinsy; p++)
- hist->AddBinContent(fIndex[index][p],signal);
-
+ cerr<<"AliL3HoughTransformer::TransformCircleC : Bad row range "<<minrow<<" "<<maxrow<<endl;
+ return;
}
-
}
-
- printf("Total signal %d\n",totsignal);
-}
-
-void AliL3HoughTransformer::Transform2Circle(TH2F **histos,Int_t n_eta_segments,UInt_t ndigits,AliL3DigitRowData *ptr)
-{
- //Transform all the pixels while reading them, and fill the corresponding histograms.
- //Everything is done in one go here.
-
- Double_t etaslice = 0.9/n_eta_segments;
- Int_t eta_index;
- AliL3DigitRowData *tempPt = (AliL3DigitRowData*)ptr;
- TH2F *hist;
- Int_t out_count=0,tot_count=0;
- for(Int_t i=NRows[fPatch][0]; i<=NRows[fPatch][1]; i++)
+ for(Int_t i=minrow; i<=maxrow; i++)
{
- printf("doing row %d\n",i);
- for(UInt_t dig=0; dig<tempPt->fNDigit; dig++)
+ AliL3DigitData *digPt = tempPt->fDigitData;
+ if(i != (Int_t)tempPt->fRow)
{
-
- AliL3DigitData *bins = tempPt->fDigitData;
- Float_t xyz[3];
+ printf("AliL3HoughTransform::TransformLine : Mismatching padrow numbering\n");
+ continue;
+ }
+ for(UInt_t j=0; j<tempPt->fNDigit; j++)
+ {
+ UShort_t charge = digPt[j].fCharge;
+ UChar_t pad = digPt[j].fPad;
+ UShort_t time = digPt[j].fTime;
+ if(charge < GetLowerThreshold())
+ continue;
Int_t sector,row;
- fTransform->Slice2Sector(fSlice,i,sector,row);
- fTransform->Raw2Local(xyz,sector,row,bins[dig].fPad,bins[dig].fTime);
- Double_t eta = fTransform->GetEta(xyz);
- eta_index = (Int_t)(eta/etaslice);
- if(eta_index < 0 || eta_index >= n_eta_segments)
+ Float_t xyz[3];
+ AliL3Transform::Slice2Sector(GetSlice(),i,sector,row);
+ AliL3Transform::Raw2Local(xyz,sector,row,(Int_t)pad,(Int_t)time);
+
+ if(phirange)
{
- //printf("Eta index out of range %d\n",eta_index);
- out_count++;
- continue;
+ Float_t phi = AliL3Transform::GetPhi(xyz);
+ if(phi < phirange[0] || phi > phirange[1])
+ continue;
}
- tot_count++;
- hist = histos[eta_index];
+ Float_t eta = AliL3Transform::GetEta(xyz);
+ Int_t eta_index = GetEtaIndex(eta);//(Int_t)(eta/etaslice);
+ if(eta_index < 0 || eta_index >= GetNEtaSegments())
+ continue;
+
+ xyz[0] = xyz[0] - AliL3Transform::Row2X(minrow);
+
+ //Get the correct histogram:
+ AliL3Histogram *hist = fParamSpace[eta_index];
if(!hist)
{
- printf("Error getting histogramm!\n");
- return;
+ printf("AliL3HoughTransformer::TransformLine : Error getting histogram in index %d\n",eta_index);
+ continue;
}
-
- Int_t ymin = hist->GetYaxis()->GetFirst();
- Int_t ymax = hist->GetYaxis()->GetLast();
-
- Double_t r_pix = sqrt(xyz[0]*xyz[0]+xyz[1]*xyz[1]);
- Double_t phi_pix = fTransform->GetPhi(xyz);
- for(Int_t p=ymin; p<=ymax; p++)
+ for(Int_t xbin=hist->GetFirstXbin(); xbin<hist->GetLastXbin(); xbin++)
{
- Double_t phi0 = hist->GetYaxis()->GetBinCenter(p);
- Double_t kappa = 2*sin(phi_pix-phi0)/r_pix;
- //printf("kappa %f phi0 %f\n",kappa,phi0);
- hist->Fill(kappa,phi0,bins[dig].fCharge);
+ Double_t theta = hist->GetBinCenterX(xbin);
+ Double_t rho = xyz[0]*cos(theta) + xyz[1]*sin(theta);
+ hist->Fill(theta,rho,charge);
}
}
-
-
- Byte_t *tmp = (Byte_t*)tempPt;
- Int_t size = sizeof(AliL3DigitRowData) + tempPt->fNDigit*sizeof(AliL3DigitData);
- tmp += size;
- tempPt = (AliL3DigitRowData*)tmp;
-
+ AliL3MemHandler::UpdateRowPointer(tempPt);
}
- printf("There were %d pixels out of range and %d inside\n", out_count,tot_count);
-
}
-
-void AliL3HoughTransformer::TransformLines2Circle(TH2F *hist,AliL3TrackArray *tracks)
+struct LDigit {
+ Int_t row;
+ Int_t charge;
+ Float_t y;
+ LDigit *next;
+};
+struct LEtaContainer {
+ LDigit *first;
+ LDigit *last;
+};
+void AliL3HoughTransformer::TransformLineC(Int_t *rowrange,Float_t *phirange)
{
+ AliL3DigitRowData *tempPt = GetDataPointer();
+ if(!tempPt)
+ LOG(AliL3Log::kError,"AliL3HoughTransformer::TransformCircleC","Data")
+ <<"No input data "<<ENDLOG;
- for(Int_t i=0; i<tracks->GetNTracks(); i++)
- {
- AliL3HoughTrack *track = (AliL3HoughTrack*)tracks->GetCheckedTrack(i);
- if(!track) {printf("AliL3HoughTransformer::TransformLines2Circle : NO TRACK IN ARRAY\n"); continue;}
-
- Double_t xmin = fTransform->Row2X(track->GetFirstRow());
- Double_t xmax = fTransform->Row2X(track->GetLastRow());
- Double_t a = -1./tan(track->GetPsiLine());
- Double_t b = track->GetDLine()/sin(track->GetPsiLine());
-
- Double_t ymin = a*xmin + b;
- Double_t ymax = a*xmax + b;
-
- Double_t middle_x = xmin + (xmax-xmin)/2;
- Double_t middle_y = ymin + (ymax-ymin)/2;
-
- Double_t r_middle = sqrt(middle_x*middle_x + middle_y*middle_y);
- Double_t phi = atan2(middle_y,middle_x);
- Double_t phi0 = 2*phi - track->GetPsiLine();
- Double_t kappa = 2*sin(phi-phi0)/r_middle;
- hist->Fill(kappa,phi0,track->GetWeight());
-
+ Int_t counter=0;
+ for(Int_t i=AliL3Transform::GetFirstRow(GetPatch()); i<=AliL3Transform::GetLastRow(GetPatch()); i++)
+ {
+ counter += tempPt->fNDigit;
+ AliL3MemHandler::UpdateRowPointer(tempPt);
}
-
-}
-
-void AliL3HoughTransformer::Transform2Line(TH2F *hist,Int_t ref_row,Int_t *rowrange,Double_t *phirange,TH2F *raw)
-{
- //Transform every pixel into histogram, using parametrisation:
- //D = x*cos(psi) + y*sin(psi)
-
- // printf("In Transform; rowrange %d %d ref_row %d phirange %f %f\n",rowrange[0],rowrange[1],ref_row,phirange[0],phirange[1]);
-
- AliL3Digits *pix1;
+ Int_t bound = (GetNEtaSegments()+1)*(AliL3Transform::GetNRows(GetPatch())+1);
+ LEtaContainer *etaPt = new LEtaContainer[bound];
+ memset(etaPt,0,bound*sizeof(LEtaContainer));
- Int_t xmin = hist->GetXaxis()->GetFirst();
- Int_t xmax = hist->GetXaxis()->GetLast();
-
- Double_t x0 = fTransform->Row2X(ref_row);
- Double_t y0 = 0;
+ LDigit *digits = new LDigit[counter];
+ cout<<"Allocating "<<counter*sizeof(LDigit)<<" bytes to digitsarray"<<endl;
+ memset(digits,0,counter*sizeof(LDigit));
Int_t sector,row;
- //for(Int_t padrow = NRows[fPatch][0]; padrow <= NRows[fPatch][1]; padrow++)
-
- Double_t phi_min = -10*ToRad;
- Double_t phi_max = 10*ToRad;
- Double_t delta_phi = (phi_max-phi_min)/fNPhiSegments;
-
-
- Int_t phi_min_index = (Int_t)((phirange[0]*ToRad-phi_min)/delta_phi);
- Int_t phi_max_index = (Int_t)((phirange[1]*ToRad-phi_min)/delta_phi);
-
+ Float_t xyz[3];
- Int_t index;
+ counter=0;
+ tempPt = GetDataPointer();
- for(Int_t phi=phi_min_index; phi <= phi_max_index; phi++)
+ cout<<"Calculating digits in patch "<<GetPatch()<<endl;
+ for(Int_t i=AliL3Transform::GetFirstRow(GetPatch()); i<=AliL3Transform::GetLastRow(GetPatch()); i++)
{
- for(Int_t padrow = rowrange[0]; padrow <= rowrange[1]; padrow++)
+ AliL3DigitData *digPt = tempPt->fDigitData;
+ for(UInt_t di=0; di<tempPt->fNDigit; di++)
{
+ Int_t charge = digPt[di].fCharge;
+ Int_t pad = digPt[di].fPad;
+ Int_t time = digPt[di].fTime;
+ AliL3Transform::Slice2Sector(GetSlice(),i,sector,row);
+ AliL3Transform::Raw2Local(xyz,sector,row,(Int_t)pad,(Int_t)time);
+ Double_t eta = AliL3Transform::GetEta(xyz);
+
+ Float_t phi = atan2(xyz[1],xyz[0]);
+ if(phi < phirange[0] || phi > phirange[1]) continue;
+
+ digits[counter].row = i;
+ digits[counter].y = xyz[1];
+ digits[counter].charge = charge;
+
+ Int_t eta_index = GetEtaIndex(eta);
+ Int_t index = (GetNEtaSegments()+1)*(i-AliL3Transform::GetFirstRow(GetPatch())) + eta_index;
- index = phi*fNumOfPadRows + padrow;
- //printf("Looping index %d\n",index);
- if(index > fContainerBounds || index < 0)
+ if(index > 0 && index < bound)
{
- printf("AliL3HoughTransformer::Transform2Line : index %d out of range \n",index);
- return;
+ if(etaPt[index].first == 0)
+ etaPt[index].first = &digits[counter];
+ else
+ (etaPt[index].last)->next = &digits[counter];
+ etaPt[index].last = &digits[counter];
}
- for(pix1=(AliL3Digits*)fRowContainer[padrow].first; pix1!=0; pix1=(AliL3Digits*)pix1->nextRowPixel)
- //for(pix1=(AliL3Digits*)fPhiRowContainer[index].first; pix1!=0; pix1=(AliL3Digits*)pix1->nextPhiRowPixel)
+ counter++;
+ }
+ AliL3MemHandler::UpdateRowPointer(tempPt);
+ }
+
+ cout<<"Doing the combinatorics"<<endl;
+
+ LDigit *dPt1,*dPt2;
+
+ for(Int_t e=0; e<GetNEtaSegments(); e++)
+ {
+ for(Int_t i=rowrange[0]; i<=rowrange[1]; i++)
+ {
+ Int_t index1 = (GetNEtaSegments()+1)*(i-AliL3Transform::GetFirstRow(GetPatch())) + e;
+
+ for(dPt1 = (LDigit*)etaPt[index1].first; dPt1 != 0; dPt1 = (LDigit*)dPt1->next)
{
- //printf("Transforming pixel in index %d pad %d time %d padrow %d\n",index,pix1->fPad,pix1->fTime,padrow);
- Float_t xyz[3];
- fTransform->Slice2Sector(fSlice,padrow,sector,row);
- fTransform->Raw2Local(xyz,sector,row,pix1->fPad,pix1->fTime);
-
- if(raw)
- raw->Fill(xyz[0],xyz[1],pix1->fCharge);
-
- xyz[0] = xyz[0]-x0;
- xyz[1] = xyz[1]-y0;
-
- //printf("calculating...");
- for(Int_t d=xmin+1; d<=xmax; d++)
+ for(Int_t j=i+1; j<=rowrange[1]; j++)
{
- Double_t psi = hist->GetXaxis()->GetBinCenter(d);
- Double_t D = xyz[0]*cos(psi) + xyz[1]*sin(psi);
+ Int_t index2 = (GetNEtaSegments()+1)*(j-AliL3Transform::GetFirstRow(GetPatch())) + e;
- Short_t signal = pix1->fCharge;
- hist->Fill(psi,D,signal);
- //printf("Filling histo, psi %f D %f\n",psi,D);
+ for(dPt2 = (LDigit*)etaPt[index2].first; dPt2 != 0; dPt2 = (LDigit*)dPt2->next)
+ {
+ if(dPt1->row == dPt2->row)
+ {
+ cerr<<"same row; indexes "<<index1<<" "<<index2<<endl;
+ exit(5);
+ }
+
+ //Get the correct histogrampointer:
+ AliL3Histogram *hist = fParamSpace[e];
+ if(!hist)
+ {
+ printf("AliL3HoughTransformer::TransformCircleC() : No histogram at index %d\n",i);
+ continue;
+ }
+
+ //Do the transform:
+ float x1 = AliL3Transform::Row2X(dPt1->row) - AliL3Transform::Row2X(rowrange[0]);
+ float x2 = AliL3Transform::Row2X(dPt2->row) - AliL3Transform::Row2X(rowrange[0]);
+ float y1 = dPt1->y;
+ float y2 = dPt2->y;
+ float theta = atan2(x2-x1,y1-y2);
+ float rho = x1*cos(theta)+y1*sin(theta);
+ hist->Fill(theta,rho,1);//dPt1->charge+dPt2->charge);
+ }
}
- //printf("done\n");
}
- //printf(" done\n");
}
-
}
-
-}
+ cout<<"done"<<endl;
+ delete [] etaPt;
+ delete [] digits;
+}
-void AliL3HoughTransformer::GetPixels(Char_t *rootfile,TH2F *hist)
+Int_t AliL3HoughTransformer::GetTrackID(Int_t eta_index,Double_t kappa,Double_t psi)
{
-
- //read data from rootfile. more or less obsolete code this.
-
- TFile *file = new TFile(rootfile);
- file->cd();
-
- AliTPCParam *param=(AliTPCParam *)file->Get("75x40_100x60");
- TTree *t=(TTree*)file->Get("TreeD_75x40_100x60");
-
- AliSimDigits da, *digarr=&da;
- t->GetBranch("Segment")->SetAddress(&digarr);
- Stat_t num_of_entries=t->GetEntries();
-
- Int_t digit_counter=0;
- Float_t xyz[3];
- Double_t eta;
-
- Int_t nrows = NRows[fPatch][1] - NRows[fPatch][0] + 1;
- printf("nrows %d slice %d patch %d\n",nrows,fSlice,fPatch);
-
- if(fRowContainer)
- delete [] fRowContainer;
- fRowContainer = new AliL3HoughContainer[fNumOfPadRows];
- memset(fRowContainer,0,fNumOfPadRows*sizeof(AliL3HoughContainer));
-
-
- //fContainerBounds = (fNPhiSegments+1)*(fNumOfPadRows+1);
- //printf("Allocating %d bytes to container of size %d\n",fContainerBounds*sizeof(AliL3HoughContainer),fContainerBounds);
-
-
- // if(fPhiRowContainer)
- // delete [] fPhiRowContainer;
- // fPhiRowContainer = new AliL3HoughContainer[fContainerBounds];
- // memset(fPhiRowContainer,0,fContainerBounds*sizeof(AliL3HoughContainer));
-
- fContainerBounds = (fNumEtaSegments+1)*(fNumOfPadRows+1);
- if(fVolume)
- delete [] fVolume;
- fVolume = new AliL3HoughContainer[fContainerBounds];
- memset(fVolume,0,fContainerBounds*sizeof(AliL3HoughContainer));
-
- // Double_t phi_min = -10*ToRad;
- // Double_t phi_max = 10*ToRad;
- // Double_t delta_phi = (phi_max-phi_min)/fNPhiSegments;
-
- Double_t eta_slice = (fEtaMax-fEtaMin)/fNumEtaSegments;
- Int_t index;
- digit_counter=0;
-
- //printf("\nLoading ALL pixels in slice\n\n");
-
- for (Int_t i=0; i<num_of_entries; i++)
- {
- t->GetEvent(i);
- Int_t sector;
- Int_t row;
- param->AdjustSectorRow(digarr->GetID(),sector,row);
- Int_t slice,padrow;
- fTransform->Sector2Slice(slice,padrow,sector,row);
- if(slice != fSlice) continue;
- if(padrow < NRows[fPatch][0]) continue;
- if(padrow > NRows[fPatch][1]) break;
- digarr->First();
- do {
- Int_t time=digarr->CurrentRow();
- Int_t pad=digarr->CurrentColumn();
- Short_t signal=digarr->CurrentDigit();
- if(time < param->GetMaxTBin()-1 && time > 0)
- if(digarr->GetDigit(time-1,pad) <= param->GetZeroSup()
- && digarr->GetDigit(time+1,pad) <= param->GetZeroSup())
- continue;
-
-
- fTransform->Raw2Global(xyz,sector,row,pad,time);
- eta = fTransform->GetEta(xyz);
-
- if(eta < fEtaMin || eta > fEtaMax) continue;
- fTransform->Global2Local(xyz,sector);
-
-
- //phi = fTransform->GetPhi(xyz);
- if(hist)
- hist->Fill(xyz[0],xyz[1],signal);
-
- AliL3Digits *dig = new AliL3Digits;
- dig->fIndex = digit_counter;
- digit_counter++;
- dig->fCharge = signal;
- dig->fPad = pad;
- dig->fTime = time;
-
- if(fRowContainer[padrow].first == NULL)
- fRowContainer[padrow].first = (void*)dig;
- else
- ((AliL3Digits*)(fRowContainer[padrow].last))->nextRowPixel=dig;
- fRowContainer[padrow].last = (void*)dig;
-
- //thisHit->etaIndex=(Int_t)((thisHit->GetEta()-fEtaMin)/etaSlice + 1);
- Int_t eta_index = (Int_t)((eta-fEtaMin)/eta_slice);
- index = eta_index*fNumOfPadRows + padrow;
- if(index > fContainerBounds || index < 0)
- {
-
- //printf("AliL3HoughTransformer::GetPixels : index out of range %d %d eta_index %d padrow %d\n",index,fContainerBounds,eta_index,padrow);
- continue;
- }
-
- if(fVolume[index].first == NULL)
- fVolume[index].first = (void*)dig;
- else
- ((AliL3Digits*)(fVolume[index].last))->fNextVolumePixel = dig;
- fVolume[index].last = (void*)dig;
-
-
- // Int_t phi_index = (Int_t)((phi-phi_min)/delta_phi);
- // index = phi_index*fNumOfPadRows + padrow;
- // if(phi_index > fContainerBounds || phi_index < 0)
- // {
- // printf("AliL3HoughTransform::GetPixels : index out of range %d\n",phi_index);
- // continue;
- // }
-
- // if(fPhiRowContainer[index].first == NULL)
- // fPhiRowContainer[index].first = (void*)dig;
- // else
- // ((AliL3Digits*)(fPhiRowContainer[index].last))->nextPhiRowPixel = dig;
- // fPhiRowContainer[index].last=(void*)dig;
-
- }while (digarr->Next());
-
+ if(!fDoMC)
+ {
+ cerr<<"AliL3HoughTransformer::GetTrackID : Flag switched off"<<endl;
+ return -1;
}
- fNDigits = digit_counter;
- printf("digitcounter %d\n",digit_counter);
- printf("Allocated %d bytes to pixels\n",digit_counter*sizeof(AliL3Digits));
- file->Close();
- delete file;
-
+#ifdef do_mc
+ if(eta_index < 0 || eta_index > GetNEtaSegments())
+ {
+ cerr<<"AliL3HoughTransformer::GetTrackID : Wrong etaindex "<<eta_index<<endl;
+ return -1;
+ }
+ AliL3Histogram *hist = fParamSpace[eta_index];
+ Int_t bin = hist->FindBin(kappa,psi);
+ Int_t label=-1;
+ Int_t max=0;
+ for(UInt_t i=0; i<MaxTrack; i++)
+ {
+ Int_t nhits=fTrackID[eta_index][bin].fNHits[i];
+ if(nhits == 0) break;
+ if(nhits > max)
+ {
+ max = nhits;
+ label = fTrackID[eta_index][bin].fLabel[i];
+ }
+ }
+ //nhits = max;
+ return label;
+#endif
+ cout<<"AliL3HoughTransformer::GetTrackID : Compile with do_mc flag!"<<endl;
+ return -1;
}
-*/
+