Skip to content

Commit

Permalink
Merge pull request #179 from DUNE-DAQ/cbatchelor/completeness_tolerance
Browse files Browse the repository at this point in the history
Fixes and enhancements for patch/v3.2.x VDCB tests
  • Loading branch information
wesketchum authored Feb 1, 2023
2 parents 98a008b + 787a5bb commit 702d5d4
Show file tree
Hide file tree
Showing 8 changed files with 87 additions and 11 deletions.
6 changes: 6 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,12 @@ daq_add_plugin(TriggerCandidateMakerPrescalePlugin duneTCMaker LINK_LIBRARIES tr
daq_add_plugin(TriggerActivityMakerSupernovaPlugin duneTAMaker LINK_LIBRARIES trigger)
daq_add_plugin(TriggerCandidateMakerSupernovaPlugin duneTCMaker LINK_LIBRARIES trigger)
daq_add_plugin(TriggerDecisionMakerSupernovaPlugin duneTDMaker LINK_LIBRARIES trigger)
daq_add_plugin(TriggerActivityMakerLowEnergyEventPlugin duneTAMaker LINK_LIBRARIES trigger)
daq_add_plugin(TriggerCandidateMakerLowEnergyEventPlugin duneTCMaker LINK_LIBRARIES trigger)
daq_add_plugin(TriggerActivityMakerMichelElectronPlugin duneTAMaker LINK_LIBRARIES trigger)
daq_add_plugin(TriggerCandidateMakerMichelElectronPlugin duneTCMaker LINK_LIBRARIES trigger)
# daq_add_plugin(TriggerActivityMakerDBSCANPlugin duneTAMaker LINK_LIBRARIES trigger)


##############################################################################
# Integration tests
Expand Down
12 changes: 12 additions & 0 deletions plugins/TriggerActivityMakerLowEnergyEventPlugin.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/**
* @file TriggerActivityMakerLowEnergyEvent.cpp
*
* This is part of the DUNE DAQ Application Framework, copyright 2020.
* Licensing/copyright details are in the COPYING file that you should have
* received with this code.
*/

#include "trigger/AlgorithmPlugins.hpp"
#include "triggeralgs/LowEnergyEvent/TriggerActivityMakerLowEnergyEvent.hpp"

DEFINE_DUNE_TA_MAKER(triggeralgs::TriggerActivityMakerLowEnergyEvent)
12 changes: 12 additions & 0 deletions plugins/TriggerActivityMakerMichelElectronPlugin.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/**
* @file TriggerActivityMakerMichelElectron.cpp
*
* This is part of the DUNE DAQ Application Framework, copyright 2020.
* Licensing/copyright details are in the COPYING file that you should have
* received with this code.
*/

#include "trigger/AlgorithmPlugins.hpp"
#include "triggeralgs/MichelElectron/TriggerActivityMakerMichelElectron.hpp"

DEFINE_DUNE_TA_MAKER(triggeralgs::TriggerActivityMakerMichelElectron)
12 changes: 12 additions & 0 deletions plugins/TriggerCandidateMakerLowEnergyEventPlugin.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/**
* @file TriggerCandidateMakerLowEnergyEvent.cpp
*
* This is part of the DUNE DAQ Application Framework, copyright 2020.
* Licensing/copyright details are in the COPYING file that you should have
* received with this code.
*/

#include "trigger/AlgorithmPlugins.hpp"
#include "triggeralgs/LowEnergyEvent/TriggerCandidateMakerLowEnergyEvent.hpp"

DEFINE_DUNE_TC_MAKER(triggeralgs::TriggerCandidateMakerLowEnergyEvent)
12 changes: 12 additions & 0 deletions plugins/TriggerCandidateMakerMichelElectronPlugin.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/**
* @file TriggerCandidateMakerMichelElectron.cpp
*
* This is part of the DUNE DAQ Application Framework, copyright 2020.
* Licensing/copyright details are in the COPYING file that you should have
* received with this code.
*/

#include "trigger/AlgorithmPlugins.hpp"
#include "triggeralgs/MichelElectron/TriggerCandidateMakerMichelElectron.hpp"

DEFINE_DUNE_TC_MAKER(triggeralgs::TriggerCandidateMakerMichelElectron)
2 changes: 2 additions & 0 deletions plugins/TriggerZipper.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,8 @@ class TriggerZipper : public dunedaq::appfwk::DAQModule
m_cfg = cfgobj.get<cfg_t>();
m_zm.set_max_latency(std::chrono::milliseconds(m_cfg.max_latency_ms));
m_zm.set_cardinality(m_cfg.cardinality);
m_zm.set_tolerance(m_cfg.completeness_tolerance);
m_zm.set_tolerate_incompleteness(m_cfg.tolerate_incompleteness);
}

