Skip to content

Commit d6df980

Browse files
committed
Add per-stack TPC mult info to TrackData
1 parent 1999540 commit d6df980

File tree

6 files changed

+123
-14
lines changed

6 files changed

+123
-14
lines changed

Detectors/GlobalTrackingWorkflow/tpcinterpolationworkflow/CMakeLists.txt

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

12+
# add_compile_options(-O0 -g -fPIC -fno-omit-frame-pointer)
13+
1214
o2_add_library(TPCInterpolationWorkflow
1315
SOURCES src/TPCInterpolationSpec.cxx
1416
src/TPCResidualWriterSpec.cxx

Detectors/GlobalTrackingWorkflow/tpcinterpolationworkflow/src/TPCInterpolationSpec.cxx

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -66,11 +66,12 @@ void TPCInterpolationDPL::updateTimeDependentParams(ProcessingContext& pc)
6666
initOnceDone = true;
6767
// other init-once stuff
6868
const auto& param = SpacePointsCalibConfParam::Instance();
69+
mInterpolation.setSqrtS(o2::base::GRPGeomHelper::instance().getGRPLHCIF()->getSqrtS());
70+
mInterpolation.setNHBPerTF(o2::base::GRPGeomHelper::getNHBFPerTF());
6971
mInterpolation.init(mSources, mSourcesMap);
7072
if (mProcessITSTPConly) {
7173
mInterpolation.setProcessITSTPConly();
7274
}
73-
mInterpolation.setSqrtS(o2::base::GRPGeomHelper::instance().getGRPLHCIF()->getSqrtS());
7475
int nTfs = mSlotLength / (o2::base::GRPGeomHelper::getNHBFPerTF() * o2::constants::lhc::LHCOrbitMUS * 1e-6);
7576
bool limitTracks = (param.maxTracksPerCalibSlot < 0) ? false : true;
7677
int nTracksPerTfMax = (nTfs > 0 && limitTracks) ? param.maxTracksPerCalibSlot / nTfs : -1;
@@ -93,6 +94,11 @@ void TPCInterpolationDPL::updateTimeDependentParams(ProcessingContext& pc)
9394
mInterpolation.setProcessSeeds();
9495
}
9596
o2::its::GeometryTGeo::Instance()->fillMatrixCache(o2::math_utils::bit2Mask(o2::math_utils::TransformType::T2GRot) | o2::math_utils::bit2Mask(o2::math_utils::TransformType::T2L));
97+
mInterpolation.setExtDetResid(mExtDetResid);
98+
mInterpolation.setITSClusterDictionary(mITSDict);
99+
if (mDebugOutput) {
100+
mInterpolation.setDumpTrackPoints();
101+
}
96102
}
97103
// we may have other params which need to be queried regularly
98104
if (mTPCVDriftHelper.isUpdated()) {
@@ -103,11 +109,6 @@ void TPCInterpolationDPL::updateTimeDependentParams(ProcessingContext& pc)
103109
mInterpolation.setTPCVDrift(mTPCVDriftHelper.getVDriftObject());
104110
mTPCVDriftHelper.acknowledgeUpdate();
105111
}
106-
if (mDebugOutput) {
107-
mInterpolation.setDumpTrackPoints();
108-
}
109-
mInterpolation.setExtDetResid(mExtDetResid);
110-
mInterpolation.setITSClusterDictionary(mITSDict);
111112
}
112113

113114
void TPCInterpolationDPL::finaliseCCDB(ConcreteDataMatcher& matcher, void* obj)

