16#ifndef ALICEO2_GLOBTRACKING_MATCHTPCITS_
17#define ALICEO2_GLOBTRACKING_MATCHTPCITS_
19#define _ALLOW_DEBUG_TREES_
21#define _ALLOW_DEBUG_AB_
29#include <TStopwatch.h>
59#if !defined(__CINT__) && !defined(__MAKECINT__) && !defined(__ROOTCLING__) && !defined(__CLING__)
71namespace globaltracking
78template <
typename TruthElement>
103namespace globaltracking
272 const auto& link =
getLink(linkID);
276 linkID = link.parentID;
284 const auto& link =
getLink(linkID);
288 linkID = link.parentID;
309#ifndef ENABLE_UPGRADES
353#if !defined(__CINT__) && !defined(__MAKECINT__) && !defined(__ROOTCLING__) && !defined(__CLING__)
418#ifdef ENABLE_UPGRADES
450#ifdef _ALLOW_DEBUG_TREES_
470 mDebugTreeFileName =
name;
484 void updateTimeDependentParams();
487 std::array<int, MaxLadderCand>& lad2Check)
const;
489 std::array<int, MatchTPCITS::MaxLadderCand>& lad2Check)
const;
490 bool prepareTPCData();
491 bool prepareITSData();
492 bool prepareFITData();
493 int prepareInteractionTimes();
494 int prepareTPCTracksAfterBurner();
498 float trackY,
float trackZ,
float tolerY,
float tolerZ)
const;
499 void fillClustersForAfterBurner(
int rofStart,
int nROFs,
ITSChipClustersRefs& itsChipClRefs);
502 void doMatching(
int sec);
504 bool refitTPCInward(
o2::track::TrackParCov& trcIn,
float& chi2,
float xTgt,
int trcID,
float timeTB)
const;
506 void selectBestMatches();
507 bool validateTPCMatch(
int iTPC);
508 void removeITSfromTPC(
int itsID,
int tpcID);
509 void removeTPCfromITS(
int tpcID,
int itsID);
521 bool registerMatchRecordTPC(
int iITS,
int iTPC,
float chi2,
int candIC =
MinusOne);
522 void registerMatchRecordITS(
int iITS,
int iTPC,
float chi2,
int candIC =
MinusOne);
523 void suppressMatchRecordITS(
int iITS,
int iTPC);
526 int getNMatchRecordsTPC(
const TrackLocTPC& tTPC)
const;
529 int getNMatchRecordsITS(
const TrackLocITS& tITS)
const;
535 int time2ITSROFrameCont(
float t)
const
537 int rof = (t - mITSTimeBiasMUS) * mITSROFrameLengthMUSInv;
542 return rof <
int(mITSTrackROFContMapping.size()) ? mITSTrackROFContMapping[rof] : mITSTrackROFContMapping.back();
546 int time2ITSROFrameTrig(
float t,
int start)
const
548 t -= mITSTimeBiasMUS;
549 while (
start <
int(mITSROFTimes.size())) {
550 if (mITSROFTimes[
start].getMax() > t) {
559 float tpcTimeBin2Z(
float tbn)
const {
return tbn * mTPCBin2Z; }
562 float tpcTimeBin2MUS(
float tbn)
const {
return tbn * mTPCTBinMUS; }
565 float tpcTimeBin2NS(
float tbn)
const {
return tbn * mTPCTBinNS; }
568 float z2TPCBin(
float z)
const {
return z * mZ2TPCBin; }
571 float tpcBin2Z(
float t)
const {
return t * mTPCBin2Z; }
574 int roughCheckDif(
float delta,
float toler,
int rejFlag)
const
576 return delta > toler ? rejFlag : (delta < -toler ? -rejFlag :
Accept);
580 int prepareABSeeds();
581 void processABSeed(
int sid,
const ITSChipClustersRefs& itsChipClRefs, uint8_t tID);
582 int followABSeed(
const o2::track::TrackParCov& seed,
const ITSChipClustersRefs& itsChipClRefs,
int seedID,
int lrID, TPCABSeed& ABSeed);
583 int registerABTrackLink(TPCABSeed& ABSeed,
const o2::track::TrackParCov& trc,
int clID,
int parentID,
int lr,
int laddID,
float chi2Cl);
584 bool isBetter(
float chi2A,
float chi2B) {
return chi2A < chi2B; }
585 void accountForOverlapsAB(
int lrSeed);
586 float correctTPCTrack(
o2::track::TrackParCov& trc,
const TrackLocTPC& tTPC,
const InteractionCandidate& cand)
const;
589 bool mInitDone =
false;
590 bool mFieldON =
true;
591 bool mCosmics =
false;
592 bool mMCTruthON =
false;
597 int mNTPCOccBinLength = 0;
598 float mNTPCOccBinLengthInv;
602 const Params* mParams =
nullptr;
605 MatCorrType mUseMatCorrFlag = MatCorrType::USEMatCorrTGeo;
606 bool mUseBCFilling =
false;
607 bool mSkipTPCOnly =
false;
608 bool mITSTriggered =
false;
609 bool mUseFT0 =
false;
612 bool mCompareTracksDZ =
false;
614 float YMaxAtXMatchingRef = 999.;
616 float mSectEdgeMargin = 0.;
620 float mTPCTimeEdgeTSafeMargin = 0.f;
621 float mTPCExtConstrainedNSigmaInv = 0.f;
622 int mITSROFrameLengthInBC = 0;
623 float mITSROFrameLengthMUS = -1.;
624 float mITSTimeResMUS = -1.;
625 float mITSROFrameLengthMUSInv = -1.;
626 int mITSTimeBiasInBC = 0;
627 float mITSTimeBiasMUS = 0.;
628 float mTPCVDrift = -1.;
629 float mTPCVDriftInv = -1.;
630 float mTPCDriftTimeOffset = 0;
631 float mTPCTBinMUS = 0.;
632 float mTPCTBinNS = 0.;
633 float mTPCTBinMUSInv = 0.;
634 float mZ2TPCBin = 0.;
635 float mTPCBin2Z = 0.;
636 float mNTPCBinsFullDrift = 0.;
638 float mTPCmeanX0Inv = 1. / 31850.;
640 float mMinTPCTrackPtInv = 999.;
641 float mMinITSTrackPtInv = 999.;
642 bool mVDriftCalibOn =
false;
646 std::unique_ptr<o2::gpu::GPUO2InterfaceRefit> mTPCRefitter;
649 std::array<int16_t, o2::constants::lhc::LHCMaxBunches> mClosestBunchAbove;
650 std::array<int16_t, o2::constants::lhc::LHCMaxBunches> mClosestBunchBelow;
652 std::array<float, 5> mCovDiagInner{};
653 std::array<float, 5> mCovDiagOuter{};
660 gsl::span<const o2::tpc::TrackTPC> mTPCTracksArray;
661 gsl::span<const o2::tpc::TPCClRefElem> mTPCTrackClusIdx;
662 gsl::span<const o2::itsmft::ROFRecord> mITSTrackROFRec;
663 gsl::span<const o2::its::TrackITS> mITSTracksArray;
664 gsl::span<const int> mITSTrackClusIdx;
665 std::vector<ITSCluster> mITSClustersArray;
666 std::vector<uint8_t> mITSClusterSizes;
668 gsl::span<const o2::itsmft::ROFRecord> mITSClusterROFRec;
669 gsl::span<const o2::ft0::RecPoints> mFITInfo;
671 gsl::span<const unsigned char> mTPCRefitterShMap;
672 gsl::span<const unsigned int> mTPCRefitterOccMap;
675#ifdef ENABLE_UPGRADES
682 gsl::span<const o2::MCCompLabel> mITSTrkLabels;
683 gsl::span<const o2::MCCompLabel> mTPCTrkLabels;
686 size_t mNMatches = 0;
687 size_t mNCalibPrelim = 0;
688 size_t mNMatchesControl = 0;
690 size_t mNABRefsClus = 0;
691 float mAB2MatchGuess = 0.2;
692 std::vector<InteractionCandidate> mInteractions;
693 std::vector<int> mInteractionMUSLUT;
696 std::vector<MatchRecord> mMatchRecordsTPC;
698 std::vector<MatchRecord> mMatchRecordsITS;
701 std::vector<BracketF> mITSROFTimes;
702 std::vector<TrackLocTPC> mTPCWork;
703 std::vector<TrackLocITS> mITSWork;
704 std::vector<o2::MCCompLabel> mTPCLblWork;
705 std::vector<o2::MCCompLabel> mITSLblWork;
706 std::vector<float> mWinnerChi2Refit;
707 std::vector<float> mTBinClOcc;
710 std::vector<TPCABSeed> mTPCABSeeds;
712 std::vector<int> mTPCABIndexCache;
713 std::vector<int> mABWinnersIDs;
714 std::vector<int> mABClusterLinkIndex;
715 LinksPoolMT mABLinksPool;
728 std::vector<int> mITSTrackROFContMapping;
732#ifdef _ALLOW_DEBUG_TREES_
733 std::unique_ptr<o2::utils::TreeStreamRedirector> mDBGOut;
734 UInt_t mDBGFlags = 0;
735 std::string mDebugTreeFileName =
"dbg_TPCITSmatch.root";
739 static constexpr float Tan70 = 2.74747771e+00;
740 static constexpr float Cos70I2 = 1. + Tan70 * Tan70;
741 static constexpr float MaxSnp = 0.9;
742 static constexpr float MaxTgp = 2.064;
743 static constexpr float MinTBToCleanCache = 600.;
746 enum TimerIDs { SWTot,
759 static constexpr std::string_view TimerName[] = {
"Total",
"PrepareITS",
"PrepareTPC",
"DoMatching",
"SelectBest",
"Refit",
760 "ABSeeds",
"ABMatching",
"ABWinners",
"ABRefit",
"IO",
"Debug"};
761 TStopwatch mTimer[NStopWatches];
765inline bool MatchTPCITS::isValidatedTPC(
const TrackLocTPC& t)
const
767 return t.matchID >
MinusOne && mMatchRecordsTPC[t.matchID].nextRecID ==
Validated;
771inline bool MatchTPCITS::isValidatedITS(
const TrackLocITS& t)
const
773 return t.matchID >
MinusOne && mMatchRecordsITS[t.matchID].nextRecID ==
Validated;
777inline bool MatchTPCITS::isDisabledITS(
const TrackLocITS& t)
const {
return t.matchID < 0; }
780inline bool MatchTPCITS::isDisabledTPC(
const TrackLocTPC& t)
const {
return t.matchID < 0; }
Helper class to read the binary format of TPC ClusterNative.
Helper class to access correction maps.
Definition of the BuildTopologyDictionary class for ITS3.
Class to store event ID and index in the event for objects like track, cluster...
Global index for barrel track: provides provenance (detectors combination), index in respective array...
Configurable params for TPC ITS matching.
Declarations of 2D primitives.
Class to refer to the 1st entry and N elements of some group in the continuous container.
Declarations of the helper class for clusters / roadwidth matching.
o2::track::TrackParCov TrackParCov
Definition of the ITS track.
Result of refitting TPC-ITS matched track.
Reference on ITS/MFT clusters set.
calibration data from laser track calibration
bool isITSTriggered() const
void setUseMatCorrFlag(MatCorrType f)
void setDebugTreeFileName(std::string name)
get the name of output debug file
static constexpr int MaxLadderCand
void fillCalibDebug(int ifit, int iTPC, const o2::dataformats::TrackTPCITS &match, pmr::vector< o2::dataformats::Triplet< float, float, float > > &calib)
void setUseBCFilling(bool v)
void reportTiming()
clear results of previous event reco
bool getUseBCFilling() const
set ITS ROFrame duration in microseconds
void setITSROFrameLengthMUS(float fums)
set ITS ROFrame duration in BC (continuous mode only)
@ MatchTreeAccOnly
fill the matching candidates tree only once the cut is passed
@ TPCOrigTree
original TPC tracks with some aux info
@ MatchTreeAll
produce matching candidates tree for all candidates
@ WinnerMatchesTree
separate debug tree for winner matches
void clear()
set Bunch filling and init helpers for validation by BCs
void refitWinners(pmr::vector< o2::dataformats::TrackTPCITS > &matchedTracks, pmr::vector< o2::MCCompLabel > &matchLabels, pmr::vector< o2::dataformats::Triplet< float, float, float > > &calib)
void refitABWinners(pmr::vector< o2::dataformats::TrackTPCITS > &matchedTracks, pmr::vector< o2::MCCompLabel > &matchLabels, pmr::vector< o2::MCCompLabel > &ABTrackletLabels, pmr::vector< int > &ABTrackletClusterIDs, pmr::vector< o2::itsmft::TrkClusRef > &ABTrackletRefs, pmr::vector< o2::dataformats::Triplet< float, float, float > > &calib)
bool refitABTrack(int iITSAB, const TPCABSeed &seed, pmr::vector< o2::dataformats::TrackTPCITS > &matchedTracks, pmr::vector< int > &ABTrackletClusterIDs, pmr::vector< o2::itsmft::TrkClusRef > &ABTrackletRefs)
void setTPCVDrift(const o2::tpc::VDriftCorrFact &v)
void setNHBPerTF(int n)
ITS readout mode.
bool isDebugFlag(UInt_t flags) const
get debug trees flags
void setITSTriggered(bool v)
void printCandidatesITS() const
bool runAfterBurner(pmr::vector< o2::dataformats::TrackTPCITS > &matchedTracks, pmr::vector< o2::MCCompLabel > &matchLabels, pmr::vector< o2::MCCompLabel > &ABTrackletLabels, pmr::vector< int > &ABTrackletClusterIDs, pmr::vector< o2::itsmft::TrkClusRef > &ABTrackletRefs, pmr::vector< o2::dataformats::Triplet< float, float, float > > &calib)
void setTPCCorrMaps(o2::gpu::CorrectionMapsHelper *maph)
print settings
void reportSizes(pmr::vector< o2::dataformats::TrackTPCITS > &matchedTracks, pmr::vector< o2::itsmft::TrkClusRef > &ABTrackletRefs, pmr::vector< int > &ABTrackletClusterIDs, pmr::vector< o2::MCCompLabel > &matchLabels, pmr::vector< o2::MCCompLabel > &ABTrackletLabels, pmr::vector< o2::dataformats::Triplet< float, float, float > > &calib)
void printCandidatesTPC() const
void setSkipTPCOnly(bool v)
void setMCTruthOn(bool v)
request VDrift calibration
static constexpr int MaxSeedsPerLayer
void fillTPCITSmatchTree(int itsID, int tpcID, int rejFlag, float chi2=-1., float tCorr=0.)
bool refitTrackTPCITS(int slot, int iTPC, int &iITS, pmr::vector< o2::dataformats::TrackTPCITS > &matchedTracks, pmr::vector< o2::MCCompLabel > &matchLabels, pmr::vector< o2::dataformats::Triplet< float, float, float > > &calib)
static constexpr int MaxUpDnLadders
int getITSTimeBiasInBC() const
float getITSTimeBiasMUS() const
void run(const o2::globaltracking::RecoContainer &inp, pmr::vector< o2::dataformats::TrackTPCITS > &matchedTracks, pmr::vector< o2::itsmft::TrkClusRef > &ABTrackletRefs, pmr::vector< int > &ABTrackletClusterIDs, pmr::vector< o2::MCCompLabel > &matchLabels, pmr::vector< o2::MCCompLabel > &ABTrackletLabels, pmr::vector< o2::dataformats::Triplet< float, float, float > > &calib)
void setVDriftCalib(bool v)
void setBunchFilling(const o2::BunchFilling &bf)
void dumpTPCOrig(bool acc, int tpcIndex)
void setDebugFlag(UInt_t flag, bool on=true)
set the name of output debug file
void setITSROFrameLengthInBC(int nbc)
void setITSTimeBiasInBC(int n)
o2::globaltracking::MatchTPCITSParams Params
void setITSDictionary(const o2::itsmft::TopologyDictionary *d)
set flag to use MC truth
static constexpr int NITSLayers
perform matching for provided input
const std::string & getDebugTreeFileName() const
fill matching debug tree
auto getUseMatCorrFlag() const
UInt_t getDebugFlags() const
set or unset debug stream flag
void setNThreads(int n)
perform all initializations
HMPID cluster implementation.
bool match(const std::vector< std::string > &queries, const char *pattern)
GLuint const GLchar * name
GLuint GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat t0
GLdouble GLdouble GLdouble z
constexpr int Validated
flags to tell the status of TPC-ITS tracks comparison
std::vector< T, o2::pmr::polymorphic_allocator< T > > vector
a couple of static helper functions to create timestamp values for CCDB queries or override obsolete ...
float chi2
chi2 after update
int parentID
ID of the parent link (on prev layer) or parent TPC seed.
uint8_t nDaughters
number of daughter links on lower layers
static constexpr int Disabled
uint8_t ladderID
ladder ID in the layer (used for seeds with 2 hits in the layer)
int8_t nContLayers
number of contributing layers
ABTrackLink(const o2::track::TrackParCov &tr, int cl, int parID, int nextID, int lr, int nc, int ld, float _chi2)
int clID
ID of the attached cluster, MinusOne: no attachment on this layer.
float chi2NormPredict(float chi2cl) const
int nextOnLr
ID of the next (in quality) link on the same layer.
std::array< ClusRange, o2::its::RecoGeomHelper::getNChips()> chipRefs
ITSChipClustersRefs(int nclIni=50000)
std::vector< int > clusterID
size_t capInternal() const
size_t sizeInternal() const
o2::dataformats::RangeReference< int, int > ClusRange
o2::math_utils::Bracketf_t tBracket
o2::dataformats::RangeReference< int, int > seedsRef
InteractionCandidate(const o2::InteractionRecord &ir, float t, float dt, int rof, uint32_t f=0)
std::vector< std::deque< ABTrackLink > > threadPool
bool isBetter(const MatchRecord &other) const
int partnerID
id of parnter track entry in mTPCWork or mITSWork containers
int nextRecID
index of eventual next record
int matchedIC
index of eventually matched InteractionCandidate
MatchRecord(int partID, float chi2match, int nxt=MinusOne, int candIC=MinusOne)
bool isBetter(float otherChi2, int otherIC=MinusOne) const
auto getBestLinkID() const
std::array< int, o2::its::RecoGeomHelper::getNLayers()> firstInLr
entry of 1st (best) hypothesis on each layer
void flagLinkUsedClusters(int linkID, std::vector< int > &clStatus) const
int8_t status
status (RS TODO)
size_t sizeInternal() const
int8_t getNLayers() const
int winLinkID
ID of the validated link.
TPCABSeed(int id, int ic, const o2::track::TrackParCov &trc)
void addLink(const o2::track::TrackParCov &trc, int clID, int parentID, int nextID, int lr, int nc, int laddID, float chi2)
const ABTrackLink & getLink(int i) const
size_t capInternal() const
int ICCanID
interaction candidate ID (they are sorted in increasing time)
ABTrackLink & getLink(int i)
uint32_t linksEntry
1st entry of the link
uint8_t threadID
thread ID
static constexpr int8_t NeedAlternative
o2::track::TrackParCov track
Seed propagated to the outer layer under certain time constraint.
int nLinks
number of links
bool checkLinkHasUsedClusters(int linkID, const std::vector< int > &clStatus) const
static LinksPoolMT * gLinksPool
pool of links per thread
bool needAlteranative() const
void setNeedAlternative()
int8_t lowestLayer
lowest layer reached
int roFrame
ITS readout frame assigned to this track.
o2::math_utils::Bracketf_t tBracket
bracketing time in \mus
bool hasCloneAfter() const
int getCloneShift() const
float dL
distance integrated during propagation to reference X (as pion)
int matchID
entry (non if MinusOne) of its matchCand struct in the mMatchesITS
float xrho
x*rho seen during propagation to reference X (as pion)
int sourceID
track origin id
ClassDefNV(TrackLocITS, 1)
bool hasCloneBefore() const
float time0
nominal time in \mus since start of TF (time0 for bare TPC tracks, constrained time for TRD/TOF const...
int sourceID
TPC track origin in.
float getSignedDT(float dt) const
o2::math_utils::Bracketf_t tBracket
bracketing time in \mus
int matchID
entry (non if MinusOne) of its matchTPC struct in the mMatchesTPC
float getCorrectedTime(float dt) const
float timeErr
time sigma (makes sense for constrained tracks only)
ClassDefNV(TrackLocTPC, 3)
o2::dataformats::GlobalTrackID gid
static constexpr int getNLayers()
static constexpr int getNChips()
VectorOfTObjectPtrs other
o2::InteractionRecord ir(0, 0)