Skip to content
Snippets Groups Projects
Commit 0b299d72 authored by Sergei Zharko's avatar Sergei Zharko
Browse files

CA online: monitor fixes

parent 534d8417
No related branches found
No related tags found
1 merge request!1458CA online: monitor fixes
Pipeline #25111 failed
......@@ -11,6 +11,7 @@
#include "tof/Config.h"
#include <fstream>
#include <unordered_map>
#include <xpu/host.h>
......@@ -60,12 +61,14 @@ TrackingChain::Return_t TrackingChain::Run(Input_t recoResults)
fCaMonitorData.Reset();
// ----- Init input data ---------------------------------------------------------------------------------------------
fCaMonitorData.StartTimer(ca::ETimer::PrepareInput);
this->PrepareInput(recoResults);
fCaMonitorData.StopTimer(ca::ETimer::PrepareInput);
// ----- Run reconstruction ------------------------------------------------------------------------------------------
fCaFramework.SetMonitorData(fCaMonitorData);
fCaMonitorData = fCaFramework.GetMonitorData();
fCaFramework.fTrackFinder.FindTracks();
fCaMonitorData = fCaFramework.GetMonitorData();
L_(info) << "TrackingChain: Timeslice contains " << fCaMonitorData.GetCounterValue(ca::ECounter::RecoTrack)
<< " tracks, the FindTracks routine ran " << fCaMonitorData.GetTimer(ca::ETimer::FindTracks).GetTotal()
<< " s";
......@@ -100,6 +103,9 @@ void TrackingChain::PrepareInput(Input_t recoResults)
template<EDetectorID DetID>
void TrackingChain::ReadHits(PartitionedSpan<const ca::HitTypes_t::at<DetID>> hits)
{
std::ofstream out;
if constexpr (kDEBUG) { out.open(std::string("./Debug_hits_") + ca::kDetName[DetID] + ".txt"); }
using Hit_t = ca::HitTypes_t::at<DetID>;
constexpr bool IsMvd = (DetID == EDetectorID::Mvd);
constexpr bool IsSts = (DetID == EDetectorID::Sts);
......@@ -129,6 +135,7 @@ void TrackingChain::ReadHits(PartitionedSpan<const ca::HitTypes_t::at<DetID>> hi
size_t iOffset = hits.Offsets()[iPartition];
if (iStActive < 0) { continue; }
double lastTime = -1e9;
double prevTime = -1;
for (size_t iPartHit = 0; iPartHit < vHits.size(); ++iPartHit) {
const auto& hit = vHits[iPartHit];
int iHitExt = iOffset + iPartHit;
......@@ -161,6 +168,11 @@ void TrackingChain::ReadHits(PartitionedSpan<const ca::HitTypes_t::at<DetID>> hi
lastTime = caHit.T();
if (!IsTof) { dataStream = extHitAddress; }
fCaDataManager.PushBackHit(caHit, dataStreamDet | dataStream);
if constexpr (kDEBUG) {
out << (dataStreamDet | dataStream) << " ----- " << caHit.ToString() << '\n';
if (prevTime > caHit.T()) { out << "TIME IS UNSORTED\n"; }
}
if (fNofHitKeys <= caHit.FrontKey()) { fNofHitKeys = caHit.FrontKey() + 1; }
if (fNofHitKeys <= caHit.BackKey()) { fNofHitKeys = caHit.BackKey() + 1; }
}
......@@ -171,6 +183,7 @@ void TrackingChain::ReadHits(PartitionedSpan<const ca::HitTypes_t::at<DetID>> hi
if constexpr (IsTrd) { fCaMonitorData.IncrementCounter(ca::ECounter::UndefinedTrdHit); }
if constexpr (IsTof) { fCaMonitorData.IncrementCounter(ca::ECounter::UndefinedTofHit); }
}
prevTime = caHit.T();
// ---- Update number of hit keys
} // iPartHit
} // iPartition
......
......@@ -82,6 +82,8 @@ namespace cbm::algo
// ** Auxilary variables
ca::HitKeyIndex_t fNofHitKeys = 0; ///< Current number of hit keys (aux)
static constexpr bool kDEBUG = false; ///< Debug mode
};
......
......@@ -152,13 +152,13 @@ namespace cbm::algo::ca
using std::setw;
std::stringstream msg;
constexpr size_t widthKey = 30;
constexpr size_t width = 12;
constexpr size_t width = 24;
msg << "\n===== Monitor: " << fsName << "\n";
if constexpr (!std::is_same_v<ETimerKey, EDummy>) {
msg << "\n----- Timers:\n";
msg << setw(widthKey) << left << "Key" << ' ';
msg << setw(width) << left << "N Calls" << ' ';
//msg << setw(width) << left << "Average [s]" << ' ';
msg << setw(width) << left << "Average [s]" << ' ';
msg << setw(width) << left << "Min [s]" << ' ';
msg << setw(width) << left << "Max [s]" << ' ';
msg << setw(width) << left << "Total [s]" << '\n';
......@@ -167,7 +167,7 @@ namespace cbm::algo::ca
const Timer& timer = fMonitorData.GetTimer(static_cast<ETimerKey>(iKey));
msg << setw(widthKey) << faTimerNames[iKey] << ' ';
msg << setw(width) << timer.GetNofCalls() << ' ';
//msg << setw(width) << timer.GetAverage() << ' ';
msg << setw(width) << timer.GetAverage() << ' ';
msg << setw(width) << timer.GetMin() << ' ';
msg << setw(width) << timer.GetMax() << ' ';
msg << setw(width) << timer.GetTotal() << '\n';
......
......@@ -49,7 +49,7 @@ namespace cbm::algo::ca
void AddTimer(const Timer& other);
/// \brief Gets average time [s]
double GetAverage() const { return static_cast<double>(fTotal / fNofCalls) * 1.e-9; }
double GetAverage() const { return static_cast<double>(fTotal) / fNofCalls * 1.e-9; }
/// \brief Gets time of the longest call [s]
double GetMax() const { return static_cast<double>(fMax) * 1.e-9; }
......
......@@ -37,7 +37,7 @@ namespace cbm::algo::ca
enum class ETimer
{
//Tracking,
//PrepareInput,
PrepareInput,
FindTracks,
TrackFinder,
TrackFitter,
......@@ -67,7 +67,7 @@ namespace cbm::algo::ca
SetCounterName(ECounter::UndefinedTrdHit, "undefined TRD hits");
SetCounterName(ECounter::UndefinedTofHit, "undefined TOF hits");
//SetTimerName(ETimer::Tracking, "full tracking");
//SetTimerName(ETimer::PrepareInput, "input data initialization");
SetTimerName(ETimer::PrepareInput, "input data initialization");
SetTimerName(ETimer::FindTracks, "find tracks procedure");
SetTimerName(ETimer::TrackFinder, "track finder");
SetTimerName(ETimer::TrackFitter, "track fitter");
......
......@@ -918,8 +918,7 @@ void CbmL1::Finish()
LOG(info) << "\033[31;1m -------------------------------------------------------------\033[0m";
// monitor of the reconstructed tracks
// FIXME: For some reason this string causes the crash of the analysis tree converter. Further investigations are needed
//LOG(info) << fMonitor.ToString();
LOG(info) << fMonitor.ToString();
TDirectory* curr = gDirectory;
TFile* currentFile = gFile;
......
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