Skip to content

Commit 2e0476b

Browse files
committed
Extend p.vertex/track matching to all track types
1 parent a2a0412 commit 2e0476b

10 files changed

Lines changed: 186 additions & 251 deletions

File tree

DataFormats/Reconstruction/include/ReconstructionDataFormats/GlobalTrackID.h

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,4 +82,17 @@ std::ostream& operator<<(std::ostream& os, const o2::dataformats::GlobalTrackID&
8282
} // namespace dataformats
8383
} // namespace o2
8484

85+
namespace std
86+
{
87+
// defining std::hash for GlobalTrackIndex to be used with std containers
88+
template <>
89+
struct hash<o2::dataformats::GlobalTrackID> {
90+
public:
91+
size_t operator()(const o2::dataformats::GlobalTrackID& id) const
92+
{
93+
return id.getRawWOFlags();
94+
}
95+
};
96+
} // namespace std
97+
8598
#endif

DataFormats/common/include/CommonDataFormat/AbstractRef.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,10 +68,13 @@ class AbstractRef
6868
void set(Idx_t idx, Src_t src) { mRef = (mRef & (FlgMask << (NBIdx + NBSrc))) | ((SrcMask & Src_t(src)) << NBIdx) | (IdxMask & Idx_t(idx)); }
6969

7070
Base_t getRaw() const { return mRef; }
71-
71+
Base_t getRawWOFlags() const { return mRef & (IdxMask | (SrcMask << NBIdx)); }
7272
bool isIndexSet() const { return getIndex() != IdxMask; }
7373
bool isSourceSet() const { return getSource() != SrcMask; }
7474

75+
bool operator==(const AbstractRef& o) const { return getRawWOFlags() == o.getRawWOFlags(); }
76+
bool operator!=(const AbstractRef& o) const { return !operator==(o); }
77+
7578
protected:
7679
Base_t mRef = IdxMask | (SrcMask << NBIdx); // packed reference, dummy by default
7780

Detectors/GlobalTracking/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ o2_add_library(
1313
SOURCES src/MatchTPCITS.cxx src/MatchTOF.cxx
1414
src/MatchTPCITSParams.cxx
1515
src/MatchCosmics.cxx
16-
src/MatchCosmicsParams.cxx
17-
src/RecoContainer.cxx
16+
src/MatchCosmicsParams.cxx
17+
src/RecoContainer.cxx
1818
PUBLIC_LINK_LIBRARIES
1919
O2::Framework
2020
O2::DataFormatsTPC

Detectors/GlobalTracking/src/RecoContainer.cxx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -326,8 +326,8 @@ void RecoContainer::createTracks(std::function<void(const o2::track::TrackParCov
326326
if (!usedData[src].empty()) {
327327
usedData[gidx.getSource()][gidx.getIndex()] = 1;
328328
} };
329-
auto isUsed = [&usedData](const GTrackID gidx) { return usedData[gidx.getSource()][gidx.getIndex()] != 0; };
330-
auto isUsed2 = [&usedData](int idx, int src) { return usedData[src][idx] != 0; };
329+
auto isUsed = [&usedData](const GTrackID gidx) { return (!usedData[gidx.getSource()].empty()) && (usedData[gidx.getSource()][gidx.getIndex()] != 0); };
330+
auto isUsed2 = [&usedData](int idx, int src) { return (!usedData[src].empty()) && (usedData[src][idx] != 0); };
331331

332332
// create only for those data types which are used
333333
const auto& tracksITS = getITSTracks<o2::its::TrackITS>();

Detectors/GlobalTrackingWorkflow/include/GlobalTrackingWorkflow/VertexTrackMatcherSpec.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ class VertexTrackMatcherSpec : public Task
4242
};
4343

4444
/// create a processor spec
45-
DataProcessorSpec getVertexTrackMatcherSpec();
45+
DataProcessorSpec getVertexTrackMatcherSpec(o2::detectors::DetID::mask_t dets);
4646

4747
} // namespace vertexing
4848
} // namespace o2

