18 const int nframes = frames.size();
19 std::vector<double> times(nframes),
ticks(nframes);
20 for (
int ind=0; ind<nframes; ++ind) {
21 times[ind] = frames[ind]->time();
22 ticks[ind] = frames[ind]->tick();
24 auto tick_mm = std::minmax_element(ticks.begin(), ticks.end());
25 if (*tick_mm.first != *tick_mm.second) {
28 const double tick = ticks[0];
29 auto times_mm = std::minmax_element(times.begin(), times.end());
30 const double start_time = *times_mm.first;
35 for (
int ind=0; ind<nframes; ++ind) {
37 const double dt = frame->time() - start_time;
38 const int tbinoff = dt/
tick;
39 for (
auto trace : *frame->traces()) {
40 const int ch =
trace->channel();
41 const int new_tbin = tbinoff +
trace->tbin();
42 index[ch].push_back(make_pair(new_tbin, &(
trace->charge())));
48 for (
auto ctc : index) {
50 auto tcv = ctc.second;
53 const int tbin = tc.first;
54 tbins.push_back(tbin);
55 tbins.push_back(tbin+tc.second->size());
57 auto tbin_mm = std::minmax_element(tbins.begin(), tbins.end());
58 const int trace_tbin = *tbin_mm.first;
59 const int trace_nbins = *tbin_mm.second-trace_tbin;
60 vector<float> charge(trace_nbins, 0.0);
62 int ind = tc.first - trace_tbin;
63 for (
auto q : *tc.second) {
69 out_traces.push_back(trace);
72 return make_shared<SimpleFrame>(ident, start_time, out_traces,
tick);
std::shared_ptr< const IFrame > pointer
std::map< int, std::vector< tbin_charge_t > > channel_index_t
std::vector< pointer > vector
tick ticks
Alias for common language habits.
Binning tbins(nticks, t0, t0+readout_time)
IFrame::pointer sum(std::vector< IFrame::pointer > frames, int ident)
std::pair< int, const std::vector< float > * > tbin_charge_t