From 540f6d195c79b278ed3a53b6ec394077780db603 Mon Sep 17 00:00:00 2001 From: "s.zharko@gsi.de" <s.zharko@gsi.de> Date: Mon, 4 Apr 2022 10:52:25 +0200 Subject: [PATCH] update --- reco/L1/CbmL1.cxx | 9 ++- reco/L1/CbmL1Performance.cxx | 104 ++++++++++++++++++++++++----------- reco/L1/L1Algo/L1Assert.h | 4 +- 3 files changed, 81 insertions(+), 36 deletions(-) diff --git a/reco/L1/CbmL1.cxx b/reco/L1/CbmL1.cxx index 2526d10a97..784fb96e6b 100644 --- a/reco/L1/CbmL1.cxx +++ b/reco/L1/CbmL1.cxx @@ -17,6 +17,9 @@ * *==================================================================== */ + +#include <boost/filesystem.hpp> + #include "CbmL1.h" #include "CbmKF.h" @@ -1822,7 +1825,11 @@ void CbmL1::Finish() TFile* currentFile = gFile; // Open output file and write histograms - TFile* outfile = new TFile("L1_histo.root", "RECREATE"); + boost::filesystem::path p = (FairRunAna::Instance()->GetUserOutputFileName()).Data(); + std::string histoOutName = p.parent_path().string() + "/L1_histo_" + p.filename().string(); + LOG(info) << "\033[31;1mHistograms will be saved to: \033[0m" << histoOutName; + + TFile* outfile = new TFile(histoOutName.c_str(), "RECREATE"); outfile->cd(); writedir2current(fHistoDir); outfile->Close(); diff --git a/reco/L1/CbmL1Performance.cxx b/reco/L1/CbmL1Performance.cxx index df24b3afc0..b275ca3f6e 100644 --- a/reco/L1/CbmL1Performance.cxx +++ b/reco/L1/CbmL1Performance.cxx @@ -35,6 +35,8 @@ #include "CbmTofPoint.h" #include "CbmTrdHit.h" #include "CbmTrdPoint.h" +#include "CbmQaTable.h" + #include "FairTrackParam.h" // for vertex pulls @@ -220,48 +222,81 @@ struct TL1PerfEfficiencies : public TL1Efficiencies { mc_length_hits.counters[index] += _mc_length_hits; }; - void PrintEff() + void PrintEff(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; - + // 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) { + rowNames[iC] = std::string(names[iC].Data()); + } + std::vector<std::string> colNames = { + "Eff.", + "Killed", + "Length", + "Fakes", + "Clones", + "All Reco", + "All MC", + "MCl(hits)", + "MCl(MCps)" + }; + + TDirectory* curdir = gDirectory; + gDirectory = fOutDir; + + static int sTableNo = 0; + std::string nameOfTableNew = nameOfTable + "_no" + std::to_string(sTableNo); + LOG(info) << ">> Table No " << sTableNo; + ++sTableNo; + + + + CbmQaTable* aTable = new CbmQaTable(nameOfTableNew.c_str(), "Track Efficiency", 20, 9); + aTable->SetNamesOfRows(rowNames); + aTable->SetNamesOfCols(colNames); for (int iC = 0; iC < NCounters; iC++) { - if ((names[iC] != "D0 efficiency") || (mc.counters[iC] != 0)) - cout << names[iC] << " : " << ratio_reco.counters[iC] << " / " - << ratio_killed.counters[iC] // tracks with aren't reco because other tracks takes their hit(-s) - << " / " << ratio_length.counters[iC] // nRecoMCHits/nMCHits - << " / " << ratio_fakes.counters[iC] // nFakeHits/nRecoAllHits - << " / " << ratio_clone.counters[iC] // nCloneTracks/nMCTracks - << " / " << setw(8) << reco.counters[iC] / double(nEvents) << " | " << setw(8) - << mc.counters[iC] / double(nEvents) << " / " << mc_length_hits.counters[iC] / double(mc.counters[iC]) - << " / " << mc_length.counters[iC] / double(mc.counters[iC]) << endl; + aTable->SetCell(iC, 0, ratio_reco.counters[iC]); + aTable->SetCell(iC, 1, ratio_killed.counters[iC]); + 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])); } + cout << *aTable; cout << "Ghost probability : " << ratio_ghosts << " | " << ghosts << endl; + + gDirectory = curdir; }; + + TL1TracksCatCounters<double> ratio_killed; TL1TracksCatCounters<double> ratio_clone; TL1TracksCatCounters<double> ratio_length; @@ -273,6 +308,8 @@ struct TL1PerfEfficiencies : public TL1Efficiencies { TL1TracksCatCounters<double> reco_fakes; TL1TracksCatCounters<int> mc_length; TL1TracksCatCounters<int> mc_length_hits; + + TDirectory* fOutDir {nullptr}; }; @@ -285,6 +322,7 @@ void CbmL1::EfficienciesPerformance() TL1PerfEfficiencies ntra; // efficiencies for current event + ntra.fOutDir = fHistoDir; // Setup a pointer for output directory for (vector<CbmL1Track>::iterator rtraIt = vRTracks.begin(); rtraIt != vRTracks.end(); ++rtraIt) { ntra.ghosts += rtraIt->IsGhost(); diff --git a/reco/L1/L1Algo/L1Assert.h b/reco/L1/L1Algo/L1Assert.h index e5bdf5032b..d2cd46c43b 100644 --- a/reco/L1/L1Algo/L1Assert.h +++ b/reco/L1/L1Algo/L1Assert.h @@ -53,8 +53,8 @@ namespace L1Assert /// Specialization in case of IsAsserted = false, i.e. the assertion is not made template<> - constexpr int DoAssertion<false>(int /*level*/, bool /*condition*/, const char* /*msg*/, const char* /*fileName*/, - int /*lineNo*/) + inline __attribute__((always_inline)) int DoAssertion<false>(int /*level*/, bool /*condition*/, const char* /*msg*/, + const char* /*fileName*/, int /*lineNo*/) { return 0; } -- GitLab