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

#include <TCMakerMichelElectronAlgorithm.hpp>

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

Classes

class  Window
 

Public Member Functions

void process (const TriggerActivity &, std::vector< TriggerCandidate > &)
 The function that gets call when there is a new activity.
 
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 (Window window)
 
void dump_window_record ()
 

Private Attributes

Window 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< Windowm_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 20 of file TCMakerMichelElectronAlgorithm.hpp.

Member Function Documentation

◆ add_window_to_record()

void TCMakerMichelElectronAlgorithm::add_window_to_record ( Window window)
private

Definition at line 162 of file TCMakerMichelElectronAlgorithm.cpp.

163{
164 m_window_record.push_back(window);
165 return;
166}

◆ check_adjacency()

bool TCMakerMichelElectronAlgorithm::check_adjacency ( ) const
private

Definition at line 154 of file TCMakerMichelElectronAlgorithm.cpp.

155{
156 // FIX ME: An adjacency check on the channels which have hits.
157 return true;
158}

◆ configure()

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

Reimplemented from triggeralgs::TriggerCandidateMaker.

Definition at line 101 of file TCMakerMichelElectronAlgorithm.cpp.

102{
104
105 // FIX ME: Use some schema here. Also can't work out how to pass booleans.
106 if (config.is_object()) {
107 if (config.contains("trigger_on_adc"))
108 m_trigger_on_adc = config["trigger_on_adc"];
109 if (config.contains("trigger_on_n_channels"))
110 m_trigger_on_n_channels = config["trigger_on_n_channels"];
111 if (config.contains("adc_threshold"))
112 m_adc_threshold = config["adc_threshold"];
113 if (config.contains("n_channels_threshold"))
114 m_n_channels_threshold = config["n_channels_threshold"];
115 if (config.contains("window_length"))
116 m_window_length = config["window_length"];
117 // if (config.contains("channel_map")) m_channel_map = config["channel_map"];
118 }
120 TLOG_DEBUG(TLVL_VERY_IMPORTANT) << "[TCM:ME] Triggering on ADC count and number of channels is not supported.";
121 throw BadConfiguration(ERS_HERE, TRACE_NAME);
122 }
124 TLOG_DEBUG(TLVL_DEBUG_LOW) << "[TCM:ME] Both trigger flags are false. Passing TAs through 1:1.";
125 }
126
127 return;
128}
#define ERS_HERE
virtual void configure(const nlohmann::json &config)
#define TLOG_DEBUG(lvl,...)
Definition Logging.hpp:112
#define TRACE_NAME

◆ construct_tc()

TriggerCandidate TCMakerMichelElectronAlgorithm::construct_tc ( ) const
private

Definition at line 131 of file TCMakerMichelElectronAlgorithm.cpp.

132{
133 TriggerActivity latest_ta_in_window = m_current_window.inputs.back();
134
137 tc.time_end = latest_ta_in_window.time_end;
139 tc.detid = latest_ta_in_window.detid;
140 tc.type = m_tc_type_out;
142
143 // Take the list of triggeralgs::TriggerActivity in the current
144 // window and convert them (implicitly) to detdataformats'
145 // TriggerActivityData, which is the base class of TriggerActivity
146 for (auto& ta : m_current_window.inputs) {
147 tc.inputs.push_back(ta);
148 }
149
150 return tc;
151}
TriggerCandidate::Type m_tc_type_out
Configurable TC type output.
std::vector< dunedaq::trgdataformats::TriggerActivityData > inputs

◆ dump_window_record()

void TCMakerMichelElectronAlgorithm::dump_window_record ( )
private

Definition at line 169 of file TCMakerMichelElectronAlgorithm.cpp.

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

◆ process()

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

The function that gets call when there is a new activity.

Implements triggeralgs::TriggerCandidateMaker.

Definition at line 25 of file TCMakerMichelElectronAlgorithm.cpp.

