Skip to content

Commit a985fe9

Browse files
makorMaximilian Korwieser
andauthored
[QC-TPC] Remove non-mergable canvas objects from PID task. Add switch for hypothesis histos. (AliceO2Group#13437)
Co-authored-by: Maximilian Korwieser <[email protected]>
1 parent 815676e commit a985fe9

File tree

2 files changed

+20
-35
lines changed

2 files changed

+20
-35
lines changed

Detectors/TPC/qc/include/TPCQC/PID.h

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424

2525
// root includes
2626
#include "TH1.h"
27+
// Decapricated to be removed in next PR
2728
#include "TCanvas.h"
2829

2930
// o2 includes
@@ -70,7 +71,7 @@ class PID
7071

7172
// To set the elementary track cuts
7273
void setPIDCuts(int minnCls = 60, float absTgl = 1., float mindEdxTot = 10.0,
73-
float maxdEdxTot = 70., float minpTPC = 0.05, float maxpTPC = 20., float minpTPCMIPs = 0.45, float maxpTPCMIPs = 0.55, bool turnOffHistosForAsync = false)
74+
float maxdEdxTot = 70., float minpTPC = 0.05, float maxpTPC = 20., float minpTPCMIPs = 0.45, float maxpTPCMIPs = 0.55, bool turnOffHistosForAsync = false, bool getdEdxVspHypoHist = false)
7475
{
7576
mCutMinnCls = minnCls;
7677
mCutAbsTgl = absTgl;
@@ -81,15 +82,21 @@ class PID
8182
mCutMinpTPCMIPs = minpTPCMIPs;
8283
mCutMaxpTPCMIPs = maxpTPCMIPs;
8384
mTurnOffHistosForAsync = turnOffHistosForAsync;
85+
mGetdEdxVspHypoHist = getdEdxVspHypoHist;
8486
}
87+
88+
// Decapricated to be removed in next PR
8589
void setCreateCanvas(int createCanvas = 1)
8690
{
8791
mCreateCanvas = createCanvas;
8892
}
93+
8994
std::unordered_map<std::string_view, std::vector<std::unique_ptr<TH1>>>& getMapOfHisto() { return mMapHist; }
95+
const std::unordered_map<std::string_view, std::vector<std::unique_ptr<TH1>>>& getMapOfHisto() const { return mMapHist; }
96+
97+
// Decapricated to be removed in next PR
9098
std::unordered_map<std::string_view, std::vector<std::unique_ptr<TCanvas>>>& getMapOfCanvas() { return mMapCanvas; }
9199
TCanvas* getSeparationPowerCanvas() { return mSeparationPowerCanvas.get(); }
92-
const std::unordered_map<std::string_view, std::vector<std::unique_ptr<TH1>>>& getMapOfHisto() const { return mMapHist; }
93100
const std::unordered_map<std::string_view, std::vector<std::unique_ptr<TCanvas>>>& getMapOfCanvas() const { return mMapCanvas; }
94101

95102
private:
@@ -101,15 +108,19 @@ class PID
101108
float mCutMaxpTPC = 20.f; // pTPC max value
102109
float mCutMinpTPCMIPs = 0.45f; // pTPC min value for MIPs
103110
float mCutMaxpTPCMIPs = 0.55f; // pTPC max value for MIPs
104-
bool mCreateCanvas = true; // Decide whether to create the TCanvas Object as it cannot be merged
105111
bool mTurnOffHistosForAsync = false; // Decide whether to turn off some histograms for async to reduce memory
112+
bool mGetdEdxVspHypoHist = false; // Decide whether to generate the EdxVspHypo histograms
113+
// Decapricated to be removed in next PR
114+
bool mCreateCanvas = true; // Decide whether to create the TCanvas Object as it cannot be merged
115+
106116
std::unordered_map<std::string_view, std::vector<std::unique_ptr<TH1>>> mMapHist;
117+
// Decapricated to be removed in next PR
107118
// Map for Canvases to be published
108119
std::unordered_map<std::string_view, std::vector<std::unique_ptr<TCanvas>>> mMapCanvas;
109120
// Map for Histograms which will be put onto the canvases, and not published separately
110121
std::unordered_map<std::string_view, std::vector<std::unique_ptr<TH1>>> mMapHistCanvas;
111-
// Canvas for Trending Separation Power
112122
std::unique_ptr<TCanvas> mSeparationPowerCanvas;
123+
113124
ClassDefNV(PID, 1)
114125
};
115126
} // namespace qc

