diff --git a/DataFormats/Reconstruction/include/ReconstructionDataFormats/MatchInfoTOFReco.h b/DataFormats/Reconstruction/include/ReconstructionDataFormats/MatchInfoTOFReco.h index aa955ca81c1c6..5718019cb37b0 100644 --- a/DataFormats/Reconstruction/include/ReconstructionDataFormats/MatchInfoTOFReco.h +++ b/DataFormats/Reconstruction/include/ReconstructionDataFormats/MatchInfoTOFReco.h @@ -45,6 +45,11 @@ class MatchInfoTOFReco : public MatchInfoTOF float pt() const { return mPt; } void setPt(float pt) { mPt = pt; } + void setResX(float val) { mResX = val; } + void setResZ(float val) { mResZ = val; } + float getResX() const { return mResX; } + float getResZ() const { return mResZ; } + void setTrackType(TrackType value) { mTrackType = value; } TrackType getTrackType() const { return mTrackType; } @@ -52,7 +57,9 @@ class MatchInfoTOFReco : public MatchInfoTOF TrackType mTrackType; ///< track type (TPC, ITSTPC, TPCTRD, ITSTPCTRD) bool mFakeMC = false; float mPt = 0; - ClassDefNV(MatchInfoTOFReco, 4); + float mResX = 1; + float mResZ = 1; + ClassDefNV(MatchInfoTOFReco, 5); }; } // namespace dataformats } // namespace o2 diff --git a/Detectors/GlobalTracking/src/MatchTOF.cxx b/Detectors/GlobalTracking/src/MatchTOF.cxx index 099eb12d1f28f..3ee6209e76e09 100644 --- a/Detectors/GlobalTracking/src/MatchTOF.cxx +++ b/Detectors/GlobalTracking/src/MatchTOF.cxx @@ -1012,6 +1012,13 @@ void MatchTOF::doMatching(int sec) int eventIdTOF; int sourceIdTOF; for (auto iPropagation = 0; iPropagation < nStripsCrossedInPropagation; iPropagation++) { + float padResX2 = 0.52; // (2.5/sqrt(12))^2 + float padResZ2 = 1.02; // (3.5/sqrt(12))^2 + float cosangle = TMath::Cos(Geo::getAngles(indices[1], indices[2]) * TMath::DegToRad()); + float errXinv2 = 1. / (trefTrk.getSigmaY2() + padResX2); + float errZinv2 = 1. / (trefTrk.getSigmaZ2() * cosangle + padResZ2); // should be valid only at eta=0 + // look at getPadDxDyDz to understand how to convert track errors in TOF strip ref system (wip) + LOG(debug) << "TOF Cluster [" << itof << ", " << cacheTOF[itof] << "]: indices = " << indices[0] << ", " << indices[1] << ", " << indices[2] << ", " << indices[3] << ", " << indices[4]; LOG(debug) << "Propagated Track [" << itrk << "]: detId[" << iPropagation << "] = " << detId[iPropagation][0] << ", " << detId[iPropagation][1] << ", " << detId[iPropagation][2] << ", " << detId[iPropagation][3] << ", " << detId[iPropagation][4]; float resX = deltaPos[iPropagation][0] - (indices[4] - detId[iPropagation][4]) * Geo::XPAD + posCorr[0]; // readjusting the residuals due to the fact that the propagation fell in a pad that was not exactly the one of the cluster @@ -1028,7 +1035,7 @@ void MatchTOF::doMatching(int sec) if (indices[2] != detId[iPropagation][2]) { continue; } - float chi2 = res; // TODO: take into account also the time! + float chi2 = 0.5 * (resX * resX * errXinv2 + resZ * resZ * errZinv2); // TODO: take into account also the time! if (res < mSpaceTolerance) { // matching ok! LOG(debug) << "MATCHING FOUND: We have a match! between track " << mTracksSectIndexCache[type][sec][itrk] << " and TOF cluster " << mTOFClusSectIndexCache[indices[0]][itof]; @@ -1037,6 +1044,8 @@ void MatchTOF::doMatching(int sec) int eventIndexTOFCluster = mTOFClusSectIndexCache[indices[0]][itof]; mMatchedTracksPairsSec[sec].emplace_back(cacheTrk[itrk], eventIndexTOFCluster, mTOFClusWork[cacheTOF[itof]].getTime(), chi2, trkLTInt[iPropagation], mTrackGid[sec][type][cacheTrk[itrk]], type, (trefTOF.getTime() - (minTrkTime + maxTrkTime - 100E3) * 0.5) * 1E-6, trefTOF.getZ(), resX, resZ); // subracting 100 ns to max track which was artificially added mMatchedTracksPairsSec[sec][mMatchedTracksPairsSec[sec].size() - 1].setPt(pt); + mMatchedTracksPairsSec[sec][mMatchedTracksPairsSec[sec].size() - 1].setResX(sqrt(1. / errXinv2)); + mMatchedTracksPairsSec[sec][mMatchedTracksPairsSec[sec].size() - 1].setResZ(sqrt(1. / errZinv2)); } } } @@ -1337,6 +1346,12 @@ void MatchTOF::doMatchingForTPC(int sec) if (detId[ibc][iPropagation][1] != indices[1] || detId[ibc][iPropagation][2] != indices[2]) { continue; } + float padResX2 = 0.52; // (2.5/sqrt(12))^2 + float padResZ2 = 1.02; // (3.5/sqrt(12))^2 + float cosangle = TMath::Cos(Geo::getAngles(indices[1], indices[2]) * TMath::DegToRad()); + float errXinv2 = 1. / (trefTrk.getSigmaY2() + padResX2); + float errZinv2 = 1. / (trefTrk.getSigmaZ2() * cosangle + padResZ2); // should be valid only at eta=0 + // look at getPadDxDyDz to understand how to convert track errors in TOF strip ref system (wip) LOG(debug) << "TOF Cluster [" << itof << ", " << cacheTOF[itof] << "]: indices = " << indices[0] << ", " << indices[1] << ", " << indices[2] << ", " << indices[3] << ", " << indices[4]; LOG(debug) << "Propagated Track [" << itrk << "]: detId[" << iPropagation << "] = " << detId[ibc][iPropagation][0] << ", " << detId[ibc][iPropagation][1] << ", " << detId[ibc][iPropagation][2] << ", " << detId[ibc][iPropagation][3] << ", " << detId[ibc][iPropagation][4]; @@ -1360,7 +1375,7 @@ void MatchTOF::doMatchingForTPC(int sec) } LOG(debug) << "resX = " << resX << ", resZ = " << resZ << ", res = " << res; - float chi2 = mIsCosmics ? resX : res; // TODO: take into account also the time! + float chi2 = mIsCosmics ? resX : 0.5 * (resX * resX * errXinv2 + resZ * resZ * errZinv2); // TODO: take into account also the time! if (res < mSpaceTolerance) { // matching ok! LOG(debug) << "MATCHING FOUND: We have a match! between track " << mTracksSectIndexCache[trkType::UNCONS][sec][itrk] << " and TOF cluster " << mTOFClusSectIndexCache[indices[0]][itof]; @@ -1369,6 +1384,8 @@ void MatchTOF::doMatchingForTPC(int sec) int eventIndexTOFCluster = mTOFClusSectIndexCache[indices[0]][itof]; mMatchedTracksPairsSec[sec].emplace_back(cacheTrk[itrk], eventIndexTOFCluster, mTOFClusWork[cacheTOF[itof]].getTime(), chi2, trkLTInt[ibc][iPropagation], mTrackGid[sec][trkType::UNCONS][cacheTrk[itrk]], trkType::UNCONS, trefTOF.getTime() * 1E-6 - tpctime, trefTOF.getZ(), resX, resZ); // TODO: check if this is correct! mMatchedTracksPairsSec[sec][mMatchedTracksPairsSec[sec].size() - 1].setPt(pt); + mMatchedTracksPairsSec[sec][mMatchedTracksPairsSec[sec].size() - 1].setResX(sqrt(1. / errXinv2)); + mMatchedTracksPairsSec[sec][mMatchedTracksPairsSec[sec].size() - 1].setResZ(sqrt(1. / errZinv2)); } } }