Skip to content

Commit

Permalink
Assign lowest TPC cluster position as TPC track minR
Browse files Browse the repository at this point in the history
... even if the track was already propagated to the reference X=83cm.
  • Loading branch information
shahor02 committed Nov 14, 2023
1 parent 2b494d7 commit 33890e0
Show file tree
Hide file tree
Showing 4 changed files with 91 additions and 42 deletions.
65 changes: 39 additions & 26 deletions Detectors/GlobalTrackingWorkflow/src/SecondaryVertexingSpec.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ namespace o2d = o2::dataformats;
class SecondaryVertexingSpec : public Task
{
public:
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) {}
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) {}
~SecondaryVertexingSpec() override = default;
void init(InitContext& ic) final;
void run(ProcessingContext& pc) final;
Expand All @@ -69,6 +69,7 @@ class SecondaryVertexingSpec : public Task
std::shared_ptr<o2::base::GRPGeomRequest> mGGCCDBRequest;
o2::tpc::VDriftHelper mTPCVDriftHelper{};
o2::tpc::CorrectionMapsLoader mTPCCorrMapsLoader{};
GTrackID::mask_t mSrc{};
bool mEnableCascades = false;
bool mEnable3BodyVertices = false;
bool mEnableStrangenessTracking = false;
Expand Down Expand Up @@ -96,7 +97,9 @@ void SecondaryVertexingSpec::init(InitContext& ic)
mStrTracker.setMCTruthOn(mUseMC);
mVertexer.setStrangenessTracker(&mStrTracker);
}
mTPCCorrMapsLoader.init(ic);
if (mSrc[GTrackID::TPC]) {
mTPCCorrMapsLoader.init(ic);
}
}

