10#include "TRACE/trace.h"
11#define TRACE_NAME "TAMakerPlaneCoincidenceAlgorithm"
16using Logging::TLVL_DEBUG_MEDIUM;
25 bool isU = plane == 0;
26 bool isY = plane == 1;
27 bool isZ = plane == 2;
61 if (!collectionComplete) { }
104 if (config.is_object()) {
105 if (config.contains(
"adc_threshold"))
107 if (config.contains(
"window_length"))
109 if (config.contains(
"adjacency_tolerance"))
111 if (config.contains(
"adjacency_threshold"))
151 unsigned int channel = 0;
152 unsigned int next_channel = 0;
153 unsigned int next = 0;
154 unsigned int tol_count = 0;
157 std::vector<int> chanList;
158 for (
auto tp : window.
inputs) {
159 chanList.push_back(tp.channel);
161 std::sort(chanList.begin(), chanList.end());
166 for (
size_t i = 0; i < chanList.size(); ++i) {
168 next = (i + 1) % chanList.size();
169 channel = chanList.at(i);
170 next_channel = chanList.at(next);
173 if (next_channel == 0) { next_channel = channel - 1; }
176 if (next_channel == channel) {
continue; }
179 else if (next_channel == channel + 1){ ++adj; }
183 else if ((next_channel == channel + 2 || next_channel == channel + 3) && (tol_count <
m_adj_tolerance)) {
185 for (
size_t i = 0 ; i < next_channel-channel ; ++i) ++tol_count;
191 if (adj > max) { max = adj; }
214 std::ofstream outfile;
215 outfile.open(
"window_record_tam.csv", std::ios_base::app);
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() <<
",";
223 outfile << window.inputs.size() <<
",";
224 outfile << window.inputs.back().channel <<
",";
225 outfile << window.inputs.back().time_start <<
",";
226 outfile << window.inputs.front().channel <<
",";
227 outfile << window.inputs.front().time_start <<
",";
229 outfile <<
check_sot(window) << std::endl;
242 std::ofstream outfile;
243 outfile.open(
"triggered_coldbox_tps.txt", std::ios_base::app);
249 outfile << input_tp.
channel <<
" ";
251 outfile << input_tp.
adc_peak <<
" ";
252 outfile << input_tp.
detid <<
" ";
265 window_sot += tp.samples_over_threshold;
#define REGISTER_TRIGGER_ACTIVITY_MAKER(tam_name, tam_class)
timestamp_t m_window_length
std::shared_ptr< dunedaq::detchannelmaps::TPCChannelMap > channelMap
uint16_t m_adjacency_threshold
void dump_tp(TriggerPrimitive const &input_tp)
TPWindow m_induction1_window
uint64_t m_primitive_count
void configure(const nlohmann::json &config)
uint16_t check_adjacency(TPWindow window) const
TriggerActivity construct_ta(TPWindow m_current_window) const
TPWindow m_induction2_window
int check_sot(TPWindow m_current_window) const
void dump_window_record()
void add_window_to_record(TPWindow window)
std::vector< TPWindow > m_window_record
TPWindow m_current_window
void process(const TriggerPrimitive &input_tp, std::vector< TriggerActivity > &output_ta)
TP processing function that creates & fills TAs.
TPWindow m_collection_window
void reset(TriggerPrimitive const &input_tp)
void add(TriggerPrimitive const &input_tp)
std::vector< TriggerPrimitive > inputs
void move(TriggerPrimitive const &input_tp, timestamp_t const &window_length)
virtual void configure(const nlohmann::json &config)
#define TLOG_DEBUG(lvl,...)
std::vector< TriggerPrimitive > inputs