Skip to content

Commit

Permalink
[QC-TPC] Remove non-mergable canvas objects from PID task. Add switch…
Browse files Browse the repository at this point in the history
… for hypothesis histos. (#13437)

Co-authored-by: Maximilian Korwieser <[email protected]>
  • Loading branch information
makor and Maximilian Korwieser authored Sep 3, 2024
1 parent 815676e commit a985fe9
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 35 deletions.
19 changes: 15 additions & 4 deletions Detectors/TPC/qc/include/TPCQC/PID.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@

// root includes
#include "TH1.h"
// Decapricated to be removed in next PR
#include "TCanvas.h"

// o2 includes
Expand Down Expand Up @@ -70,7 +71,7 @@ class PID

// To set the elementary track cuts
void setPIDCuts(int minnCls = 60, float absTgl = 1., float mindEdxTot = 10.0,
float maxdEdxTot = 70., float minpTPC = 0.05, float maxpTPC = 20., float minpTPCMIPs = 0.45, float maxpTPCMIPs = 0.55, bool turnOffHistosForAsync = false)
float maxdEdxTot = 70., float minpTPC = 0.05, float maxpTPC = 20., float minpTPCMIPs = 0.45, float maxpTPCMIPs = 0.55, bool turnOffHistosForAsync = false, bool getdEdxVspHypoHist = false)
{
mCutMinnCls = minnCls;
mCutAbsTgl = absTgl;
Expand All @@ -81,15 +82,21 @@ class PID
mCutMinpTPCMIPs = minpTPCMIPs;
mCutMaxpTPCMIPs = maxpTPCMIPs;
mTurnOffHistosForAsync = turnOffHistosForAsync;
mGetdEdxVspHypoHist = getdEdxVspHypoHist;
}

// Decapricated to be removed in next PR
void setCreateCanvas(int createCanvas = 1)
{
mCreateCanvas = createCanvas;
}

std::unordered_map<std::string_view, std::vector<std::unique_ptr<TH1>>>& getMapOfHisto() { return mMapHist; }
const std::unordered_map<std::string_view, std::vector<std::unique_ptr<TH1>>>& getMapOfHisto() const { return mMapHist; }

// Decapricated to be removed in next PR
std::unordered_map<std::string_view, std::vector<std::unique_ptr<TCanvas>>>& getMapOfCanvas() { return mMapCanvas; }
TCanvas* getSeparationPowerCanvas() { return mSeparationPowerCanvas.get(); }
const std::unordered_map<std::string_view, std::vector<std::unique_ptr<TH1>>>& getMapOfHisto() const { return mMapHist; }
const std::unordered_map<std::string_view, std::vector<std::unique_ptr<TCanvas>>>& getMapOfCanvas() const { return mMapCanvas; }

private:
Expand All @@ -101,15 +108,19 @@ class PID
float mCutMaxpTPC = 20.f; // pTPC max value
float mCutMinpTPCMIPs = 0.45f; // pTPC min value for MIPs
float mCutMaxpTPCMIPs = 0.55f; // pTPC max value for MIPs
bool mCreateCanvas = true; // Decide whether to create the TCanvas Object as it cannot be merged
bool mTurnOffHistosForAsync = false; // Decide whether to turn off some histograms for async to reduce memory
bool mGetdEdxVspHypoHist = false; // Decide whether to generate the EdxVspHypo histograms
// Decapricated to be removed in next PR
bool mCreateCanvas = true; // Decide whether to create the TCanvas Object as it cannot be merged

std::unordered_map<std::string_view, std::vector<std::unique_ptr<TH1>>> mMapHist;
// Decapricated to be removed in next PR
// Map for Canvases to be published
std::unordered_map<std::string_view, std::vector<std::unique_ptr<TCanvas>>> mMapCanvas;
// Map for Histograms which will be put onto the canvases, and not published separately
std::unordered_map<std::string_view, std::vector<std::unique_ptr<TH1>>> mMapHistCanvas;
// Canvas for Trending Separation Power
std::unique_ptr<TCanvas> mSeparationPowerCanvas;

ClassDefNV(PID, 1)
};
} // namespace qc
Expand Down
36 changes: 5 additions & 31 deletions Detectors/TPC/qc/src/PID.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
// root includes
#include "TStyle.h"
#include "TFile.h"
#include "TCanvas.h"
#include "TMathBase.h"
#include "TObjArray.h"

