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

#include <TAMakerPlaneCoincidenceAlgorithm.hpp>

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

Public Member Functions

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

Private Member Functions

TriggerActivity construct_ta (TPWindow m_current_window) const
 
uint16_t check_adjacency (TPWindow window) const
 
int check_sot (TPWindow m_current_window) const
 
void add_window_to_record (TPWindow window)
 
void dump_window_record ()
 
void dump_tp (TriggerPrimitive const &input_tp)
 

Private Attributes

TPWindow m_current_window
 
uint64_t m_primitive_count = 0
 
TPWindow m_collection_window
 
TPWindow m_induction1_window
 
TPWindow m_induction2_window
 
std::string m_channel_map_name = "VDColdboxTPCChannelMap"
 
uint16_t m_adjacency_threshold = 15
 
int m_max_adjacency = 0
 
uint32_t m_sot_threshold = 2000
 
uint32_t m_adc_threshold = 300000
 
uint16_t m_adj_tolerance = 5
 
int index = 0
 
uint16_t ta_adc = 0
 
uint16_t ta_channels = 0
 
timestamp_t m_window_length = 3000
 
std::shared_ptr< dunedaq::detchannelmaps::TPCChannelMap > channelMap = dunedaq::detchannelmaps::make_tpc_map(m_channel_map_name)
 
std::vector< TPWindowm_window_record
 

Additional Inherited Members

- Public Attributes inherited from triggeralgs::TriggerActivityMaker
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_ta_count = 0
 TA made count for prescaling.
 
uint32_t m_max_samples_over_threshold = std::numeric_limits<uint32_t>::max()
 Time-over-threshold TP filtering.
 

Detailed Description

Definition at line 26 of file TAMakerPlaneCoincidenceAlgorithm.hpp.

Member Function Documentation

◆ add_window_to_record()

void TAMakerPlaneCoincidenceAlgorithm::add_window_to_record ( TPWindow window)
private

Definition at line 204 of file TAMakerPlaneCoincidenceAlgorithm.cpp.

205{
206 m_window_record.push_back(window);
207 return;
208}

◆ check_adjacency()

uint16_t TAMakerPlaneCoincidenceAlgorithm::check_adjacency ( TPWindow window) const
private

Definition at line 142 of file TAMakerPlaneCoincidenceAlgorithm.cpp.

143{
144 /* This function returns the adjacency value for the current window, where adjacency
145 * is defined as the maximum number of consecutive wires containing hits. It accepts
146 * a configurable tolerance paramter, which allows up to adj_tolerance missing hits
147 * on adjacent wires before restarting the adjacency count. */
148
149 uint16_t adj = 1; // Initialise adjacency, 1 for the first wire.
150 uint16_t max = 0; // Maximum adjacency of window, which this function returns
151 unsigned int channel = 0; // Current channel ID
152 unsigned int next_channel = 0; // Next channel ID
153 unsigned int next = 0; // The next position in the hit channels vector
154 unsigned int tol_count = 0; // Tolerance count, should not pass adj_tolerance
155
156 /* Generate a channelID ordered list of hit channels for this window */
157 std::vector<int> chanList;
158 for (auto tp : window.inputs) {
159 chanList.push_back(tp.channel);
160 }
161 std::sort(chanList.begin(), chanList.end());
162
163 /* ADAJACENCY LOGIC ====================================================================
164 * Adjcancency Tolerance = Number of times prepared to skip missed hits before resetting
165 * the adjacency count. This accounts for things like dead channels / missed TPs. */
166 for (size_t i = 0; i < chanList.size(); ++i) {
167
168 next = (i + 1) % chanList.size(); // Loops back when outside of channel list range
169 channel = chanList.at(i);
170 next_channel = chanList.at(next); // Next channel with a hit
171
172 // End of vector condition.
173 if (next_channel == 0) { next_channel = channel - 1; }
174
175 // Skip same channel hits.
176 if (next_channel == channel) { continue; }
177
178 // If next hit is on next channel, increment the adjacency count.
179 else if (next_channel == channel + 1){ ++adj; }
180
181 // If next channel is not on the next hit, but the 'second next', increase adjacency
182 // but also tally up with the tolerance counter.
183 else if ((next_channel == channel + 2 || next_channel == channel + 3) && (tol_count < m_adj_tolerance)) {
184 ++adj;
185 for (size_t i = 0 ; i < next_channel-channel ; ++i) ++tol_count;
186 }
187
188 // If next hit isn't within reach, end the adjacency count and check for a new max.
189 // Reset variables for next iteration.
190 else {
191 if (adj > max) { max = adj; }
192 adj = 1;
193 tol_count = 0;
194 }
195 }
196
197 return max;
198}
std::vector< TriggerPrimitive > inputs
Definition TPWindow.hpp:40

