@@ -505,13 +505,12 @@ bool MatchTOF::prepareTracks()
505505 std::array<float, 3> globalPos;
506506 int itmp = 0;
507507 for (int sec = o2::constants::math::NSectors; sec--;) {
508- Printf("sector %d", sec);
509508 auto& cacheTrk = mTracksSectIndexCache[sec]; // array of cached tracks indices for this sector; reminder: they are ordered in time!
510509 for (int itrk = 0; itrk < cacheTrk.size(); itrk++){
511510 itmp++;
512511 auto& trc = mTracksWork[cacheTrk[itrk]];
513512 trc.getXYZGlo(globalPos);
514- printf("Track %d: Global coordinates After propagating to 371 cm: globalPos[0] = %f, globalPos[1] = %f, globalPos[2] = %f\n", itrk, globalPos[0], globalPos[1], globalPos[2]);
513+ // printf("Track %d: Global coordinates After propagating to 371 cm: globalPos[0] = %f, globalPos[1] = %f, globalPos[2] = %f\n", itrk, globalPos[0], globalPos[1], globalPos[2]);
515514 // Printf("The phi angle is %f", TMath::ATan2(globalPos[1], globalPos[0]));
516515 }
517516 }
@@ -563,10 +562,14 @@ bool MatchTOF::prepareTPCTracks()
563562 // create working copy of track param
564563 timeEst timeInfo;
565564 // set
565+ float extraErr = 0 ;
566+ if (mIsCosmics ) {
567+ extraErr = 100 ;
568+ }
566569 timeInfo.setTimeStamp (trcOrig.getTime0 () * mTPCTBinMUS );
567- timeInfo.setTimeStampError ((trcOrig.getDeltaTBwd () + 5 ) * mTPCTBinMUS );
570+ timeInfo.setTimeStampError ((trcOrig.getDeltaTBwd () + 5 ) * mTPCTBinMUS + extraErr );
568571 mSideTPC .push_back (trcOrig.hasASideClustersOnly () ? 1 : (trcOrig.hasCSideClustersOnly () ? -1 : 0 ));
569- mExtraTPCFwdTime .push_back ((trcOrig.getDeltaTFwd () + 5 ) * mTPCTBinMUS );
572+ mExtraTPCFwdTime .push_back ((trcOrig.getDeltaTFwd () + 5 ) * mTPCTBinMUS + extraErr );
570573
571574 o2::track::TrackLTIntegral intLT0; // mTPCTracksWork.back().getLTIntegralOut(); // we get the integrated length from TPC-ITC outward propagation
572575 // make a copy of the TPC track that we have to propagate
@@ -641,6 +644,7 @@ bool MatchTOF::prepareTPCTracks()
641644 auto & trcB = mTracksWork [b].second ;
642645 return ((trcA.getTimeStamp () - trcA.getTimeStampError ()) - (trcB.getTimeStamp () - trcB.getTimeStampError ()) < 0 .);
643646 });
647+
644648 } // loop over tracks of single sector
645649
646650 // Uncomment for local debug
@@ -653,14 +657,15 @@ bool MatchTOF::prepareTPCTracks()
653657 auto& cacheTrk = mTracksSectIndexCache[sec]; // array of cached tracks indices for this sector; reminder: they are ordered in time!
654658 for (int itrk = 0; itrk < cacheTrk.size(); itrk++){
655659 itmp++;
656- auto& trc = mTracksWork[cacheTrk[itrk]];
660+ auto& trc = mTracksWork[cacheTrk[itrk]].first;
661+ auto& trcAttr = mTracksWork[cacheTrk[itrk]].second;
657662 trc.getXYZGlo(globalPos);
658- printf("Track %d: Global coordinates After propagating to 371 cm: globalPos[0] = %f, globalPos[1] = %f, globalPos[2] = %f\n", itrk, globalPos[0], globalPos[1], globalPos[2]);
663+ printf("Track %d: Global coordinates After propagating to 371 cm: globalPos[0] = %f, globalPos[1] = %f, globalPos[2] = %f -- timestamp = %f +/- %f \n", itrk, globalPos[0], globalPos[1], globalPos[2],trcAttr.getTimeStamp(),trcAttr.getTimeStampError());
659664 // Printf("The phi angle is %f", TMath::ATan2(globalPos[1], globalPos[0]));
660665 }
661666 }
662667 Printf("we have %d tracks",itmp);
663- */
668+ */
664669
665670 return true ;
666671}
@@ -1116,6 +1121,7 @@ void MatchTOF::doMatchingForTPC(int sec)
11161121 float vdriftInBC = Geo::BC_TIME_INPS * 1E-6 * vdrift;
11171122
11181123 int bc_grouping = 40 ;
1124+ int bc_grouping_tolerance = bc_grouping + mTimeTolerance / 25 ;
11191125 int bc_grouping_half = (bc_grouping + 1 ) / 2 ;
11201126 double BCgranularity = Geo::BC_TIME_INPS * bc_grouping;
11211127
@@ -1162,17 +1168,20 @@ void MatchTOF::doMatchingForTPC(int sec)
11621168 minTrkTime = int (minTrkTime / BCgranularity) * BCgranularity; // align min to a BC
11631169 double maxTrkTime = (trackWork.second .getTimeStamp () + mExtraTPCFwdTime [cacheTrk[itrk]]) * 1 .E6 ; // maximum time in ps
11641170
1165- /*
1171+ // printf("trk time %f - %f (max shift +/- %f cm)\n",minTrkTime,maxTrkTime,trackWork.second.getTimeStampError()*vdrift );
1172+
11661173 for (double tBC = minTrkTime; tBC < maxTrkTime; tBC += BCgranularity) {
11671174 unsigned long ibc = (unsigned long )(tBC * Geo::BC_TIME_INPS_INV);
11681175 BCcand.emplace_back (ibc);
11691176 nStripsCrossedInPropagation.emplace_back (0 );
11701177 }
1171- */
11721178
1179+ /*
11731180 for (auto itof = itof0; itof < nTOFCls; itof++) {
11741181 auto& trefTOF = mTOFClusWork[cacheTOF[itof]];
11751182
1183+ // printf("clus time = %f\n",trefTOF.getTime());
1184+
11761185 if (trefTOF.getTime() < minTrkTime) { // this cluster has a time that is too small for the current track, we will get to the next one
11771186 itof0 = itof + 1;
11781187 continue;
@@ -1203,7 +1212,7 @@ void MatchTOF::doMatchingForTPC(int sec)
12031212 nStripsCrossedInPropagation.emplace_back(0);
12041213 }
12051214 }
1206-
1215+ */
12071216 // printf("BC = %ld\n",BCcand.size());
12081217
12091218 detId.clear ();
@@ -1320,8 +1329,8 @@ void MatchTOF::doMatchingForTPC(int sec)
13201329 }
13211330 }
13221331 for (int ibc = 0 ; ibc < BCcand.size (); ibc++) {
1323- float minTime = (BCcand[ibc] - bc_grouping ) * Geo::BC_TIME_INPS;
1324- float maxTime = (BCcand[ibc] + bc_grouping ) * Geo::BC_TIME_INPS;
1332+ float minTime = (BCcand[ibc] - bc_grouping_tolerance ) * Geo::BC_TIME_INPS;
1333+ float maxTime = (BCcand[ibc] + bc_grouping_tolerance ) * Geo::BC_TIME_INPS;
13251334 for (Int_t imatch = 0 ; imatch < nStripsCrossedInPropagation[ibc]; imatch++) {
13261335 // we take as residual the average of the residuals along the propagation in the same strip
13271336 deltaPos[ibc][imatch][0 ] /= nStepsInsideSameStrip[ibc][imatch];
@@ -1340,17 +1349,14 @@ void MatchTOF::doMatchingForTPC(int sec)
13401349 // printf("itof = %d\n", itof);
13411350 auto & trefTOF = mTOFClusWork [cacheTOF[itof]];
13421351 // compare the times of the track and the TOF clusters - remember that they both are ordered in time!
1343- // Printf("trefTOF.getTime() = %f, maxTrkTime = %f, minTrkTime = %f", trefTOF.getTime(), maxTrkTime, minTrkTime);
13441352
13451353 if (trefTOF.getTime () < minTime) { // this cluster has a time that is too small for the current track, we will get to the next one
1346- // Printf("In trefTOF.getTime() < minTrkTime");
13471354 itof0 = itof + 1 ; // but for the next track that we will check, we will ignore this cluster (the time is anyway too small)
13481355 continue ;
13491356 }
13501357 if (trefTOF.getTime () > maxTime) { // no more TOF clusters can be matched to this track
13511358 break ;
13521359 }
1353-
13541360 unsigned long bcClus = trefTOF.getTime () * Geo::BC_TIME_INPS_INV;
13551361
13561362 int mainChannel = trefTOF.getMainContributingChannel ();
@@ -1402,8 +1408,13 @@ void MatchTOF::doMatchingForTPC(int sec)
14021408 LOG (DEBUG) << " Propagated Track [" << itrk << " , " << cacheTrk[itrk] << " ]: detId[" << iPropagation << " ] = " << detId[ibc][iPropagation][0 ] << " , " << detId[ibc][iPropagation][1 ] << " , " << detId[ibc][iPropagation][2 ] << " , " << detId[ibc][iPropagation][3 ] << " , " << detId[ibc][iPropagation][4 ];
14031409 float resX = deltaPos[ibc][iPropagation][0 ] - (indices[4 ] - detId[ibc][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
14041410 float resZ = deltaPos[ibc][iPropagation][2 ] - (indices[3 ] - detId[ibc][iPropagation][3 ]) * Geo::ZPAD + posCorr[2 ]; // readjusting the residuals due to the fact that the propagation fell in a pad that was not exactly the one of the cluster
1405- resZ += (BCcand[ibc] - bcClus) * vdriftInBC * side; // add bc correction
1411+ if (BCcand[ibc] > bcClus) {
1412+ resZ += (BCcand[ibc] - bcClus) * vdriftInBC * side; // add bc correction
1413+ } else {
1414+ resZ -= (bcClus - BCcand[ibc]) * vdriftInBC * side;
1415+ }
14061416 float res = TMath::Sqrt (resX * resX + resZ * resZ);
1417+
14071418 if (indices[0 ] != detId[ibc][iPropagation][0 ]) {
14081419 continue ;
14091420 }
@@ -1413,16 +1424,17 @@ void MatchTOF::doMatchingForTPC(int sec)
14131424 if (indices[2 ] != detId[ibc][iPropagation][2 ]) {
14141425 continue ;
14151426 }
1427+
14161428 LOG (DEBUG) << " resX = " << resX << " , resZ = " << resZ << " , res = " << res;
1417- float chi2 = res; // TODO: take into account also the time!
1429+ float chi2 = mIsCosmics ? resX : res; // TODO: take into account also the time!
14181430
14191431 if (res < mSpaceTolerance ) { // matching ok!
14201432 LOG (DEBUG) << " MATCHING FOUND: We have a match! between track " << mTracksSectIndexCache [indices[0 ]][itrk] << " and TOF cluster " << mTOFClusSectIndexCache [indices[0 ]][itof];
14211433 foundCluster = true ;
14221434 // set event indexes (to be checked)
14231435 evIdx eventIndexTOFCluster (trefTOF.getEntryInTree (), mTOFClusSectIndexCache [indices[0 ]][itof]);
14241436 evGIdx eventIndexTracks (mCurrTracksTreeEntry , {uint32_t (mTracksSectIndexCache [indices[0 ]][itrk]), o2::dataformats::GlobalTrackID::TPC});
1425- mMatchedTracksPairs .emplace_back (eventIndexTOFCluster, chi2, trkLTInt[ibc][iPropagation], eventIndexTracks); // TODO: check if this is correct!
1437+ mMatchedTracksPairs .emplace_back (eventIndexTOFCluster, chi2, trkLTInt[ibc][iPropagation], eventIndexTracks, resZ / vdrift * side, trefTOF. getZ () ); // TODO: check if this is correct!
14261438 }
14271439 }
14281440 }
0 commit comments