Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hotfix for PID Hypothesis - switch to disable Canvas #12755

Merged
merged 16 commits into from
Feb 28, 2024
6 changes: 5 additions & 1 deletion Detectors/TPC/qc/include/TPCQC/PID.h
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,10 @@ class PID
mCutMinpTPCMIPs = minpTPCMIPs;
mCutMaxpTPCMIPs = maxpTPCMIPs;
}
void setCreateCanvas(int createCanvas = 1)
{
mCreateCanvas = createCanvas;
}
std::unordered_map<std::string_view, std::vector<std::unique_ptr<TH1>>>& getMapOfHisto() { return mMapHist; }
std::unordered_map<std::string_view, std::vector<std::unique_ptr<TCanvas>>>& getMapOfCanvas() { return mMapCanvas; }
const std::unordered_map<std::string_view, std::vector<std::unique_ptr<TH1>>>& getMapOfHisto() const { return mMapHist; }
Expand All @@ -95,7 +99,7 @@ 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
std::unordered_map<std::string_view, std::vector<std::unique_ptr<TH1>>> mMapHist;
// Map for Canvases to be published
std::unordered_map<std::string_view, std::vector<std::unique_ptr<TCanvas>>> mMapCanvas;
Expand Down
42 changes: 24 additions & 18 deletions Detectors/TPC/qc/src/PID.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -89,12 +89,15 @@ 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);d#it{E}/d#it{x}_{Max} (arb. unit)").data(), 50, -2, 2, nclMax[idEdxType], 0, nclMax[idEdxType]));
mMapHist["hMIPNclVsTglSub"].emplace_back(std::make_unique<TH2F>(fmt::format("hMIPNclVsTglSub_{}", name).data(), (fmt::format("rec. + sub-thrs. clusters {}", name) + ";#tan(#lambda);d#it{E}/d#it{x}_{Max} (arb. unit)").data(), 50, -2, 2, nclMax[idEdxType], 0, nclMax[idEdxType]));

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(), binsdEdxTot.bins, binsdEdxTot.min, binsdEdxTot.max));
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(), binsdEdxTot.bins, binsdEdxTot.min, binsdEdxTot.max));
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(), binsdEdxTot.bins, binsdEdxTot.min, binsdEdxTot.max));
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(), binsdEdxTot.bins, binsdEdxTot.min, binsdEdxTot.max));
}
}
if (mCreateCanvas) {
mMapCanvas["CdEdxPIDHypothesisVsp"].emplace_back(std::make_unique<TCanvas>("CdEdxPIDHypothesisVsp", "PID Hypothesis Ratio"));
mMapCanvas["CdEdxPIDHypothesisVsp"].at(0)->Divide(5, 2);
}
mMapCanvas["CdEdxPIDHypothesisVsp"].emplace_back(std::make_unique<TCanvas>("CdEdxPIDHypothesisVsp", "PID Hypothesis Ratio"));
mMapCanvas["CdEdxPIDHypothesisVsp"].at(0)->Divide(5, 2);
}

//______________________________________________________________________________
Expand Down Expand Up @@ -174,10 +177,12 @@ 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]);
const auto pidHypothesis = track.getPID().getID();
if (pidHypothesis <= o2::track::PID::NIDs) {
auto pidHist = mMapHistCanvas[(track.getCharge() > 0) ? "hdEdxVspHypoPos" : "hdEdxVspHypoNeg"][idEdxType].get();
pidHist->SetBinContent(pidHist->GetXaxis()->FindBin(pTPC), pidHist->GetYaxis()->FindBin(dEdxTot[idEdxType]), pidHypothesis + 1);
if (mCreateCanvas) {
const auto pidHypothesis = track.getPID().getID();
if (pidHypothesis <= o2::track::PID::NIDs) {
auto pidHist = mMapHistCanvas[(track.getCharge() > 0) ? "hdEdxVspHypoPos" : "hdEdxVspHypoNeg"][idEdxType].get();
pidHist->SetBinContent(pidHist->GetXaxis()->FindBin(pTPC), pidHist->GetYaxis()->FindBin(dEdxTot[idEdxType]), pidHypothesis + 1);
}
}
}

Expand Down Expand Up @@ -212,15 +217,16 @@ bool PID::processTrack(const o2::tpc::TrackTPC& track, size_t nTracks)
}
}
}

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++;
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++;
}
}
}
}
Expand Down
Loading