16#ifndef ALICEO2_GLOBTRACKING_MATCHTPCITS_
17#define ALICEO2_GLOBTRACKING_MATCHTPCITS_
19#define _ALLOW_DEBUG_TREES_
21#define _ALLOW_DEBUG_AB_
29#include <TStopwatch.h>
58#if !defined(__CINT__) && !defined(__MAKECINT__) && !defined(__ROOTCLING__) && !defined(__CLING__)
70namespace globaltracking
77template <
typename TruthElement>
102namespace globaltracking
275 linkID =
link.parentID;
287 linkID =
link.parentID;
308#ifndef ENABLE_UPGRADES
352#if !defined(__CINT__) && !defined(__MAKECINT__) && !defined(__ROOTCLING__) && !defined(__CLING__)
417#ifdef ENABLE_UPGRADES
449#ifdef _ALLOW_DEBUG_TREES_
469 mDebugTreeFileName =
name;
483 void updateTimeDependentParams();
486 std::array<int, MaxLadderCand>& lad2Check)
const;
488 std::array<int, MatchTPCITS::MaxLadderCand>& lad2Check)
const;
489 bool prepareTPCData();
490 bool prepareITSData();
491 bool prepareFITData();
492 int prepareInteractionTimes();
493 int prepareTPCTracksAfterBurner();
497 float trackY,
float trackZ,
float tolerY,
float tolerZ)
const;
498 void fillClustersForAfterBurner(
int rofStart,
int nROFs,
ITSChipClustersRefs& itsChipClRefs);
501 void doMatching(
int sec);
503 bool refitTPCInward(
o2::track::TrackParCov& trcIn,
float& chi2,
float xTgt,
int trcID,
float timeTB)
const;
505 void selectBestMatches();
506 bool validateTPCMatch(
int iTPC);
507 void removeITSfromTPC(
int itsID,
int tpcID);
508 void removeTPCfromITS(
int tpcID,
int itsID);
520 bool registerMatchRecordTPC(
int iITS,
int iTPC,
float chi2,
int candIC =
MinusOne);
521 void registerMatchRecordITS(
int iITS,
int iTPC,
float chi2,
int candIC =
MinusOne);
522 void suppressMatchRecordITS(
int iITS,
int iTPC);
525 int getNMatchRecordsTPC(
const TrackLocTPC& tTPC)
const;
528 int getNMatchRecordsITS(
const TrackLocITS& tITS)
const;
534 int time2ITSROFrameCont(
float t)
const
536 int rof = (t - mITSTimeBiasMUS) * mITSROFrameLengthMUSInv;
541 return rof <
int(mITSTrackROFContMapping.size()) ? mITSTrackROFContMapping[rof] : mITSTrackROFContMapping.back();
545 int time2ITSROFrameTrig(
float t,
int start)
const
547 t -= mITSTimeBiasMUS;
548 while (
start <
int(mITSROFTimes.size())) {
549 if (mITSROFTimes[
start].getMax() > t) {
558 float tpcTimeBin2Z(
float tbn)
const {
return tbn * mTPCBin2Z; }
561 float tpcTimeBin2MUS(
float tbn)
const {
return tbn * mTPCTBinMUS; }
564 float tpcTimeBin2NS(
float tbn)
const {
return tbn * mTPCTBinNS; }
567 float z2TPCBin(
float z)
const {
return z * mZ2TPCBin; }
570 float tpcBin2Z(
float t)
const {
return t * mTPCBin2Z; }
573 int roughCheckDif(
float delta,
float toler,
int rejFlag)
const
575 return delta > toler ? rejFlag : (delta < -toler ? -rejFlag :
Accept);
579 int prepareABSeeds();
580 void processABSeed(
int sid,
const ITSChipClustersRefs& itsChipClRefs, uint8_t tID);
581 int followABSeed(
const o2::track::TrackParCov& seed,
const ITSChipClustersRefs& itsChipClRefs,
int seedID,
int lrID, TPCABSeed& ABSeed);
582 int registerABTrackLink(TPCABSeed& ABSeed,
const o2::track::TrackParCov& trc,
int clID,
int parentID,
int lr,
int laddID,
float chi2Cl);
583 bool isBetter(
float chi2A,
float chi2B) {
return chi2A < chi2B; }
584 void accountForOverlapsAB(
int lrSeed);
585 float correctTPCTrack(
o2::track::TrackParCov& trc,
const TrackLocTPC& tTPC,
const InteractionCandidate& cand)
const;
588 bool mInitDone =
false;
589 bool mFieldON =
true;
590 bool mCosmics =
false;
591 bool mMCTruthON =
false;
596 int mNTPCOccBinLength = 0;
597 float mNTPCOccBinLengthInv;
601 const Params* mParams =
nullptr;
604 MatCorrType mUseMatCorrFlag = MatCorrType::USEMatCorrTGeo;
605 bool mUseBCFilling =
false;
606 bool mSkipTPCOnly =
false;
607 bool mITSTriggered =
false;
608 bool mUseFT0 =
false;
611 bool mCompareTracksDZ =
false;
613 float YMaxAtXMatchingRef = 999.;
615 float mSectEdgeMargin = 0.;
619 float mTPCTimeEdgeTSafeMargin = 0.f;
620 float mTPCExtConstrainedNSigmaInv = 0.f;
621 int mITSROFrameLengthInBC = 0;
622 float mITSROFrameLengthMUS = -1.;
623 float mITSTimeResMUS = -1.;
624 float mITSROFrameLengthMUSInv = -1.;
625 int mITSTimeBiasInBC = 0;
626 float mITSTimeBiasMUS = 0.;
627 float mTPCVDrift = -1.;
628 float mTPCVDriftInv = -1.;
629 float mTPCDriftTimeOffset = 0;
630 float mTPCTBinMUS = 0.;
631 float mTPCTBinNS = 0.;
632 float mTPCTBinMUSInv = 0.;
633 float mZ2TPCBin = 0.;
634 float mTPCBin2Z = 0.;
635 float mNTPCBinsFullDrift = 0.;
637 float mTPCmeanX0Inv = 1. / 31850.;
639 float mMinTPCTrackPtInv = 999.;
640 float mMinITSTrackPtInv = 999.;
641 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.
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
void setTPCCorrMaps(const o2::gpu::TPCFastTransformPOD *maph, float lumi)
print settings
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 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, fair::mq::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)