void SecondaryVertexingSpec::run(ProcessingContext& pc)
Expand Down Expand Up @@ -151,8 +154,10 @@ void SecondaryVertexingSpec::finaliseCCDB(ConcreteDataMatcher& matcher, void* ob
void SecondaryVertexingSpec::updateTimeDependentParams(ProcessingContext& pc)
{
o2::base::GRPGeomHelper::instance().checkUpdates(pc);
mTPCVDriftHelper.extractCCDBInputs(pc);
mTPCCorrMapsLoader.extractCCDBInputs(pc);
if (mSrc[GTrackID::TPC]) {
mTPCVDriftHelper.extractCCDBInputs(pc);
mTPCCorrMapsLoader.extractCCDBInputs(pc);
}
static bool initOnceDone = false;
if (!initOnceDone) { // this params need to be queried only once
initOnceDone = true;
Expand All @@ -166,23 +171,25 @@ void SecondaryVertexingSpec::updateTimeDependentParams(ProcessingContext& pc)
}
}
// we may have other params which need to be queried regularly
bool updateMaps = false;
if (mTPCCorrMapsLoader.isUpdated()) {
mVertexer.setTPCCorrMaps(&mTPCCorrMapsLoader);
mTPCCorrMapsLoader.acknowledgeUpdate();
updateMaps = true;
}
if (mTPCVDriftHelper.isUpdated()) {
LOGP(info, "Updating TPC fast transform map with new VDrift factor of {} wrt reference {} and DriftTimeOffset correction {} wrt {} from source {}",
mTPCVDriftHelper.getVDriftObject().corrFact, mTPCVDriftHelper.getVDriftObject().refVDrift,
mTPCVDriftHelper.getVDriftObject().timeOffsetCorr, mTPCVDriftHelper.getVDriftObject().refTimeOffset,
mTPCVDriftHelper.getSourceName());
mVertexer.setTPCVDrift(mTPCVDriftHelper.getVDriftObject());
mTPCVDriftHelper.acknowledgeUpdate();
updateMaps = true;
}
if (updateMaps) {
mTPCCorrMapsLoader.updateVDrift(mTPCVDriftHelper.getVDriftObject().corrFact, mTPCVDriftHelper.getVDriftObject().refVDrift, mTPCVDriftHelper.getVDriftObject().getTimeOffset());
if (mSrc[GTrackID::TPC]) {
bool updateMaps = false;
if (mTPCCorrMapsLoader.isUpdated()) {
mVertexer.setTPCCorrMaps(&mTPCCorrMapsLoader);
mTPCCorrMapsLoader.acknowledgeUpdate();
updateMaps = true;
}
if (mTPCVDriftHelper.isUpdated()) {
LOGP(info, "Updating TPC fast transform map with new VDrift factor of {} wrt reference {} and DriftTimeOffset correction {} wrt {} from source {}",
mTPCVDriftHelper.getVDriftObject().corrFact, mTPCVDriftHelper.getVDriftObject().refVDrift,
mTPCVDriftHelper.getVDriftObject().timeOffsetCorr, mTPCVDriftHelper.getVDriftObject().refTimeOffset,
mTPCVDriftHelper.getSourceName());
mVertexer.setTPCVDrift(mTPCVDriftHelper.getVDriftObject());
mTPCVDriftHelper.acknowledgeUpdate();
updateMaps = true;
}
if (updateMaps) {
mTPCCorrMapsLoader.updateVDrift(mTPCVDriftHelper.getVDriftObject().corrFact, mTPCVDriftHelper.getVDriftObject().refVDrift, mTPCVDriftHelper.getVDriftObject().getTimeOffset());
}
}
if (mEnableStrangenessTracking) {
if (o2::base::Propagator::Instance()->getNominalBz() != mStrTracker.getBz()) {
Expand All @@ -203,7 +210,12 @@ DataProcessorSpec getSecondaryVertexingSpec(GTrackID::mask_t src, bool enableCas
auto dataRequest = std::make_shared<DataRequest>();
GTrackID::mask_t srcClus{};
if (enableStrangenesTracking) {
src |= (srcClus = GTrackID::getSourceMask(GTrackID::Source::ITS));
src |= (srcClus = GTrackID::getSourceMask(GTrackID::ITS));
}
if (src[GTrackID::TPC]) {
srcClus |= GTrackID::getSourceMask(GTrackID::TPC);
}
if (srcClus.any()) {
dataRequest->requestClusters(srcClus, useMC);
}
dataRequest->requestTracks(src, useMC);
Expand All @@ -217,9 +229,10 @@ DataProcessorSpec getSecondaryVertexingSpec(GTrackID::mask_t src, bool enableCas
enableStrangenesTracking ? o2::base::GRPGeomRequest::Aligned : o2::base::GRPGeomRequest::None, // geometry
dataRequest->inputs,
true);
o2::tpc::VDriftHelper::requestCCDBInputs(dataRequest->inputs);
o2::tpc::CorrectionMapsLoader::requestCCDBInputs(dataRequest->inputs, opts, lumiType);

if (src[GTrackID::TPC]) {
o2::tpc::VDriftHelper::requestCCDBInputs(dataRequest->inputs);
o2::tpc::CorrectionMapsLoader::requestCCDBInputs(dataRequest->inputs, opts, lumiType);
}
outputs.emplace_back("GLO", "V0S_IDX", 0, Lifetime::Timeframe); // found V0s indices
outputs.emplace_back("GLO", "V0S", 0, Lifetime::Timeframe); // found V0s
outputs.emplace_back("GLO", "PVTX_V0REFS", 0, Lifetime::Timeframe); // prim.vertex -> V0s refs
Expand All @@ -245,7 +258,7 @@ DataProcessorSpec getSecondaryVertexingSpec(GTrackID::mask_t src, bool enableCas
"secondary-vertexing",
dataRequest->inputs,
outputs,
AlgorithmSpec{adaptFromTask<SecondaryVertexingSpec>(dataRequest, ggRequest, enableCasc, enable3body, enableStrangenesTracking, useMC)},
AlgorithmSpec{adaptFromTask<SecondaryVertexingSpec>(dataRequest, ggRequest, src, enableCasc, enable3body, enableStrangenesTracking, useMC)},
opts};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,20 +80,23 @@ WorkflowSpec defineDataProcessing(ConfigContext const& configcontext)
auto disableRootOut = configcontext.options().get<bool>("disable-root-output");
auto enableCasc = !configcontext.options().get<bool>("disable-cascade-finder");
auto enable3body = !configcontext.options().get<bool>("disable-3body-finder");
auto enagleStrTr = !configcontext.options().get<bool>("disable-strangeness-tracker");
auto enableStrTr = !configcontext.options().get<bool>("disable-strangeness-tracker");
auto lumiType = configcontext.options().get<int>("lumi-type");

GID::mask_t src = allowedSources & GID::getSourcesMask(configcontext.options().get<std::string>("vertexing-sources"));
GID::mask_t dummy, srcClus = GID::includesDet(DetID::TOF, src) ? GID::getSourceMask(GID::TOF) : dummy; // eventually, TPC clusters will be needed for refit
if (enagleStrTr) {
if (enableStrTr) {
srcClus |= GID::getSourceMask(GID::ITS);
}
if (src[GID::TPC]) {
srcClus |= GID::getSourceMask(GID::TPC);
}
if (lumiType == 1) {
src = src | GID::getSourcesMask("CTP");
}
WorkflowSpec specs;

specs.emplace_back(o2::vertexing::getSecondaryVertexingSpec(src, enableCasc, enable3body, enagleStrTr, useMC, lumiType));
specs.emplace_back(o2::vertexing::getSecondaryVertexingSpec(src, enableCasc, enable3body, enableStrTr, useMC, lumiType));

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

if (!disableRootOut) {
specs.emplace_back(o2::vertexing::getSecondaryVertexWriterSpec());
if (enagleStrTr) {
if (enableStrTr) {
specs.emplace_back(o2::strangeness_tracking::getStrangenessTrackingWriterSpec(useMC));
}
}
Expand Down
12 changes: 9 additions & 3 deletions Detectors/Vertexing/include/DetectorsVertexing/SVertexer.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
#include "ReconstructionDataFormats/VtxTrackIndex.h"
#include "ReconstructionDataFormats/VtxTrackRef.h"
#include "CommonDataFormat/RangeReference.h"
#include "DataFormatsTPC/ClusterNativeHelper.h"
#include "DCAFitter/DCAFitterN.h"
#include "DetectorsVertexing/SVertexerParams.h"
#include "DetectorsVertexing/SVertexHypothesis.h"
Expand Down Expand Up @@ -131,11 +132,11 @@ class SVertexer
}
void setTPCVDrift(const o2::tpc::VDriftCorrFact& v);
void setTPCCorrMaps(o2::gpu::CorrectionMapsHelper* maph);
void initTPCTransform();
void setStrangenessTracker(o2::strangeness_tracking::StrangenessTracker* tracker) { mStrTracker = tracker; }
o2::strangeness_tracking::StrangenessTracker* getStrangenessTracker() { return mStrTracker; }

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

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

uint64_t getPairIdx(GIndex id1, GIndex id2) const
{
return (uint64_t(id1) << 32) | id2;
}
const o2::globaltracking::RecoContainer* mRecoCont = nullptr;
GIndex::mask_t mSrc{};

// at the moment not used
const o2::tpc::ClusterNativeAccess* mTPCClusterIdxStruct = nullptr; ///< struct holding the TPC cluster indices
gsl::span<const o2::tpc::TrackTPC> mTPCTracksArray; ///< input TPC tracks span
gsl::span<const o2::tpc::TPCClRefElem> mTPCTrackClusIdx; ///< input TPC track cluster indices span
gsl::span<const unsigned char> mTPCRefitterShMap; ///< externally set TPC clusters sharing map
o2::gpu::CorrectionMapsHelper* mTPCCorrMapsHelper = nullptr;
std::unique_ptr<o2::gpu::GPUO2InterfaceRefit> mTPCRefitter; ///< TPC refitter used for TPC tracks refit during the reconstruction
o2::strangeness_tracking::StrangenessTracker* mStrTracker = nullptr;
Expand Down
45 changes: 36 additions & 9 deletions Detectors/Vertexing/src/SVertexer.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,13 @@
#include "DetectorsVertexing/SVertexer.h"
#include "DetectorsBase/Propagator.h"
#include "TPCReconstruction/TPCFastTransformHelperO2.h"
#include "DataFormatsTPC/WorkflowHelper.h"
#include "DataFormatsTPC/VDriftCorrFact.h"
#include "CorrectionMapsHelper.h"
#include "Framework/ProcessingContext.h"
#include "Framework/DataProcessorSpec.h"
#include "ReconstructionDataFormats/StrangeTrack.h"
#include "CommonConstants/GeomConstants.h"

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

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

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

//______________________________________________
float SVertexer::correctTPCTrack(o2::track::TrackParCov& trc, const o2::tpc::TrackTPC tTPC, float tmus, float tmusErr) const
float SVertexer::correctTPCTrack(SVertexer::TrackCand& trc, const o2::tpc::TrackTPC& tTPC, float tmus, float tmusErr) const
{
// Correct the track copy trc of the TPC track for the assumed interaction time
// return extra uncertainty in Z due to the interaction time uncertainty
// TODO: at the moment, apply simple shift, but with Z-dependent calibration we may
// need to do corrections on TPC cluster level and refit
// This is a clone of MatchTPCITS::correctTPCTrack
float dDrift = (tmus * mMUS2TPCBin - tTPC.getTime0()) * mTPCBin2Z;
float driftErr = tmusErr * mMUS2TPCBin * mTPCBin2Z;
// This is almosto clone of the MatchTPCITS::correctTPCTrack

float tTB, tTBErr;
if (tmusErr < 0) { // use track data
tTB = tTPC.getTime0();
tTBErr = 0.5 * (tTPC.getDeltaTBwd() + tTPC.getDeltaTFwd());
} else {
tTB = tmus * mMUS2TPCBin;
tTBErr = tmusErr * mMUS2TPCBin;
}
float dDrift = (tTB - tTPC.getTime0()) * mTPCBin2Z;
float driftErr = tTBErr * mTPCBin2Z;
// eventually should be refitted, at the moment we simply shift...
trc.setZ(tTPC.getZ() + (tTPC.hasASideClustersOnly() ? dDrift : -dDrift));
trc.setCov(trc.getSigmaZ2() + driftErr * driftErr, o2::track::kSigZ2);

uint8_t sector, row;
auto cl = &tTPC.getCluster(mTPCTrackClusIdx, tTPC.getNClusters() - 1, *mTPCClusterIdxStruct, sector, row);
float x = 0, y = 0, z = 0;
mTPCCorrMapsHelper->Transform(sector, row, cl->getPad(), cl->getTime(), x, y, z, tTB);
if (x < o2::constants::geom::XTPCInnerRef) {
x = o2::constants::geom::XTPCInnerRef;
}
trc.minR = std::sqrt(x * x + y * y);
LOGP(debug, "set MinR = {} for row {}, x:{}, y:{}, z:{}", trc.minR, row, x, y, z);
return driftErr;
}

Expand Down

0 comments on commit 33890e0

Please sign in to comment.