◆ check_sot()

int TAMakerPlaneCoincidenceAlgorithm::check_sot ( TPWindow m_current_window) const
private

Definition at line 259 of file TAMakerPlaneCoincidenceAlgorithm.cpp.

260{
261 // Here, we just want to sum up all the sot values for each TP within window,
262 // and return this sot of the window.
263 int window_sot = 0;
264 for (auto tp : m_current_window.inputs) {
265 window_sot += tp.samples_over_threshold;
266 }
267
268 return window_sot;
269}

◆ configure()

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

Reimplemented from triggeralgs::TriggerActivityMaker.

Definition at line 100 of file TAMakerPlaneCoincidenceAlgorithm.cpp.

101{
103
104 if (config.is_object()) {
105 if (config.contains("adc_threshold"))
106 m_adc_threshold = config["adc_threshold"];
107 if (config.contains("window_length"))
108 m_window_length = config["window_length"];
109 if (config.contains("adjacency_tolerance"))
110 m_adj_tolerance = config["adjacency_tolerance"];
111 if (config.contains("adjacency_threshold"))
112 m_adjacency_threshold = config["adjacency_threshold"];
113 }
114
115}
virtual void configure(const nlohmann::json &config)

◆ construct_ta()

TriggerActivity TAMakerPlaneCoincidenceAlgorithm::construct_ta ( TPWindow m_current_window) const
private

Definition at line 118 of file TAMakerPlaneCoincidenceAlgorithm.cpp.

119{
120
121 TriggerPrimitive latest_tp_in_window = m_current_window.inputs.back();
122
125 ta.time_end = latest_tp_in_window.time_start + latest_tp_in_window.samples_over_threshold * 32; // FIXME: Replace the hard-coded SOT to TOT scaling.
126 ta.time_peak = latest_tp_in_window.samples_to_peak * 32 + latest_tp_in_window.time_start; // FIXME: Replace hard-coded STP to `time_peak` conversion.
127 ta.time_activity = ta.time_peak;
128 ta.channel_start = latest_tp_in_window.channel;
129 ta.channel_end = latest_tp_in_window.channel;
130 ta.channel_peak = latest_tp_in_window.channel;
132 ta.adc_peak = latest_tp_in_window.adc_peak;
133 ta.detid = latest_tp_in_window.detid;
137
138 return ta;
139}
timestamp_t time_start
Definition TPWindow.hpp:37
A single energy deposition on a TPC or PDS channel.
std::vector< TriggerPrimitive > inputs

◆ dump_tp()

void TAMakerPlaneCoincidenceAlgorithm::dump_tp ( TriggerPrimitive const & input_tp)
private

Definition at line 240 of file TAMakerPlaneCoincidenceAlgorithm.cpp.

241{
242 std::ofstream outfile;
243 outfile.open("triggered_coldbox_tps.txt", std::ios_base::app);
244
245 // Output relevant TP information to file
246 outfile << input_tp.time_start << " ";
247 outfile << input_tp.samples_over_threshold << " "; // 50MHz ticks
248 outfile << input_tp.samples_to_peak << " ";
249 outfile << input_tp.channel << " "; // Offline channel ID
250 outfile << input_tp.adc_integral << " ";
251 outfile << input_tp.adc_peak << " ";
252 outfile << input_tp.detid << " "; // Det ID - Identifies detector element
253 outfile.close();
254
255 return;
256}

◆ dump_window_record()

void TAMakerPlaneCoincidenceAlgorithm::dump_window_record ( )
private

Definition at line 212 of file TAMakerPlaneCoincidenceAlgorithm.cpp.

213{
214 std::ofstream outfile;
215 outfile.open("window_record_tam.csv", std::ios_base::app);
216
217 for (auto window : m_window_record) {
218 outfile << window.time_start << ",";
219 outfile << window.inputs.back().time_start << ",";
220 outfile << window.inputs.back().time_start - window.time_start << ",";
221 outfile << window.adc_integral << ",";
222 outfile << window.n_channels_hit() << ","; // Number of unique channels with hits
223 outfile << window.inputs.size() << ","; // Number of TPs in TPWindow
224 outfile << window.inputs.back().channel << ","; // Last TP Channel ID
225 outfile << window.inputs.back().time_start << ","; // Last TP start time
226 outfile << window.inputs.front().channel << ","; // First TP Channel ID
227 outfile << window.inputs.front().time_start << ","; // First TP start time
228 outfile << check_adjacency(window) << ","; // New adjacency value for the window
229 outfile << check_sot(window) << std::endl; // Summed window SOT
230 }
231
232 outfile.close();
233 m_window_record.clear();
234
235 return;
236}

