1 #ifndef ALITPCCALIBALIGN_H
2 #define ALITPCCALIBALIGN_H
4 /* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
5 * See cxx source for full Copyright notice */
15 #include <TLinearFitter.h>
16 #include <TMatrixDfwd.h>
20 #include "AliTPCcalibBase.h"
21 class AliExternalTrackParam;
22 class AliTPCPointCorrection;
25 class AliTPCcalibAlign:public AliTPCcalibBase {
27 enum HistoType {kY=0, kZ =1, kPhi=2, kTheta=3,
29 kYz=6,kZz=7,kPhiZ=8,kThetaZ=9};
30 enum FitType{ k6=0, k9=1, k12=2};
32 AliTPCcalibAlign(const Text_t *name, const Text_t *title);
33 AliTPCcalibAlign(const AliTPCcalibAlign &align);
35 virtual ~AliTPCcalibAlign();
36 void Process(AliESDEvent *event);
37 virtual void ProcessSeed(AliTPCseed *track);
38 virtual void Process(AliTPCseed */*track*/){ return ;}
39 virtual void Analyze();
40 virtual void Terminate();
41 virtual Long64_t Merge(TCollection* const list);
42 void ExportTrackPoints(AliESDEvent *event);
45 void MakeReportDy(TFile *output);
46 void MakeReportDyPhi(TFile *output);
48 void UpdatePointCorrection(AliTPCPointCorrection * correction);
50 virtual void EvalFitters(Int_t minPoints=20);
51 TH1 * GetHisto(HistoType type, Int_t s1, Int_t s2, Bool_t force=kFALSE);
52 void MakeTree(const char *fname="alignTree.root", Int_t minPoints=20);
53 TGraphErrors * MakeGraph(Int_t sec0, Int_t sec1, Int_t dsec,
54 Int_t i0, Int_t i1, FitType type);
55 Int_t RefitLinear(const AliTPCseed * seed, Int_t isec, Double_t *fitParam, Int_t refSector, TMatrixD ¶m, TMatrixD&covar, Double_t xRef, Bool_t both=kFALSE);
57 void ProcessTracklets(const AliExternalTrackParam &t1,
58 const AliExternalTrackParam &t2,
59 const AliTPCseed * seed,
62 void UpdateClusterDeltaField(const AliTPCseed * seed);
63 void UpdateAlignSector(const AliTPCseed * seed,Int_t isec);
64 Int_t GetIndex(Int_t s1,Int_t s2) const {return 72*s1+s2;}
66 inline const TMatrixD * GetTransformation(Int_t s1,Int_t s2, Int_t fitType);
68 inline TLinearFitter* GetFitter12(Int_t s1,Int_t s2);
69 inline TLinearFitter* GetFitter9(Int_t s1,Int_t s2);
70 inline TLinearFitter* GetFitter6(Int_t s1,Int_t s2);
72 Bool_t GetTransformation12(Int_t s1,Int_t s2,TMatrixD &a);
73 Bool_t GetTransformation9(Int_t s1,Int_t s2,TMatrixD &a);
74 Bool_t GetTransformation6(Int_t s1,Int_t s2,TMatrixD &a);
75 Int_t AcceptTracklet(const AliExternalTrackParam &tp1,
76 const AliExternalTrackParam &tp2) const;
77 Int_t AcceptTracklet(const Double_t *t1,
78 const Double_t *t2) const;
80 void ProcessDiff(const AliExternalTrackParam &t1,
81 const AliExternalTrackParam &t2,
82 const AliTPCseed *seed,
84 void ProcessAlign(Double_t * t1, Double_t * t2, Int_t s1,Int_t s2);
86 // Bool_t GetTransformationCovar12(Int_t s1,Int_t s2,TMatrixD &a, Bool_t norm=kFALSE);
87 // Bool_t GetTransformationCovar9(Int_t s1,Int_t s2,TMatrixD &a, Bool_t norm=kFALSE);
88 // Bool_t GetTransformationCovar6(Int_t s1,Int_t s2,TMatrixD &a, Bool_t norm=kFALSE);
89 void Add(AliTPCcalibAlign * align);
90 const Int_t *GetPoints() const {return fPoints;}
91 void Process(AliESDtrack *const track, Int_t runNo=-1){AliTPCcalibBase::Process(track,runNo);};
92 TLinearFitter* GetOrMakeFitter12(Int_t s1,Int_t s2);
93 TLinearFitter* GetOrMakeFitter9(Int_t s1,Int_t s2);
94 TLinearFitter* GetOrMakeFitter6(Int_t s1,Int_t s2);
95 void Process12(const Double_t *t1, const Double_t *t2,
96 TLinearFitter *fitter) const;
97 void Process9(const Double_t *const t1, const Double_t *const t2, TLinearFitter *fitter) const;
98 void Process6(const Double_t *const t1, const Double_t *const t2, TLinearFitter *fitter) const;
99 void GlobalAlign6(Int_t minPoints, Float_t sysError, Int_t niter);
101 // Cluster comparison Part
104 // For visualization and test purposes
106 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);
107 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);}
108 static AliTPCcalibAlign* Instance();
109 void SetInstance(AliTPCcalibAlign* const param){fgInstance = param;}
110 static void Constrain1Pt(AliExternalTrackParam &t1, const AliExternalTrackParam &t2, Bool_t noField);
111 void SetNoField(Bool_t noField){ fNoField=noField;}
114 // Kalman fileter for sectors
116 void MakeSectorKalman();
117 void UpdateSectorKalman(Int_t sector, Int_t quadrant0, Int_t quadrant1, TMatrixD *const p0, TMatrixD *const c0, TMatrixD *const p1, TMatrixD *const c1);
118 void UpdateSectorKalman(TMatrixD &par0, TMatrixD &cov0, TMatrixD ¶1, TMatrixD &cov1);
119 Double_t GetCorrectionSector(Int_t coord, Int_t sector, Double_t lx, Double_t ly, Double_t lz);
120 static Double_t SGetCorrectionSector(Int_t coord, Int_t sector, Double_t lx, Double_t ly, Double_t lz);
123 // Kalman filter for full TPC
126 void UpdateKalman(Int_t sector0, Int_t sector1, TMatrixD &p0, TMatrixD &c0, TMatrixD &p1, TMatrixD &c1);
127 void UpdateKalman(TMatrixD &par0, TMatrixD &cov0, TMatrixD ¶1, TMatrixD &cov1);
130 static Int_t CheckCovariance(TMatrixD &covar);
133 void MakeResidualHistos();
134 void MakeResidualHistosTracklet();
135 THnSparse * GetClusterDelta(Int_t index) const { return fClusterDelta[index];}
136 THnSparse * GetTrackletDelta(Int_t index) const { return fTrackletDelta[index];}
139 void FillHisto(const Double_t *t1,
142 void FillHisto(AliExternalTrackParam *tp1,
143 AliExternalTrackParam *tp2,
147 THnSparse *fClusterDelta[2]; //clusters residuals
148 THnSparse *fTrackletDelta[4]; //track residuals
150 TObjArray fDphiHistArray; // array of residual histograms phi -kPhi
151 TObjArray fDthetaHistArray; // array of residual histograms theta -kTheta
152 TObjArray fDyHistArray; // array of residual histograms y -kY
153 TObjArray fDzHistArray; // array of residual histograms z -kZ
155 TObjArray fDyPhiHistArray; // array of residual histograms y -kYPhi
156 TObjArray fDzThetaHistArray; // array of residual histograms z-z -kZTheta
158 TObjArray fDphiZHistArray; // array of residual histograms phi -kPhiz
159 TObjArray fDthetaZHistArray; // array of residual histograms theta -kThetaz
160 TObjArray fDyZHistArray; // array of residual histograms y -kYz
161 TObjArray fDzZHistArray; // array of residual histograms z -kZz
164 TObjArray fFitterArray12; // array of fitters
165 TObjArray fFitterArray9; // array of fitters
166 TObjArray fFitterArray6; // array of fitters
168 TObjArray fMatrixArray12; // array of transnformtation matrix
169 TObjArray fMatrixArray9; // array of transnformtation matrix
170 TObjArray fMatrixArray6; // array of transnformtation matrix
175 TObjArray fCombinedMatrixArray6; // array combeined transformation matrix
178 Int_t fPoints[72*72]; // number of points in the fitter
179 Bool_t fNoField; // flag - no field data
181 Double_t fXIO; // OROC-IROC boundary
182 Double_t fXmiddle; // center of the TPC sector local X
183 Double_t fXquadrant; // x quadrant
185 // Kalman filter for sector internal alignemnt
187 TObjArray fArraySectorIntParam; // array of sector alignment parameters
188 TObjArray fArraySectorIntCovar; // array of sector alignment covariances
190 // Kalman filter for global alignment
192 TMatrixD *fSectorParamA; // Kalman parameter for A side
193 TMatrixD *fSectorCovarA; // Kalman covariance for A side
194 TMatrixD *fSectorParamC; // Kalman parameter for A side
195 TMatrixD *fSectorCovarC; // Kalman covariance for A side
199 Bool_t fUseInnerOuter; // flag- use Inner Outer sector for left righ alignment
201 static AliTPCcalibAlign* fgInstance; //! Instance of this class (singleton implementation)
203 AliTPCcalibAlign& operator=(const AliTPCcalibAlign&);// not implemented
205 ClassDef(AliTPCcalibAlign,6)
209 TLinearFitter* AliTPCcalibAlign::GetFitter12(Int_t s1,Int_t s2) {
210 return static_cast<TLinearFitter*>(fFitterArray12[GetIndex(s1,s2)]);
212 TLinearFitter* AliTPCcalibAlign::GetFitter9(Int_t s1,Int_t s2) {
213 return static_cast<TLinearFitter*>(fFitterArray9[GetIndex(s1,s2)]);
215 TLinearFitter* AliTPCcalibAlign::GetFitter6(Int_t s1,Int_t s2) {
216 return static_cast<TLinearFitter*>(fFitterArray6[GetIndex(s1,s2)]);
219 const TMatrixD * AliTPCcalibAlign::GetTransformation(Int_t s1,Int_t s2, Int_t fitType){
220 if (fitType==0) return static_cast<TMatrixD*>(fMatrixArray6[GetIndex(s1,s2)]);
221 if (fitType==1) return static_cast<TMatrixD*>(fMatrixArray9[GetIndex(s1,s2)]);
222 if (fitType==2) return static_cast<TMatrixD*>(fMatrixArray12[GetIndex(s1,s2)]);