Project
Loading...
Searching...
No Matches
MatchTPCITS.h
Go to the documentation of this file.
1// Copyright 2019-2020 CERN and copyright holders of ALICE O2.
2// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
3// All rights not expressly granted are reserved.
4//
5// This software is distributed under the terms of the GNU General Public
6// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
7//
8// In applying this license CERN does not waive the privileges and immunities
9// granted to it by virtue of its status as an Intergovernmental Organization
10// or submit itself to any jurisdiction.
11
15
16#ifndef ALICEO2_GLOBTRACKING_MATCHTPCITS_
17#define ALICEO2_GLOBTRACKING_MATCHTPCITS_
18
19#define _ALLOW_DEBUG_TREES_ // to allow debug and control tree output
20
21#define _ALLOW_DEBUG_AB_ // fill extra debug info for AB
22
23#include <Rtypes.h>
24#include <array>
25#include <deque>
26#include <vector>
27#include <string>
28#include <gsl/span>
29#include <TStopwatch.h>
53#include "GPUO2InterfaceRefit.h"
54#include "GPUTPCGeometry.h"
60#include "TPCFastTransformPOD.h"
61#if !defined(__CINT__) && !defined(__MAKECINT__) && !defined(__ROOTCLING__) && !defined(__CLING__)
63#endif
64#ifdef ENABLE_UPGRADES
66#endif
67
68class TTree;
69
70namespace o2
71{
72
73namespace globaltracking
74{
75class RecoContainer;
76}
77
78namespace dataformats
79{
80template <typename TruthElement>
82}
83
84namespace its
85{
86class TrackITS;
87}
88
89namespace itsmft
90{
91class Cluster;
92}
93
94namespace tpc
95{
96class TrackTPC;
97class VDriftCorrFact;
98} // namespace tpc
99
100namespace gpu
101{
102struct GPUParam;
103}
104
105namespace globaltracking
106{
107
108constexpr int Zero = 0;
109constexpr int MinusOne = -1;
110constexpr int MinusTen = -10;
111constexpr int Validated = -2;
112
114using ITSClusStatus = std::array<std::vector<int>, o2::its::RecoGeomHelper::getNLayers()>;
115
128
132 enum Constraint_t : uint8_t { Constrained,
136 float time0 = 0.f;
137 float timeErr = 0.f;
138 int sourceID = 0;
139 o2::dataformats::GlobalTrackID gid{}; // global track source ID (TPC track may be part of it)
141 uint8_t lowestRow = -1;
142 uint8_t padFromEdge = -1;
144
145 float getCorrectedTime(float dt) const // return time0 corrected for extra drift (to match certain Z)
146 {
147 return constraint == Constrained ? time0 : (constraint == ASide ? time0 + dt : time0 - dt);
148 }
149 float getSignedDT(float dt) const // account for TPC side in time difference for dt=external_time - tpc.time0
150 {
151 return constraint == Constrained ? 0.f : (constraint == ASide ? dt : -dt);
152 }
153
155};
156
160 enum : uint16_t { CloneBefore = 0x1,
161 CloneAfter = 0x2 };
163 int sourceID = 0;
166 float xrho = 0;
167 float dL = 0;
168 bool hasCloneBefore() const { return getUserField() & CloneBefore; }
169 bool hasCloneAfter() const { return getUserField() & CloneAfter; }
170 int getCloneShift() const { return hasCloneBefore() ? -1 : (hasCloneAfter() ? 1 : 0); }
171 void setCloneBefore() { setUserField(getUserField() | CloneBefore); }
172 void setCloneAfter() { setUserField(getUserField() | CloneAfter); }
173
175};
176
180 float chi2 = -1.f;
184 MatchRecord(int partID, float chi2match, int nxt = MinusOne, int candIC = MinusOne) : partnerID(partID), chi2(chi2match), nextRecID(nxt), matchedIC(candIC) {}
185 MatchRecord() = default;
186
187 bool isBetter(float otherChi2, int otherIC = MinusOne) const
188 { // prefer record with matched IC candidate, otherwise, better chi2
189 if (otherIC == MinusOne) {
190 return matchedIC == MinusOne ? chi2 < otherChi2 : true;
191 } else {
192 return matchedIC == MinusOne ? false : chi2 < otherChi2;
193 }
194 }
195
196 bool isBetter(const MatchRecord& other) const
197 {
198 return isBetter(other.chi2, other.matchedIC);
199 }
200};
201
205 static constexpr int Disabled = -2;
209 uint8_t nDaughters = 0;
210 int8_t layerID = -1;
211 int8_t nContLayers = 0;
212 uint8_t ladderID = 0xff;
213 float chi2 = 0.f;
214
215 ABTrackLink() = default;
216 ~ABTrackLink() = default;
217 ABTrackLink(const o2::track::TrackParCov& tr, int cl, int parID, int nextID, int lr, int nc, int ld, float _chi2)
218 : o2::track::TrackParCov(tr), clID(cl), parentID(parID), nextOnLr(nextID), layerID(int8_t(lr)), nContLayers(int8_t(nc)), ladderID(uint8_t(ld)), chi2(_chi2) {}
219
220 bool isDisabled() const { return clID == Disabled; }
221 void disable() { clID = Disabled; }
222 bool isDummyTop() const { return clID == MinusTen; }
224 float chi2NormPredict(float chi2cl) const { return (chi2 + chi2cl) / (1 + o2::its::RecoGeomHelper::getNLayers() - layerID); }
225};
226
228 std::vector<std::deque<ABTrackLink>> threadPool;
229};
230
231// AB primary seed: TPC track propagated to outermost ITS layer under specific InteractionCandidate hypothesis
232struct TPCABSeed {
233 static constexpr int8_t NeedAlternative = -3;
237 uint32_t linksEntry = 0;
238 int nLinks = 0;
240 int8_t status = MinusOne;
241 uint8_t threadID = 0;
245
246 TPCABSeed(int id, int ic, const o2::track::TrackParCov& trc) : tpcWID(id), ICCanID(ic), track(trc)
247 {
248 firstInLr.fill(MinusOne);
249 }
250 bool isDisabled() const { return status == MinusTen; }
251 void disable() { status = MinusTen; }
252 bool isValidated() const { return status == Validated; }
253 void validate(int lID)
254 {
255 winLinkID = lID;
257 }
259 bool needAlteranative() const { return status == NeedAlternative; }
262 const ABTrackLink& getLink(int i) const { return gLinksPool->threadPool[threadID][i + linksEntry]; }
263 void addLink(const o2::track::TrackParCov& trc, int clID, int parentID, int nextID, int lr, int nc, int laddID, float chi2)
264 {
265 gLinksPool->threadPool[threadID].push_back({trc, clID, parentID, nextID, lr, nc, laddID, chi2});
266 nLinks++;
267 }
268 int getNLinks() const { return nLinks; }
273 bool checkLinkHasUsedClusters(int linkID, const ITSClusStatus& clStatus) const
274 {
275 // check if some clusters used by the link or its parents are forbidden (already used by validatet track)
276 while (linkID > MinusOne) {
277 const auto& link = getLink(linkID);
278 if (link.clID > MinusOne && clStatus[o2::itsmft::clusID2Layer(link.clID)][o2::itsmft::clusID2Index(link.clID)] != MinusOne) {
279 return true;
280 }
281 linkID = link.parentID;
282 }
283 return false;
284 }
285 void flagLinkUsedClusters(int linkID, ITSClusStatus& clStatus) const
286 {
287 // check if some clusters used by the link or its parents are forbidden (already used by validated track)
288 while (linkID > MinusOne) {
289 const auto& link = getLink(linkID);
290 if (link.clID > MinusOne) {
292 }
293 linkID = link.parentID;
294 }
295 }
296 size_t sizeInternal() const { return sizeof(ABTrackLink) * getNLinks(); }
297 size_t capInternal() const { return sizeof(ABTrackLink) * getNLinks(); }
298};
299
302 int rofITS; // corresponding ITS clock-layer cluster ROF entry (in the ROFRecord vectors)
303 uint32_t flag; // origin, etc.
305 std::array<int, o2::its::RecoGeomHelper::getNLayers()> rofLr; // per ITS layer: cluster ROF entry compatible with the candidate time, -1: none
306 uint8_t rofNextLr = 0; // bit lr set: the candidate time is compatible also with the ROF rofLr[lr]+1 of the layer
307 InteractionCandidate(const o2::InteractionRecord& ir, float t, float dt, int rof, uint32_t f = 0) : o2::InteractionRecord(ir), tBracket(t - dt, t + dt), rofITS(rof), flag(f)
308 {
309 rofLr.fill(MinusOne);
310 }
311};
312
315 float y = 0.f, z = 0.f;
316 int id = MinusOne;
317 int chip = -1;
318};
319
324 std::vector<o2::math_utils::Bracketf_t> rofTimes;
325 std::vector<ClusRange> rofRefs;
326 std::vector<ABClusterInfo> clus;
327 std::vector<uint8_t> needROF;
328 void clear()
329 {
330 rofTimes.clear();
331 rofRefs.clear();
332 clus.clear();
333 needROF.clear();
334 }
335 size_t sizeInternal() const { return sizeof(ABClusterInfo) * clus.size() + sizeof(o2::math_utils::Bracketf_t) * rofTimes.size() + sizeof(ClusRange) * rofRefs.size() + needROF.size(); }
336 size_t capInternal() const { return sizeof(ABClusterInfo) * clus.capacity() + sizeof(o2::math_utils::Bracketf_t) * rofTimes.capacity() + sizeof(ClusRange) * rofRefs.capacity() + needROF.capacity(); }
337};
338
342 int rofKey = -2;
343 int nROFsKey = 0;
344 int chipOffs = 0;
345 int nData = 0;
346 const ABClusterInfo* data = nullptr;
347 std::vector<ClusRange> chipRefs;
348 std::vector<int> touchedChips;
349 std::vector<ABClusterInfo> merged;
350};
351
356
358{
359 public:
369
370 MatchTPCITS(); // std::unique_ptr to forward declared type needs constructor / destructor in .cxx
372
373 static constexpr int MaxUpDnLadders = 3; // max N ladders to check up and down from selected one
374 static constexpr int MaxLadderCand = 2 * MaxUpDnLadders + 1; // max ladders to check for matching clusters
375 static constexpr int MaxSeedsPerLayer = 50; // TODO
377 static_assert(NITSLayers == AlpParamITS::getNLayers(), "ITS layers count mismatch between geometry helper and DPLAlpideParam");
378 static_assert(NITSLayers == o2::itsmft::MaxITSClusLayers, "ITS layers count mismatch between geometry helper and the composed cluster ID encoding");
380#if !defined(__CINT__) && !defined(__MAKECINT__) && !defined(__ROOTCLING__) && !defined(__CLING__)
384 pmr::vector<int>& ABTrackletClusterIDs,
385 pmr::vector<o2::MCCompLabel>& matchLabels,
386 pmr::vector<o2::MCCompLabel>& ABTrackletLabels,
393 pmr::vector<int>& ABTrackletClusterIDs,
394 pmr::vector<o2::MCCompLabel>& matchLabels,
395 pmr::vector<o2::MCCompLabel>& ABTrackletLabels,
397 bool runAfterBurner(pmr::vector<o2::dataformats::TrackTPCITS>& matchedTracks, pmr::vector<o2::MCCompLabel>& matchLabels, pmr::vector<o2::MCCompLabel>& ABTrackletLabels, pmr::vector<int>& ABTrackletClusterIDs,
399 void refitABWinners(pmr::vector<o2::dataformats::TrackTPCITS>& matchedTracks, pmr::vector<o2::MCCompLabel>& matchLabels, pmr::vector<o2::MCCompLabel>& ABTrackletLabels, pmr::vector<int>& ABTrackletClusterIDs,
401 bool refitABTrack(int iITSAB, const TPCABSeed& seed, pmr::vector<o2::dataformats::TrackTPCITS>& matchedTracks, pmr::vector<int>& ABTrackletClusterIDs, pmr::vector<o2::itsmft::TrkClusRef>& ABTrackletRefs);
402#endif // CLING
403 void setSkipTPCOnly(bool v)
404 {
405 mSkipTPCOnly = v;
406 }
407 void setCosmics(bool v) { mCosmics = v; }
408 bool isCosmics() const { return mCosmics; }
409 void setNThreads(int n);
410
412 void init();
413 void end();
414 void reportTiming();
415
417 void clear();
418
420 void setBunchFilling(const o2::BunchFilling& bf);
421
422 void setNHBPerTF(int n) { mNHBPerTF = n; }
423
426 {
427 mITSTriggered = v;
428 if (mAlpParams) { // the ROF length depends on the readout mode
429 setAlpideParam(mAlpParams);
430 }
431 }
432 bool isITSTriggered() const { return mITSTriggered; }
433
434 void setUseFT0(bool v) { mUseFT0 = v; }
435 bool getUseFT0() const { return mUseFT0; }
436
437 void setUseBCFilling(bool v) { mUseBCFilling = v; }
438 bool getUseBCFilling() const { return mUseBCFilling; }
439
443 void setAlpideParam(const AlpParamITS* p);
444 const AlpParamITS* getAlpideParam() const { return mAlpParams; }
445
447 int getITSClockLayer() const { return mITSClockLayer; }
448
450 int getITSROFrameLengthInBC(int lr) const { return mITSROFrameLengthInBC[lr]; }
451 float getITSROFrameLengthMUS(int lr) const { return mITSROFrameLengthMUS[lr]; }
452 float getITSROFrameLengthMUSInv(int lr) const { return mITSROFrameLengthMUSInv[lr]; }
453 float getITSTimeResMUS(int lr) const { return mITSTimeResMUS[lr]; }
454 int getITSTimeBiasInBC(int lr) const { return mITSTimeBiasInBC[lr]; }
455 float getITSTimeBiasMUS(int lr) const { return mITSTimeBiasMUS[lr]; }
456
458 BracketF getITSROFTimeBracket(long nBC, int lr) const
459 {
460 float tMin = (nBC + mITSTimeBiasInBC[lr]) * o2::constants::lhc::LHCBunchSpacingMUS;
461 return {tMin, tMin + mITSROFrameLengthMUS[lr]};
462 }
463
464 // ==================== >> DPL-driven input >> =======================
465 void setITSDictionary(const o2::itsmft::TopologyDictionary* d) { mITSDict = d; }
466#ifdef ENABLE_UPGRADES
467 void setIT3Dictionary(const o2::its3::TopologyDictionary* d)
468 {
469 mIT3Dict = d;
470 }
471#endif
472
474 void setMCTruthOn(bool v)
475 {
476 mMCTruthON = v;
477 }
478
480 void setVDriftCalib(bool v)
481 {
482 mVDriftCalibOn = v;
483 }
485 void setTPCCorrMaps(const o2::gpu::TPCFastTransformPOD* maph, float lumi);
486
488 void print() const;
489 void printCandidatesTPC() const;
490 void printCandidatesITS() const;
491
492 //>>> ====================== options =============================>>>
493 void setUseMatCorrFlag(MatCorrType f) { mUseMatCorrFlag = f; }
494 auto getUseMatCorrFlag() const { return mUseMatCorrFlag; }
495
496 //<<< ====================== options =============================<<<
497
498#ifdef _ALLOW_DEBUG_TREES_
499 enum DebugFlagTypes : UInt_t {
500 MatchTreeAll = 0x1 << 1,
501 MatchTreeAccOnly = 0x1 << 2,
502 WinnerMatchesTree = 0x1 << 3,
503 TPCOrigTree = 0x1 << 4
504 };
506 bool isDebugFlag(UInt_t flags) const { return mDBGFlags & flags; }
507
509 UInt_t getDebugFlags() const { return mDBGFlags; }
510
512 void setDebugFlag(UInt_t flag, bool on = true);
513
515 void setDebugTreeFileName(std::string name)
516 {
517 if (!name.empty()) {
518 mDebugTreeFileName = name;
519 }
520 }
521
523 const std::string& getDebugTreeFileName() const { return mDebugTreeFileName; }
524
526 void fillTPCITSmatchTree(int itsID, int tpcID, int rejFlag, float chi2 = -1., float tCorr = 0.);
528 void dumpTPCOrig(bool acc, int tpcIndex);
529#endif
530
531 private:
532 void updateTimeDependentParams();
533
534 int findLaddersToCheckBOn(int ilr, int lad0, const o2::math_utils::CircleXYf_t& circle, float errYFrac,
535 std::array<int, MaxLadderCand>& lad2Check) const;
536 int findLaddersToCheckBOff(int ilr, int lad0, const o2::math_utils::IntervalXYf_t& trcLinPar, float errYFrac,
537 std::array<int, MatchTPCITS::MaxLadderCand>& lad2Check) const;
538 bool prepareTPCData();
539 bool prepareITSData();
540 bool prepareFITData();
541 int prepareInteractionTimes();
542 int prepareTPCTracksAfterBurner();
543 int addTPCSeed(const o2::track::TrackParCov& _tr, float t0, float terr, o2::dataformats::GlobalTrackID srcGID, int tpcID);
544
545 int preselectChipClusters(std::vector<int>& clVecOut, const ClusRange& clRange, const ABLayerView& clView,
546 float trackY, float trackZ, float tolerY, float tolerZ) const;
547 void flagUsedITSClusters(const o2::its::TrackITS& track);
548
549 void doMatching(int sec);
550
551 bool refitTPCInward(o2::track::TrackParCov& trcIn, float& chi2, float xTgt, int trcID, float timeTB) const;
552
553 void selectBestMatches();
554 bool validateTPCMatch(int iTPC);
555 void removeITSfromTPC(int itsID, int tpcID);
556 void removeTPCfromITS(int tpcID, int itsID);
557 bool isValidatedTPC(const TrackLocTPC& t) const;
558 bool isValidatedITS(const TrackLocITS& t) const;
559 bool isDisabledTPC(const TrackLocTPC& t) const;
560 bool isDisabledITS(const TrackLocITS& t) const;
561
562 int compareTPCITSTracks(const TrackLocITS& tITS, const TrackLocTPC& tTPC, float& chi2) const;
563 float getPredictedChi2NoZ(const o2::track::TrackParCov& trITS, const o2::track::TrackParCov& trTPC) const;
564 bool propagateToRefX(o2::track::TrackParCov& trc, o2::track::TrackLTIntegral* lti = nullptr);
565 void addLastTrackCloneForNeighbourSector(int sector, o2::track::TrackLTIntegral* trackLTInt = nullptr);
566
568 bool registerMatchRecordTPC(int iITS, int iTPC, float chi2, int candIC = MinusOne);
569 void registerMatchRecordITS(int iITS, int iTPC, float chi2, int candIC = MinusOne);
570 void suppressMatchRecordITS(int iITS, int iTPC);
571
573 int getNMatchRecordsTPC(const TrackLocTPC& tTPC) const;
574
576 int getNMatchRecordsITS(const TrackLocITS& tITS) const;
577
579 BracketIR tBracket2IRBracket(const BracketF tbrange);
580
582 int time2ITSROFrameCont(float t) const
583 {
584 int rof = (t - mITSTimeBiasMUS[mITSClockLayer]) * mITSROFrameLengthMUSInv[mITSClockLayer];
585 if (rof < 0) {
586 rof = 0;
587 }
588 // the rof is estimated continuous counter but the actual bins might have gaps (e.g. HB rejects etc)-> use mapping
589 return rof < int(mITSTrackROFContMapping.size()) ? mITSTrackROFContMapping[rof] : mITSTrackROFContMapping.back();
590 }
591
593 int time2ITSROFrameTrig(float t, int start) const
594 {
595 t -= mITSTimeBiasMUS[mITSClockLayer];
596 while (start < int(mITSROFTimes.size())) {
597 if (mITSROFTimes[start].getMax() > t) {
598 return start;
599 }
600 start++;
601 }
602 return --start;
603 }
604
606 float tpcTimeBin2Z(float tbn) const { return tbn * mTPCBin2Z; }
607
609 float tpcTimeBin2MUS(float tbn) const { return tbn * mTPCTBinMUS; }
610
612 float tpcTimeBin2NS(float tbn) const { return tbn * mTPCTBinNS; }
613
615 float z2TPCBin(float z) const { return z * mZ2TPCBin; }
616
618 float tpcBin2Z(float t) const { return t * mTPCBin2Z; }
619
621 int roughCheckDif(float delta, float toler, int rejFlag) const
622 {
623 return delta > toler ? rejFlag : (delta < -toler ? -rejFlag : Accept);
624 }
625
626 const ITSCluster& getITSCluster(int composedID) const
627 {
628 return mITSClustersArray[o2::itsmft::clusID2Layer(composedID)][o2::itsmft::clusID2Index(composedID)];
629 }
630
631 // ========================= AFTERBURNER =========================
632 int prepareABSeeds();
633 void prepareABClusters();
634 void updateABLayerView(ABLayerView& view, int lr, int rof, int nROFs) const;
635 void processABSeed(int sid, const ABThreadClusterViews& itsClViews, uint8_t tID);
636 int followABSeed(const o2::track::TrackParCov& seed, const ABLayerView& clView, int seedID, int lrID, TPCABSeed& ABSeed);
637 int registerABTrackLink(TPCABSeed& ABSeed, const o2::track::TrackParCov& trc, int clID, int parentID, int lr, int laddID, float chi2Cl);
638 bool isBetter(float chi2A, float chi2B) { return chi2A < chi2B; } // RS FIMXE TODO
639 void accountForOverlapsAB(int lrSeed);
640 float correctTPCTrack(o2::track::TrackParCov& trc, const TrackLocTPC& tTPC, const InteractionCandidate& cand) const; // RS FIXME will be needed for refit
641 //================================================================
642
643 bool mInitDone = false;
644 bool mFieldON = true;
645 bool mCosmics = false;
646 bool mMCTruthON = false;
647 float mBz = 0;
648 int mTFCount = 0;
649 int mNThreads = 1;
650 int mNHBPerTF = 0;
651 int mNTPCOccBinLength = 0;
652 float mNTPCOccBinLengthInv;
653 o2::InteractionRecord mStartIR{0, 0};
654
656 const Params* mParams = nullptr;
657 const o2::ft0::InteractionTag* mFT0Params = nullptr;
658 const AlpParamITS* mAlpParams = nullptr;
659
660 MatCorrType mUseMatCorrFlag = MatCorrType::USEMatCorrTGeo;
661 bool mUseBCFilling = false;
662 bool mSkipTPCOnly = false;
663 bool mITSTriggered = false;
664 bool mUseFT0 = false;
665
667 bool mCompareTracksDZ = false;
668
669 float YMaxAtXMatchingRef = 999.;
670
671 float mSectEdgeMargin = 0.;
672
675 float mTPCTimeEdgeTSafeMargin = 0.f;
676 float mTPCExtConstrainedNSigmaInv = 0.f; // inverse for NSigmas for TPC time-interval from external constraint time sigma
679 int mITSClockLayer = 0;
680 std::array<int, NITSLayers> mITSROFrameLengthInBC{};
681 std::array<float, NITSLayers> mITSROFrameLengthMUS{};
682 std::array<float, NITSLayers> mITSROFrameLengthMUSInv{};
683 std::array<float, NITSLayers> mITSTimeResMUS{};
684 std::array<int, NITSLayers> mITSTimeBiasInBC{};
685 std::array<float, NITSLayers> mITSTimeBiasMUS{};
686 float mTPCVDrift = -1.;
687 float mTPCVDriftInv = -1.;
688 float mTPCDriftTimeOffset = 0;
689 float mTPCTBinMUS = 0.;
690 float mTPCTBinNS = 0.;
691 float mTPCTBinMUSInv = 0.;
692 float mZ2TPCBin = 0.;
693 float mTPCBin2Z = 0.;
694 float mNTPCBinsFullDrift = 0.;
695 float mTPCZMax = 0.;
696 float mTPCmeanX0Inv = 1. / 31850.;
697
698 float mMinTPCTrackPtInv = 999.;
699 float mMinITSTrackPtInv = 999.;
700 bool mVDriftCalibOn = false;
701 o2::tpc::VDriftCorrFact mTPCDrift{};
702 const o2::gpu::TPCFastTransformPOD* mTPCCorrMaps = nullptr;
703 float mLumiCTP{-1};
704
705 std::unique_ptr<o2::gpu::GPUO2InterfaceRefit> mTPCRefitter;
706
707 o2::BunchFilling mBunchFilling;
708 std::array<int16_t, o2::constants::lhc::LHCMaxBunches> mClosestBunchAbove; // closest filled bunch from above
709 std::array<int16_t, o2::constants::lhc::LHCMaxBunches> mClosestBunchBelow; // closest filled bunch from below
710
711 std::array<float, 5> mCovDiagInner{};
712 std::array<float, 5> mCovDiagOuter{};
713
714 const o2::itsmft::ChipMappingITS ITSChMap{};
715
716 const o2::globaltracking::RecoContainer* mRecoCont = nullptr;
718 // since this info is provided by external device
719 gsl::span<const o2::tpc::TrackTPC> mTPCTracksArray;
720 gsl::span<const o2::tpc::TPCClRefElem> mTPCTrackClusIdx;
721 gsl::span<const o2::itsmft::ROFRecord> mITSTrackROFRec;
722 gsl::span<const o2::its::TrackITS> mITSTracksArray;
723 gsl::span<const int> mITSTrackClusIdx;
724 std::array<std::vector<ITSCluster>, NITSLayers> mITSClustersArray{};
725 std::array<std::vector<uint8_t>, NITSLayers> mITSClusterSizes{};
726 std::array<gsl::span<const o2::itsmft::ROFRecord>, NITSLayers> mITSClusterROFRec;
727 int mNITSClusters = 0;
728 gsl::span<const o2::ft0::RecPoints> mFITInfo;
729
730 gsl::span<const unsigned char> mTPCRefitterShMap;
731 gsl::span<const unsigned int> mTPCRefitterOccMap;
732 const o2::itsmft::TopologyDictionary* mITSDict{nullptr}; // cluster patterns dictionary
733#ifdef ENABLE_UPGRADES
734 const o2::its3::TopologyDictionary* mIT3Dict{nullptr}; // cluster patterns dictionary
735#endif
736
737 const o2::tpc::ClusterNativeAccess* mTPCClusterIdxStruct = nullptr;
738
739 std::array<const o2::dataformats::MCTruthContainer<o2::MCCompLabel>*, NITSLayers> mITSClsLabels{};
740 gsl::span<const o2::MCCompLabel> mITSTrkLabels;
741 gsl::span<const o2::MCCompLabel> mTPCTrkLabels;
743
744 size_t mNMatches = 0;
745 size_t mNCalibPrelim = 0;
746 size_t mNMatchesControl = 0;
747
748 size_t mNABRefsClus = 0;
749 float mAB2MatchGuess = 0.2; // heuristic guess about fraction of AB matches in total matches
750 std::vector<InteractionCandidate> mInteractions;
751 std::vector<int> mInteractionMUSLUT;
752
754 std::vector<MatchRecord> mMatchRecordsTPC; // RSS DEQ
756 std::vector<MatchRecord> mMatchRecordsITS; // RSS DEQ
757
759 std::vector<BracketF> mITSROFTimes;
760 std::vector<TrackLocTPC> mTPCWork;
761 std::vector<TrackLocITS> mITSWork;
762 std::vector<o2::MCCompLabel> mTPCLblWork;
763 std::vector<o2::MCCompLabel> mITSLblWork;
764 std::vector<float> mWinnerChi2Refit;
765 std::vector<float> mTBinClOcc;
766
767 // ------------------------------
768 std::vector<TPCABSeed> mTPCABSeeds;
770 std::vector<int> mTPCABIndexCache;
771 std::vector<int> mABWinnersIDs;
774 ITSClusStatus mABClusterStatus;
775 std::array<ABLayerClusters, NITSLayers> mABLayerClusters;
776 std::array<int, NITSLayers + 1> mABChipsBounds{};
777 float mABROFMarginMUS = 0.f;
778 float mITSMaxROFOverhangMUS = 0.f;
779 LinksPoolMT mABLinksPool;
780
782 std::array<std::vector<int>, o2::constants::math::NSectors> mTPCSectIndexCache;
784 std::array<std::vector<int>, o2::constants::math::NSectors> mITSSectIndexCache;
785
787 std::array<std::vector<int>, o2::constants::math::NSectors> mTPCTimeStart;
789 std::array<std::vector<int>, o2::constants::math::NSectors> mITSTimeStart;
790
792 std::vector<int> mITSTrackROFContMapping;
793
794 o2::its::RecoGeomHelper mRGHelper;
795
796#ifdef _ALLOW_DEBUG_TREES_
797 std::unique_ptr<o2::utils::TreeStreamRedirector> mDBGOut;
798 UInt_t mDBGFlags = 0;
799 std::string mDebugTreeFileName = "dbg_TPCITSmatch.root";
800#endif
801
803 static constexpr float Tan70 = 2.74747771e+00; // tg(70 degree): std::tan(70.*o2::constants::math::PI/180.);
804 static constexpr float Cos70I2 = 1. + Tan70 * Tan70; // 1/cos^2(70) = 1 + tan^2(70)
805 static constexpr float MaxSnp = 0.9; // max snp of ITS or TPC track at xRef to be matched
806 static constexpr float MaxTgp = 2.064; // max tg corresponting to MaxSnp = MaxSnp/std::sqrt(1.-MaxSnp^2)
807 static constexpr float MinTBToCleanCache = 600.; // keep in AB ITS cluster refs cache at most this number of TPC bins
808 static const o2::gpu::GPUTPCGeometry TPCGeometry;
809
810 enum TimerIDs { SWTot,
811 SWPrepITS,
812 SWPrepTPC,
813 SWDoMatching,
814 SWSelectBest,
815 SWRefit,
816 SWABSeeds,
817 SWABMatch,
818 SWABWinners,
819 SWABRefit,
820 SWIO,
821 SWDBG,
822 NStopWatches };
823 static constexpr std::string_view TimerName[] = {"Total", "PrepareITS", "PrepareTPC", "DoMatching", "SelectBest", "Refit",
824 "ABSeeds", "ABMatching", "ABWinners", "ABRefit", "IO", "Debug"};
825 TStopwatch mTimer[NStopWatches];
826};
827
828//______________________________________________
829inline bool MatchTPCITS::isValidatedTPC(const TrackLocTPC& t) const
830{
831 return t.matchID > MinusOne && mMatchRecordsTPC[t.matchID].nextRecID == Validated;
832}
833
834//______________________________________________
835inline bool MatchTPCITS::isValidatedITS(const TrackLocITS& t) const
836{
837 return t.matchID > MinusOne && mMatchRecordsITS[t.matchID].nextRecID == Validated;
838}
839
840//______________________________________________
841inline bool MatchTPCITS::isDisabledITS(const TrackLocITS& t) const { return t.matchID < 0; }
842
843//______________________________________________
844inline bool MatchTPCITS::isDisabledTPC(const TrackLocTPC& t) const { return t.matchID < 0; }
845
846} // namespace globaltracking
847} // namespace o2
848
849#endif
Composition/decomposition of the ITS/MFT cluster IDs referring to per-layer cluster arrays.
Helper class to read the binary format of TPC ClusterNative.
Definition of the ITSMFT cluster.
Definition of the ClusterTopology class.
Base track model for the Barrel, params only, w/o covariance.
Definition of the BuildTopologyDictionary class for ITS3.
Class to store event ID and index in the event for objects like track, cluster...
Definition of the FIT RecPoints class.
int32_t i
Global index for barrel track: provides provenance (detectors combination), index in respective array...
Definition of the ITSMFT ROFrame (trigger) record.
float chi2
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 Recon.h:39
POD correction map.
Definition of the ITS track.
Result of refitting TPC-ITS matched track.
Reference on ITS/MFT clusters set.
calibration data from laser track calibration
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)
o2::BaseCluster< float > ITSCluster
void reportTiming()
clear results of previous event reco
int getITSClockLayer() const
per-layer ITS ROF length and bias, always defined for all NITSLayers
@ 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
float getITSTimeBiasMUS(int lr) const
time bracket (wrt TF start) of the ROF starting at nBC of the given layer
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)
BracketF getITSROFTimeBracket(long nBC, int lr) const
bool refitABTrack(int iITSAB, const TPCABSeed &seed, pmr::vector< o2::dataformats::TrackTPCITS > &matchedTracks, pmr::vector< int > &ABTrackletClusterIDs, pmr::vector< o2::itsmft::TrkClusRef > &ABTrackletRefs)
void setAlpideParam(const AlpParamITS *p)
void setTPCVDrift(const o2::tpc::VDriftCorrFact &v)
void setNHBPerTF(int n)
ITS readout mode.
bool isDebugFlag(UInt_t flags) const
get debug trees flags
int getITSTimeBiasInBC(int lr) 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)
const AlpParamITS * getAlpideParam() const
layer whose ROF defines the granularity of the ITS tracks ROFRecords (0 if all layers share the same ...
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)
float getITSROFrameLengthMUS(int lr) const
void setMCTruthOn(bool v)
request VDrift calibration
int getITSROFrameLengthInBC(int lr) const
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
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)
perform matching for provided input
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
o2::globaltracking::MatchTPCITSParams Params
o2::itsmft::DPLAlpideParam< o2::detectors::DetID::ITS > AlpParamITS
void setITSDictionary(const o2::itsmft::TopologyDictionary *d)
set flag to use MC truth
static constexpr int NITSLayers
const std::string & getDebugTreeFileName() const
fill matching debug tree
float getITSROFrameLengthMUSInv(int lr) const
UInt_t getDebugFlags() const
set or unset debug stream flag
float getITSTimeResMUS(int lr) const
void setNThreads(int n)
perform all initializations
HMPID cluster implementation.
Definition Cluster.h:27
bool match(const std::vector< std::string > &queries, const char *pattern)
Definition dcs-ccdb.cxx:229
GLdouble n
Definition glcorearb.h:1982
const GLdouble * v
Definition glcorearb.h:832
GLuint const GLchar * name
Definition glcorearb.h:781
GLdouble f
Definition glcorearb.h:310
GLint y
Definition glcorearb.h:270
GLboolean * data
Definition glcorearb.h:298
GLbitfield flags
Definition glcorearb.h:1570
GLuint GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat t0
Definition glcorearb.h:5034
GLuint start
Definition glcorearb.h:469
GLuint id
Definition glcorearb.h:650
GLdouble GLdouble GLdouble z
Definition glcorearb.h:843
constexpr int MinusTen
constexpr int MinusOne
std::array< std::vector< int >, o2::its::RecoGeomHelper::getNLayers()> ITSClusStatus
flags to tell the status of TPC-ITS tracks comparison
constexpr int Validated
per-layer status of ITS clusters (e.g. for the AfterBurner)
constexpr int Zero
const float chi2A
const float const int const float chi2B
constexpr int clusID2Layer(int id)
Definition ClusterID.h:38
constexpr int MaxITSClusLayers
Definition ClusterID.h:23
constexpr int clusID2Index(int id)
Definition ClusterID.h:39
detail::Bracket< float > Bracketf_t
Definition Primitive2D.h:40
std::vector< T, fair::mq::pmr::polymorphic_allocator< T > > vector
TrackParCovF TrackParCov
Definition Track.h:33
a couple of static helper functions to create timestamp values for CCDB queries or override obsolete ...
int chip
global chip (sensor) ID
std::vector< uint8_t > needROF
scratch buffer: blocks to build for the current TF
o2::dataformats::RangeReference< int, int > ClusRange
std::vector< ABClusterInfo > clus
clusters of the built blocks
std::vector< o2::math_utils::Bracketf_t > rofTimes
time brackets of all cluster ROFs of the layer
std::vector< ClusRange > rofRefs
block of every ROF in the clus vector, firstEntry < 0 if the block was not built
int nData
number of clusters in the view
int chipOffs
global ID of the 1st chip of the layer
int rofKey
1st ROF of the loaded block(s): -1: no compatible ROF, -2: nothing loaded yet
std::vector< ClusRange > chipRefs
cluster range in data for every chip of the layer
std::vector< ABClusterInfo > merged
buffer to merge 2 blocks when the candidate time is compatible with 2 ROFs
std::vector< int > touchedChips
chips with non-empty chipRefs, for fast reset
int nROFsKey
number of consecutive ROFs loaded (1 or 2)
std::array< ABLayerView, o2::its::RecoGeomHelper::getNLayers()> layers
< per-thread views of the AB clusters of all layers
o2::math_utils::Bracketf_t tBracket
o2::dataformats::RangeReference< int, int > seedsRef
std::array< int, o2::its::RecoGeomHelper::getNLayers()> rofLr
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
std::array< int, o2::its::RecoGeomHelper::getNLayers()> firstInLr
entry of 1st (best) hypothesis on each layer
int8_t status
status (RS TODO)
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
int ICCanID
interaction candidate ID (they are sorted in increasing time)
ABTrackLink & getLink(int i)
uint32_t linksEntry
1st entry of the link
void flagLinkUsedClusters(int linkID, ITSClusStatus &clStatus) const
static constexpr int8_t NeedAlternative
o2::track::TrackParCov track
Seed propagated to the outer layer under certain time constraint.
int nLinks
number of links
static LinksPoolMT * gLinksPool
pool of links per thread
bool checkLinkHasUsedClusters(int linkID, const ITSClusStatus &clStatus) const
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
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)
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)
o2::dataformats::GlobalTrackID gid
static constexpr int getNLayers()
VectorOfTObjectPtrs other
o2::InteractionRecord ir(0, 0)
LumiInfo lumi