DUNE-DAQ
DUNE Trigger and Data Acquisition software
Loading...
Searching...
No Matches
triggeralgs::TCMakerHorizontalMuonAlgorithm Class Reference

#include <TCMakerHorizontalMuonAlgorithm.hpp>

Inheritance diagram for triggeralgs::TCMakerHorizontalMuonAlgorithm:
[legend]
Collaboration diagram for triggeralgs::TCMakerHorizontalMuonAlgorithm:
[legend]

Public Member Functions

void process (const TriggerActivity &, std::vector< TriggerCandidate > &)
 TA processing function that creates & fills TCs.
 
void configure (const nlohmann::json &config)
 
- Public Member Functions inherited from triggeralgs::TriggerCandidateMaker
virtual ~TriggerCandidateMaker ()=default
 
void operator() (const TriggerActivity &input_ta, std::vector< TriggerCandidate > &output_tc)
 
virtual bool preprocess (const TriggerActivity &)
 TA pre-processing/filtering.
 
virtual void postprocess (std::vector< TriggerCandidate > &output_tc)
 Post-processing/filtering of the TCs, e.g. prescale.
 
virtual void flush (timestamp_t, std::vector< TriggerCandidate > &)
 

Private Member Functions

TriggerCandidate construct_tc () const
 
bool check_adjacency () const
 
void add_window_to_record (TAWindow window)
 
void dump_window_record ()
 

Private Attributes

TAWindow m_current_window
 
uint64_t m_activity_count = 0
 
bool m_trigger_on_adc = false
 
bool m_trigger_on_n_channels = false
 
uint32_t m_adc_threshold = 1200000
 
uint16_t m_n_channels_threshold = 600
 
timestamp_t m_window_length = 80000
 
int tc_number = 0
 
std::vector< TAWindowm_window_record
 

Additional Inherited Members

- Public Attributes inherited from triggeralgs::TriggerCandidateMaker
std::atomic< uint64_t > m_data_vs_system_time = 0
 
std::atomic< uint64_t > m_initial_offset = 0
 
uint64_t m_prescale = 1
 Configurable prescale factor.
 
uint64_t m_tc_count = 0
 TC made count for prescaling.
 
TriggerCandidate::Type m_tc_type_out = TriggerCandidate::Type::kUnknown
 Configurable TC type output.
 

Detailed Description

Definition at line 19 of file TCMakerHorizontalMuonAlgorithm.hpp.

Member Function Documentation

◆ add_window_to_record()

void TCMakerHorizontalMuonAlgorithm::add_window_to_record ( TAWindow window)
private

Definition at line 166 of file TCMakerHorizontalMuonAlgorithm.cpp.

167{
168 m_window_record.push_back(window);
169 return;
170}

◆ check_adjacency()

bool TCMakerHorizontalMuonAlgorithm::check_adjacency ( ) const
private

Definition at line 158 of file TCMakerHorizontalMuonAlgorithm.cpp.

159{
160 // FIX ME: An adjacency check on the channels which have hits.
161 return true;
162}

◆ configure()

void TCMakerHorizontalMuonAlgorithm::configure ( const nlohmann::json & config)
virtual

Reimplemented from triggeralgs::TriggerCandidateMaker.

Definition at line 103 of file TCMakerHorizontalMuonAlgorithm.cpp.

104{
106
107 if (config.is_object()) {
108 if (config.contains("trigger_on_adc"))
109 m_trigger_on_adc = config["trigger_on_adc"];
110 if (config.contains("trigger_on_n_channels"))
111 m_trigger_on_n_channels = config["trigger_on_n_channels"];
112 if (config.contains("adc_threshold"))
113 m_adc_threshold = config["adc_threshold"];
114 if (config.contains("n_channels_threshold"))
115 m_n_channels_threshold = config["n_channels_threshold"];
116 if (config.contains("window_length"))
117 m_window_length = config["window_length"];
118 }
120 TLOG_DEBUG(TLVL_VERY_IMPORTANT) << "[TCM:HM] Triggering on ADC count and number of channels is not supported.";
121 throw BadConfiguration(ERS_HERE, TRACE_NAME);
122 }
124 TLOG_DEBUG(TLVL_VERY_IMPORTANT) << "[TCM:HM] Not triggering! All trigger flags are false!";
125 throw BadConfiguration(ERS_HERE, TRACE_NAME);
126 }
127
128 return;
129}
#define ERS_HERE
virtual void configure(const nlohmann::json &config)
#define TLOG_DEBUG(lvl,...)
Definition Logging.hpp:112
#define TRACE_NAME