void do_scrap(const nlohmann::json& /*stopobj*/)
Expand Down
36 changes: 25 additions & 11 deletions plugins/zipper.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#include <functional>
#include <unordered_map>
#include <stdexcept>
#include <iostream>

namespace zipper {

Expand Down Expand Up @@ -113,7 +114,9 @@ class merge : public std::priority_queue<Node, std::vector<Node>, std::greater<N
considered complete and thus will exhibit permanent
undefined behavior as described above.
*/
void set_cardinality(size_t k) { cardinality = k; }
void set_cardinality(size_t k) { cardinality = k; }
void set_tolerance(size_t t) { completeness_tolerance = t; }
void set_tolerate_incompleteness(bool b) { tolerate_incompleteness = b; }

/**
Set the maximum latency
Expand Down Expand Up @@ -258,11 +261,19 @@ class merge : public std::priority_queue<Node, std::vector<Node>, std::greater<N
return false;
}

const size_t target_cardinality = streams.size();

if (target_cardinality < cardinality) { // absent streams
if (latency == duration_t::zero()) { // unbound latency
return false;
}
}

size_t completeness = 0;

const auto top_ident = this->top().identity;

// check each stream to see if it is "represented"
// check each known stream to see if it is "represented"
for (const auto& sit : streams) {
const auto& ident = sit.first;
auto have = sit.second.occupancy;
Expand All @@ -276,9 +287,7 @@ class merge : public std::priority_queue<Node, std::vector<Node>, std::greater<N
continue; // stream is represented
}

// check last ditch check where latency
// bounding allows us to ignore stale streams.

// unbound latency, wait as long as needed
if (latency == duration_t::zero()) {
// std::cerr << "no latency " << ident << std::endl;
return false;
Expand Down Expand Up @@ -309,18 +318,23 @@ class merge : public std::priority_queue<Node, std::vector<Node>, std::greater<N
++completeness;
}

// Currently, the cardinality is set to 2 even when there is
// only 1 (active) input stream during FW TP Generation. We'll temporarily
// reduce the cardinality condition to see if this resolves FW TPG
// runs, and then if it does, rethink the cardinality/completeness
// logic.
return completeness >= cardinality;
// If we are choosing to tolerate "incompleteness", then check we are within the
// configurable tolerance level, and return a "pseudo-complete" state.
auto d = cardinality - completeness;
if(tolerate_incompleteness && (completeness < target_cardinality) && d<=completeness_tolerance){
return true;
}

// Otherwise, completeness has been achieved.
return completeness >= target_cardinality;
}

private:
size_t cardinality;
duration_t latency{ 0 };
ordering_t origin;
bool tolerate_incompleteness = false;
size_t completeness_tolerance = 1;
struct Stream
{
size_t occupancy{ 0 };
Expand Down
6 changes: 6 additions & 0 deletions schema/trigger/triggerzipper.jsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ local hier = {
// doc="Maximum time in milliseconds to wait to send output"),
card: s.number("Count", dtype='u8'),
delay: s.number("Delay", dtype='u8'),
tolerance: s.number("Tolerance", dtype='u8'),
bool: s.boolean("Boolean"),

// fixme: this should be factored, not copy-pasted
element_id : s.number("ElementId", "u4"),
Expand All @@ -20,6 +22,10 @@ local hier = {
doc="Max bound on latency, zero for unbound but lossless"),
s.field("element_id", hier.element_id,
doc="The element of output"),
s.field("tolerate_incompleteness", hier.bool, false,
doc="Bool to configure whether or not we will tolerate incompleteness of active TSET queues."),
s.field("completeness_tolerance", hier.tolerance, 1,
doc="Maximum number of inactive TSET queues we are willing to tolerate."),
], doc="TriggerZipper configuration"),


Expand Down

0 comments on commit 702d5d4

Please sign in to comment.