Skip to content

Commit

Permalink
update cluster
Browse files Browse the repository at this point in the history
  • Loading branch information
f3sch committed Nov 20, 2023
1 parent a54277e commit 9b192b1
Show file tree
Hide file tree
Showing 3 changed files with 78 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,11 @@ DataProcessorSpec getSecondaryVertexingSpec(GTrackID::mask_t src, bool enableCas
GTrackID::mask_t srcClus{};
if (enableStrangenesTracking) {
src |= (srcClus = GTrackID::getSourceMask(GTrackID::Source::ITS));
}
if (src[GTrackID::TPC]) {
srcClus |= GTrackID::getSourceMask(GTrackID::TPC);
}
if (srcClus.any()) {
dataRequest->requestClusters(srcClus, useMC);
}
dataRequest->requestTracks(src, useMC);
Expand Down
9 changes: 7 additions & 2 deletions Detectors/Vertexing/include/DetectorsVertexing/SVertexer.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,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 @@ -161,13 +162,17 @@ class SVertexer
void updateTimeDependentParams();
bool acceptTrack(GIndex gid, const o2::track::TrackParCov& trc);
bool processTPCTrack(const o2::tpc::TrackTPC& trTPC, GIndex gid, int vtxid, bool& status);
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;

static uint64_t getPairIdx(GIndex id1, GIndex id2)
{
return (uint64_t(id1) << 32) | id2;
}

const o2::globaltracking::RecoContainer* mRecoCont = nullptr;
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
// at the moment not used
o2::gpu::CorrectionMapsHelper* mTPCCorrMapsHelper = nullptr;
std::unique_ptr<o2::gpu::GPUO2InterfaceRefit> mTPCRefitter; ///< TPC refitter used for TPC tracks refit during the reconstruction
Expand Down
71 changes: 66 additions & 5 deletions Detectors/Vertexing/src/SVertexer.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@
#include "FairLogger.h"
#include "DataFormatsTRD/TrackTRD.h"
#include "SimulationDataFormat/MCEventLabel.h"
#include "CommonConstants/GeomConstants.h"
#include "DataFormatsTPC/WorkflowHelper.h"

#include "TTree.h"
#include "TFile.h"
Expand All @@ -48,6 +50,7 @@ using TrackTPC = o2::tpc::TrackTPC;
//__________________________________________________________________
void SVertexer::process(const o2::globaltracking::RecoContainer& recoData, o2::framework::ProcessingContext& pc)
{
mRecoCont = &recoData;
LOGP(info, "Enabled MC={} Enabled Recheck={}", mUseMC, mCheckFound);
if (mCheckFound) {
LOGP(info, "Rechecking found V0s");
Expand Down Expand Up @@ -76,6 +79,11 @@ void SVertexer::process(const o2::globaltracking::RecoContainer& recoData, o2::f
mITSTrkLabels = recoData.getITSTracksMCLabels();
mTPCTrkLabels = recoData.getTPCTracksMCLabels();
mPVertexLabels = recoData.getPrimaryVertexMCLabels();
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());
buildT2V(recoData); // build track->vertex refs from vertex->track (if other workflow will need this, consider producing a message in the VertexTrackMatcher)
int ntrP = mTracksPool[POS].size(), ntrN = mTracksPool[NEG].size();
if (mStrTracker) {
Expand Down Expand Up @@ -533,7 +541,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.
bool status = false;
if (processTPCTrack(recoData.getTPCTrack(tvid), tvid, iv, status)) {
if (processTPCTrack(mTPCTracksArray[tvid], tvid, iv, status)) {
if (status) {
mCounterBuildT2V.inc(BUILDT2V::TPCSPROCESS, tvid, lbl, mD0V0Map, mD1V0Map, mMCParticle);
++cTPC;
Expand Down Expand Up @@ -587,6 +595,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 @@ -1380,19 +1391,38 @@ bool SVertexer::processTPCTrack(const o2::tpc::TrackTPC& trTPC, GIndex gid, int
}

//______________________________________________
float SVertexer::correctTPCTrack(o2::track::TrackParCov& trc, const o2::tpc::TrackTPC& tTPC, float tmus, float tmusErr) const
float SVertexer::correctTPCTrack(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;
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;
if (driftErr < 0) {
return driftErr;
}
// 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 All @@ -1407,6 +1437,35 @@ bool SVertexer::writeDebugV0Candidates(o2::tpc::TrackTPC const& trk, GIndex gid,
MCTrack mother;
bool goodProp = false, isV0 = (mD0V0Map.find(idx) != mD0V0Map.end() || mD1V0Map.find(idx) != mD1V0Map.end());
o2::track::TrackPar trkProp;
std::array<bool, 152> clMap{};
uint8_t sectorIndex, rowIndex;
uint32_t clusterIndex;
uint8_t found = 0;
uint8_t crossed = 0;
constexpr int maxRows = 152;
constexpr int neighbour = 2;
for (int i = 0; i < trk.getNClusterReferences(); i++) {
o2::tpc::TrackTPC::getClusterReference(mTPCTrackClusIdx, i, sectorIndex, rowIndex, clusterIndex, trk.getClusterRef());
clMap[rowIndex] = true;
}
int last = -1;
for (int i = 0; i < maxRows; i++) {
if (clMap[i]) {
crossed++;
found++;
last = i;
} else if ((i - last) <= neighbour) {
crossed++;
} else {
int lim = std::min(i + 1 + neighbour, maxRows);
for (int j = i + 1; j < lim; j++) {
if (clMap[j]) {
crossed++;
break;
}
}
}
}

while (!goodProp) {
if (!lbl.isValid() || lbl.isFake() || (mcTrack = mcReader.getTrack(lbl)) == nullptr) {
Expand Down Expand Up @@ -1442,6 +1501,8 @@ bool SVertexer::writeDebugV0Candidates(o2::tpc::TrackTPC const& trk, GIndex gid,
<< "propTrk=" << trkProp
<< "mcTrk=" << mcTrack
<< "mcMother=" << mother
<< "crossed=" << crossed
<< "found=" << found
<< "isV0=" << isV0
<< "goodProp=" << goodProp
<< "endMarker=" << marker++
Expand Down

0 comments on commit 9b192b1

Please sign in to comment.