15 if (charge.size() == 0){
16 charge = std::vector<float>(PMTid.size(), 0.);
25 const std::vector<int> empty;
37 std::vector<int> save_triggers;
41 for (i = 1; i <
m_PMTid.size(); ++i) {
47 for (j = i; j > 0 &&
m_time[j-1] > save_time; j--) {
64 for (
int i=0; i<size-1; ++i){
76 return std::vector<SubSample>(1, *
this);
82 return std::vector<SubSample>();
86 TimeDelta target_stride = target_width - target_overlap;
89 std::vector<SubSample> split_samples;
92 std::vector<float> temp_charge;
93 std::vector<int> temp_PMTid;
94 std::vector<TimeDelta::short_time_t> temp_time;
100 temp_timestamp -= target_stride;
104 temp_timestamp += target_stride;
108 int ihit_first_unique = 0, ihit_first = 0;
109 for (
int i = 0; i <
m_time.size(); ++i){
111 if (time_in_window < target_width){
115 temp_PMTid.push_back(
m_PMTid[i]);
120 new_sample.
Append(temp_PMTid, temp_time, temp_charge, temp_timestamp);
122 split_samples.push_back(new_sample);
123 ihit_first_unique = i;
130 temp_timestamp += target_stride;
143 new_sample.
Append(temp_PMTid, temp_time, temp_charge, temp_timestamp);
145 split_samples.push_back(new_sample);
147 return split_samples;
159 bool SubSample::Append(
const std::vector<int> PMTid,
const std::vector<TimeDelta::short_time_t> time,
const std::vector<float> charge,
const TimeDelta timestamp){
160 if (not (PMTid.size() == time.size() && PMTid.size() == charge.size())){
173 for (
int i=0; i<time.size(); ++i){
174 m_time.push_back(time[i] + time_shift);
179 const std::vector<int> empty;
195 std::vector<util::Window> readout_windows(num_triggers -
m_start_trigger);
196 std::vector<util::Window> mask_windows(num_triggers -
m_start_trigger);
199 std::stringstream ss;
200 for(
unsigned int itrigger =
m_start_trigger; itrigger < num_triggers; itrigger++) {
210 ss <<
"DEBUG: Trigger: " << itrigger
211 <<
"\tReadout windows: " << readout_windows[itrigger].
m_start
212 <<
"\t" << readout_windows[itrigger].m_end
213 <<
"\tMask windows: " << mask_windows[itrigger].m_start
214 <<
"\t" << mask_windows[itrigger].m_end;
231 for(
unsigned int itrigger = 0; itrigger < readout_windows.size(); itrigger++) {
232 ss <<
"DEBUG: Trigger: " << itrigger
233 <<
"\tReadout windows: " << readout_windows[itrigger].m_start
234 <<
"\t" << readout_windows[itrigger].m_end
235 <<
"\tMask windows: " << mask_windows[itrigger].m_start
236 <<
"\t" << mask_windows[itrigger].m_end;
248 for(
size_t ihit = 0; ihit <
n_hits; ihit++) {
251 for(std::vector<util::Window>::reverse_iterator it = readout_windows.rbegin();
252 it != readout_windows.rend(); ++it) {
254 ss <<
"DEBUG: READOUT " << (*it).m_start <<
"\t" << (*it).m_end <<
"\t" << (*it).m_trigger_num;
258 if(hit_time < (*it).m_start) {
260 ss <<
"DEBUG: Hit time " << hit_time <<
" earlier than all subsequent trigger readouts";
266 else if (hit_time > (*it).m_end) {
268 ss <<
"DEBUG: Hit time " << hit_time <<
" later than last trigger window. Removing last window from readout vector";
271 readout_windows.pop_back();
276 ss <<
"DEBUG: Hit time " << hit_time <<
" in trigger readout window " << (*it).m_trigger_num;
283 for(std::vector<util::Window>::reverse_iterator it = mask_windows.rbegin();
284 it != mask_windows.rend(); ++it) {
286 ss <<
"DEBUG: MASK " << (*it).m_start <<
"\t" << (*it).m_end <<
"\t" << (*it).m_trigger_num;
290 if(hit_time < (*it).m_start) {
292 ss <<
"DEBUG: Hit time " << hit_time <<
" earlier than all subsequent trigger masks";
298 else if (hit_time > (*it).m_end) {
300 ss <<
"DEBUG: Hit time " << hit_time <<
" later than last trigger window. Removing last window from mask vector";
303 mask_windows.pop_back();
308 ss <<
"DEBUG: Hit time " << hit_time <<
" in trigger mask window " << (*it).m_trigger_num;
Contains the start and end of a time window, along with an ID (nominally trigger number) ...
unsigned int m_first_unique
Position of the first hit that isn't overlapping with the previous SubSample.
void SortByTime()
Sort all digits in the SubSample by their time.
float short_time_t
Type for relative hit times within a SubSample. Unit = ns.
std::vector< SubSample > Split(TimeDelta target_width, TimeDelta target_overlap) const
bool Append(const SubSample &sub)
std::vector< int > m_PMTid
Vector of PMT IDs for all hits in SubSample.
std::vector< TimeDelta > m_readout_end_time
The ending time of the trigger window.
int m_start_trigger
Which trigger are we starting from in TellMeAboutTheTriggers()?
static bool WindowSorter(const Window &lhs, const Window &rhs)
When sorting Window structs, sort by the start time.
std::vector< float > m_charge
Vector of charges for all hits in SubSample. Unit: photoelectrons (MC), calibrated photoelectrons (da...
std::vector< TimeDelta > m_mask_end_time
The ending time of the hit mask.
TimeDelta m_timestamp
Timestamp of the whole SubSample.
std::vector< TimeDelta > m_mask_start_time
The starting time of the hit mask.
static const TimeDelta ns
TimeDelta of 1 ns.
TimeDelta AbsoluteDigitTime(int index) const
Return the absolute time (timestamp + digit time) of a digit.
std::vector< TimeDelta > m_readout_start_time
The starting time of the trigger window.
std::vector< std::vector< int > > m_trigger_readout_windows
Stores the trigger readout windows each hit is associated with.
bool IsSortedByTime() const
Check whether all hits are in time order.
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.
std::vector< bool > m_masked
Is each hit masked from future trigger decisions?
void TellMeAboutTheTriggers(const TriggerInfo &triggers, const int verbose)
unsigned int m_num_triggers
The number of triggers.