7 if(configfile!=
"") m_variables.Initialise(configfile);
14 bool use_stopwatch =
false;
15 m_variables.Get(
"use_stopwatch", use_stopwatch);
25 double temp_trigger_search_window;
26 double temp_trigger_search_window_step;
27 double temp_trigger_save_window_pre;
28 double temp_trigger_save_window_post;
30 m_variables.Get(
"trigger_search_window", temp_trigger_search_window);
31 m_variables.Get(
"trigger_search_window_step", temp_trigger_search_window_step);
33 m_variables.Get(
"pretrigger_save_window", temp_trigger_save_window_pre);
34 m_variables.Get(
"posttrigger_save_window", temp_trigger_save_window_post);
42 bool adjust_for_noise;
43 m_variables.Get(
"trigger_threshold_adjust_for_noise", adjust_for_noise);
44 int npmts =
m_trigger_OD ? m_data->ODNPMTs : m_data->IDNPMTs;
45 double dark_rate_kHZ =
m_trigger_OD ? m_data->ODPMTDarkRate : m_data->IDPMTDarkRate;
47 double dark_rate_Hz = dark_rate_kHZ * 1000;
48 double average_occupancy = dark_rate_Hz * trigger_window_seconds * npmts;
51 <<
"ns window with a dark noise rate of " << dark_rate_kHZ
52 <<
"kHz is " << average_occupancy
53 <<
" (" << npmts <<
" total PMTs)";
58 if(adjust_for_noise) {
66 std::string ParameterFile;
68 m_variables.Get(
"ParameterFile",ParameterFile);
73 m_time_int.reserve(2*(
int)average_occupancy);
90 std::vector<SubSample> & samples =
m_trigger_OD ? (m_data->ODSamples) : (m_data->IDSamples);
92 m_ss <<
" Number of data samples " << samples.size();
95 for( std::vector<SubSample>::iterator is=samples.begin(); is!=samples.end(); ++is){
98 std::vector<int> trigger_ns;
99 std::vector<int> trigger_ts;
101 for(
unsigned int i = 0; i < is->m_time.size(); i++) {
102 m_time_int.push_back(is->m_time[i]);
105 for(
int i=0; i<trigger_ns.size(); i++){
106 m_data->IDTriggers.AddTrigger(kTriggerNDigits,
111 TimeDelta(trigger_ts[i]) + is->m_timestamp,
112 std::vector<float>(1, trigger_ns[i]));
114 m_ss <<
"trigger! time " << trigger_ts[i] <<
" nhits " << trigger_ns[i];
StreamToLog(
INFO);
118 if (not is->IsSortedByTime()){
128 for( std::vector<SubSample>::iterator is=samples.begin(); is!=samples.end(); ++is) {
129 (*is).TellMeAboutTheTriggers(m_data->IDTriggers,
m_verbose);
142 const unsigned int ndigits = sample->
m_time.size();
143 m_ss <<
"DEBUG: NHits::AlgNDigits(). Number of entries in input digit collection: " << ndigits;
153 int first_digit_in_window = 0;
154 for(;current_digit < ndigits; ++current_digit) {
159 ++first_digit_in_window;
163 int digit_time = (int)sample->
m_time.at(current_digit);
165 ++first_digit_in_window;
171 int n_digits_in_window = current_digit - first_digit_in_window + 1;
179 m_ss <<
"DEBUG: Found NHits trigger in SubSample at " << triggertime;
185 if (current_digit >= ndigits){
191 int n_digits = current_digit - first_digit_in_window + 1;
192 m_ss <<
"DEBUG: Number of digits between (trigger_time - trigger_search_window) and (trigger_time + posttrigger_save_window):" << n_digits;
197 triggertime + m_trigger_save_window_post,
201 std::vector<float>(1, n_digits));
206 <<
" NDigit trigger(s) from " << (
m_trigger_OD ?
"OD" :
"ID")
void AlgNDigits(const SubSample *samples)
CPU version of the NDigits algorithm.
std::string Result(std::string method_name, std::string output_file="")
float short_time_t
Type for relative hit times within a SubSample. Unit = ns.
TimeDelta m_trigger_mask_window_post
Post-trigger time for masking digits from future tools.
void Start()
Start the stopwatch.
bool Initialise(std::string configfile, DataModel &data)
StopwatchTimes Stop()
Stop the stopwatch, returning the CPU time.
TimeDelta m_trigger_mask_window_pre
Pre-trigger time for masking digits from future tools.
util::Stopwatch * m_stopwatch
The stopwatch, if we're using one.
TimeDelta m_trigger_search_window
Width of the sliding window.
std::string m_stopwatch_file
Image filename to save the histogram to, if required.
bool m_trigger_OD
Trigger on OD digits, rather than ID digits?
void AddTrigger(TriggerType_t type, double starttime, double endtime, double triggertime, std::vector< float > info)
Add a trigger, all times in ns.
TimeDelta m_trigger_save_window_post
Post-trigger time for saving digits.
static const TimeDelta ns
TimeDelta of 1 ns.
int nhits_initialize_ToolDAQ(std::string ParameterFile, int nPMTs, int fTriggerSearchWindow, int fTriggerSearchWindowStep, int fTriggerThreshold, int fTriggerSaveWindowPre, int fTriggerSaveWindowPost)
void StreamToLog(int level)
TimeDelta AbsoluteDigitTime(int index) const
Return the absolute time (timestamp + digit time) of a digit.
unsigned int m_trigger_threshold
Trigger threshold - number of digits must be above this value (equal to does not fire the trigger) ...
void Log(const std::string &message, const int message_level)
Format messages in the same way as for tools.
std::vector< TimeDelta::short_time_t > m_time
Vector of hit times relative to timestamp for all hits in SubSample. Unit: ns.
TimeDelta m_trigger_save_window_pre
Pre-trigger time for saving digits.
static const TimeDelta s
TimeDelta of 1 s.
bool m_degrade_CPU
degrade data type from float to int
unsigned int m_num_triggers
The number of triggers.