/*! Summarize the mc hits */ struct hits_summary { int nhits; // number of mc hits double atot; // total amplitude charge of all mc hits double tmin,tmax; // time of earliest / lastest hit int ndoms; // number of DOMs with hits int nlines; // number of lines with hits }; template bool fill( Det& det, hits_summary& s, vector hits , F selection ) { s.nhits = 0; s.atot=0; s.tmin=1e100; s.tmax=-1e100; set doms; set lines; for (auto& h : hits ) { if (!selection(h) ) continue; s.atot += h.tot; s.nhits ++; if ( h.t < s.tmin ) s.tmin = h.t; if ( h.t > s.tmax ) s.tmax = h.t; doms.insert( h.dom_id ); lines.insert( det.doms[ h.dom_id].line_id ); } s.nlines = lines.size(); s.ndoms = doms.size(); return true; } /*! Summarize and then delete the MC hits */ bool summarize_hits( Det& det, Evt& evt , hits_summary& sum , string what = "hits") { if ( what == "hits") return fill( det, sum, evt.hits, [](Hit& h) { return true ;} ); else if ( what == "trig_hits") return fill( det, sum, evt.hits, [](Hit& h) { return h.trig != 0; } ); else if ( what == "mc_hits" ) return fill( det, sum, evt.mc_hits, [](Hit& h) { return true ;} ); else fatal("programming error in summarize_hits", what); return false; }