Skip to content
Snippets Groups Projects
Commit 4379de20 authored by Sergey Gorbunov's avatar Sergey Gorbunov
Browse files

Ca: bugfix for debug mode: the performance table was stored after every event

parent 9ac33414
No related branches found
No related tags found
1 merge request!1919Ca: bugfix for debug mode: the performance table was stored after every event
Pipeline #31106 passed
......@@ -797,6 +797,9 @@ void CbmL1::Reconstruct(CbmEvent* event)
// ----- Finish CbmStsFitPerformanceTask task -----------------------------
void CbmL1::Finish()
{
if (fPerformance) {
EfficienciesPerformance(kTRUE);
}
// monitor the material
LOG(info) << "\033[31;1m ***************************\033[0m";
......
......@@ -358,7 +358,7 @@ class CbmL1 : public FairTask {
void SetRandomSeed(unsigned int seed) { fInitManager.SetRandomSeed(seed); }
/// Calculates tracking efficiencies (counters)
void EfficienciesPerformance();
void EfficienciesPerformance(bool doFinish = kFALSE);
/// Builds pulls and residuals
/// \note Should be called only after CbmL1::Performance()
......
......@@ -66,6 +66,7 @@ using std::map;
using std::vector;
struct TL1PerfEfficiencies : public TL1Efficiencies {
TL1PerfEfficiencies()
: TL1Efficiencies()
, ratio_killed()
......@@ -157,10 +158,9 @@ struct TL1PerfEfficiencies : public TL1Efficiencies {
mc_length_hits.counters[index] += _mc_length_hits;
};
void PrintEff(bool ifPrintTableToLog = false, bool ifDeleteTable = false,
void PrintEff(bool ifPrintTableToLog = false, TDirectory* outDir = nullptr,
const std::string& nameOfTable = "efficiency_table")
{
assert(nEvents != 0);
int NCounters = mc.GetNcounters();
std::vector<std::string> rowNames(NCounters + 2);
for (int iC = 0; iC < NCounters; ++iC) {
......@@ -181,10 +181,22 @@ struct TL1PerfEfficiencies : public TL1Efficiencies {
aTable->SetCell(iC, 2, ratio_length.counters[iC]);
aTable->SetCell(iC, 3, ratio_fakes.counters[iC]);
aTable->SetCell(iC, 4, ratio_clone.counters[iC]);
aTable->SetCell(iC, 5, reco.counters[iC] / double(nEvents));
aTable->SetCell(iC, 6, mc.counters[iC] / double(nEvents));
aTable->SetCell(iC, 7, mc_length_hits.counters[iC] / double(mc.counters[iC]));
aTable->SetCell(iC, 8, mc_length.counters[iC] / double(mc.counters[iC]));
if (nEvents > 0) {
aTable->SetCell(iC, 5, reco.counters[iC] / double(nEvents));
aTable->SetCell(iC, 6, mc.counters[iC] / double(nEvents));
}
else {
aTable->SetCell(iC, 5, -1.);
aTable->SetCell(iC, 6, -1.);
}
if (mc.counters[iC] > 0) {
aTable->SetCell(iC, 7, mc_length_hits.counters[iC] / double(mc.counters[iC]));
aTable->SetCell(iC, 8, mc_length.counters[iC] / double(mc.counters[iC]));
}
else {
aTable->SetCell(iC, 7, -1.);
aTable->SetCell(iC, 8, -1.);
}
}
aTable->SetCell(NCounters, 0, ratio_ghosts);
aTable->SetCell(NCounters + 1, 0, ghosts);
......@@ -192,10 +204,11 @@ struct TL1PerfEfficiencies : public TL1Efficiencies {
if (ifPrintTableToLog) {
LOG(info) << *aTable; // print a table to log
}
if (!ifDeleteTable) {
aTable->SetDirectory(fOutDir);
if (outDir != nullptr) {
aTable->SetDirectory(outDir);
}
else {
aTable->SetDirectory(nullptr);
delete aTable;
}
};
......@@ -211,22 +224,23 @@ struct TL1PerfEfficiencies : public TL1Efficiencies {
TL1TracksCatCounters<double> reco_fakes;
TL1TracksCatCounters<int> mc_length;
TL1TracksCatCounters<int> mc_length_hits;
TDirectory* fOutDir{nullptr}; // Specified for saving tables
};
void CbmL1::EfficienciesPerformance()
void CbmL1::EfficienciesPerformance(bool doFinish)
{
static TL1PerfEfficiencies L1_NTRA; // average efficiencies
static int L1_NEVENTS = 0;
static double L1_CATIME = 0.0;
if (doFinish) {
L1_NTRA.CalcEff();
L1_NTRA.PrintEff(false, fTableDir);
return;
}
TL1PerfEfficiencies ntra; // efficiencies for current event
ntra.fOutDir = fTableDir; // Setup a pointer for output directory
L1_NTRA.fOutDir = fTableDir; // Save average efficiencies
TL1PerfEfficiencies ntra; // efficiencies for current event
cbm::ca::tools::Debugger::Instance().AddNtuple("ghost", "it:ih:p:x:y:z:t:dx:dy");
static int statNghost = 0;
......@@ -394,7 +408,7 @@ void CbmL1::EfficienciesPerformance()
if (fVerbose) {
if (fVerbose > 1) {
ntra.PrintEff(true, true);
ntra.PrintEff(true);
std::stringstream ss;
ss << "Number of true and fake hits in stations: \n";
for (int i = 0; i < fpAlgo->GetParameters().GetNstationsActive(); i++) {
......@@ -404,7 +418,7 @@ void CbmL1::EfficienciesPerformance()
} // fVerbose > 1
LOG(info) << "\n"
<< "L1 ACCUMULATED STAT : " << L1_NEVENTS << " EVENTS \n";
L1_NTRA.PrintEff(/*ifPrintTableToLog = */ true, false);
L1_NTRA.PrintEff(true);
LOG(info) << "Reconstructible MC tracks/event: "
<< (double(L1_NTRA.mc.counters[L1_NTRA.indices["total"]]) / double(L1_NEVENTS));
LOG(info) << "Reconstructed MC tracks/event: "
......@@ -413,6 +427,7 @@ void CbmL1::EfficienciesPerformance()
}
} // void CbmL1::Performance()
void CbmL1::HistoPerformance() // TODO: check if works correctly. Change vHitFast on match data in CbmL1**Track classes
{
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment