3838
3939#include " TPCBase/ParameterGas.h"
4040#include " TPCBase/ParameterElectronics.h"
41+ #include " TPCReconstruction/TPCFastTransformHelperO2.h"
4142
4243using namespace o2 ::globaltracking;
4344using evGIdx = o2::dataformats::EvIndex<int , o2::dataformats::GlobalTrackID>;
@@ -49,6 +50,7 @@ ClassImp(MatchTOF);
4950void MatchTOF::run ()
5051{
5152 // /< running the matching
53+ updateTimeDependentParams ();
5254
5355 if (!mWFInputAttached && !mSAInitDone ) {
5456 LOG (ERROR) << " run called with mSAInitDone=" << mSAInitDone << " and mWFInputAttached=" << mWFInputAttached ;
@@ -449,10 +451,7 @@ bool MatchTOF::prepareTracks()
449451 mTracksSectIndexCache [sec].reserve (100 + 1.2 * mNumOfTracks / o2::constants::math::NSectors);
450452 }
451453
452- // getting Bz (mag field)
453- auto o2field = static_cast <o2::field::MagneticField*>(TGeoGlobalMagField::Instance ()->GetField ());
454- float bzField = o2field->solenoidField (); // magnetic field in kGauss
455- float maxInvPt = abs (bzField) > 0.1 ? 1 . / (abs (bzField) * 0.05 ) : 999 .;
454+ float maxInvPt = abs (mBz ) > 0.1 ? 1 . / (abs (mBz ) * 0.05 ) : 999 .;
456455
457456 LOG (DEBUG) << " \n\n We have %d tracks to try to match to TOF: " << mNumOfTracks ;
458457 int nNotPropagatedToTOF = 0 ;
@@ -479,7 +478,7 @@ bool MatchTOF::prepareTracks()
479478 LOG (DEBUG) << " Global coordinates Before propagating to 371 cm: globalPos[0] = " << globalPos[0 ] << " , globalPos[1] = " << globalPos[1 ] << " , globalPos[2] = " << globalPos[2 ];
480479 LOG (DEBUG) << " Radius xy Before propagating to 371 cm = " << TMath::Sqrt (globalPos[0 ] * globalPos[0 ] + globalPos[1 ] * globalPos[1 ]);
481480 LOG (DEBUG) << " Radius xyz Before propagating to 371 cm = " << TMath::Sqrt (globalPos[0 ] * globalPos[0 ] + globalPos[1 ] * globalPos[1 ] + globalPos[2 ] * globalPos[2 ]);
482- if (!propagateToRefXWithoutCov (trc, mXRef , 2 , bzField )) { // we first propagate to 371 cm without considering the covariance matrix
481+ if (!propagateToRefXWithoutCov (trc, mXRef , 2 , mBz )) { // we first propagate to 371 cm without considering the covariance matrix
483482 nNotPropagatedToTOF++;
484483 continue ;
485484 }
@@ -567,10 +566,7 @@ bool MatchTOF::prepareTPCTracks()
567566 mTPCTracksSectIndexCache [sec].reserve (100 + 1.2 * mNumOfTracks / o2::constants::math::NSectors);
568567 }
569568
570- // getting Bz (mag field)
571- auto o2field = static_cast <o2::field::MagneticField*>(TGeoGlobalMagField::Instance ()->GetField ());
572- float bzField = o2field->solenoidField (); // magnetic field in kGauss
573- float maxInvPt = abs (bzField) > 0.1 ? 1 . / (abs (bzField) * 0.05 ) : 999 .;
569+ float maxInvPt = abs (mBz ) > 0.1 ? 1 . / (abs (mBz ) * 0.05 ) : 999 .;
574570 int nclustersMin = 0 ;
575571 LOG (INFO) << " Max track Inv pT allowed = " << maxInvPt;
576572 LOG (INFO) << " Min track Nclusters allowed = " << nclustersMin;
@@ -584,10 +580,10 @@ bool MatchTOF::prepareTPCTracks()
584580 // create working copy of track param
585581 timeEst timeInfo;
586582 // set
587- timeInfo.setTimeStamp (trcOrig.getTime0 () * o2::tpc::ParameterElectronics::Instance (). ZbinWidth );
588- timeInfo.setTimeStampError ((trcOrig.getDeltaTBwd () + 5 ) * o2::tpc::ParameterElectronics::Instance (). ZbinWidth );
583+ timeInfo.setTimeStamp (trcOrig.getTime0 () * mTPCTBinMUS );
584+ timeInfo.setTimeStampError ((trcOrig.getDeltaTBwd () + 5 ) * mTPCTBinMUS );
589585 mSideTPC .push_back (trcOrig.hasASideClustersOnly () ? 1 : (trcOrig.hasCSideClustersOnly () ? -1 : 0 ));
590- mExtraTPCFwdTime .push_back ((trcOrig.getDeltaTFwd () + 5 ) * o2::tpc::ParameterElectronics::Instance (). ZbinWidth );
586+ mExtraTPCFwdTime .push_back ((trcOrig.getDeltaTFwd () + 5 ) * mTPCTBinMUS );
591587
592588 o2::track::TrackLTIntegral intLT0; // mTPCTracksWork.back().getLTIntegralOut(); // we get the integrated length from TPC-ITC outward propagation
593589 // make a copy of the TPC track that we have to propagate
@@ -617,7 +613,7 @@ bool MatchTOF::prepareTPCTracks()
617613 // the "very rough" propagation worked; now we can propagate considering also the cov matrix
618614#endif
619615
620- if (!propagateToRefXWithoutCov (trc, mXRef , 10 , bzField )) { // we first propagate to 371 cm without considering the covariance matrix
616+ if (!propagateToRefXWithoutCov (trc, mXRef , 10 , mBz )) { // we first propagate to 371 cm without considering the covariance matrix
621617 nNotPropagatedToTOF++;
622618 continue ;
623619 }
@@ -1137,7 +1133,6 @@ void MatchTOF::doMatching(int sec)
11371133// ______________________________________________
11381134void MatchTOF::doMatchingForTPC (int sec)
11391135{
1140- printf (" here, DoMatch\n " );
11411136 auto & gasParam = o2::tpc::ParameterGas::Instance ();
11421137 float vdrift = gasParam.DriftV ;
11431138
@@ -1542,7 +1537,7 @@ void MatchTOF::selectBestMatches()
15421537bool MatchTOF::propagateToRefX (o2::track::TrackParCov& trc, float xRef, float stepInCm, o2::track::TrackLTIntegral& intLT)
15431538{
15441539 // propagate track to matching reference X
1545- o2::base::Propagator::MatCorrType matCorr = o2::base::Propagator::MatCorrType::USEMatCorrTGeo ; // material correction method
1540+ o2::base::Propagator::MatCorrType matCorr = o2::base::Propagator::MatCorrType::USEMatCorrLUT ; // material correction method
15461541 const float tanHalfSector = tan (o2::constants::math::SectorSpanRad / 2 );
15471542 bool refReached = false ;
15481543 float xStart = trc.getX ();
@@ -1668,3 +1663,75 @@ void MatchTOF::fillTOFmatchTreeWithLabels(const char* trname, int cacheTOF, int
16681663 }
16691664 mTimerDBG .Stop ();
16701665}
1666+
1667+ // ______________________________________________
1668+ void MatchTOF::updateTimeDependentParams ()
1669+ {
1670+ // /< update parameters depending on time (once per TF)
1671+ auto & elParam = o2::tpc::ParameterElectronics::Instance ();
1672+ auto & gasParam = o2::tpc::ParameterGas::Instance ();
1673+ mTPCTBinMUS = elParam.ZbinWidth ; // TPC bin in microseconds
1674+ mTPCTBinMUSInv = 1 . / mTPCTBinMUS ;
1675+ mTPCBin2Z = mTPCTBinMUS * gasParam.DriftV ;
1676+
1677+ mBz = o2::base::Propagator::Instance ()->getNominalBz ();
1678+ }
1679+
1680+ // _________________________________________________________
1681+ bool MatchTOF::makeConstrainedTPCTrack (int matchedID, o2::dataformats::TrackTPCTOF& trConstr)
1682+ {
1683+ auto & match = mMatchedTracks [matchedID];
1684+ const auto & tpcTrOrig = mTPCTracksArrayInp [match.getTrackIndex ()];
1685+ const auto & tofCl = mTOFClustersArrayInp [match.getTOFClIndex ()];
1686+ const auto & intLT = match.getLTIntegralOut ();
1687+ // correct the time of the track
1688+ auto timeTOFMUS = (tofCl.getTime () - intLT.getTOF (o2::track::PID::Pion)) * 1e-6 ; // tof time in \mus, FIXME: account for time of flight to R TOF
1689+ auto timeTOFTB = timeTOFMUS * mTPCTBinMUSInv ; // TOF time in TPC timebins
1690+ auto deltaTBins = timeTOFTB - tpcTrOrig.getTime0 (); // time shift in timeBins
1691+ float timeErr = 0.010 ; // assume 10 ns error FIXME
1692+ auto dzCorr = deltaTBins * mTPCBin2Z ;
1693+
1694+ if (mTPCClusterIdxStruct ) { // refit was requested
1695+ trConstr.o2 ::track::TrackParCov::operator =(tpcTrOrig.getOuterParam ()); // seed for inward refit of constrained track, made from the outer param
1696+ } else {
1697+ trConstr.o2 ::track::TrackParCov::operator =(tpcTrOrig); // inner param, we just correct is position, w/o refit
1698+ }
1699+
1700+ auto zTrack = trConstr.getZ ();
1701+
1702+ if (tpcTrOrig.hasASideClustersOnly ()) {
1703+ zTrack += dzCorr;
1704+ } else if (tpcTrOrig.hasCSideClustersOnly ()) {
1705+ zTrack -= dzCorr;
1706+ } else {
1707+ // TODO : special treatment of tracks crossing the CE
1708+ }
1709+ trConstr.setZ (zTrack);
1710+ trConstr.setTimeMUS (timeTOFMUS, timeErr);
1711+ trConstr.setRefMatch (matchedID);
1712+ if (mTPCClusterIdxStruct ) { // refit was requested
1713+ float chi2 = 0 ;
1714+ mTPCRefitter ->setTrackReferenceX (o2::globaltracking::MatchTPCITS::XTPCInnerRef);
1715+ if (mTPCRefitter ->RefitTrackAsTrackParCov (trConstr, tpcTrOrig.getClusterRef (), timeTOFTB, &chi2, false , true ) < 0 ) { // outward refit after resetting cov.mat.
1716+ LOG (DEBUG) << " Refit failed" ;
1717+ return false ;
1718+ }
1719+ trConstr.setChi2Refit (chi2);
1720+ }
1721+
1722+ return true ;
1723+ }
1724+
1725+ // _________________________________________________________
1726+ void MatchTOF::checkRefitter ()
1727+ {
1728+ if (mTPCClusterIdxStruct ) {
1729+ if (!mTPCTransform ) { // eventually, should be updated at every TF?
1730+ mTPCTransform = o2::tpc::TPCFastTransformHelperO2::instance ()->create (0 );
1731+ }
1732+
1733+ mTPCRefitter = std::make_unique<o2::gpu::GPUO2InterfaceRefit>(mTPCClusterIdxStruct , mTPCTransform .get (), mBz ,
1734+ mTPCTrackClusIdx .data (), mTPCRefitterShMap .data (),
1735+ nullptr , o2::base::Propagator::Instance ());
1736+ }
1737+ }
0 commit comments