fQ(1.e-15),
fPMeasurement(new TVectorD( fgkNMeasurementParams )),
fPMeasurementCov(new TMatrixDSym( fgkNMeasurementParams )),
+ fPMeasurementPrediction(new TVectorD( fgkNMeasurementParams )),
fOutRejSigmas(1.),
fDelta(new Double_t[fgkNSystemParams]),
fNumericalParanoia(kTRUE),
fNMatchedTPCtracklets(0),
fNProcessedEvents(0),
fTrackInBuffer(0),
+ fTimeStamp(0),
fTPCvd(2.64),
fTPCZLengthA(2.4972500e02),
fTPCZLengthC(2.4969799e02)
fQ(a.fQ),
fPMeasurement(new TVectorD( *a.fPMeasurement )),
fPMeasurementCov(new TMatrixDSym( *a.fPMeasurementCov )),
+ fPMeasurementPrediction(new TVectorD( *a.fPMeasurement )),
fOutRejSigmas(a.fOutRejSigmas),
fDelta(new Double_t[fgkNSystemParams]),
fNumericalParanoia(a.fNumericalParanoia),
fNMatchedTPCtracklets(a.fNMatchedTPCtracklets),
fNProcessedEvents(a.fNProcessedEvents),
fTrackInBuffer(a.fTrackInBuffer),
+ fTimeStamp(a.fTimeStamp),
fTPCvd(a.fTPCvd),
fTPCZLengthA(a.fTPCZLengthA),
fTPCZLengthC(a.fTPCZLengthC)
fNMatchedTPCtracklets=a.fNMatchedTPCtracklets;
fNProcessedEvents=a.fNProcessedEvents;
fTrackInBuffer=a.fTrackInBuffer;
+ fTimeStamp=a.fTimeStamp;
//fApplyCovarianceCorrection=a.fApplyCovarianceCorrection;
//fCalibrationMode=a.fCalibrationMode;
//fFillHistograms=a.fFillHistograms;
success = ( AddESDtrack( track ) || success );
}
}
+ if (success) fTimeStamp = pEvent->GetTimeStamp();
return success;
}
//______________________________________________________________________________
Bool_t AliRelAlignerKalman::AddESDtrack( const AliESDtrack* pTrack )
{
- ////Adds a full track, returns true if results in a new estimate
-
- //const AliExternalTrackParam* pconstparamsITS = pTrack->GetOuterParam();
- //if (!pconstparamsITS) return kFALSE;
- //const AliExternalTrackParam* pconstparamsTPC = pTrack->GetInnerParam();
- //if (!pconstparamsTPC) return kFALSE;
- //
- ////TPC part
- //AliExternalTrackParam paramsTPC = (*pconstparamsTPC);
- //paramsTPC.Rotate(pconstparamsITS->GetAlpha());
- //paramsTPC.PropagateTo(pconstparamsITS->GetX(), pconstparamsITS->GetAlpha());
-
- //if (!SetTrackParams( pconstparamsITS, ¶msTPC )) return kFALSE;
- //
- ////do some accounting and update
- //return (Update());
-
- const AliESDtrack* p;
- p=pTrack; //shuts up the compiler
+ //Adds a full track, returns true if results in a new estimate
+ // gets the inner TPC parameters from AliESDTrack::GetInnerParam()
+ // gets the outer ITS parameters from AliESDTrack::GetOuterParam()
+
+ const AliExternalTrackParam* pconstparamsITS = pTrack->GetOuterParam();
+ if (!pconstparamsITS) return kFALSE;
+ const AliExternalTrackParam* pconstparamsTPC = pTrack->GetInnerParam();
+ if (!pconstparamsTPC) return kFALSE;
- return kFALSE;
+ //TPC part
+ AliExternalTrackParam paramsTPC = (*pconstparamsTPC);
+ paramsTPC.Rotate(pconstparamsITS->GetAlpha());
+ paramsTPC.PropagateTo(pconstparamsITS->GetX(), fMagField);
+
+ return (AddTrackParams(pconstparamsITS, ¶msTPC));
}
//______________________________________________________________________________
if (!pconstparams2) continue;
params2 = *pconstparams2; //make copy
params2.Rotate(params1.GetAlpha());
- params2.PropagateTo( params1.GetX(), params1.GetAlpha() );
+ params2.PropagateTo( params1.GetX(), fMagField );
if (!SetTrackParams( ¶ms1, ¶ms2 )) continue;
else
continue;
}
+ if (success) fTimeStamp=pEvent->GetTimeStamp();
return success;
}
//else return UpdateEstimateKalman();
if (!PrepareMeasurement()) return kFALSE;
if (!PrepareSystemMatrix()) return kFALSE;
+ if (!PreparePrediction()) return kFALSE;
return UpdateEstimateKalman();
}
return kTRUE;
}
+//______________________________________________________________________________
+Bool_t AliRelAlignerKalman::PreparePrediction()
+{
+ //Prepare the prediction of the measurement using state vector
+ return PredictMeasurement( (*fPMeasurementPrediction), (*fPX) );
+}
+
//______________________________________________________________________________
Bool_t AliRelAlignerKalman::PredictMeasurement( TVectorD& pred, const TVectorD& state )
{
// update the state and its covariance matrix
TVectorD xupdate(fgkNSystemParams);
- TVectorD hx(fgkNMeasurementParams);
- PredictMeasurement( hx, (*fPX) );
- xupdate = k*((*fPMeasurement)-hx);
+ xupdate = k*((*fPMeasurement)-(*fPMeasurementPrediction));
//SIMPLE OUTLIER REJECTION
if ( IsOutlier( xupdate, (*fPXcov) ) && fRejectOutliers )
{
if (fgkNSystemParams>6) (*fPXcov)(6,6) = .1*.1;
if (fgkNSystemParams>7) (*fPXcov)(7,7) = 1.*1.;
- if (fgkNSystemParams>8) (*fPXcov)(8,8) = 1.*1.;
+ if (fgkNSystemParams>8) (*fPXcov)(8,8) = .1*.1;
}
else
{
}
}
+Bool_t AliRelAlignerKalman::Merge( const AliRelAlignerKalman* al )
+{
+ //Merge two aligners
+
+ if (!al) return kFALSE;
+ if (al->fgkNSystemParams != fgkNSystemParams) return kFALSE;
+
+ //store the pointers to current stuff
+ TVectorD* pmes = fPMeasurement;
+ TMatrixDSym* pmescov = fPMeasurementCov;
+ TVectorD* pmespred = fPMeasurementPrediction;
+ TMatrixD* ph = fPH;
+
+ //make a unity system matrix
+ TMatrixD tmp(fgkNSystemParams,fgkNSystemParams);
+ fPH = new TMatrixD(TMatrixD::kUnit, tmp);
+
+ //mesurement is the state of the new aligner
+ fPMeasurement = al->fPX;
+ fPMeasurementCov = al->fPXcov;
+
+ //the mesurement prediction is the state
+ fPMeasurementPrediction = fPX; //this is safe as fPX doesn't change until end
+
+ //do the merging
+ Bool_t success = UpdateEstimateKalman();
+
+ //restore pointers to old stuff
+ fPMeasurement = pmes;
+ fPMeasurementCov = pmescov;
+ fPMeasurementPrediction = pmespred;
+ delete fPH;
+ fPH = ph;
+
+ //merge stats
+ fNProcessedEvents += al->fNProcessedEvents;
+ fNUpdates += al->fNUpdates;
+ fNOutliers += al->fNOutliers;
+ fNTracks += al->fNTracks;
+ fNMatchedTPCtracklets += al->fNMatchedTPCtracklets;
+ fNMatchedCosmics += al->fNMatchedCosmics;
+ if (fTimeStamp < al->fTimeStamp) fTimeStamp = al->fTimeStamp; //a bit arbitrary: take the older one
+
+ return success;
+}
+
//______________________________________________________________________________
//void AliRelAlignerKalman::PrintCovarianceCorrection()
//{
TMatrixDSym* GetStateCov() const { return fPXcov; }
void GetSeed( TVectorD& seed, TMatrixDSym& seedCov ) const { seed = *fPX; seedCov = *fPXcov; }
void SetSeed( const TVectorD& seed, const TMatrixDSym& seedCov ) {*fPX = seed; *fPXcov = seedCov; }
+ Bool_t Merge( const AliRelAlignerKalman* al );
//Expert methods:
Bool_t AddESDevent( const AliESDEvent* pEvent );
static void RotMat( TMatrixD& R, const TVectorD& angles );
static void TMatrixDSymFromTMatrixD( TMatrixDSym& matsym, const TMatrixD& mat );
Bool_t IsPositiveDefinite( const TMatrixD& mat ) const;
+ void SetTimeStamp( const UInt_t ts ) { fTimeStamp = ts; }
+ UInt_t GetTimeStamp() const {return fTimeStamp;}
protected:
Bool_t UpdateEstimateKalman();
Bool_t PrepareMeasurement();
Bool_t PrepareSystemMatrix();
+ Bool_t PreparePrediction();
Bool_t PredictMeasurement( TVectorD& z, const TVectorD& x );
Bool_t IsOutlier( const TVectorD& update, const TMatrixDSym& covmatrix );
Double_t fLocalX; //!local x coordinate of reference plane = r(global)
AliExternalTrackParam* fPTrackParamArr1; //!local track parameters
AliExternalTrackParam* fPTrackParamArr2; //!local track parameters
- Double_t fMagField; //magnetic field
+ Double_t fMagField; //!magnetic field
//Kalman filter related stuff
TVectorD* fPX; //System (fit) parameters (phi, theta, psi, x, y, z, driftcorr, driftoffset )
Double_t fQ; //!measure for system noise
TVectorD* fPMeasurement; //!the measurement vec for Kalman filter (theta,phi,x,z)
TMatrixDSym* fPMeasurementCov; //!measurement vec cvariance
+ TVectorD* fPMeasurementPrediction; //!prediction of the measurement
Double_t fOutRejSigmas; //number of sigmas for outlier rejection
Double_t* fDelta; //array with differentials for calculating derivatives for every parameter(see PrepareSystemMatrix())
//Control
- Bool_t fNumericalParanoia; //whether to perform additional checks for numerical stability
- Bool_t fRejectOutliers; //whether to do outlier rejection in the Kalman filter
- Bool_t fRequireMatchInTPC; //when looking for a cosmic in event, require that TPC has 2 matching segments
- Bool_t fCuts; //track cuts?
- Int_t fMinPointsVol1; //mininum number of points in volume 1
- Int_t fMinPointsVol2; //mininum number of points in volume 2
- Double_t fMinMom; //min momentum of track for track cuts
- Double_t fMaxMom; //max momentum of track for track cuts
- Double_t fMaxMatchingAngle; //cuts
- Double_t fMaxMatchingDistance; //cuts
+ Bool_t fNumericalParanoia; //!whether to perform additional checks for numerical stability
+ Bool_t fRejectOutliers; //!whether to do outlier rejection in the Kalman filter
+ Bool_t fRequireMatchInTPC; //!when looking for a cosmic in event, require that TPC has 2 matching segments
+ Bool_t fCuts; //!track cuts?
+ Int_t fMinPointsVol1; //!mininum number of points in volume 1
+ Int_t fMinPointsVol2; //!mininum number of points in volume 2
+ Double_t fMinMom; //!min momentum of track for track cuts
+ Double_t fMaxMom; //!max momentum of track for track cuts
+ Double_t fMaxMatchingAngle; //!cuts
+ Double_t fMaxMatchingDistance; //!cuts
Bool_t fCorrectionMode; //calculate corrective transform for TPC (or monitor actual TPC misal params)
//Counters
Int_t fNMatchedCosmics; //number of cosmic events with matching tracklets (good cosmics)
Int_t fNMatchedTPCtracklets;//number of cosmic events with 2 matching TPC tracklets
Int_t fNProcessedEvents; //number of processed events
- Int_t fTrackInBuffer; //number of tracks in buffer
+ Int_t fTrackInBuffer; //!number of tracks in buffer
+ UInt_t fTimeStamp;
//TPC stuff
Double_t fTPCvd; //TPC drift velocity