Detectors/GlobalTrackingWorkflow/tpcinterpolationworkflow/src/TPCResidualWriterSpec.cxx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ DataProcessorSpec getTPCResidualWriterSpec(bool writeTrackData, bool debugOutput
3838
BranchDefinition<std::vector<TrackData>>{InputSpec{"tracksUnfiltered", "GLO", "TPCINT_TRK", 0}, "tracksUnfiltered", ((writeUnfiltered && writeTrackData) ? 1 : 0)},
3939
BranchDefinition<std::vector<TPCClusterResiduals>>{InputSpec{"residualsUnfiltered", "GLO", "TPCINT_RES", 0}, "residualsUnfiltered", (writeUnfiltered ? 1 : 0)},
4040
BranchDefinition<std::vector<UnbinnedResid>>{InputSpec{"residuals", "GLO", "UNBINNEDRES"}, "residuals"},
41+
BranchDefinition<std::vector<DetInfoResid>>{InputSpec{"detInfo", "GLO", "DETINFORES"}, "detInfo"},
4142
BranchDefinition<std::vector<TrackDataCompact>>{InputSpec{"trackRefs", "GLO", "TRKREFS"}, "trackRefs"},
4243
BranchDefinition<std::vector<TrackData>>{InputSpec{"tracks", "GLO", "TRKDATA"}, "tracks", (writeTrackData ? 1 : 0)},
4344
BranchDefinition<std::vector<TrackDataExtended>>{InputSpec{"trackExt", "GLO", "TRKDATAEXT"}, "trackExt", (debugOutput ? 1 : 0)})();

Detectors/TPC/calibration/SpacePoints/CMakeLists.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@ o2_add_library(SpacePoints
2929
O2::DataFormatsITSMFT
3030
O2::DataFormatsTRD
3131
O2::DataFormatsTOF
32-
O2::DataFormatsGlobalTracking)
32+
O2::DataFormatsGlobalTracking
33+
O2::GPUTracking)
3334