Detectors/TPC/qc/src/PID.cxx

Lines changed: 5 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
// root includes
1919
#include "TStyle.h"
2020
#include "TFile.h"
21-
#include "TCanvas.h"
2221
#include "TMathBase.h"
2322
#include "TObjArray.h"
2423

@@ -93,16 +92,11 @@ void PID::initializeHistograms()
9392
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));
9493
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]));
9594
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));
96-
if (mCreateCanvas) {
97-
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()));
98-
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()));
95+
if (mGetdEdxVspHypoHist) {
96+
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()));
97+
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()));
9998
}
10099
}
101-
if (mCreateCanvas) {
102-
mMapCanvas["CdEdxPIDHypothesisVsp"].emplace_back(std::make_unique<TCanvas>("CdEdxPIDHypothesisVsp", "PID Hypothesis Ratio"));
103-
mMapCanvas["CdEdxPIDHypothesisVsp"].at(0)->Divide(5, 2);
104-
}
105-
mSeparationPowerCanvas.reset(new TCanvas("CSeparationPower", "Separation Power"));
106100
}
107101

108102
//______________________________________________________________________________
@@ -113,11 +107,6 @@ void PID::resetHistograms()
113107
hist->Reset();
114108
}
115109
}
116-
for (const auto& pair : mMapHistCanvas) {
117-
for (auto& hist : pair.second) {
118-
hist->Reset();
119-
}
120-
}
121110
}
122111

123112
//______________________________________________________________________________
@@ -185,10 +174,10 @@ bool PID::processTrack(const o2::tpc::TrackTPC& track, size_t nTracks)
185174
if (std::abs(tgl) < mCutAbsTgl) {
186175
mMapHist["hdEdxTotVsp"][idEdxType]->Fill(pTPC, dEdxTot[idEdxType]);
187176
mMapHist["hdEdxMaxVsp"][idEdxType]->Fill(pTPC, dEdxMax[idEdxType]);
188-
if (mCreateCanvas) {
177+
if (mGetdEdxVspHypoHist) {
189178
const auto pidHypothesis = track.getPID().getID();
190179
if (pidHypothesis <= o2::track::PID::NIDs) {
191-
auto pidHist = mMapHistCanvas[(track.getCharge() > 0) ? "hdEdxVspHypoPos" : "hdEdxVspHypoNeg"][idEdxType].get();
180+
auto pidHist = mMapHist[(track.getCharge() > 0) ? "hdEdxVspHypoPos" : "hdEdxVspHypoNeg"][idEdxType].get();
192181
pidHist->SetBinContent(pidHist->GetXaxis()->FindBin(pTPC), pidHist->GetYaxis()->FindBin(dEdxTot[idEdxType]), pidHypothesis + 1);
193182
}
194183
}
@@ -227,21 +216,6 @@ bool PID::processTrack(const o2::tpc::TrackTPC& track, size_t nTracks)
227216
}
228217
}
229218
}
230-
231-
if (mCreateCanvas) {
232-
for (auto const& pairC : mMapCanvas) {
233-
for (auto& canv : pairC.second) {
234-
int h = 1;
235-
for (auto const& pairH : mMapHistCanvas) {
236-
for (auto& hist : pairH.second) {
237-
canv->cd(h);
238-
hist->Draw();
239-
h++;
240-
}
241-
}
242-
}
243-
}
244-
}
245219
return true;
246220
}
247221

0 commit comments

Comments
 (0)