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