Skip to content

Commit

Permalink
Improved TRACE severity
Browse files Browse the repository at this point in the history
  • Loading branch information
rrivera747 committed Jan 6, 2025
1 parent 7eb7d19 commit c6ef325
Showing 1 changed file with 17 additions and 17 deletions.
34 changes: 17 additions & 17 deletions artdaq-mu2e/Generators/Mu2eSubEventReceiver_generator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ class Mu2eSubEventReceiver : public artdaq::CommandableFragmentGenerator

size_t dtc_offset_{0};
size_t n_dtcs_{1};
size_t first_timestamp_seen_{size_t(-1)}, last_fragment_timestamp{size_t(-1)};
size_t first_timestamp_seen_{size_t(-1)}, last_fragment_timestamp_{size_t(-1)};

std::unique_ptr<DTCLib::DTC> theInterface_;
std::unique_ptr<DTCLib::DTCSoftwareCFO> theCFO_;
Expand All @@ -85,23 +85,23 @@ mu2e::Mu2eSubEventReceiver::~Mu2eSubEventReceiver()

bool mu2e::Mu2eSubEventReceiver::getNext_(artdaq::FragmentPtrs& frags)
{
TLOG(TLVL_TRACE + 20) << "getNext_";
TLOG(TLVL_TRACE + 30) << "getNext_";
while (!simFileRead_ && !should_stop())
{
TLOG(TLVL_TRACE + 20) << "Sleeping...";
TLOG(TLVL_TRACE + 31) << "Sleeping...";
usleep(5000);
}

if(throttle_usecs_ > 0)
{
TLOG(TLVL_TRACE + 20) << "Throttling... " << throttle_usecs_;
TLOG(TLVL_TRACE + 32) << "Throttling... " << throttle_usecs_;
std::unique_lock<std::mutex> throttle_lock(throttle_mutex_);
throttle_cv_.wait_for(throttle_lock, std::chrono::microseconds(throttle_usecs_), [&]() { return should_stop(); });
}

if (should_stop())
{
TLOG(TLVL_TRACE + 20) << "Stopping.";
TLOG(TLVL_TRACE + 33) << "Stopping.";
return false;
}

Expand All @@ -123,16 +123,16 @@ bool mu2e::Mu2eSubEventReceiver::getNext_(artdaq::FragmentPtrs& frags)
frags.emplace_back(std::move(endOfSubrunFrag));
}

TLOG(TLVL_TRACE + 20) << "getNext_ req";
TLOG(TLVL_TRACE + 34) << "getNext_ req";
auto start_time = std::chrono::steady_clock::now();
bool retVal = true;
do
{
retVal = getNextDTCFragment(frags, zero);
TLOG(TLVL_TRACE + 20) << "getNext_ req retry? " << retVal << " " << frags.size();
TLOG(TLVL_TRACE + 35) << "getNext_ req retry? " << retVal << " " << frags.size();
} while (1 && retVal && frags.size() < 900 &&
artdaq::TimeUtils::GetElapsedTimeMicroseconds(start_time) < 100000 /* 100 ms */);
TLOG(TLVL_TRACE + 20) << "getNext_ req done" << retVal << " " << frags.size();
TLOG(TLVL_TRACE + 36) << "getNext_ req done" << retVal << " " << frags.size();

return retVal;
} //end getNext_()
Expand Down Expand Up @@ -296,12 +296,12 @@ bool mu2e::Mu2eSubEventReceiver::getNextDTCFragment(artdaq::FragmentPtrs& frags,
memcpy(const_cast<uint8_t*>(reinterpret_cast<const uint8_t*>(evt->GetRawBufferPointer())), &evtHdr, sizeof(DTCLib::DTC_EventHeader));
auto ptr = reinterpret_cast<const uint8_t*>(evt->GetRawBufferPointer()) + sizeof(DTCLib::DTC_EventHeader);

TLOG(TLVL_TRACE + 20) << "Calling memcpy(" << (const void*)ptr << ", " << (void*)subevt->GetRawBufferPointer() << ", " << subevt->GetSubEventByteCount() << ")";
TLOG(TLVL_TRACE + 21) << "Calling memcpy(" << (const void*)ptr << ", " << (void*)subevt->GetRawBufferPointer() << ", " << subevt->GetSubEventByteCount() << ")";
memcpy(const_cast<uint8_t*>(ptr), subevt->GetRawBufferPointer(), subevt->GetSubEventByteCount());
ptr += subevt->GetSubEventByteCount();
TLOG(TLVL_TRACE + 20) << "Calling SetupEvent";
TLOG(TLVL_TRACE + 22) << "Calling SetupEvent";
evt->SetupEvent();
TLOG(TLVL_TRACE + 20) << "Setting EventWindowTag to " << ts_out.GetEventWindowTag(true);
TLOG(TLVL_TRACE + 23) << "Setting EventWindowTag to " << ts_out.GetEventWindowTag(true);
evt->SetEventWindowTag(ts_out);

for (size_t se = 0; se < evt->GetSubEventCount(); ++se)
Expand Down Expand Up @@ -366,7 +366,7 @@ bool mu2e::Mu2eSubEventReceiver::getNextDTCFragment(artdaq::FragmentPtrs& frags,

if (last_fragment_timestamp_ != size_t(-1) && last_fragment_timestamp_ + 1 != timestamp_to_use)
{
TLOG(TLVL_DEBUG) << "NOT INCREMENTAL timestamp new=" << timestamp_to_use << " vs old=" << last_fragment_timestamp_;
TLOG(TLVL_DEBUG+19) << "NOT INCREMENTAL timestamp new=" << timestamp_to_use << " vs old=" << last_fragment_timestamp_;
}

if (first_timestamp_seen_ == size_t(-1)) //reset
Expand All @@ -380,20 +380,20 @@ bool mu2e::Mu2eSubEventReceiver::getNextDTCFragment(artdaq::FragmentPtrs& frags,
timestamp_to_use = fragment_timestamp + current_timestamp_offset_;
}
last_fragment_timestamp_ = timestamp_to_use;
TLOG(TLVL_TRACE + 20) << "fragment_timestamp=" << fragment_timestamp << " while timestamp_to_use=" << timestamp_to_use;
TLOG(TLVL_TRACE + 24) << "fragment_timestamp=" << fragment_timestamp << " while timestamp_to_use=" << timestamp_to_use;


//frags.emplace_back(new artdaq::Fragment(getCurrentSequenceID(), fragment_ids_[0], FragmentType::DTCEVT, fragment_timestamp));
TLOG(TLVL_TRACE + 20) << "Creating Fragment, sz=" << evt->GetEventByteCount() << ", seqid=" << getCurrentSequenceID();
TLOG(TLVL_TRACE + 25) << "Creating Fragment, sz=" << evt->GetEventByteCount() << ", seqid=" << getCurrentSequenceID();
frags.emplace_back(new artdaq::Fragment(timestamp_to_use, fragment_ids_[0], FragmentType::DTCEVT, fragment_timestamp));
frags.back()->resizeBytes(evt->GetEventByteCount());
memcpy(frags.back()->dataBegin(), evt->GetRawBufferPointer(), evt->GetEventByteCount());
metricMan->sendMetric("Average Event Size", evt->GetEventByteCount(), "Bytes", 3, artdaq::MetricMode::Average);
TLOG(TLVL_TRACE + 20) << "Incrementing event counter";
TLOG(TLVL_TRACE + 26) << "Incrementing event counter";
ev_counter_inc();
}
auto after_copy = std::chrono::steady_clock::now();
TLOG(TLVL_TRACE + 20) << "Reporting Metrics";
TLOG(TLVL_TRACE + 27) << "Reporting Metrics";
auto hwTime = theInterface_->GetDevice()->GetDeviceTime();

double hw_timestamp_rate = 1 / hwTime;
Expand All @@ -404,7 +404,7 @@ bool mu2e::Mu2eSubEventReceiver::getNextDTCFragment(artdaq::FragmentPtrs& frags,
metricMan->sendMetric("HW Timestamp Rate", hw_timestamp_rate, "timestamps/s", 1, artdaq::MetricMode::Average);
metricMan->sendMetric("PCIe Transfer Rate", hw_data_rate, "B/s", 1, artdaq::MetricMode::Average);

TLOG(TLVL_TRACE + 20) << "Returning true";
TLOG(TLVL_TRACE + 28) << "Returning true";

return true;
}
Expand Down

0 comments on commit c6ef325

Please sign in to comment.