Skip to content

Commit 33890e0

Browse files
committed
Assign lowest TPC cluster position as TPC track minR
... even if the track was already propagated to the reference X=83cm.
1 parent 2b494d7 commit 33890e0

File tree

4 files changed

+91
-42
lines changed

4 files changed

+91
-42
lines changed

Detectors/GlobalTrackingWorkflow/src/SecondaryVertexingSpec.cxx

Lines changed: 39 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ namespace o2d = o2::dataformats;
5656
class SecondaryVertexingSpec : public Task
5757
{
5858
public:
59-
SecondaryVertexingSpec(std::shared_ptr<DataRequest> dr, std::shared_ptr<o2::base::GRPGeomRequest> gr, bool enabCasc, bool enable3body, bool enableStrangenessTracking, bool useMC) : mDataRequest(dr), mGGCCDBRequest(gr), mEnableCascades(enabCasc), mEnable3BodyVertices(enable3body), mEnableStrangenessTracking(enableStrangenessTracking), mUseMC(useMC) {}
59+
SecondaryVertexingSpec(std::shared_ptr<DataRequest> dr, std::shared_ptr<o2::base::GRPGeomRequest> gr, GTrackID::mask_t src, bool enabCasc, bool enable3body, bool enableStrangenessTracking, bool useMC) : mDataRequest(dr), mGGCCDBRequest(gr), mSrc(src), mEnableCascades(enabCasc), mEnable3BodyVertices(enable3body), mEnableStrangenessTracking(enableStrangenessTracking), mUseMC(useMC) {}
6060
~SecondaryVertexingSpec() override = default;
6161
void init(InitContext& ic) final;
6262
void run(ProcessingContext& pc) final;
@@ -69,6 +69,7 @@ class SecondaryVertexingSpec : public Task
6969
std::shared_ptr<o2::base::GRPGeomRequest> mGGCCDBRequest;
7070
o2::tpc::VDriftHelper mTPCVDriftHelper{};
7171
o2::tpc::CorrectionMapsLoader mTPCCorrMapsLoader{};
72+
GTrackID::mask_t mSrc{};
7273
bool mEnableCascades = false;
7374
bool mEnable3BodyVertices = false;
7475
bool mEnableStrangenessTracking = false;
@@ -96,7 +97,9 @@ void SecondaryVertexingSpec::init(InitContext& ic)
9697
mStrTracker.setMCTruthOn(mUseMC);
9798
mVertexer.setStrangenessTracker(&mStrTracker);
9899
}
99-
mTPCCorrMapsLoader.init(ic);
100+
if (mSrc[GTrackID::TPC]) {
101+
mTPCCorrMapsLoader.init(ic);
102+
}
100103
}
101104

