Skip to content

Commit 3eb5a70

Browse files
committed
Account for TPC clusters non-monotonous sorting
1 parent da3a178 commit 3eb5a70

File tree

4 files changed

+111
-17
lines changed

4 files changed

+111
-17
lines changed

Detectors/GlobalTrackingWorkflow/study/include/GlobalTrackingStudy/TrackMCStudyTypes.h

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,10 @@ struct MCTrackInfo {
6969
void setBit(int bit) { flags |= BitMask & (0x1 << bit); }
7070
void resetBit(int bit) { flags &= ~(BitMask & (0x1 << bit)); }
7171

72+
o2::track::TrackPar getTrackParTPC(float b, float x = 90) const;
73+
float getTrackParTPCPar(int i, float b, float x = 90) const;
74+
float getTrackParTPCPhiSec(float b, float x = 90) const;
75+
7276
ClassDefNV(MCTrackInfo, 7);
7377
};
7478

@@ -80,28 +84,33 @@ struct RecTrack {
8084
FakeTOF = 0x1 << 3,
8185
FakeITSTPC = 0x1 << 4,
8286
FakeITSTPCTRD = 0x1 << 5,
87+
HASACSides = 0x1 << 6,
8388
FakeGLO = 0x1 << 7
8489
};
8590
o2::track::TrackParCov track{};
8691
o2::dataformats::VtxTrackIndex gid{};
8792
o2::dataformats::TimeStampWithError<float, float> ts{};
8893
o2::MCEventLabel pvLabel{};
8994
short pvID = -1;
95+
uint8_t nClTPCShared = 0;
9096
uint8_t flags = 0;
9197
uint8_t nClITS = 0;
9298
uint8_t nClTPC = 0;
9399
uint8_t pattITS = 0;
94100
int8_t lowestPadRow = -1;
95101
int8_t padFromEdge = -1;
102+
uint8_t rowMaxTPC = 0;
103+
uint8_t rowCountTPC = 0;
96104

97105
bool isFakeGLO() const { return flags & FakeGLO; }
98106
bool isFakeITS() const { return flags & FakeITS; }
99107
bool isFakeTPC() const { return flags & FakeTPC; }
100108
bool isFakeTRD() const { return flags & FakeTRD; }
101109
bool isFakeTOF() const { return flags & FakeTOF; }
102110
bool isFakeITSTPC() const { return flags & FakeITSTPC; }
111+
bool hasACSides() const { return flags & HASACSides; }
103112

104-
ClassDefNV(RecTrack, 2);
113+
ClassDefNV(RecTrack, 3);
105114
};
106115

