From a8ffd46b12a62f47c436df472078d73846974fc5 Mon Sep 17 00:00:00 2001 From: cvetan Date: Wed, 29 Sep 2004 12:01:18 +0000 Subject: [PATCH] Time performance improvements in HLT hough transform and huffman decompression of TPC raw data. New version of monitorGDC executable which containes now HLT HT method running in 2 threads. The fast version of raw data decoding and HT can be switched on through fast_raw flag in hlt.conf file. --- HLT/hough/AliL3Histogram.h | 4 +- HLT/hough/AliL3Hough.cxx | 212 +++- HLT/hough/AliL3Hough.h | 19 +- HLT/hough/AliL3HoughBaseTransformer.cxx | 4 + HLT/hough/AliL3HoughBaseTransformer.h | 13 + HLT/hough/AliL3HoughMaxFinder.cxx | 19 +- HLT/hough/AliL3HoughMaxFinder.h | 5 + HLT/hough/AliL3HoughTransformerRow.cxx | 1348 +++++++++++++++-------- HLT/hough/AliL3HoughTransformerRow.h | 77 +- HLT/misc/AliL3DDLDataFileHandler.cxx | 141 ++- HLT/misc/AliL3DDLDataFileHandler.h | 2 + HLT/src/AliL3FileHandler.cxx | 16 +- HLT/src/AliL3MemHandler.cxx | 8 +- HLT/src/AliL3MemHandler.h | 21 +- HLT/src/AliL3Transform.cxx | 37 + HLT/src/AliL3Transform.h | 2 + MONITOR/monitorGDC.cxx | 174 ++- RAW/AliTPCCompression.cxx | 92 +- RAW/AliTPCCompression.h | 7 +- RAW/AliTPCHNode.h | 6 +- RAW/AliTPCRawStream.cxx | 9 + RAW/AliTPCRawStream.h | 23 +- 22 files changed, 1556 insertions(+), 683 deletions(-) diff --git a/HLT/hough/AliL3Histogram.h b/HLT/hough/AliL3Histogram.h index b6b5f5220ae..4381b8a1809 100644 --- a/HLT/hough/AliL3Histogram.h +++ b/HLT/hough/AliL3Histogram.h @@ -65,9 +65,11 @@ class AliL3Histogram { Int_t GetNbinsX() const {return fNxbins;} Int_t GetNbinsY() const {return fNybins;} Int_t GetNEntries() const {return fEntries;} + + Int_t *fContent; //! + Int_t *GetContentArray() const {return fContent;} protected: - Int_t *fContent; //! Char_t fName[100]; // Name of the histogram Int_t fNxbins; // Number of bins in the histogram Int_t fNybins; // Number of bins in the histogram diff --git a/HLT/hough/AliL3Hough.cxx b/HLT/hough/AliL3Hough.cxx index ce26bb24c19..659c2dedc13 100644 --- a/HLT/hough/AliL3Hough.cxx +++ b/HLT/hough/AliL3Hough.cxx @@ -32,6 +32,8 @@ #include "AliL3HoughTrack.h" #include "AliL3DDLDataFileHandler.h" +#include "TThread.h" + #if __GNUC__ == 3 using namespace std; #endif @@ -80,6 +82,7 @@ AliL3Hough::AliL3Hough() fNEtaSegments = 0; fNPatches = 0; + fLastPatch =-1; fVersion = 0; fCurrentSlice = 0; fEvent = 0; @@ -100,6 +103,7 @@ AliL3Hough::AliL3Hough() fRunLoader = 0; #endif #endif + fThread = 0; } AliL3Hough::AliL3Hough(Char_t *path,Bool_t binary,Int_t netasegments,Bool_t bit8,Int_t tv,Char_t *infile,Char_t *ptr) @@ -136,6 +140,7 @@ AliL3Hough::AliL3Hough(Char_t *path,Bool_t binary,Int_t netasegments,Bool_t bit8 fRunLoader = 0; #endif #endif + fThread = 0; } AliL3Hough::~AliL3Hough() @@ -161,6 +166,11 @@ AliL3Hough::~AliL3Hough() if(fGlobalTracks) delete fGlobalTracks; //cout << "Cleaned class globaltracks " << endl; + if(fThread) { + // fThread->Delete(); + delete fThread; + fThread = 0; + } } void AliL3Hough::CleanUp() @@ -224,7 +234,6 @@ void AliL3Hough::Init(Bool_t doit, Bool_t addhists) fAddHistograms = addhists; fNPatches = AliL3Transform::GetNPatches(); - fHoughTransformer = new AliL3HoughBaseTransformer*[fNPatches]; fMemHandler = new AliL3MemHandler*[fNPatches]; @@ -233,6 +242,8 @@ void AliL3Hough::Init(Bool_t doit, Bool_t addhists) fGlobalTracks = new AliL3TrackArray("AliL3HoughTrack"); + AliL3HoughBaseTransformer *lasttransformer = 0; + for(Int_t i=0; iSetLastTransformer(lasttransformer); + lasttransformer = fHoughTransformer[i]; // fHoughTransformer[i]->CreateHistograms(fNBinX[i],fLowPt[i],fNBinY[i],-fPhi[i],fPhi[i]); fHoughTransformer[i]->CreateHistograms(fNBinX[i],-fLowPt[i],fLowPt[i],fNBinY[i],-fPhi[i],fPhi[i]); //fHoughTransformer[i]->CreateHistograms(fLowPt[i],fUpperPt[i],fPtRes[i],fNBinY[i],fPhi[i]); @@ -508,6 +521,9 @@ void AliL3Hough::ReadData(Int_t slice,Int_t eventnr) #endif } + //Set the pointer to the TPCRawStream in case of fast raw data reading + fHoughTransformer[i]->SetTPCRawStream(fMemHandler[i]->GetTPCRawStream()); + //set input data and init transformer fHoughTransformer[i]->SetInputData(ndigits,digits); fHoughTransformer[i]->Init(slice,i,fNEtaSegments); @@ -523,17 +539,33 @@ void AliL3Hough::Transform(Int_t *rowrange) Double_t initTime,cpuTime; initTime = GetCpuTime(); + Int_t patchorder[6] = {5,2,0,1,3,4}; //The order in which patches are processed + // Int_t patchorder[6] = {0,1,2,3,4,5}; //The order in which patches are processed + // Int_t patchorder[6] = {5,4,3,2,1,0}; //The order in which patches are processed + // Int_t patchorder[6] = {5,2,4,3,1,0}; //The order in which patches are processed + fLastPatch=-1; for(Int_t i=0; iReset();//Reset the histograms + if((fVersion != 4) || (i == 0)) { + fBenchmark->Start("Hough Reset"); + fHoughTransformer[0]->Reset();//Reset the histograms + fBenchmark->Stop("Hough Reset"); + } fBenchmark->Start("Hough Transform"); - if(!rowrange) - fHoughTransformer[i]->TransformCircle(); + PrepareForNextPatch(patchorder[i]); + if(!rowrange) { + char buf[256]; + sprintf(buf,"Patch %d",patchorder[i]); + fBenchmark->Start(buf); + fHoughTransformer[patchorder[i]]->SetLastPatch(fLastPatch); + fHoughTransformer[patchorder[i]]->TransformCircle(); + fBenchmark->Stop(buf); + } else fHoughTransformer[i]->TransformCircleC(rowrange,1); fBenchmark->Stop("Hough Transform"); + fLastPatch=patchorder[i]; } cpuTime = GetCpuTime() - initTime; LOG(AliL3Log::kInformational,"AliL3Hough::Transform()","Timing") @@ -690,13 +722,12 @@ void AliL3Hough::AddAllHistogramsRows() initTime = GetCpuTime(); fBenchmark->Start("Add HistogramsRows"); - UChar_t *tracknrows = ((AliL3HoughTransformerRow *)fHoughTransformer[0])->GetTrackNRows(); - UChar_t *trackfirstrow = ((AliL3HoughTransformerRow *)fHoughTransformer[0])->GetTrackFirstRow(); + UChar_t lastpatchlastrow = AliL3Transform::GetLastRowOnDDL(fLastPatch)+1; + UChar_t *tracklastrow = ((AliL3HoughTransformerRow *)fHoughTransformer[0])->GetTrackLastRow(); for(Int_t i=0; iGetRowCount(i); UChar_t *gapcount = ((AliL3HoughTransformerRow *)fHoughTransformer[0])->GetGapCount(i); UChar_t *currentrowcount = ((AliL3HoughTransformerRow *)fHoughTransformer[0])->GetCurrentRowCount(i); @@ -705,18 +736,25 @@ void AliL3Hough::AddAllHistogramsRows() Int_t xmax = hist->GetLastXbin(); Int_t ymin = hist->GetFirstYbin(); Int_t ymax = hist->GetLastYbin(); + Int_t nxbins = hist->GetNbinsX()+2; for(Int_t ybin=ymin; ybin<=ymax; ybin++) { for(Int_t xbin=xmin; xbin<=xmax; xbin++) { - Int_t bin = hist->GetBin(xbin,ybin); - if(tracklastrow[bin] > (currentrowcount[bin] + 1)) - gapcount[bin]++; - if(gapcount[bin] < MAX_N_GAPS) - if(rowcount[bin] >= MIN_TRACK_LENGTH) - if(((Int_t)rowcount[bin] + (Int_t)gapcount[bin])>=((Int_t)tracknrows[bin]-MAX_MISS_ROWS)) - hist->AddBinContent(bin,(rowcount[bin]+trackfirstrow[bin]+159-tracklastrow[bin])); + Int_t bin = xbin + ybin*nxbins; //Int_t bin = hist->GetBin(xbin,ybin); + if(gapcount[bin] < MAX_N_GAPS) { + if(tracklastrow[bin] > lastpatchlastrow) { + if(lastpatchlastrow > currentrowcount[bin]) + gapcount[bin] += (lastpatchlastrow-currentrowcount[bin]-1); + } + else { + if(tracklastrow[bin] > currentrowcount[bin]) + gapcount[bin] += (tracklastrow[bin]-currentrowcount[bin]-1); + } + if(gapcount[bin] < MAX_N_GAPS) + hist->AddBinContent(bin,(159-gapcount[bin])); + } } } } @@ -728,6 +766,112 @@ void AliL3Hough::AddAllHistogramsRows() <<"Adding histograms in "<Start(buf); + + UChar_t lastpatchlastrow; + if(fLastPatch == -1) + lastpatchlastrow = 0; + else + lastpatchlastrow = AliL3Transform::GetLastRowOnDDL(fLastPatch)+1; + UChar_t nextpatchfirstrow; + if(nextpatch==0) + nextpatchfirstrow = 0; + else + nextpatchfirstrow = AliL3Transform::GetFirstRowOnDDL(nextpatch)-1; + + UChar_t *trackfirstrow = ((AliL3HoughTransformerRow *)fHoughTransformer[0])->GetTrackFirstRow(); + UChar_t *tracklastrow = ((AliL3HoughTransformerRow *)fHoughTransformer[0])->GetTrackLastRow(); + + for(Int_t i=0; iGetGapCount(i); + UChar_t *currentrowcount = ((AliL3HoughTransformerRow *)fHoughTransformer[0])->GetCurrentRowCount(i); + UChar_t *prevbin = ((AliL3HoughTransformerRow *)fHoughTransformer[0])->GetPrevBin(i); + UChar_t *nextbin = ((AliL3HoughTransformerRow *)fHoughTransformer[0])->GetNextBin(i); + UChar_t *nextrow = ((AliL3HoughTransformerRow *)fHoughTransformer[0])->GetNextRow(i); + + AliL3Histogram *hist = fHoughTransformer[0]->GetHistogram(i); + Int_t xmin = hist->GetFirstXbin(); + Int_t xmax = hist->GetLastXbin(); + Int_t ymin = hist->GetFirstYbin(); + Int_t ymax = hist->GetLastYbin(); + Int_t nxbins = hist->GetNbinsX()+2; + + UChar_t lastyvalue = 0; + Int_t endybin = ymin - 1; + for(Int_t ybin=ymin; ybin<=ymax; ybin++) + { + UChar_t lastxvalue = 0; + UChar_t maxvalue = 0; + Int_t endxbin = xmin - 1; + for(Int_t xbin=xmin; xbin<=xmax; xbin++) + { + Int_t bin = xbin + ybin*nxbins; + UChar_t value = 0; + if(gapcount[bin] < MAX_N_GAPS) { + value = 1; + maxvalue = 1; + if(tracklastrow[bin] > lastpatchlastrow) { + if(lastpatchlastrow > currentrowcount[bin]) + gapcount[bin] += (lastpatchlastrow-currentrowcount[bin]-1); + } + else { + if(tracklastrow[bin] > currentrowcount[bin]) + gapcount[bin] += (tracklastrow[bin]-currentrowcount[bin]-1); + } + if(trackfirstrow[bin] < nextpatchfirstrow) + currentrowcount[bin] = nextpatchfirstrow; + else + currentrowcount[bin] = trackfirstrow[bin]; + } + if(fLastPatch != -1) { + if(value > 0) + { + nextbin[xbin + ybin*nxbins] = (UChar_t)xbin; + prevbin[xbin + ybin*nxbins] = (UChar_t)xbin; + if(value > lastxvalue) + { + UChar_t *tempnextbin = nextbin + endxbin + 1 + ybin*nxbins; + memset(tempnextbin,(UChar_t)xbin,xbin-endxbin-1); + } + endxbin = xbin; + } + else + { + prevbin[xbin + ybin*nxbins] = (UChar_t)endxbin; + } + lastxvalue = value; + } + } + if(fLastPatch != -1) { + UChar_t *tempnextbin = nextbin + endxbin + 1 + ybin*nxbins; + memset(tempnextbin,(UChar_t)(xmax+1),xmax-endxbin); + if(maxvalue > 0) + { + nextrow[ybin] = (UChar_t)ybin; + if(maxvalue > lastyvalue) + { + UChar_t *tempnextrow = nextrow + endybin + 1; + memset(tempnextrow,(UChar_t)ybin,ybin-endybin-1); + } + endybin = ybin; + } + lastyvalue = maxvalue; + } + } + if(fLastPatch != -1) { + UChar_t *tempnextrow = nextrow + endybin + 1; + memset(tempnextrow,(UChar_t)(ymax+1),ymax-endybin); + } + } + + fBenchmark->Stop(buf); +} + void AliL3Hough::AddTracks() { // Add current slice slice tracks to the global list of found tracks @@ -780,6 +924,7 @@ void AliL3Hough::FindTrackCandidatesRow() if(hist->GetNEntries()==0) continue; fPeakFinder->SetHistogram(hist); fPeakFinder->SetEtaSlice(j); + fPeakFinder->SetTrackLUTs(((AliL3HoughTransformerRow *)tr)->fTrackNRows,((AliL3HoughTransformerRow *)tr)->fTrackFirstRow,((AliL3HoughTransformerRow *)tr)->fTrackLastRow); #ifdef do_mc LOG(AliL3Log::kInformational,"AliL3Hough::FindTrackCandidates()","") <<"Starting "<GetEntries(); k++) { - // if(fPeakFinder->GetWeight(k) < 0) continue; + if(fPeakFinder->GetWeight(k) < 0) continue; AliL3HoughTrack *track = (AliL3HoughTrack*)fTracks[i]->NextTrack(); Float_t psi = atan((fPeakFinder->GetXPeak(k)-fPeakFinder->GetYPeak(k))/(AliL3HoughTransformerRow::GetBeta1()-AliL3HoughTransformerRow::GetBeta2())); Float_t kappa = 2.0*(fPeakFinder->GetXPeak(k)*cos(psi)-AliL3HoughTransformerRow::GetBeta1()*sin(psi)); @@ -814,7 +959,7 @@ void AliL3Hough::FindTrackCandidatesRow() #endif } LOG(AliL3Log::kInformational,"AliL3Hough::FindTrackCandidates()","") - <<"Found "<GetNTracks()<<" tracks in patch "<GetNTracks()<<" tracks in slice "<QSort(); } fBenchmark->Stop("Find Maxima"); @@ -1090,3 +1235,36 @@ Double_t AliL3Hough::GetCpuTime() return tv.tv_sec+(((Double_t)tv.tv_usec)/1000000.); } +void *AliL3Hough::ProcessInThread(void *args) +{ + AliL3Hough *instance = (AliL3Hough *)args; + Int_t minslice = instance->GetMinSlice(); + Int_t maxslice = instance->GetMaxSlice(); + for(Int_t i=minslice; i<=maxslice; i++) + { + instance->ReadData(i,0); + instance->Transform(); + instance->AddAllHistogramsRows(); + instance->FindTrackCandidatesRow(); + instance->AddTracks(); + } + return (void *)0; +} + +void AliL3Hough::StartProcessInThread(Int_t minslice,Int_t maxslice) +{ + if(!fThread) { + char buf[255]; + sprintf(buf,"houghtrans_%d_%d",minslice,maxslice); + SetMinMaxSlices(minslice,maxslice); + // fThread = new TThread(buf,(void (*) (void *))&ProcessInThread,(void *)this); + fThread = new TThread(buf,&ProcessInThread,(void *)this); + fThread->Run(); + } + return; +} + +Int_t AliL3Hough::WaitForThreadFinish() +{ + return TThread::Join(fThread->GetId()); +} diff --git a/HLT/hough/AliL3Hough.h b/HLT/hough/AliL3Hough.h index 02741b82d84..35d7c068326 100644 --- a/HLT/hough/AliL3Hough.h +++ b/HLT/hough/AliL3Hough.h @@ -17,6 +17,8 @@ class AliL3HoughIntMerger; class AliL3HoughGlobalMerger; class AliL3Benchmark; +#include "TThread.h" +//class TThread; #ifdef use_newio #include #endif @@ -48,6 +50,7 @@ class AliL3Hough { void FindTrackCandidatesRow(); void AddAllHistograms(); void AddAllHistogramsRows(); + void PrepareForNextPatch(Int_t nextpatch); Int_t Evaluate(Int_t roadwidth=1,Int_t nrowstomiss=1); void EvaluatePatch(Int_t i,Int_t roadwidth,Int_t nrowstomiss); void WriteTracks(Int_t slice,Char_t *path="./"); @@ -81,6 +84,14 @@ class AliL3Hough { AliL3HoughIntMerger *GetInterMerger() {if(!fInterMerger) return 0; return fInterMerger;} AliL3MemHandler *GetMemHandler(Int_t i) {if(!fMemHandler[i]) return 0; return fMemHandler[i];} AliL3HoughMaxFinder *GetMaxFinder() {return fPeakFinder;} + + //Special methods for executing Hough Transform as a thread + static void *ProcessInThread(void *args); + void StartProcessInThread(Int_t minslice,Int_t maxslice); + Int_t WaitForThreadFinish(); + void SetMinMaxSlices(Int_t minslice,Int_t maxslice) {fMinSlice = minslice; fMaxSlice = maxslice;} + Int_t GetMinSlice() {return fMinSlice;} + Int_t GetMaxSlice() {return fMaxSlice;} private: Char_t *fInputFile;//! @@ -93,8 +104,9 @@ class AliL3Hough { Bool_t fUse8bits; // Use 8 bits or not Int_t fNEtaSegments; // Number of eta slices Int_t fNPatches; // Number of patches + Int_t fLastPatch; //The index of the last processed patch Int_t fVersion; //which HoughTransformer to use - Int_t fCurrentSlice; // Current eta slice + Int_t fCurrentSlice; // Current TPC slice (sector) Int_t fEvent; // Current event number Int_t fPeakThreshold[6]; // Threshold for the peak finder @@ -113,6 +125,9 @@ class AliL3Hough { Float_t fZVertex; // Z position of the primary vertex + Int_t fMinSlice; + Int_t fMaxSlice; + AliL3MemHandler **fMemHandler; //! AliL3HoughBaseTransformer **fHoughTransformer; //! AliL3HoughEval **fEval; //! @@ -131,6 +146,8 @@ class AliL3Hough { void CleanUp(); Double_t GetCpuTime(); + TThread *fThread; + ClassDef(AliL3Hough,1) //Hough transform base class }; diff --git a/HLT/hough/AliL3HoughBaseTransformer.cxx b/HLT/hough/AliL3HoughBaseTransformer.cxx index d4b80602584..c2965602498 100644 --- a/HLT/hough/AliL3HoughBaseTransformer.cxx +++ b/HLT/hough/AliL3HoughBaseTransformer.cxx @@ -33,6 +33,8 @@ AliL3HoughBaseTransformer::AliL3HoughBaseTransformer() fSlice = 0; fPatch = 0; + fLastPatch = -1; + fLastTransformer = 0; fNEtaSegments =0; fEtaMin = 0; fEtaMax = 0; @@ -48,6 +50,7 @@ AliL3HoughBaseTransformer::AliL3HoughBaseTransformer(Int_t slice,Int_t patch,Int fSlice = 0; fPatch = 0; + fLastPatch = -1; fNEtaSegments =0; fEtaMin = 0; fEtaMax = 0; @@ -68,6 +71,7 @@ void AliL3HoughBaseTransformer::Init(Int_t slice,Int_t patch,Int_t netasegments, //Transformer init fSlice = slice; fPatch = patch; + fLastPatch = -1; fNEtaSegments = netasegments; fEtaMin = 0; fEtaMax = fSlice < 18 ? 1. : -1.; diff --git a/HLT/hough/AliL3HoughBaseTransformer.h b/HLT/hough/AliL3HoughBaseTransformer.h index 2413c074fed..c36d1d5e046 100644 --- a/HLT/hough/AliL3HoughBaseTransformer.h +++ b/HLT/hough/AliL3HoughBaseTransformer.h @@ -18,6 +18,8 @@ typedef struct AliL3TrackIndex AliL3TrackIndex; class AliL3DigitRowData; class AliL3Histogram; +#include "../RAW/AliTPCRawStream.h" + class AliL3HoughBaseTransformer { public: @@ -50,6 +52,8 @@ class AliL3HoughBaseTransformer { //Getters Int_t GetSlice() const {return fSlice;} Int_t GetPatch() const {return fPatch;} + Int_t GetLastPatch() const {return fLastPatch;} + AliL3HoughBaseTransformer *GetLastTransfromer() const {return fLastTransformer;} Int_t GetNEtaSegments() const {return fNEtaSegments;} Int_t GetLowerThreshold() const {return fLowerThreshold;} Int_t GetUpperThreshold() const {return fUpperThreshold;} @@ -74,13 +78,22 @@ class AliL3HoughBaseTransformer { virtual void Init(Int_t slice=0,Int_t patch=0,Int_t netasegments=100,Int_t nsegs=-1); void SetLowerThreshold(Int_t i) {fLowerThreshold = i;} void SetUpperThreshold(Int_t i) {fUpperThreshold = i;} + void SetLastPatch(Int_t i) {fLastPatch = i;} + void SetLastTransformer(AliL3HoughBaseTransformer *transformer) {fLastTransformer = transformer;} + + virtual void SetTPCRawStream(AliTPCRawStream */*rawstream*/){}; virtual void Print(){}; + + protected: + + AliL3HoughBaseTransformer *fLastTransformer;//Pointer to the previous hough transformer private: Int_t fSlice;//Index of the current slice being processed Int_t fPatch;//Index of the current patch being processed + Int_t fLastPatch;//Index of the last processed patch Int_t fNEtaSegments;//Number of eta slices Double_t fEtaMin;//Minimum allowed eta Double_t fEtaMax;//Maximum allowed eta diff --git a/HLT/hough/AliL3HoughMaxFinder.cxx b/HLT/hough/AliL3HoughMaxFinder.cxx index 64b4d1aaa18..56277f45f58 100644 --- a/HLT/hough/AliL3HoughMaxFinder.cxx +++ b/HLT/hough/AliL3HoughMaxFinder.cxx @@ -707,7 +707,9 @@ void AliL3HoughMaxFinder::FindAdaptedRowPeaks(Int_t kappawindow,Int_t xsize,Int_ Int_t xmax = hist->GetLastXbin(); Int_t ymin = hist->GetFirstYbin(); Int_t ymax = hist->GetLastYbin(); - + Int_t nxbins = hist->GetNbinsX()+2; + Int_t *content = hist->GetContentArray(); + //Start by looking for pre-peaks: AliL3PreYPeak **localmaxima = new AliL3PreYPeak*[hist->GetNbinsY()]; @@ -716,13 +718,13 @@ void AliL3HoughMaxFinder::FindAdaptedRowPeaks(Int_t kappawindow,Int_t xsize,Int_ Int_t lastvalue=0,value=0; for(Int_t ybin=ymin; ybin<=ymax; ybin++) { - localmaxima[ybin-ymin] = new AliL3PreYPeak[hist->GetNbinsX()]; + localmaxima[ybin-ymin] = new AliL3PreYPeak[nxbins-2]; nmaxs[ybin-ymin] = 0; lastvalue = 0; Bool_t found = 0; for(Int_t xbin=xmin; xbin<=xmax; xbin++) { - value = hist->GetBinContent(hist->GetBin(xbin,ybin)); + value = content[xbin + nxbins*ybin]; //value = hist->GetBinContent(xbin + nxbins*ybin); //value = hist->GetBinContent(hist->GetBin(xbin,ybin)); if(value > 0) { if((value - lastvalue) > 1) @@ -862,7 +864,6 @@ void AliL3HoughMaxFinder::FindAdaptedRowPeaks(Int_t kappawindow,Int_t xsize,Int_ } //remove fake tracks - Int_t nxbins = hist->GetNbinsX()+2; for(Int_t i = 0; i < (nmaxima - 1); i++) { @@ -891,10 +892,10 @@ void AliL3HoughMaxFinder::FindAdaptedRowPeaks(Int_t kappawindow,Int_t xsize,Int_ } } } - Int_t firstrow1 = AliL3HoughTransformerRow::GetTrackFirstRow()[xtrack1 + nxbins*ytrack1]; - Int_t lastrow1 = AliL3HoughTransformerRow::GetTrackLastRow()[xtrack1 + nxbins*ytrack1]; - Int_t firstrow2 = AliL3HoughTransformerRow::GetTrackFirstRow()[xtrack1 + nxbins*ytrack1]; - Int_t lastrow2 = AliL3HoughTransformerRow::GetTrackLastRow()[xtrack1 + nxbins*ytrack1]; + Int_t firstrow1 = fTrackFirstRow[xtrack1 + nxbins*ytrack1]; + Int_t lastrow1 = fTrackLastRow[xtrack1 + nxbins*ytrack1]; + Int_t firstrow2 = fTrackFirstRow[xtrack1 + nxbins*ytrack1]; + Int_t lastrow2 = fTrackLastRow[xtrack1 + nxbins*ytrack1]; Int_t firstrow,lastrow; if(firstrow1 < firstrow2) firstrow = firstrow2; @@ -1005,7 +1006,7 @@ void AliL3HoughMaxFinder::FindAdaptedRowPeaks(Int_t kappawindow,Int_t xsize,Int_ fN2PeaksPrevEtaSlice = fNPeaks; for(Int_t i=0; iGetNbinsY(); i++) - delete [] localmaxima[i]; + delete localmaxima[i]; delete [] localmaxima; delete [] nmaxs; diff --git a/HLT/hough/AliL3HoughMaxFinder.h b/HLT/hough/AliL3HoughMaxFinder.h index 64ec6cf40dc..9b5a5623c65 100644 --- a/HLT/hough/AliL3HoughMaxFinder.h +++ b/HLT/hough/AliL3HoughMaxFinder.h @@ -47,6 +47,7 @@ class AliL3HoughMaxFinder { void SetGradient(Float_t x,Float_t y) {fGradX=x; fGradY=y;} void SetThreshold(Int_t f) {fThreshold = f;} void SetHistogram(AliL3Histogram *hist) {fCurrentHisto = hist;} + void SetTrackLUTs(UChar_t *tracknrows, UChar_t *trackfirstrow, UChar_t *tracklastrow) {fTrackNRows = tracknrows; fTrackFirstRow = trackfirstrow; fTrackLastRow = tracklastrow;} void SetEtaSlice(Int_t etaslice) {fCurrentEtaSlice = etaslice;} //Getters: @@ -64,6 +65,10 @@ class AliL3HoughMaxFinder { Int_t fThreshold; // Threshold for Peak Finder Int_t fCurrentEtaSlice; // Current eta slice being processed AliL3Histogram *fCurrentHisto; //! + + UChar_t *fTrackNRows; //! + UChar_t *fTrackFirstRow; //! + UChar_t *fTrackLastRow; //! Float_t fGradX; // Gradient threshold inside Peak Finder Float_t fGradY; // Gradient threshold inside Peak Finder diff --git a/HLT/hough/AliL3HoughTransformerRow.cxx b/HLT/hough/AliL3HoughTransformerRow.cxx index 43faf716f38..b43f3cd4735 100644 --- a/HLT/hough/AliL3HoughTransformerRow.cxx +++ b/HLT/hough/AliL3HoughTransformerRow.cxx @@ -26,124 +26,211 @@ using namespace std; ClassImp(AliL3HoughTransformerRow) -UChar_t **AliL3HoughTransformerRow::fgRowCount = 0; -UChar_t **AliL3HoughTransformerRow::fgGapCount = 0; -UChar_t **AliL3HoughTransformerRow::fgCurrentRowCount = 0; -#ifdef do_mc -AliL3TrackIndex **AliL3HoughTransformerRow::fgTrackID = 0; -#endif -UChar_t *AliL3HoughTransformerRow::fgTrackNRows = 0; -UChar_t *AliL3HoughTransformerRow::fgTrackFirstRow = 0; -UChar_t *AliL3HoughTransformerRow::fgTrackLastRow = 0; - -Float_t AliL3HoughTransformerRow::fgBeta1 = AliL3Transform::Row2X(79)/pow(AliL3Transform::Row2X(79),2); -Float_t AliL3HoughTransformerRow::fgBeta2 = (AliL3Transform::Row2X(158)+6.0)/pow((AliL3Transform::Row2X(158)+6.0),2); +Float_t AliL3HoughTransformerRow::fgBeta1 = 1.0/AliL3Transform::Row2X(79); +Float_t AliL3HoughTransformerRow::fgBeta2 = 1.0/(AliL3Transform::Row2X(158)*(1.0+tan(AliL3Transform::Pi()*10/180)*tan(AliL3Transform::Pi()*10/180))); AliL3HoughTransformerRow::AliL3HoughTransformerRow() { //Default constructor fParamSpace = 0; - fDoMC = kFALSE;; - fLUTforwardZ=0; - fLUTforwardZ2=0; - fLUTbackwardZ=0; - fLUTbackwardZ2=0; + fGapCount = 0; + fCurrentRowCount = 0; +#ifdef do_mc + fTrackID = 0; +#endif + fTrackNRows = 0; + fTrackFirstRow = 0; + fTrackLastRow = 0; + fInitialGapCount = 0; + + fPrevBin = 0; + fNextBin = 0; + fNextRow = 0; + + fStartPadParams = 0; + fEndPadParams = 0; + fLUTr2 = 0; + fLUTforwardZ = 0; + fLUTforwardZ2 = 0; + fLUTbackwardZ = 0; + fLUTbackwardZ2 = 0; + } AliL3HoughTransformerRow::AliL3HoughTransformerRow(Int_t slice,Int_t patch,Int_t netasegments,Bool_t /*DoMC*/,Float_t zvertex) : AliL3HoughBaseTransformer(slice,patch,netasegments,zvertex) { //Normal constructor fParamSpace = 0; - fDoMC = kFALSE; - fDoMC=kFALSE; + + fGapCount = 0; + fCurrentRowCount = 0; #ifdef do_mc - fDoMC = kTRUE; + fTrackID = 0; #endif - fLUTforwardZ=0; - fLUTforwardZ2=0; - fLUTbackwardZ=0; - fLUTbackwardZ2=0; + fTrackNRows = 0; + fTrackFirstRow = 0; + fTrackLastRow = 0; + fInitialGapCount = 0; + + fPrevBin = 0; + fNextBin = 0; + fNextRow = 0; + + fStartPadParams = 0; + fEndPadParams = 0; + fLUTr2 = 0; + fLUTforwardZ = 0; + fLUTforwardZ2 = 0; + fLUTbackwardZ = 0; + fLUTbackwardZ2 = 0; + } AliL3HoughTransformerRow::~AliL3HoughTransformerRow() { //Destructor DeleteHistograms(); + if(fLastTransformer) return; #ifdef do_mc - if(fgTrackID) + if(fTrackID) { for(Int_t i=0; ifGapCount; + fCurrentRowCount = ((AliL3HoughTransformerRow *)fLastTransformer)->fCurrentRowCount; #ifdef do_mc - if(fDoMC) - { - AliL3Histogram *hist = fParamSpace[0]; - Int_t ncellsx = (hist->GetNbinsX()+3)/2; - Int_t ncellsy = (hist->GetNbinsY()+3)/2; - Int_t ncells = ncellsx*ncellsy; - if(!fgTrackID) - { - LOG(AliL3Log::kInformational,"AliL3HoughTransformerRow::CreateHistograms()","") - <<"Transformer: Allocating "<fTrackID; +#endif + fTrackNRows = ((AliL3HoughTransformerRow *)fLastTransformer)->fTrackNRows; + fTrackFirstRow = ((AliL3HoughTransformerRow *)fLastTransformer)->fTrackFirstRow; + fTrackLastRow = ((AliL3HoughTransformerRow *)fLastTransformer)->fTrackLastRow; + fInitialGapCount = ((AliL3HoughTransformerRow *)fLastTransformer)->fInitialGapCount; + + fPrevBin = ((AliL3HoughTransformerRow *)fLastTransformer)->fPrevBin; + fNextBin = ((AliL3HoughTransformerRow *)fLastTransformer)->fNextBin; + fNextRow = ((AliL3HoughTransformerRow *)fLastTransformer)->fNextRow; + + fStartPadParams = ((AliL3HoughTransformerRow *)fLastTransformer)->fStartPadParams; + fEndPadParams = ((AliL3HoughTransformerRow *)fLastTransformer)->fEndPadParams; + fLUTr2 = ((AliL3HoughTransformerRow *)fLastTransformer)->fLUTr2; + fLUTforwardZ = ((AliL3HoughTransformerRow *)fLastTransformer)->fLUTforwardZ; + fLUTforwardZ2 = ((AliL3HoughTransformerRow *)fLastTransformer)->fLUTforwardZ2; + fLUTbackwardZ = ((AliL3HoughTransformerRow *)fLastTransformer)->fLUTbackwardZ; + fLUTbackwardZ2 = ((AliL3HoughTransformerRow *)fLastTransformer)->fLUTbackwardZ2; + + return; + } +#ifdef do_mc + { + AliL3Histogram *hist = fParamSpace[0]; + Int_t ncellsx = (hist->GetNbinsX()+3)/2; + Int_t ncellsy = (hist->GetNbinsY()+3)/2; + Int_t ncells = ncellsx*ncellsy; + if(!fTrackID) + { + LOG(AliL3Log::kInformational,"AliL3HoughTransformerRow::CreateHistograms()","") + <<"Transformer: Allocating "<GetNbinsX()+2)*(hist->GetNbinsY()+2); - if(!fgRowCount) + if(!fGapCount) { LOG(AliL3Log::kInformational,"AliL3HoughTransformerRow::CreateHistograms()","") - <<"Transformer: Allocating "<GetNbinsY()+2; + if(!fNextRow) + { + LOG(AliL3Log::kInformational,"AliL3HoughTransformerRow::CreateHistograms()","") + <<"Transformer: Allocating "<GetFirstXbin(); Int_t xmax = hist->GetLastXbin(); + Int_t xmiddle = (hist->GetNbinsX()+1)/2; Int_t ymin = hist->GetFirstYbin(); Int_t ymax = hist->GetLastYbin(); Int_t nxbins = hist->GetNbinsX()+2; + Int_t nxgrid = (hist->GetNbinsX()+3)/2+1; + Int_t nygrid = hist->GetNbinsY()+3; + + AliL3TrackLength *tracklength = new AliL3TrackLength[nxgrid*nygrid]; + memset(tracklength,0,nxgrid*nygrid*sizeof(AliL3TrackLength)); + for(Int_t ybin=ymin-1; ybin<=(ymax+1); ybin++) { - for(Int_t xbin=xmin-1; xbin<=(xmax+1); xbin++) + for(Int_t xbin=xmin-1; xbin<=xmiddle; xbin++) { - //cvetan: we get strange warning on gcc-2.95 - //warning: large integer implicitly truncated to unsigned type - fgTrackNRows[xbin + ybin*nxbins] = 99999; - for(Int_t deltay = -1; deltay <= 1; deltay += 2) { - for(Int_t deltax = -1; deltax <= 1; deltax += 2) { - - Float_t xtrack = hist->GetPreciseBinCenterX((Float_t)xbin+0.5*(Float_t)deltax); - Float_t ytrack = hist->GetPreciseBinCenterY((Float_t)ybin+0.5*(Float_t)deltay); - - Float_t psi = atan((xtrack-ytrack)/(fgBeta1-fgBeta2)); - Float_t kappa = 2.0*(xtrack*cos(psi)-fgBeta1*sin(psi)); - track.SetTrackParameters(kappa,psi,1); - Bool_t firstrow = kFALSE; + fTrackNRows[xbin + ybin*nxbins] = 255; + for(Int_t deltay = 0; deltay <= 1; deltay++) { + for(Int_t deltax = 0; deltax <= 1; deltax++) { + + AliL3TrackLength *curtracklength = &tracklength[(xbin + deltax) + (ybin + deltay)*nxgrid]; UInt_t maxfirstrow = 0; UInt_t maxlastrow = 0; - UInt_t curfirstrow = 0; - UInt_t curlastrow = 0; - for(Int_t j=AliL3Transform::GetFirstRow(0); j<=AliL3Transform::GetLastRow(5); j++) - { - Float_t hit[3]; - if(!track.GetCrossingPoint(j,hit)) continue; - AliL3Transform::LocHLT2Raw(hit,0,j); - if(hit[1]>=0 && hit[1]fIsFilled) { + maxfirstrow = curtracklength->fFirstRow; + maxlastrow = curtracklength->fLastRow; + maxtrackpt = curtracklength->fTrackPt; + } + else { + Float_t xtrack = hist->GetPreciseBinCenterX((Float_t)xbin+0.5*(Float_t)(2*deltax-1)); + Float_t ytrack = hist->GetPreciseBinCenterY((Float_t)ybin+0.5*(Float_t)(2*deltay-1)); + + Float_t psi = atan((xtrack-ytrack)/(fgBeta1-fgBeta2)); + Float_t kappa = 2.0*(xtrack*cos(psi)-fgBeta1*sin(psi)); + track.SetTrackParameters(kappa,psi,1); + Bool_t firstrow = kFALSE; + UInt_t curfirstrow = 0; + UInt_t curlastrow = 0; + + Double_t centerx = track.GetCenterX(); + Double_t centery = track.GetCenterY(); + Double_t radius = track.GetRadius(); + + for(Int_t j=AliL3Transform::GetFirstRow(0); j<=AliL3Transform::GetLastRow(5); j++) + { + Float_t hit[3]; + // if(!track.GetCrossingPoint(j,hit)) continue; + hit[0] = AliL3Transform::Row2X(j); + Double_t aa = (hit[0] - centerx)*(hit[0] - centerx); + Double_t r2 = radius*radius; + if(aa > r2) + continue; + + Double_t aa2 = sqrt(r2 - aa); + Double_t y1 = centery + aa2; + Double_t y2 = centery - aa2; + hit[1] = y1; + if(fabs(y2) < fabs(y1)) hit[1] = y2; + + hit[2] = 0; + + AliL3Transform::LocHLT2Raw(hit,0,j); + hit[1] += 0.5; + if(hit[1]>=0 && hit[1]= (maxlastrow-maxfirstrow)) { - maxfirstrow = curfirstrow; - maxlastrow = curlastrow; + else { + if(firstrow) { + firstrow = kFALSE; + if((curlastrow-curfirstrow) >= (maxlastrow-maxfirstrow)) { + maxfirstrow = curfirstrow; + maxlastrow = curlastrow; + } } } } + if((curlastrow-curfirstrow) >= (maxlastrow-maxfirstrow)) { + maxfirstrow = curfirstrow; + maxlastrow = curlastrow; } - if((curlastrow-curfirstrow) >= (maxlastrow-maxfirstrow)) { - maxfirstrow = curfirstrow; - maxlastrow = curlastrow; + + maxtrackpt = track.GetPt(); + + curtracklength->fIsFilled = kTRUE; + curtracklength->fFirstRow = maxfirstrow; + curtracklength->fLastRow = maxlastrow; + curtracklength->fTrackPt = maxtrackpt; + } - if((maxlastrow-maxfirstrow) < fgTrackNRows[xbin + ybin*nxbins]) { - fgTrackNRows[xbin + ybin*nxbins] = maxlastrow-maxfirstrow; - fgTrackFirstRow[xbin + ybin*nxbins] = maxfirstrow; - fgTrackLastRow[xbin + ybin*nxbins] = maxlastrow; + if((maxlastrow-maxfirstrow) < fTrackNRows[xbin + ybin*nxbins]) { + fTrackNRows[xbin + ybin*nxbins] = maxlastrow-maxfirstrow; + fInitialGapCount[xbin + ybin*nxbins] = 1; + if((maxlastrow-maxfirstrow+1)GetYmin(); + Float_t histbin = hist->GetBinWidthY(); + Float_t xmin = hist->GetXmin(); + Float_t xmax = hist->GetXmax(); + Float_t xbin = (xmax-xmin)/hist->GetNbinsX(); + Int_t firstbinx = hist->GetFirstXbin(); + Int_t lastbinx = hist->GetLastXbin(); + Int_t nbinx = hist->GetNbinsX()+2; + Int_t firstbin = hist->GetFirstYbin(); + Int_t lastbin = hist->GetLastYbin(); + for(Int_t i=AliL3Transform::GetFirstRow(0); i<=AliL3Transform::GetLastRow(5); i++) + { + Int_t npads = AliL3Transform::GetNPads(i); + Int_t ipatch = AliL3Transform::GetPatch(i); + Double_t padpitch = AliL3Transform::GetPadPitchWidth(ipatch); + Float_t x = AliL3Transform::Row2X(i); + Float_t x2 = x*x; + + fStartPadParams[i] = new AliL3PadHoughParams[npads]; + fEndPadParams[i] = new AliL3PadHoughParams[npads]; + fLUTr2[i] = new Float_t[npads]; + for(Int_t pad=0; pad=0) + alpha2 += deltaalpha2; + + fStartPadParams[i][pad].fAlpha = alpha1; + fStartPadParams[i][pad].fDeltaAlpha = deltaalpha1; + fEndPadParams[i][pad].fAlpha = alpha2; + fEndPadParams[i][pad].fDeltaAlpha = deltaalpha2; + + //Find the first and last bin rows to be filled + Bool_t binfound1 = kFALSE; + Bool_t binfound2 = kFALSE; + Int_t firstbin1 = lastbin; + Int_t firstbin2 = lastbin; + Int_t lastbin1 = firstbin; + Int_t lastbin2 = firstbin; + for(Int_t b=firstbin; b<=lastbin; b++, alpha1 += deltaalpha1, alpha2 += deltaalpha2) + { + Int_t binx1 = 1 + (Int_t)alpha1; + if(binx1<=lastbinx) { + UChar_t initialgapcount; + if(binx1>=firstbinx) + initialgapcount = fInitialGapCount[binx1 + b*nbinx]; + else + initialgapcount = fInitialGapCount[firstbinx + b*nbinx]; + if(initialgapcount != MAX_N_GAPS) { + if(!binfound1) { + firstbin1 = b; + binfound1 = kTRUE; + } + lastbin1 = b; + } + } + Int_t binx2 = 1 + (Int_t)alpha2; + if(binx2>=firstbin) { + UChar_t initialgapcount; + if(binx2<=lastbinx) + initialgapcount = fInitialGapCount[binx2 + b*nbinx]; + else + initialgapcount = fInitialGapCount[lastbinx + b*nbinx]; + if(initialgapcount != MAX_N_GAPS) { + if(!binfound2) { + firstbin2 = b; + binfound2 = kTRUE; + } + lastbin2 = b; + } + } + } + fStartPadParams[i][pad].fFirstBin=firstbin1; + fStartPadParams[i][pad].fLastBin=lastbin1; + fEndPadParams[i][pad].fFirstBin=firstbin2; + fEndPadParams[i][pad].fLastBin=lastbin2; + } + } + } + //create lookup table for z of the digits - Int_t ntimebins = AliL3Transform::GetNTimeBins(); - fLUTforwardZ = new Float_t[ntimebins]; - fLUTforwardZ2 = new Float_t[ntimebins]; - fLUTbackwardZ = new Float_t[ntimebins]; - fLUTbackwardZ2 = new Float_t[ntimebins]; - for(Int_t i=0; iReset(); #ifdef do_mc - if(fDoMC) - { - AliL3Histogram *hist = fParamSpace[0]; - Int_t ncellsx = (hist->GetNbinsX()+3)/2; - Int_t ncellsy = (hist->GetNbinsY()+3)/2; - Int_t ncells = ncellsx*ncellsy; - for(Int_t i=0; iGetNbinsX()+3)/2; + Int_t ncellsy = (hist->GetNbinsY()+3)/2; + Int_t ncells = ncellsx*ncellsy; + for(Int_t i=0; iGetNbinsX()+2)*(hist->GetNbinsY()+2); for(Int_t i=0; iGetYmin(); - //Float_t y_max = h->GetYmax(); - Float_t histbin = h->GetBinWidthY(); - Int_t firstbin = h->GetFirstYbin(); - Int_t lastbin = h->GetLastYbin(); - Float_t xmin = h->GetXmin(); - Float_t xmax = h->GetXmax(); - Float_t xbin = (xmax-xmin)/h->GetNbinsX(); - Int_t firstbinx = h->GetFirstXbin()-1; - Int_t lastbinx = h->GetLastXbin()+1; + Int_t firstbiny = h->GetFirstYbin(); + Int_t firstbinx = h->GetFirstXbin(); + Int_t lastbinx = h->GetLastXbin(); Int_t nbinx = h->GetNbinsX()+2; UChar_t lastpad; @@ -424,31 +729,29 @@ void AliL3HoughTransformerRow::TransformCircle() } Int_t ipatch = GetPatch(); - Double_t padpitch = AliL3Transform::GetPadPitchWidth(ipatch); + Int_t ilastpatch = GetLastPatch(); Int_t islice = GetSlice(); - Float_t *fLUTz; - Float_t *fLUTz2; + Float_t *lutz; + Float_t *lutz2; if(islice < 18) { - fLUTz = fLUTforwardZ; - fLUTz2 = fLUTforwardZ2; + lutz = fLUTforwardZ; + lutz2 = fLUTforwardZ2; } else { - fLUTz = fLUTbackwardZ; - fLUTz2 = fLUTbackwardZ2; + lutz = fLUTbackwardZ; + lutz2 = fLUTbackwardZ2; } //Loop over the padrows: for(UChar_t i=AliL3Transform::GetFirstRow(ipatch); i<=AliL3Transform::GetLastRow(ipatch); i++) { - Int_t npads = AliL3Transform::GetNPads((Int_t)i)-1; - lastpad = 255; //Flush eta clusters array memset(etaclust,0,netasegments*sizeof(AliL3EtaRow)); Float_t x = AliL3Transform::Row2X((Int_t)i); Float_t x2 = x*x; - Float_t y=0,r2=0; + Float_t radius2=0; //Get the data on this padrow: AliL3DigitData *digPt = tempPt->fDigitData; @@ -470,17 +773,18 @@ void AliL3HoughTransformerRow::TransformCircle() if(pad != lastpad) { - y = (pad-0.5*npads)*padpitch; - Float_t y2 = y*y; - r2 = x2 + y2; + radius2 = fLUTr2[(Int_t)i][(Int_t)pad]; lastetaindex = -1; } //Transform data to local cartesian coordinates: - Float_t z = fLUTz[(Int_t)time]; - Float_t z2 = fLUTz2[(Int_t)time]; + Float_t z = lutz[(Int_t)time]; + Float_t z2 = lutz2[(Int_t)time]; + // Acceptance cut : to be verified + // if(radius2<0.72406166*z2) continue; + if(x2<0.8464*z2) continue; //Calculate the eta: - Double_t r = sqrt(r2+z2); + Double_t r = sqrt(radius2+z2); Double_t eta = 0.5 * log((r+z)/(r-z)); //Get the corresponding index, which determines which histogram to fill: Int_t etaindex = (Int_t)((eta-etamin)/etaslice); @@ -497,23 +801,9 @@ void AliL3HoughTransformerRow::TransformCircle() { etaclust[etaindex].fStartPad = pad; etaclust[etaindex].fEndPad = pad; - etaclust[etaindex].fStartY = y - padpitch/2.0; etaclust[etaindex].fIsFound = 1; #ifdef do_mc - if(fDoMC) - { - 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-1); c++) - if(etaclust[etaindex].fMcLabels[c] == label || etaclust[etaindex].fMcLabels[c] == 0) - break; - // if(c == MaxTrack-1) cerr<<"AliL3HoughTransformer::TransformCircle : Cluster array reached maximum!! "<=0) - alpha2 += deltaalpha2; - - //Fill the histogram along the phirange - for(Int_t b=firstbin; b<=lastbin; b++, alpha1 += deltaalpha1, alpha2 += deltaalpha2) - { - Int_t binx1 = 1 + (Int_t)alpha1; - if(binx1>lastbinx) continue; - if(binx1lastbinx) binx2 = lastbinx; -#ifdef do_mc - if(binx2 (currentrow2[bin] + MAX_GAP_SIZE) && i < lastrow2[bin]) { - ngaps2[bin] = MAX_N_GAPS; - continue; - } - if(i > currentrow2[bin] && i < lastrow2[bin]) - { - nrows2[bin]++; - if(i > (currentrow2[bin] + 1)) - ngaps2[bin]++; - currentrow2[bin]=i; - } -#ifdef do_mc - if(fDoMC) - { - for(UInt_t t=0;t<(MaxTrack-1); t++) - { - Int_t label = etaclust[etaindex].fMcLabels[t]; - if(label == 0) break; - UInt_t c; - Int_t tempbin2 = ((Int_t)(b/2))*((Int_t)((nbinx+1)/2)) + (Int_t)(bin/2); - for(c=0; c<(MaxTrack-1); c++) - if(fgTrackID[etaindex][tempbin2].fLabel[c] == label || fgTrackID[etaindex][tempbin2].fNHits[c] == 0) - break; - // if(c == MaxTrack-1) cerr<<"AliL3HoughTransformer::TransformCircle : Array reached maximum!! "<=0) - alpha2 += deltaalpha2; - - //Fill the histogram along the phirange - for(Int_t b=firstbin; b<=lastbin; b++, alpha1 += deltaalpha1, alpha2 += deltaalpha2) - { - Int_t binx1 = 1 + (Int_t)alpha1; - if(binx1>lastbinx) continue; - if(binx1lastbinx) binx2 = lastbinx; -#ifdef do_mc - if(binx2 (currentrow2[bin] + MAX_GAP_SIZE) && i < lastrow2[bin]) { - ngaps2[bin] = MAX_N_GAPS; - continue; - } - if(i > currentrow2[bin] && i < lastrow2[bin]) - { - nrows2[bin]++; - if(i > (currentrow2[bin] + 1)) - ngaps2[bin]++; - currentrow2[bin]=i; - } -#ifdef do_mc - if(fDoMC) - { - for(UInt_t t=0;t<(MaxTrack-1); t++) - { - Int_t label = etaclust[etaindex].fMcLabels[t]; - if(label == 0) break; - UInt_t c; - Int_t tempbin2 = ((Int_t)(b/2))*((Int_t)((nbinx+1)/2)) + (Int_t)(bin/2); - for(c=0; c<(MaxTrack-1); c++) - if(fgTrackID[etaindex][tempbin2].fLabel[c] == label || fgTrackID[etaindex][tempbin2].fNHits[c] == 0) - break; - // if(c == MaxTrack-1) cout<<"AliL3HoughTransformer::TransformCircle : Array reached maximum!! "<GetFirstYbin(); + Int_t firstbinx = h->GetFirstXbin(); + Int_t lastbinx = h->GetLastXbin(); + Int_t nbinx = h->GetNbinsX()+2; + + Int_t lastetaindex; + AliL3EtaRow *etaclust = new AliL3EtaRow[netasegments]; + + if(!fTPCRawStream) { - LOG(AliL3Log::kWarning,"AliL3HoughTransformerRow::GetTrackID","Data") - <<"Flag switched off"<Next()) { + + if(fTPCRawStream->IsNewSector() || fTPCRawStream->IsNewRow()) { + + //Write remaining clusters + for(Int_t etaindex = 0;etaindex < netasegments;etaindex++) + { + //Check for empty row + if((etaclust[etaindex].fStartPad == 0) && (etaclust[etaindex].fEndPad == 0)) continue; + + FillCluster(i,etaindex,etaclust,ilastpatch,firstbinx,lastbinx,nbinx,firstbiny); + } + + Int_t sector=fTPCRawStream->GetSector(); + Int_t row=fTPCRawStream->GetRow(); + Int_t slice,srow; + AliL3Transform::Sector2Slice(slice,srow,sector,row); + if(slice!=islice){ + LOG(AliL3Log::kError,"AliL3DDLDataFileHandler::DDLDigits2Memory","Slice") + <rowmax))continue; + + // cout<<" Starting row "<<(UInt_t)i<IsNewRow() || fTPCRawStream->IsNewPad()) { + pad=fTPCRawStream->GetPad(); + /* + if((pad<0)||(pad>=(npads+1))){ + LOG(AliL3Log::kError,"AliL3DDLDataFileHandler::DDLDigits2Memory","Pad") + <GetTime(); + /* + if((time<0)||(time>=ntimebins)){ + LOG(AliL3Log::kError,"AliL3DDLDataFileHandler::DDLDigits2Memory","Time") + <GetSignal() <= lowerthreshold) + continue; + + //Transform data to local cartesian coordinates: + Float_t z = lutz[(Int_t)time]; + Float_t z2 = lutz2[(Int_t)time]; + // if(radius2<0.72406166*z2) continue; + if(x2<0.8464*z2) continue; + //Calculate the eta: + Double_t r = sqrt(radius2+z2); + Double_t eta = 0.5 * log((r+z)/(r-z)); + //Get the corresponding index, which determines which histogram to fill: + Int_t etaindex = (Int_t)((eta-etamin)/etaslice); + +#ifndef do_mc + if(etaindex == lastetaindex) continue; +#endif + // cout<<" Digit at patch "<= netasegments) + continue; + + if(!etaclust[etaindex].fIsFound) + { + etaclust[etaindex].fStartPad = pad; + etaclust[etaindex].fEndPad = pad; + etaclust[etaindex].fIsFound = 1; + continue; + } + else + { + if(pad <= (etaclust[etaindex].fEndPad + 1)) + { + etaclust[etaindex].fEndPad = pad; + } + else + { + FillCluster(i,etaindex,etaclust,ilastpatch,firstbinx,lastbinx,nbinx,firstbiny); + + etaclust[etaindex].fStartPad = pad; + etaclust[etaindex].fEndPad = pad; + + } + } + lastetaindex = etaindex; + } + + //Write remaining clusters + for(Int_t etaindex = 0;etaindex < netasegments;etaindex++) + { + //Check for empty row + if((etaclust[etaindex].fStartPad == 0) && (etaclust[etaindex].fEndPad == 0)) continue; + + FillCluster(i,etaindex,etaclust,ilastpatch,firstbinx,lastbinx,nbinx,firstbiny); } -#ifdef do_mc + delete [] etaclust; +} + +Int_t AliL3HoughTransformerRow::GetTrackID(Int_t etaindex,Double_t alpha1,Double_t alpha2) const +{ + // Returns the MC label for a given peak found in the Hough space +#ifndef do_mc + LOG(AliL3Log::kWarning,"AliL3HoughTransformerRow::GetTrackID","Data") + <<"Flag switched off"< GetNEtaSegments()) { LOG(AliL3Log::kWarning,"AliL3HoughTransformerRow::GetTrackID","Data") @@ -799,31 +1050,31 @@ Int_t AliL3HoughTransformerRow::GetTrackID(Int_t etaindex,Double_t alpha1,Double Int_t max=0; for(UInt_t i=0; i<(MaxTrack-1); i++) { - Int_t nhits=fgTrackID[etaindex][bin].fNHits[i]; + Int_t nhits=fTrackID[etaindex][bin].fNHits[i]; if(nhits == 0) break; if(nhits > max) { max = nhits; - label = fgTrackID[etaindex][bin].fLabel[i]; + label = fTrackID[etaindex][bin].fLabel[i]; } } Int_t label2=-1; Int_t max2=0; for(UInt_t i=0; i<(MaxTrack-1); i++) { - Int_t nhits=fgTrackID[etaindex][bin].fNHits[i]; + Int_t nhits=fTrackID[etaindex][bin].fNHits[i]; if(nhits == 0) break; if(nhits > max2) { - if(fgTrackID[etaindex][bin].fLabel[i]!=label) { + if(fTrackID[etaindex][bin].fLabel[i]!=label) { max2 = nhits; - label2 = fgTrackID[etaindex][bin].fLabel[i]; + label2 = fTrackID[etaindex][bin].fLabel[i]; } } } if(max2 !=0 ) { LOG(AliL3Log::kDebug,"AliL3HoughTransformerRow::GetTrackID()","") - <<" TrackID"<<" label "< currentrow2[bin]) { + ngaps2[bin] += (i-currentrow2[bin]-1); + currentrow2[bin]=i; + } +#ifdef do_mc + if(i < lastrow2[bin] && i >= currentrow2[bin]) { + for(UInt_t t=0;t<(MaxTrack-1); t++) + { + Int_t label = etaclust.fMcLabels[t]; + if(label == 0) break; + UInt_t c; + Int_t tempbin2 = (Int_t)(bin/2); + for(c=0; c<(MaxTrack-1); c++) + if(trackid[tempbin2].fLabel[c] == label || trackid[tempbin2].fNHits[c] == 0) + break; + trackid[tempbin2].fLabel[c] = label; + if(trackid[tempbin2].fCurrentRow[c] != i) { + trackid[tempbin2].fNHits[c]++; + trackid[tempbin2].fCurrentRow[c] = i; + } + } + } +#endif + } + } + +} + +inline void AliL3HoughTransformerRow::FillCluster(UChar_t i,Int_t etaindex,AliL3EtaRow *etaclust,Int_t ilastpatch,Int_t firstbinx,Int_t lastbinx,Int_t nbinx,Int_t firstbiny) +{ + UChar_t *ngaps = fGapCount[etaindex]; + UChar_t *currentrow = fCurrentRowCount[etaindex]; + UChar_t *lastrow = fTrackLastRow; + UChar_t *prevbin = fPrevBin[etaindex]; + UChar_t *nextbin = fNextBin[etaindex]; + UChar_t *nextrow = fNextRow[etaindex]; +#ifdef do_mc + AliL3TrackIndex *trackid = fTrackID[etaindex]; +#endif + + //Do the transformation: + AliL3PadHoughParams *startparams = &fStartPadParams[(Int_t)i][etaclust[etaindex].fStartPad]; + AliL3PadHoughParams *endparams = &fEndPadParams[(Int_t)i][etaclust[etaindex].fEndPad]; + + Float_t alpha1 = startparams->fAlpha; + Float_t deltaalpha1 = startparams->fDeltaAlpha; + Float_t alpha2 = endparams->fAlpha; + Float_t deltaalpha2 = endparams->fDeltaAlpha; + + Int_t firstbin1 = startparams->fFirstBin; + Int_t firstbin2 = endparams->fFirstBin; + Int_t firstbin = firstbin1; + if(firstbin>firstbin2) firstbin = firstbin2; + + Int_t lastbin1 = startparams->fLastBin; + Int_t lastbin2 = endparams->fLastBin; + Int_t lastbin = lastbin1; + if(lastbinlastbinx) continue; + if(binx1lastbinx) binx2 = lastbinx; +#ifdef do_mc + if(binx2lastbinx) continue; + if(binx1lastbinx) binx2 = lastbinx; +#ifdef do_mc + if(binx2 (b + 1)) { + Int_t deltab = (nextrow[b] - b - 1); + b += deltab; + alpha1 += deltaalpha1*deltab; + alpha2 += deltaalpha2*deltab; + continue; + } + Int_t tempbin = b*nbinx; + binx1 = (UInt_t)nextbin[binx1 + tempbin]; + binx2 = (UInt_t)prevbin[binx2 + tempbin]; + if(binx2ddls[ddlsToSearch-1]) { + Int_t tempddl = ddls[0]; + ddls[0] = ddls[ddlsToSearch-1]; + ddls[ddlsToSearch-1] = tempddl; + } #ifdef use_newio fReader->Reset(); - fReader->Select(0,ddls[i],ddls[i]+1); + fReader->Select(0,ddls[0],ddls[ddlsToSearch-1]); + fTPCStream->Reset(); #else fTPCStream->SetDDLID(ddls[i]); //ddl to read out #endif + Int_t zerosup = AliL3Transform::GetZeroSup(); + Int_t adcsat = AliL3Transform::GetADCSat(); + Int_t slice,srow; + Int_t lrow; while (fTPCStream->Next()){ - - UShort_t dig=fTPCStream->GetSignal(); - if(dig <= AliL3Transform::GetZeroSup()) continue; - if(dig >= AliL3Transform::GetADCSat()) - dig = AliL3Transform::GetADCSat(); - Int_t time=fTPCStream->GetTime(); - Int_t pad=fTPCStream->GetPad(); - Int_t sector=fTPCStream->GetSector(); - Int_t row=fTPCStream->GetRow(); - Int_t slice,srow; + if(fTPCStream->IsNewSector() || fTPCStream->IsNewRow()) { + Int_t sector=fTPCStream->GetSector(); + Int_t row=fTPCStream->GetRow(); + AliL3Transform::Sector2Slice(slice,srow,sector,row); + if(slice!=fSlice){ + LOG(AliL3Log::kError,"AliL3DDLDataFileHandler::DDLDigits2Memory","Slice") + <fRowMax))continue; - if(slice!=fSlice){ - LOG(AliL3Log::kError,"AliL3DDLDataFileHandler::DDLDigits2Memory","Slice") - <=nrows){ - LOG(AliL3Log::kError,"AliL3DDLDataFileHandler::DDLDigits2Memory","Row") - <=AliL3Transform::GetNPads(srow))){ - LOG(AliL3Log::kError,"AliL3DDLDataFileHandler::DDLDigits2Memory","Pad") - <GetPad(); + if(fTPCStream->IsNewPad()) { + if((pad<0)||(pad>=AliL3Transform::GetNPads(srow))){ + LOG(AliL3Log::kError,"AliL3DDLDataFileHandler::DDLDigits2Memory","Pad") + <GetTime(); if((time<0)||(time>=AliL3Transform::GetNTimeBins())){ LOG(AliL3Log::kError,"AliL3DDLDataFileHandler::DDLDigits2Memory","Time") <GetSignal(); + if(dig <= zerosup) continue; + if(dig >= adcsat) dig = adcsat; + ndigits[lrow]++; //for this row only ndigitcount++; //total number of digits to be published charges[lrow][pad][time]=dig; } - } - + Int_t size = sizeof(AliL3DigitData)*ndigitcount + nrows*sizeof(AliL3DigitRowData); @@ -326,7 +329,65 @@ AliL3DigitRowData * AliL3DDLDataFileHandler::DDLData2Memory(UInt_t &nrow,Int_t e return data; } +#else +AliL3DigitRowData * AliL3DDLDataFileHandler::DDLData2Memory(UInt_t &nrow,Int_t event) +{ + // transfers the DDL data to the memory +#ifdef use_newio + if((fEvent>=0)&&(event!=fEvent)){ + fEvent=event; + if(fReader) delete fReader; + if(fTPCStream) delete fTPCStream; + fReader=new AliRawReaderRoot(fFilename,event); + fTPCStream=new AliTPCRawStream(fReader); + } +#endif + AliL3DigitRowData *data = 0; + nrow=0; + if(!fReader){ + LOG(AliL3Log::kWarning,"AliL3DDLDataFileHandler::DDLData2Memory","File") + <<"No Input avalible: no object AliL3DDLRawReaderFile"<Reset(); + fReader->Select(0,ddls[0],ddls[ddlsToSearch-1]); + fTPCStream->Reset(); +#else + fTPCStream->SetDDLID(ddls[i]); //ddl to read out +#endif + + nrow = (UInt_t)nrows; + + return data; +} +#endif Bool_t AliL3DDLDataFileHandler::DDLData2CompBinary(Int_t event) { diff --git a/HLT/misc/AliL3DDLDataFileHandler.h b/HLT/misc/AliL3DDLDataFileHandler.h index 490f38fa7c9..843c24146fb 100644 --- a/HLT/misc/AliL3DDLDataFileHandler.h +++ b/HLT/misc/AliL3DDLDataFileHandler.h @@ -35,6 +35,8 @@ class AliL3DDLDataFileHandler:public AliL3MemHandler{ AliL3DigitRowData* DDLData2Memory(UInt_t &nrow,Int_t event=-1); Bool_t DDLData2CompBinary(Int_t event=-1); + AliTPCRawStream* GetTPCRawStream(){return fTPCStream;} + private: #ifdef use_newio TString fFilename; // IO file name diff --git a/HLT/src/AliL3FileHandler.cxx b/HLT/src/AliL3FileHandler.cxx index 846331c9bef..c1acea193b3 100644 --- a/HLT/src/AliL3FileHandler.cxx +++ b/HLT/src/AliL3FileHandler.cxx @@ -530,8 +530,8 @@ AliL3DigitRowData * AliL3FileHandler::AliDigits2Memory(UInt_t & nrow,Int_t event dig = AliL3Transform::GetADCSat(); AliL3Transform::Raw2Local(xyz,sector,row,pad,time); - if(fParam->GetPadRowRadii(sector,row)<230./250.*fabs(xyz[2])) - continue; // why 230??? + // if(fParam->GetPadRowRadii(sector,row)<230./250.*fabs(xyz[2])) + // continue; // why 230??? ndigits[lrow]++; //for this row only ndigitcount++; //total number of digits to be published @@ -581,8 +581,8 @@ AliL3DigitRowData * AliL3FileHandler::AliDigits2Memory(UInt_t & nrow,Int_t event //Exclude data outside cone: AliL3Transform::Raw2Local(xyz,sector,row,pad,time); - if(fParam->GetPadRowRadii(sector,row)<230./250.*fabs(xyz[2])) - continue; // why 230??? + // if(fParam->GetPadRowRadii(sector,row)<230./250.*fabs(xyz[2])) + // continue; // why 230??? if(localcount >= ndigits[lrow]) LOG(AliL3Log::kFatal,"AliL3FileHandler::AliDigits2Binary","Memory") @@ -792,8 +792,8 @@ AliL3DigitRowData * AliL3FileHandler::AliAltroDigits2Memory(UInt_t & nrow,Int_t } AliL3Transform::Raw2Local(xyz,sector,row,pad,time); - if(fParam->GetPadRowRadii(sector,row)<230./250.*fabs(xyz[2])) - continue; + // if(fParam->GetPadRowRadii(sector,row)<230./250.*fabs(xyz[2])) + // continue; ndigits[lrow]++; //for this row only ndigitcount++; //total number of digits to be published @@ -930,8 +930,8 @@ AliL3DigitRowData * AliL3FileHandler::AliAltroDigits2Memory(UInt_t & nrow,Int_t } AliL3Transform::Raw2Local(xyz,sector,row,pad,time); - if(fParam->GetPadRowRadii(sector,row)<230./250.*fabs(xyz[2])) - continue; + // if(fParam->GetPadRowRadii(sector,row)<230./250.*fabs(xyz[2])) + // continue; if(localcount >= ndigits[lrow]) LOG(AliL3Log::kFatal,"AliL3FileHandler::AliAltroDigits2Binary","Memory") diff --git a/HLT/src/AliL3MemHandler.cxx b/HLT/src/AliL3MemHandler.cxx index 4f7194eed60..9b65568176e 100644 --- a/HLT/src/AliL3MemHandler.cxx +++ b/HLT/src/AliL3MemHandler.cxx @@ -183,7 +183,7 @@ void AliL3MemHandler::SetROI(Float_t *eta,Int_t */*slice*/) } -Bool_t AliL3MemHandler::SetBinaryInput(Char_t *name) +Bool_t AliL3MemHandler::SetBinaryInput(char *name) { //Set the input binary file. fInBinary = fopen(name,"r"); @@ -219,7 +219,7 @@ void AliL3MemHandler::CloseBinaryInput() fInBinary =0; } -Bool_t AliL3MemHandler::SetBinaryOutput(Char_t *name) +Bool_t AliL3MemHandler::SetBinaryOutput(char *name) { //Set the binary output file. fOutBinary = fopen(name,"w"); @@ -306,8 +306,8 @@ void AliL3MemHandler::Free() { //Clear the memory, if allocated. if(!fPt){ - LOG(AliL3Log::kInformational,"AliL3MemHandler::Free","Memory") - <<"No Memory allocated - can't Free"<= 6) + { + LOG(AliL3Log::kError,"AliL3Transform::GetFirstRow","Patch") + <= 6) + { + LOG(AliL3Log::kError,"AliL3Transform::GetLastRow","Patch") + < +#include #include #include #include +#include +#include +#include +#include #endif @@ -68,6 +72,7 @@ int main(int argc, char** argv) // open a log file FILE* file = fopen("monitorGDC.log", "w"); + TDatime time; // get data from a file or online from this node @@ -111,21 +116,11 @@ int main(int argc, char** argv) continue; } - // read run, event, detector, DDL numbers and data size AliRawReaderDate rawReader(ptr); - time.Set(); - printf("\n%s\n", time.AsString()); - printf("run: %d event: %d %d\n", rawReader.GetRunNumber(), - rawReader.GetEventId()[0], rawReader.GetEventId()[1]); - while (rawReader.ReadHeader()) { - printf(" detector: %d DDL: %d size: %d\n", - rawReader.GetDetectorID(), rawReader.GetDDLID(), - rawReader.GetDataSize()); - } - - if ((rawReader.GetAttributes()[0] & 0x02) != 0) { + // if ((rawReader.GetAttributes()[0] & 0x02) != 0) { - Int_t errorCode = rawReader.CheckData(); + // Int_t errorCode = rawReader.CheckData(); + Int_t errorCode = 0; if (errorCode && (errorCode != AliRawReader::kErrSize)) { time.Set(); if (file) fprintf(file, "%s\n", time.AsString()); @@ -137,38 +132,68 @@ int main(int argc, char** argv) } else { - // run the HLT tracker - AliLevel3* hlt = new AliLevel3((Char_t*)ptr); - hlt->Init("./", AliLevel3::kDate, 1); - - hlt->SetClusterFinderParam(-1, -1, kTRUE); - - Int_t phiSegments = 50; - Int_t etaSegments = 100; - Int_t trackletlength = 3; - Int_t tracklength = 20;//40 or 5 - Int_t rowscopetracklet = 2; - Int_t rowscopetrack = 10; - Double_t minPtFit = 0; - Double_t maxangle = 0.1745; - Double_t goodDist = 5; - Double_t maxphi = 0.1; - Double_t maxeta = 0.1; - Double_t hitChi2Cut = 15;//100 or 15 - Double_t goodHitChi2 = 5;//20 or 5 - Double_t trackChi2Cut = 10;//50 or 10 - hlt->SetTrackerParam(phiSegments, etaSegments, - trackletlength, tracklength, - rowscopetracklet, rowscopetrack, - minPtFit, maxangle, goodDist, hitChi2Cut, - goodHitChi2, trackChi2Cut, 50, maxphi, maxeta, - kTRUE); - - gSystem->Exec("rm -rf hlt"); - gSystem->MakeDirectory("hlt"); - hlt->WriteFiles("./hlt/"); - hlt->ProcessEvent(0, 35, 0); - + AliL3Benchmark *fBenchmark = new AliL3Benchmark(); + fBenchmark->Start("Overall timing"); + + // Run the Hough Transformer + fBenchmark->Start("Init"); + AliL3Hough *hough1 = new AliL3Hough(); + + hough1->SetThreshold(4); + hough1->SetTransformerParams(76,140,0.4,-1); + hough1->SetPeakThreshold(70,-1); + // printf("Pointer is %x\n",ptr); + hough1->Init("./", kFALSE, 100, kFALSE,4,0,(Char_t*)ptr,3.82147); + hough1->SetAddHistograms(); + fBenchmark->Stop("Init"); + + fBenchmark->Start("Init"); + AliL3Hough *hough2 = new AliL3Hough(); + + hough2->SetThreshold(4); + hough2->SetTransformerParams(76,140,0.4,-1); + hough2->SetPeakThreshold(70,-1); + // printf("Pointer is %x\n",ptr); + hough2->Init("./", kFALSE, 100, kFALSE,4,0,(Char_t*)ptr,3.82147); + hough2->SetAddHistograms(); + fBenchmark->Stop("Init"); + + Int_t n_global_tracks = 0; + hough1->StartProcessInThread(0,17); + hough2->StartProcessInThread(18,35); + + // gSystem->Sleep(20000); + if(hough1->WaitForThreadFinish()) + ::Fatal("AliL3Hough::WaitForThreadFinish"," Can not join the required thread! "); + if(hough2->WaitForThreadFinish()) + ::Fatal("AliL3Hough::WaitForThreadFinish"," Can not join the required thread! "); + + gSystem->MakeDirectory("hough1"); + hough1->WriteTracks("./hough1"); + gSystem->MakeDirectory("hough2"); + hough2->WriteTracks("./hough2"); + + /* + for(int slice=0; slice<=35; slice++) + { + // cout<<"Processing slice "<Start("ReadData"); + hough->ReadData(slice,0); + fBenchmark->Stop("ReadData"); + fBenchmark->Start("Transform"); + hough->Transform(); + fBenchmark->Stop("Transform"); + hough->AddAllHistogramsRows(); + hough->FindTrackCandidatesRow(); + fBenchmark->Start("AddTracks"); + hough->AddTracks(); + fBenchmark->Stop("AddTracks"); + + AliL3TrackArray* tracks = (AliL3TrackArray*)hough->GetTracks(0); + n_global_tracks += tracks->GetNTracks(); + } + */ + fBenchmark->Stop("Overall timing"); time.Set(); if (file) fprintf(file, "%s\n", time.AsString()); if (file) fprintf(file, "run: %d event: %d %d\n", @@ -177,39 +202,66 @@ int main(int argc, char** argv) rawReader.GetEventId()[1]); if (errorCode) fprintf(file, "ERROR: %d\n", errorCode); - AliL3MemHandler memHandler; - if (!memHandler.SetBinaryInput("hlt/tracks_0.raw")) { - if (file) fprintf(file, "no HLT tracks\n"); - continue; - } - AliL3TrackArray* tracks = new AliL3TrackArray; - memHandler.Binary2TrackArray(tracks); - if (file) fprintf(file, "HLT found %d tracks\n", tracks->GetNTracks()); - delete tracks; - memHandler.CloseBinaryInput(); + if (file) fprintf(file, "Hough Transformer found %d tracks\n",n_global_tracks); - hlt->DoBench("hlt"); + hough1->DoBench("hough1"); + hough2->DoBench("hough2"); + fBenchmark->Analyze("overall"); + if (file) { + FILE* bench = fopen("hough1.dat", "r"); + while (bench && !feof(bench)) { + char buffer[256]; + if (!fgets(buffer, 256, bench)) break; + fprintf(file, "%s", buffer); + } + fclose(bench); + } if (file) { - FILE* bench = fopen("hlt.dat", "r"); + FILE* bench = fopen("hough2.dat", "r"); while (bench && !feof(bench)) { char buffer[256]; if (!fgets(buffer, 256, bench)) break; fprintf(file, "%s", buffer); } fclose(bench); - fprintf(file, "\n"); + } + if (file) { + FILE* bench = fopen("overall.dat", "r"); + while (bench && !feof(bench)) { + char buffer[256]; + if (!fgets(buffer, 256, bench)) break; + fprintf(file, "%s", buffer); + } + fclose(bench); + fprintf(file, "\n\n"); } - gSystem->Exec("rm -rf hlt"); - delete hlt; + delete hough1; + delete hough2; } + // } + + /* + // read run, event, detector, DDL numbers and data size + AliRawReaderDate rawReader(ptr); + time.Set(); + printf("\n%s\n", time.AsString()); + printf("run: %d event: %d %d\n", rawReader.GetRunNumber(), + rawReader.GetEventId()[0], rawReader.GetEventId()[1]); + while (rawReader.ReadMiniHeader()) { + printf(" detector: %d DDL: %d size: %d\n", + rawReader.GetDetectorID(), rawReader.GetDDLID(), + rawReader.GetDataSize()); } + */ + gSystem->Sleep(100); // sleep for 0.1 second free(ptr); gSystem->ProcessEvents(); if (file) fflush(file); + } gSystem->RemoveSignalHandler(handler); diff --git a/RAW/AliTPCCompression.cxx b/RAW/AliTPCCompression.cxx index e994a13ee5b..d1271283911 100644 --- a/RAW/AliTPCCompression.cxx +++ b/RAW/AliTPCCompression.cxx @@ -892,8 +892,9 @@ UInt_t AliTPCCompression::ReadWord(Int_t NumberOfBit){ f.read((char*)(&fBuffer),sizeof(UInt_t)); fReadBits=0; }//end if - UInt_t mask=0; - mask=(UInt_t)TMath::Power(2,fReadBits); + // UInt_t mask=0; + // mask=(UInt_t)TMath::Power(2,fReadBits); + UInt_t mask=(UInt_t)(1<>fReadBits; fReadBits++; @@ -909,34 +910,40 @@ UInt_t AliTPCCompression::ReadWordBuffer(Int_t NumberOfBit){ UInt_t bit=0; for (Int_t i=0;i>fReadBits; - fReadBits++; + bit=fBuffer&0x1; bit=bit<>1; }//end for return result; } +////////////////////////////////////////////////////////////////////////////////////////////////// +inline UInt_t AliTPCCompression::ReadBitFromWordBuffer(){ + //This method retrieves a word of a specific number of bits from the file through the buffer + UInt_t result=0; + + if (fReadBits==32){ + fPointBuffer--; + fBuffer=*fPointBuffer; + fReadBits=0; + }//end if + result=fBuffer&0x1; + fReadBits++; + fBuffer=fBuffer>>1; + return result; +} + ////////////////////////////////////////////////////////////////////////////////////////////////// void AliTPCCompression::ReadTrailer(Int_t &WordsNumber,Int_t &PadNumber,Int_t &RowNumber,Int_t &SecNumber,Bool_t Memory){ //It retrieves a trailer if(Memory){ - ReadWordBuffer(1); + ReadBitFromWordBuffer(); SecNumber=ReadWordBuffer(9); RowNumber=ReadWordBuffer(10); PadNumber=ReadWordBuffer(10); @@ -952,17 +959,34 @@ void AliTPCCompression::ReadTrailer(Int_t &WordsNumber,Int_t &PadNumber,Int_t &R return; } ////////////////////////////////////////////////////////////////////////////////////////////////// -UInt_t AliTPCCompression::GetDecodedWord(AliTPCHNode* root,Bool_t Memory){ +inline UInt_t AliTPCCompression::GetDecodedWordBuffer(AliTPCHNode* root){ //This method retrieves a decoded word. AliTPCHNode *node=root; UInt_t symbol=0; Bool_t decoded=0; + while(!decoded){ - UInt_t bit=0; - if(Memory) - bit=ReadWordBuffer(1); + UInt_t bit=ReadBitFromWordBuffer(); + if(bit) + node=node->GetRight(); else - bit=ReadWord(1); + node=node->GetLeft(); + if (!(node->GetLeft())){ + symbol=node->GetSymbol(); + decoded=1; + } + }//end while + return symbol; +} + +inline UInt_t AliTPCCompression::GetDecodedWord(AliTPCHNode* root){ + //This method retrieves a decoded word. + AliTPCHNode *node=root; + UInt_t symbol=0; + Bool_t decoded=0; + + while(!decoded){ + UInt_t bit=ReadWord(1); if(bit) node=node->GetRight(); else @@ -972,6 +996,7 @@ UInt_t AliTPCCompression::GetDecodedWord(AliTPCHNode* root,Bool_t Memory){ decoded=1; } }//end while + return symbol; } ////////////////////////////////////////////////////////////////////////////////////////////////// @@ -1036,7 +1061,7 @@ Int_t AliTPCCompression::DecompressDataOptTables(Int_t NumTables,const char* fna Int_t bunchLen=0; Int_t count=0; for(Int_t i=0;i>1; fReadBits++; }//end while UInt_t packetNumber=ReadWordBuffer(sizeof(UInt_t)*8); //32 bits @@ -1121,7 +1139,7 @@ Int_t AliTPCCompression::Decompress(AliTPCHNode *RootNode[],Int_t /*NumTables*/, Int_t count=0; Int_t timeDigit=0; for(Int_t i=0;i