Expand Down Expand Up @@ -93,16 +92,11 @@ void PID::initializeHistograms()
mMapHist["hdEdxMaxMIPVsSec"].emplace_back(std::make_unique<TH2F>(fmt::format("hdEdxMaxMIPVsSec_{}", name).data(), (fmt::format("MIP Q_{{Max}} {}", name) + ";sector;d#it{E}/d#it{x}_{Max} (arb. unit)").data(), binsSec.bins, binsSec.min, binsSec.max, binsdEdxMIPMax.bins, binsdEdxMIPMax.min, binsdEdxMIPMax.max));
mMapHist["hMIPNclVsTgl"].emplace_back(std::make_unique<TH2F>(fmt::format("hMIPNclVsTgl_{}", name).data(), (fmt::format("rec. clusters {}", name) + ";#tan(#lambda); rec clusters").data(), 50, -2, 2, nclMax[idEdxType] - nclCuts[idEdxType], nclCuts[idEdxType], nclMax[idEdxType]));
mMapHist["hMIPNclVsTglSub"].emplace_back(std::make_unique<TH2F>(fmt::format("hMIPNclVsTglSub_{}", name).data(), (fmt::format("sub-thrs. clusters {}", name) + ";#tan(#lambda);sub-thrs. clusters").data(), 50, -2, 2, 20, 0, 20));
if (mCreateCanvas) {
mMapHistCanvas["hdEdxVspHypoPos"].emplace_back(std::make_unique<TH2F>(fmt::format("hdEdxVspHypoPos_{}", name).data(), (fmt::format("Q_{{Tot}} Pos {}", name) + ";#it{p} (GeV/#it{c});d#it{E}/d#it{x}_{Tot} (arb. unit)").data(), 200, bins.data(), binNumber, binsdEdxTot_Log.data()));
mMapHistCanvas["hdEdxVspHypoNeg"].emplace_back(std::make_unique<TH2F>(fmt::format("hdEdxVspHypoNeg_{}", name).data(), (fmt::format("Q_{{Tot}} Neg {}", name) + ";#it{p} (GeV/#it{c});d#it{E}/d#it{x}_{Tot} (arb. unit)").data(), 200, bins.data(), binNumber, binsdEdxTot_Log.data()));
if (mGetdEdxVspHypoHist) {
mMapHist["hdEdxVspHypoPos"].emplace_back(std::make_unique<TH2F>(fmt::format("hdEdxVspHypoPos_{}", name).data(), (fmt::format("Q_{{Tot}} Pos {}", name) + ";#it{p} (GeV/#it{c});d#it{E}/d#it{x}_{Tot} (arb. unit)").data(), 200, bins.data(), binNumber, binsdEdxTot_Log.data()));
mMapHist["hdEdxVspHypoNeg"].emplace_back(std::make_unique<TH2F>(fmt::format("hdEdxVspHypoNeg_{}", name).data(), (fmt::format("Q_{{Tot}} Neg {}", name) + ";#it{p} (GeV/#it{c});d#it{E}/d#it{x}_{Tot} (arb. unit)").data(), 200, bins.data(), binNumber, binsdEdxTot_Log.data()));
}
}
if (mCreateCanvas) {
mMapCanvas["CdEdxPIDHypothesisVsp"].emplace_back(std::make_unique<TCanvas>("CdEdxPIDHypothesisVsp", "PID Hypothesis Ratio"));
mMapCanvas["CdEdxPIDHypothesisVsp"].at(0)->Divide(5, 2);
}
mSeparationPowerCanvas.reset(new TCanvas("CSeparationPower", "Separation Power"));
}

//______________________________________________________________________________
Expand All @@ -113,11 +107,6 @@ void PID::resetHistograms()
hist->Reset();
}
}
for (const auto& pair : mMapHistCanvas) {
for (auto& hist : pair.second) {
hist->Reset();
}
}
}

//______________________________________________________________________________
Expand Down Expand Up @@ -185,10 +174,10 @@ bool PID::processTrack(const o2::tpc::TrackTPC& track, size_t nTracks)
if (std::abs(tgl) < mCutAbsTgl) {
mMapHist["hdEdxTotVsp"][idEdxType]->Fill(pTPC, dEdxTot[idEdxType]);
mMapHist["hdEdxMaxVsp"][idEdxType]->Fill(pTPC, dEdxMax[idEdxType]);
if (mCreateCanvas) {
if (mGetdEdxVspHypoHist) {
const auto pidHypothesis = track.getPID().getID();
if (pidHypothesis <= o2::track::PID::NIDs) {
auto pidHist = mMapHistCanvas[(track.getCharge() > 0) ? "hdEdxVspHypoPos" : "hdEdxVspHypoNeg"][idEdxType].get();
auto pidHist = mMapHist[(track.getCharge() > 0) ? "hdEdxVspHypoPos" : "hdEdxVspHypoNeg"][idEdxType].get();
pidHist->SetBinContent(pidHist->GetXaxis()->FindBin(pTPC), pidHist->GetYaxis()->FindBin(dEdxTot[idEdxType]), pidHypothesis + 1);
}
}
Expand Down Expand Up @@ -227,21 +216,6 @@ bool PID::processTrack(const o2::tpc::TrackTPC& track, size_t nTracks)
}
}
}

if (mCreateCanvas) {
for (auto const& pairC : mMapCanvas) {
for (auto& canv : pairC.second) {
int h = 1;
for (auto const& pairH : mMapHistCanvas) {
for (auto& hist : pairH.second) {
canv->cd(h);
hist->Draw();
h++;
}
}
}
}
}
return true;
}

Expand Down

0 comments on commit a985fe9

Please sign in to comment.