107116
struct TrackPairInfo {
@@ -151,6 +160,13 @@ struct TrackFamily { // set of tracks related to the same MC label
151160
const RecTrack& getTrackWithTPC() const { return entTPC < 0 ? dummyRecTrack : recTracks[entTPC]; }
152161
const RecTrack& getTrackWithITSTPC() const { return entITSTPC < 0 ? dummyRecTrack : recTracks[entITSTPC]; }
153162
const RecTrack& getTrackWithITSFound() const { return entITSFound < 0 ? dummyRecTrack : recTracks[entITSFound]; }
163+
const RecTrack& getLongestTPCTrack() const
164+
{
165+
int n = getLongestTPCTrackEntry();
166+
return n < 0 ? dummyRecTrack : recTracks[n];
167+
}
168+
int getLongestTPCTrackEntry() const;
169+
int getNTPCClones() const;
154170
static RecTrack dummyRecTrack; //
155171

156172
ClassDefNV(TrackFamily, 1);

Detectors/GlobalTrackingWorkflow/study/src/TrackMCStudy.cxx

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -280,20 +280,33 @@ void TrackMCStudy::process(const o2::globaltracking::RecoContainer& recoData)
280280
return patt;
281281
};
282282

283-
auto getLowestPadrow = [&recoData](const o2::tpc::TrackTPC& trc, RecTrack& tref) {
283+
auto fillTPCClusterInfo = [&recoData](const o2::tpc::TrackTPC& trc, RecTrack& tref) {
284284
if (recoData.inputsTPCclusters) {
285-
uint8_t clSect = 0, clRow = 0;
285+
uint8_t clSect = 0, clRow = 0, lowestR = -1;
286286
uint32_t clIdx = 0;
287287
const auto clRefs = recoData.getTPCTracksClusterRefs();
288288
const auto tpcClusAcc = recoData.getTPCClusters();
289-
trc.getClusterReference(clRefs, trc.getNClusterReferences() - 1, clSect, clRow, clIdx);
289+
const auto shMap = recoData.clusterShMapTPC;
290+
for (int ic = 0; ic < trc.getNClusterReferences(); ic++) { // outside -> inside ordering, but on the sector boundaries backward jumps are possible
291+
trc.getClusterReference(clRefs, ic, clSect, clRow, clIdx);
292+
if (clRow < lowestR) {
293+
tref.rowCountTPC++;
294+
lowestR = clRow;
295+
}
296+
unsigned int absoluteIndex = tpcClusAcc.clusterOffset[clSect][clRow] + clIdx;
297+
if (shMap[absoluteIndex] & o2::gpu::GPUTPCGMMergedTrackHit::flagShared) {
298+
tref.nClTPCShared++;
299+
}
300+
}
301+
tref.lowestPadRow = lowestR;
290302
const auto& clus = tpcClusAcc.clusters[clSect][clRow][clIdx];
291303
int padFromEdge = int(clus.getPad()), npads = o2::gpu::GPUTPCGeometry::NPads(clRow);
292304
if (padFromEdge > npads / 2) {
293305
padFromEdge = npads - 1 - padFromEdge;
294306
}
295307
tref.padFromEdge = uint8_t(padFromEdge);
296-
tref.lowestPadRow = clRow;
308+
trc.getClusterReference(clRefs, 0, clSect, clRow, clIdx);
309+
tref.rowMaxTPC = clRow;
297310
}
298311
};
299312

@@ -557,7 +570,10 @@ void TrackMCStudy::process(const o2::globaltracking::RecoContainer& recoData)
557570
if (msk[DetID::TPC]) {
558571
const auto& trtpc = recoData.getTPCTrack(gidSet[GTrackID::TPC]);
559572
tref.nClTPC = trtpc.getNClusters();
560-
getLowestPadrow(trtpc, tref);
573+
if (trtpc.hasBothSidesClusters()) {
574+
tref.flags |= RecTrack::HASACSides;
575+
}
576+
fillTPCClusterInfo(trtpc, tref);
561577
flagTPCClusters(trtpc, entry.first);
562578
if (trackFam.entTPC < 0) {
563579
trackFam.entTPC = tcnt;
@@ -748,8 +764,8 @@ void TrackMCStudy::fillMCClusterInfo(const o2::globaltracking::RecoContainer& re
748764
const auto& params = o2::trackstudy::TrackMCStudyConfig::Instance();
749765

750766
ClResTPC clRes{};
751-
for (uint8_t sector = 0; sector < 36; sector++) {
752-
for (uint8_t row = 0; row < 152; row++) {
767+
for (uint8_t row = 0; row < 152; row++) { // we need to go in increasing row, so this should be the outer loop
768+
for (uint8_t sector = 0; sector < 36; sector++) {
753769
unsigned int offs = TPCClusterIdxStruct.clusterOffset[sector][row];
754770
for (unsigned int icl0 = 0; icl0 < TPCClusterIdxStruct.nClusters[sector][row]; icl0++) {
755771
const auto labels = TPCClMClab->getLabels(icl0 + offs);

Detectors/GlobalTrackingWorkflow/study/src/TrackMCStudyTypes.cxx

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,4 +77,66 @@ int MCTrackInfo::getHighestITSLayer() const
7777
return -1;
7878
}
7979

80+
o2::track::TrackPar MCTrackInfo::getTrackParTPC(float b, float x) const
81+
{
82+
o2::track::TrackPar t(track);
83+
int ntri = 0;
84+
while (ntri < 2) {
85+
int sector0 = o2::math_utils::angle2Sector(t.getAlpha());
86+
if (!t.propagateParamTo(x, b)) {
87+
t.invalidate();
88+
break;
89+
}
90+
int sector = o2::math_utils::angle2Sector(t.getPhiPos());
91+
float alpha = o2::math_utils::sector2Angle(sector);
92+
if (!t.rotateParam(alpha)) {
93+
t.invalidate();
94+
break;
95+
}
96+
if (sector != sector0) {
97+
ntri++;
98+
continue;
99+
}
100+
break;
101+
}
102+
// printf("%s ->\n%s <-\n",track.asString().c_str(), t.asString().c_str());
103+
return t;
104+
}
105+
106+
float MCTrackInfo::getTrackParTPCPar(int i, float b, float x) const
107+
{
108+
auto t = getTrackParTPC(b, x);
109+
return t.isValid() ? t.getParam(i) : -999.;
110+
}
111+
112+
float MCTrackInfo::getTrackParTPCPhiSec(float b, float x) const
113+
{
114+
auto t = getTrackParTPC(b, x);
115+
return t.isValid() ? std::atan2(t.getY(), t.getX()) : -999.;
116+
}
117+
118+
int TrackFamily::getLongestTPCTrackEntry() const
119+
{
120+
int n = -1, ncl = 0;
121+
int ntr = recTracks.size();
122+
for (int i = 0; i < ntr; i++) {
123+
if (recTracks[i].nClTPC > ncl) {
124+
ncl = recTracks[i].nClTPC;
125+
n = i;
126+
}
127+
}
128+
return n;
129+
}
130+
131+
int TrackFamily::getNTPCClones() const
132+
{
133+
int n = 0;
134+
for (auto& t : recTracks) {
135+
if (t.nClTPC > 0) {
136+
n++;
137+
}
138+
}
139+
return n;
140+
}
141+
80142
} // namespace o2::trackstudy

Detectors/GlobalTrackingWorkflow/study/src/TrackingStudy.cxx

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -274,25 +274,25 @@ void TrackingStudySpec::process(o2::globaltracking::RecoContainer& recoData)
274274
const auto clRefs = recoData.getTPCTracksClusterRefs();
275275
const auto tpcClusAcc = recoData.getTPCClusters();
276276
const auto shMap = recoData.clusterShMapTPC;
277+
277278
if (recoData.inputsTPCclusters) {
278-
uint8_t clSect = 0, clRow = 0, clRowP = -1;
279+
uint8_t clSect = 0, clRow = 0, lowestR = -1;
279280
uint32_t clIdx = 0;
280-
for (int ic = 0; ic < trc.getNClusterReferences(); ic++) {
281+
for (int ic = 0; ic < trc.getNClusterReferences(); ic++) { // outside -> inside ordering, but on the sector boundaries backward jumps are possible
281282
trc.getClusterReference(clRefs, ic, clSect, clRow, clIdx);
282-
if (clRow != clRowP) {
283+
if (clRow < lowestR) {
283284
trExt.rowCountTPC++;
284-
clRowP = clRow;
285+
lowestR = clRow;
285286
}
286287
unsigned int absoluteIndex = tpcClusAcc.clusterOffset[clSect][clRow] + clIdx;
287288
if (shMap[absoluteIndex] & o2::gpu::GPUTPCGMMergedTrackHit::flagShared) {
288289
trExt.nClTPCShared++;
289290
}
290291
}
291-
trc.getClusterReference(clRefs, trc.getNClusterReferences() - 1, clSect, clRow, clIdx);
292-
trExt.rowMinTPC = clRow;
292+
trExt.rowMinTPC = lowestR;
293293
const auto& clus = tpcClusAcc.clusters[clSect][clRow][clIdx];
294294
trExt.padFromEdge = uint8_t(clus.getPad());
295-
int npads = o2::gpu::GPUTPCGeometry::NPads(clRow);
295+
int npads = o2::gpu::GPUTPCGeometry::NPads(lowestR);
296296
if (trExt.padFromEdge > npads / 2) {
297297
trExt.padFromEdge = npads - 1 - trExt.padFromEdge;
298298
}
@@ -314,9 +314,9 @@ void TrackingStudySpec::process(o2::globaltracking::RecoContainer& recoData)
314314
uint8_t clSect0 = 0, clRow0 = 0, clSect1 = 0, clRow1 = 0;
315315
uint32_t clIdx0 = 0, clIdx1 = 0;
316316
int ic1Start = 0;
317-
for (int ic0 = 0; ic0 < trc0.getNClusterReferences(); ic0++) { // outside -> inside
317+
for (int ic0 = 0; ic0 < trc0.getNClusterReferences(); ic0++) { // outside -> inside, but on the sector boundaries backward jumps are possible
318318
trc0.getClusterReference(clRefs, ic0, clSect0, clRow0, clIdx0);
319-
for (int ic1 = ic1Start; ic1 < trc1.getNClusterReferences(); ic1++) { // outside -> inside
319+
for (int ic1 = ic1Start; ic1 < trc1.getNClusterReferences(); ic1++) { // outside -> inside, but on the sector boundaries backward jumps are possible
320320
trc1.getClusterReference(clRefs, ic1, clSect1, clRow1, clIdx1);
321321
if (clRow1 > clRow0) {
322322
ic1Start = ic1 + 1;

0 commit comments

Comments
 (0)