// @(#) $Id$ // Author: Constantin Loizides //*-- Copyright © ALICE HLT Group /** /class AliL3HoughTransformerLUT //
//_____________________________________________________________
// AliL3HoughTransformerLUT
//
// Hough transformation class using Look-UP-Tables
//
//
*/ #include "AliL3StandardIncludes.h" #include "AliL3Logging.h" #include "AliL3HoughTransformerLUT.h" #include "AliL3Transform.h" #include "AliL3MemHandler.h" #include "AliL3DigitData.h" #include "AliL3Histogram.h" #include "AliL3HistogramAdaptive.h" #if __GNUC__ >= 3 using namespace std; #endif ClassImp(AliL3HoughTransformerLUT) AliL3HoughTransformerLUT::AliL3HoughTransformerLUT() : AliL3HoughBaseTransformer() { // default contructor fParamSpace=0; fMinRow=0; fMaxRow=0; fNRows=0; fNEtas=0; fNPhi0=0; fSector=0; fSlice=0; fSectorRow=0; fZSign=0; fZLengthPlusOff=0; fTimeWidth=0; fPadPitch=0; fEtaSlice=0; fLUTX=0; fLUTY=0; fLUTEta=0; fLUTEtaReal=0; fLUTphi0=0; fLUT2sinphi0=0; fLUT2cosphi0=0; fLUTKappa=0; fLastPad=0; fLastIndex=0; fAccCharge=0; fX=fY=0.; } AliL3HoughTransformerLUT::AliL3HoughTransformerLUT(Int_t slice,Int_t patch,Int_t nEtaSegments) : AliL3HoughBaseTransformer(slice,patch,nEtaSegments) { // constructor fParamSpace=0; fMinRow=0; fMaxRow=0; fNRows=0; fNEtas=0; fNPhi0=0; fSector=0; fSectorRow=0; fZSign=0; fZLengthPlusOff=0; fTimeWidth=0; fPadPitch=0; fEtaSlice=0; fLUTX=0; fLUTY=0; fLUTEta=0; fLUTEtaReal=0; fLUTphi0=0; fLUT2sinphi0=0; fLUT2cosphi0=0; fLUTKappa=0; fLastPad=0; fLastIndex=0; fAccCharge=0; fX=fY=0.; Init(slice,patch,nEtaSegments); } AliL3HoughTransformerLUT::~AliL3HoughTransformerLUT() { // destructor DeleteHistograms(); if(fNRows){ delete[] fLUTX; delete[] fLUTY; fNRows=0; } if(fNEtas){ delete[] fLUTEta; delete[] fLUTEtaReal; fNEtas=0; } } void AliL3HoughTransformerLUT::DeleteHistograms() { // deletes all histograms if(fNPhi0){ delete[] fLUT2sinphi0; delete[] fLUT2cosphi0; delete[] fLUTphi0; delete[] fLUTKappa; fNPhi0=0; fLUTphi0=0; fLUT2sinphi0=0; fLUT2cosphi0=0; fLUTKappa=0; } if(!fParamSpace){ for(Int_t i=0; i Error: Number of Etas must be equal!" << endl; exit(1); } AliL3Transform::Slice2Sector(slice,fMinRow,fSector,fSectorRow); fZSign = slice < 18 ? 1:-1; //see AliL3Transformer fSlice = slice; fZLengthPlusOff=AliL3Transform::GetZLength()+AliL3Transform::GetZOffset(); fTimeWidth=AliL3Transform::GetZWidth(); fPadPitch=0; if(fSector etas //will only be used ifdef FULLLUT fLUTEta=new Float_t[fNEtas]; fLUTEtaReal=new Float_t[fNEtas]; for(Int_t rr=0;rr ptmax) { cerr<<"AliL3HoughTransformerLUT::CreateHistograms: Error in ptrange "<GetFirstYbin(); b<=hist->GetLastYbin(); b++) { Float_t phi0 = hist->GetBinCenterY(b); fLUTphi0[i]=phi0; fLUT2sinphi0[i]=2.*sin(phi0); fLUT2cosphi0[i]=2.*cos(phi0); fLUTKappa[i]=0.; i++; //cout << i << ": " << fLUTphi0[i] << " " << fLUT2sinphi0[i] << " " << fLUT2cosphi0[i] << endl; } } void AliL3HoughTransformerLUT::CreateHistograms(Int_t nxbin,Float_t ptMin,Int_t nybin,Float_t phimin,Float_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 //ptMin = 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()/ptMin; //Double_t torad = AliL3Transform::Pi()/180; CreateHistograms(nxbin,-1.*x,x,nybin,phimin/**torad*/,phimax/**torad*/); } void AliL3HoughTransformerLUT::CreateHistograms(Int_t nxbin,Float_t xmin,Float_t xmax,Int_t nybin,Float_t ymin,Float_t ymax) { fParamSpace = new AliL3Histogram*[fNEtas]; Char_t histname[256]; for(Int_t i=0; iGetFirstYbin(); b<=hist->GetLastYbin(); b++) { Float_t phi0 = hist->GetBinCenterY(b); fLUTphi0[i]=phi0; fLUT2sinphi0[i]=2.*sin(phi0); fLUT2cosphi0[i]=2.*cos(phi0); fLUTKappa[i]=0.; //cout << i << ": " << fLUTphi0[i] << " " << fLUT2sinphi0[i] << " " << fLUT2cosphi0[i] << endl; i++; } } void AliL3HoughTransformerLUT::Reset() { //Reset all the histograms if(!fParamSpace) { LOG(AliL3Log::kWarning,"AliL3HoughTransformer::Reset","Histograms") <<"No histograms to reset"<Reset(); } Int_t AliL3HoughTransformerLUT::GetEtaIndex(Double_t eta) const { //Return the histogram index of the corresponding eta. #ifdef FULLLUT /* try to imitate a circuit -> should go into the VHDL implementation of transformer */ Float_t rz2=CalcRoverZ2(eta); return FindIndex(rz2); #else /* optimize for speed on the computer */ Double_t index = (eta-GetEtaMin())/fEtaSlice; return (Int_t)index; #endif } AliL3Histogram *AliL3HoughTransformerLUT::GetHistogram(Int_t etaIndex) { // gets hitogram if(!fParamSpace || etaIndex >= fNEtas || etaIndex < 0) return 0; if(!fParamSpace[etaIndex]) return 0; return fParamSpace[etaIndex]; } Double_t AliL3HoughTransformerLUT::GetEta(Int_t etaIndex,Int_t slice) const { // gets eta if(etaIndex >= fNEtas || etaIndex < 0){ LOG(AliL3Log::kWarning,"AliL3HoughTransformerLUT::GetEta","Index") << "Index out of range."<fDigitData; if(i != (Int_t)tempPt->fRow) { LOG(AliL3Log::kError,"AliL3HoughTransformerLUT::TransformCircle","Data") <<"AliL3HoughTransformerLUT::TransformCircle : Mismatching padrow numbering "<0) AddCurveToHistogram(-1); //Move the data pointer to the next padrow: AliL3MemHandler::UpdateRowPointer(tempPt); } } void AliL3HoughTransformerLUT::Print() { // debug printout cout << "fSlice: " << GetSlice() << endl; cout << "fPatch: " << GetPatch() << endl; cout << "fSector: " << fSector << endl; cout << "fSectorRow: " << fSectorRow << endl; cout << "fMinRow: " << fMinRow << endl; cout << "fMaxRow: " << fMaxRow << endl; cout << "fNRows: " << fNRows << endl; cout << "fNEtas: " << fNEtas << endl; cout << "fNPhi0: " << fNPhi0 << endl; cout << "fZSign: " << fZSign << endl; cout << "fZLengthPlusOff: " << fZLengthPlusOff << endl; cout << "fPadPitch: " << fPadPitch << endl; cout << "fTimeWidth: " << fTimeWidth << endl; if(!fNRows) return; cout << "fLUTX " << fNRows << endl; for(Int_t i=0;i