From: vestbo Date: Fri, 31 May 2002 14:41:19 +0000 (+0000) Subject: Some changes in AliL3Hough::Evaluate. Comments have been added in the code. X-Git-Url: http://git.uio.no/git/?p=u%2Fmrichter%2FAliRoot.git;a=commitdiff_plain;h=0309a5eefcbabc4a69bdeeff2f6e96a25315c8f5 Some changes in AliL3Hough::Evaluate. Comments have been added in the code. Added some timing outputs in AliL3Hough. In AliL3HoughEval::LookInsideRoad; removed the check whether the tracks is leaving the slice; because this fails when the tracks is bending _in_ to the slice. In the argument, one can also access the number of padrows which where good; meaning padrows along the road which had signal. In AliL3HoughMaxFinder; currently the check for the gradient is commented out. --- diff --git a/HLT/hough/AliL3Hough.cxx b/HLT/hough/AliL3Hough.cxx index 8af03dfc42c..085458615ce 100644 --- a/HLT/hough/AliL3Hough.cxx +++ b/HLT/hough/AliL3Hough.cxx @@ -5,6 +5,7 @@ #include +#include #include "AliL3HoughMerger.h" #include "AliL3HoughIntMerger.h" @@ -137,13 +138,15 @@ void AliL3Hough::Init(Char_t *path,Bool_t binary,Int_t n_eta_segments,Bool_t bit fHoughTransformer[i] = new AliL3HoughTransformerVhdl(1,i,fNEtaSegments); fHoughTransformer[i]->CreateHistograms(180,0.1,180,-90,90); fHoughTransformer[i]->SetLowerThreshold(3); + break; default: fHoughTransformer[i] = new AliL3HoughTransformer(1,i,fNEtaSegments); fHoughTransformer[i]->CreateHistograms(64,0.1,64,-30,30); fHoughTransformer[i]->SetLowerThreshold(3); } - + LOG(AliL3Log::kInformational,"AliL3Hough::Init","Version") + <<"Initializing Hough transformer version "<Reset();//Reset the histograms @@ -234,6 +239,9 @@ void AliL3Hough::Transform(Int_t row_range=-1) else fHoughTransformer[i]->TransformCircleC(row_range); } + cpuTime = GetCpuTime() - initTime; + LOG(AliL3Log::kInformational,"AliL3Hough::Transform()","Timing") + <<"Transform done in average per patch of "<GetHistogram(i); @@ -322,6 +332,9 @@ void AliL3Hough::AddAllHistograms() } } fAddHistograms = kTRUE; + cpuTime = GetCpuTime() - initTime; + LOG(AliL3Log::kInformational,"AliL3Hough::AddAllHistograms()","Timing") + <<"Adding histograms in "<QSort(); } + cpuTime = GetCpuTime() - initTime; + LOG(AliL3Log::kInformational,"AliL3Hough::FindTrackCandidates()","Timing") + <<"Maxima finding done in "<InitTransformer(fHoughTransformer[i]); } -void AliL3Hough::Evaluate(Int_t road_width) +Int_t AliL3Hough::Evaluate(Int_t road_width,Int_t nrowstomiss) { //Evaluate the tracks, by looking along the road in the raw data. //If track does not cross all padrows - rows2miss, it is removed from the arrray. + //If histograms were not added, the check is done locally in patch, + //meaning that nrowstomiss is the number of padrows the road can miss with respect + //to the number of rows in the patch. + //If the histograms were added, the comparison is done globally in the _slice_, + //meaing that nrowstomiss is the number of padrows the road can miss with + //respect to the total number of padrows in the slice. + // + //Return value = number of tracks which were removed (only in case of fAddHistograms) if(!fTracks[0]) { LOG(AliL3Log::kError,"AliL3Hough::Evaluate","Track Array") <<"No tracks to work with..."<GetNTracks()]; + for(Int_t i=0; iGetNTracks(); i++) + total_rows[i]=0; + } + for(Int_t i=0; iInitTransformer(fHoughTransformer[i]); - fEval[i]->SetNumOfRowsToMiss(2); fEval[i]->SetNumOfPadsToLook(road_width); - if(fAddHistograms) - tracks = fTracks[0]; - else + fEval[i]->SetNumOfRowsToMiss(nrowstomiss); + if(!fAddHistograms) tracks = fTracks[i]; + for(Int_t j=0; jGetNTracks(); j++) { AliL3HoughTrack *track = (AliL3HoughTrack*)tracks->GetCheckedTrack(j); @@ -409,18 +443,39 @@ void AliL3Hough::Evaluate(Int_t road_width) continue; } - if(!fEval[i]->LookInsideRoad(track,track->GetEtaIndex())) - tracks->Remove(j); - if(fAddHistograms) - track->SetRowRange(AliL3Transform::GetFirstRow(0),AliL3Transform::GetLastRow(5));//All rows included + Bool_t result = fEval[i]->LookInsideRoad(track,total_rows[j]); + if(!fAddHistograms)//the track crossed too few good padrows (padrows with signal) in the patch, so remove it + { + if(result == kFALSE) + tracks->Remove(j); + } } - tracks->Compress(); - tracks->QSort(); //Sort the tracks according to weight - if(!fAddHistograms) - fMerger->FillTracks(tracks,i); //Copy tracks to the track merger + { + tracks->Compress(); + tracks->QSort(); + fMerger->FillTracks(tracks,i); //Copy tracks to the track merger + } } + if(fAddHistograms) //Here we check the tracks globally; how many good rows (padrows with signal) did it cross in the slice + { + for(Int_t j=0; jGetNTracks(); j++) + { + if(total_rows[j] < AliL3Transform::GetNRows() - nrowstomiss) + { + tracks->Remove(j); + removed_tracks++; + } + } + tracks->Compress(); + tracks->QSort(); + } + + if(total_rows) + delete [] total_rows; + + return removed_tracks; } void AliL3Hough::EvaluateWithEta() @@ -485,3 +540,11 @@ void AliL3Hough::WriteDigits(Char_t *outfile) #endif } +Double_t AliL3Hough::GetCpuTime() +{ + //Return the Cputime in seconds. + struct timeval tv; + gettimeofday( &tv, NULL ); + return tv.tv_sec+(((Double_t)tv.tv_usec)/1000000.); + //return (Double_t)(clock()) / CLOCKS_PER_SEC; +} diff --git a/HLT/hough/AliL3Hough.h b/HLT/hough/AliL3Hough.h index 02960bcba3e..7999f4b6690 100644 --- a/HLT/hough/AliL3Hough.h +++ b/HLT/hough/AliL3Hough.h @@ -38,6 +38,7 @@ class AliL3Hough { AliL3HoughGlobalMerger *fGlobalMerger; //! void CleanUp(); + Double_t GetCpuTime(); public: @@ -56,7 +57,7 @@ class AliL3Hough { void FindTrackCandidates(); void AddAllHistograms(); - void Evaluate(Int_t road_width=1); + Int_t Evaluate(Int_t road_width=1,Int_t nrowstomiss=1); void EvaluateWithEta(); void WriteTracks(Int_t slice,Char_t *path="./"); void WriteDigits(Char_t *outfile="output_digits.root"); diff --git a/HLT/hough/AliL3HoughEval.cxx b/HLT/hough/AliL3HoughEval.cxx index 51a7bcfd7e8..6a26d0cba86 100644 --- a/HLT/hough/AliL3HoughEval.cxx +++ b/HLT/hough/AliL3HoughEval.cxx @@ -81,19 +81,21 @@ void AliL3HoughEval::GenerateLUT() } -Bool_t AliL3HoughEval::LookInsideRoad(AliL3HoughTrack *track,Int_t eta_index,Bool_t remove) +Bool_t AliL3HoughEval::LookInsideRoad(AliL3HoughTrack *track,Int_t &nrows_crossed,Bool_t remove) { //Look at rawdata along the road specified by the track candidates. //If track is good, return true, if not return false. Int_t sector,row; - Int_t nrow=0,npixs=0,rows_crossed=0; + Int_t nrow=0,npixs=0;//,rows_crossed=0; Float_t xyz[3]; Int_t total_charge=0;//total charge along the road - + + /* //Check if the track is leaving the sector at some point + //This does not work, if the track is bending _in_ to the slice..... Float_t maxrow=300; Double_t angle=AliL3Transform::Pi()/18; track->CalculateEdgePoint(angle); @@ -105,11 +107,13 @@ Bool_t AliL3HoughEval::LookInsideRoad(AliL3HoughTrack *track,Int_t eta_index,Boo } else maxrow = track->GetPointX(); - + */ + for(Int_t padrow = AliL3Transform::GetFirstRow(fPatch); padrow <= AliL3Transform::GetLastRow(fPatch); padrow++) { - if(AliL3Transform::Row2X(padrow) > maxrow) break;//The track has left this slice - rows_crossed++; + //if(AliL3Transform::Row2X(padrow) > maxrow) break;//The track has left this slice + //rows_crossed++; + Int_t prow = padrow - AliL3Transform::GetFirstRow(fPatch); if(!track->GetCrossingPoint(padrow,xyz)) { @@ -120,7 +124,6 @@ Bool_t AliL3HoughEval::LookInsideRoad(AliL3HoughTrack *track,Int_t eta_index,Boo AliL3Transform::Local2Raw(xyz,sector,row); npixs=0; - //Get the timebins for this pad AliL3DigitRowData *tempPt = fRowPointers[prow]; if(!tempPt) @@ -136,13 +139,15 @@ Bool_t AliL3HoughEval::LookInsideRoad(AliL3HoughTrack *track,Int_t eta_index,Boo for(UInt_t j=0; jfNDigit; j++) { UChar_t pad = digPt[j].fPad; + Int_t charge = digPt[j].fCharge; + if(charge <= fHoughTransformer->GetLowerThreshold()) continue; if(pad < p) continue; if(pad > p) break; UShort_t time = digPt[j].fTime; Double_t eta = AliL3Transform::GetEta(padrow,pad,time); Int_t pixel_index = fHoughTransformer->GetEtaIndex(eta); - if(pixel_index > eta_index) continue; - if(pixel_index != eta_index) break; + if(pixel_index > track->GetEtaIndex()) continue; + if(pixel_index != track->GetEtaIndex()) break; total_charge += digPt[j].fCharge; if(remove) digPt[j].fCharge = 0; //Erase the track from image @@ -158,10 +163,15 @@ Bool_t AliL3HoughEval::LookInsideRoad(AliL3HoughTrack *track,Int_t eta_index,Boo if(remove) return kTRUE; - if(nrow >= rows_crossed - fNumOfRowsToMiss)//this was a good track + nrows_crossed += nrow; //Update the number of rows crossed. + + if(nrow >= AliL3Transform::GetNRows(fPatch) - fNumOfRowsToMiss)//this was a good track { if(fRemoveFoundTracks) - LookInsideRoad(track,eta_index,kTRUE); + { + Int_t dummy=0; + LookInsideRoad(track,dummy,kTRUE); + } return kTRUE; } else @@ -217,7 +227,8 @@ void AliL3HoughEval::FindEta(AliL3TrackArray *tracks) for(UInt_t j=0; jfNDigit; j++) { UChar_t pad = digPt[j].fPad; - + Int_t charge = digPt[j].fCharge; + if(charge <= fHoughTransformer->GetLowerThreshold()) continue; if(pad < p) continue; if(pad > p) break; UShort_t time = digPt[j].fTime; @@ -289,7 +300,7 @@ void AliL3HoughEval::DisplayEtaSlice(Int_t eta_index,AliL3Histogram *hist) UChar_t pad = digPt[j].fPad; UChar_t charge = digPt[j].fCharge; UShort_t time = digPt[j].fTime; - if((Int_t)charge < fHoughTransformer->GetLowerThreshold() || (Int_t)charge > fHoughTransformer->GetUpperThreshold()) continue; + if((Int_t)charge <= fHoughTransformer->GetLowerThreshold() || (Int_t)charge >= fHoughTransformer->GetUpperThreshold()) continue; Float_t xyz[3]; Int_t sector,row; AliL3Transform::Slice2Sector(fSlice,padrow,sector,row); diff --git a/HLT/hough/AliL3HoughEval.h b/HLT/hough/AliL3HoughEval.h index 7d657947716..ca6c899799b 100644 --- a/HLT/hough/AliL3HoughEval.h +++ b/HLT/hough/AliL3HoughEval.h @@ -37,7 +37,7 @@ class AliL3HoughEval { void InitTransformer(AliL3HoughBaseTransformer *transformer); void GenerateLUT(); void DisplayEtaSlice(Int_t eta_index,AliL3Histogram *hist); - Bool_t LookInsideRoad(AliL3HoughTrack *track,Int_t eta_index,Bool_t remove=kFALSE); + Bool_t LookInsideRoad(AliL3HoughTrack *track,Int_t &nrows_crossed,Bool_t remove=kFALSE); #ifdef use_root void CompareMC(AliL3TrackArray *tracks,Char_t *goodtracks="good_tracks",Int_t treshold=0); #endif diff --git a/HLT/hough/AliL3HoughGlobalMerger.cxx b/HLT/hough/AliL3HoughGlobalMerger.cxx index c5334955c14..66c7af58965 100644 --- a/HLT/hough/AliL3HoughGlobalMerger.cxx +++ b/HLT/hough/AliL3HoughGlobalMerger.cxx @@ -16,246 +16,56 @@ ClassImp(AliL3HoughGlobalMerger) -AliL3HoughGlobalMerger::AliL3HoughGlobalMerger(){ - //Default constructor - Is2Global(kTRUE); - SetParameter(2,2,0.001,0.05,0.1); -} - - -AliL3HoughGlobalMerger::AliL3HoughGlobalMerger(Int_t first,Int_t last) : AliL3Merger(last-first+1,"AliL3HoughTrack") +AliL3HoughGlobalMerger::AliL3HoughGlobalMerger() { - //Constructor. - fNSlices = last-first+1; - fFirst = first; - fLast = last; - Is2Global(kTRUE); - SetParameter(2,2,0.001,0.05,0.1); + fTracks = 0; } -AliL3HoughGlobalMerger::~AliL3HoughGlobalMerger(){ - //Destructor -} - - -void AliL3HoughGlobalMerger::FillTracks(AliL3TrackArray *tracks,Int_t slice) +AliL3HoughGlobalMerger::AliL3HoughGlobalMerger(Int_t first,Int_t last) { - fSlice = slice; - fCurrentTracks = fSlice - fFirst; - if(tracks->GetNTracks()==0) - LOG(AliL3Log::kWarning,"AliL3HoughGlobalMerger::FillTracks","Track Array") - <AddTracks(tracks,kFALSE,fSlice);//Copy tracks, and rotate them to global coordinates } - -Bool_t AliL3HoughGlobalMerger::IsTrack(AliL3Track *innertrack,AliL3Track *outertrack) +AliL3HoughGlobalMerger::~AliL3HoughGlobalMerger() { - //Check if the tracks can be merged, called by the track merger - - AliL3HoughTrack *tr1 = (AliL3HoughTrack*)innertrack; - AliL3HoughTrack *tr2 = (AliL3HoughTrack*)outertrack; - - if( (!tr1->IsPoint()) || (!tr2->IsPoint()) ) return kFALSE; - if(abs(tr1->GetEtaIndex() - tr2->GetEtaIndex()) > 1) return kFALSE; - if(tr1->GetCharge() != tr2->GetCharge()) return kFALSE; - if(fabs(tr1->GetPhi0() - tr2->GetPhi0()) > fMaxPhi0) return kFALSE; - if(fabs(tr1->GetKappa() - tr2->GetKappa()) > fMaxKappa) return kFALSE; + if(fTracks) + { + for(Int_t i=0; iNextTrack(); - AliL3HoughTrack **trs = (AliL3HoughTrack**)tracks; - Int_t weight=0; - - //Sum up the total weight: - for(Int_t i=ntrack-1; i>=0; i--) - weight += trs[i]->GetWeight(); - AliL3HoughTrack *tpt=trs[0];//This is the innermost track - AliL3HoughTrack *tpl=trs[ntrack-1]; - newtrack->SetTrackParameters(tpt->GetKappa(),tpt->GetPhi0(),weight); - newtrack->SetEtaIndex(tpt->GetEtaIndex()); - newtrack->SetEta(tpt->GetEta()); - newtrack->SetPsi(tpt->GetPsi()); - newtrack->SetCenterX(tpt->GetCenterX()); - newtrack->SetCenterY(tpt->GetCenterY()); - newtrack->SetFirstPoint(tpt->GetFirstPointX(),tpt->GetFirstPointY(),tpt->GetFirstPointZ()); - newtrack->SetLastPoint(tpl->GetLastPointX(),tpl->GetLastPointY(),tpl->GetLastPointZ()); - newtrack->SetCharge(tpt->GetCharge()); - newtrack->SetRowRange(tpt->GetFirstRow(),tpl->GetLastRow()); + fTracks[slice]->AddTracks(tracks,kTRUE,slice); - return (AliL3Track*)newtrack; - -} - -void AliL3HoughGlobalMerger::SlowMerge(){ - void* ntuple=GetNtuple(); - AliL3Track *track[2]; - AliL3TrackArray *tout = GetOutTracks(); - if(fNSlices<2){ - LOG(AliL3Log::kWarning,"AliL3HoughGlobalMerger::SlowMerge","Slice Number") - <<"Need more than one Slice!"< the border of the slices - AliL3Transform::Local2GlobalAngle(&angle,slice); - if(i==0) - ttt0->QSort(); - ttt1->QSort(); - for(Int_t s0=0;s0GetNTracks();s0++){ - AliL3Track *track0=ttt0->GetCheckedTrack(s0); - if(!track0) continue; - track0->CalculateHelix(); - track0->CalculateEdgePoint(angle); -// if(track0->IsPoint()) AddTrack(tout,track0); - } - for(Int_t s1=0;s1GetNTracks();s1++){ - AliL3Track *track1=ttt1->GetCheckedTrack(s1); - if(!track1) continue; - track1->CalculateHelix(); - track1->CalculateEdgePoint(angle); -// if(track1->IsPoint()) AddTrack(tout,track1); - } - Bool_t merge = kTRUE; - while(merge){ - Int_t min0=-1,min1=-1; - Double_t min=10; - for(Int_t s0=0;s0GetNTracks();s0++){ - AliL3Track *track0=ttt0->GetCheckedTrack(s0); - if(!track0) continue; - if(!track0->IsPoint()) continue; - for(Int_t s1=0;s1GetNTracks();s1++){ - AliL3Track *track1=ttt1->GetCheckedTrack(s1); - if(!track1) continue; - if(!track1->IsPoint()) continue; - Double_t diff = TrackDiff(track0,track1); - if(diff>=0&&diff=0&&min1>=0){ - AliL3Track *track0=ttt0->GetTrack(min0); - AliL3Track *track1=ttt1->GetTrack(min1); - track[0] = track0; - track[1] = track1; - SortGlobalTracks(track,2); - MultiMerge(tout,track,2); - track0->CalculateReferencePoint(angle); - track1->CalculateReferencePoint(angle); - PrintDiff(track0,track1); - FillNtuple(ntuple,track0,track1); - ttt0->Remove(min0); - ttt1->Remove(min1); - } - else merge = kFALSE; - } - ttt0->Compress(); - ttt1->Compress(); - LOG(AliL3Log::kInformational,"AliL3HoughGlobalMerger::SlowMerge","Result") - <GetNTracks()<<" at:" - < the border of the slices + if(slice+1 == fNSlices) continue; + AliL3TrackArray *t1 = fTracks[slice]; + AliL3TrackArray *t2 = fTracks[slice+1]; + Float_t angle = AliL3Transform::Pi()/18; AliL3Transform::Local2GlobalAngle(&angle,slice); - if(i==0) - ttt0->QSort(); - ttt1->QSort(); - if(ismatched0) delete [] ismatched0; - if(ismatched1) delete [] ismatched1; - ismatched0 = new Bool_t[ttt0->GetNTracks()]; - ismatched1 = new Bool_t[ttt1->GetNTracks()]; - Int_t n0=0,n1=0; - for(Int_t s0=0;s0GetNTracks();s0++) - { - ismatched0[s0]=kFALSE; - AliL3Track *track0=ttt0->GetCheckedTrack(s0); - if(!track0) continue; - track0->CalculateHelix(); - track0->CalculateEdgePoint(angle); - if(track0->IsPoint()) {n0++;track0->CalculateReferencePoint(angle); - } - } - for(Int_t s1=0;s1GetNTracks();s1++) - { - ismatched1[s1]=kFALSE; - AliL3Track *track1=ttt1->GetCheckedTrack(s1); - if(!track1) continue; - track1->CalculateHelix(); - track1->CalculateEdgePoint(angle); - if(track1->IsPoint()) {n1++;track1->CalculateReferencePoint(angle); - } - } - for(Int_t s0=0;s0GetNTracks();s0++) + + for(Int_t i=0; iGetNTracks(); i++) { - AliL3Track *track0=ttt0->GetCheckedTrack(s0); - if(!track0) continue; - if(!track0->IsPoint()) continue; - for(Int_t s1=0;s1GetNTracks();s1++) - { - if(ismatched1[s1]) continue; - AliL3Track *track1=ttt1->GetCheckedTrack(s1); - if(!track1) continue; - if(!track1->IsPoint()) continue; - if(IsTrack(track0,track1)) - { - track[0] = track0; - track[1] = track1; - SortGlobalTracks(track,2); - Double_t r0 = pow(track[0]->GetLastPointX(),2) + pow(track[0]->GetLastPointY(),2); - Double_t r1 = pow(track[1]->GetFirstPointX(),2) + pow(track[1]->GetFirstPointY(),2); - if(r0Remove(s0); - ttt1->Remove(s1); - } - } - } + } - LOG(AliL3Log::kInformational,"AliL3HoughGlobalMerger::Merge","Result") - <GetNTracks()<GetBinCenterX(xbin); Float_t max_y = fCurrentHisto->GetBinCenterY(ybin); - cout<<"Checking for threshols "< fNMax) + if(fNPeaks >= fNMax) { cerr<<"AliL3HoughMaxFinder::FindMaxima : Array out of range "<