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 May 7, 2024
1 parent b04a351 commit d9f2e2c
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,11 @@ class MatchInfoTOF

int getIdLocal() const { return mIdLocal; }

float getVz() const { return mVz; }
void setVz(float val) { mVz = val; }
int getChannel() const { return mChannel; }
void setChannel(int val) { mChannel = val; }

private:
int mIdLocal; // track id in sector of the pair track-TOFcluster
float mChi2; // chi2 of the pair track-TOFcluster
Expand All @@ -69,8 +74,10 @@ class MatchInfoTOF
float mDZatTOF = 0.0; ///< DZ position at TOF
float mDeltaT = 0.0; ///< tTOF - TPC (microsec)
double mSignal = 0.0; ///< TOF time in ps
float mVz = 0.0; ///< Vz from TOF match
int mChannel = -1; ///< channel

ClassDefNV(MatchInfoTOF, 5);
ClassDefNV(MatchInfoTOF, 6);
};
} // namespace dataformats
} // namespace o2
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,24 @@ 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; }
void setResT(float val) { mResT = val; }
float getResX() const { return mResX; }
float getResZ() const { return mResZ; }
float getResT() const { return mResT; }

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;
float mResT = 1;
ClassDefNV(MatchInfoTOFReco, 5);
};
} // namespace dataformats
} // namespace o2
Expand Down
3 changes: 2 additions & 1 deletion Detectors/GlobalTracking/include/GlobalTracking/MatchTOF.h
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,7 @@ class MatchTOF
///< per sector indices of track entry in mTracksWork
std::array<std::vector<int>, o2::constants::math::NSectors> mTracksSectIndexCache[trkType::SIZE];
std::array<std::vector<int>, o2::constants::math::NSectors> mTracksSeed[trkType::SIZE];
std::vector<float> mVZtpcOnly[o2::constants::math::NSectors];

