From 382140f0b463de1eb06af1e453bc198e5842ce2c Mon Sep 17 00:00:00 2001 From: "s.zharko@gsi.de" <s.zharko@gsi.de> Date: Mon, 22 Aug 2022 11:23:41 +0200 Subject: [PATCH] L1: fixed memory leak in performance tables --- reco/L1/CbmL1.cxx | 2 +- reco/L1/CbmL1Performance.cxx | 45 ++++++++---------------------- reco/L1/L1Algo/L1Algo.cxx | 2 +- reco/L1/L1Algo/L1Algo.h | 2 +- reco/L1/L1Algo/L1CATrackFinder.cxx | 8 +++--- reco/L1/L1Algo/L1Constants.h | 2 +- reco/L1/L1Algo/L1Def.h | 10 +++++++ 7 files changed, 30 insertions(+), 41 deletions(-) diff --git a/reco/L1/CbmL1.cxx b/reco/L1/CbmL1.cxx index 1bb057fd7d..e8b67a0f13 100644 --- a/reco/L1/CbmL1.cxx +++ b/reco/L1/CbmL1.cxx @@ -1112,7 +1112,7 @@ void CbmL1::Reconstruct(CbmEvent* event) if (!fLegacyEventMode) cout << "CA Track Finder: " << fpAlgo->fCATime << " s/sub-ts" << endl << endl; } - + if (fPerformance) { diff --git a/reco/L1/CbmL1Performance.cxx b/reco/L1/CbmL1Performance.cxx index 5c50447626..15fc5ffd90 100644 --- a/reco/L1/CbmL1Performance.cxx +++ b/reco/L1/CbmL1Performance.cxx @@ -51,9 +51,11 @@ #include <vector> #include "L1Algo/L1Algo.h" +#include "L1Algo/L1Def.h" #include "L1Algo/L1Extrapolation.h" // for vertex pulls #include "L1Algo/L1Fit.h" // for vertex pulls + using std::cout; using std::endl; using std::ios; @@ -222,32 +224,10 @@ struct TL1PerfEfficiencies : public TL1Efficiencies { mc_length_hits.counters[index] += _mc_length_hits; }; - void PrintEff(bool ifPrintTableToLog = false, const std::string& nameOfTable = "efficiency_table") + void PrintEff(bool ifPrintTableToLog = false, bool ifDeleteTable = false, + const std::string& nameOfTable = "efficiency_table") { L1_assert(nEvents != 0); - - // cout.setf(ios::fixed); - // cout.setf(ios::showpoint); - // cout.precision(3); - // cout.setf(ios::right); - // cout << "Track category : " - // << " Eff " - // << " / " - // << "Killed" - // << " / " - // << "Length" - // << " / " - // << "Fakes " - // << " / " - // << "Clones" - // << " / " - // << "All Reco" - // << " | " - // << " All MC " - // << " / " - // << "MCl(hits)" - // << " / " - // << "MCl(MCps)" << endl; int NCounters = mc.GetNcounters(); std::vector<std::string> rowNames(20); for (int iC = 0; iC < NCounters; ++iC) { @@ -256,9 +236,6 @@ struct TL1PerfEfficiencies : public TL1Efficiencies { std::vector<std::string> colNames = {"Eff.", "Killed", "Length", "Fakes", "Clones", "All Reco", "All MC", "MCl(hits)", "MCl(MCps)"}; - TDirectory* curdir = gDirectory; - gDirectory = fOutDir; - CbmQaTable* aTable = new CbmQaTable(nameOfTable.c_str(), "Track Efficiency", 20, 9); aTable->SetNamesOfRows(rowNames); aTable->SetNamesOfCols(colNames); @@ -276,12 +253,14 @@ struct TL1PerfEfficiencies : public TL1Efficiencies { if (ifPrintTableToLog) { cout << *aTable; // print a table to log } - cout << "Ghost probability : " << ratio_ghosts << " | " << ghosts << endl; + if (!ifDeleteTable) { aTable->SetDirectory(fOutDir); } + else { + delete aTable; + } - gDirectory = curdir; + cout << "Ghost probability : " << ratio_ghosts << " | " << ghosts << endl; }; - TL1TracksCatCounters<double> ratio_killed; TL1TracksCatCounters<double> ratio_clone; TL1TracksCatCounters<double> ratio_length; @@ -320,7 +299,7 @@ void CbmL1::EfficienciesPerformance() } cout << endl; for (map<int, int>::iterator posIt = rtraIt->hitMap.begin(); posIt != rtraIt->hitMap.end(); posIt++) { - CbmL1MCTrack& t = vMCTracks[posIt->first]; + CbmL1MCTrack& t = fvMCTracks[posIt->first]; cout << "mc " << posIt->first << " pdg " << t.pdg << " mother: " << t.mother_ID; cout << " n mc stations: " << t.NMCStations() << endl; } @@ -464,7 +443,7 @@ void CbmL1::EfficienciesPerformance() // cout.precision(3); if (fVerbose) { if (fVerbose > 1) { - ntra.PrintEff(true); + ntra.PrintEff(true, true); cout << "Number of true and fake hits in stations: " << endl; for (int i = 0; i < fpAlgo->GetNstations(); i++) { cout << sta_nhits[i] - sta_nfakes[i] << "+" << sta_nfakes[i] << " "; @@ -473,7 +452,7 @@ void CbmL1::EfficienciesPerformance() } // fVerbose > 1 cout << endl; cout << "L1 ACCUMULATED STAT : " << L1_NEVENTS << " EVENTS " << endl << endl; - L1_NTRA.PrintEff(/*ifPrintTableToLog = */ true); + L1_NTRA.PrintEff(/*ifPrintTableToLog = */ true, false); cout << "MC tracks/event found : " << int(double(L1_NTRA.reco.counters[L1_NTRA.indices["total"]]) / double(L1_NEVENTS)) << endl; cout << endl; diff --git a/reco/L1/L1Algo/L1Algo.cxx b/reco/L1/L1Algo/L1Algo.cxx index 081c7dd1be..473e6f1a51 100644 --- a/reco/L1/L1Algo/L1Algo.cxx +++ b/reco/L1/L1Algo/L1Algo.cxx @@ -109,7 +109,7 @@ void L1Algo::ReceiveInputData(L1InputData&& inputData) // ----- Reset data arrays ------------------------------------------------------------------------------------------- fvHitKeyFlags.reset(fInputData.GetNhitKeys()); - int nHits = fInputData.GetNhits(); + int nHits = fInputData.GetNhits(); NHitsIsecAll = nHits; vNotUsedHits_A.reset(nHits); vNotUsedHits_B.reset(nHits); diff --git a/reco/L1/L1Algo/L1Algo.h b/reco/L1/L1Algo/L1Algo.h index bfa960d7bc..714e968777 100644 --- a/reco/L1/L1Algo/L1Algo.h +++ b/reco/L1/L1Algo/L1Algo.h @@ -484,7 +484,7 @@ public: // L1Branch* pointer; unsigned int NHitsIsecAll {0}; - + L1Vector<L1Hit> vNotUsedHits_A {"L1Algo::vNotUsedHits_A"}; L1Vector<L1Hit> vNotUsedHits_B {"L1Algo::vNotUsedHits_B"}; L1Vector<L1Hit> vNotUsedHits_Buf {"L1Algo::vNotUsedHits_Buf"}; diff --git a/reco/L1/L1Algo/L1CATrackFinder.cxx b/reco/L1/L1Algo/L1CATrackFinder.cxx index 4ad0533ac1..174c40869b 100644 --- a/reco/L1/L1Algo/L1CATrackFinder.cxx +++ b/reco/L1/L1Algo/L1CATrackFinder.cxx @@ -2090,7 +2090,7 @@ void L1Algo::CATrackFinder() i1G_2) //schedule(dynamic, 2) #endif for (Tindex ip = fDupletPortionStopIndex[istal + 1]; ip < fDupletPortionStopIndex[istal]; ++ip) { - Tindex n_2 = 0; /// number of doublets in portion + Tindex n_2 = 0; /// number of doublets in portion int NHitsSta = fInputData.GetStopHitIndex(istal) - fInputData.GetStartHitIndex(istal); lmDuplets[istal].reset(NHitsSta); lmDupletsG[istal].reset(NHitsSta); @@ -2465,9 +2465,9 @@ void L1Algo::CATrackFinder() #endif for (L1Vector<L1HitIndex_t>::iterator phIt = tr.fHits.begin(); /// used strips are marked phIt != tr.fHits.end(); ++phIt) { - const L1Hit& hit = fInputData.GetHit(*phIt); - fvHitKeyFlags[hit.f] = 1; - fvHitKeyFlags[hit.b] = 1; + const L1Hit& hit = fInputData.GetHit(*phIt); + fvHitKeyFlags[hit.f] = 1; + fvHitKeyFlags[hit.b] = 1; fRecoHits_local[num_thread].push_back(*phIt); L1HitPoint tempPoint = CreateHitPoint(hit); //TODO take number of station from hit diff --git a/reco/L1/L1Algo/L1Constants.h b/reco/L1/L1Algo/L1Constants.h index b436d95c9b..fbfff4e2f8 100644 --- a/reco/L1/L1Algo/L1Constants.h +++ b/reco/L1/L1Algo/L1Constants.h @@ -68,7 +68,7 @@ namespace L1Constants /// - 2: hits sorting is checked /// - 3: every hit is checked for consistency /// \note The larger Level corresponds to more precise checks, but is followed by larger time penalty - constexpr int kInputDataQaLevel = 3; + constexpr int kInputDataQaLevel = 0; // WARNING: other options does not work properly, more tests are needed! } // namespace control diff --git a/reco/L1/L1Algo/L1Def.h b/reco/L1/L1Algo/L1Def.h index 3e73ce9a05..00a3d0a271 100644 --- a/reco/L1/L1Algo/L1Def.h +++ b/reco/L1/L1Algo/L1Def.h @@ -48,10 +48,14 @@ T finite(T x) #if defined(NDEBUG) || defined(L1_NO_ASSERT) #define L1_ASSERT(v, msg) #define L1_assert(v) + // Prints expression value to the std::cout #define L1_SHOW(expr) + // Prints file and line information to the std::cout #define L1_SHOWF(msg) + + #else #define L1_ASSERT(v, msg) \ if (v) {} \ @@ -67,6 +71,12 @@ T finite(T x) std::cout << "(!) " << __FILE__ << ":" << __LINE__ << ": \033[01;38;5;208m" << (#msg) << "\033[0m\n" #endif +// Prints function call +#if defined(__GNUC__) +#define L1_SHOWFN std::cout << "\033[1;32mCALL \033[1;33m" << __PRETTY_FUNCTION__ << "\033[0m\n" +#else +#define L1_SHOWFN std::cout << "\033[1;32mCALL \033[1;33m" << __func__ << "\033[0m\n" +#endif typedef int index_type; -- GitLab