23#include "TGraphAsymmErrors.h"
41#include "GPUChainTrackingGetters.inc"
50#include "GPUParam.inc"
70#include "TParticlePDG.h"
71#include "TDatabasePDG.h"
80#include <oneapi/tbb.h>
84#ifdef GPUCA_MERGER_BY_MC_LABEL
85#define CHECK_CLUSTER_STATE_INIT_LEG_BY_MC() \
86 if (!unattached && mTrackMCLabels[id].isValid()) { \
87 int32_t mcLabel = mTrackMCLabels[id].getTrackID(); \
88 int32_t mcEvent = mTrackMCLabels[id].getEventID(); \
89 int32_t mcSource = mTrackMCLabels[id].getSourceID(); \
90 if (mTrackMCLabelsReverse[mMCEventOffset[mcSource] + mcEvent][mcLabel] != id) { \
91 attach &= (~gputpcgmmergertypes::attachGoodLeg); \
95#define CHECK_CLUSTER_STATE_INIT_LEG_BY_MC()
98#define CHECK_CLUSTER_STATE_INIT() \
99 bool unattached = attach == 0; \
101 bool lowPt = false; \
102 bool mev200 = false; \
103 bool mergedLooper = false; \
104 int32_t id = attach & gputpcgmmergertypes::attachTrackMask; \
106 qpt = fabsf(mTracking->mIOPtrs.mergedTracks[id].GetParam().GetQPt()); \
107 lowPt = qpt * mTracking->GetParam().qptB5Scaler > mTracking->GetParam().rec.tpc.rejectQPtB5; \
109 mergedLooper = mTracking->mIOPtrs.mergedTracks[id].MergedLooper(); \
111 bool physics = false, protect = false; \
112 CHECK_CLUSTER_STATE_INIT_LEG_BY_MC();
114#define CHECK_CLUSTER_STATE() \
115 CHECK_CLUSTER_STATE_INIT() \
117 mClusterCounts.n200MeV++; \
120 mClusterCounts.nLowPt++; \
121 } else if (mergedLooper) { \
122 mClusterCounts.nMergedLooper++; \
124 GPUTPCClusterRejection::GetProtectionStatus<true>(attach, physics, protect, &mClusterCounts, &mev200); \
127#define CHECK_CLUSTER_STATE_NOCOUNT() \
128 CHECK_CLUSTER_STATE_INIT() \
130 if (!lowPt && !mergedLooper) { \
131 GPUTPCClusterRejection::GetProtectionStatus<false>(attach, physics, protect); \
136 static GPUSettingsQA defaultConfig;
138 return *
chain->mConfigQA;
140 return defaultConfig;
146static const constexpr bool PERF_FIGURE = 0;
149static const constexpr float LOG_PT_MIN = -1.;
151static constexpr float Y_MAX = 40;
152static constexpr float Z_MAX = 100;
155static constexpr float PT_MIN_PRIM = 0.1;
157static constexpr float PT_MAX = 20;
158static constexpr float ETA_MAX = 1.5;
159static constexpr float ETA_MAX2 = 0.9;
161static constexpr bool CLUST_HIST_INT_SUM =
false;
163static constexpr const int32_t COLORCOUNT = 12;
165static const constexpr char* EFF_TYPES[5] = {
"Rec",
"Clone",
"Fake",
"All",
"RecAndClone"};
166static const constexpr char* FINDABLE_NAMES[2] = {
"All",
"Findable"};
167static const constexpr char* PRIM_NAMES[2] = {
"Prim",
"Sec"};
168static const constexpr char* PARAMETER_NAMES[5] = {
"Y",
"Z",
"#Phi",
"#lambda",
"Relative #it{p}_{T}"};
169static const constexpr char* PARAMETER_NAMES_NATIVE[5] = {
"Y",
"Z",
"sin(#Phi)",
"tan(#lambda)",
"q/#it{p}_{T} (curvature)"};
170static const constexpr char* VSPARAMETER_NAMES[6] = {
"Y",
"Z",
"Phi",
"Eta",
"Pt",
"Pt_log"};
171static const constexpr char* EFF_NAMES[3] = {
"Efficiency",
"Clone Rate",
"Fake Rate"};
172static const constexpr char* EFFICIENCY_TITLES[4] = {
"Efficiency (Primary Tracks, Findable)",
"Efficiency (Secondary Tracks, Findable)",
"Efficiency (Primary Tracks)",
"Efficiency (Secondary Tracks)"};
173static const constexpr double SCALE[5] = {10., 10., 1000., 1000., 100.};
174static const constexpr double SCALE_NATIVE[5] = {10., 10., 1000., 1000., 1.};
175static const constexpr char* XAXIS_TITLES[5] = {
"#it{y}_{mc} (cm)",
"#it{z}_{mc} (cm)",
"#Phi_{mc} (rad)",
"#eta_{mc}",
"#it{p}_{Tmc} (GeV/#it{c})"};
176static const constexpr char* AXIS_TITLES[5] = {
"#it{y}-#it{y}_{mc} (mm) (Resolution)",
"#it{z}-#it{z}_{mc} (mm) (Resolution)",
"#phi-#phi_{mc} (mrad) (Resolution)",
"#lambda-#lambda_{mc} (mrad) (Resolution)",
"(#it{p}_{T} - #it{p}_{Tmc}) / #it{p}_{Tmc} (%) (Resolution)"};
177static const constexpr char* AXIS_TITLES_NATIVE[5] = {
"#it{y}-#it{y}_{mc} (mm) (Resolution)",
"#it{z}-#it{z}_{mc} (mm) (Resolution)",
"sin(#phi)-sin(#phi_{mc}) (Resolution)",
"tan(#lambda)-tan(#lambda_{mc}) (Resolution)",
"q*(q/#it{p}_{T} - q/#it{p}_{Tmc}) (Resolution)"};
178static const constexpr char* AXIS_TITLES_PULL[5] = {
"#it{y}-#it{y}_{mc}/#sigma_{y} (Pull)",
"#it{z}-#it{z}_{mc}/#sigma_{z} (Pull)",
"sin(#phi)-sin(#phi_{mc})/#sigma_{sin(#phi)} (Pull)",
"tan(#lambda)-tan(#lambda_{mc})/#sigma_{tan(#lambda)} (Pull)",
179 "q*(q/#it{p}_{T} - q/#it{p}_{Tmc})/#sigma_{q/#it{p}_{T}} (Pull)"};
180static const constexpr char* CLUSTER_NAMES[GPUQA::N_CLS_HIST] = {
"Correctly attached clusters",
"Fake attached clusters",
"Attached + adjacent clusters",
"Fake adjacent clusters",
"Clusters of reconstructed tracks",
"Used in Physics",
"Protected",
"All clusters"};
181static const constexpr char* CLUSTER_TITLES[GPUQA::N_CLS_TYPE] = {
"Clusters Pt Distribution / Attachment",
"Clusters Pt Distribution / Attachment (relative to all clusters)",
"Clusters Pt Distribution / Attachment (integrated)"};
182static const constexpr char* CLUSTER_NAMES_SHORT[GPUQA::N_CLS_HIST] = {
"Attached",
"Fake",
"AttachAdjacent",
"FakeAdjacent",
"FoundTracks",
"Physics",
"Protected",
"All"};
183static const constexpr char* CLUSTER_TYPES[GPUQA::N_CLS_TYPE] = {
"",
"Ratio",
"Integral"};
184static const constexpr int32_t COLORS_HEX[COLORCOUNT] = {0xB03030, 0x00A000, 0x0000C0, 0x9400D3, 0x19BBBF, 0xF25900, 0x7F7F7F, 0xFFD700, 0x07F707, 0x07F7F7, 0xF08080, 0x000000};
186static const constexpr int32_t CONFIG_DASHED_MARKERS = 0;
188static const constexpr float AXES_MIN[5] = {-Y_MAX, -Z_MAX, 0.f, -ETA_MAX, PT_MIN};
189static const constexpr float AXES_MAX[5] = {Y_MAX, Z_MAX, 2.f * M_PI, ETA_MAX, PT_MAX};
190static const constexpr int32_t AXIS_BINS[5] = {51, 51, 144, 31, 50};
191static const constexpr int32_t RES_AXIS_BINS[] = {1017, 113};
192static const constexpr float RES_AXES[5] = {1., 1., 0.03, 0.03, 1.0};
193static const constexpr float RES_AXES_NATIVE[5] = {1., 1., 0.1, 0.1, 5.0};
194static const constexpr float PULL_AXIS = 10.f;
196std::vector<TColor*> GPUQA::mColors;
197int32_t GPUQA::initColors()
199 mColors.reserve(COLORCOUNT);
200 for (int32_t
i = 0;
i < COLORCOUNT;
i++) {
201 float f1 = (float)((COLORS_HEX[
i] >> 16) & 0xFF) / (
float)0xFF;
202 float f2 = (float)((COLORS_HEX[
i] >> 8) & 0xFF) / (
float)0xFF;
203 float f3 = (float)((COLORS_HEX[
i] >> 0) & 0xFF) / (
float)0xFF;
204 mColors.emplace_back(
new TColor(10000 +
i, f1, f2, f3));
208static constexpr Color_t defaultColorNums[COLORCOUNT] = {kRed, kBlue, kGreen, kMagenta, kOrange, kAzure, kBlack, kYellow, kGray, kTeal, kSpring, kPink};
210#define TRACK_EXPECTED_REFERENCE_X_DEFAULT 81
211#ifdef GPUCA_TPC_GEOMETRY_O2
212static inline int32_t GPUQA_O2_ConvertFakeLabel(int32_t
label) {
return label >= 0x7FFFFFFE ? -1 :
label; }
213inline uint32_t GPUQA::GetNMCCollissions()
const {
return mMCInfosCol.size(); }
214inline uint32_t GPUQA::GetNMCTracks(int32_t iCol)
const {
return mMCInfosCol[iCol].num; }
215inline uint32_t GPUQA::GetNMCTracks(
const mcLabelI_t&
label)
const {
return mMCInfosCol[mMCEventOffset[
label.getSourceID()] +
label.getEventID()].num; }
216inline uint32_t GPUQA::GetNMCLabels()
const {
return mClNative->clustersMCTruth ? mClNative->clustersMCTruth->getIndexedSize() : 0; }
217inline const GPUQA::mcInfo_t& GPUQA::GetMCTrack(uint32_t iTrk, uint32_t iCol) {
return mMCInfos[mMCInfosCol[iCol].first + iTrk]; }
218inline const GPUQA::mcInfo_t& GPUQA::GetMCTrack(
const mcLabel_t&
label) {
return mMCInfos[mMCInfosCol[mMCEventOffset[
label.getSourceID()] +
label.getEventID()].first +
label.getTrackID()]; }
219inline GPUQA::mcLabels_t GPUQA::GetMCLabel(uint32_t
i) {
return mClNative->clustersMCTruth->getLabels(
i); }
220inline int32_t GPUQA::GetMCLabelNID(
const mcLabels_t&
label) {
return label.size(); }
221inline int32_t GPUQA::GetMCLabelNID(uint32_t
i) {
return mClNative->clustersMCTruth->getLabels(
i).size(); }
222inline GPUQA::mcLabel_t GPUQA::GetMCLabel(uint32_t
i, uint32_t
j) {
return mClNative->clustersMCTruth->getLabels(
i)[
j]; }
223inline int32_t GPUQA::GetMCLabelID(uint32_t
i, uint32_t
j) {
return GPUQA_O2_ConvertFakeLabel(mClNative->clustersMCTruth->getLabels(
i)[
j].getTrackID()); }
224inline int32_t GPUQA::GetMCLabelID(
const mcLabels_t&
label, uint32_t
j) {
return GPUQA_O2_ConvertFakeLabel(
label[
j].getTrackID()); }
225inline int32_t GPUQA::GetMCLabelID(
const mcLabel_t&
label) {
return GPUQA_O2_ConvertFakeLabel(
label.getTrackID()); }
226inline uint32_t GPUQA::GetMCLabelCol(uint32_t
i, uint32_t
j) {
return mMCEventOffset[mClNative->clustersMCTruth->getLabels(
i)[
j].getSourceID()] + mClNative->clustersMCTruth->getLabels(
i)[
j].getEventID(); }
227inline const auto& GPUQA::GetClusterLabels() {
return mClNative->clustersMCTruth; }
228inline float GPUQA::GetMCLabelWeight(uint32_t
i, uint32_t
j) {
return 1; }
229inline float GPUQA::GetMCLabelWeight(
const mcLabels_t&
label, uint32_t
j) {
return 1; }
230inline float GPUQA::GetMCLabelWeight(
const mcLabel_t&
label) {
return 1; }
231inline bool GPUQA::mcPresent() {
return !mConfig.noMC && mTracking && mClNative && mClNative->clustersMCTruth && mMCInfos.size(); }
232uint32_t GPUQA::GetMCLabelCol(
const mcLabel_t&
label)
const {
return !
label.isValid() ? 0 : (mMCEventOffset[
label.getSourceID()] +
label.getEventID()); }
234bool GPUQA::CompareIgnoreFake(
const mcLabelI_t& l1,
const mcLabelI_t& l2) {
return l1.compare(l2) >= 0; }
235#define TRACK_EXPECTED_REFERENCE_X 78
237inline GPUQA::mcLabelI_t::mcLabelI_t(
const GPUQA::mcLabel_t& l) : track(l.fMCID) {}
238inline bool GPUQA::mcLabelI_t::operator==(
const GPUQA::mcLabel_t& l) {
return AbsLabelID(track) == l.fMCID; }
239inline uint32_t GPUQA::GetNMCCollissions()
const {
return 1; }
240inline uint32_t GPUQA::GetNMCTracks(int32_t iCol)
const {
return mTracking->mIOPtrs.nMCInfosTPC; }
241inline uint32_t GPUQA::GetNMCTracks(
const mcLabelI_t&
label)
const {
return mTracking->mIOPtrs.nMCInfosTPC; }
242inline uint32_t GPUQA::GetNMCLabels()
const {
return mTracking->mIOPtrs.nMCLabelsTPC; }
243inline const GPUQA::mcInfo_t& GPUQA::GetMCTrack(uint32_t iTrk, uint32_t iCol) {
return mTracking->mIOPtrs.mcInfosTPC[AbsLabelID(iTrk)]; }
244inline const GPUQA::mcInfo_t& GPUQA::GetMCTrack(
const mcLabel_t&
label) {
return GetMCTrack(
label.fMCID, 0); }
245inline const GPUQA::mcInfo_t& GPUQA::GetMCTrack(
const mcLabelI_t&
label) {
return GetMCTrack(
label.track, 0); }
246inline const GPUQA::mcLabels_t& GPUQA::GetMCLabel(uint32_t
i) {
return mTracking->mIOPtrs.mcLabelsTPC[
i]; }
247inline const GPUQA::mcLabel_t& GPUQA::GetMCLabel(uint32_t
i, uint32_t
j) {
return mTracking->mIOPtrs.mcLabelsTPC[
i].fClusterID[
j]; }
248inline int32_t GPUQA::GetMCLabelNID(
const mcLabels_t&
label) {
return 3; }
249inline int32_t GPUQA::GetMCLabelNID(uint32_t
i) {
return 3; }
250inline int32_t GPUQA::GetMCLabelID(uint32_t
i, uint32_t
j) {
return mTracking->mIOPtrs.mcLabelsTPC[
i].fClusterID[
j].fMCID; }
251inline int32_t GPUQA::GetMCLabelID(
const mcLabels_t&
label, uint32_t
j) {
return label.fClusterID[
j].fMCID; }
252inline int32_t GPUQA::GetMCLabelID(
const mcLabel_t&
label) {
return label.fMCID; }
253inline uint32_t GPUQA::GetMCLabelCol(uint32_t
i, uint32_t
j) {
return 0; }
255inline const auto& GPUQA::GetClusterLabels() {
return mTracking->mIOPtrs.mcLabelsTPC; }
256inline float GPUQA::GetMCLabelWeight(uint32_t
i, uint32_t
j) {
return mTracking->mIOPtrs.mcLabelsTPC[
i].fClusterID[
j].fWeight; }
257inline float GPUQA::GetMCLabelWeight(
const mcLabels_t&
label, uint32_t
j) {
return label.fClusterID[
j].fWeight; }
258inline float GPUQA::GetMCLabelWeight(
const mcLabel_t&
label) {
return label.fWeight; }
259inline int32_t GPUQA::FakeLabelID(int32_t
id) {
return id < 0 ?
id : (-2 -
id); }
260inline int32_t GPUQA::AbsLabelID(int32_t
id) {
return id >= 0 ?
id : (-
id - 2); }
261inline bool GPUQA::mcPresent() {
return !mConfig.noMC && mTracking && GetNMCLabels() && GetNMCTracks(0); }
262uint32_t GPUQA::GetMCLabelCol(
const mcLabel_t&
label)
const {
return 0; }
264bool GPUQA::CompareIgnoreFake(
const mcLabelI_t& l1,
const mcLabelI_t& l2) {
return AbsLabelID(l1) == AbsLabelID(l2); }
265#define TRACK_EXPECTED_REFERENCE_X TRACK_EXPECTED_REFERENCE_X_DEFAULT
270 return obj[mMCEventOffset[l.getSourceID()] + l.getEventID()][l.getTrackID()];
274auto GPUQA::getHistArray<TH1F>()
276 return std::make_pair(mHist1D, &mHist1D_pos);
279auto GPUQA::getHistArray<TH2F>()
281 return std::make_pair(mHist2D, &mHist2D_pos);
284auto GPUQA::getHistArray<TH1D>()
286 return std::make_pair(mHist1Dd, &mHist1Dd_pos);
289auto GPUQA::getHistArray<TGraphAsymmErrors>()
291 return std::make_pair(mHistGraph, &mHistGraph_pos);
293template <
class T,
typename... Args>
294void GPUQA::createHist(T*&
h,
const char*
name, Args... args)
296 const auto&
p = getHistArray<T>();
297 if (mHaveExternalHists) {
298 if (
p.first->size() <=
p.second->size()) {
299 GPUError(
"Array sizes mismatch: Histograms %lu <= Positions %lu",
p.first->size(),
p.second->size());
300 throw std::runtime_error(
"Incoming histogram array incomplete");
302 if (strcmp((*
p.first)[
p.second->size()].GetName(),
name)) {
303 GPUError(
"Histogram name mismatch: in array %s, trying to create %s", (*
p.first)[
p.second->size()].GetName(),
name);
304 throw std::runtime_error(
"Incoming histogram has incorrect name");
307 if constexpr (std::is_same_v<T, TGraphAsymmErrors>) {
308 p.first->emplace_back();
309 p.first->back().SetName(
name);
311 p.first->emplace_back(
name, args...);
314 h = &((*
p.first)[
p.second->size()]);
315 p.second->emplace_back(&
h);
321 std::tuple<std::vector<std::unique_ptr<TCanvas>>, std::vector<std::unique_ptr<TLegend>>, std::vector<std::unique_ptr<TPad>>, std::vector<std::unique_ptr<TLatex>>, std::vector<std::unique_ptr<TH1D>>>
v;
325template <
class T,
typename... Args>
326T* GPUQA::createGarbageCollected(Args... args)
328 auto&
v = std::get<std::vector<std::unique_ptr<T>>>(mGarbageCollector->v);
329 v.emplace_back(std::make_unique<T>(args...));
330 return v.back().get();
332void GPUQA::clearGarbagageCollector()
334 std::get<std::vector<std::unique_ptr<TPad>>>(mGarbageCollector->v).
clear();
335 std::apply([](
auto&&... args) { ((args.clear()), ...); }, mGarbageCollector->v);
340 mMCEventOffset.resize(1, 0);
345 if (mQAInitialized && !mHaveExternalHists) {
351 clearGarbagageCollector();
358 return protect || physics;
360 return (!unattached && !physics && !protect);
364void GPUQA::SetAxisSize(T* e)
366 e->GetYaxis()->SetTitleOffset(1.0);
367 e->GetYaxis()->SetTitleSize(0.045);
368 e->GetYaxis()->SetLabelSize(0.045);
369 e->GetXaxis()->SetTitleOffset(1.03);
370 e->GetXaxis()->SetTitleSize(0.045);
371 e->GetXaxis()->SetLabelOffset(-0.005);
372 e->GetXaxis()->SetLabelSize(0.045);
375void GPUQA::SetLegend(TLegend* l)
378 l->SetTextSize(0.016);
382double* GPUQA::CreateLogAxis(int32_t nbins,
float xmin,
float xmax)
384 float logxmin = std::log10(xmin);
385 float logxmax = std::log10(xmax);
386 float binwidth = (logxmax - logxmin) / nbins;
388 double* xbins =
new double[nbins + 1];
391 for (int32_t
i = 1;
i <= nbins;
i++) {
392 xbins[
i] = std::pow(10, logxmin +
i * binwidth);
397void GPUQA::ChangePadTitleSize(TPad* p,
float size)
400 TPaveText* pt = (TPaveText*)(
p->GetPrimitive(
"title"));
402 GPUError(
"Error changing title");
404 pt->SetTextSize(
size);
409void GPUQA::DrawHisto(TH1* histo,
char*
filename,
char* options)
413 histo->Draw(options);
417void GPUQA::doPerfFigure(
float x,
float y,
float size)
422 TLatex* t = createGarbageCollected<TLatex>();
425 t->SetTextSize(
size);
426 t->DrawLatex(
x,
y, str_perf_figure_1);
427 t->DrawLatex(
x,
y - 0.01 -
size, str_perf_figure_2);
436int32_t GPUQA::InitQACreateHistograms()
438 char name[2048], fname[1024];
439 if (mQATasks & taskTrackingEff) {
441 for (int32_t
i = 0;
i < 5;
i++) {
442 for (int32_t
j = 0;
j < 2;
j++) {
443 for (int32_t k = 0; k < 2; k++) {
444 for (int32_t l = 0; l < 5; l++) {
445 snprintf(
name, 2048,
"%s%s%s%sVs%s",
"tracks", EFF_TYPES[
i], FINDABLE_NAMES[
j], PRIM_NAMES[k], VSPARAMETER_NAMES[l]);
447 std::unique_ptr<double[]> binsPt{CreateLogAxis(AXIS_BINS[4], k == 0 ? PT_MIN_PRIM : AXES_MIN[4], AXES_MAX[4])};
448 createHist(mEff[
i][
j][k][l],
name,
name, AXIS_BINS[l], binsPt.get());
450 createHist(mEff[
i][
j][k][l],
name,
name, AXIS_BINS[l], AXES_MIN[l], AXES_MAX[l]);
452 if (!mHaveExternalHists) {
453 mEff[
i][
j][k][l]->Sumw2();
455 strcat(
name,
"_eff");
457 createHist(mEffResult[
i][
j][k][l],
name);
466 if (mQATasks & taskTrackingRes) {
467 for (int32_t
i = 0;
i < 5;
i++) {
468 for (int32_t
j = 0;
j < 5;
j++) {
469 snprintf(
name, 2048,
"rms_%s_vs_%s", VSPARAMETER_NAMES[
i], VSPARAMETER_NAMES[
j]);
470 snprintf(fname, 1024,
"mean_%s_vs_%s", VSPARAMETER_NAMES[
i], VSPARAMETER_NAMES[
j]);
472 std::unique_ptr<double[]> binsPt{CreateLogAxis(AXIS_BINS[4], mConfig.resPrimaries == 1 ? PT_MIN_PRIM : AXES_MIN[4], AXES_MAX[4])};
473 createHist(mRes[
i][
j][0],
name,
name, AXIS_BINS[
j], binsPt.get());
474 createHist(mRes[
i][
j][1], fname, fname, AXIS_BINS[
j], binsPt.get());
476 createHist(mRes[
i][
j][0],
name,
name, AXIS_BINS[
j], AXES_MIN[
j], AXES_MAX[
j]);
477 createHist(mRes[
i][
j][1], fname, fname, AXIS_BINS[
j], AXES_MIN[
j], AXES_MAX[
j]);
479 snprintf(
name, 2048,
"res_%s_vs_%s", VSPARAMETER_NAMES[
i], VSPARAMETER_NAMES[
j]);
480 const float* axis = mConfig.nativeFitResolutions ? RES_AXES_NATIVE : RES_AXES;
481 const int32_t nbins =
i == 4 && mConfig.nativeFitResolutions ? (10 * RES_AXIS_BINS[0]) : RES_AXIS_BINS[0];
483 std::unique_ptr<double[]> binsPt{CreateLogAxis(AXIS_BINS[4], mConfig.resPrimaries == 1 ? PT_MIN_PRIM : AXES_MIN[4], AXES_MAX[4])};
484 createHist(mRes2[
i][
j],
name,
name, nbins, -axis[
i], axis[
i], AXIS_BINS[
j], binsPt.get());
486 createHist(mRes2[
i][
j],
name,
name, nbins, -axis[
i], axis[
i], AXIS_BINS[
j], AXES_MIN[
j], AXES_MAX[
j]);
493 if (mQATasks & taskTrackingResPull) {
494 for (int32_t
i = 0;
i < 5;
i++) {
495 for (int32_t
j = 0;
j < 5;
j++) {
496 snprintf(
name, 2048,
"pull_rms_%s_vs_%s", VSPARAMETER_NAMES[
i], VSPARAMETER_NAMES[
j]);
497 snprintf(fname, 1024,
"pull_mean_%s_vs_%s", VSPARAMETER_NAMES[
i], VSPARAMETER_NAMES[
j]);
499 std::unique_ptr<double[]> binsPt{CreateLogAxis(AXIS_BINS[4], AXES_MIN[4], AXES_MAX[4])};
500 createHist(mPull[
i][
j][0],
name,
name, AXIS_BINS[
j], binsPt.get());
501 createHist(mPull[
i][
j][1], fname, fname, AXIS_BINS[
j], binsPt.get());
503 createHist(mPull[
i][
j][0],
name,
name, AXIS_BINS[
j], AXES_MIN[
j], AXES_MAX[
j]);
504 createHist(mPull[
i][
j][1], fname, fname, AXIS_BINS[
j], AXES_MIN[
j], AXES_MAX[
j]);
506 snprintf(
name, 2048,
"pull_%s_vs_%s", VSPARAMETER_NAMES[
i], VSPARAMETER_NAMES[
j]);
508 std::unique_ptr<double[]> binsPt{CreateLogAxis(AXIS_BINS[4], AXES_MIN[4], AXES_MAX[4])};
509 createHist(mPull2[
i][
j],
name,
name, RES_AXIS_BINS[0], -PULL_AXIS, PULL_AXIS, AXIS_BINS[
j], binsPt.get());
511 createHist(mPull2[
i][
j],
name,
name, RES_AXIS_BINS[0], -PULL_AXIS, PULL_AXIS, AXIS_BINS[
j], AXES_MIN[
j], AXES_MAX[
j]);
518 if (mQATasks & taskClusterAttach) {
519 for (int32_t
i = 0;
i < N_CLS_TYPE * N_CLS_HIST - 1;
i++) {
520 int32_t ioffset =
i >= (2 * N_CLS_HIST - 1) ? (2 * N_CLS_HIST - 1) :
i >= N_CLS_HIST ? N_CLS_HIST : 0;
521 int32_t itype =
i >= (2 * N_CLS_HIST - 1) ? 2 :
i >= N_CLS_HIST ? 1 : 0;
522 snprintf(
name, 2048,
"clusters%s%s", CLUSTER_NAMES_SHORT[
i - ioffset], CLUSTER_TYPES[itype]);
523 std::unique_ptr<double[]> binsPt{CreateLogAxis(AXIS_BINS[4], PT_MIN_CLUST, PT_MAX)};
524 createHist(mClusters[
i],
name,
name, AXIS_BINS[4], binsPt.get());
528 if (mQATasks & taskTrackStatistics) {
530 for (int32_t
i = 0;
i < 2;
i++) {
531 snprintf(
name, 2048,
i ?
"nrows_with_cluster" :
"nclusters");
532 createHist(mNCl[
i],
name,
name, 160, 0, 159);
534 snprintf(
name, 2048,
"tracks");
535 std::unique_ptr<double[]> binsPt{CreateLogAxis(AXIS_BINS[4], PT_MIN_CLUST, PT_MAX)};
536 createHist(mTracks,
name,
name, AXIS_BINS[4], binsPt.get());
537 createHist(mClXY,
"clXY",
"clXY", 1000, -250, 250, 1000, -250, 250);
540 if ((mQATasks & taskClusterCounts) && mConfig.clusterRejectionHistograms) {
541 int32_t
num = DoClusterCounts(
nullptr, 2);
542 mHistClusterCount.resize(
num);
543 DoClusterCounts(
nullptr, 1);
546 for (uint32_t
i = 0;
i < mHist1D->size();
i++) {
547 *mHist1D_pos[
i] = &(*mHist1D)[
i];
549 for (uint32_t
i = 0;
i < mHist2D->size();
i++) {
550 *mHist2D_pos[
i] = &(*mHist2D)[
i];
552 for (uint32_t
i = 0;
i < mHist1Dd->size();
i++) {
553 *mHist1Dd_pos[
i] = &(*mHist1Dd)[
i];
555 for (uint32_t
i = 0;
i < mHistGraph->size();
i++) {
556 *mHistGraph_pos[
i] = &(*mHistGraph)[
i];
562int32_t GPUQA::loadHistograms(std::vector<TH1F>& i1, std::vector<TH2F>& i2, std::vector<TH1D>& i3, std::vector<TGraphAsymmErrors>& i4, int32_t tasks)
565 tasks = taskDefaultPostprocess;
567 if (mQAInitialized && (!mHaveExternalHists || tasks != mQATasks)) {
568 throw std::runtime_error(
"QA not initialized or initialized with different task array");
576 mHist1Dd_pos.clear();
577 mHistGraph_pos.clear();
578 mHaveExternalHists =
true;
583 if (InitQACreateHistograms()) {
586 mQAInitialized =
true;
596 uint32_t
n = mMCInfos.size();
597 fwrite(&
n,
sizeof(
n), 1, fp);
598 fwrite(mMCInfos.data(),
sizeof(mMCInfos[0]),
n, fp);
599 n = mMCInfosCol.size();
600 fwrite(&
n,
sizeof(
n), 1, fp);
601 fwrite(mMCInfosCol.data(),
sizeof(mMCInfosCol[0]),
n, fp);
602 n = mMCEventOffset.size();
603 fwrite(&
n,
sizeof(
n), 1, fp);
604 fwrite(mMCEventOffset.data(),
sizeof(mMCEventOffset[0]),
n, fp);
616 if ((
x = fread(&
n,
sizeof(
n), 1, fp)) != 1) {
621 if (fread(mMCInfos.data(),
sizeof(mMCInfos[0]),
n, fp) !=
n) {
625 if ((
x = fread(&
n,
sizeof(
n), 1, fp)) != 1) {
629 mMCInfosCol.resize(
n);
630 if (fread(mMCInfosCol.data(),
sizeof(mMCInfosCol[0]),
n, fp) !=
n) {
634 if ((
x = fread(&
n,
sizeof(
n), 1, fp)) != 1) {
638 mMCEventOffset.resize(
n);
639 if (fread(mMCEventOffset.data(),
sizeof(mMCEventOffset[0]),
n, fp) !=
n) {
643 if (mTracking && mTracking->GetProcessingSettings().debugLevel >= 2) {
644 printf(
"Read %ld bytes MC Infos\n", ftell(fp));
648 CopyO2MCtoIOPtr(&mTracking->mIOPtrs);
655 ptr->mcInfosTPC = mMCInfos.data();
656 ptr->nMCInfosTPC = mMCInfos.size();
657 ptr->mcInfosTPCCol = mMCInfosCol.data();
658 ptr->nMCInfosTPCCol = mMCInfosCol.size();
664 if (!mO2MCDataLoaded) {
666 if (mTracking && mTracking->GetProcessingSettings().debugLevel) {
667 GPUInfo(
"Start reading O2 Track MC information");
670 static constexpr float PRIM_MAX_T = 0.01f;
673 std::vector<int32_t> refId;
676 auto evrec = dc->getEventRecords();
678 uint32_t nSimSources = mcReader.getNSources();
679 mMCEventOffset.resize(nSimSources);
680 uint32_t nSimTotalEvents = 0;
681 uint32_t nSimTotalTracks = 0;
682 for (uint32_t
i = 0;
i < nSimSources;
i++) {
683 mMCEventOffset[
i] = nSimTotalEvents;
684 nSimTotalEvents += mcReader.getNEvents(
i);
687 mMCInfosCol.resize(nSimTotalEvents);
688 for (int32_t iSim = 0; iSim < mcReader.getNSources(); iSim++) {
689 for (int32_t
i = 0;
i < mcReader.getNEvents(iSim);
i++) {
694 const std::vector<o2::MCTrack>&
tracks = mcReader.getTracks(iSim,
i);
695 const std::vector<o2::TrackReference>& trackRefs = mcReader.getTrackRefsByEvent(iSim,
i);
697 refId.resize(
tracks.size());
698 std::fill(refId.begin(), refId.end(), -1);
699 for (uint32_t
j = 0;
j < trackRefs.size();
j++) {
701 int32_t trkId = trackRefs[
j].getTrackID();
702 if (refId[trkId] == -1) {
707 mMCInfosCol[mMCEventOffset[iSim] +
i].first = mMCInfos.size();
708 mMCInfosCol[mMCEventOffset[iSim] +
i].num =
tracks.size();
709 mMCInfos.resize(mMCInfos.size() +
tracks.size());
710 for (uint32_t
j = 0;
j <
tracks.size();
j++) {
711 auto& info = mMCInfos[mMCInfosCol[mMCEventOffset[iSim] +
i].first +
j];
713 TParticlePDG* particle = TDatabasePDG::Instance()->GetParticle(trk.GetPdgCode());
715 if (abs(trk.GetPdgCode()) == kElectron) {
718 if (abs(trk.GetPdgCode()) == kMuonMinus) {
721 if (abs(trk.GetPdgCode()) == kPiPlus) {
724 if (abs(trk.GetPdgCode()) == kKPlus) {
727 if (abs(trk.GetPdgCode()) == kProton) {
731 info.charge = particle ? particle->Charge() : 0;
732 info.prim = trk.T() < PRIM_MAX_T;
733 info.primDaughters = 0;
734 if (trk.getFirstDaughterTrackId() != -1) {
735 for (int32_t k = trk.getFirstDaughterTrackId(); k <= trk.getLastDaughterTrackId(); k++) {
736 if (tracks[k].
T() < PRIM_MAX_T) {
737 info.primDaughters = 1;
745 const auto& trkRef = trackRefs[refId[
j]];
749 info.pX = trkRef.Px();
750 info.pY = trkRef.Py();
751 info.pZ = trkRef.Pz();
752 info.genRadius = std::sqrt(trk.GetStartVertexCoordinatesX() * trk.GetStartVertexCoordinatesX() + trk.GetStartVertexCoordinatesY() * trk.GetStartVertexCoordinatesY() + trk.GetStartVertexCoordinatesZ() * trk.GetStartVertexCoordinatesZ());
754 info.x = info.y = info.z = info.pX = info.pY = info.pZ = 0;
760 if (mTracking && mTracking->GetProcessingSettings().debugLevel) {
763 mO2MCDataLoaded =
true;
766 CopyO2MCtoIOPtr(updateIOPtr);
773 if (mQAInitialized) {
774 throw std::runtime_error(
"QA already initialized");
780 mHist1D =
new std::vector<TH1F>;
781 mHist2D =
new std::vector<TH2F>;
782 mHist1Dd =
new std::vector<TH1D>;
783 mHistGraph =
new std::vector<TGraphAsymmErrors>;
789 if (mTracking->GetProcessingSettings().qcRunFraction != 100.f && mQATasks != taskClusterCounts) {
790 throw std::runtime_error(
"QA with qcRunFraction only supported for taskClusterCounts");
794 mClNative = mTracking->mIOPtrs.clustersNative;
797 if (InitQACreateHistograms()) {
801 if (mConfig.enableLocalOutput) {
802 mkdir(
"plots", S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH);
807 InitO2MCData(mTracking ? &mTracking->mIOPtrs : nullptr);
811 if (mConfig.matchMCLabels.size()) {
812 uint32_t nFiles = mConfig.matchMCLabels.size();
813 std::vector<std::unique_ptr<TFile>> files;
814 std::vector<std::vector<std::vector<int32_t>>*> labelsBuffer(nFiles);
815 std::vector<std::vector<std::vector<int32_t>>*> effBuffer(nFiles);
816 for (uint32_t
i = 0;
i < nFiles;
i++) {
817 files.emplace_back(std::make_unique<TFile>(mConfig.matchMCLabels[
i].c_str()));
818 labelsBuffer[
i] = (std::vector<std::vector<int32_t>>*)files[
i]->Get(
"mcLabelBuffer");
819 effBuffer[
i] = (std::vector<std::vector<int32_t>>*)files[
i]->Get(
"mcEffBuffer");
820 if (labelsBuffer[
i] ==
nullptr || effBuffer[
i] ==
nullptr) {
821 GPUError(
"Error opening / reading from labels file %u/%s: %p %p",
i, mConfig.matchMCLabels[
i].c_str(), (
void*)labelsBuffer[
i], (
void*)effBuffer[
i]);
826 mGoodTracks.resize(labelsBuffer[0]->
size());
827 mGoodHits.resize(labelsBuffer[0]->
size());
828 for (uint32_t iEvent = 0; iEvent < labelsBuffer[0]->size(); iEvent++) {
829 std::vector<bool> labelsOK((*effBuffer[0])[iEvent].
size());
830 for (uint32_t k = 0; k < (*effBuffer[0])[iEvent].
size(); k++) {
832 for (uint32_t l = 0; l < nFiles; l++) {
833 if ((*effBuffer[0])[iEvent][k] != (*effBuffer[l])[iEvent][k]) {
839 mGoodTracks[iEvent].resize((*labelsBuffer[0])[iEvent].size());
840 for (uint32_t k = 0; k < (*labelsBuffer[0])[iEvent].
size(); k++) {
841 if ((*labelsBuffer[0])[iEvent][k] == MC_LABEL_INVALID) {
844 mGoodTracks[iEvent][k] = labelsOK[abs((*labelsBuffer[0])[iEvent][k])];
848 mQAInitialized =
true;
854 if (!mQAInitialized) {
855 throw std::runtime_error(
"QA not initialized");
857 if (mTracking && mTracking->GetProcessingSettings().debugLevel >= 2) {
858 GPUInfo(
"Running QA - Mask %d, Efficiency %d, Resolution %d, Pulls %d, Cluster Attachment %d, Track Statistics %d, Cluster Counts %d", mQATasks, (int32_t)(mQATasks & taskTrackingEff), (int32_t)(mQATasks & taskTrackingRes), (int32_t)(mQATasks & taskTrackingResPull), (int32_t)(mQATasks & taskClusterAttach), (int32_t)(mQATasks & taskTrackStatistics), (int32_t)(mQATasks & taskClusterCounts));
860 if (!clNative && mTracking) {
861 clNative = mTracking->mIOPtrs.clustersNative;
863 mClNative = clNative;
865#ifdef GPUCA_TPC_GEOMETRY_O2
866 uint32_t nSimEvents = GetNMCCollissions();
867 if (mTrackMCLabelsReverse.size() < nSimEvents) {
868 mTrackMCLabelsReverse.resize(nSimEvents);
870 if (mRecTracks.size() < nSimEvents) {
871 mRecTracks.resize(nSimEvents);
873 if (mFakeTracks.size() < nSimEvents) {
874 mFakeTracks.resize(nSimEvents);
876 if (mMCParam.size() < nSimEvents) {
877 mMCParam.resize(nSimEvents);
882 uint32_t nReconstructedTracks = 0;
883 if (tracksExternal) {
885 nReconstructedTracks = tracksExternal->size();
888 nReconstructedTracks = mTracking->mIOPtrs.nMergedTracks;
890 mTrackMCLabels.resize(nReconstructedTracks);
891 for (uint32_t iCol = 0; iCol < GetNMCCollissions(); iCol++) {
892 mTrackMCLabelsReverse[iCol].resize(GetNMCTracks(iCol));
893 mRecTracks[iCol].resize(GetNMCTracks(iCol));
894 mFakeTracks[iCol].resize(GetNMCTracks(iCol));
895 mMCParam[iCol].resize(GetNMCTracks(iCol));
896 memset(mRecTracks[iCol].
data(), 0, mRecTracks[iCol].
size() *
sizeof(mRecTracks[iCol][0]));
897 memset(mFakeTracks[iCol].
data(), 0, mFakeTracks[iCol].
size() *
sizeof(mFakeTracks[iCol][0]));
898 for (
size_t i = 0;
i < mTrackMCLabelsReverse[iCol].size();
i++) {
899 mTrackMCLabelsReverse[iCol][
i] = -1;
902 if (mQATasks & taskClusterAttach && GetNMCLabels()) {
903 mClusterParam.resize(GetNMCLabels());
904 memset(mClusterParam.data(), 0, mClusterParam.size() *
sizeof(mClusterParam[0]));
909 if (mConfig.writeMCLabels) {
910 mcEffBuffer.resize(mNEvents);
911 mcLabelBuffer.resize(mNEvents);
912 mcEffBuffer[mNEvents - 1].resize(GetNMCTracks(0));
913 mcLabelBuffer[mNEvents - 1].resize(nReconstructedTracks);
916 bool mcAvail = mcPresent() || tracksExtMC;
921 if (tracksExternal) {
923 for (uint32_t
i = 0;
i < tracksExternal->size();
i++) {
924 mTrackMCLabels[
i] = (*tracksExtMC)[
i];
928 tbb::parallel_for(tbb::blocked_range<uint32_t>(0, nReconstructedTracks, (
QA_DEBUG == 0) ? 32 : nReconstructedTracks), [&](const tbb::blocked_range<uint32_t>&
range) {
929 auto acc = GPUTPCTrkLbl<true, mcLabelI_t>(GetClusterLabels(), 1.f - mConfig.recThreshold);
934 std::vector<mcLabel_t> labels;
935 for (uint32_t k = 0; k < track.NClusters(); k++) {
940 uint32_t hitId = mTracking->mIOPtrs.mergedTrackHits[track.FirstClusterRef() + k].num;
941 if (hitId >= GetNMCLabels()) {
942 GPUError(
"Invalid hit id %u > %d (nClusters %d)", hitId, GetNMCLabels(), mTracking->mIOPtrs.clustersNative ? mTracking->mIOPtrs.clustersNative->nClustersTotal : 0);
943 throw std::runtime_error(
"qa error");
946 for (int32_t
j = 0;
j < GetMCLabelNID(hitId);
j++) {
947 if (GetMCLabelID(hitId,
j) >= (int32_t)GetNMCTracks(GetMCLabelCol(hitId,
j))) {
948 GPUError(
"Invalid label %d > %d (hit %d, label %d, col %d)", GetMCLabelID(hitId,
j), GetNMCTracks(GetMCLabelCol(hitId,
j)), hitId,
j, (int32_t)GetMCLabelCol(hitId,
j));
949 throw std::runtime_error(
"qa error");
951 if (GetMCLabelID(hitId,
j) >= 0) {
953 GPUInfo(
"Track %d Cluster %u Label %d: %d (%f)",
i, k,
j, GetMCLabelID(hitId,
j), GetMCLabelWeight(hitId,
j));
959 float maxweight, sumweight;
961 auto maxLabel = acc.computeLabel(&maxweight, &sumweight, &maxcount);
962 mTrackMCLabels[
i] = maxLabel;
963 if (
QA_DEBUG && track.OK() && GetNMCTracks(maxLabel) > (uint32_t)maxLabel.getTrackID()) {
964 const mcInfo_t& mc = GetMCTrack(maxLabel);
965 GPUInfo(
"Track %d label %d (fake %d) weight %f clusters %d (fitted %d) (%f%% %f%%) Pt %f",
i, maxLabel.getTrackID(), (int32_t)(maxLabel.isFake()), maxweight,
nClusters, track.NClustersFitted(), 100.f * maxweight / sumweight, 100.f * (
float)maxcount / (
float)
nClusters,
966 std::sqrt(mc.pX * mc.pX + mc.pY * mc.pY));
971 if (
QA_TIMING || (mTracking && mTracking->GetProcessingSettings().debugLevel >= 3)) {
975 for (uint32_t
i = 0;
i < nReconstructedTracks;
i++) {
977 mcLabelI_t
label = mTrackMCLabels[
i];
978 if (mQATasks & taskClusterAttach) {
984 for (uint32_t k = 0; k < track->NClusters(); k++) {
988 mClusterParam[mTracking->mIOPtrs.mergedTrackHits[track->FirstClusterRef() + k].num].fakeAttached++;
992 if (mMCTrackMin == -1 || (
label.getTrackID() >= mMCTrackMin &&
label.getTrackID() < mMCTrackMax)) {
993 for (uint32_t k = 0; k < track->NClusters(); k++) {
997 int32_t hitId = mTracking->mIOPtrs.mergedTrackHits[track->FirstClusterRef() + k].num;
998 bool correct =
false;
999 for (int32_t
j = 0;
j < GetMCLabelNID(hitId);
j++) {
1000 if (
label == GetMCLabel(hitId,
j)) {
1006 mClusterParam[hitId].attached++;
1008 mClusterParam[hitId].fakeAttached++;
1014 if (mTrackMCLabels[
i].isFake()) {
1015 (GetMCTrackObj(mFakeTracks,
label))++;
1016 }
else if (tracksExternal || !track->MergedLooper()) {
1017 GetMCTrackObj(mRecTracks,
label)++;
1018 if (mMCTrackMin == -1 || (
label.getTrackID() >= mMCTrackMin &&
label.getTrackID() < mMCTrackMax)) {
1019 int32_t& revLabel = GetMCTrackObj(mTrackMCLabelsReverse,
label);
1020 if (tracksExternal) {
1022 if (revLabel == -1 || fabsf((*tracksExternal)[
i].getZ()) < fabsf((*tracksExternal)[revLabel].getZ())) {
1027 const auto* trks = mTracking->mIOPtrs.mergedTracks;
1029 if (revLabel == -1) {
1031 }
else if (mTracking->GetParam().par.earlyTpcTransform) {
1032 comp = fabsf(trks[
i].GetParam().GetZ() + trks[
i].GetParam().GetTZOffset()) < fabsf(trks[revLabel].GetParam().GetZ() + trks[revLabel].GetParam().GetTZOffset());
1034 float shift1 = mTracking->GetTPCTransformHelper()->getCorrMap()->convDeltaTimeToDeltaZinTimeFrame(trks[
i].CSide() *
GPUChainTracking::NSECTORS / 2, trks[
i].GetParam().GetTZOffset());
1035 float shift2 = mTracking->GetTPCTransformHelper()->getCorrMap()->convDeltaTimeToDeltaZinTimeFrame(trks[revLabel].CSide() *
GPUChainTracking::NSECTORS / 2, trks[revLabel].GetParam().GetTZOffset());
1036 comp = fabsf(trks[
i].GetParam().GetZ() + shift1) < fabsf(trks[revLabel].GetParam().GetZ() + shift2);
1038 if (revLabel == -1 || !trks[revLabel].OK() || (trks[
i].OK() && comp)) {
1045 if ((mQATasks & taskClusterAttach) && mTracking->mIOPtrs.mergedTrackHitAttachment) {
1047 for (uint32_t
i = 0;
i < GetNMCLabels();
i++) {
1048 if (mClusterParam[
i].attached == 0 && mClusterParam[
i].fakeAttached == 0) {
1049 int32_t attach = mTracking->mIOPtrs.mergedTrackHitAttachment[
i];
1052 mcLabelI_t trackL = mTrackMCLabels[track];
1054 for (int32_t
j = 0;
j < GetMCLabelNID(
i);
j++) {
1056 if (trackL == GetMCLabel(
i,
j)) {
1062 mClusterParam[
i].fakeAdjacent++;
1064 mClusterParam[
i].adjacent++;
1071 if (mConfig.matchMCLabels.size()) {
1072 mGoodHits[mNEvents - 1].resize(GetNMCLabels());
1073 std::vector<bool> allowMCLabels(GetNMCTracks(0));
1074 for (uint32_t k = 0; k < GetNMCTracks(0); k++) {
1075 allowMCLabels[k] =
false;
1077 for (uint32_t
i = 0;
i < nReconstructedTracks;
i++) {
1078 if (!mGoodTracks[mNEvents - 1][
i]) {
1081 if (mConfig.matchDisplayMinPt > 0) {
1082 if (!mTrackMCLabels[
i].
isValid()) {
1085 const mcInfo_t& info = GetMCTrack(mTrackMCLabels[
i]);
1086 if (info.pX * info.pX + info.pY * info.pY < mConfig.matchDisplayMinPt * mConfig.matchDisplayMinPt) {
1092 for (uint32_t
j = 0;
j < track.NClusters();
j++) {
1093 int32_t hitId = mTracking->mIOPtrs.mergedTrackHits[track.FirstClusterRef() +
j].num;
1094 if (GetMCLabelNID(hitId)) {
1095 int32_t mcID = GetMCLabelID(hitId, 0);
1097 allowMCLabels[mcID] =
true;
1102 for (uint32_t
i = 0;
i < GetNMCLabels();
i++) {
1103 for (int32_t
j = 0;
j < GetMCLabelNID(
i);
j++) {
1104 int32_t mcID = GetMCLabelID(
i,
j);
1105 if (mcID >= 0 && allowMCLabels[mcID]) {
1106 mGoodHits[mNEvents - 1][
i] =
true;
1111 if (
QA_TIMING || (mTracking && mTracking->GetProcessingSettings().debugLevel >= 3)) {
1120 for (uint32_t iCol = 0; iCol < GetNMCCollissions(); iCol++) {
1121 for (uint32_t
i = 0;
i < GetNMCTracks(iCol);
i++) {
1122 mMCParam[iCol][
i].nWeightCls = 0.;
1125 for (uint32_t
i = 0;
i < GetNMCLabels();
i++) {
1126 float weightTotal = 0.f;
1127 for (int32_t
j = 0;
j < GetMCLabelNID(
i);
j++) {
1128 if (GetMCLabelID(
i,
j) >= 0) {
1129 weightTotal += GetMCLabelWeight(
i,
j);
1132 for (int32_t
j = 0;
j < GetMCLabelNID(
i);
j++) {
1133 if (GetMCLabelID(
i,
j) >= 0) {
1134 GetMCTrackObj(mMCParam, GetMCLabel(
i,
j)).nWeightCls += GetMCLabelWeight(
i,
j) / weightTotal;
1138 if (
QA_TIMING || (mTracking && mTracking->GetProcessingSettings().debugLevel >= 3)) {
1139 GPUInfo(
"QA Time: Compute cluster label weights:\t%6.0f us", timer.
GetCurrentElapsedTime(
true) * 1e6);
1143 tbb::parallel_for<uint32_t>(0, GetNMCCollissions(), [&](
auto iCol) {
1144 for (uint32_t
i = 0;
i < GetNMCTracks(iCol);
i++) {
1145 const mcInfo_t& info = GetMCTrack(
i, iCol);
1146 additionalMCParameters& mc2 = mMCParam[iCol][
i];
1147 mc2.pt = std::sqrt(info.pX * info.pX + info.pY * info.pY);
1148 mc2.phi = M_PI + std::atan2(-info.pY, -info.pX);
1149 float p = info.pX * info.pX + info.pY * info.pY + info.pZ * info.pZ;
1151 mc2.theta = mc2.eta = 0.f;
1153 mc2.theta = info.pZ == 0 ? (M_PI / 2) : (
std::acos(info.pZ /
std::sqrt(
p)));
1154 mc2.eta = -std::log(std::tan(0.5 * mc2.theta));
1156 if (mConfig.writeMCLabels) {
1157 std::vector<int32_t>& effBuffer = mcEffBuffer[mNEvents - 1];
1158 effBuffer[
i] = mRecTracks[iCol][
i] * 1000 + mFakeTracks[iCol][
i];
1161 }, tbb::simple_partitioner());
1162 if (
QA_TIMING || (mTracking && mTracking->GetProcessingSettings().debugLevel >= 3)) {
1163 GPUInfo(
"QA Time: Compute track mc parameters:\t%6.0f us", timer.
GetCurrentElapsedTime(
true) * 1e6);
1167 if (mQATasks & taskTrackingEff) {
1168 for (uint32_t iCol = 0; iCol < GetNMCCollissions(); iCol++) {
1169 for (uint32_t
i = 0;
i < GetNMCTracks(iCol);
i++) {
1170 if ((mMCTrackMin != -1 && (int32_t)
i < mMCTrackMin) || (mMCTrackMax != -1 && (int32_t)
i >= mMCTrackMax)) {
1173 const mcInfo_t& info = GetMCTrack(
i, iCol);
1174 const additionalMCParameters& mc2 = mMCParam[iCol][
i];
1175 if (mc2.nWeightCls == 0.f) {
1178 const float& mcpt = mc2.pt;
1179 const float& mcphi = mc2.phi;
1180 const float& mceta = mc2.eta;
1182 if (info.primDaughters) {
1185 if (mc2.nWeightCls < mConfig.minNClEff) {
1188 int32_t findable = mc2.nWeightCls >= mConfig.minNClFindable;
1192 if (info.charge == 0.f) {
1195 if (mConfig.filterCharge && info.charge * mConfig.filterCharge < 0) {
1198 if (mConfig.filterPID >= 0 && info.pid != mConfig.filterPID) {
1202 if (fabsf(mceta) > ETA_MAX || mcpt < PT_MIN || mcpt > PT_MAX) {
1206 float alpha = std::atan2(info.y, info.x);
1207 alpha /= M_PI / 9.f;
1209 alpha *= M_PI / 9.f;
1210 alpha += M_PI / 18.f;
1212 float c = std::cos(
alpha);
1213 float s = std::sin(
alpha);
1214 float localY = -info.x *
s + info.y *
c;
1216 if (mConfig.dumpToROOT) {
1218 float localX = info.x *
c + info.y *
s;
1219 effdump.Fill(
alpha, localX, localY, info.z, mcphi, mceta, mcpt, mRecTracks[iCol][
i], mFakeTracks[iCol][
i], findable, info.prim, mc2.nWeightCls);
1222 for (int32_t
j = 0;
j < 4;
j++) {
1223 for (int32_t k = 0; k < 2; k++) {
1224 if (k == 0 && findable == 0) {
1228 int32_t
val = (
j == 0) ? (mRecTracks[iCol][
i] ? 1 : 0) : (
j == 1) ? (mRecTracks[iCol][
i] ? mRecTracks[iCol][
i] - 1 : 0) : (
j == 2) ? mFakeTracks[iCol][
i] : 1;
1233 for (int32_t l = 0; l < 5; l++) {
1234 if (info.prim && mcpt < PT_MIN_PRIM) {
1237 if (l != 3 && fabsf(mceta) > ETA_MAX2) {
1240 if (l < 4 && mcpt < 1.f / mConfig.qpt) {
1244 float pos = l == 0 ? localY : l == 1 ? info.z : l == 2 ? mcphi : l == 3 ? mceta : mcpt;
1246 mEff[
j][k][!info.prim][l]->Fill(
pos,
val);
1252 if (
QA_TIMING || (mTracking && mTracking->GetProcessingSettings().debugLevel >= 3)) {
1258 if (mQATasks & (taskTrackingRes | taskTrackingResPull)) {
1260 prop.SetMaxSinPhi(.999);
1261 prop.SetMaterialTPC();
1262 prop.SetPolynomialField(&mParam->polynomialField);
1264 for (uint32_t
i = 0;
i < mTrackMCLabels.size();
i++) {
1265 if (mConfig.writeMCLabels) {
1266 std::vector<int32_t>& labelBuffer = mcLabelBuffer[mNEvents - 1];
1267 labelBuffer[
i] = mTrackMCLabels[
i].getTrackID();
1269 if (mTrackMCLabels[
i].isFake()) {
1272 const mcInfo_t& mc1 = GetMCTrack(mTrackMCLabels[
i]);
1273 const additionalMCParameters& mc2 = GetMCTrackObj(mMCParam, mTrackMCLabels[
i]);
1275 if (mc1.primDaughters) {
1278 if (!tracksExternal) {
1279 if (!mTracking->mIOPtrs.mergedTracks[
i].OK()) {
1282 if (mTracking->mIOPtrs.mergedTracks[
i].MergedLooper()) {
1286 if ((mMCTrackMin != -1 && mTrackMCLabels[
i].getTrackID() < mMCTrackMin) || (mMCTrackMax != -1 && mTrackMCLabels[
i].getTrackID() >= mMCTrackMax)) {
1289 if (fabsf(mc2.eta) > ETA_MAX || mc2.pt < PT_MIN || mc2.pt > PT_MAX) {
1292 if (mc1.charge == 0.f) {
1298 if (mConfig.filterCharge && mc1.charge * mConfig.filterCharge < 0) {
1301 if (mConfig.filterPID >= 0 && mc1.pid != mConfig.filterPID) {
1304 if (mc2.nWeightCls < mConfig.minNClRes) {
1307 if (mConfig.resPrimaries == 1 && !mc1.prim) {
1309 }
else if (mConfig.resPrimaries == 2 && mc1.prim) {
1312 if (GetMCTrackObj(mTrackMCLabelsReverse, mTrackMCLabels[
i]) != (int32_t)
i) {
1319 if (tracksExternal) {
1321 for (int32_t k = 0; k < 5; k++) {
1322 param.Par()[k] = (*tracksExternal)[
i].getParams()[k];
1324 for (int32_t k = 0; k < 15; k++) {
1325 param.Cov()[k] = (*tracksExternal)[
i].getCov()[k];
1327 param.X() = (*tracksExternal)[
i].getX();
1328 param.TZOffset() = (*tracksExternal)[
i].getTime0();
1329 alpha = (*tracksExternal)[
i].getAlpha();
1330 side = (*tracksExternal)[
i].hasBothSidesClusters() ? 2 : ((*tracksExternal)[
i].hasCSideClusters() ? 1 : 0);
1333 param = mTracking->mIOPtrs.mergedTracks[
i].GetParam();
1334 alpha = mTracking->mIOPtrs.mergedTracks[
i].GetAlpha();
1335 side = mTracking->mIOPtrs.mergedTracks[
i].CCE() ? 2 : (mTracking->mIOPtrs.mergedTracks[
i].CSide() ? 1 : 0);
1339 float c = std::cos(
alpha);
1340 float s = std::sin(
alpha);
1343 mclocal[0] =
x *
c +
y *
s;
1344 mclocal[1] = -
x *
s +
y *
c;
1347 mclocal[2] = px *
c + py *
s;
1348 mclocal[3] = -px *
s + py *
c;
1353 if (mclocal[0] >
param.GetX() + 20) {
1356 if (
param.GetX() > mConfig.maxResX) {
1360 auto getdz = [
this, &
param, &mc1, &
side, tracksExternal]() {
1361 if (tracksExternal) {
1362 return param.GetZ();
1364 if (!mParam->continuousMaxTimeBin) {
1365 return param.GetZ() - mc1.z;
1367#ifdef GPUCA_TPC_GEOMETRY_O2
1368 if (!mParam->par.earlyTpcTransform) {
1370 return param.GetZ() + shift - mc1.z;
1377 bool inFlyDirection = 0;
1378 if (mConfig.strict) {
1380 const float dy =
param.Y() - mclocal[1];
1381 const float dz = getdz();
1382 if (dx * dx + dy * dy + dz * dz > 5.f * 5.f) {
1387 if (prop.PropagateToXAlpha(mclocal[0],
alpha, inFlyDirection)) {
1390 if (fabsf(
param.Y() - mclocal[1]) > (mConfig.strict ? 1.f : 4.f) || fabsf(getdz()) > (mConfig.strict ? 1.f : 4.f)) {
1393 float charge = mc1.charge > 0 ? 1.f : -1.f;
1395 float deltaY =
param.GetY() - mclocal[1];
1396 float deltaZ = getdz();
1397 float deltaPhiNative =
param.GetSinPhi() - mclocal[3] / mc2.pt;
1398 float deltaPhi = std::asin(
param.GetSinPhi()) - std::atan2(mclocal[3], mclocal[2]);
1399 float deltaLambdaNative =
param.GetDzDs() - mc1.pZ / mc2.pt;
1400 float deltaLambda = std::atan(
param.GetDzDs()) - std::atan2(mc1.pZ, mc2.pt);
1402 float deltaPt = (fabsf(1.f /
param.GetQPt()) - mc2.pt) / mc2.pt;
1404 float paramval[5] = {mclocal[1], mc1.z, mc2.phi, mc2.eta, mc2.pt};
1405 float resval[5] = {deltaY, deltaZ, mConfig.nativeFitResolutions ? deltaPhiNative : deltaPhi, mConfig.nativeFitResolutions ? deltaLambdaNative : deltaLambda, mConfig.nativeFitResolutions ? deltaPtNative : deltaPt};
1406 float pullval[5] = {deltaY / std::sqrt(
param.GetErr2Y()), deltaZ / std::sqrt(
param.GetErr2Z()), deltaPhiNative / std::sqrt(
param.GetErr2SinPhi()), deltaLambdaNative / std::sqrt(
param.GetErr2DzDs()), deltaPtNative / std::sqrt(
param.GetErr2QPt())};
1408 for (int32_t
j = 0;
j < 5;
j++) {
1409 for (int32_t k = 0; k < 5; k++) {
1410 if (k != 3 && fabsf(mc2.eta) > ETA_MAX2) {
1413 if (k < 4 && mc2.pt < 1.f / mConfig.qpt) {
1416 if (mQATasks & taskTrackingRes) {
1417 mRes2[
j][k]->Fill(resval[
j], paramval[k]);
1419 if (mQATasks & taskTrackingResPull) {
1420 mPull2[
j][k]->Fill(pullval[
j], paramval[k]);
1425 if (
QA_TIMING || (mTracking && mTracking->GetProcessingSettings().debugLevel >= 3)) {
1430 if (mQATasks & taskClusterAttach) {
1432 for (uint32_t iTrk = 0; iTrk < nReconstructedTracks; iTrk++) {
1437 if (!mTrackMCLabels[iTrk].
isValid()) {
1438 for (uint32_t k = 0; k < track.NClusters(); k++) {
1442 int32_t hitId = mTracking->mIOPtrs.mergedTrackHits[track.FirstClusterRef() + k].num;
1443 float totalWeight = 0.;
1444 for (int32_t
j = 0;
j < GetMCLabelNID(hitId);
j++) {
1446 totalWeight += GetMCLabelWeight(hitId,
j);
1449 int32_t attach = mTracking->mIOPtrs.mergedTrackHitAttachment[hitId];
1451 if (totalWeight > 0) {
1452 float weight = 1.f / (totalWeight * (mClusterParam[hitId].attached + mClusterParam[hitId].fakeAttached));
1453 for (int32_t
j = 0;
j < GetMCLabelNID(hitId);
j++) {
1454 mcLabelI_t
label = GetMCLabel(hitId,
j);
1456 float pt = GetMCTrackObj(mMCParam,
label).pt;
1457 if (pt < PT_MIN_CLUST) {
1460 mClusters[CL_fake]->Fill(pt, GetMCLabelWeight(hitId,
j) *
weight);
1461 mClusters[CL_att_adj]->Fill(pt, GetMCLabelWeight(hitId,
j) *
weight);
1462 if (GetMCTrackObj(mRecTracks,
label)) {
1463 mClusters[CL_tracks]->Fill(pt, GetMCLabelWeight(hitId,
j) *
weight);
1465 mClusters[CL_all]->Fill(pt, GetMCLabelWeight(hitId,
j) *
weight);
1466 if (protect || physics) {
1467 mClusters[CL_prot]->Fill(pt, GetMCLabelWeight(hitId,
j) *
weight);
1470 mClusters[CL_physics]->Fill(pt, GetMCLabelWeight(hitId,
j) *
weight);
1475 float weight = 1.f / (mClusterParam[hitId].attached + mClusterParam[hitId].fakeAttached);
1476 mClusters[CL_fake]->Fill(0.f,
weight);
1477 mClusters[CL_att_adj]->Fill(0.f,
weight);
1478 mClusters[CL_all]->Fill(0.f,
weight);
1479 mClusterCounts.nUnaccessible +=
weight;
1480 if (protect || physics) {
1481 mClusters[CL_prot]->Fill(0.f,
weight);
1484 mClusters[CL_physics]->Fill(0.f,
weight);
1490 mcLabelI_t
label = mTrackMCLabels[iTrk];
1491 if (mMCTrackMin != -1 && (
label.getTrackID() < mMCTrackMin ||
label.getTrackID() >= mMCTrackMax)) {
1494 for (uint32_t k = 0; k < track.NClusters(); k++) {
1498 int32_t hitId = mTracking->mIOPtrs.mergedTrackHits[track.FirstClusterRef() + k].num;
1499 float pt = GetMCTrackObj(mMCParam,
label).pt;
1500 if (pt < PT_MIN_CLUST) {
1503 float weight = 1.f / (mClusterParam[hitId].attached + mClusterParam[hitId].fakeAttached);
1504 bool correct =
false;
1505 for (int32_t
j = 0;
j < GetMCLabelNID(hitId);
j++) {
1506 if (
label == GetMCLabel(hitId,
j)) {
1512 mClusters[CL_attached]->Fill(pt,
weight);
1513 mClusters[CL_tracks]->Fill(pt,
weight);
1515 mClusters[CL_fake]->Fill(pt,
weight);
1517 mClusters[CL_att_adj]->Fill(pt,
weight);
1518 mClusters[CL_all]->Fill(pt,
weight);
1519 int32_t attach = mTracking->mIOPtrs.mergedTrackHitAttachment[hitId];
1521 if (protect || physics) {
1522 mClusters[CL_prot]->Fill(pt,
weight);
1525 mClusters[CL_physics]->Fill(pt,
weight);
1529 for (uint32_t
i = 0;
i < GetNMCLabels();
i++) {
1530 if ((mMCTrackMin != -1 && GetMCLabelID(
i, 0) < mMCTrackMin) || (mMCTrackMax != -1 && GetMCLabelID(
i, 0) >= mMCTrackMax)) {
1533 if (mClusterParam[
i].attached || mClusterParam[
i].fakeAttached) {
1536 int32_t attach = mTracking->mIOPtrs.mergedTrackHitAttachment[
i];
1538 if (mClusterParam[
i].adjacent) {
1541 float totalWeight = 0.;
1542 for (int32_t
j = 0;
j < GetMCLabelNID(
i);
j++) {
1543 mcLabelI_t labelT = GetMCLabel(
i,
j);
1545 totalWeight += GetMCLabelWeight(
i,
j);
1548 float weight = 1.f / totalWeight;
1549 if (totalWeight > 0) {
1550 for (int32_t
j = 0;
j < GetMCLabelNID(
i);
j++) {
1551 mcLabelI_t labelT = GetMCLabel(
i,
j);
1553 float pt = GetMCTrackObj(mMCParam, labelT).pt;
1554 if (pt < PT_MIN_CLUST) {
1557 if (GetMCTrackObj(mRecTracks, labelT)) {
1558 mClusters[CL_tracks]->Fill(pt, GetMCLabelWeight(
i,
j) *
weight);
1560 mClusters[CL_att_adj]->Fill(pt, GetMCLabelWeight(
i,
j) *
weight);
1561 mClusters[CL_fakeAdj]->Fill(pt, GetMCLabelWeight(
i,
j) *
weight);
1562 mClusters[CL_all]->Fill(pt, GetMCLabelWeight(
i,
j) *
weight);
1563 if (protect || physics) {
1564 mClusters[CL_prot]->Fill(pt, GetMCLabelWeight(
i,
j) *
weight);
1567 mClusters[CL_physics]->Fill(pt, GetMCLabelWeight(
i,
j) *
weight);
1572 mClusters[CL_att_adj]->Fill(0.f, 1.f);
1573 mClusters[CL_fakeAdj]->Fill(0.f, 1.f);
1574 mClusters[CL_all]->Fill(0.f, 1.f);
1575 mClusterCounts.nUnaccessible++;
1576 if (protect || physics) {
1577 mClusters[CL_prot]->Fill(0.f, 1.f);
1580 mClusters[CL_physics]->Fill(0.f, 1.f);
1584 float pt = GetMCTrackObj(mMCParam, mTrackMCLabels[
label]).pt;
1585 if (pt < PT_MIN_CLUST) {
1588 mClusters[CL_att_adj]->Fill(pt, 1.f);
1589 mClusters[CL_tracks]->Fill(pt, 1.f);
1590 mClusters[CL_all]->Fill(pt, 1.f);
1591 if (protect || physics) {
1592 mClusters[CL_prot]->Fill(pt, 1.f);
1595 mClusters[CL_physics]->Fill(pt, 1.f);
1599 float totalWeight = 0.;
1600 for (int32_t
j = 0;
j < GetMCLabelNID(
i);
j++) {
1601 mcLabelI_t labelT = GetMCLabel(
i,
j);
1603 totalWeight += GetMCLabelWeight(
i,
j);
1606 if (totalWeight > 0) {
1607 for (int32_t
j = 0;
j < GetMCLabelNID(
i);
j++) {
1608 mcLabelI_t
label = GetMCLabel(
i,
j);
1610 float pt = GetMCTrackObj(mMCParam,
label).pt;
1611 if (pt < PT_MIN_CLUST) {
1614 float weight = GetMCLabelWeight(
i,
j) / totalWeight;
1615 if (mClusterParam[
i].fakeAdjacent) {
1616 mClusters[CL_fakeAdj]->Fill(pt,
weight);
1618 if (mClusterParam[
i].fakeAdjacent) {
1619 mClusters[CL_att_adj]->Fill(pt,
weight);
1621 if (GetMCTrackObj(mRecTracks,
label)) {
1622 mClusters[CL_tracks]->Fill(pt,
weight);
1624 mClusters[CL_all]->Fill(pt,
weight);
1625 if (protect || physics) {
1626 mClusters[CL_prot]->Fill(pt,
weight);
1629 mClusters[CL_physics]->Fill(pt,
weight);
1634 if (mClusterParam[
i].fakeAdjacent) {
1635 mClusters[CL_fakeAdj]->Fill(0.f, 1.f);
1637 if (mClusterParam[
i].fakeAdjacent) {
1638 mClusters[CL_att_adj]->Fill(0.f, 1.f);
1640 mClusters[CL_all]->Fill(0.f, 1.f);
1641 mClusterCounts.nUnaccessible++;
1642 if (protect || physics) {
1643 mClusters[CL_prot]->Fill(0.f, 1.f);
1646 mClusters[CL_physics]->Fill(0.f, 1.f);
1652 if (
QA_TIMING || (mTracking && mTracking->GetProcessingSettings().debugLevel >= 3)) {
1656 }
else if (!mConfig.inputHistogramsOnly && !mConfig.noMC && (mQATasks & (taskTrackingEff | taskTrackingRes | taskTrackingResPull | taskClusterAttach))) {
1657 GPUWarning(
"No MC information available, only running partial TPC QA!");
1660 if (mQATasks & taskTrackStatistics) {
1662 std::vector<std::array<float, 3>> clusterAttachCounts;
1664 clusterAttachCounts.resize(GetNMCLabels(), {0.f, 0.f});
1666 for (uint32_t
i = 0;
i < nReconstructedTracks;
i++) {
1671 mTracks->Fill(1.f / fabsf(track.GetParam().GetQPt()));
1672 mNCl[0]->Fill(track.NClustersFitted());
1673 uint32_t nClCorrected = 0;
1674 const auto& trackClusters = mTracking->mIOPtrs.mergedTrackHits;
1676 for (uint32_t
j = 0;
j < track.NClusters();
j = jNext) {
1678 for (jNext =
j + 1;
j < track.NClusters(); jNext++) {
1679 if (trackClusters[track.FirstClusterRef() +
j].sector != trackClusters[track.FirstClusterRef() + jNext].sector || trackClusters[track.FirstClusterRef() +
j].row != trackClusters[track.FirstClusterRef() + jNext].row) {
1684 if (trackClusters[track.FirstClusterRef() +
j].leg == trackClusters[track.FirstClusterRef() + track.NClusters() - 1].leg && rowClCount) {
1687 if (mcAvail && rowClCount) {
1688 for (uint32_t k =
j; k < jNext; k++) {
1689 const auto& cl = trackClusters[track.FirstClusterRef() + k];
1693 bool labelOk =
false, labelOkNonFake =
false;
1694 const mcLabelI_t& trkLabel = mTrackMCLabels[
i];
1695 if (trkLabel.isValid() && !trkLabel.isNoise()) {
1696 for (int32_t l = 0; l < GetMCLabelNID(cl.num); l++) {
1697 const mcLabelI_t& clLabel = GetMCLabel(cl.num, l);
1698 if (clLabel.isValid() && !clLabel.isNoise() && CompareIgnoreFake(trkLabel, clLabel)) {
1700 if (!trkLabel.isFake()) {
1701 labelOkNonFake =
true;
1707 clusterAttachCounts[cl.num][0] += 1.0f;
1708 clusterAttachCounts[cl.num][1] += (float)labelOk / rowClCount;
1709 clusterAttachCounts[cl.num][2] += (float)labelOkNonFake / rowClCount;
1713 mNCl[1]->Fill(nClCorrected);
1715 if (mClNative && mTracking && mTracking->GetTPCTransformHelper()) {
1718 for (uint32_t k = 0; k < mClNative->nClusters[
i][
j]; k++) {
1719 const auto& cl = mClNative->clusters[
i][
j][k];
1721 GPUTPCConvertImpl::convert(*mTracking->GetTPCTransformHelper()->getCorrMap(), mTracking->GetParam(),
i,
j, cl.getPad(), cl.getTime(),
x,
y,
z);
1722 mTracking->GetParam().Sector2Global(
i,
x,
y,
z, &
x, &
y, &
z);
1729 double clusterAttachNormalizedCount = 0, clusterAttachNormalizedCountNonFake = 0;
1730 for (uint32_t
i = 0;
i < clusterAttachCounts.size();
i++) {
1731 if (clusterAttachCounts[
i][0]) {
1732 clusterAttachNormalizedCount += clusterAttachCounts[
i][1] / clusterAttachCounts[
i][0];
1733 clusterAttachNormalizedCountNonFake += clusterAttachCounts[
i][2] / clusterAttachCounts[
i][0];
1736 mClusterCounts.nCorrectlyAttachedNormalized = clusterAttachNormalizedCount;
1737 mClusterCounts.nCorrectlyAttachedNormalizedNonFake = clusterAttachNormalizedCountNonFake;
1738 clusterAttachCounts.clear();
1741 if (
QA_TIMING || (mTracking && mTracking->GetProcessingSettings().debugLevel >= 3)) {
1746 uint32_t nCl = clNative ? clNative->
nClustersTotal : mTracking->GetProcessors()->tpcMerger.NMaxClusters();
1747 mClusterCounts.nTotal += nCl;
1748 if (mQATasks & taskClusterCounts) {
1749 for (uint32_t
i = 0;
i < nCl;
i++) {
1750 int32_t attach = mTracking->mIOPtrs.mergedTrackHitAttachment[
i];
1754 float totalWeight = 0, weight400 = 0, weight40 = 0;
1755 for (int32_t
j = 0;
j < GetMCLabelNID(
i);
j++) {
1756 const auto&
label = GetMCLabel(
i,
j);
1757 if (GetMCLabelID(
label) >= 0) {
1758 totalWeight += GetMCLabelWeight(
label);
1759 if (GetMCTrackObj(mMCParam,
label).pt >= 0.4) {
1760 weight400 += GetMCLabelWeight(
label);
1762 if (GetMCTrackObj(mMCParam,
label).pt <= 0.04) {
1763 weight40 += GetMCLabelWeight(
label);
1767 if (totalWeight > 0 && 10.f * weight400 >= totalWeight) {
1768 if (!unattached && !protect && !physics) {
1769 mClusterCounts.nFakeRemove400++;
1770 int32_t totalFake = weight400 < 0.9f * totalWeight;
1772 mClusterCounts.nFullFakeRemove400++;
1787 mClusterCounts.nAbove400++;
1789 if (totalWeight > 0 && weight40 >= 0.9 * totalWeight) {
1790 mClusterCounts.nBelow40++;
1791 if (protect || physics) {
1792 mClusterCounts.nFakeProtect40++;
1797 mClusterCounts.nPhysics++;
1799 if (physics || protect) {
1800 mClusterCounts.nProt++;
1803 mClusterCounts.nUnattached++;
1809 if ((mQATasks & taskClusterCounts) && mConfig.clusterRejectionHistograms) {
1810 DoClusterCounts(
nullptr);
1811 mClusterCounts = counts_t();
1814 if (
QA_TIMING || (mTracking && mTracking->GetProcessingSettings().debugLevel >= 3)) {
1818 if (mConfig.dumpToROOT) {
1819 if (!clNative || !mTracking || !mTracking->mIOPtrs.mergedTrackHitAttachment || !mTracking->mIOPtrs.mergedTracks) {
1820 throw std::runtime_error(
"Cannot dump non o2::tpc::clusterNative clusters, need also hit attachmend and GPU tracks");
1825 for (uint32_t k = 0; k < mClNative->nClusters[
i][
j]; k++) {
1826 const auto& cl = mClNative->clusters[
i][
j][k];
1827 uint32_t attach = mTracking->mIOPtrs.mergedTrackHitAttachment[clid];
1828 float x = 0,
y = 0,
z = 0;
1831 const auto& trk = mTracking->mIOPtrs.mergedTracks[track];
1832 mTracking->GetTPCTransformHelper()->Transform(
i,
j, cl.getPad(), cl.getTime(),
x,
y,
z, trk.GetParam().GetTZOffset());
1833 mTracking->GetParam().Sector2Global(
i,
x,
y,
z, &
x, &
y, &
z);
1835 uint32_t extState = mTracking->mIOPtrs.mergedTrackHitStates ? mTracking->mIOPtrs.mergedTrackHitStates[clid] : 0;
1837 if (mConfig.dumpToROOT >= 2) {
1840 memset((
void*)&trk, 0,
sizeof(trk));
1841 memset((
void*)&trkHit, 0,
sizeof(trkHit));
1844 trk = mTracking->mIOPtrs.mergedTracks[track];
1845 for (uint32_t l = 0; l < trk.NClusters(); l++) {
1846 const auto& tmp = mTracking->mIOPtrs.mergedTrackHits[trk.FirstClusterRef() + l];
1847 if (tmp.num == clid) {
1853 static auto cldump =
GPUROOTDump<o2::tpc::ClusterNative, GPUTPCGMMergedTrack, GPUTPCGMMergedTrackHit, uint32_t, uint32_t, float, float, float, uint32_t, uint32_t, uint32_t>::getNew(
"cluster",
"track",
"trackHit",
"attach",
"extState",
"x",
"y",
"z",
"sector",
"row",
"nEv",
"clusterTree");
1854 cldump.Fill(cl, trk, trkHit, attach, extState,
x,
y,
z,
i,
j, mNEvents - 1);
1856 static auto cldump =
GPUROOTDump<o2::tpc::ClusterNative, uint32_t, uint32_t, float, float, float, uint32_t, uint32_t, uint32_t>::getNew(
"cluster",
"attach",
"extState",
"x",
"y",
"z",
"sector",
"row",
"nEv",
"clusterTree");
1857 cldump.Fill(cl, attach, extState,
x,
y,
z,
i,
j, mNEvents - 1);
1865 for (uint32_t
i = 0;
i < mTracking->mIOPtrs.nMergedTracks;
i++) {
1866 if (mTracking->mIOPtrs.mergedTracks[
i].OK()) {
1867 trkdump.Fill(mNEvents - 1, mTracking->mIOPtrs.mergedTracks[
i]);
1871 if (mTracking && mTracking->GetProcessingSettings().createO2Output) {
1873 for (uint32_t
i = 0;
i < mTracking->mIOPtrs.nOutputTracksTPCO2;
i++) {
1874 o2trkdump.Fill(mNEvents - 1, mTracking->mIOPtrs.outputTracksTPCO2[
i]);
1878 mTrackingScratchBuffer.clear();
1879 mTrackingScratchBuffer.shrink_to_fit();
1882void GPUQA::GetName(
char* fname, int32_t k)
1884 const int32_t nNewInput = mConfig.inputHistogramsOnly ? 0 : 1;
1885 if (k || mConfig.inputHistogramsOnly || mConfig.name.size()) {
1886 if (!(mConfig.inputHistogramsOnly || k)) {
1887 snprintf(fname, 1024,
"%s - ", mConfig.name.c_str());
1888 }
else if (mConfig.compareInputNames.size() > (
unsigned)(k - nNewInput)) {
1889 snprintf(fname, 1024,
"%s - ", mConfig.compareInputNames[k - nNewInput].c_str());
1891 strcpy(fname, mConfig.compareInputs[k - nNewInput].c_str());
1892 if (strlen(fname) > 5 && strcmp(fname + strlen(fname) - 5,
".root") == 0) {
1893 fname[strlen(fname) - 5] = 0;
1895 strcat(fname,
" - ");
1903T* GPUQA::GetHist(T*& ee, std::vector<std::unique_ptr<TFile>>& tin, int32_t k, int32_t nNewInput)
1906 if ((mConfig.inputHistogramsOnly || k) && (e =
dynamic_cast<T*
>(tin[k - nNewInput]->Get(e->GetName()))) ==
nullptr) {
1907 GPUWarning(
"Missing histogram in input %s: %s", mConfig.compareInputs[k - nNewInput].c_str(), ee->GetName());
1914void GPUQA::DrawQAHistogramsCleanup()
1916 clearGarbagageCollector();
1919void GPUQA::resetHists()
1921 if (!mQAInitialized) {
1922 throw std::runtime_error(
"QA not initialized");
1924 if (mHaveExternalHists) {
1925 throw std::runtime_error(
"Cannot reset external hists");
1927 for (
auto&
h : *mHist1D) {
1930 for (
auto&
h : *mHist2D) {
1933 for (
auto&
h : *mHist1Dd) {
1936 for (
auto&
h : *mHistGraph) {
1937 h = TGraphAsymmErrors();
1939 mClusterCounts = counts_t();
1944 const auto oldRootIgnoreLevel = gErrorIgnoreLevel;
1945 gErrorIgnoreLevel = kWarning;
1946 if (!mQAInitialized) {
1947 throw std::runtime_error(
"QA not initialized");
1950 if (mTracking && mTracking->GetProcessingSettings().debugLevel >= 2) {
1951 printf(
"Creating QA Histograms\n");
1954 std::vector<Color_t> colorNums(COLORCOUNT);
1956 static int32_t initColorsInitialized = initColors();
1957 (
void)initColorsInitialized;
1959 for (int32_t
i = 0;
i < COLORCOUNT;
i++) {
1960 colorNums[
i] = qcout ? defaultColorNums[
i] : mColors[
i]->GetNumber();
1963 bool mcAvail = mcPresent();
1964 char name[2048], fname[1024];
1966 const int32_t nNewInput = mConfig.inputHistogramsOnly ? 0 : 1;
1967 const int32_t ConfigNumInputs = nNewInput + mConfig.compareInputs.size();
1969 std::vector<std::unique_ptr<TFile>> tin;
1970 for (uint32_t
i = 0;
i < mConfig.compareInputs.size();
i++) {
1971 tin.emplace_back(std::make_unique<TFile>(mConfig.compareInputs[
i].c_str()));
1973 std::unique_ptr<TFile> tout =
nullptr;
1974 if (mConfig.output.size()) {
1975 tout = std::make_unique<TFile>(mConfig.output.c_str(),
"RECREATE");
1978 if (mConfig.enableLocalOutput || mConfig.shipToQCAsCanvas) {
1979 float legendSpacingString = 0.025;
1980 for (int32_t
i = 0;
i < ConfigNumInputs;
i++) {
1982 if (strlen(fname) * 0.006 > legendSpacingString) {
1983 legendSpacingString = strlen(fname) * 0.006;
1988 if (mQATasks & taskTrackingEff) {
1989 for (int32_t ii = 0; ii < 6; ii++) {
1990 int32_t
i = ii == 5 ? 4 : ii;
1991 snprintf(fname, 1024,
"eff_vs_%s_layout", VSPARAMETER_NAMES[ii]);
1992 snprintf(
name, 2048,
"Efficiency versus %s", VSPARAMETER_NAMES[
i]);
1993 mCEff[ii] = createGarbageCollected<TCanvas>(fname,
name, 0, 0, 700, 700. * 2. / 3.);
1996 mPEff[ii][0] = createGarbageCollected<TPad>(
"p0",
"", 0.0, dy * 0, 0.5, dy * 1);
1997 mPEff[ii][0]->Draw();
1998 mPEff[ii][0]->SetRightMargin(0.04);
1999 mPEff[ii][1] = createGarbageCollected<TPad>(
"p1",
"", 0.5, dy * 0, 1.0, dy * 1);
2000 mPEff[ii][1]->Draw();
2001 mPEff[ii][1]->SetRightMargin(0.04);
2002 mPEff[ii][2] = createGarbageCollected<TPad>(
"p2",
"", 0.0, dy * 1, 0.5, dy * 2 - .001);
2003 mPEff[ii][2]->Draw();
2004 mPEff[ii][2]->SetRightMargin(0.04);
2005 mPEff[ii][3] = createGarbageCollected<TPad>(
"p3",
"", 0.5, dy * 1, 1.0, dy * 2 - .001);
2006 mPEff[ii][3]->Draw();
2007 mPEff[ii][3]->SetRightMargin(0.04);
2008 mLEff[ii] = createGarbageCollected<TLegend>(0.92 - legendSpacingString * 1.45, 0.83 - (0.93 - 0.82) / 2. * (
float)ConfigNumInputs, 0.98, 0.849);
2009 SetLegend(mLEff[ii]);
2014 if (mQATasks & taskTrackingRes) {
2015 for (int32_t ii = 0; ii < 7; ii++) {
2016 int32_t
i = ii == 5 ? 4 : ii;
2018 snprintf(fname, 1024,
"res_integral_layout");
2019 snprintf(
name, 2048,
"Integral Resolution");
2021 snprintf(fname, 1024,
"res_vs_%s_layout", VSPARAMETER_NAMES[ii]);
2022 snprintf(
name, 2048,
"Resolution versus %s", VSPARAMETER_NAMES[
i]);
2024 mCRes[ii] = createGarbageCollected<TCanvas>(fname,
name, 0, 0, 700, 700. * 2. / 3.);
2026 gStyle->SetOptFit(1);
2029 mPRes[ii][3] = createGarbageCollected<TPad>(
"p0",
"", 0.0, dy * 0, 0.5, dy * 1);
2030 mPRes[ii][3]->Draw();
2031 mPRes[ii][3]->SetRightMargin(0.04);
2032 mPRes[ii][4] = createGarbageCollected<TPad>(
"p1",
"", 0.5, dy * 0, 1.0, dy * 1);
2033 mPRes[ii][4]->Draw();
2034 mPRes[ii][4]->SetRightMargin(0.04);
2035 mPRes[ii][0] = createGarbageCollected<TPad>(
"p2",
"", 0.0, dy * 1, 1. / 3., dy * 2 - .001);
2036 mPRes[ii][0]->Draw();
2037 mPRes[ii][0]->SetRightMargin(0.04);
2038 mPRes[ii][0]->SetLeftMargin(0.15);
2039 mPRes[ii][1] = createGarbageCollected<TPad>(
"p3",
"", 1. / 3., dy * 1, 2. / 3., dy * 2 - .001);
2040 mPRes[ii][1]->Draw();
2041 mPRes[ii][1]->SetRightMargin(0.04);
2042 mPRes[ii][1]->SetLeftMargin(0.135);
2043 mPRes[ii][2] = createGarbageCollected<TPad>(
"p4",
"", 2. / 3., dy * 1, 1.0, dy * 2 - .001);
2044 mPRes[ii][2]->Draw();
2045 mPRes[ii][2]->SetRightMargin(0.06);
2046 mPRes[ii][2]->SetLeftMargin(0.135);
2048 mLRes[ii] = createGarbageCollected<TLegend>(0.9 - legendSpacingString * 1.45, 0.93 - (0.93 - 0.86) / 2. * (
float)ConfigNumInputs, 0.98, 0.949);
2049 SetLegend(mLRes[ii]);
2055 if (mQATasks & taskTrackingResPull) {
2056 for (int32_t ii = 0; ii < 7; ii++) {
2057 int32_t
i = ii == 5 ? 4 : ii;
2060 snprintf(fname, 1024,
"pull_integral_layout");
2061 snprintf(
name, 2048,
"Integral Pull");
2063 snprintf(fname, 1024,
"pull_vs_%s_layout", VSPARAMETER_NAMES[ii]);
2064 snprintf(
name, 2048,
"Pull versus %s", VSPARAMETER_NAMES[
i]);
2066 mCPull[ii] = createGarbageCollected<TCanvas>(fname,
name, 0, 0, 700, 700. * 2. / 3.);
2068 gStyle->SetOptFit(1);
2071 mPPull[ii][3] = createGarbageCollected<TPad>(
"p0",
"", 0.0, dy * 0, 0.5, dy * 1);
2072 mPPull[ii][3]->Draw();
2073 mPPull[ii][3]->SetRightMargin(0.04);
2074 mPPull[ii][4] = createGarbageCollected<TPad>(
"p1",
"", 0.5, dy * 0, 1.0, dy * 1);
2075 mPPull[ii][4]->Draw();
2076 mPPull[ii][4]->SetRightMargin(0.04);
2077 mPPull[ii][0] = createGarbageCollected<TPad>(
"p2",
"", 0.0, dy * 1, 1. / 3., dy * 2 - .001);
2078 mPPull[ii][0]->Draw();
2079 mPPull[ii][0]->SetRightMargin(0.04);
2080 mPPull[ii][0]->SetLeftMargin(0.15);
2081 mPPull[ii][1] = createGarbageCollected<TPad>(
"p3",
"", 1. / 3., dy * 1, 2. / 3., dy * 2 - .001);
2082 mPPull[ii][1]->Draw();
2083 mPPull[ii][1]->SetRightMargin(0.04);
2084 mPPull[ii][1]->SetLeftMargin(0.135);
2085 mPPull[ii][2] = createGarbageCollected<TPad>(
"p4",
"", 2. / 3., dy * 1, 1.0, dy * 2 - .001);
2086 mPPull[ii][2]->Draw();
2087 mPPull[ii][2]->SetRightMargin(0.06);
2088 mPPull[ii][2]->SetLeftMargin(0.135);
2090 mLPull[ii] = createGarbageCollected<TLegend>(0.9 - legendSpacingString * 1.45, 0.93 - (0.93 - 0.86) / 2. * (
float)ConfigNumInputs, 0.98, 0.949);
2091 SetLegend(mLPull[ii]);
2097 if (mQATasks & taskClusterAttach) {
2098 for (int32_t
i = 0;
i < 3;
i++) {
2099 snprintf(fname, 1024,
"clusters_%s_layout", CLUSTER_TYPES[
i]);
2100 mCClust[
i] = createGarbageCollected<TCanvas>(fname, CLUSTER_TITLES[
i], 0, 0, 700, 700. * 2. / 3.);
2102 mPClust[
i] = createGarbageCollected<TPad>(
"p0",
"", 0.0, 0.0, 1.0, 1.0);
2104 float y1 =
i != 1 ? 0.77 : 0.27,
y2 =
i != 1 ? 0.9 : 0.42;
2105 mLClust[
i] = createGarbageCollected<TLegend>(
i == 2 ? 0.1 : (0.65 - legendSpacingString * 1.45),
y2 - (
y2 -
y1) * (ConfigNumInputs + (
i != 1) / 2.) + 0.005,
i == 2 ? (0.3 + legendSpacingString * 1.45) : 0.9,
y2);
2106 SetLegend(mLClust[
i]);
2111 if (mQATasks & taskTrackStatistics) {
2112 mCTracks = createGarbageCollected<TCanvas>(
"ctracks",
"Track Pt", 0, 0, 700, 700. * 2. / 3.);
2114 mPTracks = createGarbageCollected<TPad>(
"p0",
"", 0.0, 0.0, 1.0, 1.0);
2116 mLTracks = createGarbageCollected<TLegend>(0.9 - legendSpacingString * 1.45, 0.93 - (0.93 - 0.86) / 2. * (
float)ConfigNumInputs, 0.98, 0.949);
2117 SetLegend(mLTracks);
2119 for (int32_t
i = 0;
i < 2;
i++) {
2120 snprintf(
name, 2048,
"cncl%d Pull",
i);
2121 mCNCl[
i] = createGarbageCollected<TCanvas>(
name,
i ?
"Number of clusters (corrected for multiple per row)" :
"Number of clusters per track", 0, 0, 700, 700. * 2. / 3.);
2123 mPNCl[
i] = createGarbageCollected<TPad>(
"p0",
"", 0.0, 0.0, 1.0, 1.0);
2125 mLNCl[
i] = createGarbageCollected<TLegend>(0.9 - legendSpacingString * 1.45, 0.93 - (0.93 - 0.86) / 2. * (
float)ConfigNumInputs, 0.98, 0.949);
2126 SetLegend(mLNCl[
i]);
2129 mCClXY = createGarbageCollected<TCanvas>(
"clxy",
"Number of clusters per X / Y", 0, 0, 700, 700. * 2. / 3.);
2131 mPClXY = createGarbageCollected<TPad>(
"p0",
"", 0.0, 0.0, 1.0, 1.0);
2136 if (mConfig.enableLocalOutput && !mConfig.inputHistogramsOnly && (mQATasks & taskTrackingEff) && mcPresent()) {
2137 GPUInfo(
"QA Stats: Eff: Tracks Prim %d (Eta %d, Pt %d) %f%% (%f%%) Sec %d (Eta %d, Pt %d) %f%% (%f%%) - Res: Tracks %d (Eta %d, Pt %d)", (int32_t)mEff[3][1][0][0]->GetEntries(), (int32_t)mEff[3][1][0][3]->GetEntries(), (int32_t)mEff[3][1][0][4]->GetEntries(),
2138 mEff[0][0][0][0]->GetSumOfWeights() / std::max(1., mEff[3][0][0][0]->GetSumOfWeights()), mEff[0][1][0][0]->GetSumOfWeights() / std::max(1., mEff[3][1][0][0]->GetSumOfWeights()), (int32_t)mEff[3][1][1][0]->GetEntries(), (int32_t)mEff[3][1][1][3]->GetEntries(),
2139 (int32_t)mEff[3][1][1][4]->GetEntries(), mEff[0][0][1][0]->GetSumOfWeights() / std::max(1., mEff[3][0][1][0]->GetSumOfWeights()), mEff[0][1][1][0]->GetSumOfWeights() / std::max(1., mEff[3][1][1][0]->GetSumOfWeights()), (int32_t)mRes2[0][0]->GetEntries(),
2140 (int32_t)mRes2[0][3]->GetEntries(), (int32_t)mRes2[0][4]->GetEntries());
2143 int32_t flagShowVsPtLog = (mConfig.enableLocalOutput || mConfig.shipToQCAsCanvas) ? 1 : 0;
2145 if (mQATasks & taskTrackingEff) {
2147 for (int32_t ii = 0; ii < 5 + flagShowVsPtLog; ii++) {
2148 int32_t
i = ii == 5 ? 4 : ii;
2149 for (int32_t k = 0; k < ConfigNumInputs; k++) {
2150 for (int32_t
j = 0;
j < 4;
j++) {
2151 if (mConfig.enableLocalOutput || mConfig.shipToQCAsCanvas) {
2154 mPEff[ii][
j]->SetLogx();
2157 for (int32_t l = 0; l < 3; l++) {
2158 if (k == 0 && mConfig.inputHistogramsOnly == 0 && ii != 5) {
2161 auto oldLevel = gErrorIgnoreLevel;
2162 gErrorIgnoreLevel = kError;
2163 mEffResult[0][
j / 2][
j % 2][
i]->Divide(mEff[l][
j / 2][
j % 2][
i], mEff[3][
j / 2][
j % 2][
i],
"cl=0.683 b(1,1) mode");
2164 gErrorIgnoreLevel = oldLevel;
2165 mEff[3][
j / 2][
j % 2][
i]->Reset();
2166 mEff[3][
j / 2][
j % 2][
i]->Add(mEff[0][
j / 2][
j % 2][
i]);
2167 mEff[3][
j / 2][
j % 2][
i]->Add(mEff[1][
j / 2][
j % 2][
i]);
2168 mEff[3][
j / 2][
j % 2][
i]->Add(mEff[2][
j / 2][
j % 2][
i]);
2169 mEff[4][
j / 2][
j % 2][
i]->Reset();
2170 mEff[4][
j / 2][
j % 2][
i]->Add(mEff[0][
j / 2][
j % 2][
i]);
2171 mEff[4][
j / 2][
j % 2][
i]->Add(mEff[1][
j / 2][
j % 2][
i]);
2174 auto oldLevel = gErrorIgnoreLevel;
2175 gErrorIgnoreLevel = kError;
2176 mEffResult[l][
j / 2][
j % 2][
i]->Divide(mEff[l][
j / 2][
j % 2][
i], mEff[l == 1 ? 4 : 3][
j / 2][
j % 2][
i],
"cl=0.683 b(1,1) mode");
2177 gErrorIgnoreLevel = oldLevel;
2181 TGraphAsymmErrors* e = mEffResult[l][
j / 2][
j % 2][
i];
2183 if (!mConfig.inputHistogramsOnly && k == 0) {
2185 mEff[l][
j / 2][
j % 2][
i]->Write();
2188 mEff[3][
j / 2][
j % 2][
i]->Write();
2189 mEff[4][
j / 2][
j % 2][
i]->Write();
2192 }
else if (GetHist(e, tin, k, nNewInput) ==
nullptr) {
2195 e->SetTitle(EFFICIENCY_TITLES[
j]);
2196 e->GetYaxis()->SetTitle(
"(Efficiency)");
2197 e->GetXaxis()->SetTitle(XAXIS_TITLES[
i]);
2200 e->SetLineStyle(CONFIG_DASHED_MARKERS ? k + 1 : 1);
2202 if (qcout && !mConfig.shipToQCAsCanvas) {
2205 if (!mConfig.enableLocalOutput && !mConfig.shipToQCAsCanvas) {
2208 e->SetMarkerColor(kBlack);
2209 e->SetLineColor(colorNums[(l == 2 ? (ConfigNumInputs * 2 + k) : (k * 2 + l)) % COLORCOUNT]);
2210 e->GetHistogram()->GetYaxis()->SetRangeUser(-0.02, 1.02);
2211 e->Draw(k || l ?
"same P" :
"AP");
2214 snprintf(
name, 2048,
"%s%s", fname, EFF_NAMES[l]);
2215 mLEff[ii]->AddEntry(e,
name,
"l");
2218 if (!mConfig.enableLocalOutput && !mConfig.shipToQCAsCanvas) {
2222 ChangePadTitleSize(mPEff[ii][
j], 0.056);
2225 if (!mConfig.enableLocalOutput && !mConfig.shipToQCAsCanvas) {
2232 qcout->Add(mCEff[ii]);
2234 if (!mConfig.enableLocalOutput) {
2237 doPerfFigure(0.2, 0.295, 0.025);
2238 mCEff[ii]->Print(Form(
"plots/eff_vs_%s.pdf", VSPARAMETER_NAMES[ii]));
2239 if (mConfig.writeRootFiles) {
2240 mCEff[ii]->Print(Form(
"plots/eff_vs_%s.root", VSPARAMETER_NAMES[ii]));
2245 if (mQATasks & (taskTrackingRes | taskTrackingResPull)) {
2247 TH1D *resIntegral[5] = {}, *pullIntegral[5] = {};
2248 TCanvas* cfit =
nullptr;
2249 std::unique_ptr<TF1> customGaus = std::make_unique<TF1>(
"G",
"[0]*exp(-(x-[1])*(x-[1])/(2.*[2]*[2]))");
2250 for (int32_t p = 0;
p < 2;
p++) {
2251 if ((p == 0 && (mQATasks & taskTrackingRes) == 0) || (p == 1 && (mQATasks & taskTrackingResPull) == 0)) {
2254 for (int32_t ii = 0; ii < 5 + flagShowVsPtLog; ii++) {
2255 TCanvas* can =
p ? mCPull[ii] : mCRes[ii];
2256 TLegend*
leg =
p ? mLPull[ii] : mLRes[ii];
2257 int32_t
i = ii == 5 ? 4 : ii;
2258 for (int32_t
j = 0;
j < 5;
j++) {
2259 TH2F*
src =
p ? mPull2[
j][
i] : mRes2[
j][
i];
2260 TH1F**
dst =
p ? mPull[
j][
i] : mRes[
j][
i];
2261 TH1D*& dstIntegral =
p ? pullIntegral[
j] : resIntegral[
j];
2262 TPad* pad =
p ? mPPull[ii][
j] : mPRes[ii][
j];
2264 if (!mConfig.inputHistogramsOnly && ii != 5) {
2265 if (cfit ==
nullptr) {
2266 cfit = createGarbageCollected<TCanvas>();
2270 TAxis* axis =
src->GetYaxis();
2271 int32_t nBins = axis->GetNbins();
2273 for (int32_t bin = 1; bin <= nBins; bin++) {
2274 int32_t bin0 = std::max(bin - integ, 0);
2275 int32_t bin1 = std::min(bin + integ, nBins);
2276 std::unique_ptr<TH1D> proj{
src->ProjectionX(
"proj", bin0, bin1)};
2277 proj->ClearUnderflowAndOverflow();
2278 if (proj->GetEntries()) {
2280 while (proj->GetMaximum() < 50 && rebin <
sizeof(RES_AXIS_BINS) /
sizeof(RES_AXIS_BINS[0])) {
2281 proj->Rebin(RES_AXIS_BINS[rebin - 1] / RES_AXIS_BINS[rebin]);
2285 if (proj->GetEntries() < 20 || proj->GetRMS() < 0.00001) {
2286 dst[0]->SetBinContent(bin, proj->GetRMS());
2287 dst[0]->SetBinError(bin, std::sqrt(proj->GetRMS()));
2288 dst[1]->SetBinContent(bin, proj->GetMean());
2289 dst[1]->SetBinError(bin, std::sqrt(proj->GetRMS()));
2291 proj->GetXaxis()->SetRange(0, 0);
2292 proj->GetXaxis()->SetRangeUser(std::max(proj->GetXaxis()->GetXmin(), proj->GetMean() - 3. * proj->GetRMS()), std::min(proj->GetXaxis()->GetXmax(), proj->GetMean() + 3. * proj->GetRMS()));
2293 bool forceLogLike = proj->GetMaximum() < 20;
2294 for (int32_t k = forceLogLike ? 2 : 0; k < 3; k++) {
2295 proj->Fit(
"gaus", forceLogLike || k == 2 ?
"sQl" : k ?
"sQww" :
"sQ");
2296 TF1* fitFunc = proj->GetFunction(
"gaus");
2298 if (k && !forceLogLike) {
2299 customGaus->SetParameters(fitFunc->GetParameter(0), fitFunc->GetParameter(1), fitFunc->GetParameter(2));
2300 proj->Fit(customGaus.get(),
"sQ");
2301 fitFunc = customGaus.get();
2304 const float sigma = fabs(fitFunc->GetParameter(2));
2305 dst[0]->SetBinContent(bin, sigma);
2306 dst[1]->SetBinContent(bin, fitFunc->GetParameter(1));
2307 dst[0]->SetBinError(bin, fitFunc->GetParError(2));
2308 dst[1]->SetBinError(bin, fitFunc->GetParError(1));
2310 const bool fail1 = sigma <= 0.f;
2311 const bool fail2 = fabs(proj->GetMean() -
dst[1]->GetBinContent(bin)) > std::min<float>(p ? PULL_AXIS : mConfig.nativeFitResolutions ? RES_AXES_NATIVE[
j] : RES_AXES[
j], 3.f * proj->GetRMS());
2312 const bool fail3 =
dst[0]->GetBinContent(bin) > 3.f * proj->GetRMS() ||
dst[0]->GetBinError(bin) > 1 ||
dst[1]->GetBinError(bin) > 1;
2313 const bool fail4 = fitFunc->GetParameter(0) < proj->GetMaximum() / 5.;
2314 const bool fail = fail1 || fail2 || fail3 || fail4;
2319 }
else if (k >= 2) {
2320 dst[0]->SetBinContent(bin, proj->GetRMS());
2321 dst[0]->SetBinError(bin, std::sqrt(proj->GetRMS()));
2322 dst[1]->SetBinContent(bin, proj->GetMean());
2323 dst[1]->SetBinError(bin, std::sqrt(proj->GetRMS()));
2328 dst[0]->SetBinContent(bin, 0.f);
2329 dst[0]->SetBinError(bin, 0.f);
2330 dst[1]->SetBinContent(bin, 0.f);
2331 dst[1]->SetBinError(bin, 0.f);
2335 dstIntegral =
src->ProjectionX(mConfig.nativeFitResolutions ? PARAMETER_NAMES_NATIVE[
j] : PARAMETER_NAMES[
j], 0, nBins + 1);
2337 while (dstIntegral->GetMaximum() < 50 && rebin <
sizeof(RES_AXIS_BINS) /
sizeof(RES_AXIS_BINS[0])) {
2338 dstIntegral->Rebin(RES_AXIS_BINS[rebin - 1] / RES_AXIS_BINS[rebin]);
2344 if (mConfig.inputHistogramsOnly) {
2345 dstIntegral = createGarbageCollected<TH1D>();
2347 snprintf(fname, 1024, p ?
"IntPull%s" :
"IntRes%s", VSPARAMETER_NAMES[
j]);
2348 snprintf(
name, 2048, p ?
"%s Pull" :
"%s Resolution",
p || mConfig.nativeFitResolutions ? PARAMETER_NAMES_NATIVE[
j] : PARAMETER_NAMES[
j]);
2349 dstIntegral->SetName(fname);
2350 dstIntegral->SetTitle(
name);
2352 if (mConfig.enableLocalOutput || mConfig.shipToQCAsCanvas) {
2355 int32_t numColor = 0;
2356 float tmpMax = -1000.;
2357 float tmpMin = 1000.;
2359 for (int32_t l = 0; l < 2; l++) {
2360 for (int32_t k = 0; k < ConfigNumInputs; k++) {
2362 if (GetHist(e, tin, k, nNewInput) ==
nullptr) {
2365 if (nNewInput && k == 0 && ii != 5) {
2367 e->Scale(mConfig.nativeFitResolutions ? SCALE_NATIVE[
j] : SCALE[
j]);
2371 e->GetXaxis()->SetRangeUser(0.2, PT_MAX);
2372 }
else if (LOG_PT_MIN > 0 && ii == 5) {
2373 e->GetXaxis()->SetRangeUser(LOG_PT_MIN, PT_MAX);
2374 }
else if (ii == 5) {
2375 e->GetXaxis()->SetRange(1, 0);
2377 e->SetMinimum(-1111);
2378 e->SetMaximum(-1111);
2380 if (e->GetMaximum() > tmpMax) {
2381 tmpMax = e->GetMaximum();
2383 if (e->GetMinimum() < tmpMin) {
2384 tmpMin = e->GetMinimum();
2390 tmpSpan = tmpMax - tmpMin;
2391 tmpMax += tmpSpan * .02;
2392 tmpMin -= tmpSpan * .02;
2393 if (
j == 2 &&
i < 3) {
2394 tmpMax += tmpSpan * 0.13 * ConfigNumInputs;
2397 for (int32_t k = 0; k < ConfigNumInputs; k++) {
2398 for (int32_t l = 0; l < 2; l++) {
2400 if (!mConfig.inputHistogramsOnly && k == 0) {
2401 snprintf(
name, 2048, p ?
"%s Pull" :
"%s Resolution",
p || mConfig.nativeFitResolutions ? PARAMETER_NAMES_NATIVE[
j] : PARAMETER_NAMES[
j]);
2403 e->SetStats(kFALSE);
2406 mRes2[
j][
i]->SetOption(
"colz");
2407 mRes2[
j][
i]->Write();
2411 }
else if (GetHist(e, tin, k, nNewInput) ==
nullptr) {
2414 e->SetMaximum(tmpMax);
2415 e->SetMinimum(tmpMin);
2417 e->SetLineStyle(CONFIG_DASHED_MARKERS ? k + 1 : 1);
2419 e->GetYaxis()->SetTitle(p ? AXIS_TITLES_PULL[
j] : mConfig.nativeFitResolutions ? AXIS_TITLES_NATIVE[
j] : AXIS_TITLES[
j]);
2420 e->GetXaxis()->SetTitle(XAXIS_TITLES[
i]);
2421 if (LOG_PT_MIN > 0 && ii == 5) {
2422 e->GetXaxis()->SetRangeUser(LOG_PT_MIN, PT_MAX);
2426 e->GetYaxis()->SetTitleOffset(1.5);
2428 e->GetYaxis()->SetTitleOffset(1.4);
2430 if (qcout && !mConfig.shipToQCAsCanvas) {
2433 if (!mConfig.enableLocalOutput && !mConfig.shipToQCAsCanvas) {
2437 e->SetMarkerColor(kBlack);
2438 e->SetLineColor(colorNums[numColor++ % COLORCOUNT]);
2439 e->Draw(k || l ?
"same" :
"");
2443 snprintf(
name, 2048,
"%s%s", fname, l ?
"Mean" :
"Pull");
2445 snprintf(
name, 2048,
"%s%s", fname, l ?
"Mean" :
"Resolution");
2451 if (!mConfig.enableLocalOutput && !mConfig.shipToQCAsCanvas) {
2460 ChangePadTitleSize(pad, 0.056);
2463 if (!mConfig.enableLocalOutput && !mConfig.shipToQCAsCanvas) {
2472 if (!mConfig.enableLocalOutput) {
2475 doPerfFigure(0.2, 0.295, 0.025);
2476 can->Print(Form(p ?
"plots/pull_vs_%s.pdf" :
"plots/res_vs_%s.pdf", VSPARAMETER_NAMES[ii]));
2477 if (mConfig.writeRootFiles) {
2478 can->Print(Form(p ?
"plots/pull_vs_%s.root" :
"plots/res_vs_%s.root", VSPARAMETER_NAMES[ii]));
2484 for (int32_t p = 0;
p < 2;
p++) {
2485 if ((p == 0 && (mQATasks & taskTrackingRes) == 0) || (p == 1 && (mQATasks & taskTrackingResPull) == 0)) {
2488 TCanvas* can =
p ? mCPull[6] : mCRes[6];
2489 for (int32_t
i = 0;
i < 5;
i++) {
2490 TPad* pad =
p ? mPPull[6][
i] : mPRes[6][
i];
2491 TH1D* hist =
p ? pullIntegral[
i] : resIntegral[
i];
2492 int32_t numColor = 0;
2493 if (mConfig.enableLocalOutput || mConfig.shipToQCAsCanvas) {
2496 if (!mConfig.inputHistogramsOnly && mcAvail) {
2498 if (e && e->GetEntries()) {
2499 e->Fit(
"gaus",
"sQ");
2504 for (int32_t k = 0; k < ConfigNumInputs; k++) {
2506 if (GetHist(e, tin, k, nNewInput) ==
nullptr) {
2509 e->SetMaximum(-1111);
2510 if (e->GetMaximum() > tmpMax) {
2511 tmpMax = e->GetMaximum();
2515 for (int32_t k = 0; k < ConfigNumInputs; k++) {
2517 if (GetHist(e, tin, k, nNewInput) ==
nullptr) {
2520 e->SetMaximum(tmpMax * 1.02);
2521 e->SetMinimum(tmpMax * -0.02);
2522 if (tout && !mConfig.inputHistogramsOnly && k == 0) {
2525 if (qcout && !mConfig.shipToQCAsCanvas) {
2528 if (!mConfig.enableLocalOutput && !mConfig.shipToQCAsCanvas) {
2532 e->SetLineColor(colorNums[numColor++ % COLORCOUNT]);
2533 e->Draw(k == 0 ?
"" :
"same");
2535 if (!mConfig.enableLocalOutput && !mConfig.shipToQCAsCanvas) {
2543 if (!mConfig.enableLocalOutput) {
2547 can->Print(p ?
"plots/pull_integral.pdf" :
"plots/res_integral.pdf");
2548 if (mConfig.writeRootFiles) {
2549 can->Print(p ?
"plots/pull_integral.root" :
"plots/res_integral.root");
2554 uint64_t attachClusterCounts[N_CLS_HIST];
2555 if (mQATasks & taskClusterAttach) {
2557 if (mConfig.inputHistogramsOnly == 0) {
2558 for (int32_t
i = N_CLS_HIST;
i < N_CLS_TYPE * N_CLS_HIST - 1;
i++) {
2559 mClusters[
i]->Sumw2(
true);
2561 double totalVal = 0;
2562 if (!CLUST_HIST_INT_SUM) {
2563 for (int32_t
j = 0;
j < mClusters[N_CLS_HIST - 1]->GetXaxis()->GetNbins() + 2;
j++) {
2564 totalVal += mClusters[N_CLS_HIST - 1]->GetBinContent(
j);
2567 if (totalVal == 0.) {
2570 for (int32_t
i = 0;
i < N_CLS_HIST;
i++) {
2572 for (int32_t
j = 0;
j < mClusters[
i]->GetXaxis()->GetNbins() + 2;
j++) {
2573 val += mClusters[
i]->GetBinContent(
j);
2574 mClusters[2 * N_CLS_HIST - 1 +
i]->SetBinContent(
j,
val / totalVal);
2576 attachClusterCounts[
i] =
val;
2579 if (!CLUST_HIST_INT_SUM) {
2580 for (int32_t
i = 0;
i < N_CLS_HIST;
i++) {
2581 mClusters[2 * N_CLS_HIST - 1 +
i]->SetMaximum(1.02);
2582 mClusters[2 * N_CLS_HIST - 1 +
i]->SetMinimum(-0.02);
2586 for (int32_t
i = 0;
i < N_CLS_HIST - 1;
i++) {
2587 auto oldLevel = gErrorIgnoreLevel;
2588 gErrorIgnoreLevel = kError;
2589 mClusters[N_CLS_HIST +
i]->Divide(mClusters[
i], mClusters[N_CLS_HIST - 1], 1, 1,
"B");
2590 gErrorIgnoreLevel = oldLevel;
2591 mClusters[N_CLS_HIST +
i]->SetMinimum(-0.02);
2592 mClusters[N_CLS_HIST +
i]->SetMaximum(1.02);
2596 float tmpMax[2] = {0, 0}, tmpMin[2] = {0, 0};
2597 for (int32_t l = 0; l <= CLUST_HIST_INT_SUM; l++) {
2598 for (int32_t k = 0; k < ConfigNumInputs; k++) {
2599 TH1* e = mClusters[l ? (N_CLS_TYPE * N_CLS_HIST - 2) : (N_CLS_HIST - 1)];
2600 if (GetHist(e, tin, k, nNewInput) ==
nullptr) {
2603 e->SetMinimum(-1111);
2604 e->SetMaximum(-1111);
2606 e->GetXaxis()->SetRange(2, AXIS_BINS[4]);
2608 if (e->GetMaximum() > tmpMax[l]) {
2609 tmpMax[l] = e->GetMaximum();
2611 if (e->GetMinimum() < tmpMin[l]) {
2612 tmpMin[l] = e->GetMinimum();
2615 for (int32_t k = 0; k < ConfigNumInputs; k++) {
2616 for (int32_t
i = 0;
i < N_CLS_HIST;
i++) {
2617 TH1* e = mClusters[l ? (2 * N_CLS_HIST - 1 +
i) :
i];
2618 if (GetHist(e, tin, k, nNewInput) ==
nullptr) {
2621 e->SetMaximum(tmpMax[l] * 1.02);
2622 e->SetMinimum(tmpMax[l] * -0.02);
2627 for (int32_t
i = 0;
i < N_CLS_TYPE;
i++) {
2628 if (mConfig.enableLocalOutput || mConfig.shipToQCAsCanvas) {
2630 mPClust[
i]->SetLogx();
2632 int32_t
begin =
i == 2 ? (2 * N_CLS_HIST - 1) :
i == 1 ? N_CLS_HIST : 0;
2633 int32_t
end =
i == 2 ? (3 * N_CLS_HIST - 1) :
i == 1 ? (2 * N_CLS_HIST - 1) : N_CLS_HIST;
2634 int32_t numColor = 0;
2635 for (int32_t k = 0; k < ConfigNumInputs; k++) {
2637 TH1* e = mClusters[
j];
2638 if (GetHist(e, tin, k, nNewInput) ==
nullptr) {
2642 e->SetTitle(CLUSTER_TITLES[
i]);
2643 e->GetYaxis()->SetTitle(
i == 0 ?
"Number of TPC clusters" :
i == 1 ?
"Fraction of TPC clusters" : CLUST_HIST_INT_SUM ?
"Total TPC clusters (integrated)" :
"Fraction of TPC clusters (integrated)");
2644 e->GetXaxis()->SetTitle(
"#it{p}_{Tmc} (GeV/#it{c})");
2645 e->GetXaxis()->SetTitleOffset(1.1);
2646 e->GetXaxis()->SetLabelOffset(-0.005);
2647 if (tout && !mConfig.inputHistogramsOnly && k == 0) {
2650 e->SetStats(kFALSE);
2652 e->SetLineStyle(CONFIG_DASHED_MARKERS ?
j + 1 : 1);
2654 e->GetXaxis()->SetRange(2, AXIS_BINS[4]);
2656 if (qcout && !mConfig.shipToQCAsCanvas) {
2659 if (!mConfig.enableLocalOutput && !mConfig.shipToQCAsCanvas) {
2663 e->SetMarkerColor(kBlack);
2664 e->SetLineColor(colorNums[numColor++ % COLORCOUNT]);
2665 e->Draw(
j ==
end - 1 && k == 0 ?
"" :
"same");
2667 snprintf(
name, 2048,
"%s%s", fname, CLUSTER_NAMES[
j - begin]);
2668 mLClust[
i]->AddEntry(e,
name,
"l");
2671 if (ConfigNumInputs == 1) {
2672 TH1* e =
reinterpret_cast<TH1F*
>(mClusters[
begin + CL_att_adj]->Clone());
2673 e->Add(mClusters[begin + CL_prot], -1);
2674 if (qcout && !mConfig.shipToQCAsCanvas) {
2677 if (!mConfig.enableLocalOutput && !mConfig.shipToQCAsCanvas) {
2681 e->SetLineColor(colorNums[numColor++ % COLORCOUNT]);
2683 mLClust[
i]->AddEntry(e,
"Removed (Strategy A)",
"l");
2685 if (!mConfig.enableLocalOutput && !mConfig.shipToQCAsCanvas) {
2692 qcout->Add(mCClust[
i]);
2694 if (!mConfig.enableLocalOutput) {
2697 doPerfFigure(
i != 2 ? 0.37 : 0.6, 0.295, 0.030);
2699 mCClust[
i]->Print(
i == 2 ?
"plots/clusters_integral.pdf" :
i == 1 ?
"plots/clusters_relative.pdf" :
"plots/clusters.pdf");
2700 if (mConfig.writeRootFiles) {
2701 mCClust[
i]->Print(
i == 2 ?
"plots/clusters_integral.root" :
i == 1 ?
"plots/clusters_relative.root" :
"plots/clusters.root");
2707 if ((mQATasks & taskClusterCounts) && !mHaveExternalHists && !mConfig.clusterRejectionHistograms && !mConfig.inputHistogramsOnly) {
2708 DoClusterCounts(attachClusterCounts);
2710 if ((qcout || tout) && (mQATasks & taskClusterCounts) && mConfig.clusterRejectionHistograms) {
2711 for (uint32_t
i = 0;
i < mHistClusterCount.size();
i++) {
2713 mHistClusterCount[
i]->Write();
2716 qcout->Add(mHistClusterCount[
i]);
2721 if (mQATasks & taskTrackStatistics) {
2724 for (int32_t k = 0; k < ConfigNumInputs; k++) {
2726 if (GetHist(e, tin, k, nNewInput) ==
nullptr) {
2729 e->SetMaximum(-1111);
2730 if (e->GetMaximum() > tmpMax) {
2731 tmpMax = e->GetMaximum();
2735 mPTracks->SetLogx();
2736 for (int32_t k = 0; k < ConfigNumInputs; k++) {
2738 if (GetHist(e, tin, k, nNewInput) ==
nullptr) {
2741 if (tout && !mConfig.inputHistogramsOnly && k == 0) {
2744 e->SetMaximum(tmpMax * 1.02);
2745 e->SetMinimum(tmpMax * -0.02);
2746 e->SetStats(kFALSE);
2748 e->GetYaxis()->SetTitle(
"a.u.");
2749 e->GetXaxis()->SetTitle(
"#it{p}_{Tmc} (GeV/#it{c})");
2753 e->SetMarkerColor(kBlack);
2754 e->SetLineColor(colorNums[k % COLORCOUNT]);
2755 e->Draw(k == 0 ?
"" :
"same");
2757 snprintf(
name, 2048,
"%sTrack Pt", fname);
2758 mLTracks->AddEntry(e,
name,
"l");
2762 mCTracks->Print(
"plots/tracks.pdf");
2763 if (mConfig.writeRootFiles) {
2764 mCTracks->Print(
"plots/tracks.root");
2767 for (int32_t
i = 0;
i < 2;
i++) {
2769 for (int32_t k = 0; k < ConfigNumInputs; k++) {
2771 if (GetHist(e, tin, k, nNewInput) ==
nullptr) {
2774 e->SetMaximum(-1111);
2775 if (e->GetMaximum() > tmpMax) {
2776 tmpMax = e->GetMaximum();
2780 for (int32_t k = 0; k < ConfigNumInputs; k++) {
2782 if (GetHist(e, tin, k, nNewInput) ==
nullptr) {
2785 if (tout && !mConfig.inputHistogramsOnly && k == 0) {
2788 e->SetMaximum(tmpMax * 1.02);
2789 e->SetMinimum(tmpMax * -0.02);
2790 e->SetStats(kFALSE);
2792 e->GetYaxis()->SetTitle(
"a.u.");
2793 e->GetXaxis()->SetTitle(
"NClusters");
2797 e->SetMarkerColor(kBlack);
2798 e->SetLineColor(colorNums[k % COLORCOUNT]);
2799 e->Draw(k == 0 ?
"" :
"same");
2801 snprintf(
name, 2048,
"%sNClusters%d", fname,
i);
2802 mLNCl[
i]->AddEntry(e,
name,
"l");
2806 snprintf(
name, 2048,
"plots/nClusters%s.pdf",
i ?
"_corrected" :
"");
2807 mCNCl[
i]->Print(
name);
2808 if (mConfig.writeRootFiles) {
2809 snprintf(
name, 2048,
"plots/nClusters%s.root",
i ?
"_corrected" :
"");
2810 mCNCl[
i]->Print(
name);
2815 mClXY->SetOption(
"colz");
2818 mCClXY->Print(
"plots/clustersXY.pdf");
2819 if (mConfig.writeRootFiles) {
2820 mCClXY->Print(
"plots/clustersXY.root");
2824 if (tout && !mConfig.inputHistogramsOnly && mConfig.writeMCLabels) {
2825 gInterpreter->GenerateDictionary(
"vector<vector<int32_t>>",
"");
2826 tout->WriteObject(&mcEffBuffer,
"mcEffBuffer");
2827 tout->WriteObject(&mcLabelBuffer,
"mcLabelBuffer");
2828 remove(
"AutoDict_vector_vector_int__.cxx");
2829 remove(
"AutoDict_vector_vector_int___cxx_ACLiC_dict_rdict.pcm");
2830 remove(
"AutoDict_vector_vector_int___cxx.d");
2831 remove(
"AutoDict_vector_vector_int___cxx.so");
2837 for (uint32_t
i = 0;
i < mConfig.compareInputs.size();
i++) {
2841 clearGarbagageCollector();
2843 GPUInfo(
"GPU TPC QA histograms have been written to %s files", mConfig.writeRootFiles ?
".pdf and .root" :
".pdf");
2844 gErrorIgnoreLevel = oldRootIgnoreLevel;
2848void GPUQA::PrintClusterCount(int32_t
mode, int32_t&
num,
const char*
name, uint64_t
n, uint64_t normalization)
2852 }
else if (
mode == 1) {
2854 snprintf(name2, 128,
"clusterCount%d_",
num);
2855 char*
ptr = name2 + strlen(name2);
2856 for (uint32_t
i = 0;
i < strlen(
name);
i++) {
2862 createHist(mHistClusterCount[
num], name2,
name, 1000, 0, mConfig.histMaxNClusters, 1000, 0, 100);
2863 }
else if (
mode == 0) {
2864 if (normalization && mConfig.enableLocalOutput) {
2865 printf(
"\t%40s: %'12" PRIu64
" (%6.2f%%)\n",
name,
n, 100.f *
n / normalization);
2867 if (mConfig.clusterRejectionHistograms) {
2868 float ratio = 100.f *
n / std::max<uint64_t>(normalization, 1);
2869 mHistClusterCount[
num]->Fill(normalization, ratio, 1);
2875int32_t GPUQA::DoClusterCounts(uint64_t* attachClusterCounts, int32_t
mode)
2878 if (mcPresent() && (mQATasks & taskClusterAttach) && attachClusterCounts) {
2879 for (int32_t
i = 0;
i < N_CLS_HIST;
i++) {
2880 PrintClusterCount(
mode,
num, CLUSTER_NAMES[
i], attachClusterCounts[
i], mClusterCounts.nTotal);
2882 PrintClusterCount(
mode,
num,
"Unattached", attachClusterCounts[N_CLS_HIST - 1] - attachClusterCounts[CL_att_adj], mClusterCounts.nTotal);
2883 PrintClusterCount(
mode,
num,
"Removed (Strategy A)", attachClusterCounts[CL_att_adj] - attachClusterCounts[CL_prot], mClusterCounts.nTotal);
2884 PrintClusterCount(
mode,
num,
"Unaccessible", mClusterCounts.nUnaccessible, mClusterCounts.nTotal);
2886 PrintClusterCount(
mode,
num,
"All Clusters", mClusterCounts.nTotal, mClusterCounts.nTotal);
2887 PrintClusterCount(
mode,
num,
"Used in Physics", mClusterCounts.nPhysics, mClusterCounts.nTotal);
2888 PrintClusterCount(
mode,
num,
"Protected", mClusterCounts.nProt, mClusterCounts.nTotal);
2889 PrintClusterCount(
mode,
num,
"Unattached", mClusterCounts.nUnattached, mClusterCounts.nTotal);
2890 PrintClusterCount(
mode,
num,
"Removed (Strategy A)", mClusterCounts.nTotal - mClusterCounts.nUnattached - mClusterCounts.nProt, mClusterCounts.nTotal);
2891 PrintClusterCount(
mode,
num,
"Removed (Strategy B)", mClusterCounts.nTotal - mClusterCounts.nProt, mClusterCounts.nTotal);
2894 PrintClusterCount(
mode,
num,
"Merged Loopers (Afterburner)", mClusterCounts.nMergedLooper, mClusterCounts.nTotal);
2895 PrintClusterCount(
mode,
num,
"High Inclination Angle", mClusterCounts.nHighIncl, mClusterCounts.nTotal);
2896 PrintClusterCount(
mode,
num,
"Rejected", mClusterCounts.nRejected, mClusterCounts.nTotal);
2897 PrintClusterCount(
mode,
num,
"Tube (> 200 MeV)", mClusterCounts.nTube, mClusterCounts.nTotal);
2898 PrintClusterCount(
mode,
num,
"Tube (< 200 MeV)", mClusterCounts.nTube200, mClusterCounts.nTotal);
2899 PrintClusterCount(
mode,
num,
"Looping Legs", mClusterCounts.nLoopers, mClusterCounts.nTotal);
2900 PrintClusterCount(
mode,
num,
"Low Pt < 50 MeV", mClusterCounts.nLowPt, mClusterCounts.nTotal);
2901 PrintClusterCount(
mode,
num,
"Low Pt < 200 MeV", mClusterCounts.n200MeV, mClusterCounts.nTotal);
2903 if (mcPresent() && (mQATasks & taskClusterAttach)) {
2904 PrintClusterCount(
mode,
num,
"Tracks > 400 MeV", mClusterCounts.nAbove400, mClusterCounts.nTotal);
2905 PrintClusterCount(
mode,
num,
"Fake Removed (> 400 MeV)", mClusterCounts.nFakeRemove400, mClusterCounts.nAbove400);
2906 PrintClusterCount(
mode,
num,
"Full Fake Removed (> 400 MeV)", mClusterCounts.nFullFakeRemove400, mClusterCounts.nAbove400);
2907 PrintClusterCount(
mode,
num,
"Tracks < 40 MeV", mClusterCounts.nBelow40, mClusterCounts.nTotal);
2908 PrintClusterCount(
mode,
num,
"Fake Protect (< 40 MeV)", mClusterCounts.nFakeProtect40, mClusterCounts.nBelow40);
2910 if (mcPresent() && (mQATasks & taskTrackStatistics)) {
2911 PrintClusterCount(
mode,
num,
"Correctly Attached all-trk normalized", mClusterCounts.nCorrectlyAttachedNormalized, mClusterCounts.nTotal);
2912 PrintClusterCount(
mode,
num,
"Correctly Attached non-fake normalized", mClusterCounts.nCorrectlyAttachedNormalizedNonFake, mClusterCounts.nTotal);
2919 mTrackingScratchBuffer.resize((nBytes +
sizeof(mTrackingScratchBuffer[0]) - 1) /
sizeof(mTrackingScratchBuffer[0]));
2920 return mTrackingScratchBuffer.data();
A const (ready only) version of MCTruthContainer.
Helper class to access correction maps.
#define GPUCA_MIN_TRACK_PTB5_DEFAULT
#define TRACK_EXPECTED_REFERENCE_X_DEFAULT
#define TRACK_EXPECTED_REFERENCE_X
#define CHECK_CLUSTER_STATE_NOCOUNT()
#define CHECK_CLUSTER_STATE()
Definition of the MCTrack class.
Definition of the Names Generator class.
double GetCurrentElapsedTime(bool reset=false)
Class for time synchronization of RawReader instances.
static const HBFUtils & Instance()
static constexpr int32_t NSECTORS
int32_t ReadO2MCData(const char *filename)
bool clusterRemovable(int32_t attach, bool prot) const
void * AllocateScratchBuffer(size_t nBytes)
void SetMCTrackRange(int32_t min, int32_t max)
mcLabelI_t GetMCTrackLabel(uint32_t trackId) const
int32_t DrawQAHistograms()
int32_t InitQA(int32_t tasks=0)
void DumpO2MCData(const char *filename) const
void RunQA(bool matchOnly=false)
static GPUROOTDump< T, Args... > getNew(const char *name1, Names... names)
static DigitizationContext * loadFromFile(std::string_view filename="")
GLfloat GLfloat GLfloat alpha
GLuint GLfloat GLfloat GLfloat GLfloat y1
GLuint const GLchar * name
GLuint GLuint GLfloat weight
GLuint GLsizei const GLchar * label
typedef void(APIENTRYP PFNGLCULLFACEPROC)(GLenum mode)
GLdouble GLdouble GLdouble z
constexpr int LHCBCPERTIMEBIN
Enum< T >::Iterator begin(Enum< T >)
struct o2::upgrades_utils::@454 tracks
structure to keep trigger-related info
Defining DataPointCompositeObject explicitly as copiable.
bool isValid(std::string alias)
int64_t differenceInBC(const InteractionRecord &other) const
std::tuple< std::vector< std::unique_ptr< TCanvas > >, std::vector< std::unique_ptr< TLegend > >, std::vector< std::unique_ptr< TPad > >, std::vector< std::unique_ptr< TLatex > >, std::vector< std::unique_ptr< TH1D > > > v
IR getFirstIRofTF(const IR &rec) const
get 1st IR of TF corresponding to the 1st sampled orbit (in MC)
unsigned int nClustersTotal
o2::InteractionRecord ir(0, 0)
o2::InteractionRecord ir0(3, 5)