std::vector<float> mExtraTPCFwdTime[o2::constants::math::NSectors]; ///< track extra params for TPC tracks: Fws Max time
std::vector<Cluster> mTOFClusWork; ///< track params prepared for matching
Expand Down Expand Up @@ -347,7 +348,7 @@ class MatchTOF
TStopwatch mTimerMatchITSTPC;
TStopwatch mTimerMatchTPC;
TStopwatch mTimerDBG;
ClassDefNV(MatchTOF, 5);
ClassDefNV(MatchTOF, 6);
};
} // namespace globaltracking
} // namespace o2
Expand Down
37 changes: 34 additions & 3 deletions Detectors/GlobalTracking/src/MatchTOF.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -701,6 +701,11 @@ void MatchTOF::addTPCSeed(const o2::tpc::TrackTPC& _tr, o2::dataformats::GlobalT
o2::track::TrackLTIntegral intLT0; // mTPCTracksWork.back().getLTIntegralOut(); // we get the integrated length from TPC-ITC outward propagation
// compute track length up to now
mLTinfos[sector][trkType::UNCONS].emplace_back(intLT0);
float vz0 = _tr.getZAt(0, mBz);
if (abs(vz0) > 9000) {
vz0 = _tr.getZ() - _tr.getX() * _tr.getTgl();
}
mVZtpcOnly[sector].push_back(vz0);

/*
const auto& trackTune = TrackTuneParams::Instance();
Expand Down Expand Up @@ -841,6 +846,8 @@ void MatchTOF::doMatching(int sec)
// Printf("intLT (before doing anything): length = %f, time (Pion) = %f", intLT.getL(), intLT.getTOF(o2::track::PID::Pion));
float minTrkTime = (trackWork.second.getTimeStamp() - mSigmaTimeCut * trackWork.second.getTimeStampError()) * 1.E6 + timeShift; // minimum time in ps
float maxTrkTime = (trackWork.second.getTimeStamp() + mSigmaTimeCut * trackWork.second.getTimeStampError()) * 1.E6 + timeShift + 100E3; // maximum time in ps + 100 ns for slow tracks (beta->0.2)
const float sqrt12inv = 1. / sqrt(12.);
float resT = (trackWork.second.getTimeStampError() + 100E-3) * sqrt12inv;
int istep = 1; // number of steps
float step = 1.0; // step size in cm

Expand Down Expand Up @@ -1012,6 +1019,11 @@ void MatchTOF::doMatching(int sec)
int eventIdTOF;
int sourceIdTOF;
for (auto iPropagation = 0; iPropagation < nStripsCrossedInPropagation; iPropagation++) {
float cosangle = TMath::Cos(Geo::getAngles(indices[1], indices[2]) * TMath::DegToRad());
float errXinv2 = 1. / (trefTrk.getSigmaY2());
float errZinv2 = 1. / (trefTrk.getSigmaZ2() * cosangle); // 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 +1040,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 +1049,11 @@ 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));
mMatchedTracksPairsSec[sec][mMatchedTracksPairsSec[sec].size() - 1].setResT(resT);
mMatchedTracksPairsSec[sec][mMatchedTracksPairsSec[sec].size() - 1].setVz2(0.0); // not needed for constrained tracks
mMatchedTracksPairsSec[sec][mMatchedTracksPairsSec[sec].size() - 1].setChannel(mainChannel);
}
}
}
Expand Down Expand Up @@ -1097,6 +1114,8 @@ void MatchTOF::doMatchingForTPC(int sec)
double minTrkTime = (tpctime - trackWork.second.getTimeStampError()) * 1.E6 + timeShift; // minimum time in ps
minTrkTime = int(minTrkTime / BCgranularity) * BCgranularity; // align min to a BC
double maxTrkTime = (tpctime + mExtraTPCFwdTime[sec][cacheTrk[itrk]]) * 1.E6 + timeShift; // maximum time in ps
const float sqrt12inv = 1. / sqrt(12.);
float resT = (maxTrkTime - minTrkTime) * sqrt12inv;

if (mIsCosmics) {
for (double tBC = minTrkTime; tBC < maxTrkTime; tBC += BCgranularity) {
Expand Down Expand Up @@ -1209,6 +1228,8 @@ void MatchTOF::doMatchingForTPC(int sec)
posFloat[2] = pos[2];
}

float Zshift = posFloat[2] - pos[2];

Geo::getPadDxDyDz(posFloat, detIdTemp, deltaPosTemp, sec);

if (detIdTemp[2] == -1) {
Expand Down Expand Up @@ -1337,6 +1358,10 @@ void MatchTOF::doMatchingForTPC(int sec)
if (detId[ibc][iPropagation][1] != indices[1] || detId[ibc][iPropagation][2] != indices[2]) {
continue;
}
float cosangle = TMath::Cos(Geo::getAngles(indices[1], indices[2]) * TMath::DegToRad());
float errXinv2 = 1. / (trefTrk.getSigmaY2());
float errZinv2 = 1. / (trefTrk.getSigmaZ2() * cosangle); // 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,15 +1385,21 @@ 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];
foundCluster = true;
// set event indexes (to be checked)

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].emplace_back(cacheTrk[itrk], eventIndexTOFCluster, mTOFClusWork[cacheTOF[itof]].getTime(), chi2, trkLTInt[ibc][iPropagation], mTrackGid[sec][trkType::UNCONS][cacheTrk[itrk]], trkType::UNCONS, deltat, 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));
mMatchedTracksPairsSec[sec][mMatchedTracksPairsSec[sec].size() - 1].setResT(resT);
mMatchedTracksPairsSec[sec][mMatchedTracksPairsSec[sec].size() - 1].setVz(mVZtpcOnly[sec][itrk] + Zshift);
mMatchedTracksPairsSec[sec][mMatchedTracksPairsSec[sec].size() - 1].setChannel(mainChannel);
}
}
}
Expand Down

0 comments on commit d9f2e2c

Please sign in to comment.