Skip to content

Commit

Permalink
Hotfix for PID Hypothesis - switch to disable Canvas (AliceO2Group#12755
Browse files Browse the repository at this point in the history
)

* Adding PID Hypothesis for PID Task

* Updated GetMostProbablePID

* formatting

* formatting 2

* formatting3

* formatting4

* added recommendations

* fromatting

* cleanup

* change runPID macro with new processTrack

* Added dummy processTrack to be compatible with QC

* Hotfix for PID Hypothesis to disable TCanvas generation

* quickfix

* Formatting

* naming Convention, added separate function for setCreateCanvas

---------

Co-authored-by: Maximilian Horst <[email protected]>
  • Loading branch information
2 people authored and andreasmolander committed Apr 12, 2024
1 parent 054d43e commit c6a0cd6
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 19 deletions.
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

0 comments on commit c6a0cd6

Please sign in to comment.