◆ process()

void TAMakerPlaneCoincidenceAlgorithm::process ( const TriggerPrimitive & input_tp,
std::vector< TriggerActivity > & output_ta )
virtual

TP processing function that creates & fills TAs.

Parameters
input_tp[in]Input TP for the triggering algorithm
output_ta[out]Output vector of TAs to fill by the algorithm

Implements triggeralgs::TriggerActivityMaker.

Definition at line 19 of file TAMakerPlaneCoincidenceAlgorithm.cpp.

20{
21
22 // Get the plane from which this hit arrived:
23 // U (induction) = 0, Y (induction) = 1, Z (collection) = 2, unconnected channel = 9999
24 uint plane = channelMap->get_plane_from_offline_channel(input_tp.channel);
25 bool isU = plane == 0; // Induction1 = U
26 bool isY = plane == 1; // Induction2 = Y
27 bool isZ = plane == 2; // Collection = Z
28
29 // The first time operator() is called, reset the window object(s).
30 if (m_induction1_window.is_empty() && isU) { m_induction1_window.reset(input_tp); m_primitive_count++; return; }
31 if (m_induction2_window.is_empty() && isY) { m_induction2_window.reset(input_tp); m_primitive_count++; return; }
32 if (m_collection_window.is_empty() && isZ) { m_collection_window.reset(input_tp); m_primitive_count++; return; }
33
34 // If the difference between the current TP's start time and the start of the window
35 // is less than the specified window size, add the TP to the corresponding window.
39
40 // ISSUE - We are checking the collection plane window too early: Every time we are NOT receiving a collection plane
41 // TP, we're checking the trigger conditions. Fix this immediately and rerun trigger runs to test.
42
43 // ===================================================================================
44 // Below this line, we begin our hierarchy of checks for a low energy event,
45 // taking advantage of the newly gained induction hits window.
46 // ===================================================================================
47
48 // Our windows have ADC Sum, Time Over Threshold, Multiplicity & Adjacency properties.
49 // Take advantage of these to screen the activities passed to more involved checks.
50
51 // 1) REQUIRE ADC SPIKE FROM INDUCTION AND CHECK ADJACENCY ===========================
52 // We're looking for a localised spike of ADC (short time window) and then a short
53 // adjacency corresponding to an electron track/shower.
54
55 // ISSUE - We are checking the collection plane window too early and too frequently probably:
56 // Every time we are NOT receiving a collection plane TP, we're checking the trigger conditions.
57 // Fix this immediately and rerun trigger runs to test.
58 // Introduce bool to check for collection window completeness:
59 bool collectionComplete = (input_tp.time_start - m_collection_window.time_start) > m_window_length;
60 // Then require that the collection window be complete in the adjacency checks
61 if (!collectionComplete) { } // Do nothing
64
65 TLOG_DEBUG(TLVL_DEBUG_MEDIUM) << "[TAM:PC] Emitting low energy trigger with " << m_induction1_window.adc_integral << " U "
66 << m_induction2_window.adc_integral << " Y induction ADC sums and "
67 << check_adjacency(m_collection_window) << " adjacent collection hits.";
68
69 // Initial studies - output the TPs of the collection plane window that caused this trigger
72 m_window_record.clear();
73
74 // Initial studies - Also dump the TPs that have contributed to this TA decision
75 for(auto tp : m_collection_window.inputs) dump_tp(tp);
76
77 // We have fulfilled our trigger condition, construct a TA and reset/flush the windows
78 // to ensure they're all in the same "time zone"!
79 output_ta.push_back(construct_ta(m_collection_window));
80 if (isZ) m_collection_window.reset(input_tp);
82 if (isU) m_induction1_window.reset(input_tp);
84 if (isY) m_induction2_window.reset(input_tp);
86 }
87
88 // Otherwise, slide the relevant window along using the current TP.
89 else {
90 if (isU) m_induction1_window.move(input_tp, m_window_length);
91 else if (isY) m_induction2_window.move(input_tp, m_window_length);
92 else if (isZ) m_collection_window.move(input_tp, m_window_length);
93 }
95
96 return;
97}
std::shared_ptr< dunedaq::detchannelmaps::TPCChannelMap > channelMap
TriggerActivity construct_ta(TPWindow m_current_window) const
void reset(TriggerPrimitive const &input_tp)
Definition TPWindow.cpp:79
void add(TriggerPrimitive const &input_tp)
Definition TPWindow.cpp:20
bool is_empty() const
Definition TPWindow.cpp:14
void move(TriggerPrimitive const &input_tp, timestamp_t const &window_length)
Definition TPWindow.cpp:45
#define TLOG_DEBUG(lvl,...)
Definition Logging.hpp:112

