Skip to content

Commit e4cee5d

Browse files
authored
Merge branch 'AliceO2Group:dev' into new-detector4
2 parents c7bf68d + 20eb9d2 commit e4cee5d

File tree

21 files changed

+333
-171
lines changed

21 files changed

+333
-171
lines changed

DataFormats/Detectors/GlobalTracking/src/RecoContainer.cxx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1447,7 +1447,7 @@ RecoContainer::GlobalIDSet RecoContainer::getSingleDetectorRefs(GTrackID gidx) c
14471447
table[GTrackID::MCH] = parent0.getMCHRef();
14481448
table[GTrackID::MID] = parent0.getMIDRef();
14491449
}
1450-
return std::move(table);
1450+
return table;
14511451
}
14521452

14531453
//________________________________________________________

DataFormats/Reconstruction/include/ReconstructionDataFormats/MatchInfoTOF.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,17 @@ class MatchInfoTOF
7575
double getT0true() const { return mT0true; }
7676
void setT0true(double val) { mT0true = val; }
7777

78+
enum QualityFlags { isMultiHitX = 0x1 << 0,
79+
isMultiHitZ = 0x1 << 1,
80+
badDy = 0x1 << 2,
81+
isMultiStrip = 0x1 << 3,
82+
isNotInPad = 0x1 << 4,
83+
chiGT3 = 0x1 << 5,
84+
chiGT5 = 0x1 << 6,
85+
hasT0sameBC = 0x1 << 7,
86+
hasT0_1BCbefore = 0x1 << 8,
87+
hasT0_2BCbefore = 0x1 << 9 };
88+
7889
private:
7990
int mIdLocal; // track id in sector of the pair track-TOFcluster
8091
float mChi2; // chi2 of the pair track-TOFcluster

