ROOT logo
/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
 * See cxx source for full Copyright notice                               */

////////////////////////////////////////////////////////////////////////////
// AliTPCCorrectionLookupTable class                                              //
// Authors: Jens Wiechula                                            //
////////////////////////////////////////////////////////////////////////////

#include "AliTPCCorrection.h"
#include <TVectorD.h>
#include <TMatrixFfwd.h>
#include <THn.h>

class AliTPCCorrectionLookupTable : public AliTPCCorrection {

public:
  AliTPCCorrectionLookupTable();
  virtual ~AliTPCCorrectionLookupTable();

  virtual void GetCorrection(const Float_t x[],const Short_t roc,Float_t dx[]);
  virtual void GetDistortion(const Float_t x[],const Short_t roc,Float_t dx[]);

  void SetupDefaultLimits();
  void CreateLookupTable(AliTPCCorrection &tpcCorr, Float_t stepSize=5.);
  void CreateLookupTableSinglePhi(AliTPCCorrection &tpcCorr, Int_t iPhi, Float_t stepSize=5.);

  void CreateLookupTableFromResidualDistortion(THn &resDist);
  void CreateResidual(AliTPCCorrection *distortion, AliTPCCorrection* correction);
  
  void MergePhiTables(const char* files);

  void   SetFillCorrection(Bool_t fill) { fFillCorrection=fill;   }
  Bool_t GetFillCorrection() const      { return fFillCorrection; }
  void BuildExactInverse();

  Int_t GetNR()   const { return fNR;   }
  Int_t GetNPhi() const { return fNPhi; }
  Int_t GetNZ()   const { return fNZ;   }

  const TVectorD& GetLimitsR()   const { return fLimitsR; }
  const TVectorD& GetLimitsPhi() const { return fLimitsPhi; }
  const TVectorD& GetLimitsZ()   const { return fLimitsZ; }
  
  void SetCorrScaleFactor(Float_t    val) { fCorrScaleFactor = val; }
  Float_t    GetCorrScaleFactor() const { return fCorrScaleFactor; }
  
private:

  // sizes of lookup tables
  // TODO: Remove, since it will be stored in the TVectorD anyhow?
  Int_t     fNR;                   // number of rows (r) used for lookup table
  Int_t     fNPhi;                 // number of phi slices used for lookup table
  Int_t     fNZ;                   // number of columns (z) used for lookup table

  Float_t   fCorrScaleFactor;      // overall scaling factor for the correction
  
  Bool_t    fFillCorrection;       // whether to also fill the correction tables
  //
  TVectorD  fLimitsR;              // bin limits in row direction
  TVectorD  fLimitsPhi;            // bin limits in phi direction
  TVectorD  fLimitsZ;              // bin limits in z direction
  // for distortion
  TMatrixF **fLookUpDxDist;        //[fNPhi] Array to store electric field integral (int Er/Ez)
  TMatrixF **fLookUpDyDist;        //[fNPhi] Array to store electric field integral (int Er/Ez)
  TMatrixF **fLookUpDzDist;        //[fNPhi] Array to store electric field integral (int Er/Ez)

  // for correction
  TMatrixF **fLookUpDxCorr;        //[fNPhi] Array to store electric field integral (int Er/Ez)
  TMatrixF **fLookUpDyCorr;        //[fNPhi] Array to store electric field integral (int Er/Ez)
  TMatrixF **fLookUpDzCorr;        //[fNPhi] Array to store electric field integral (int Er/Ez)

  void InitTables();
  void InitTableArrays();
  void InitTablesPhiBin(Int_t iPhi);
  
  void ResetTables();
  void ResetLimits();
  
  void GetInterpolation(const Float_t x[],const Short_t roc,Float_t dx[],
                        TMatrixF **mR, TMatrixF **mPhi, TMatrixF **mZ);

  void CreateLookupTablePhiBin(AliTPCCorrection &tpcCorr, Int_t iPhi, Float_t stepSize);

  void FindClosestPosition(const Int_t binR, const Int_t binZ, const Int_t binPhi,
                           const Float_t xref[3], Float_t xret[3]);
  AliTPCCorrectionLookupTable(const AliTPCCorrectionLookupTable &corr);
  AliTPCCorrectionLookupTable& operator= (const AliTPCCorrectionLookupTable &corr);
  