◆ construct_tc()

TriggerCandidate TCMakerHorizontalMuonAlgorithm::construct_tc ( ) const
private

Definition at line 132 of file TCMakerHorizontalMuonAlgorithm.cpp.

133{
134 TriggerActivity latest_ta_in_window = m_current_window.inputs.back();
135
138 tc.time_end = latest_ta_in_window.inputs.back().time_start;
140 tc.detid = latest_ta_in_window.detid;
141 tc.type = m_tc_type_out;
143
144 // Take the list of triggeralgs::TriggerActivity in the current
145 // window and convert them (implicitly) to detdataformats'
146 // TriggerActivityData, which is the base class of TriggerActivity
147 for (auto& ta : m_current_window.inputs) {
148 tc.inputs.push_back(ta);
149 if (ta.time_end > tc.time_end) {
150 tc.time_end = ta.time_end;
151 }
152 }
153
154 return tc;
155}
timestamp_t time_start
Definition TAWindow.hpp:52
std::vector< TriggerActivity > inputs
Definition TAWindow.hpp:55
TriggerCandidate::Type m_tc_type_out
Configurable TC type output.
std::vector< TriggerPrimitive > inputs
std::vector< dunedaq::trgdataformats::TriggerActivityData > inputs

◆ dump_window_record()

void TCMakerHorizontalMuonAlgorithm::dump_window_record ( )
private

Definition at line 173 of file TCMakerHorizontalMuonAlgorithm.cpp.

174{
175 // FIX ME: Need to index this outfile in the name by detid or something similar.
176 std::ofstream outfile;
177 outfile.open("window_record_tcm.csv", std::ios_base::app);
178
179 for (auto window : m_window_record) {
180 outfile << window.time_start << ",";
181 outfile << window.inputs.back().time_start << ",";
182 outfile << window.inputs.back().time_start - window.time_start << ",";
183 outfile << window.adc_integral << ",";
184 outfile << window.n_channels_hit() << ",";
185 outfile << window.inputs.size() << std::endl;
186 }
187
188 outfile.close();
189
190 m_window_record.clear();
191
192 return;
193}

◆ process()

void TCMakerHorizontalMuonAlgorithm::process ( const TriggerActivity & input_ta,
std::vector< TriggerCandidate > & output_tc )
virtual

TA processing function that creates & fills TCs.

Parameters
input_ta[in]Input TA for the triggering algorithm
output_tc[out]Output vector of TCs to fill by the algorithm

Implements triggeralgs::TriggerCandidateMaker.

Definition at line 24 of file TCMakerHorizontalMuonAlgorithm.cpp.