DataFormats/simulation/src/DigitizationContext.cxx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -289,6 +289,11 @@ DigitizationContext* DigitizationContext::loadFromFile(std::string_view filename
289289

290290
void DigitizationContext::fillQED(std::string_view QEDprefix, int max_events, double qedrate)
291291
{
292+
if (mEventRecords.size() <= 1) {
293+
// nothing to do
294+
return;
295+
}
296+
292297
o2::steer::InteractionSampler qedInteractionSampler;
293298
qedInteractionSampler.setBunchFilling(mBCFilling);
294299

Detectors/AOD/include/AODProducerWorkflow/AODProducerWorkflowSpec.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -482,8 +482,6 @@ class AODProducerWorkflowDPL : public Task
482482
// using -1 as dummies for AOD
483483
struct MCLabels {
484484
uint32_t labelID = -1;
485-
uint32_t labelITS = -1;
486-
uint32_t labelTPC = -1;
487485
uint16_t labelMask = 0;
488486
uint8_t fwdLabelMask = 0;
489487
};

Detectors/AOD/src/AODProducerWorkflowSpec.cxx

Lines changed: 14 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@ using PVertex = o2::dataformats::PrimaryVertex;
109109
using GIndex = o2::dataformats::VtxTrackIndex;
110110
using DataRequest = o2::globaltracking::DataRequest;
111111
using GID = o2::dataformats::GlobalTrackID;
112+
using DetID = o2::detectors::DetID;
112113
using SMatrix55Sym = ROOT::Math::SMatrix<double, 5, 5, ROOT::Math::MatRepSym<double, 5>>;
113114

114115
namespace o2::aodproducer
@@ -1058,9 +1059,9 @@ void AODProducerWorkflowDPL::fillMCTrackLabelsTable(MCTrackLabelCursorType& mcTr
10581059
int vertexId)
10591060
{
10601061
// labelMask (temporary) usage:
1061-
// bit 13 -- ITS/TPC or TPC/TOF labels are not equal
1062+
// bit 13 -- ITS/TPC with ITS label (track of AB tracklet) different from TPC
10621063
// bit 14 -- isNoise() == true
1063-
// bit 15 -- isFake() == true
1064+
// bit 15 -- isFake() == true (defined by the fakeness of the top level global track, i.e. if TOF is present, fake means that the track of the TPC label does not contribute to TOF cluster)
10641065
// labelID = -1 -- label is not set
10651066

10661067
for (int src = GIndex::NSources; src--;) {
@@ -1084,7 +1085,7 @@ void AODProducerWorkflowDPL::fillMCTrackLabelsTable(MCTrackLabelCursorType& mcTr
10841085

10851086
if (GIndex::includesSource(src, mInputSources)) {
10861087
auto mcTruth = data.getTrackMCLabel(trackIndex);
1087-
MCLabels labelHolder;
1088+
MCLabels labelHolder{};
10881089
if ((src == GIndex::Source::MFT) || (src == GIndex::Source::MFTMCH) || (src == GIndex::Source::MCH) || (src == GIndex::Source::MCHMID)) { // treating mft and fwd labels separately
10891090
if (!needToStore(src == GIndex::Source::MFT ? mGIDToTableMFTID : mGIDToTableFwdID)) {
10901091
continue;
@@ -1110,51 +1111,22 @@ void AODProducerWorkflowDPL::fillMCTrackLabelsTable(MCTrackLabelCursorType& mcTr
11101111
continue;
11111112
}
11121113
if (mcTruth.isValid()) { // if not set, -1 will be stored
1113-
labelHolder.labelID = (mToStore[mcTruth.getSourceID()][mcTruth.getEventID()])[mcTruth.getTrackID()];
1114-
}
1115-
// treating possible mismatches and fakes for global tracks
1116-
auto contributorsGID = data.getSingleDetectorRefs(trackIndex);
1117-
bool isSetTPC = contributorsGID[GIndex::Source::TPC].isIndexSet();
1118-
bool isSetITS = contributorsGID[GIndex::Source::ITS].isIndexSet();
1119-
bool isSetTOF = contributorsGID[GIndex::Source::TOF].isIndexSet();
1120-
bool isTOFFake = true;
1121-
if (isSetTPC && (isSetITS || isSetTOF)) {
1122-
auto mcTruthTPC = data.getTrackMCLabel(contributorsGID[GIndex::Source::TPC]);
1123-
if (mcTruthTPC.isValid()) {
1124-
labelHolder.labelTPC = (mToStore[mcTruthTPC.getSourceID()][mcTruthTPC.getEventID()])[mcTruthTPC.getTrackID()];
1125-
labelHolder.labelID = labelHolder.labelTPC;
1126-
}
1127-
if (isSetITS) {
1128-
auto mcTruthITS = data.getTrackMCLabel(contributorsGID[GIndex::Source::ITS]);
1129-
if (mcTruthITS.isValid()) {
1130-
labelHolder.labelITS = (mToStore[mcTruthITS.getSourceID()][mcTruthITS.getEventID()])[mcTruthITS.getTrackID()];
1131-
}
1132-
if (labelHolder.labelITS != labelHolder.labelTPC) {
1133-
LOG(debug) << "ITS-TPC MCTruth: labelIDs do not match at " << trackIndex.getIndex() << ", src = " << src;
1134-
labelHolder.labelMask |= (0x1 << 13);
1135-
}
1114+
labelHolder.labelID = (mToStore[mcTruth.getSourceID()][mcTruth.getEventID()])[mcTruth.getTrackID()]; // defined by TPC if it contributes, otherwise: by ITS
1115+
if (mcTruth.isFake()) {
1116+
labelHolder.labelMask |= (0x1 << 15);
11361117
}
1137-
if (isSetTOF) {
1138-
const auto& labelsTOF = data.getTOFClustersMCLabels()->getLabels(contributorsGID[GIndex::Source::TOF]);
1139-
for (auto& mcLabel : labelsTOF) {
1140-
if (!mcLabel.isValid()) {
1141-
continue;
1142-
}
1143-
if (mcLabel == labelHolder.labelTPC) {
1144-
isTOFFake = false;
1145-
break;
1118+
if (trackIndex.includesDet(DetID::TPC) && trackIndex.getSource() != GIndex::Source::TPC) { // this is global track
1119+
auto contributorsGID = data.getSingleDetectorRefs(trackIndex);
1120+
if (contributorsGID[GIndex::Source::ITSTPC].isIndexSet()) { // there is a match to ITS tracks or ITSAB tracklet!
1121+
if (data.getTrackMCLabel(contributorsGID[GIndex::Source::ITSTPC]).isFake()) {
1122+
labelHolder.labelMask |= (0x1 << 13);
11461123
}
11471124
}
11481125
}
1149-
}
1150-
if (mcTruth.isFake() || (isSetTOF && isTOFFake)) {
1151-
labelHolder.labelMask |= (0x1 << 15);
1152-
}
1153-
if (mcTruth.isNoise()) {
1126+
} else if (mcTruth.isNoise()) {
11541127
labelHolder.labelMask |= (0x1 << 14);
11551128
}
1156-
mcTrackLabelCursor(labelHolder.labelID,
1157-
labelHolder.labelMask);
1129+
mcTrackLabelCursor(labelHolder.labelID, labelHolder.labelMask);
11581130
}
11591131
}
11601132
}

Detectors/GlobalTracking/include/GlobalTracking/MatchTPCITS.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@
5050
#include "ITSReconstruction/RecoGeomHelper.h"
5151
#include "TPCFastTransform.h"
5252
#include "GPUO2InterfaceRefit.h"
53+
#include "GPUTPCGeometry.h"
5354
#include "GlobalTracking/MatchTPCITSParams.h"
5455
#include "DataFormatsITSMFT/TopologyDictionary.h"
5556
#include "DataFormatsITSMFT/TrkClusRef.h"
@@ -132,6 +133,8 @@ struct TrackLocTPC : public o2::track::TrackParCov {
132133
int sourceID = 0; ///< TPC track origin in
133134
o2::dataformats::GlobalTrackID gid{}; // global track source ID (TPC track may be part of it)
134135
int matchID = MinusOne; ///< entry (non if MinusOne) of its matchTPC struct in the mMatchesTPC
136+
uint8_t lowestRow = -1;
137+
uint8_t padFromEdge = -1;
135138
Constraint_t constraint{Constrained};
136139

137140
float getCorrectedTime(float dt) const // return time0 corrected for extra drift (to match certain Z)
@@ -143,7 +146,7 @@ struct TrackLocTPC : public o2::track::TrackParCov {
143146
return constraint == Constrained ? 0.f : (constraint == ASide ? dt : -dt);
144147
}
145148

146-
ClassDefNV(TrackLocTPC, 2);
149+
ClassDefNV(TrackLocTPC, 3);
147150
};
148151

149152
///< ITS track outward parameters propagated to reference X, with time bracket and index of
@@ -738,6 +741,7 @@ class MatchTPCITS
738741
static constexpr float MaxSnp = 0.9; // max snp of ITS or TPC track at xRef to be matched
739742
static constexpr float MaxTgp = 2.064; // max tg corresponting to MaxSnp = MaxSnp/std::sqrt(1.-MaxSnp^2)
740743
static constexpr float MinTBToCleanCache = 600.; // keep in AB ITS cluster refs cache at most this number of TPC bins
744+
static const o2::gpu::GPUTPCGeometry TPCGeometry;
741745

742746
enum TimerIDs { SWTot,
743747
SWPrepITS,

Detectors/GlobalTracking/src/MatchTPCITS.cxx

Lines changed: 24 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,13 @@
99
// granted to it by virtue of its status as an Intergovernmental Organization
1010
// or submit itself to any jurisdiction.
1111

12+
#include "GPUO2Interface.h" // Needed for propper settings in GPUParam.h
13+
#include "GPUParam.h"
14+
#include "GPUParam.inc"
15+
#ifdef WITH_OPENMP
16+
#include <omp.h>
17+
#endif
18+
1219
#include <TTree.h>
1320
#include <cassert>
1421
#include <algorithm>
@@ -50,13 +57,6 @@
5057
#include "ITS3Reconstruction/IOUtils.h"
5158
#endif
5259

53-
#include "GPUO2Interface.h" // Needed for propper settings in GPUParam.h
54-
#include "GPUParam.h"
55-
#include "GPUParam.inc"
56-
#ifdef WITH_OPENMP
57-
#include <omp.h>
58-
#endif
59-
6060
using namespace o2::globaltracking;
6161

6262
using MatrixDSym4 = ROOT::Math::SMatrix<double, 4, 4, ROOT::Math::MatRepSym<double, 4>>;
@@ -68,6 +68,8 @@ constexpr float MatchTPCITS::Tan70, MatchTPCITS::Cos70I2, MatchTPCITS::MaxSnp, M
6868

6969
LinksPoolMT* TPCABSeed::gLinksPool = nullptr;
7070

71+
const o2::gpu::GPUTPCGeometry MatchTPCITS::TPCGeometry{};
72+
7173
//______________________________________________
7274
MatchTPCITS::MatchTPCITS() = default;
7375

@@ -428,6 +430,12 @@ int MatchTPCITS::addTPCSeed(const o2::track::TrackParCov& _tr, float t0, float t
428430
if (clRow > mParams->askMinTPCRow[clSect]) {
429431
return -9;
430432
}
433+
const auto& clus = mTPCClusterIdxStruct->clusters[clSect][clRow][clIdx];
434+
uint8_t padFromEdge = uint8_t(clus.getPad());
435+
if (padFromEdge > TPCGeometry.NPads(clRow) / 2) {
436+
padFromEdge = TPCGeometry.NPads(clRow) - 1 - padFromEdge;
437+
}
438+
431439
// create working copy of track param
432440
bool extConstrained = srcGID.getSource() != GTrackID::TPC;
433441
if (extConstrained) {
@@ -442,6 +450,8 @@ int MatchTPCITS::addTPCSeed(const o2::track::TrackParCov& _tr, float t0, float t
442450
tpcID,
443451
srcGID,
444452
MinusOne,
453+
clRow,
454+
padFromEdge,
445455
(extConstrained || tpcOrig.hasBothSidesClusters()) ? TrackLocTPC::Constrained : (tpcOrig.hasASideClustersOnly() ? TrackLocTPC::ASide : TrackLocTPC::CSide)});
446456
// propagate to matching Xref
447457
const auto& trackTune = TrackTuneParams::Instance();
@@ -2872,7 +2882,7 @@ void MatchTPCITS::dumpTPCOrig(bool acc, int tpcIndex)
28722882
///< fill debug tree for TPC original tracks (passing pT cut)
28732883
mTimer[SWDBG].Start(false);
28742884
const auto& tpcOrig = mTPCTracksArray[tpcIndex];
2875-
uint8_t clSect = 0, clRow = 0, prevRow = 0xff;
2885+
uint8_t clSect = 0, clRow = 0, prevRow = 0xff, padFromEdge = -1;
28762886
uint32_t clIdx = 0;
28772887
int nshared = 0;
28782888
std::array<bool, 152> shMap{};
@@ -2888,6 +2898,11 @@ void MatchTPCITS::dumpTPCOrig(bool acc, int tpcIndex)
28882898
prevRawShared = true;
28892899
}
28902900
}
2901+
const auto& clus = mTPCClusterIdxStruct->clusters[clSect][clRow][clIdx];
2902+
padFromEdge = uint8_t(clus.getPad());
2903+
if (padFromEdge > TPCGeometry.NPads(clRow) / 2) {
2904+
padFromEdge = TPCGeometry.NPads(clRow) - 1 - padFromEdge;
2905+
}
28912906
int tb = tpcOrig.getTime0() * mNTPCOccBinLengthInv;
28922907
float mltTPC = tb < 0 ? mTBinClOcc[0] : (tb >= mTBinClOcc.size() ? mTBinClOcc.back() : mTBinClOcc[tb]);
28932908
(*mDBGOut) << "tpcOrig"
@@ -2900,6 +2915,7 @@ void MatchTPCITS::dumpTPCOrig(bool acc, int tpcIndex)
29002915
<< "time0=" << tpcOrig.getTime0()
29012916
<< "trc=" << ((o2::track::TrackParCov&)tpcOrig)
29022917
<< "minRow=" << clRow
2918+
<< "padFromEdge=" << padFromEdge
29032919
<< "multTPC=" << mltTPC;
29042920
if (mMCTruthON) {
29052921
(*mDBGOut) << "tpcOrig"

Detectors/ITSMFT/ITS/tracking/GPU/ITStrackingGPU/TimeFrameGPU.h

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,8 @@ class TimeFrameGPU : public TimeFrame
7777
void createCellsDevice();
7878
void createCellsLUTDevice();
7979
void createNeighboursIndexTablesDevice();
80-
void createNeighboursDevice(const unsigned int& layer, std::vector<std::pair<int, int>>& neighbours);
80+
void createNeighboursDevice(const unsigned int layer, const unsigned int nNeighbours);
81+
void createNeighboursDevice(const unsigned int layer, std::vector<std::pair<int, int>>& neighbours);
8182
void createNeighboursLUTDevice(const int, const unsigned int);
8283
void createNeighboursDeviceArray();
8384
void createTrackITSExtDevice(std::vector<CellSeed>&);
@@ -151,6 +152,9 @@ class TimeFrameGPU : public TimeFrame
151152
gsl::span<Tracklet*> getDeviceTracklet() { return mTrackletsDevice; }
152153
gsl::span<CellSeed*> getDeviceCells() { return mCellsDevice; }
153154

155+
// Overridden getters
156+
int getNumberOfCells() const;
157+
154158
private:
155159
void allocMemAsync(void**, size_t, Stream*, bool); // Abstract owned and unowned memory allocations
156160
bool mHostRegistered = false;
@@ -252,6 +256,12 @@ inline std::vector<unsigned int> TimeFrameGPU<nLayers>::getClusterSizes()
252256
return sizes;
253257
}
254258

259+
template <int nLayers>
260+
inline int TimeFrameGPU<nLayers>::getNumberOfCells() const
261+
{
262+
return std::accumulate(mNCells.begin(), mNCells.end(), 0);
263+
}
264+
255265
} // namespace gpu
256266
} // namespace its
257267
} // namespace o2

Detectors/ITSMFT/ITS/tracking/GPU/ITStrackingGPU/TrackingKernels.h

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -148,19 +148,19 @@ void computeCellsHandler(const Cluster** sortedClusters,
148148
const int nBlocks,
149149
const int nThreads);
150150

151-
void countCellNeighboursHandler(CellSeed** cellsLayersDevice,
152-
int* neighboursLUTs,
153-
int** cellsLUTs,
154-
gpuPair<int, int>* cellNeighbours,
155-
int* neighboursIndexTable,
156-
const float maxChi2ClusterAttachment,
157-
const float bz,
158-
const int layerIndex,
159-
const unsigned int nCells,
160-
const unsigned int nCellsNext,
161-
const int maxCellNeighbours,
162-
const int nBlocks,
163-
const int nThreads);
151+
unsigned int countCellNeighboursHandler(CellSeed** cellsLayersDevice,
152+
int* neighboursLUTs,
153+
int** cellsLUTs,
154+
gpuPair<int, int>* cellNeighbours,
155+
int* neighboursIndexTable,
156+
const float maxChi2ClusterAttachment,
157+
const float bz,
158+
const int layerIndex,
159+
const unsigned int nCells,
160+
const unsigned int nCellsNext,
161+
const int maxCellNeighbours,
162+
const int nBlocks,
163+
const int nThreads);
164164

165165
void computeCellNeighboursHandler(CellSeed** cellsLayersDevice,
166166
int* neighboursLUTs,

Detectors/ITSMFT/ITS/tracking/GPU/cuda/TimeFrameGPU.cu

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -406,7 +406,19 @@ void TimeFrameGPU<nLayers>::loadTrackSeedsDevice(std::vector<CellSeed>& seeds)
406406
}
407407

408408
template <int nLayers>
409-
void TimeFrameGPU<nLayers>::createNeighboursDevice(const unsigned int& layer, std::vector<std::pair<int, int>>& neighbours)
409+
void TimeFrameGPU<nLayers>::createNeighboursDevice(const unsigned int layer, const unsigned int nNeighbours)
410+
{
411+
START_GPU_STREAM_TIMER(mGpuStreams[0].get(), "reserving neighbours");
412+
LOGP(debug, "gpu-allocation: reserving {} neighbours (pairs), for {} MB.", nNeighbours, nNeighbours * sizeof(gpuPair<int, int>) / MB);
413+
allocMemAsync(reinterpret_cast<void**>(&mNeighbourPairsDevice[layer]), nNeighbours * sizeof(gpuPair<int, int>), &(mGpuStreams[0]), getExtAllocator());
414+
checkGPUError(cudaMemsetAsync(mNeighbourPairsDevice[layer], -1, nNeighbours * sizeof(gpuPair<int, int>), mGpuStreams[0].get()));
415+
LOGP(debug, "gpu-allocation: reserving {} neighbours, for {} MB.", nNeighbours, nNeighbours * sizeof(gpuPair<int, int>) / MB);
416+
allocMemAsync(reinterpret_cast<void**>(&mNeighboursDevice[layer]), nNeighbours * sizeof(int), &(mGpuStreams[0]), getExtAllocator());
417+
STOP_GPU_STREAM_TIMER(mGpuStreams[0].get());
418+
}
419+
420+
template <int nLayers>
421+
void TimeFrameGPU<nLayers>::createNeighboursDevice(const unsigned int layer, std::vector<std::pair<int, int>>& neighbours)
410422
{
411423
START_GPU_STREAM_TIMER(mGpuStreams[0].get(), "reserving neighbours");
412424
mCellsNeighbours[layer].clear();

0 commit comments

Comments
 (0)