  ClassDef(AliTPCCorrectionLookupTable,3);  // TPC corrections dumped into a lookup table
};


 AliTPCCorrectionLookupTable.h:1
 AliTPCCorrectionLookupTable.h:2
 AliTPCCorrectionLookupTable.h:3
 AliTPCCorrectionLookupTable.h:4
 AliTPCCorrectionLookupTable.h:5
 AliTPCCorrectionLookupTable.h:6
 AliTPCCorrectionLookupTable.h:7
 AliTPCCorrectionLookupTable.h:8
 AliTPCCorrectionLookupTable.h:9
 AliTPCCorrectionLookupTable.h:10
 AliTPCCorrectionLookupTable.h:11
 AliTPCCorrectionLookupTable.h:12
 AliTPCCorrectionLookupTable.h:13
 AliTPCCorrectionLookupTable.h:14
 AliTPCCorrectionLookupTable.h:15
 AliTPCCorrectionLookupTable.h:16
 AliTPCCorrectionLookupTable.h:17
 AliTPCCorrectionLookupTable.h:18
 AliTPCCorrectionLookupTable.h:19
 AliTPCCorrectionLookupTable.h:20
 AliTPCCorrectionLookupTable.h:21
 AliTPCCorrectionLookupTable.h:22
 AliTPCCorrectionLookupTable.h:23
 AliTPCCorrectionLookupTable.h:24
 AliTPCCorrectionLookupTable.h:25
 AliTPCCorrectionLookupTable.h:26
 AliTPCCorrectionLookupTable.h:27
 AliTPCCorrectionLookupTable.h:28
 AliTPCCorrectionLookupTable.h:29
 AliTPCCorrectionLookupTable.h:30
 AliTPCCorrectionLookupTable.h:31
 AliTPCCorrectionLookupTable.h:32
 AliTPCCorrectionLookupTable.h:33
 AliTPCCorrectionLookupTable.h:34
 AliTPCCorrectionLookupTable.h:35
 AliTPCCorrectionLookupTable.h:36
 AliTPCCorrectionLookupTable.h:37
 AliTPCCorrectionLookupTable.h:38
 AliTPCCorrectionLookupTable.h:39
 AliTPCCorrectionLookupTable.h:40
 AliTPCCorrectionLookupTable.h:41
 AliTPCCorrectionLookupTable.h:42
 AliTPCCorrectionLookupTable.h:43
 AliTPCCorrectionLookupTable.h:44
 AliTPCCorrectionLookupTable.h:45
 AliTPCCorrectionLookupTable.h:46
 AliTPCCorrectionLookupTable.h:47
 AliTPCCorrectionLookupTable.h:48
 AliTPCCorrectionLookupTable.h:49
 AliTPCCorrectionLookupTable.h:50
 AliTPCCorrectionLookupTable.h:51
 AliTPCCorrectionLookupTable.h:52
 AliTPCCorrectionLookupTable.h:53
 AliTPCCorrectionLookupTable.h:54
 AliTPCCorrectionLookupTable.h:55
 AliTPCCorrectionLookupTable.h:56
 AliTPCCorrectionLookupTable.h:57
 AliTPCCorrectionLookupTable.h:58
 AliTPCCorrectionLookupTable.h:59
 AliTPCCorrectionLookupTable.h:60
 AliTPCCorrectionLookupTable.h:61
 AliTPCCorrectionLookupTable.h:62
 AliTPCCorrectionLookupTable.h:63
 AliTPCCorrectionLookupTable.h:64
 AliTPCCorrectionLookupTable.h:65
 AliTPCCorrectionLookupTable.h:66
 AliTPCCorrectionLookupTable.h:67
 AliTPCCorrectionLookupTable.h:68
 AliTPCCorrectionLookupTable.h:69
 AliTPCCorrectionLookupTable.h:70
 AliTPCCorrectionLookupTable.h:71
 AliTPCCorrectionLookupTable.h:72
 AliTPCCorrectionLookupTable.h:73
 AliTPCCorrectionLookupTable.h:74
 AliTPCCorrectionLookupTable.h:75
 AliTPCCorrectionLookupTable.h:76
 AliTPCCorrectionLookupTable.h:77
 AliTPCCorrectionLookupTable.h:78
 AliTPCCorrectionLookupTable.h:79
 AliTPCCorrectionLookupTable.h:80
 AliTPCCorrectionLookupTable.h:81
 AliTPCCorrectionLookupTable.h:82
 AliTPCCorrectionLookupTable.h:83
 AliTPCCorrectionLookupTable.h:84
 AliTPCCorrectionLookupTable.h:85
 AliTPCCorrectionLookupTable.h:86
 AliTPCCorrectionLookupTable.h:87
 AliTPCCorrectionLookupTable.h:88
 AliTPCCorrectionLookupTable.h:89
 AliTPCCorrectionLookupTable.h:90
 AliTPCCorrectionLookupTable.h:91
 AliTPCCorrectionLookupTable.h:92