Detectors/GlobalTrackingWorkflow/src/VertexTrackMatcherSpec.cxx

Lines changed: 26 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,16 @@
1616
#include "DataFormatsParameters/GRPObject.h"
1717
#include "ITSMFTBase/DPLAlpideParam.h"
1818
#include "DetectorsCommonDataFormats/NameConf.h"
19+
#include "GlobalTracking/RecoContainer.h"
1920

2021
using namespace o2::framework;
22+
using DetID = o2::detectors::DetID;
2123

2224
namespace o2
2325
{
2426
namespace vertexing
2527
{
28+
o2::globaltracking::DataRequest dataRequestV2T;
2629

2730
void VertexTrackMatcherSpec::init(InitContext& ic)
2831
{
@@ -38,33 +41,21 @@ void VertexTrackMatcherSpec::run(ProcessingContext& pc)
3841
double timeCPU0 = mTimer.CpuTime(), timeReal0 = mTimer.RealTime();
3942
mTimer.Start(false);
4043

41-
// eventually, this should be set per TF from CCDB?
42-
if (mMatcher.getITSROFrameLengthInBC() == 0) {
43-
std::unique_ptr<o2::parameters::GRPObject> grp{o2::parameters::GRPObject::loadFrom(o2::base::NameConf::getGRPFileName())};
44-
const auto& alpParams = o2::itsmft::DPLAlpideParam<o2::detectors::DetID::ITS>::Instance();
45-
if (grp->isDetContinuousReadOut(o2::detectors::DetID::ITS)) {
46-
mMatcher.setITSROFrameLengthInBC(alpParams.roFrameLengthInBC);
47-
} else {
48-
mMatcher.setITSROFrameLengthInBC(alpParams.roFrameLengthTrig / o2::constants::lhc::LHCOrbitNS);
49-
}
50-
}
44+
o2::globaltracking::RecoContainer recoData;
5145

5246
// RS FIXME this will not have effect until the 1st orbit is propagated, until that will work only for TF starting at orbit 0
53-
const auto* dh = o2::header::get<o2::header::DataHeader*>(pc.inputs().get("vertices").header);
47+
const auto* dh = o2::header::get<o2::header::DataHeader*>(pc.inputs().getByPos(0).header);
5448
mMatcher.setStartIR({0, dh->firstTForbit});
49+
recoData.collectData(pc, dataRequestV2T);
5550

56-
const auto tracksITSTPC = pc.inputs().get<gsl::span<o2::dataformats::TrackTPCITS>>("tpcits");
57-
const auto tracksTPC = pc.inputs().get<gsl::span<o2::tpc::TrackTPC>>("tpc");
58-
const auto tracksITS = pc.inputs().get<gsl::span<o2::its::TrackITS>>("its");
59-
const auto tracksITSROF = pc.inputs().get<gsl::span<o2::itsmft::ROFRecord>>("itsROF");
6051
const auto vertices = pc.inputs().get<gsl::span<o2::dataformats::PrimaryVertex>>("vertices");
6152
const auto vtxTracks = pc.inputs().get<gsl::span<o2::dataformats::VtxTrackIndex>>("vtxTracks");
6253
const auto vtxTrackRefs = pc.inputs().get<gsl::span<o2::dataformats::VtxTrackRef>>("vtxTrackRefs");
6354

6455
std::vector<o2::dataformats::VtxTrackIndex> trackIndex;
6556
std::vector<o2::dataformats::VtxTrackRef> vtxRefs;
6657

67-
mMatcher.process(vertices, vtxTracks, vtxTrackRefs, tracksITSTPC, tracksITS, tracksITSROF, tracksTPC, trackIndex, vtxRefs);
58+
mMatcher.process(vertices, vtxTracks, vtxTrackRefs, recoData, trackIndex, vtxRefs);
6859

6960
pc.outputs().snapshot(Output{"GLO", "PVTX_TRMTC", 0, Lifetime::Timeframe}, trackIndex);
7061
pc.outputs().snapshot(Output{"GLO", "PVTX_TRMTCREFS", 0, Lifetime::Timeframe}, vtxRefs);
@@ -80,16 +71,28 @@ void VertexTrackMatcherSpec::endOfStream(EndOfStreamContext& ec)
8071
mTimer.CpuTime(), mTimer.RealTime(), mTimer.Counter() - 1);
8172
}
8273

83-
DataProcessorSpec getVertexTrackMatcherSpec()
74+
DataProcessorSpec getVertexTrackMatcherSpec(DetID::mask_t dets)
8475
{
85-
std::vector<InputSpec> inputs;
8676
std::vector<OutputSpec> outputs;
8777

88-
inputs.emplace_back("tpcits", "GLO", "TPCITS", 0, Lifetime::Timeframe);
89-
inputs.emplace_back("its", "ITS", "TRACKS", 0, Lifetime::Timeframe);
90-
inputs.emplace_back("itsROF", "ITS", "ITSTrackROF", 0, Lifetime::Timeframe);
91-
inputs.emplace_back("tpc", "TPC", "TRACKS", 0, Lifetime::Timeframe);
92-
78+
if (dets[DetID::ITS]) {
79+
dataRequestV2T.requestITSTracks(false);
80+
}
81+
if (dets[DetID::TPC]) {
82+
dataRequestV2T.requestITSTPCTracks(false);
83+
dataRequestV2T.requestTPCTracks(false);
84+
if (dets[DetID::TRD]) {
85+
// RSTODO will add once TRD tracking available
86+
}
87+
if (dets[DetID::TOF]) {
88+
dataRequestV2T.requestTPCTOFTracks(false);
89+
dataRequestV2T.requestTOFClusters(false);
90+
if (dets[DetID::ITS]) {
91+
dataRequestV2T.requestTOFMatches(false);
92+
}
93+
}
94+
}
95+
auto& inputs = dataRequestV2T.inputs;
9396
inputs.emplace_back("vertices", "GLO", "PVTX", 0, Lifetime::Timeframe);
9497
inputs.emplace_back("vtxTracks", "GLO", "PVTX_CONTID", 0, Lifetime::Timeframe);
9598
inputs.emplace_back("vtxTrackRefs", "GLO", "PVTX_CONTIDREFS", 0, Lifetime::Timeframe);

Detectors/GlobalTrackingWorkflow/src/primary-vertexing-workflow.cxx

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ WorkflowSpec defineDataProcessing(ConfigContext const& configcontext)
8787
// RSTODO will add once TRD tracking available
8888
}
8989
if (dets[DetID::TOF]) {
90-
specs.emplace_back(o2::tof::getTOFMatchedReaderSpec(true, false, false)); // MC info here is redundant
90+
specs.emplace_back(o2::tof::getTOFMatchedReaderSpec(true, false, false)); // MC, MatchInfo_glo, no TOF_TPCtracks
9191
readerGloTOFDone = true;
9292
specs.emplace_back(o2::tof::getClusterReaderSpec(false)); // RSTODO Needed just to set the time of ITSTPC track, consider moving to MatchInfoTOF
9393
}
@@ -100,15 +100,27 @@ WorkflowSpec defineDataProcessing(ConfigContext const& configcontext)
100100

101101
if (!disableMatching) {
102102
if (!disableRootInp) {
103-
if (!readerTrackITSDone) {
104-
specs.emplace_back(o2::its::getITSTrackReaderSpec(false));
103+
104+
if (dets[DetID::ITS]) {
105+
if (!readerTrackITSDone) {
106+
specs.emplace_back(o2::its::getITSTrackReaderSpec(false));
107+
}
105108
}
106-
if (!readerTrackITSTPCDone) {
107-
specs.emplace_back(o2::globaltracking::getTrackTPCITSReaderSpec(false));
109+
if (dets[DetID::TPC]) {
110+
if (dets[DetID::ITS] && !readerTrackITSTPCDone) {
111+
specs.emplace_back(o2::globaltracking::getTrackTPCITSReaderSpec(false));
112+
}
113+
specs.emplace_back(o2::tpc::getTPCTrackReaderSpec(false));
114+
if (dets[DetID::TOF]) {
115+
if (!readerGloTOFDone) {
116+
specs.emplace_back(o2::tof::getTOFMatchedReaderSpec(false, false, false)); // MC, MatchInfo_glo, no TOF_TPCtracks
117+
specs.emplace_back(o2::tof::getClusterReaderSpec(false)); // RSTODO Needed just to set the time of ITSTPC track, consider moving to MatchInfoTOF
118+
}
119+
specs.emplace_back(o2::tof::getTOFMatchedReaderSpec(false, true, true)); // mc, MatchInfo_TPC, TOF_TPCtracks
120+
}
108121
}
109-
specs.emplace_back(o2::tpc::getTPCTrackReaderSpec(false));
110122
}
111-
specs.emplace_back(o2::vertexing::getVertexTrackMatcherSpec());
123+
specs.emplace_back(o2::vertexing::getVertexTrackMatcherSpec(dets));
112124
}
113125

114126
if (!disableRootOut) {

Detectors/Vertexing/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,14 @@ o2_add_library(DetectorsVertexing
2020
PUBLIC_LINK_LIBRARIES ROOT::Core
2121
O2::CommonUtils
2222
O2::ReconstructionDataFormats
23+
O2::DataFormatsParameters
2324
O2::DataFormatsTPC
2425
O2::DataFormatsITS
2526
O2::TPCBase
2627
O2::SimulationDataFormat
2728
O2::FT0Reconstruction
2829
O2::DataFormatsFT0
30+
O2::GlobalTracking
2931
ms_gsl::ms_gsl)
3032

3133
o2_target_root_dictionary(DetectorsVertexing

Detectors/Vertexing/include/DetectorsVertexing/VertexTrackMatcher.h

Lines changed: 23 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,11 @@
1919
#include "ReconstructionDataFormats/PrimaryVertex.h"
2020
#include "ReconstructionDataFormats/VtxTrackIndex.h"
2121
#include "ReconstructionDataFormats/VtxTrackRef.h"
22-
#include "ReconstructionDataFormats/TrackTPCITS.h"
23-
#include "DataFormatsTPC/TrackTPC.h"
24-
#include "DataFormatsITS/TrackITS.h"
2522
#include "DataFormatsITSMFT/ROFRecord.h"
2623
#include "CommonDataFormat/InteractionRecord.h"
2724
#include "DetectorsVertexing/PVertexerParams.h"
2825
#include "MathUtils/Primitive2D.h"
26+
#include "GlobalTracking/RecoContainer.h"
2927

3028
namespace o2
3129
{
@@ -35,47 +33,42 @@ namespace vertexing
3533
class VertexTrackMatcher
3634
{
3735
public:
38-
using GIndex = o2::dataformats::VtxTrackIndex;
36+
using GIndex = o2::dataformats::GlobalTrackID;
37+
using VTIndex = o2::dataformats::VtxTrackIndex;
3938
using VRef = o2::dataformats::VtxTrackRef;
4039
using PVertex = const o2::dataformats::PrimaryVertex;
41-
using TrackTPCITS = o2::dataformats::TrackTPCITS;
42-
using TrackITS = o2::its::TrackITS;
43-
using ITSROFR = o2::itsmft::ROFRecord;
44-
using TrackTPC = o2::tpc::TrackTPC;
45-
using TmpMap = std::vector<std::vector<GIndex>>;
40+
using TmpMap = std::vector<std::vector<VTIndex>>;
4641
using TimeEst = o2::dataformats::TimeStampWithError<float, float>;
4742
using TBracket = o2::math_utils::Bracketf_t;
4843

44+
struct TrackTBracket {
45+
TBracket tBracket{}; ///< bracketing time in ns
46+
GIndex origID{}; ///< track origin id
47+
};
48+
struct VtxTBracket {
49+
TBracket tBracket{}; ///< bracketing time in ns
50+
int origID = -1; ///< vertex origin id
51+
};
52+
4953
void init();
50-
void process(const gsl::span<const PVertex>& vertices, // vertices
51-
const gsl::span<const GIndex>& v2tfitIDs, // IDs of contributor tracks used in fit
52-
const gsl::span<const VRef>& v2tfitRefs, // references on these tracks (we used special reference with multiple sources, but currently only TPCITS used)
53-
const gsl::span<const TrackTPCITS>& tpcits, // global tracks
54-
const gsl::span<const TrackITS>& its, // ITS tracks
55-
const gsl::span<const ITSROFR>& itsROFR, // ITS tracks ROFRecords
56-
const gsl::span<const TrackTPC>& tpc, // TPC tracks
57-
std::vector<GIndex>& trackIndex, // Global ID's for associated tracks
58-
std::vector<VRef>& vtxRefs); // references on these tracks
54+
void process(const gsl::span<const PVertex>& vertices, // vertices
55+
const gsl::span<const VTIndex>& v2tfitIDs, // IDs of contributor tracks used in fit
56+
const gsl::span<const VRef>& v2tfitRefs, // references on these tracks (we used special reference with multiple sources, but currently only TPCITS used)
57+
const o2::globaltracking::RecoContainer& recoData,
58+
std::vector<VTIndex>& trackIndex, // Global ID's for associated tracks
59+
std::vector<VRef>& vtxRefs); // references on these tracks
5960

6061
///< set InteractionRecods for the beginning of the TF
6162
void setStartIR(const o2::InteractionRecord& ir) { mStartIR = ir; }
62-
void setITSROFrameLengthInBC(int nbc);
63-
int getITSROFrameLengthInBC() const { return mITSROFrameLengthInBC; }
6463

6564
private:
66-
void attachTPCITS(TmpMap& tmpMap, const gsl::span<const TrackTPCITS>& tpcits, const std::vector<int>& idTPCITS, const gsl::span<const PVertex>& vertices);
67-
void attachITS(TmpMap& tmpMap, const gsl::span<const TrackITS>& its, const gsl::span<const ITSROFR>& itsROFR, const std::vector<int>& flITS,
68-
const gsl::span<const PVertex>& vertices, std::vector<int>& idxVtx);
69-
void attachTPC(TmpMap& tmpMap, const std::vector<TBracket>& tpcTimes, const std::vector<int>& idTPC, const gsl::span<const PVertex>& vertices, std::vector<int>& idVtx);
70-
bool compatibleTimes(const TimeEst& vtxT, const TimeEst& trcT) const;
7165
void updateTPCTimeDependentParams();
72-
float tpcTimeBin2MUS(float t)
73-
{ // convert TPC time bin to microseconds
74-
return t * mTPCBin2MUS;
75-
}
66+
void extractTracks(const o2::globaltracking::RecoContainer& data, const std::unordered_map<GIndex, bool>& vcont);
67+
68+
std::vector<TrackTBracket> mTBrackets;
7669

7770
o2::InteractionRecord mStartIR{0, 0}; ///< IR corresponding to the start of the TF
78-
int mITSROFrameLengthInBC = 0; ///< ITS RO frame in BC (for ITS cont. mode only)
71+
float mITSROFrameLengthMUS = 0; ///< ITS RO frame in mus
7972
float mMaxTPCDriftTimeMUS = 0;
8073
float mTPCBin2MUS = 0;
8174
const o2::vertexing::PVertexerParams* mPVParams = nullptr;

0 commit comments

Comments
 (0)