7 #include <unordered_map> 8 #include <unordered_set> 16 auto traces = frame->traces();
19 const double tref = frame->time();
20 const double tick = frame->tick();
21 const double tmin = tref + tbin_mm.first*
tick;
22 const double tmax = tref + tbin_mm.second*
tick;
36 return std::pair<IFrame::pointer, IFrame::pointer>(frame,
nullptr);
39 return std::pair<IFrame::pointer, IFrame::pointer>(
nullptr, frame);
43 const double tref = frame->time();
44 const double tick = frame->tick();
45 const int ident = frame->ident();
48 const double fnticks = (time - tref)/tick;
49 const int tbin_split = 0.5 + fnticks;
53 for (
auto trace : (*frame->traces())) {
54 const int tbin =
trace->tbin();
56 if (tbin >= tbin_split) {
57 ptraces.push_back(
trace);
62 const int lbin = tbin + wave.size();
64 if (lbin <= tbin_split) {
65 mtraces.push_back(
trace);
68 const int ind_split = tbin_split - tbin;
72 const int chid =
trace->channel();
74 auto mtrace = std::make_shared<SimpleTrace>(chid, tbin, mcharge);
75 mtraces.push_back(mtrace);
76 auto ptrace = std::make_shared<SimpleTrace>(chid, tbin_split, pcharge);
77 ptraces.push_back(ptrace);
82 return std::pair<IFrame::pointer, IFrame::pointer>(mframe, pframe);
92 auto traces = frame->traces();
93 size_t ntraces = traces->size();
95 std::unordered_set<size_t> tagged;
96 for (
auto tag : frame->trace_tags()) {
97 const auto& taglist = frame->tagged_traces(
tag);
98 tagged.insert(taglist.begin(), taglist.end());
100 std::vector<size_t>
all(ntraces), untagged;
101 std::iota(
all.begin(),
all.end(), 0);
102 std::set_difference(
all.begin(),
all.end(), tagged.begin(), tagged.end(),
103 std::inserter(untagged, untagged.begin()));
105 for (
size_t ind : untagged) {
106 ret.push_back(traces->at(ind));
117 auto const& all_traces = frame->traces();
118 for (
size_t index : frame->tagged_traces(tag)) {
119 ret.push_back(all_traces->at(
index));
124 auto ftags = frame->frame_tags();
125 if (
std::find(ftags.begin(), ftags.end(), tag) == ftags.end()) {
134 const auto nchans = traces.size();
136 for (
size_t ind=0; ind != nchans; ++ind) {
137 ret[ind] = traces[ind]->channel();
145 const auto siz = traces.size();
146 std::vector<int>
tbins(siz), tlens(siz);
147 for (
size_t ind=0; ind != siz; ++ind) {
148 const auto trace = traces[ind];
149 const int tbin =
trace->tbin();
151 tlens[ind] = tbin+
trace->charge().size();
153 return std::pair<int,int>(
154 *std::min_element(
tbins.begin(),
tbins.end()),
155 *std::max_element(tlens.begin(), tlens.end()));
164 std::unordered_map<int,int>
index;
168 const int ncols = array.cols();
170 for (
int ind = 0; ind != nrows and chit != chend; ++ind, ++chit) {
173 for (
const auto trace : traces) {
176 const int ch =
trace->channel();
177 auto it = index.find(ch);
178 if (it == index.end()) {
181 const int irow = it->second;
183 const auto& charge =
trace->charge();
184 const int nticks = charge.size();
185 const int dtbin =
trace->tbin() - tbin;
186 int icol0 = 0, itick0 = 0;
194 const int ncols_left = ncols - icol0;
195 const int nticks_left = nticks - itick0;
196 if (ncols_left <= 0 or nticks_left <= 0) {
199 const int nleft =
std::min(ncols_left, nticks_left);
200 for (
int ind=0; ind != nleft; ++ind) {
201 array(irow, icol0+ind) += charge.at(itick0 + ind);
std::shared_ptr< const IFrame > pointer
std::vector< pointer > vector
Binning tbins(nticks, t0, t0+readout_time)
auto array(Array const &a)
Returns a manipulator which will print the specified array.
double distance(double x1, double y1, double z1, double x2, double y2, double z2)
static QInternalList< QTextCodec > * all
T min(sqlite3 *const db, std::string const &table_name, std::string const &column_name)
FMT_CONSTEXPR bool find(Ptr first, Ptr last, T value, Ptr &out)
unsigned nrows(sqlite3 *db, std::string const &tablename)
std::vector< float > ChargeSequence
Sequential collection of charge.
Eigen::ArrayXXf array_xxf
A real, 2D array.