3435
o2_target_root_dictionary(SpacePoints
3536
HEADERS include/SpacePoints/TrackResiduals.h

Detectors/TPC/calibration/SpacePoints/include/SpacePoints/TrackInterpolation.h

Lines changed: 41 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,11 @@ class TTree;
4747
namespace o2
4848
{
4949

50+
namespace gpu
51+
{
52+
class GPUParam;
53+
}
54+
5055
namespace tpc
5156
{
5257
class VDriftCorrFact;
@@ -148,12 +153,25 @@ struct DetInfoResid { // detector info associated with residual
148153
/// Structure for the information required to associate each residual with a given track type (ITS-TPC-TRD-TOF, etc)
149154
struct TrackDataCompact {
150155
TrackDataCompact() = default;
151-
TrackDataCompact(uint32_t idx, uint8_t nRes, uint8_t source, uint8_t nextraRes = 0) : idxFirstResidual(idx), nResiduals(nRes), sourceId(source), nExtDetResid(nextraRes) {}
156+
TrackDataCompact(uint32_t idx, std::array<uint8_t, 4> mlt, uint8_t nRes, uint8_t source, uint8_t nextraRes = 0) : idxFirstResidual(idx), multStack{mlt}, nResiduals(nRes), sourceId(source), nExtDetResid(nextraRes) {}
152157
uint32_t idxFirstResidual; ///< the index of the first residual from this track
158+
std::array<uint8_t, 4> multStack{}; // multiplicity in the stack packed as asinh(x*0.05)/0.05
153159
uint8_t nResiduals; ///< total number of TPC residuals associated to this track
154160
uint8_t nExtDetResid = 0; ///< number of external detectors (wrt TPC) residuals stored, on top of clIdx.getEntries
155161
uint8_t sourceId; ///< source ID obtained from the global track ID
156-
ClassDefNV(TrackDataCompact, 2);
162+
163+
void setMultStack(float v, int stack)
164+
{
165+
uint32_t mltPacked = std::round(std::asinh(v * 0.05) / 0.05);
166+
multStack[stack] = mltPacked < 0xff ? mltPacked : 0xff;
167+
}
168+
float getMultStack(int stack) const
169+
{
170+
return std::sinh(multStack[stack] * 0.05) / 0.05;
171+
}
172+
float getMultStackPacked(int stack) const { return multStack[stack]; }
173+
174+
ClassDefNV(TrackDataCompact, 3);
157175
};
158176

159177
// TODO add to UnbinnedResid::sec flag if cluster was used or not
@@ -193,11 +211,22 @@ struct TrackData {
193211
short TRDTrkltSlope[6] = {}; ///< TRD tracklet slope 0x7fff / param::MaxTRDSlope
194212
uint8_t nExtDetResid = 0; ///< number of external detectors (to TPC) residuals stored, on top of clIdx.getEntries
195213
o2::dataformats::RangeReference<> clIdx{}; ///< index of first cluster residual and total number of TPC cluster residuals of this track
196-
214+
std::array<uint8_t, 4> multStack{}; // multiplicity in the stack packed as asinh(x*0.05)/0.05
197215
float getT0Error() const { return float(clAvailTOF); }
198216
bool isTOFAvail() const { return clAvailTOF != 0; }
199217

200-
ClassDefNV(TrackData, 9);
218+
void setMultStack(float v, int stack)
219+
{
220+
uint32_t mltPacked = std::round(std::asinh(v * 0.05) / 0.05);
221+
multStack[stack] = mltPacked < 0xff ? mltPacked : 0xff;
222+
}
223+
float getMultStack(int stack) const
224+
{
225+
return std::sinh(multStack[stack] * 0.05) / 0.05;
226+
}
227+
float getMultStackPacked(int stack) const { return multStack[stack]; }
228+
229+
ClassDefNV(TrackData, 10);
201230
};
202231

203232
/// \class TrackInterpolation
@@ -312,6 +341,8 @@ class TrackInterpolation
312341
void diffToMA(const int np, const std::array<float, param::NPadRows>& y, std::array<float, param::NPadRows>& diffMA) const;
313342

314343
// -------------------------------------- settings --------------------------------------------------
344+
void setNHBPerTF(int n) { mNHBPerTF = n; }
345+
315346
void setTPCVDrift(const o2::tpc::VDriftCorrFact& v);
316347

317348
/// Sets the flag if material correction should be applied when extrapolating the tracks
@@ -355,8 +386,14 @@ class TrackInterpolation
355386

356387
private:
357388
static constexpr float sFloatEps{1.e-7f}; ///< float epsilon for robust linear fitting
389+
static constexpr int NSTACKS = 4;
390+
static constexpr std::array<int, NSTACKS + 1> STACKROWS{0, 63, 97, 127, 152};
358391
// parameters + settings
359392
const SpacePointsCalibConfParam* mParams = nullptr;
393+
std::shared_ptr<o2::gpu::GPUParam> mTPCParam = nullptr;
394+
int mNHBPerTF = 32;
395+
int mNTPCOccBinLength = 16; ///< TPC occupancy bin length in TB
396+
float mNTPCOccBinLengthInv = 1.f / 16; ///< its inverse
360397
float mTPCTimeBinMUS{.2f}; ///< TPC time bin duration in us
361398
float mTPCVDriftRef = -1.; ///< TPC nominal drift speed in cm/microseconds
362399
float mTPCDriftTimeOffsetRef = 0.; ///< TPC nominal (e.g. at the start of run) drift time bias in cm/mus

Detectors/TPC/calibration/SpacePoints/src/TrackInterpolation.cxx

Lines changed: 70 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,11 @@
3333
#include "DataFormatsTPC/VDriftCorrFact.h"
3434
#include "Framework/Logger.h"
3535
#include "CCDB/BasicCCDBManager.h"
36+
#include "GPUO2InterfaceUtils.h"
37+
#include "GPUO2InterfaceConfiguration.h"
38+
#include "GPUO2InterfaceRefit.h"
39+
#include "GPUParam.h"
40+
#include "GPUParam.inc"
3641
#include <set>
3742
#include <algorithm>
3843
#include <random>
@@ -135,7 +140,7 @@ void TrackInterpolation::init(o2::dataformats::GlobalTrackID::mask_t src, o2::da
135140

136141
auto geom = o2::its::GeometryTGeo::Instance();
137142
geom->fillMatrixCache(o2::math_utils::bit2Mask(o2::math_utils::TransformType::T2L, o2::math_utils::TransformType::L2G));
138-
143+
mTPCParam = o2::gpu::GPUO2InterfaceUtils::getFullParamShared(0.f, mNHBPerTF);
139144
mInitDone = true;
140145
LOGP(info, "Done initializing TrackInterpolation. Configured track input: {}. Track input specifically for map: {}",
141146
GTrackID::getSourcesNames(mSourcesConfigured), mSingleSourcesConfigured ? "identical" : GTrackID::getSourcesNames(mSourcesConfiguredMap));
@@ -316,6 +321,10 @@ void TrackInterpolation::process()
316321
// set the input containers
317322
mTPCTracksClusIdx = mRecoCont->getTPCTracksClusterRefs();
318323
mTPCClusterIdxStruct = &mRecoCont->getTPCClusters();
324+
int nbOccTOT = o2::gpu::GPUO2InterfaceRefit::fillOccupancyMapGetSize(mNHBPerTF, mTPCParam.get());
325+
o2::gpu::GPUO2InterfaceUtils::paramUseExternalOccupancyMap(mTPCParam.get(), mNHBPerTF, mRecoCont->occupancyMapTPC.data(), nbOccTOT);
326+
mNTPCOccBinLength = mTPCParam->rec.tpc.occupancyMapTimeBins;
327+
mNTPCOccBinLengthInv = 1.f / mNTPCOccBinLength;
319328
{
320329
if (!mITSDict) {
321330
LOG(error) << "No ITS dictionary available";
@@ -473,6 +482,7 @@ void TrackInterpolation::interpolateTrack(int iSeed)
473482

474483
// store the TPC cluster positions in the cache, as well as dedx info
475484
std::array<std::pair<uint16_t, uint16_t>, constants::MAXGLOBALPADROW> mCacheDEDX{};
485+
std::array<short, constants::MAXGLOBALPADROW> multBins{};
476486
for (int iCl = trkTPC.getNClusterReferences(); iCl--;) {
477487
uint8_t sector, row;
478488
uint32_t clusterIndexInRow;
@@ -487,6 +497,10 @@ void TrackInterpolation::interpolateTrack(int iSeed)
487497
mCache[row].clAngle = o2::math_utils::sector2Angle(sector);
488498
mCacheDEDX[row].first = clTPC.getQtot();
489499
mCacheDEDX[row].second = clTPC.getQmax();
500+
int imb = int(clTPC.getTime() * mNTPCOccBinLengthInv);
501+
if (imb < mTPCParam->occupancyMapSize) {
502+
multBins[row] = 1 + std::max(0, imb);
503+
}
490504
}
491505

492506
// extrapolate seed through TPC and store track position at each pad row
@@ -678,6 +692,30 @@ void TrackInterpolation::interpolateTrack(int iSeed)
678692
}
679693
trackData.clIdx.setEntries(nClValidated);
680694

695+
// store multiplicity info
696+
for (int ist = 0; ist < NSTACKS; ist++) {
697+
int mltBinMin = 0x7ffff, mltBinMax = -1, prevBin = -1;
698+
for (int ir = STACKROWS[ist]; ir < STACKROWS[ist + 1]; ir++) {
699+
if (multBins[ir] != prevBin && multBins[ir] > 0) { // there is a cluster different from previous one
700+
prevBin = multBins[ir];
701+
if (multBins[ir] > mltBinMax) {
702+
mltBinMax = multBins[ir];
703+
}
704+
if (multBins[ir] < mltBinMin) {
705+
mltBinMin = multBins[ir];
706+
}
707+
}
708+
}
709+
if (--mltBinMin >= 0) { // we were offsetting bin IDs by 1!
710+
float avMlt = 0;
711+
for (int ib = mltBinMin; ib < mltBinMax; ib++) {
712+
avMlt += mTPCParam->occupancyMap[ib];
713+
}
714+
avMlt /= (mltBinMax - mltBinMin);
715+
trackData.setMultStack(avMlt, ist);
716+
}
717+
}
718+
681719
bool stopPropagation = !mExtDetResid;
682720
if (!stopPropagation) {
683721
// do we have TRD residuals to add?
@@ -798,7 +836,7 @@ void TrackInterpolation::interpolateTrack(int iSeed)
798836
}
799837

800838
mGIDsSuccess.push_back(mGIDs[iSeed]);
801-
mTrackDataCompact.emplace_back(trackData.clIdx.getFirstEntry(), nClValidated, mGIDs[iSeed].getSource(), trackData.nExtDetResid);
839+
mTrackDataCompact.emplace_back(trackData.clIdx.getFirstEntry(), trackData.multStack, nClValidated, mGIDs[iSeed].getSource(), trackData.nExtDetResid);
802840
mTrackData.push_back(std::move(trackData));
803841
if (mDumpTrackPoints) {
804842
(*trackDataExtended).clIdx.setEntries(nClValidated);
@@ -907,6 +945,7 @@ void TrackInterpolation::extrapolateTrack(int iSeed)
907945
unsigned short nMeasurements = 0;
908946
uint8_t clRowPrev = constants::MAXGLOBALPADROW; // used to identify and skip split clusters on the same pad row
909947
std::array<std::pair<uint16_t, uint16_t>, constants::MAXGLOBALPADROW> mCacheDEDX{};
948+
std::array<short, constants::MAXGLOBALPADROW> multBins{};
910949
for (int iCl = trkTPC.getNClusterReferences(); iCl--;) {
911950
uint8_t sector, row;
912951
uint32_t clusterIndexInRow;
@@ -942,6 +981,10 @@ void TrackInterpolation::extrapolateTrack(int iSeed)
942981
mCacheDEDX[row].first = cl.getQtot();
943982
mCacheDEDX[row].second = cl.getQmax();
944983
rowPrev = row;
984+
int imb = int(cl.getTime() * mNTPCOccBinLengthInv);
985+
if (imb < mTPCParam->occupancyMapSize) {
986+
multBins[row] = 1 + std::max(0, imb);
987+
}
945988
++nMeasurements;
946989
}
947990

@@ -986,6 +1029,30 @@ void TrackInterpolation::extrapolateTrack(int iSeed)
9861029
}
9871030
trackData.clIdx.setEntries(nClValidated);
9881031

1032+
// store multiplicity info
1033+
for (int ist = 0; ist < NSTACKS; ist++) {
1034+
int mltBinMin = 0x7ffff, mltBinMax = -1, prevBin = -1;
1035+
for (int ir = STACKROWS[ist]; ir < STACKROWS[ist + 1]; ir++) {
1036+
if (multBins[ir] != prevBin && multBins[ir] > 0) { // there is a cluster
1037+
prevBin = multBins[ir];
1038+
if (multBins[ir] > mltBinMax) {
1039+
mltBinMax = multBins[ir];
1040+
}
1041+
if (multBins[ir] < mltBinMin) {
1042+
mltBinMin = multBins[ir];
1043+
}
1044+
}
1045+
}
1046+
if (--mltBinMin >= 0) { // we were offsetting bin IDs by 1!
1047+
float avMlt = 0;
1048+
for (int ib = mltBinMin; ib < mltBinMax; ib++) {
1049+
avMlt += mTPCParam->occupancyMap[ib];
1050+
}
1051+
avMlt /= (mltBinMax - mltBinMin);
1052+
trackData.setMultStack(avMlt, ist);
1053+
}
1054+
}
1055+
9891056
bool stopPropagation = !mExtDetResid;
9901057
if (!stopPropagation) {
9911058
// do we have TRD residuals to add?
@@ -1117,7 +1184,7 @@ void TrackInterpolation::extrapolateTrack(int iSeed)
11171184
}
11181185
mTrackData.push_back(std::move(trackData));
11191186
mGIDsSuccess.push_back(mGIDs[iSeed]);
1120-
mTrackDataCompact.emplace_back(trackData.clIdx.getFirstEntry(), nClValidated, mGIDs[iSeed].getSource(), trackData.nExtDetResid);
1187+
mTrackDataCompact.emplace_back(trackData.clIdx.getFirstEntry(), trackData.multStack, nClValidated, mGIDs[iSeed].getSource(), trackData.nExtDetResid);
11211188
if (mDumpTrackPoints) {
11221189
(*trackDataExtended).clIdx.setEntries(nClValidated);
11231190
(*trackDataExtended).nExtDetResid = trackData.nExtDetResid;

0 commit comments

Comments
 (0)