102105
void SecondaryVertexingSpec::run(ProcessingContext& pc)
@@ -151,8 +154,10 @@ void SecondaryVertexingSpec::finaliseCCDB(ConcreteDataMatcher& matcher, void* ob
151154
void SecondaryVertexingSpec::updateTimeDependentParams(ProcessingContext& pc)
152155
{
153156
o2::base::GRPGeomHelper::instance().checkUpdates(pc);
154-
mTPCVDriftHelper.extractCCDBInputs(pc);
155-
mTPCCorrMapsLoader.extractCCDBInputs(pc);
157+
if (mSrc[GTrackID::TPC]) {
158+
mTPCVDriftHelper.extractCCDBInputs(pc);
159+
mTPCCorrMapsLoader.extractCCDBInputs(pc);
160+
}
156161
static bool initOnceDone = false;
157162
if (!initOnceDone) { // this params need to be queried only once
158163
initOnceDone = true;
@@ -166,23 +171,25 @@ void SecondaryVertexingSpec::updateTimeDependentParams(ProcessingContext& pc)
166171
}
167172
}
168173
// we may have other params which need to be queried regularly
169-
bool updateMaps = false;
170-
if (mTPCCorrMapsLoader.isUpdated()) {
171-
mVertexer.setTPCCorrMaps(&mTPCCorrMapsLoader);
172-
mTPCCorrMapsLoader.acknowledgeUpdate();
173-
updateMaps = true;
174-
}
175-
if (mTPCVDriftHelper.isUpdated()) {
176-
LOGP(info, "Updating TPC fast transform map with new VDrift factor of {} wrt reference {} and DriftTimeOffset correction {} wrt {} from source {}",
177-
mTPCVDriftHelper.getVDriftObject().corrFact, mTPCVDriftHelper.getVDriftObject().refVDrift,
178-
mTPCVDriftHelper.getVDriftObject().timeOffsetCorr, mTPCVDriftHelper.getVDriftObject().refTimeOffset,
179-
mTPCVDriftHelper.getSourceName());
180-
mVertexer.setTPCVDrift(mTPCVDriftHelper.getVDriftObject());
181-
mTPCVDriftHelper.acknowledgeUpdate();
182-
updateMaps = true;
183-
}
184-
if (updateMaps) {
185-
mTPCCorrMapsLoader.updateVDrift(mTPCVDriftHelper.getVDriftObject().corrFact, mTPCVDriftHelper.getVDriftObject().refVDrift, mTPCVDriftHelper.getVDriftObject().getTimeOffset());
174+
if (mSrc[GTrackID::TPC]) {
175+
bool updateMaps = false;
176+
if (mTPCCorrMapsLoader.isUpdated()) {
177+
mVertexer.setTPCCorrMaps(&mTPCCorrMapsLoader);
178+
mTPCCorrMapsLoader.acknowledgeUpdate();
179+
updateMaps = true;
180+
}
181+
if (mTPCVDriftHelper.isUpdated()) {
182+
LOGP(info, "Updating TPC fast transform map with new VDrift factor of {} wrt reference {} and DriftTimeOffset correction {} wrt {} from source {}",
183+
mTPCVDriftHelper.getVDriftObject().corrFact, mTPCVDriftHelper.getVDriftObject().refVDrift,
184+
mTPCVDriftHelper.getVDriftObject().timeOffsetCorr, mTPCVDriftHelper.getVDriftObject().refTimeOffset,
185+
mTPCVDriftHelper.getSourceName());
186+
mVertexer.setTPCVDrift(mTPCVDriftHelper.getVDriftObject());
187+
mTPCVDriftHelper.acknowledgeUpdate();
188+
updateMaps = true;
189+
}
190+
if (updateMaps) {
191+
mTPCCorrMapsLoader.updateVDrift(mTPCVDriftHelper.getVDriftObject().corrFact, mTPCVDriftHelper.getVDriftObject().refVDrift, mTPCVDriftHelper.getVDriftObject().getTimeOffset());
192+
}
186193
}
187194
if (mEnableStrangenessTracking) {
188195
if (o2::base::Propagator::Instance()->getNominalBz() != mStrTracker.getBz()) {
@@ -203,7 +210,12 @@ DataProcessorSpec getSecondaryVertexingSpec(GTrackID::mask_t src, bool enableCas
203210
auto dataRequest = std::make_shared<DataRequest>();
204211
GTrackID::mask_t srcClus{};
205212
if (enableStrangenesTracking) {
206-
src |= (srcClus = GTrackID::getSourceMask(GTrackID::Source::ITS));
213+
src |= (srcClus = GTrackID::getSourceMask(GTrackID::ITS));
214+
}
215+
if (src[GTrackID::TPC]) {
216+
srcClus |= GTrackID::getSourceMask(GTrackID::TPC);
217+
}
218+
if (srcClus.any()) {
207219
dataRequest->requestClusters(srcClus, useMC);
208220
}
209221
dataRequest->requestTracks(src, useMC);
@@ -217,9 +229,10 @@ DataProcessorSpec getSecondaryVertexingSpec(GTrackID::mask_t src, bool enableCas
217229
enableStrangenesTracking ? o2::base::GRPGeomRequest::Aligned : o2::base::GRPGeomRequest::None, // geometry
218230
dataRequest->inputs,
219231
true);
220-
o2::tpc::VDriftHelper::requestCCDBInputs(dataRequest->inputs);
221-
o2::tpc::CorrectionMapsLoader::requestCCDBInputs(dataRequest->inputs, opts, lumiType);
222-
232+
if (src[GTrackID::TPC]) {
233+
o2::tpc::VDriftHelper::requestCCDBInputs(dataRequest->inputs);
234+
o2::tpc::CorrectionMapsLoader::requestCCDBInputs(dataRequest->inputs, opts, lumiType);
235+
}
223236
outputs.emplace_back("GLO", "V0S_IDX", 0, Lifetime::Timeframe); // found V0s indices
224237
outputs.emplace_back("GLO", "V0S", 0, Lifetime::Timeframe); // found V0s
225238
outputs.emplace_back("GLO", "PVTX_V0REFS", 0, Lifetime::Timeframe); // prim.vertex -> V0s refs
@@ -245,7 +258,7 @@ DataProcessorSpec getSecondaryVertexingSpec(GTrackID::mask_t src, bool enableCas
245258
"secondary-vertexing",
246259
dataRequest->inputs,
247260
outputs,
248-
AlgorithmSpec{adaptFromTask<SecondaryVertexingSpec>(dataRequest, ggRequest, enableCasc, enable3body, enableStrangenesTracking, useMC)},
261+
AlgorithmSpec{adaptFromTask<SecondaryVertexingSpec>(dataRequest, ggRequest, src, enableCasc, enable3body, enableStrangenesTracking, useMC)},
249262
opts};
250263
}
251264

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

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -80,20 +80,23 @@ WorkflowSpec defineDataProcessing(ConfigContext const& configcontext)
8080
auto disableRootOut = configcontext.options().get<bool>("disable-root-output");
8181
auto enableCasc = !configcontext.options().get<bool>("disable-cascade-finder");
8282
auto enable3body = !configcontext.options().get<bool>("disable-3body-finder");
83-
auto enagleStrTr = !configcontext.options().get<bool>("disable-strangeness-tracker");
83+
auto enableStrTr = !configcontext.options().get<bool>("disable-strangeness-tracker");
8484
auto lumiType = configcontext.options().get<int>("lumi-type");
8585

8686
GID::mask_t src = allowedSources & GID::getSourcesMask(configcontext.options().get<std::string>("vertexing-sources"));
8787
GID::mask_t dummy, srcClus = GID::includesDet(DetID::TOF, src) ? GID::getSourceMask(GID::TOF) : dummy; // eventually, TPC clusters will be needed for refit
88-
if (enagleStrTr) {
88+
if (enableStrTr) {
8989
srcClus |= GID::getSourceMask(GID::ITS);
9090
}
91+
if (src[GID::TPC]) {
92+
srcClus |= GID::getSourceMask(GID::TPC);
93+
}
9194
if (lumiType == 1) {
9295
src = src | GID::getSourcesMask("CTP");
9396
}
9497
WorkflowSpec specs;
9598

96-
specs.emplace_back(o2::vertexing::getSecondaryVertexingSpec(src, enableCasc, enable3body, enagleStrTr, useMC, lumiType));
99+
specs.emplace_back(o2::vertexing::getSecondaryVertexingSpec(src, enableCasc, enable3body, enableStrTr, useMC, lumiType));
97100

98101
// only TOF clusters are needed if TOF is involved, no clusters MC needed
99102
WorkflowSpec inputspecs;
@@ -118,7 +121,7 @@ WorkflowSpec defineDataProcessing(ConfigContext const& configcontext)
118121

119122
if (!disableRootOut) {
120123
specs.emplace_back(o2::vertexing::getSecondaryVertexWriterSpec());
121-
if (enagleStrTr) {
124+
if (enableStrTr) {
122125
specs.emplace_back(o2::strangeness_tracking::getStrangenessTrackingWriterSpec(useMC));
123126
}
124127
}

Detectors/Vertexing/include/DetectorsVertexing/SVertexer.h

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
#include "ReconstructionDataFormats/VtxTrackIndex.h"
2727
#include "ReconstructionDataFormats/VtxTrackRef.h"
2828
#include "CommonDataFormat/RangeReference.h"
29+
#include "DataFormatsTPC/ClusterNativeHelper.h"
2930
#include "DCAFitter/DCAFitterN.h"
3031
#include "DetectorsVertexing/SVertexerParams.h"
3132
#include "DetectorsVertexing/SVertexHypothesis.h"
@@ -131,11 +132,11 @@ class SVertexer
131132
}
132133
void setTPCVDrift(const o2::tpc::VDriftCorrFact& v);
133134
void setTPCCorrMaps(o2::gpu::CorrectionMapsHelper* maph);
134-
void initTPCTransform();
135135
void setStrangenessTracker(o2::strangeness_tracking::StrangenessTracker* tracker) { mStrTracker = tracker; }
136136
o2::strangeness_tracking::StrangenessTracker* getStrangenessTracker() { return mStrTracker; }
137137

138138
std::array<size_t, 3> getNFitterCalls() const;
139+
void setSources(GIndex::mask_t src) { mSrc = src; }
139140

140141
private:
141142
template <class TVI, class TCI, class T3I, class TR>
@@ -148,14 +149,19 @@ class SVertexer
148149
void updateTimeDependentParams();
149150
bool acceptTrack(GIndex gid, const o2::track::TrackParCov& trc) const;
150151
bool processTPCTrack(const o2::tpc::TrackTPC& trTPC, GIndex gid, int vtxid);
151-
float correctTPCTrack(o2::track::TrackParCov& trc, const o2::tpc::TrackTPC tTPC, float tmus, float tmusErr) const;
152+
float correctTPCTrack(TrackCand& trc, const o2::tpc::TrackTPC& tTPC, float tmus, float tmusErr) const;
152153

153154
uint64_t getPairIdx(GIndex id1, GIndex id2) const
154155
{
155156
return (uint64_t(id1) << 32) | id2;
156157
}
158+
const o2::globaltracking::RecoContainer* mRecoCont = nullptr;
159+
GIndex::mask_t mSrc{};
157160

158-
// at the moment not used
161+
const o2::tpc::ClusterNativeAccess* mTPCClusterIdxStruct = nullptr; ///< struct holding the TPC cluster indices
162+
gsl::span<const o2::tpc::TrackTPC> mTPCTracksArray; ///< input TPC tracks span
163+
gsl::span<const o2::tpc::TPCClRefElem> mTPCTrackClusIdx; ///< input TPC track cluster indices span
164+
gsl::span<const unsigned char> mTPCRefitterShMap; ///< externally set TPC clusters sharing map
159165
o2::gpu::CorrectionMapsHelper* mTPCCorrMapsHelper = nullptr;
160166
std::unique_ptr<o2::gpu::GPUO2InterfaceRefit> mTPCRefitter; ///< TPC refitter used for TPC tracks refit during the reconstruction
161167
o2::strangeness_tracking::StrangenessTracker* mStrTracker = nullptr;

Detectors/Vertexing/src/SVertexer.cxx

Lines changed: 36 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,13 @@
1616
#include "DetectorsVertexing/SVertexer.h"
1717
#include "DetectorsBase/Propagator.h"
1818
#include "TPCReconstruction/TPCFastTransformHelperO2.h"
19+
#include "DataFormatsTPC/WorkflowHelper.h"
1920
#include "DataFormatsTPC/VDriftCorrFact.h"
2021
#include "CorrectionMapsHelper.h"
2122
#include "Framework/ProcessingContext.h"
2223
#include "Framework/DataProcessorSpec.h"
2324
#include "ReconstructionDataFormats/StrangeTrack.h"
25+
#include "CommonConstants/GeomConstants.h"
2426

2527
#ifdef WITH_OPENMP
2628
#include <omp.h>
@@ -38,6 +40,7 @@ using TrackTPC = o2::tpc::TrackTPC;
3840
//__________________________________________________________________
3941
void SVertexer::process(const o2::globaltracking::RecoContainer& recoData, o2::framework::ProcessingContext& pc)
4042
{
43+
mRecoCont = &recoData;
4144
mNV0s = mNCascades = mN3Bodies = 0;
4245
updateTimeDependentParams(); // TODO RS: strictly speaking, one should do this only in case of the CCDB objects update
4346
mPVertices = recoData.getPrimaryVertices();
@@ -313,8 +316,6 @@ void SVertexer::setTPCVDrift(const o2::tpc::VDriftCorrFact& v)
313316
void SVertexer::setTPCCorrMaps(o2::gpu::CorrectionMapsHelper* maph)
314317
{
315318
mTPCCorrMapsHelper = maph;
316-
// to be used with refitter as
317-
// mTPCRefitter = std::make_unique<o2::gpu::GPUO2InterfaceRefit>(mTPCClusterIdxStruct, mTPCCorrMapsHelper, mBz, mTPCTrackClusIdx.data(), mTPCRefitterShMap.data(), nullptr, o2::base::Propagator::Instance());
318319
}
319320

320321
//__________________________________________________________________
@@ -428,6 +429,13 @@ void SVertexer::buildT2V(const o2::globaltracking::RecoContainer& recoData) // a
428429
auto trackIndex = recoData.getPrimaryVertexMatchedTracks(); // Global ID's for associated tracks
429430
auto vtxRefs = recoData.getPrimaryVertexMatchedTrackRefs(); // references from vertex to these track IDs
430431
bool isTPCloaded = recoData.isTrackSourceLoaded(GIndex::TPC);
432+
if (isTPCloaded && !mSVParams->mExcludeTPCtracks) {
433+
mTPCTracksArray = recoData.getTPCTracks();
434+
mTPCTrackClusIdx = recoData.getTPCTracksClusterRefs();
435+
mTPCClusterIdxStruct = &recoData.inputsTPCclusters->clusterIndex;
436+
mTPCRefitterShMap = recoData.clusterShMapTPC;
437+
mTPCRefitter = std::make_unique<o2::gpu::GPUO2InterfaceRefit>(mTPCClusterIdxStruct, mTPCCorrMapsHelper, o2::base::Propagator::Instance()->getNominalBz(), mTPCTrackClusIdx.data(), mTPCRefitterShMap.data(), nullptr, o2::base::Propagator::Instance());
438+
}
431439

432440
std::unordered_map<GIndex, std::pair<int, int>> tmap;
433441
std::unordered_map<GIndex, bool> rejmap;
@@ -451,7 +459,7 @@ void SVertexer::buildT2V(const o2::globaltracking::RecoContainer& recoData) // a
451459
}
452460
// unconstrained TPC tracks require special treatment: there is no point in checking DCA to mean vertex since it is not precise,
453461
// but we need to create a clone of TPC track constrained to this particular vertex time.
454-
if (processTPCTrack(recoData.getTPCTrack(tvid), tvid, iv)) {
462+
if (processTPCTrack(mTPCTracksArray[tvid], tvid, iv)) {
455463
continue;
456464
}
457465
}
@@ -489,6 +497,9 @@ void SVertexer::buildT2V(const o2::globaltracking::RecoContainer& recoData) // a
489497
int posneg = trc.getSign() < 0 ? 1 : 0;
490498
float r = std::sqrt(trc.getX() * trc.getX() + trc.getY() * trc.getY());
491499
mTracksPool[posneg].emplace_back(TrackCand{trc, tvid, {iv, iv}, r});
500+
if (tvid.getSource() == GIndex::TPC) { // constrained TPC track?
501+
correctTPCTrack(mTracksPool[posneg].back(), mTPCTracksArray[tvid], -1, -1);
502+
}
492503
if (tvid.isAmbiguous()) { // track attached to >1 vertex, remember that it was already processed
493504
tmap[tvid] = {mTracksPool[posneg].size() - 1, posneg};
494505
}
@@ -1130,24 +1141,40 @@ bool SVertexer::processTPCTrack(const o2::tpc::TrackTPC& trTPC, GIndex gid, int
11301141
if (err < 0) {
11311142
mTracksPool[posneg].pop_back(); // discard
11321143
}
1133-
trLoc.minR = std::sqrt(trLoc.getX() * trLoc.getX() + trLoc.getY() * trLoc.getY());
11341144
return true;
11351145
}
11361146

11371147
//______________________________________________
1138-
float SVertexer::correctTPCTrack(o2::track::TrackParCov& trc, const o2::tpc::TrackTPC tTPC, float tmus, float tmusErr) const
1148+
float SVertexer::correctTPCTrack(SVertexer::TrackCand& trc, const o2::tpc::TrackTPC& tTPC, float tmus, float tmusErr) const
11391149
{
11401150
// Correct the track copy trc of the TPC track for the assumed interaction time
11411151
// return extra uncertainty in Z due to the interaction time uncertainty
11421152
// TODO: at the moment, apply simple shift, but with Z-dependent calibration we may
11431153
// need to do corrections on TPC cluster level and refit
1144-
// This is a clone of MatchTPCITS::correctTPCTrack
1145-
float dDrift = (tmus * mMUS2TPCBin - tTPC.getTime0()) * mTPCBin2Z;
1146-
float driftErr = tmusErr * mMUS2TPCBin * mTPCBin2Z;
1154+
// This is almosto clone of the MatchTPCITS::correctTPCTrack
1155+
1156+
float tTB, tTBErr;
1157+
if (tmusErr < 0) { // use track data
1158+
tTB = tTPC.getTime0();
1159+
tTBErr = 0.5 * (tTPC.getDeltaTBwd() + tTPC.getDeltaTFwd());
1160+
} else {
1161+
tTB = tmus * mMUS2TPCBin;
1162+
tTBErr = tmusErr * mMUS2TPCBin;
1163+
}
1164+
float dDrift = (tTB - tTPC.getTime0()) * mTPCBin2Z;
1165+
float driftErr = tTBErr * mTPCBin2Z;
11471166
// eventually should be refitted, at the moment we simply shift...
11481167
trc.setZ(tTPC.getZ() + (tTPC.hasASideClustersOnly() ? dDrift : -dDrift));
11491168
trc.setCov(trc.getSigmaZ2() + driftErr * driftErr, o2::track::kSigZ2);
1150-
1169+
uint8_t sector, row;
1170+
auto cl = &tTPC.getCluster(mTPCTrackClusIdx, tTPC.getNClusters() - 1, *mTPCClusterIdxStruct, sector, row);
1171+
float x = 0, y = 0, z = 0;
1172+
mTPCCorrMapsHelper->Transform(sector, row, cl->getPad(), cl->getTime(), x, y, z, tTB);
1173+
if (x < o2::constants::geom::XTPCInnerRef) {
1174+
x = o2::constants::geom::XTPCInnerRef;
1175+
}
1176+
trc.minR = std::sqrt(x * x + y * y);
1177+
LOGP(debug, "set MinR = {} for row {}, x:{}, y:{}, z:{}", trc.minR, row, x, y, z);
11511178
return driftErr;
11521179
}
11531180

0 commit comments

Comments
 (0)