26{
27
28 std::vector<TriggerActivity::TriggerActivityData> ta_list = { static_cast<TriggerActivity::TriggerActivityData>(
29 activity) };
30
31 // The first time operator is called, reset window object.
33 m_current_window.reset(activity);
35
36 // TriggerCandidate tc = construct_tc();
37 // output_tc.push_back(tc);
38
39 // m_current_window.clear();
40 // return;
41 }
42
43 // If the difference between the current TA's start time and the start of the window
44 // is less than the specified window size, add the TA to the window.
45 else if ((activity.time_start - m_current_window.time_start) < m_window_length) {
46 TLOG_DEBUG(TLVL_DEBUG_HIGH) << "[TCM:HM] Window not yet complete, adding the activity to the window.";
47 m_current_window.add(activity);
48 }
49 // If it is not, move the window along.
50 else {
51 TLOG_DEBUG(TLVL_DEBUG_ALL)
52 << "[TCM:HM] TAWindow is at required length but specified threshold not met, shifting window along.";
54 }
55
56 // If the addition of the current TA to the window would make it longer
57 // than the specified window length, don't add it but check whether the sum of all adc in
58 // the existing window is above the specified threshold. If it is, and we are triggering on ADC,
59 // make a TA and start a fresh window with the current TP.
61 // TLOG_DEBUG(TRACE_NAME) << "ADC integral in window is greater than specified threshold.";
62 TLOG_DEBUG(TLVL_DEBUG_MEDIUM) << "[TCM:HM] m_current_window.adc_integral " << m_current_window.adc_integral
63 << " - m_adc_threshold " << m_adc_threshold;
64 tc_number++;
66 TLOG_DEBUG(TLVL_DEBUG_MEDIUM) << "[TCM:HM] tc.time_start=" << tc.time_start << " tc.time_end=" << tc.time_end
67 << " len(tc.inputs) " << tc.inputs.size();
68
69 for (const auto& ta : tc.inputs) {
70 TLOG_DEBUG(TLVL_DEBUG_ALL) << "[TCM:HM] [TA] ta.time_start=" << ta.time_start << " ta.time_end=" << ta.time_end
71 << " ta.adc_integral=" << ta.adc_integral;
72 }
73
74 output_tc.push_back(tc);
75 // m_current_window.reset(activity);
77 }
78
79 // If the addition of the current TA to the window would make it longer
80 // than the specified window length, don't add it but check whether the number of hit channels in
81 // the existing window is above the specified threshold. If it is, and we are triggering on channels,
82 // make a TC and start a fresh window with the current TA.
84 tc_number++;
85 output_tc.push_back(construct_tc());
86
87 // m_current_window.reset(activity);
89 }
90
91 // // If it is not, move the window along.
92 // else {
93 // // TLOG_DEBUG(TRACE_NAME) << "TAWindow is at required length but specified threshold not met."
94 // // << "shifting window along.";
95 // m_current_window.move(activity, m_window_length);
96 // }
97
99 return;
100}
void clear()
Clear all inputs.
Definition TAWindow.cpp:35
void add(const TriggerActivity &input_ta)
Add the input TA's contribution to the total ADC, increase the hit count of all of the channels which...
Definition TAWindow.cpp:16
bool is_empty() const
Definition TAWindow.hpp:22
void reset(TriggerActivity const &input_ta)
Reset window content on the input.
Definition TAWindow.cpp:79
uint16_t n_channels_hit()
Definition TAWindow.hpp:34
void move(TriggerActivity const &input_ta, timestamp_t const &window_length)
Find all of the TAs in the window that need to be removed if the input_ta is to be added and the size...
Definition TAWindow.cpp:45

Member Data Documentation

◆ m_activity_count

uint64_t triggeralgs::TCMakerHorizontalMuonAlgorithm::m_activity_count = 0
private

Definition at line 33 of file TCMakerHorizontalMuonAlgorithm.hpp.

◆ m_adc_threshold

uint32_t triggeralgs::TCMakerHorizontalMuonAlgorithm::m_adc_threshold = 1200000
private

Definition at line 38 of file TCMakerHorizontalMuonAlgorithm.hpp.

◆ m_current_window

TAWindow triggeralgs::TCMakerHorizontalMuonAlgorithm::m_current_window
private

Definition at line 32 of file TCMakerHorizontalMuonAlgorithm.hpp.

◆ m_n_channels_threshold

uint16_t triggeralgs::TCMakerHorizontalMuonAlgorithm::m_n_channels_threshold = 600
private

Definition at line 39 of file TCMakerHorizontalMuonAlgorithm.hpp.

◆ m_trigger_on_adc

bool triggeralgs::TCMakerHorizontalMuonAlgorithm::m_trigger_on_adc = false
private

Definition at line 36 of file TCMakerHorizontalMuonAlgorithm.hpp.

◆ m_trigger_on_n_channels

bool triggeralgs::TCMakerHorizontalMuonAlgorithm::m_trigger_on_n_channels = false
private

Definition at line 37 of file TCMakerHorizontalMuonAlgorithm.hpp.

◆ m_window_length

timestamp_t triggeralgs::TCMakerHorizontalMuonAlgorithm::m_window_length = 80000
private

Definition at line 40 of file TCMakerHorizontalMuonAlgorithm.hpp.

◆ m_window_record

std::vector<TAWindow> triggeralgs::TCMakerHorizontalMuonAlgorithm::m_window_record
private

Definition at line 46 of file TCMakerHorizontalMuonAlgorithm.hpp.

◆ tc_number

int triggeralgs::TCMakerHorizontalMuonAlgorithm::tc_number = 0
private

Definition at line 41 of file TCMakerHorizontalMuonAlgorithm.hpp.


The documentation for this class was generated from the following files: