From 2bf29b72979d81311d601baf67c4a2c53c4e2384 Mon Sep 17 00:00:00 2001 From: marian Date: Fri, 4 Mar 2011 10:14:10 +0000 Subject: [PATCH] Changing internal representation of the corrections from Double to Float (Stefan Rossegger) related to the [bug #78839] 125 MB OCDB object - TPC/Calib/Correction --- TPC/AliTPCCorrection.cxx | 87 +++++++++++++++++++++++++++++++++++- TPC/AliTPCCorrection.h | 15 +++++++ TPC/AliTPCFCVoltError3D.cxx | 27 +++++++---- TPC/AliTPCFCVoltError3D.h | 13 +++--- TPC/AliTPCROCVoltError3D.cxx | 25 +++++++---- TPC/AliTPCROCVoltError3D.h | 10 ++--- TPC/AliTPCSpaceCharge3D.cxx | 28 ++++++------ TPC/AliTPCSpaceCharge3D.h | 13 +++--- 8 files changed, 170 insertions(+), 48 deletions(-) diff --git a/TPC/AliTPCCorrection.cxx b/TPC/AliTPCCorrection.cxx index f45e564ff41..cacb23f1324 100644 --- a/TPC/AliTPCCorrection.cxx +++ b/TPC/AliTPCCorrection.cxx @@ -650,7 +650,6 @@ Double_t AliTPCCorrection::Interpolate3DTable( const Int_t order, const Double_t } - Double_t AliTPCCorrection::Interpolate( const Double_t xArray[], const Double_t yArray[], const Int_t order, const Double_t x ) { // @@ -670,6 +669,92 @@ Double_t AliTPCCorrection::Interpolate( const Double_t xArray[], const Double_t } +Float_t AliTPCCorrection::Interpolate2DTable( const Int_t order, const Double_t x, const Double_t y, + const Int_t nx, const Int_t ny, const Double_t xv[], const Double_t yv[], + const TMatrixF &array ) { + // + // Interpolate table (TMatrix format) - 2D interpolation + // Float version (in order to decrease the OCDB size) + // + + static Int_t jlow = 0, klow = 0 ; + Float_t saveArray[5] = {0.,0.,0.,0.,0.} ; + + Search( nx, xv, x, jlow ) ; + Search( ny, yv, y, klow ) ; + if ( jlow < 0 ) jlow = 0 ; // check if out of range + if ( klow < 0 ) klow = 0 ; + if ( jlow + order >= nx - 1 ) jlow = nx - 1 - order ; + if ( klow + order >= ny - 1 ) klow = ny - 1 - order ; + + for ( Int_t j = jlow ; j < jlow + order + 1 ; j++ ) + { + Float_t *ajkl = &((TMatrixF&)array)(j,klow); + saveArray[j-jlow] = Interpolate( &yv[klow], ajkl , order, y ) ; + } + + return( Interpolate( &xv[jlow], saveArray, order, x ) ) ; + +} + +Float_t AliTPCCorrection::Interpolate3DTable( const Int_t order, const Double_t x, const Double_t y, const Double_t z, + const Int_t nx, const Int_t ny, const Int_t nz, + const Double_t xv[], const Double_t yv[], const Double_t zv[], + TMatrixF **arrayofArrays ) { + // + // Interpolate table (TMatrix format) - 3D interpolation + // Float version (in order to decrease the OCDB size) + // + + static Int_t ilow = 0, jlow = 0, klow = 0 ; + Float_t saveArray[5]= {0.,0.,0.,0.,0.}; + Float_t savedArray[5]= {0.,0.,0.,0.,0.} ; + + Search( nx, xv, x, ilow ) ; + Search( ny, yv, y, jlow ) ; + Search( nz, zv, z, klow ) ; + + if ( ilow < 0 ) ilow = 0 ; // check if out of range + if ( jlow < 0 ) jlow = 0 ; + if ( klow < 0 ) klow = 0 ; + + if ( ilow + order >= nx - 1 ) ilow = nx - 1 - order ; + if ( jlow + order >= ny - 1 ) jlow = ny - 1 - order ; + if ( klow + order >= nz - 1 ) klow = nz - 1 - order ; + + for ( Int_t k = klow ; k < klow + order + 1 ; k++ ) + { + TMatrixF &table = *arrayofArrays[k] ; + for ( Int_t i = ilow ; i < ilow + order + 1 ; i++ ) + { + saveArray[i-ilow] = Interpolate( &yv[jlow], &table(i,jlow), order, y ) ; + } + savedArray[k-klow] = Interpolate( &xv[ilow], saveArray, order, x ) ; + } + return( Interpolate( &zv[klow], savedArray, order, z ) ) ; + +} +Float_t AliTPCCorrection::Interpolate( const Double_t xArray[], const Float_t yArray[], + const Int_t order, const Double_t x ) { + // + // Interpolate function Y(x) using linear (order=1) or quadratic (order=2) interpolation. + // Float version (in order to decrease the OCDB size) + // + + Float_t y ; + if ( order == 2 ) { // Quadratic Interpolation = 2 + y = (x-xArray[1]) * (x-xArray[2]) * yArray[0] / ( (xArray[0]-xArray[1]) * (xArray[0]-xArray[2]) ) ; + y += (x-xArray[2]) * (x-xArray[0]) * yArray[1] / ( (xArray[1]-xArray[2]) * (xArray[1]-xArray[0]) ) ; + y += (x-xArray[0]) * (x-xArray[1]) * yArray[2] / ( (xArray[2]-xArray[0]) * (xArray[2]-xArray[1]) ) ; + } else { // Linear Interpolation = 1 + y = yArray[0] + ( yArray[1]-yArray[0] ) * ( x-xArray[0] ) / ( xArray[1] - xArray[0] ) ; + } + + return (y); + +} + + void AliTPCCorrection::Search( const Int_t n, const Double_t xArray[], const Double_t x, Int_t &low ) { // diff --git a/TPC/AliTPCCorrection.h b/TPC/AliTPCCorrection.h index fcd2f3ae2d7..d3518e60359 100644 --- a/TPC/AliTPCCorrection.h +++ b/TPC/AliTPCCorrection.h @@ -12,6 +12,7 @@ #include #include "TMatrixD.h" +#include "TMatrixF.h" class TH2F; class TTimeStamp; class TCollection; @@ -105,12 +106,14 @@ protected: // Simple Interpolation functions: e.g. with tricubic interpolation (not yet in TH3) Int_t fILow, fJLow, fKLow; // variable to help in the interpolation + // Double_t versions void Interpolate2DEdistortion( const Int_t order, const Double_t r, const Double_t z, const Double_t er[kNZ][kNR], Double_t &erValue ); void Interpolate3DEdistortion( const Int_t order, const Double_t r, const Float_t phi, const Double_t z, const Double_t er[kNZ][kNPhi][kNR], const Double_t ephi[kNZ][kNPhi][kNR], const Double_t ez[kNZ][kNPhi][kNR], Double_t &erValue, Double_t &ephiValue, Double_t &ezValue); + // TMatrixD versions (for e.g. Poisson relaxation) Double_t Interpolate2DTable( const Int_t order, const Double_t x, const Double_t y, const Int_t nx, const Int_t ny, const Double_t xv[], const Double_t yv[], const TMatrixD &array ); @@ -121,6 +124,18 @@ protected: Double_t Interpolate( const Double_t xArray[], const Double_t yArray[], const Int_t order, const Double_t x ); void Search( const Int_t n, const Double_t xArray[], const Double_t x, Int_t &low ); + + // TMatrixF versions (smaller size, e.g. for final look up table) + Float_t Interpolate2DTable( const Int_t order, const Double_t x, const Double_t y, + const Int_t nx, const Int_t ny, const Double_t xv[], const Double_t yv[], + const TMatrixF &array ); + Float_t Interpolate3DTable( const Int_t order, const Double_t x, const Double_t y, const Double_t z, + const Int_t nx, const Int_t ny, const Int_t nz, + const Double_t xv[], const Double_t yv[], const Double_t zv[], + TMatrixF **arrayofArrays ); + Float_t Interpolate( const Double_t xArray[], const Float_t yArray[], + const Int_t order, const Double_t x ); + virtual Int_t IsPowerOfTwo ( Int_t i ) const ; diff --git a/TPC/AliTPCFCVoltError3D.cxx b/TPC/AliTPCFCVoltError3D.cxx index 37c2aaa704a..da9a9b4aee7 100644 --- a/TPC/AliTPCFCVoltError3D.cxx +++ b/TPC/AliTPCFCVoltError3D.cxx @@ -75,6 +75,7 @@ #include "AliTPCParam.h" #include "AliLog.h" #include "TMatrixD.h" +#include "TMatrixF.h" #include "TMath.h" #include "AliTPCROC.h" @@ -115,9 +116,9 @@ AliTPCFCVoltError3D::AliTPCFCVoltError3D() // it represents a sum up of the 4 basic look up tables (created individually) // see InitFCVoltError3D() function for ( Int_t k = 0 ; k < kNPhi ; k++ ) { - fLookUpErOverEz[k] = new TMatrixD(kNR,kNZ); - fLookUpEphiOverEz[k] = new TMatrixD(kNR,kNZ); - fLookUpDeltaEz[k] = new TMatrixD(kNR,kNZ); + fLookUpErOverEz[k] = new TMatrixF(kNR,kNZ); + fLookUpEphiOverEz[k] = new TMatrixF(kNR,kNZ); + fLookUpDeltaEz[k] = new TMatrixF(kNR,kNZ); } for ( Int_t k = 0 ; k < kPhiSlices ; k++ ) { @@ -230,16 +231,26 @@ void AliTPCFCVoltError3D::GetCorrection(const Float_t x[],const Short_t roc,Floa // // Calculates the correction due e.g. residual voltage errors on the TPC boundaries // + const Double_t kEpsilon=Double_t(FLT_MIN); if (!fInitLookUp) { AliInfo("Lookup table was not initialized! Perform the inizialisation now ..."); InitFCVoltError3D(); } + static Bool_t forceInit=kTRUE; //temporary needed for back compatibility with old OCDB entries + if (forceInit &&fLookUpErOverEz[0]){ + if (fLookUpErOverEz[0]->Sum()Sum()