#include "hmdcsizescells.h" #include "hkaldafsinglewire.h" //_HADES_CLASS_DESCRIPTION /////////////////////////////////////////////////////////////////////////////// // // DAF for wire hits. Does not allow competition between hits. // See doc for HKalIFilter. //----------------------------------------------------------------------- /////////////////////////////////////////////////////////////////////////////// ClassImp (HKalDafSingleWire) // ----------------------------------- // Implementation of protected methods // ----------------------------------- Bool_t HKalDafSingleWire::calcEffMeasVec(Int_t iSite) const { // Effective measurement vector needed only in case of // competing hits. return kTRUE; } // ----------------------------------- // Ctors and Dtor // ----------------------------------- HKalDafSingleWire::HKalDafSingleWire(Int_t n, Int_t measDim, Int_t stateDim, HMdcTrackGField *fMap, Double_t fpol) : HKalFiltWire(n, measDim, stateDim, fMap, fpol) { const Int_t nDafs = 5; Double_t T[nDafs] = { 81., 9., 4., 1., 1. }; setDafPars(9., &T[0], nDafs); } // -------------------------------- // Implementation of public methods // -------------------------------- Bool_t HKalDafSingleWire::fitTrack(const TObjArray &hits, const TVectorD &iniSv, const TMatrixD &iniCovMat, Int_t pId) { // Runs the Kalman filter over a set of measurement hits. // Returns false if the Kalman filter encountered problems during // track fitting or the chi^2 is too high. // // Input: // hits: the array with the measurement hits. Elements must be of class // HKalMdcHit. // iniStateVec: initial track state that the filter will use. // iniCovMat: initial covariance matrix that the filter will use. // pId: Geant particle id. // momGeant: Geant momentum that will be written in the output tree. Ignore if this is not simulation data. #if dafDebug > 1 cout<<"******************************"< 1 cout<<"********************************************"< 1 cout<<"Running DAF for site "<getNcompetitors(); iHit++) { const TVectorD &measVec = site->getHitVec(iHit); TVectorD smooMeasVec(getMeasDim()); calcMeasVecFromState(smooMeasVec, site, Kalman::kSmoothed, Kalman::kSecCoord, iHit); #if dafDebug > 2 cout<<"Updating measurement "<getNcompetitors()<getErrMat(iHit); // Measurement error covariance V #if kalDebug > 0 if(errMat.NonZeros() == 0) { Error("fitWithDaf()", Form("Measurement error matrix of hit %i is not set.", iHit)); } #endif TMatrixD invErrMat = TMatrixD(TMatrixD::kInverted, errMat); // G = V^-1 // Normalization of hit's chi2 distribution: 1 / ((2*pi)^n/2 * sqrt(T * det(V))) Double_t normChi2 = 1. / (TMath::Power(2.*TMath::Pi(), (Double_t)getMeasDim()/2.) * TMath::Sqrt(dafT[iDaf] * errMat.Determinant())); // Standardized distance between smoothed track state and measurement vector: // chi2 = r^T * (V_k)^-1 * r Double_t chi2 = (residualTrans * invErrMat * residual)(0); #if dafDebug > 2 cout<<"Error matrix: "<setHitChi2(chi2, iHit); // Normalization for hit's weight recalculation: // sum( normchi2 * exp(-chi2/(2T)) + normchi2 * exp(-chi2cut/(2T)) weightNorm += normChi2 * TMath::Exp(- chi2 / (2. * dafT[iDaf])); weightNorm += normChi2 * TMath::Exp(- dafChi2Cut / (2. * dafT[iDaf])); } // Recalculate weight of each hit. for(Int_t iHit = 0; iHit < site->getNcompetitors(); iHit++) { const TMatrixD &errMat = site->getErrMat(iHit); // New weight of hit. // 1 / ((2*pi)^n/2 * sqrt(T * det(V))) * exp(-chi2/(2T)) / weightNorm Double_t normChi2 = 1. / (TMath::Power(2.*TMath::Pi(), (Double_t)getMeasDim()/2.) * TMath::Sqrt(dafT[iDaf] * errMat.Determinant())); Double_t hitWeight = normChi2 * TMath::Exp(-site->getHitChi2(iHit) / (2. * dafT[iDaf])) / weightNorm; if(iHit > maxHitsPerSite - 1) { if(getPrintErr()) { Error("fitTrack()", Form("Site %i has more than %i competing hits.", iSite, maxHitsPerSite)); } break; } // weights[iSite][iHit][iDaf] = hitWeight; //unused #if dafDebug > 2 cout<<"Updating weight of hit "<getNcompetitors() <<": old weight "<getHitWeight(iHit)<<", new weight "<setHitWeight(hitWeight, iHit); site->setHitWeightHist(hitWeight, iDaf, iHit); } } } #if dafDebug > 1 cout<<"**** Finished with Deterministic Annealing Filter ****"< 1 if(bTrackAccepted) { cout<<"**** Fitted track ****"<setNdafs(n); } }