]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - TPC/AliTPCcalibAlign.h
fix division by 0 in graph creation
[u/mrichter/AliRoot.git] / TPC / AliTPCcalibAlign.h
index 398b4d25e3125e9541e95bd1de161382b96b0fd5..2a8d07425819de4b8c2ea4e84e71f382582aa4a4 100644 (file)
 #include "TH1.h"
 
 class AliExternalTrackParam;
+class AliExternalComparison;
 class AliTPCseed;
+class TGraphErrors;
+class TTree;
+class THnSparse;
+class AliTPCPointCorrection;
+class TFile;
 
 class AliTPCcalibAlign:public AliTPCcalibBase {
 public:
+  enum HistoType {kY=0, kZ =1, kPhi=2, kTheta=3, 
+                 kYPhi=4, kZTheta=5, 
+                 kYz=6,kZz=7,kPhiZ=8,kThetaZ=9};
+  enum FitType{ k6=0, k9=1, k12=2};
   AliTPCcalibAlign();
   AliTPCcalibAlign(const Text_t *name, const Text_t *title);
-
+  AliTPCcalibAlign(const AliTPCcalibAlign &align);
+  //
   virtual ~AliTPCcalibAlign();
-
+  void     Process(AliESDEvent *event);
   virtual void Process(AliTPCseed *track);
-
+  virtual void Analyze();
+  virtual void Terminate();  
+  virtual Long64_t Merge(TCollection* list);
+  void ExportTrackPoints(AliESDEvent *event);
+  //
+  //
+  void MakeReportDy(TFile *output); 
+  void MakeReportDyPhi(TFile *output);
+  //
+  void UpdatePointCorrection(AliTPCPointCorrection * correction);
+  //
+  virtual void EvalFitters(Int_t minPoints=20);
+  TH1 * GetHisto(HistoType type, Int_t s1, Int_t s2, Bool_t force=kFALSE);
+  void  MakeTree(const char *fname="alignTree.root", Int_t minPoints=20);
+  TGraphErrors * MakeGraph(Int_t sec0, Int_t sec1, Int_t dsec, 
+                          Int_t i0, Int_t i1, FitType type); 
+  Int_t  RefitLinear(const AliTPCseed * seed, Int_t isec, Double_t *fitParam, Int_t refSector, TMatrixD &param, TMatrixD&covar, Double_t xRef, Bool_t both=kFALSE);
+  
   void ProcessTracklets(const AliExternalTrackParam &t1,
                        const AliExternalTrackParam &t2,
+                       const AliTPCseed * seed,
                        Int_t s1,Int_t s2);
-  void Eval();
-  TLinearFitter* GetFitter12(Int_t s1,Int_t s2) {
-    return static_cast<TLinearFitter*>(fFitterArray12[s1*72+s2]);
-  }
-  TLinearFitter* GetFitter9(Int_t s1,Int_t s2) {
-    return static_cast<TLinearFitter*>(fFitterArray9[s1*72+s2]);
-  }
-  TLinearFitter* GetFitter6(Int_t s1,Int_t s2) {
-    return static_cast<TLinearFitter*>(fFitterArray6[s1*72+s2]);
-  }
+  
+  void UpdateAlignSector(const AliTPCseed * seed,Int_t isec); 
+  inline Int_t GetIndex(Int_t s1,Int_t s2){return 72*s1+s2;}
+  //
+  inline const TMatrixD     * GetTransformation(Int_t s1,Int_t s2, Int_t fitType);
+  //
+  inline TLinearFitter* GetFitter12(Int_t s1,Int_t s2);
+  inline TLinearFitter* GetFitter9(Int_t s1,Int_t s2);
+  inline TLinearFitter* GetFitter6(Int_t s1,Int_t s2);
+  //
   Bool_t GetTransformation12(Int_t s1,Int_t s2,TMatrixD &a);
   Bool_t GetTransformation9(Int_t s1,Int_t s2,TMatrixD &a);
   Bool_t GetTransformation6(Int_t s1,Int_t s2,TMatrixD &a);
+  Int_t  AcceptTracklet(const AliExternalTrackParam &tp1,
+                       const AliExternalTrackParam &tp2);
+  Int_t  AcceptTracklet(const Double_t *t1,
+                       const Double_t *t2);
 
-  TObjArray fDphiHistArray;
-  TObjArray fDthetaHistArray;
-  TObjArray fDyHistArray;
-  TObjArray fDzHistArray;
+  void ProcessDiff(const AliExternalTrackParam &t1,
+                  const AliExternalTrackParam &t2,
+                  const AliTPCseed *seed,
+                  Int_t s1,Int_t s2);
+  void ProcessAlign(Double_t * t1, Double_t * t2, Int_t s1,Int_t s2);
 
-private:
-  void Process12(Double_t *t1,
-                Double_t *t2,
+//   Bool_t GetTransformationCovar12(Int_t s1,Int_t s2,TMatrixD &a, Bool_t norm=kFALSE);
+//   Bool_t GetTransformationCovar9(Int_t s1,Int_t s2,TMatrixD &a, Bool_t norm=kFALSE);
+//   Bool_t GetTransformationCovar6(Int_t s1,Int_t s2,TMatrixD &a, Bool_t norm=kFALSE);
+  void Add(AliTPCcalibAlign * align);
+  Int_t *GetPoints() {return fPoints;}
+  void     Process(AliESDtrack *track, Int_t runNo=-1){AliTPCcalibBase::Process(track,runNo);};
+  TLinearFitter* GetOrMakeFitter12(Int_t s1,Int_t s2);
+  TLinearFitter* GetOrMakeFitter9(Int_t s1,Int_t s2);
+  TLinearFitter* GetOrMakeFitter6(Int_t s1,Int_t s2);
+  void Process12(const Double_t *t1, const Double_t *t2,
                 TLinearFitter *fitter);
-  void Process9(Double_t *t1,
-               Double_t *t2,
-               TLinearFitter *fitter);
-  void Process6(Double_t *t1,
-               Double_t *t2,
-               TLinearFitter *fitter);
-  TLinearFitter* GetOrMakeFitter12(Int_t s1,Int_t s2) {
-    //get or make fitter
-    if (!fFitterArray12[s1*72+s2])
-      fFitterArray12[s1*72+s2]=new TLinearFitter(12,"x0++x1++x2++x3++x4++x5++x6++x7++x8++x9++x10++x11");
-    return GetFitter12(s1,s2);
-  }
-  TLinearFitter* GetOrMakeFitter9(Int_t s1,Int_t s2) {
-    //get or make fitter
-    if (!fFitterArray9[s1*72+s2])
-      fFitterArray9[s1*72+s2]=new TLinearFitter(9,"x0++x1++x2++x3++x4++x5++x6++x7++x8");
-    return GetFitter9(s1,s2);
-  }
-  TLinearFitter* GetOrMakeFitter6(Int_t s1,Int_t s2) {
-    //get or make fitter
-    if (!fFitterArray6[s1*72+s2])
-      fFitterArray6[s1*72+s2]=new TLinearFitter(6,"x0++x1++x2++x3++x4++x5");
-    return GetFitter6(s1,s2);
-  }
-  TObjArray fFitterArray12;
-  TObjArray fFitterArray9;
-  TObjArray fFitterArray6;
-  Int_t fPoints[72*72];
-
-  ClassDef(AliTPCcalibAlign,1)
+  void Process9(Double_t *t1, Double_t *t2, TLinearFitter *fitter);
+  void Process6(Double_t *t1, Double_t *t2, TLinearFitter *fitter);
+  void ProcessTree(TTree * tree, AliExternalComparison *comp=0);
+  void GlobalAlign6(Int_t minPoints, Float_t sysError, Int_t niter);
+  //
+  // Cluster comparison Part
+  //
+  //
+  // For visualization and test purposes
+  //
+  Double_t Correct(Int_t type, Int_t value, Int_t s1, Int_t s2, Double_t x, Double_t y, Double_t z, Double_t phi,Double_t theta); 
+  static Double_t SCorrect(Int_t type, Int_t value, Int_t s1, Int_t s2, Double_t x, Double_t y, Double_t z, Double_t phi,Double_t theta){return Instance()->Correct(type,value,s1,s2,x,y,z,phi,theta);}
+  static AliTPCcalibAlign* Instance();
+  void SetInstance(AliTPCcalibAlign*param){fgInstance = param;}
+  static void Constrain1Pt(AliExternalTrackParam &t1, const AliExternalTrackParam &t2, Bool_t noField);
+  void SetNoField(Bool_t noField){ fNoField=noField;}
+
+  //
+  // Kalman fileter for sectors
+  //
+  void MakeSectorKalman();
+  void UpdateSectorKalman(Int_t sector, Int_t quadrant0, Int_t quadrant1,  TMatrixD *p0, TMatrixD *c0, TMatrixD *p1, TMatrixD *c1);
+  void UpdateSectorKalman(TMatrixD &par0, TMatrixD &cov0, TMatrixD &para1, TMatrixD &cov1);
+  Double_t GetCorrectionSector(Int_t coord, Int_t sector, Double_t lx, Double_t ly, Double_t lz); 
+  static Double_t SGetCorrectionSector(Int_t coord, Int_t sector, Double_t lx, Double_t ly, Double_t lz); 
+
+  //
+  // Kalman filter for full TPC
+  //
+  void MakeKalman();
+  void UpdateKalman(Int_t sector0, Int_t sector1,  TMatrixD &p0, TMatrixD &c0, TMatrixD &p1, TMatrixD &c1);
+  void UpdateKalman(TMatrixD &par0, TMatrixD &cov0, TMatrixD &para1, TMatrixD &cov1);
+  //
+  //private:
+  static Int_t CheckCovariance(TMatrixD &covar);
+public:
+  
+  void FillHisto(const Double_t *t1,
+                const Double_t *t2,
+                Int_t s1,Int_t s2);
+
+  TObjArray fDphiHistArray;    // array of residual histograms  phi      -kPhi
+  TObjArray fDthetaHistArray;  // array of residual histograms  theta    -kTheta
+  TObjArray fDyHistArray;      // array of residual histograms  y        -kY
+  TObjArray fDzHistArray;      // array of residual histograms  z        -kZ
+  //
+  TObjArray fDyPhiHistArray;      // array of residual histograms  y     -kYPhi
+  TObjArray fDzThetaHistArray;    // array of residual histograms  z-z   -kZTheta
+  //
+  TObjArray fDphiZHistArray;      // array of residual histograms  phi   -kPhiz
+  TObjArray fDthetaZHistArray;    // array of residual histograms  theta -kThetaz
+  TObjArray fDyZHistArray;        // array of residual histograms  y     -kYz
+  TObjArray fDzZHistArray;        // array of residual histograms  z     -kZz
+  //
+  //
+  TObjArray fFitterArray12;    // array of fitters
+  TObjArray fFitterArray9;     // array of fitters
+  TObjArray fFitterArray6;     // array of fitters
+  //
+  TObjArray fMatrixArray12;    // array of transnformtation matrix
+  TObjArray fMatrixArray9;     // array of transnformtation matrix
+  TObjArray fMatrixArray6;     // array of transnformtation matrix 
+  //
+  //
+  TObjArray fCombinedMatrixArray6;      // array  combeined transformation matrix
+  //
+  AliExternalComparison  *fCompTracklet;  //tracklet comparison
+  //
+  Int_t fPoints[72*72];        // number of points in the fitter 
+  Bool_t fNoField;             // flag - no field data
+  // refernce x
+  Double_t fXIO;               // OROC-IROC boundary
+  Double_t fXmiddle;           // center of the TPC sector local X
+  Double_t fXquadrant;         // x quadrant
+  //
+  // Kalman filter for sector internal  alignemnt
+  //
+  TObjArray fArraySectorIntParam; // array of sector alignment parameters
+  TObjArray fArraySectorIntCovar; // array of sector alignment covariances 
+  //
+  // Kalman filter for global alignment
+  //
+  TMatrixD  *fSectorParamA;     // Kalman parameter   for A side
+  TMatrixD  *fSectorCovarA;     // Kalman covariance  for A side 
+  TMatrixD  *fSectorParamC;     // Kalman parameter   for A side
+  TMatrixD  *fSectorCovarC;     // Kalman covariance  for A side 
+  //
+  //
+  //
+  Bool_t    fUseInnerOuter;         // flag- use Inner Outer sector for left righ alignment
+  
+  static AliTPCcalibAlign*   fgInstance; //! Instance of this class (singleton implementation)
+private:
+  AliTPCcalibAlign&  operator=(const AliTPCcalibAlign&);// not implemented
+
+  ClassDef(AliTPCcalibAlign,3)
 };
 
+
+TLinearFitter* AliTPCcalibAlign::GetFitter12(Int_t s1,Int_t s2) {
+  return static_cast<TLinearFitter*>(fFitterArray12[GetIndex(s1,s2)]);
+}
+TLinearFitter* AliTPCcalibAlign::GetFitter9(Int_t s1,Int_t s2) {
+  return static_cast<TLinearFitter*>(fFitterArray9[GetIndex(s1,s2)]);
+}
+TLinearFitter* AliTPCcalibAlign::GetFitter6(Int_t s1,Int_t s2) {
+  return static_cast<TLinearFitter*>(fFitterArray6[GetIndex(s1,s2)]);
+}
+
+const TMatrixD * AliTPCcalibAlign::GetTransformation(Int_t s1,Int_t s2, Int_t fitType){
+  if (fitType==0) return static_cast<TMatrixD*>(fMatrixArray6[GetIndex(s1,s2)]);
+  if (fitType==1) return static_cast<TMatrixD*>(fMatrixArray9[GetIndex(s1,s2)]);
+  if (fitType==2) return static_cast<TMatrixD*>(fMatrixArray12[GetIndex(s1,s2)]);
+  return 0;
+}
+
+
+
 #endif