Skip to content

Commit

Permalink
add trk res in TOF match chi2
Browse files Browse the repository at this point in the history
  • Loading branch information
noferini committed Apr 22, 2024
1 parent d08d21a commit e37249e
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,21 @@ 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; }

private:
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
Expand Down
21 changes: 19 additions & 2 deletions Detectors/GlobalTracking/src/MatchTOF.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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];
Expand All @@ -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));
}
}
}
Expand Down Expand Up @@ -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];
Expand All @@ -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];
Expand All @@ -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));
}
}
}
Expand Down

0 comments on commit e37249e

Please sign in to comment.