10 #include "art/Framework/Core/EDFilter.h"
11 #include "art/Framework/Core/ModuleMacros.h"
12 #include "art/Framework/Principal/Event.h"
13 #include "art/Framework/Principal/Handle.h"
14 #include "art/Framework/Principal/Run.h"
15 #include "art/Framework/Principal/SubRun.h"
16 #include "canvas/Utilities/InputTag.h"
17 #include "fhiclcpp/ParameterSet.h"
18 #include "messagefacility/MessageLogger/MessageLogger.h"
28 class PMTFlashTriggerFilter;
45 bool filter(art::Event&
e)
override;
54 bool HasTrigger(
const std::vector<FlashTriggerPrimitive> &primitives,
int threshold,
unsigned n_above_threshold);
60 fFlashTriggerPrimitiveLabel(
p.get<std::string>(
"FlashTriggerPrimitiveLabel")),
61 fNPMTAboveThreshold(
p.get<
unsigned>(
"NPMTAboveThreshold")),
62 fPMTTriggerThreshold(
p.get<
int>(
"PMTTriggerThreshold")),
63 fStoreDataProduct(
p.get<
bool>(
"StoreDataProduct",
false))
67 if (fStoreDataProduct) produces<bool>();
72 art::Handle<std::vector<sbn::FlashTriggerPrimitive>> flashtrig_handle;
73 e.getByLabel(fFlashTriggerPrimitiveLabel, flashtrig_handle);
76 if (flashtrig_handle.isValid()) {
77 ret =
HasTrigger(*flashtrig_handle, fPMTTriggerThreshold, fNPMTAboveThreshold);
80 if (fStoreDataProduct) {
81 std::unique_ptr<bool>
store(
new bool);
83 e.put(std::move(store));
90 if (n_above_threshold == 0)
return true;
92 std::map<int, std::vector<unsigned>> above_threshold;
96 if (trig.
adc <= threshold) {
97 above_threshold[trig.
tdc].push_back(primitive.channel);
102 for (
auto const &pair: above_threshold) {
103 if (pair.second.size() >= n_above_threshold) {
process_name opflash opflashana store
art::InputTag fFlashTriggerPrimitiveLabel
bool filter(art::Event &e) override
PMTFlashTriggerFilter(fhicl::ParameterSet const &p)
bool HasTrigger(const std::vector< FlashTriggerPrimitive > &primitives, int threshold, unsigned n_above_threshold)
PMTFlashTriggerFilter & operator=(PMTFlashTriggerFilter const &)=delete
unsigned fNPMTAboveThreshold
bool HasTrigger(const std::vector< FlashTriggerPrimitive > &primitives, int threshold, unsigned n_above_threshold)