Member Data Documentation

◆ channelMap

std::shared_ptr<dunedaq::detchannelmaps::TPCChannelMap> triggeralgs::TAMakerPlaneCoincidenceAlgorithm::channelMap = dunedaq::detchannelmaps::make_tpc_map(m_channel_map_name)
private

Definition at line 59 of file TAMakerPlaneCoincidenceAlgorithm.hpp.

◆ index

int triggeralgs::TAMakerPlaneCoincidenceAlgorithm::index = 0
private

Definition at line 53 of file TAMakerPlaneCoincidenceAlgorithm.hpp.

◆ m_adc_threshold

uint32_t triggeralgs::TAMakerPlaneCoincidenceAlgorithm::m_adc_threshold = 300000
private

Definition at line 51 of file TAMakerPlaneCoincidenceAlgorithm.hpp.

◆ m_adj_tolerance

uint16_t triggeralgs::TAMakerPlaneCoincidenceAlgorithm::m_adj_tolerance = 5
private

Definition at line 52 of file TAMakerPlaneCoincidenceAlgorithm.hpp.

◆ m_adjacency_threshold

uint16_t triggeralgs::TAMakerPlaneCoincidenceAlgorithm::m_adjacency_threshold = 15
private

Definition at line 48 of file TAMakerPlaneCoincidenceAlgorithm.hpp.

◆ m_channel_map_name

std::string triggeralgs::TAMakerPlaneCoincidenceAlgorithm::m_channel_map_name = "VDColdboxTPCChannelMap"
private

Definition at line 47 of file TAMakerPlaneCoincidenceAlgorithm.hpp.

◆ m_collection_window

TPWindow triggeralgs::TAMakerPlaneCoincidenceAlgorithm::m_collection_window
private

Definition at line 42 of file TAMakerPlaneCoincidenceAlgorithm.hpp.

◆ m_current_window

TPWindow triggeralgs::TAMakerPlaneCoincidenceAlgorithm::m_current_window
private

Definition at line 36 of file TAMakerPlaneCoincidenceAlgorithm.hpp.

◆ m_induction1_window

TPWindow triggeralgs::TAMakerPlaneCoincidenceAlgorithm::m_induction1_window
private

Definition at line 43 of file TAMakerPlaneCoincidenceAlgorithm.hpp.

◆ m_induction2_window

TPWindow triggeralgs::TAMakerPlaneCoincidenceAlgorithm::m_induction2_window
private

Definition at line 44 of file TAMakerPlaneCoincidenceAlgorithm.hpp.

◆ m_max_adjacency

int triggeralgs::TAMakerPlaneCoincidenceAlgorithm::m_max_adjacency = 0
private

Definition at line 49 of file TAMakerPlaneCoincidenceAlgorithm.hpp.

◆ m_primitive_count

uint64_t triggeralgs::TAMakerPlaneCoincidenceAlgorithm::m_primitive_count = 0
private

Definition at line 37 of file TAMakerPlaneCoincidenceAlgorithm.hpp.

◆ m_sot_threshold

uint32_t triggeralgs::TAMakerPlaneCoincidenceAlgorithm::m_sot_threshold = 2000
private

Definition at line 50 of file TAMakerPlaneCoincidenceAlgorithm.hpp.

◆ m_window_length

timestamp_t triggeralgs::TAMakerPlaneCoincidenceAlgorithm::m_window_length = 3000
private

Definition at line 56 of file TAMakerPlaneCoincidenceAlgorithm.hpp.

◆ m_window_record

std::vector<TPWindow> triggeralgs::TAMakerPlaneCoincidenceAlgorithm::m_window_record
private

Definition at line 65 of file TAMakerPlaneCoincidenceAlgorithm.hpp.

◆ ta_adc

uint16_t triggeralgs::TAMakerPlaneCoincidenceAlgorithm::ta_adc = 0
private

Definition at line 54 of file TAMakerPlaneCoincidenceAlgorithm.hpp.

◆ ta_channels

uint16_t triggeralgs::TAMakerPlaneCoincidenceAlgorithm::ta_channels = 0
private

Definition at line 55 of file TAMakerPlaneCoincidenceAlgorithm.hpp.


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