Skip to content

Commit 791d598

Browse files
committed
fix in track propagation to TOF for MC
1 parent c0c70ae commit 791d598

File tree

2 files changed

+123
-3
lines changed

2 files changed

+123
-3
lines changed

Detectors/GlobalTracking/include/GlobalTracking/MatchTOF.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,8 @@ class MatchTOF
220220
void BestMatchesHP(std::vector<o2::dataformats::MatchInfoTOFReco>& matchedTracksPairs, std::vector<o2::dataformats::MatchInfoTOF>* matchedTracks, std::vector<int>* matchedTracksIndex, int* matchedClustersIndex, const gsl::span<const o2::ft0::RecPoints>& FITRecPoints, const std::vector<Cluster>& TOFClusWork, std::vector<o2::dataformats::CalibInfoTOF>& CalibInfoTOF, unsigned long Timestamp, bool MCTruthON, const o2::dataformats::MCTruthContainer<o2::MCCompLabel>* TOFClusLabels, const std::vector<o2::MCCompLabel>* TracksLblWork, std::vector<o2::MCCompLabel>* OutTOFLabels);
221221
bool propagateToRefX(o2::track::TrackParCov& trc, float xRef /*in cm*/, float stepInCm /*in cm*/, o2::track::TrackLTIntegral& intLT);
222222
bool propagateToRefXWithoutCov(const o2::track::TrackParCov& trc, float xRef /*in cm*/, float stepInCm /*in cm*/, float bz);
223+
bool propagateToRefXWithoutCov(const o2::track::TrackParCov& trc, float xRef /*in cm*/, float stepInCm /*in cm*/, float bz, float pos[3]);
224+
void scalingIntTimes(o2::track::TrackLTIntegral& intLT, float scaling);
223225

224226
void updateTimeDependentParams();
225227

Detectors/GlobalTracking/src/MatchTOF.cxx

