From 9257023a284c617c67051e8c64c6edd1c495132a Mon Sep 17 00:00:00 2001 From: Maximilian Korwieser Date: Fri, 4 Oct 2024 12:09:56 +0200 Subject: [PATCH] [TPC-QC] Add DCAr selection to Tracks.cxx --- Detectors/TPC/qc/include/TPCQC/Tracks.h | 34 +++++++----------- Detectors/TPC/qc/src/Tracks.cxx | 47 ++++++++++++++++++++++++- 2 files changed, 58 insertions(+), 23 deletions(-) diff --git a/Detectors/TPC/qc/include/TPCQC/Tracks.h b/Detectors/TPC/qc/include/TPCQC/Tracks.h index 882e7c9222c29..f6cff7c2b8090 100644 --- a/Detectors/TPC/qc/include/TPCQC/Tracks.h +++ b/Detectors/TPC/qc/include/TPCQC/Tracks.h @@ -69,7 +69,7 @@ class Tracks // To set the elementary track cuts void setTrackCuts(float AbsEta = 1., - int nClusterCut = 60, float dEdxTot = 20, float cutPtForDCAr = 1.5, float samplingFractionDCAr = 0.1, bool turnOffHistosForAsync = false) + int nClusterCut = 60, float dEdxTot = 20, float cutPtForDCAr = 1.5, float samplingFractionDCAr = 0.1, bool turnOffHistosForAsync = false, float cutMaxAbsDCAr = 0.1, bool useCutMaxAbsDCArOnHistos = false) { mCutAbsEta = AbsEta; mCutMinnCls = nClusterCut; @@ -77,34 +77,24 @@ class Tracks mCutMinPtDCAr = cutPtForDCAr; mSamplingFractionDCAr = samplingFractionDCAr; mTurnOffHistosForAsync = turnOffHistosForAsync; + mCutMaxAbsDCAr = cutMaxAbsDCAr; + mUseCutMaxAbsDCArOnHistos = useCutMaxAbsDCArOnHistos; } - // Just for backward compatibility with crrent QC, temporary, will be removed in the next PR - /// get 1D histograms - std::vector& getHistograms1D() { return mHist1D; } - const std::vector& getHistograms1D() const { return mHist1D; } - - // Just for backward compatibility with crrent QC, temporary, will be removed in the next PR - /// get 2D histograms - std::vector& getHistograms2D() { return mHist2D; } - const std::vector& getHistograms2D() const { return mHist2D; } - - // Just for backward compatibility with crrent QC, temporary, will be removed in the next PR - /// get ratios of 1D histograms - std::vector& getHistogramRatios1D() { return mHistRatio1D; } - const std::vector& getHistogramRatios1D() const { return mHistRatio1D; } - /// get ratios of 1D histograms std::unordered_map>& getMapHist() { return mMapHist; } const std::unordered_map>& getMapHist() const { return mMapHist; } private: - float mCutAbsEta = 1.f; // Eta cut - int mCutMinnCls = 60; // minimum N clusters - float mCutMindEdxTot = 20.f; // dEdxTot min value - float mCutMinPtDCAr = 1.5f; // minimum pT for DCAr plots DCAr vs. phi, eta, nCluster - float mSamplingFractionDCAr = 0.1f; // sampling rate for calculation of DCAr - bool mTurnOffHistosForAsync = false; // Decide whether to turn off some histograms for async to reduce memory + float mCutAbsEta = 1.f; // Eta cut + int mCutMinnCls = 60; // minimum N clusters + float mCutMindEdxTot = 20.f; // dEdxTot min value + float mCutMinPtDCAr = 1.5f; // minimum pT for DCAr plots DCAr vs. phi, eta, nCluster + float mSamplingFractionDCAr = 0.1f; // sampling rate for calculation of DCAr + bool mTurnOffHistosForAsync = false; // Decide whether to turn off some histograms for async to reduce memory + float mCutMaxAbsDCAr = 1.f; // maximum DCAr + bool mUseCutMaxAbsDCArOnHistos = false; // Decide whether to use the cut on maximum DCAr for the histograms + std::unordered_map> mMapHist; std::vector mHist1D{}; ///< Initialize vector of 1D histograms std::vector mHist2D{}; ///< Initialize vector of 2D histograms diff --git a/Detectors/TPC/qc/src/Tracks.cxx b/Detectors/TPC/qc/src/Tracks.cxx index c42f35bd24644..9f1d9aabf9523 100644 --- a/Detectors/TPC/qc/src/Tracks.cxx +++ b/Detectors/TPC/qc/src/Tracks.cxx @@ -172,6 +172,9 @@ bool Tracks::processTrack(const o2::tpc::TrackTPC& track) sampleProb = randomGenerator.Uniform(1); } + bool isDcaCalculated = false; + float dcaValue = -999; + if (sampleProb > (Double_t)(1. - mSamplingFractionDCAr)) { if (propagator->getMatLUT() && propagator->hasMagFieldSet()) { @@ -190,6 +193,8 @@ bool Tracks::processTrack(const o2::tpc::TrackTPC& track) dcaHistEta_pTmin->Fill(eta, dca[0]); dcaHistNCluster_pTmin->Fill(nCls, dca[0]); } + dcaValue = dca[0]; + isDcaCalculated = true; } } else { static bool reported = false; @@ -207,6 +212,46 @@ bool Tracks::processTrack(const o2::tpc::TrackTPC& track) } } + if (mUseCutMaxAbsDCArOnHistos && !isDcaCalculated) { + // In this case the DCAr selection should be applied but is not available for the track, hence we simply return and report back + // For ease we just report back for every histogram that the propagator was not initialized + static bool reported = false; + if (!reported) { + LOGP(error, "o2::base::Propagator not properly initialized, MatLUT ({}) and / or Field ({}) missing, will not fill apply DCAr selection on histograms", (void*)propagator->getMatLUT(), propagator->hasMagFieldSet()); + mMapHist["hPhiAside"]->SetTitle("hPhiAside o2::base::Propagator not properly initialized"); + mMapHist["hPhiCside"]->SetTitle("hPhiCside o2::base::Propagator not properly initialized"); + mMapHist["hPhiBothSides"]->SetTitle("hPhiBothSides o2::base::Propagator not properly initialized"); + mMapHist["hPt"]->SetTitle("hPt o2::base::Propagator not properly initialized"); + mMapHist["hSign"]->SetTitle("hSign o2::base::Propagator not properly initialized"); + mMapHist["hQOverPt"]->SetTitle("hQOverPt o2::base::Propagator not properly initialized"); + mMapHist["hEtaNeg"]->SetTitle("hEtaNeg o2::base::Propagator not properly initialized"); + mMapHist["hPhiAsideNeg"]->SetTitle("hPhiAsideNeg o2::base::Propagator not properly initialized"); + mMapHist["hPhiCsideNeg"]->SetTitle("hPhiCsideNeg o2::base::Propagator not properly initialized"); + mMapHist["hEtaPos"]->SetTitle("hEtaPos o2::base::Propagator not properly initialized"); + mMapHist["hPtPos"]->SetTitle("hPtPos o2::base::Propagator not properly initialized"); + mMapHist["hPhiAsidePos"]->SetTitle("hPhiAsidePos o2::base::Propagator not properly initialized"); + mMapHist["hPhiCsidePos"]->SetTitle("hPhiCsidePos o2::base::Propagator not properly initialized"); + mMapHist["h2DNClustersEta"]->SetTitle("h2DNClustersEta o2::base::Propagator not properly initialized"); + mMapHist["h2DNClustersPhiAside"]->SetTitle("h2DNClustersPhiAside o2::base::Propagator not properly initialized"); + mMapHist["h2DQOverPtPhiAside"]->SetTitle("h2DQOverPtPhiAside o2::base::Propagator not properly initialized"); + mMapHist["h2DNClustersPhiCside"]->SetTitle("h2DNClustersPhiCside o2::base::Propagator not properly initialized"); + mMapHist["h2DQOverPtPhiCside"]->SetTitle("h2DQOverPtPhiCside o2::base::Propagator not properly initialized"); + mMapHist["h2DNClustersPt"]->SetTitle("h2DNClustersPt o2::base::Propagator not properly initialized"); + mMapHist["h2DEtaPhi"]->SetTitle("h2DEtaPhi o2::base::Propagator not properly initialized"); + mMapHist["h2DEtaPhiNeg"]->SetTitle("h2DEtaPhiNeg o2::base::Propagator not properly initialized"); + mMapHist["hEtaVsPtNeg"]->SetTitle("hEtaVsPtNeg o2::base::Propagator not properly initialized"); + mMapHist["hPhiVsPtNeg"]->SetTitle("hPhiVsPtNeg o2::base::Propagator not properly initialized"); + mMapHist["h2DEtaPhiPos"]->SetTitle("h2DEtaPhiPos o2::base::Propagator not properly initialized"); + mMapHist["hEtaVsPtPos"]->SetTitle("hEtaVsPtPos o2::base::Propagator not properly initialized"); + mMapHist["hPhiVsPtPos"]->SetTitle("hPhiVsPtPos o2::base::Propagator not properly initialized"); + } + return true; + } + + if (mUseCutMaxAbsDCArOnHistos && (std::abs(dcaValue) > mCutMaxAbsDCAr)) { + return true; + } + if (hasASideOnly == 1) { mMapHist["hPhiAside"]->Fill(phi); } else if (hasCSideOnly == 1) { @@ -304,4 +349,4 @@ void Tracks::dumpToFile(std::string_view filename) arr.Write(arr.GetName(), TObject::kSingleKey); } f->Close(); -} +} \ No newline at end of file