Skip to content

Commit

Permalink
[TPC-QC] Add DCAr selection to Tracks.cxx
Browse files Browse the repository at this point in the history
  • Loading branch information
Maximilian Korwieser committed Oct 4, 2024
1 parent 362c300 commit c431d33
Show file tree
Hide file tree
Showing 2 changed files with 69 additions and 21 deletions.
43 changes: 23 additions & 20 deletions Detectors/TPC/qc/include/TPCQC/Tracks.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ class Tracks
/// Dump results to a file
void dumpToFile(std::string_view filename);

// Just for backward compatibility with crrent QC, temporary, will be removed in the next PR
// 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)
Expand All @@ -79,32 +80,34 @@ class Tracks
mTurnOffHistosForAsync = turnOffHistosForAsync;
}

// Just for backward compatibility with crrent QC, temporary, will be removed in the next PR
/// get 1D histograms
std::vector<TH1F>& getHistograms1D() { return mHist1D; }
const std::vector<TH1F>& getHistograms1D() const { return mHist1D; }

// Just for backward compatibility with crrent QC, temporary, will be removed in the next PR
/// get 2D histograms
std::vector<TH2F>& getHistograms2D() { return mHist2D; }
const std::vector<TH2F>& 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<TH1F>& getHistogramRatios1D() { return mHistRatio1D; }
const std::vector<TH1F>& getHistogramRatios1D() const { return mHistRatio1D; }
// 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, float cutMaxAbsDCAr = 0.1, bool useCutMaxAbsDCArOnHistos = false)
{
mCutAbsEta = AbsEta;
mCutMinnCls = nClusterCut;
mCutMindEdxTot = dEdxTot;
mCutMinPtDCAr = cutPtForDCAr;
mSamplingFractionDCAr = samplingFractionDCAr;
mTurnOffHistosForAsync = turnOffHistosForAsync;
mCutMaxAbsDCAr = cutMaxAbsDCAr;
mUseCutMaxAbsDCArOnHistos = useCutMaxAbsDCArOnHistos;
}

/// get ratios of 1D histograms
std::unordered_map<std::string, std::unique_ptr<TH1>>& getMapHist() { return mMapHist; }
const std::unordered_map<std::string, std::unique_ptr<TH1>>& 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<std::string, std::unique_ptr<TH1>> mMapHist;
std::vector<TH1F> mHist1D{}; ///< Initialize vector of 1D histograms
std::vector<TH2F> mHist2D{}; ///< Initialize vector of 2D histograms
Expand Down
47 changes: 46 additions & 1 deletion Detectors/TPC/qc/src/Tracks.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -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()) {
Expand All @@ -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;
Expand All @@ -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 (dcaValue > mCutMaxAbsDCAr) {
return true;
}

if (hasASideOnly == 1) {
mMapHist["hPhiAside"]->Fill(phi);
} else if (hasCSideOnly == 1) {
Expand Down Expand Up @@ -304,4 +349,4 @@ void Tracks::dumpToFile(std::string_view filename)
arr.Write(arr.GetName(), TObject::kSingleKey);
}
f->Close();
}
}

0 comments on commit c431d33

Please sign in to comment.