Lines changed: 121 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -932,6 +932,40 @@ void MatchTOF::doMatching(int sec)
932932
}
933933
//Printf("nStepsInsideSameStrip[nStripsCrossedInPropagation-1] = %d", nStepsInsideSameStrip[nStripsCrossedInPropagation - 1]);
934934
if (nStepsInsideSameStrip[nStripsCrossedInPropagation - 1] == 0) {
935+
// fine propagation inside the strip -> 1 mm step
936+
trkLTInt[nStripsCrossedInPropagation - 1] = intLT;
937+
if (mMCTruthON) { // for the moment to be applied only for MC -> condition to be removed for new 2025 data
938+
// temporary variables since propagation can fail
939+
int detIdTemp2[5] = {0, 0, 0, 0, 0};
940+
float deltaPosTemp2[3] = {deltaPosTemp[0], deltaPosTemp[1], deltaPosTemp[2]};
941+
int nstep = 0;
942+
const int maxnstep = 50;
943+
float xStart = trefTrk.getX();
944+
float xStop = xStart;
945+
trefTrk.getXYZGlo(pos);
946+
for (int ii = 0; ii < 3; ii++) { // we need to change the type...
947+
posFloat[ii] = pos[ii];
948+
}
949+
while (deltaPosTemp2[1] < -0.05 && detIdTemp2[2] != -1 && nstep < maxnstep) { // continuing propagation if dy is negative and we are still inside the strip volume
950+
nstep++;
951+
xStop += 0.1;
952+
propagateToRefXWithoutCov(trefTrk, xStop, 0.1, mBz, posFloat);
953+
954+
Geo::getPadDxDyDz(posFloat, detIdTemp2, deltaPosTemp2, sec);
955+
if (detIdTemp2[2] != -1) { // if propation was succesful -> update params
956+
detIdTemp[0] = detIdTemp2[0];
957+
detIdTemp[1] = detIdTemp2[1];
958+
detIdTemp[2] = detIdTemp2[2];
959+
detIdTemp[3] = detIdTemp2[3];
960+
detIdTemp[4] = detIdTemp2[4];
961+
deltaPosTemp[0] = deltaPosTemp2[0];
962+
deltaPosTemp[1] = deltaPosTemp2[1];
963+
deltaPosTemp[2] = deltaPosTemp2[2];
964+
}
965+
}
966+
scalingIntTimes(trkLTInt[nStripsCrossedInPropagation - 1], xStop / xStart);
967+
}
968+
935969
detId[nStripsCrossedInPropagation - 1][0] = detIdTemp[0];
936970
detId[nStripsCrossedInPropagation - 1][1] = detIdTemp[1];
937971
detId[nStripsCrossedInPropagation - 1][2] = detIdTemp[2];
@@ -940,7 +974,6 @@ void MatchTOF::doMatching(int sec)
940974
deltaPos[nStripsCrossedInPropagation - 1][0] = deltaPosTemp[0];
941975
deltaPos[nStripsCrossedInPropagation - 1][1] = deltaPosTemp[1];
942976
deltaPos[nStripsCrossedInPropagation - 1][2] = deltaPosTemp[2];
943-
trkLTInt[nStripsCrossedInPropagation - 1] = intLT;
944977
// Printf("intLT (after matching to strip %d): length = %f, time (Pion) = %f", nStripsCrossedInPropagation - 1, trkLTInt[nStripsCrossedInPropagation - 1].getL(), trkLTInt[nStripsCrossedInPropagation - 1].getTOF(o2::track::PID::Pion));
945978
nStepsInsideSameStrip[nStripsCrossedInPropagation - 1]++;
946979
} else { // a further propagation step in the same strip -> update info (we sum up on all matching with strip - we will divide for the number of steps a bit below)
@@ -1290,6 +1323,39 @@ void MatchTOF::doMatchingForTPC(int sec)
12901323

12911324
//Printf("nStepsInsideSameStrip[nStripsCrossedInPropagation-1] = %d", nStepsInsideSameStrip[nStripsCrossedInPropagation - 1]);
12921325
if (nStepsInsideSameStrip[ibc][nStripsCrossedInPropagation[ibc] - 1] == 0) {
1326+
trkLTInt[ibc][nStripsCrossedInPropagation[ibc] - 1] = intLT;
1327+
if (mMCTruthON) { // for the moment to be applied only for MC -> condition to be removed for new 2025 data
1328+
// temporary variables since propagation can fail
1329+
int detIdTemp2[5] = {0, 0, 0, 0, 0};
1330+
float deltaPosTemp2[3] = {deltaPosTemp[0], deltaPosTemp[1], deltaPosTemp[2]};
1331+
int nstep = 0;
1332+
const int maxnstep = 50;
1333+
float xStart = trefTrk.getX();
1334+
float xStop = xStart;
1335+
trefTrk.getXYZGlo(pos);
1336+
for (int ii = 0; ii < 3; ii++) { // we need to change the type...
1337+
posFloat[ii] = pos[ii];
1338+
}
1339+
while (deltaPosTemp2[1] < -0.05 && detIdTemp2[2] != -1 && nstep < maxnstep) { // continuing propagation if dy is negative and we are still inside the strip volume
1340+
nstep++;
1341+
xStop += 0.1;
1342+
propagateToRefXWithoutCov(trefTrk, xStop, 0.1, mBz, posFloat);
1343+
1344+
Geo::getPadDxDyDz(posFloat, detIdTemp2, deltaPosTemp2, sec);
1345+
if (detIdTemp2[2] != -1) { // if propation was succesful -> update params
1346+
detIdTemp[0] = detIdTemp2[0];
1347+
detIdTemp[1] = detIdTemp2[1];
1348+
detIdTemp[2] = detIdTemp2[2];
1349+
detIdTemp[3] = detIdTemp2[3];
1350+
detIdTemp[4] = detIdTemp2[4];
1351+
deltaPosTemp[0] = deltaPosTemp2[0];
1352+
deltaPosTemp[1] = deltaPosTemp2[1];
1353+
deltaPosTemp[2] = deltaPosTemp2[2];
1354+
}
1355+
}
1356+
scalingIntTimes(trkLTInt[ibc][nStripsCrossedInPropagation[ibc] - 1], xStop / xStart);
1357+
}
1358+
12931359
detId[ibc][nStripsCrossedInPropagation[ibc] - 1][0] = detIdTemp[0];
12941360
detId[ibc][nStripsCrossedInPropagation[ibc] - 1][1] = detIdTemp[1];
12951361
detId[ibc][nStripsCrossedInPropagation[ibc] - 1][2] = detIdTemp[2];
@@ -1299,7 +1365,6 @@ void MatchTOF::doMatchingForTPC(int sec)
12991365
deltaPos[ibc][nStripsCrossedInPropagation[ibc] - 1][1] = deltaPosTemp[1];
13001366
deltaPos[ibc][nStripsCrossedInPropagation[ibc] - 1][2] = deltaPosTemp[2];
13011367

1302-
trkLTInt[ibc][nStripsCrossedInPropagation[ibc] - 1] = intLT;
13031368
Zshift[ibc][nStripsCrossedInPropagation[ibc] - 1] = ZshiftCurrent;
13041369
// Printf("intLT (after matching to strip %d): length = %f, time (Pion) = %f", nStripsCrossedInPropagation - 1, trkLTInt[nStripsCrossedInPropagation - 1].getL(), trkLTInt[nStripsCrossedInPropagation - 1].getTOF(o2::track::PID::Pion));
13051370
nStepsInsideSameStrip[ibc][nStripsCrossedInPropagation[ibc] - 1]++;
@@ -1839,7 +1904,6 @@ bool MatchTOF::propagateToRefX(o2::track::TrackParCov& trc, float xRef, float st
18391904
//Printf("propagateToRefX: snp of teh track is %f (--> %f grad)", trc.getSnp(), TMath::ASin(trc.getSnp())*TMath::RadToDeg());
18401905
return refReached && std::abs(trc.getSnp()) < 0.95; // Here we need to put MAXSNP
18411906
}
1842-
18431907
//______________________________________________
18441908
bool MatchTOF::propagateToRefXWithoutCov(const o2::track::TrackParCov& trc, float xRef, float stepInCm, float bzField)
18451909
{
@@ -1879,6 +1943,60 @@ bool MatchTOF::propagateToRefXWithoutCov(const o2::track::TrackParCov& trc, floa
18791943

18801944
return refReached && std::abs(trcNoCov.getSnp()) < 0.95 && TMath::Abs(trcNoCov.getZ()) < Geo::MAXHZTOF; // Here we need to put MAXSNP
18811945
}
1946+
//______________________________________________
1947+
void MatchTOF::scalingIntTimes(o2::track::TrackLTIntegral& intLT, float scaling)
1948+
{
1949+
intLT.setL(intLT.getL() * scaling);
1950+
for (int i = 0; i < intLT.getNTOFs(); i++) {
1951+
intLT.setTOF(intLT.getTOF(i) * scaling, i);
1952+
}
1953+
}
1954+
1955+
//______________________________________________
1956+
bool MatchTOF::propagateToRefXWithoutCov(const o2::track::TrackParCov& trc, float xRef, float stepInCm, float bzField, float pos[3])
1957+
{
1958+
// propagate track to matching reference X without using the covariance matrix
1959+
// we create the copy of the track in a TrackPar object (no cov matrix)
1960+
o2::track::TrackPar trcNoCov(trc);
1961+
const float tanHalfSector = tan(o2::constants::math::SectorSpanRad / 2);
1962+
bool refReached = false;
1963+
float xStart = trcNoCov.getX();
1964+
// the first propagation will be from 2m, if the track is not at least at 2m
1965+
if (xStart < 50.) {
1966+
xStart = 50.;
1967+
}
1968+
int istep = 1;
1969+
bool hasPropagated = trcNoCov.propagateParamTo(xStart + istep * stepInCm, bzField);
1970+
while (hasPropagated) {
1971+
if (trcNoCov.getX() > xRef) {
1972+
refReached = true; // we reached the 371cm reference
1973+
}
1974+
istep++;
1975+
if (fabs(trcNoCov.getY()) > trcNoCov.getX() * tanHalfSector) { // we are still in the same sector
1976+
// we need to rotate the track to go to the new sector
1977+
// Printf("propagateToRefX: changing sector");
1978+
auto alphaNew = o2::math_utils::angle2Alpha(trcNoCov.getPhiPos());
1979+
if (!trcNoCov.rotateParam(alphaNew) != 0) {
1980+
// Printf("propagateToRefX: failed to rotate");
1981+
break; // failed (this line is taken from MatchTPCITS and the following comment too: RS: check effect on matching tracks to neighbouring sector)
1982+
}
1983+
}
1984+
if (refReached) {
1985+
break;
1986+
}
1987+
hasPropagated = trcNoCov.propagateParamTo(xStart + istep * stepInCm, bzField);
1988+
}
1989+
// if (std::abs(trc.getSnp()) > MAXSNP) Printf("propagateToRefX: condition on snp not ok, returning false");
1990+
// Printf("propagateToRefX: snp of teh track is %f (--> %f grad)", trcNoCov.getSnp(), TMath::ASin(trcNoCov.getSnp())*TMath::RadToDeg());
1991+
1992+
o2::track::TrackParametrization<float>::dim3_t xyz;
1993+
trcNoCov.getXYZGlo(xyz);
1994+
pos[0] = xyz[0];
1995+
pos[1] = xyz[1];
1996+
pos[2] = xyz[2];
1997+
1998+
return refReached && std::abs(trcNoCov.getSnp()) < 0.95 && TMath::Abs(trcNoCov.getZ()) < Geo::MAXHZTOF; // Here we need to put MAXSNP
1999+
}
18822000

18832001
//______________________________________________
18842002
void MatchTOF::setDebugFlag(UInt_t flag, bool on)

0 commit comments

Comments
 (0)