27{
28
29 std::vector<TriggerActivity::TriggerActivityData> ta_list = { static_cast<TriggerActivity::TriggerActivityData>(
30 activity) };
31
32 // The first time process() is called, reset window object.
34 m_current_window.reset(activity);
36 // Trivial TC Logic:
37 // If the request has been made to not trigger on number of channels or
38 // total adc, simply construct a trigger candidate from any single activity.
40
41 // add_window_to_record(m_current_window);
42 // dump_window_record();
43 TLOG_DEBUG(TLVL_DEBUG_LOW) << "[TCM:ME] Constructing TC.";
44
46 output_tc.push_back(tc);
47
48 // Clear the current window (only has a single TA in it)
50 }
51 return;
52 }
53
54 // FIX ME: Only want to call this if running in debug mode.
55 // add_window_to_record(m_current_window);
56
57 // If the difference between the current TA's start time and the start of the window
58 // is less than the specified window size, add the TA to the window.
60 TLOG_DEBUG(TLVL_DEBUG_HIGH) << "[TCM:ME] Window not yet complete, adding the activity to the window.";
61 m_current_window.add(activity);
62 }
63 // If the addition of the current TA to the window would make it longer
64 // than the specified window length, don't add it but check whether the sum of all adc in
65 // the existing window is above the specified threshold. If it is, and we are triggering on ADC,
66 // make a TA and start a fresh window with the current TP.
68 TLOG_DEBUG(TLVL_DEBUG_LOW) << "[TCM:ME] ADC integral in window is greater than specified threshold.";
70
71 output_tc.push_back(tc);
72 TLOG_DEBUG(TLVL_DEBUG_HIGH) << "[TCM:ME] Resetting window with activity.";
73 m_current_window.reset(activity);
74 }
75 // If the addition of the current TA to the window would make it longer
76 // than the specified window length, don't add it but check whether the number of hit channels in
77 // the existing window is above the specified threshold. If it is, and we are triggering on channels,
78 // make a TC and start a fresh window with the current TA.
80 tc_number++;
81 // output_tc.push_back(construct_tc());
82 m_current_window.reset(activity);
83 TLOG_DEBUG(TLVL_DEBUG_INFO) << "[TCM:ME] Should not see this!";
84 }
85 // If it is not, move the window along.
86 else {
87 TLOG_DEBUG(TLVL_DEBUG_HIGH) << "[TCM:ME] Window is at required length but specified threshold not met, shifting window along.";
89 }
90
91 //TLOG_DEBUG(TLVL_DEBUG_ALL) << "[TCM:ME] " m_current_window;
92
94
95 // if(m_activity_count % 500 == 0) dump_window_record();
96
97 return;
98}
void move(TriggerActivity const &input_ta, timestamp_t const &window_length)

Member Data Documentation

◆ m_activity_count

uint64_t triggeralgs::TCMakerMichelElectronAlgorithm::m_activity_count = 0
private

Definition at line 128 of file TCMakerMichelElectronAlgorithm.hpp.

◆ m_adc_threshold

uint32_t triggeralgs::TCMakerMichelElectronAlgorithm::m_adc_threshold = 1200000
private

Definition at line 138 of file TCMakerMichelElectronAlgorithm.hpp.

◆ m_current_window

Window triggeralgs::TCMakerMichelElectronAlgorithm::m_current_window
private

Definition at line 127 of file TCMakerMichelElectronAlgorithm.hpp.

◆ m_n_channels_threshold

uint16_t triggeralgs::TCMakerMichelElectronAlgorithm::m_n_channels_threshold = 600
private

Definition at line 139 of file TCMakerMichelElectronAlgorithm.hpp.

◆ m_trigger_on_adc

bool triggeralgs::TCMakerMichelElectronAlgorithm::m_trigger_on_adc = false
private

Definition at line 136 of file TCMakerMichelElectronAlgorithm.hpp.

◆ m_trigger_on_n_channels

bool triggeralgs::TCMakerMichelElectronAlgorithm::m_trigger_on_n_channels = false
private

Definition at line 137 of file TCMakerMichelElectronAlgorithm.hpp.

◆ m_window_length

timestamp_t triggeralgs::TCMakerMichelElectronAlgorithm::m_window_length = 80000
private

Definition at line 140 of file TCMakerMichelElectronAlgorithm.hpp.

◆ m_window_record

std::vector<Window> triggeralgs::TCMakerMichelElectronAlgorithm::m_window_record
private

Definition at line 148 of file TCMakerMichelElectronAlgorithm.hpp.

◆ tc_number

int triggeralgs::TCMakerMichelElectronAlgorithm::tc_number = 0
private

Definition at line 141 of file TCMakerMichelElectronAlgorithm.hpp.


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