Skip to content

Commit d9f2e2c

Browse files
committed
add trk res in TOF match chi2
1 parent b04a351 commit d9f2e2c

4 files changed

Lines changed: 55 additions & 6 deletions

File tree

DataFormats/Reconstruction/include/ReconstructionDataFormats/MatchInfoTOF.h

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,11 @@ class MatchInfoTOF
5858

5959
int getIdLocal() const { return mIdLocal; }
6060

61+
float getVz() const { return mVz; }
62+
void setVz(float val) { mVz = val; }
63+
int getChannel() const { return mChannel; }
64+
void setChannel(int val) { mChannel = val; }
65+
6166
private:
6267
int mIdLocal; // track id in sector of the pair track-TOFcluster
6368
float mChi2; // chi2 of the pair track-TOFcluster
@@ -69,8 +74,10 @@ class MatchInfoTOF
6974
float mDZatTOF = 0.0; ///< DZ position at TOF
7075
float mDeltaT = 0.0; ///< tTOF - TPC (microsec)
7176
double mSignal = 0.0; ///< TOF time in ps
77+
float mVz = 0.0; ///< Vz from TOF match
78+
int mChannel = -1; ///< channel
7279

73-
ClassDefNV(MatchInfoTOF, 5);
80+
ClassDefNV(MatchInfoTOF, 6);
7481
};
7582
} // namespace dataformats
7683
} // namespace o2

DataFormats/Reconstruction/include/ReconstructionDataFormats/MatchInfoTOFReco.h

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,14 +45,24 @@ class MatchInfoTOFReco : public MatchInfoTOF
4545
float pt() const { return mPt; }
4646
void setPt(float pt) { mPt = pt; }
4747

48+
void setResX(float val) { mResX = val; }
49+
void setResZ(float val) { mResZ = val; }
50+
void setResT(float val) { mResT = val; }
51+
float getResX() const { return mResX; }
52+
float getResZ() const { return mResZ; }
53+
float getResT() const { return mResT; }
54+
4855
void setTrackType(TrackType value) { mTrackType = value; }
4956
TrackType getTrackType() const { return mTrackType; }
5057

5158
private:
5259
TrackType mTrackType; ///< track type (TPC, ITSTPC, TPCTRD, ITSTPCTRD)
5360
bool mFakeMC = false;
5461
float mPt = 0;
55-
ClassDefNV(MatchInfoTOFReco, 4);
62+
float mResX = 1;
63+
float mResZ = 1;
64+
float mResT = 1;
65+
ClassDefNV(MatchInfoTOFReco, 5);
5666
};
5767
} // namespace dataformats
5868
} // namespace o2

Detectors/GlobalTracking/include/GlobalTracking/MatchTOF.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -309,6 +309,7 @@ class MatchTOF
309309
///< per sector indices of track entry in mTracksWork
310310
std::array<std::vector<int>, o2::constants::math::NSectors> mTracksSectIndexCache[trkType::SIZE];
311311
std::array<std::vector<int>, o2::constants::math::NSectors> mTracksSeed[trkType::SIZE];
312+
std::vector<float> mVZtpcOnly[o2::constants::math::NSectors];
312313

313314
std::vector<float> mExtraTPCFwdTime[o2::constants::math::NSectors]; ///< track extra params for TPC tracks: Fws Max time
314315
std::vector<Cluster> mTOFClusWork; ///< track params prepared for matching
@@ -347,7 +348,7 @@ class MatchTOF
347348
TStopwatch mTimerMatchITSTPC;
348349
TStopwatch mTimerMatchTPC;
349350
TStopwatch mTimerDBG;
350-
ClassDefNV(MatchTOF, 5);
351+
ClassDefNV(MatchTOF, 6);
351352
};
352353
} // namespace globaltracking
353354
} // namespace o2

Detectors/GlobalTracking/src/MatchTOF.cxx

Lines changed: 34 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -701,6 +701,11 @@ void MatchTOF::addTPCSeed(const o2::tpc::TrackTPC& _tr, o2::dataformats::GlobalT
701701
o2::track::TrackLTIntegral intLT0; // mTPCTracksWork.back().getLTIntegralOut(); // we get the integrated length from TPC-ITC outward propagation
702702
// compute track length up to now
703703
mLTinfos[sector][trkType::UNCONS].emplace_back(intLT0);
704+
float vz0 = _tr.getZAt(0, mBz);
705+
if (abs(vz0) > 9000) {
706+
vz0 = _tr.getZ() - _tr.getX() * _tr.getTgl();
707+
}
708+
mVZtpcOnly[sector].push_back(vz0);
704709

705710
/*
706711
const auto& trackTune = TrackTuneParams::Instance();
@@ -841,6 +846,8 @@ void MatchTOF::doMatching(int sec)
841846
// Printf("intLT (before doing anything): length = %f, time (Pion) = %f", intLT.getL(), intLT.getTOF(o2::track::PID::Pion));
842847
float minTrkTime = (trackWork.second.getTimeStamp() - mSigmaTimeCut * trackWork.second.getTimeStampError()) * 1.E6 + timeShift; // minimum time in ps
843848
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)
849+
const float sqrt12inv = 1. / sqrt(12.);
850+
float resT = (trackWork.second.getTimeStampError() + 100E-3) * sqrt12inv;
844851
int istep = 1; // number of steps
845852
float step = 1.0; // step size in cm
846853

@@ -1012,6 +1019,11 @@ void MatchTOF::doMatching(int sec)
10121019
int eventIdTOF;
10131020
int sourceIdTOF;
10141021
for (auto iPropagation = 0; iPropagation < nStripsCrossedInPropagation; iPropagation++) {
1022+
float cosangle = TMath::Cos(Geo::getAngles(indices[1], indices[2]) * TMath::DegToRad());
1023+
float errXinv2 = 1. / (trefTrk.getSigmaY2());
1024+
float errZinv2 = 1. / (trefTrk.getSigmaZ2() * cosangle); // should be valid only at eta=0
1025+
// look at getPadDxDyDz to understand how to convert track errors in TOF strip ref system (wip)
1026+
10151027
LOG(debug) << "TOF Cluster [" << itof << ", " << cacheTOF[itof] << "]: indices = " << indices[0] << ", " << indices[1] << ", " << indices[2] << ", " << indices[3] << ", " << indices[4];
10161028
LOG(debug) << "Propagated Track [" << itrk << "]: detId[" << iPropagation << "] = " << detId[iPropagation][0] << ", " << detId[iPropagation][1] << ", " << detId[iPropagation][2] << ", " << detId[iPropagation][3] << ", " << detId[iPropagation][4];
10171029
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 +1040,7 @@ void MatchTOF::doMatching(int sec)
10281040
if (indices[2] != detId[iPropagation][2]) {
10291041
continue;
10301042
}
1031-
float chi2 = res; // TODO: take into account also the time!
1043+
float chi2 = 0.5 * (resX * resX * errXinv2 + resZ * resZ * errZinv2); // TODO: take into account also the time!
10321044

10331045
if (res < mSpaceTolerance) { // matching ok!
10341046
LOG(debug) << "MATCHING FOUND: We have a match! between track " << mTracksSectIndexCache[type][sec][itrk] << " and TOF cluster " << mTOFClusSectIndexCache[indices[0]][itof];
@@ -1037,6 +1049,11 @@ void MatchTOF::doMatching(int sec)
10371049
int eventIndexTOFCluster = mTOFClusSectIndexCache[indices[0]][itof];
10381050
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
10391051
mMatchedTracksPairsSec[sec][mMatchedTracksPairsSec[sec].size() - 1].setPt(pt);
1052+
mMatchedTracksPairsSec[sec][mMatchedTracksPairsSec[sec].size() - 1].setResX(sqrt(1. / errXinv2));
1053+
mMatchedTracksPairsSec[sec][mMatchedTracksPairsSec[sec].size() - 1].setResZ(sqrt(1. / errZinv2));
1054+
mMatchedTracksPairsSec[sec][mMatchedTracksPairsSec[sec].size() - 1].setResT(resT);
1055+
mMatchedTracksPairsSec[sec][mMatchedTracksPairsSec[sec].size() - 1].setVz2(0.0); // not needed for constrained tracks
1056+
mMatchedTracksPairsSec[sec][mMatchedTracksPairsSec[sec].size() - 1].setChannel(mainChannel);
10401057
}
10411058
}
10421059
}
@@ -1097,6 +1114,8 @@ void MatchTOF::doMatchingForTPC(int sec)
10971114
double minTrkTime = (tpctime - trackWork.second.getTimeStampError()) * 1.E6 + timeShift; // minimum time in ps
10981115
minTrkTime = int(minTrkTime / BCgranularity) * BCgranularity; // align min to a BC
10991116
double maxTrkTime = (tpctime + mExtraTPCFwdTime[sec][cacheTrk[itrk]]) * 1.E6 + timeShift; // maximum time in ps
1117+
const float sqrt12inv = 1. / sqrt(12.);
1118+
float resT = (maxTrkTime - minTrkTime) * sqrt12inv;
11001119

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

1231+
float Zshift = posFloat[2] - pos[2];
1232+
12121233
Geo::getPadDxDyDz(posFloat, detIdTemp, deltaPosTemp, sec);
12131234

12141235
if (detIdTemp[2] == -1) {
@@ -1337,6 +1358,10 @@ void MatchTOF::doMatchingForTPC(int sec)
13371358
if (detId[ibc][iPropagation][1] != indices[1] || detId[ibc][iPropagation][2] != indices[2]) {
13381359
continue;
13391360
}
1361+
float cosangle = TMath::Cos(Geo::getAngles(indices[1], indices[2]) * TMath::DegToRad());
1362+
float errXinv2 = 1. / (trefTrk.getSigmaY2());
1363+
float errZinv2 = 1. / (trefTrk.getSigmaZ2() * cosangle); // should be valid only at eta=0
1364+
// look at getPadDxDyDz to understand how to convert track errors in TOF strip ref system (wip)
13401365

13411366
LOG(debug) << "TOF Cluster [" << itof << ", " << cacheTOF[itof] << "]: indices = " << indices[0] << ", " << indices[1] << ", " << indices[2] << ", " << indices[3] << ", " << indices[4];
13421367
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,15 +1385,21 @@ void MatchTOF::doMatchingForTPC(int sec)
13601385
}
13611386

13621387
LOG(debug) << "resX = " << resX << ", resZ = " << resZ << ", res = " << res;
1363-
float chi2 = mIsCosmics ? resX : res; // TODO: take into account also the time!
1388+
float chi2 = mIsCosmics ? resX : 0.5 * (resX * resX * errXinv2 + resZ * resZ * errZinv2); // TODO: take into account also the time!
13641389

13651390
if (res < mSpaceTolerance) { // matching ok!
13661391
LOG(debug) << "MATCHING FOUND: We have a match! between track " << mTracksSectIndexCache[trkType::UNCONS][sec][itrk] << " and TOF cluster " << mTOFClusSectIndexCache[indices[0]][itof];
13671392
foundCluster = true;
13681393
// set event indexes (to be checked)
1394+
13691395
int eventIndexTOFCluster = mTOFClusSectIndexCache[indices[0]][itof];
1370-
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!
1396+
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!
13711397
mMatchedTracksPairsSec[sec][mMatchedTracksPairsSec[sec].size() - 1].setPt(pt);
1398+
mMatchedTracksPairsSec[sec][mMatchedTracksPairsSec[sec].size() - 1].setResX(sqrt(1. / errXinv2));
1399+
mMatchedTracksPairsSec[sec][mMatchedTracksPairsSec[sec].size() - 1].setResZ(sqrt(1. / errZinv2));
1400+
mMatchedTracksPairsSec[sec][mMatchedTracksPairsSec[sec].size() - 1].setResT(resT);
1401+
mMatchedTracksPairsSec[sec][mMatchedTracksPairsSec[sec].size() - 1].setVz(mVZtpcOnly[sec][itrk] + Zshift);
1402+
mMatchedTracksPairsSec[sec][mMatchedTracksPairsSec[sec].size() - 1].setChannel(mainChannel);
13721403
}
13731404
}
13741405
}

0 commit comments

Comments
 (0)