diff --git a/reco/L1/CbmL1.cxx b/reco/L1/CbmL1.cxx index 91a5616ade754a5a71d974bc880970e053b37bd3..b4e4f5e34b49fe4fe90dbd2b755cf7ae6c373ea3 100644 --- a/reco/L1/CbmL1.cxx +++ b/reco/L1/CbmL1.cxx @@ -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"; diff --git a/reco/L1/CbmL1.h b/reco/L1/CbmL1.h index 68bdc21a4539a6ca707cecf2f2f47b1f61ea31f3..6f4d78a9bf11dcd66459d05377ed68ff172a1072 100644 --- a/reco/L1/CbmL1.h +++ b/reco/L1/CbmL1.h @@ -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() diff --git a/reco/L1/CbmL1Performance.cxx b/reco/L1/CbmL1Performance.cxx index a0b4f0b491124eea536720a554ed41c1e8a9548e..53df76f1dcc4e763a1445600db9b76bf4465739d 100644 --- a/reco/L1/CbmL1Performance.cxx +++ b/reco/L1/CbmL1Performance.cxx @@ -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 {