Skip to content
Snippets Groups Projects
Commit bc7b6e36 authored by Miller, Ross's avatar Miller, Ross
Browse files

Minor changes to how data is parsed

Change how the TOPAZ listener calculated the indexes in the event list
to work around a problem with event_catcher sending out bad data.

Add a log message for cases where we have to discard the events in the
packet.

Also, we only need to add to the PROTON_CHARGE time series once per
pulse, not once per event.

Refs #11315
parent 9458f9cb
No related branches found
No related tags found
No related merge requests found
...@@ -364,7 +364,7 @@ void TOPAZLiveEventDataListener::run() { ...@@ -364,7 +364,7 @@ void TOPAZLiveEventDataListener::run() {
g_log.debug() << "Received UDP Packet. " << bytesRead << " bytes " g_log.debug() << "Received UDP Packet. " << bytesRead << " bytes "
<< num_pulse_ids << " pulses " << num_events << num_pulse_ids << " pulses " << num_events
<< " events\n" << std::endl; << " events" << std::endl;
PULSE_ID_PTR pid = (PULSE_ID_PTR)(m_udpBuf + sizeof(COMMAND_HEADER)); PULSE_ID_PTR pid = (PULSE_ID_PTR)(m_udpBuf + sizeof(COMMAND_HEADER));
NEUTRON_EVENT_PTR events = NEUTRON_EVENT_PTR events =
...@@ -379,8 +379,20 @@ void TOPAZLiveEventDataListener::run() { ...@@ -379,8 +379,20 @@ void TOPAZLiveEventDataListener::run() {
g_log.debug() << " Charge: " << pid[i].charge << std::endl; g_log.debug() << " Charge: " << pid[i].charge << std::endl;
// Figure out the event indexes that belong to this pulse // Figure out the event indexes that belong to this pulse
unsigned long firstEvent = pid[i].eventID; unsigned long firstEvent;
unsigned long lastEvent; unsigned long lastEvent;
if (num_pulse_ids == 1)
{
// This 'if' test is something of a workaround for a problem
// we saw on the beamline: event_catcher was spewing
// eventID's that were much too high.
firstEvent = 0;
}
else
{
firstEvent = pid[i].eventID;
}
if (i == num_pulse_ids - 1) // last pulse in the packet? if (i == num_pulse_ids - 1) // last pulse in the packet?
{ {
lastEvent = num_events - 1; lastEvent = num_events - 1;
...@@ -399,19 +411,28 @@ void TOPAZLiveEventDataListener::run() { ...@@ -399,19 +411,28 @@ void TOPAZLiveEventDataListener::run() {
Mantid::Kernel::DateAndTime eventTime = timeFromPulse(&pid[i]); Mantid::Kernel::DateAndTime eventTime = timeFromPulse(&pid[i]);
Poco::ScopedLock<Poco::FastMutex> scopedLock(m_mutex); Poco::ScopedLock<Poco::FastMutex> scopedLock(m_mutex);
for (unsigned long j = firstEvent; j <= lastEvent; j++) // Save the pulse charge in the logs
{ // TODO: We're not sure what the units are on the charge value
// Save the pulse charge in the logs // They *might* be picoCoulombs, or the might be units of 10pC
// TODO: We're not sure what the units are on the charge value // (in which case we need to multiply by 10 because the
// They *might* be picoCoulombs, or the might be units of 10pC // property is definitely in picoCoulombs.)
// (in which case we need to multiply by 10 because the m_eventBuffer->mutableRun()
// property is definitely in picoCoulombs.)
m_eventBuffer->mutableRun()
.getTimeSeriesProperty<double>(PROTON_CHARGE_PROPERTY) .getTimeSeriesProperty<double>(PROTON_CHARGE_PROPERTY)
->addValue(eventTime, pid[i].charge); ->addValue(eventTime, pid[i].charge);
if (firstEvent > lastEvent)
{
g_log.error() << "Invalid event indexes! firstEvent: " << firstEvent
<< " lastEvent: " << lastEvent << std::endl;
g_log.error() << "No events will be processed!" << std::endl;
}
for (unsigned long j = firstEvent; j <= lastEvent; j++)
{
// appendEvent needs tof to be in units of microseconds, but // appendEvent needs tof to be in units of microseconds, but
// it comes from the ADARA stream in units of 100ns. // it comes from the ADARA stream in units of 100ns.
// TODO: We're not using the ADARA stream! Verify that event_catcher also
// uses 100ns.
appendEvent(events[j].pixelId, events[j].tof / 10.0, eventTime); appendEvent(events[j].pixelId, events[j].tof / 10.0, eventTime);
} }
} // TODO: Verify that the mutex is unlocked when we go back to } // TODO: Verify that the mutex is unlocked when we go back to
......
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