AliRoot Core  edcc906 (edcc906)
AliRelAlignerKalman.h
Go to the documentation of this file.
1 #ifndef ALIRELALIGNERKALMAN_H
2 #define ALIRELALIGNERKALMAN_H
3 
4 /* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
5  * See cxx source for full Copyright notice */
6 
8 //
9 // Relative alignment of two tracking volumes (default ITS and TPC)
10 // (see AliRelAlignerKalman.cxx for details)
11 //
12 // Origin: Mikolaj Krzewicki, Nikhef, Mikolaj.Krzewicki@cern.ch
13 //
15 
16 #include <TMath.h>
17 #include <TVectorD.h>
18 #include <TMatrix.h>
19 
20 class TObject;
22 class AliESDEvent;
23 class AliESDtrack;
24 class TArrayI;
25 class TObjArray;
26 
27 class AliRelAlignerKalman : public TObject {
28 
29 public:
31  AliRelAlignerKalman(const char* name);
32  virtual ~AliRelAlignerKalman();
35 
36  //User methods:
37  Bool_t AddCosmicEvent( const AliESDEvent* pEvent );
38  Bool_t AddTrackParams( const AliExternalTrackParam* p1, const AliExternalTrackParam* p2 );
39 
40  void Print(Option_t* option="") const;
41 
42  Double_t GetPsi() const {return (*fPX)(0);}
43  Double_t GetTheta() const {return (*fPX)(1);}
44  Double_t GetPhi() const {return (*fPX)(2);}
45  Double_t GetX() const {return (*fPX)(3);}
46  Double_t GetY() const {return (*fPX)(4);}
47  Double_t GetZ() const {return (*fPX)(5);}
48  Double_t GetTPCvdCorr() const {return (*fPX)(6);}
49  Double_t GetTPCt0() const {return (*fPX)(7);}
50  Double_t GetTPCvdY() const {if (fgkNSystemParams>8) return (*fPX)(8); else return 0.0;}
51  Double_t GetPsiErr() const {return TMath::Sqrt((*fPXcov)(0,0));}
52  Double_t GetThetaErr() const {return TMath::Sqrt((*fPXcov)(1,1));}
53  Double_t GetPhiErr() const {return TMath::Sqrt((*fPXcov)(2,2));}
54  Double_t GetXErr() const {return TMath::Sqrt((*fPXcov)(3,3));}
55  Double_t GetYErr() const {return TMath::Sqrt((*fPXcov)(4,4));}
56  Double_t GetZErr() const {return TMath::Sqrt((*fPXcov)(5,5));}
57  Double_t GetTPCvdCorrErr() const {return TMath::Sqrt((*fPXcov)(6,6));}
58  Double_t GetTPCt0Err() const {return TMath::Sqrt((*fPXcov)(7,7));}
59  Double_t GetTPCvdYErr() const {if (fgkNSystemParams>8) return TMath::Sqrt((*fPXcov)(8,8)); else return 0.0;}
60  void GetMeasurement( TVectorD& mes ) const { mes = *fPMeasurement; }
62  void GetMeasurementCov( TMatrixDSym& cov ) const { cov = *fPMeasurementCov; }
63  void SetMeasurement( const TVectorD& mes ) {*fPMeasurement = mes;}
64  void SetMeasurementCov( const TMatrixDSym& cov ) {*fPMeasurementCov = cov;}
65  TMatrixDSym* GetMeasurementCov() const { return fPMeasurementCov; }
66  void GetState( TVectorD& state ) const { state = *fPX; }
67  TVectorD* GetState() const { return fPX; }
68  void GetStateCov ( TMatrixDSym& cov ) const { cov = *fPXcov; }
69  void SetState( const TVectorD& param ) {*fPX = param;}
70  void SetStateCov (const TMatrixDSym& cov ) {*fPXcov = cov;}
71  TMatrixDSym* GetStateCov() const { return fPXcov; }
72  void GetSeed( TVectorD& seed, TMatrixDSym& seedCov ) const { seed = *fPX; seedCov = *fPXcov; }
73  void SetSeed( const TVectorD& seed, const TMatrixDSym& seedCov ) {*fPX = seed; *fPXcov = seedCov; }
74  Bool_t Merge( const AliRelAlignerKalman* al );
75  Long64_t Merge( TCollection* list );
76 
77  //Expert methods:
78  Bool_t AddESDevent( const AliESDEvent* pEvent );
79  Bool_t AddESDtrack( const AliESDtrack* pTrack );
80  void SetMagField( const Double_t f ) { fMagField=f; }
81  Double_t GetMagField() const { return fMagField; }
82  Bool_t FindCosmicTrackletNumbersInEvent( TArrayI& outITStracksTArr, TArrayI& outTPCtracksTArr, const AliESDEvent* pEvent );
83  Int_t FindMatchingTracks(TObjArray& arrITS, TObjArray& arrTPC, AliESDEvent* pESD);
84  Bool_t Update();
86  //void PrintCovarianceCorrection();
87  void PrintSystemMatrix();
88  Int_t CheckCovariance(); // check covariance matrix
89  void Reset();
90  void ResetCovariance( const Double_t number=0. );
91  void ResetTPCparamsCovariance( const Double_t number=0. );
92  Double_t* GetStateArr() const { return fPX->GetMatrixArray(); }
93  Double_t* GetStateCovArr() const { return fPXcov->GetMatrixArray(); }
94  Double_t* GetMeasurementArr() const { return fPMeasurement->GetMatrixArray(); }
95  Double_t* GetMeasurementCovArr() const { return fPMeasurementCov->GetMatrixArray(); }
96  TMatrixD* GetH() const { return fPH; }
98  const Double_t* GetDeltaArr() const {return fDelta;}
99  void SetNumericalParanoia( const Bool_t mode=kFALSE ) { fNumericalParanoia=mode; }
100  void SetCorrectionMode( const Bool_t mode=kTRUE ) { fCorrectionMode=mode; }
101  void SetOutRejSigma( const Double_t a=2. ) { fOutRejSigmas = a; }
102  void SetRejectOutliers( const Bool_t r=kTRUE ) {fRejectOutliers = r;}
103  void SetRejectOutliersSigma2Median( const Bool_t b=kTRUE );
104  void SetOutRejSigma2Median( const Double_t s ) {fOutRejSigma2Median = s;}
105  Bool_t SetTrackParams( const AliExternalTrackParam* exparam1, const AliExternalTrackParam* exparam2 );
108  void SetMinPointsVol1( const Int_t min ) {fMinPointsVol1=min;}
109  void SetMinPointsVol2( const Int_t min ) {fMinPointsVol2=min;}
110  void SetRequireMatchInTPC( const Bool_t s=kTRUE ) {fRequireMatchInTPC = s;}
111  void SetQ( const Double_t Q = 1e-10 ) { fQ = Q; }
112  void SetMaxMatchingDistance( const Double_t m ) {fMaxMatchingDistance=m;}
113  void SetMaxMatchingAngle( const Double_t m ) {fMaxMatchingAngle=m;}
114  void SetTPCvd( const Float_t v ) {fTPCvd=v;}
115  void SetTPCZLengthA( const Double_t l ) {fTPCZLengthA=l;}
116  void SetTPCZLengthC( const Double_t l ) {fTPCZLengthC=l;}
117  Bool_t CorrectTrack( AliExternalTrackParam* tr, const TVectorD& misalignment ) const;
118  Bool_t MisalignTrack( AliExternalTrackParam* tr, const TVectorD& misalignment ) const;
119  static void Angles( TVectorD &angles, const TMatrixD &rotmat );
120  static void RotMat( TMatrixD& R, const TVectorD& angles );
121  static void TMatrixDSymFromTMatrixD( TMatrixDSym& matsym, const TMatrixD& mat );
122  Bool_t IsPositiveDefinite( const TMatrixD& mat ) const;
123  void SetTimeStamp( const UInt_t ts ) { fTimeStamp = ts; }
124  UInt_t GetTimeStamp() const {return fTimeStamp;}
125  void SetRunNumber( const Int_t rn ) { fRunNumber = rn; }
126  Int_t GetRunNumber() const {return fRunNumber;}
127  Int_t Compare(const TObject *obj) const;
128  Bool_t IsSortable() const { return kTRUE; }
129  Int_t GetNTracks() const {return fNTracks;}
130  Int_t GetNUpdates() const {return fNUpdates;}
131  Int_t GetNOutliers() const {return fNOutliers;}
133  Int_t GetNMerges() const {return fNMerges;}
134  Int_t GetNMergesFailed() const {return fNMergesFailed;}
135  void SetPoint2Track( Bool_t o );
136 
137 protected:
138  Bool_t UpdateEstimateKalman();
139  Bool_t PrepareMeasurement();
140  Bool_t PrepareSystemMatrix();
141  Bool_t PreparePrediction();
142  Bool_t PredictMeasurement( TVectorD& z, const TVectorD& x );
143  Bool_t IsOutlier( const TVectorD& update, const TMatrixDSym& covmatrix );
144  Bool_t IsOutlierSigma2Median( const AliExternalTrackParam* pITS, const AliExternalTrackParam* pTPC );
145 
146 private:
147  static const Int_t fgkNSystemParams=9; //how many fit parameters
148  static const Int_t fgkNtracksSigma2Median=500; //how many sets for median and rms
149 
150  //Track parameters
153  Double_t fMagField; //magnetic field
154 
155  //Kalman filter related stuff
156  Int_t fNMeasurementParams; //how many measurables
157  TVectorD* fPX; //System (fit) parameters (phi, theta, psi, x, y, z, driftcorr, driftoffset )
158  TMatrixDSym* fPXcov; //covariance matrix of system parameters
160  Double_t fQ;
162  TMatrixDSym* fPMeasurementCov;
164  Double_t fOutRejSigmas; //number of sigmas for outlier rejection
165  Double_t fOutRejSigma2Median; //nsigmas to median of input residual distribution
166  Double_t fDelta[fgkNSystemParams]; //array with differentials for calculating derivatives for every parameter(see PrepareSystemMatrix())
167  Double_t* fResArrSigma2Median[4];
168 
169  //Control
170  Bool_t fYZOnly; //whether to consider only yz without directions.
171  Bool_t fNumericalParanoia; //whether to perform additional checks for numerical stability
172  Bool_t fRejectOutliers; //whether to do outlier rejection in the Kalman filter
173  Bool_t fRejectOutliersSigma2Median; //whether to reject input based on distance to median
174  Bool_t fRequireMatchInTPC; //when looking for a cosmic in event, require that TPC has 2 matching segments
175  Bool_t fCuts; //track cuts?
176  Int_t fMinPointsVol1; //mininum number of points in volume 1
177  Int_t fMinPointsVol2; //mininum number of points in volume 2
178  Double_t fMinPt; //min momentum of track for track cuts
179  Double_t fMaxPt; //max momentum of track for track cuts
180  Double_t fMaxMatchingAngle; //cuts
181  Double_t fMaxMatchingDistance; //cuts
182  Bool_t fCorrectionMode; //calculate corrective transform for TPC (or monitor actual TPC misal params)
183 
184  //Counters
185  Int_t fNTracks; //number of processed tracks
186  Int_t fNUpdates; //number of successful Kalman updates
187  Int_t fNOutliers; //number of outliers
188  Int_t fNOutliersSigma2Median; //number of rejected inputs
189  Int_t fNMatchedCosmics; //number of cosmic events with matching tracklets (good cosmics)
190  Int_t fNMatchedTPCtracklets;//number of cosmic events with 2 matching TPC tracklets
191  Int_t fNProcessedEvents; //number of processed events
192  UInt_t fTimeStamp; //time stamp
193  Int_t fRunNumber; //run number
194  Int_t fNMerges; //how many succesful merges
195  Int_t fNMergesFailed; //how many merges failed
196 
197  //TPC stuff
198  Double_t fTPCvd; //TPC drift velocity
199  Double_t fTPCZLengthA; //TPC length side A
200  Double_t fTPCZLengthC; //TPC length side C
201 
202  ClassDef(AliRelAlignerKalman,4) //AliRelAlignerKalman class
203 };
204 
205 #endif
206 
207 
AliRelAlignerKalman & operator=(const AliRelAlignerKalman &a)
TBrowser b
Definition: RunAnaESD.C:12
Double_t GetZErr() const
Int_t GetNOutliers() const
void ResetTPCparamsCovariance(const Double_t number=0.)
void SetTimeStamp(const UInt_t ts)
Double_t GetTPCt0Err() const
#define TObjArray
void SetTPCZLengthA(const Double_t l)
const AliExternalTrackParam * GetTrackParams1() const
Double_t * GetMeasurementArr() const
Double_t GetTheta() const
Bool_t PredictMeasurement(TVectorD &z, const TVectorD &x)
Bool_t AddESDevent(const AliESDEvent *pEvent)
Bool_t Merge(const AliRelAlignerKalman *al)
void SetRejectOutliersSigma2Median(const Bool_t b=kTRUE)
Int_t GetNOutliersSigma2Median() const
TMatrixDSym * fPMeasurementCov
the measurement vec for Kalman filter (theta,phi,x,z)
TMatrixD mat
Definition: AnalyzeLaser.C:9
Double_t GetXErr() const
Double_t GetY() const
Double_t fDelta[fgkNSystemParams]
void SetNumericalParanoia(const Bool_t mode=kFALSE)
Double_t GetTPCvdYErr() const
Bool_t FindCosmicTrackletNumbersInEvent(TArrayI &outITStracksTArr, TArrayI &outTPCtracksTArr, const AliESDEvent *pEvent)
Double_t GetPhi() const
void SetStateCov(const TMatrixDSym &cov)
void SetMeasurement(const TVectorD &mes)
TVectorD * GetMeasurementPrediction() const
const Double_t * GetDeltaArr() const
AliExternalTrackParam * fPTrackParam1
void SetRequireMatchInTPC(const Bool_t s=kTRUE)
void SetSeed(const TVectorD &seed, const TMatrixDSym &seedCov)
void SetMaxMatchingAngle(const Double_t m)
Bool_t AddESDtrack(const AliESDtrack *pTrack)
static const Int_t fgkNtracksSigma2Median
Bool_t SetTrackParams(const AliExternalTrackParam *exparam1, const AliExternalTrackParam *exparam2)
void SetTPCvd(const Float_t v)
void ResetCovariance(const Double_t number=0.)
Double_t GetYErr() const
Double_t fOutRejSigmas
prediction of the measurement
Bool_t MisalignTrack(AliExternalTrackParam *tr, const TVectorD &misalignment) const
Int_t GetNMergesFailed() const
void SetCorrectionMode(const Bool_t mode=kTRUE)
Double_t GetTPCvdCorrErr() const
void Print(Option_t *option="") const
void GetStateCov(TMatrixDSym &cov) const
Bool_t fYZOnly
holds residuals for median based outlier removal
static void TMatrixDSymFromTMatrixD(TMatrixDSym &matsym, const TMatrixD &mat)
Double_t GetZ() const
Double_t GetPsi() const
Double_t * GetStateCovArr() const
Double_t GetTPCt0() const
Int_t FindMatchingTracks(TObjArray &arrITS, TObjArray &arrTPC, AliESDEvent *pESD)
Bool_t IsPositiveDefinite(const TMatrixD &mat) const
void SetMeasurementCov(const TMatrixDSym &cov)
void SetQ(const Double_t Q=1e-10)
void SetRunNumber(const Int_t rn)
static const Int_t fgkNSystemParams
TMatrixD * GetH() const
Bool_t IsOutlierSigma2Median(const AliExternalTrackParam *pITS, const AliExternalTrackParam *pTPC)
Int_t GetRunNumber() const
void SetRejectOutliers(const Bool_t r=kTRUE)
TVectorD * GetState() const
void SetOutRejSigma2Median(const Double_t s)
TVectorD * fPMeasurementPrediction
measurement vec cvariance
TMatrixDSym * GetStateCov() const
void SetMinPointsVol1(const Int_t min)
TF1 * f
Definition: interpolTest.C:21
static UInt_t seed
Definition: pdc06_config.C:131
Double_t GetX() const
Bool_t AddTrackParams(const AliExternalTrackParam *p1, const AliExternalTrackParam *p2)
Double_t GetTPCvdCorr() const
static void Angles(TVectorD &angles, const TMatrixD &rotmat)
void GetMeasurementCov(TMatrixDSym &cov) const
void SetMinPointsVol2(const Int_t min)
TMatrixDSym * GetMeasurementCov() const
Double_t GetThetaErr() const
Double_t GetPhiErr() const
void GetMeasurement(TVectorD &mes) const
void SetTPCZLengthC(const Double_t l)
void GetSeed(TVectorD &seed, TMatrixDSym &seedCov) const
TVectorD * fPMeasurement
measure for system noise
void SetMagField(const Double_t f)
Double_t * GetMeasurementCovArr() const
Int_t Compare(const TObject *obj) const
AliExternalTrackParam * fPTrackParam2
local track parameters
Bool_t IsOutlier(const TVectorD &update, const TMatrixDSym &covmatrix)
Double_t fMagField
local track parameters
const AliExternalTrackParam * GetTrackParams2() const
void GetState(TVectorD &state) const
class TVectorT< Double_t > TVectorD
void SetOutRejSigma(const Double_t a=2.)
Double_t * GetStateArr() const
Bool_t IsSortable() const
Bool_t CorrectTrack(AliExternalTrackParam *tr, const TVectorD &misalignment) const
UInt_t GetTimeStamp() const
Double_t fQ
System measurement matrix.
Double_t GetPsiErr() const
void SetMaxMatchingDistance(const Double_t m)
Double_t * fResArrSigma2Median[4]
static void RotMat(TMatrixD &R, const TVectorD &angles)
Double_t GetTPCvdY() const
Double_t GetMagField() const
void SetState(const TVectorD &param)
class TMatrixT< Double_t > TMatrixD
Int_t GetNUpdates() const
Bool_t AddCosmicEvent(const AliESDEvent *pEvent)