166 std::unique_ptr<sbndaq::CRTmetric> CRTMetricInfo = std::make_unique<sbndaq::CRTmetric>();
169 std::unique_ptr<sbnd::trigger::pmtSoftwareTrigger> pmtSoftwareTriggerMetrics = std::make_unique<sbnd::trigger::pmtSoftwareTrigger>();
180 std::vector<art::Handle<artdaq::Fragments>> fragmentHandles =
evt.getMany<std::vector<artdaq::Fragment>>();
183 for (
auto handle : fragmentHandles) {
184 if (!handle.isValid() || handle->size() == 0)
continue;
189 if (handle->front().type() == artdaq::Fragment::ContainerFragmentType) {
191 for (
auto cont : *handle) {
192 artdaq::ContainerFragment contf(cont);
193 if (contf.fragment_type() == sbndaq::detail::FragmentType::BERNCRTV2){
194 if (
fVerbose)
std::cout <<
" Found " << contf.block_count() <<
" CRT Fragments in container " << std::endl;
203 size_t beamFragmentIdx = -1;
204 for (
auto frag : *handle){
206 if (frag.type()==sbndaq::detail::FragmentType::BERNCRTV2) {
213 if (frag.type()==sbndaq::detail::FragmentType::CAENV1730) {
230 for (
size_t fragmentIdx = beamFragmentIdx; fragmentIdx < beamFragmentIdx+8; fragmentIdx++) {
252 std::cout <<
"CRT hit count during beam spill ";
264 pmtSoftwareTriggerMetrics->foundBeamTrigger =
true;
267 pmtSoftwareTriggerMetrics->triggerTimestamp = triggerTimeStamp;
268 if (
fVerbose)
std::cout <<
"Saving trigger timestamp: " << triggerTimeStamp <<
" ns" << std::endl;
273 int nAboveThreshold = 0;
276 int beamStartBin = (triggerTimeStamp >= 1000)? 0 :
int(500 -
abs((triggerTimeStamp-1000)/2));
280 for (
int i_ch = 0; i_ch < 120; ++i_ch){
292 for (
int bin = beamStartBin;
bin < beamEndBin; ++
bin){
293 auto adc = wvfm[
bin];
299 auto prompt_window = std::vector<uint16_t>(wvfm.begin()+500, wvfm.begin()+1000);
300 auto prelim_window = std::vector<uint16_t>(wvfm.begin()+beamStartBin, wvfm.begin()+500);
302 double ch_promptPE = (baseline-(*std::min_element(prompt_window.begin(), prompt_window.end())))/8;
303 double ch_prelimPE = (baseline-(*std::min_element(prelim_window.begin(), prelim_window.end())))/8;
304 promptPE += ch_promptPE;
305 prelimPE += ch_prelimPE;
311 for (
auto pulse : pmtInfo.pulseVec){
312 if (pulse.t_start > 500 && pulse.t_end < 550) promptPE+=pulse.pe;
313 if ((triggerTimeStamp) >= 1000){
if (pulse.t_end < 500) prelimPE+=pulse.pe; }
314 else if (triggerTimeStamp < 1000){
315 if (pulse.t_start > (500 -
abs((triggerTimeStamp-1000)/2)) && pulse.t_end < 500) prelimPE+=pulse.pe;
321 pmtSoftwareTriggerMetrics->nAboveThreshold = nAboveThreshold;
322 pmtSoftwareTriggerMetrics->promptPE = promptPE;
323 pmtSoftwareTriggerMetrics->prelimPE = prelimPE;
324 if (
fVerbose)
std::cout <<
"nPMTs Above Threshold: " << nAboveThreshold << std::endl;
330 pmtSoftwareTriggerMetrics->foundBeamTrigger =
false;
331 pmtSoftwareTriggerMetrics->triggerTimestamp = -9999;
332 pmtSoftwareTriggerMetrics->nAboveThreshold = -9999;
333 pmtSoftwareTriggerMetrics->promptPE = -9999;
334 pmtSoftwareTriggerMetrics->prelimPE = -9999;
340 evt.put(std::move(CRTMetricInfo));
341 evt.put(std::move(pmtSoftwareTriggerMetrics));
std::vector< unsigned int > channelList
void analyze_crt_fragment(artdaq::Fragment &frag)
std::vector< sbnd::trigger::pmtInfo > fpmtInfoVec
void estimateBaseline(int i_ch)
double fInputBaselineSigma
std::string fBaselineAlgo
constexpr details::BinObj< T > bin(T value)
Returns a wrapper to print the specified data in binary format.
void analyzeCAEN1730Fragment(const artdaq::Fragment &frag)
void checkCAEN1730FragmentTimeStamp(const artdaq::Fragment &frag)
void SimpleThreshAlgo(int i_ch)
art::EventNumber_t fEvent
std::vector< std::vector< uint16_t > > fWvfmsVec
BEGIN_PROLOG could also be cout