20 #include "art/Framework/Core/EDProducer.h"
21 #include "art/Framework/Core/ModuleMacros.h"
22 #include "art/Framework/Principal/Event.h"
23 #include "art/Framework/Principal/Handle.h"
24 #include "art/Framework/Principal/Run.h"
25 #include "art/Framework/Principal/SubRun.h"
26 #include "art/Utilities/make_tool.h"
28 #include "canvas/Utilities/InputTag.h"
29 #include "fhiclcpp/ParameterSet.h"
30 #include "messagefacility/MessageLogger/MessageLogger.h"
38 class PMTFlashTriggerMaker;
54 void produce(art::Event&
e)
override;
65 std::vector<sbn::FlashTriggerPrimitive>
68 std::pair<double, double> &window,
75 fWaveformLabel(
p.get<std::string>(
"WaveformLabel")),
76 fExperiment(
p.get<std::string>(
"Experiment")),
77 fTriggerWindow({
p.get<
float>(
"TriggerStart"),
p.get<
float>(
"TriggerEnd")}),
79 fOffsetTriggerTime(
p.get<
bool>(
"OffsetTriggerTime"))
81 produces< std::vector<sbn::FlashTriggerPrimitive> >();
83 fPDMapAlgPtr = art::make_tool<opdet::PDMapAlg>(
p.get<fhicl::ParameterSet>(
"PDMapAlg"));
89 auto const clock_data = art::ServiceHandle<detinfo::DetectorClocksService const>()->DataFor(e);
91 std::unique_ptr<std::vector<sbn::FlashTriggerPrimitive>> trigs(
new std::vector<sbn::FlashTriggerPrimitive>);
93 art::Handle<std::vector<raw::OpDetWaveform>> waveform_handle;
94 e.getByLabel(fWaveformLabel, waveform_handle);
96 std::pair<double, double> window = fTriggerWindow;
98 if (fOffsetTriggerTime) {
99 float offset = clock_data.TriggerTime();
104 if (waveform_handle.isValid()) {
105 const std::vector<raw::OpDetWaveform> &waveforms = *waveform_handle;
106 double tick_period = clock_data.OpticalClock().TickPeriod();
112 e.put(std::move(trigs));
117 std::pair<double, double> &window,
119 std::vector<sbn::FlashTriggerPrimitive> ret;
123 bool is_pmt =
fPDMapAlgPtr->pdType(wvf.ChannelNumber()) ==
"pmt";
125 if (!is_pmt)
continue;
128 double waveform_start = wvf.TimeStamp();
129 int waveform_index_start = std::max((
int)((window.first - waveform_start) / tick_period), 0);
130 int waveform_index_end = std::min((
int)((window.second - waveform_start) / tick_period), (
int) wvf.size());
132 if (waveform_index_start < waveform_index_end) {
134 prim.
channel = wvf.ChannelNumber();
135 for (
int i = waveform_index_start; i < waveform_index_end; i++) {
136 if (wvf[i] <= thresh) {
BEGIN_PROLOG TPC Trig offset(g4 rise time) ProjectToHeight
PMTFlashTriggerMaker(fhicl::ParameterSet const &p)
Utilities related to art service access.
std::vector< FlashTriggerPrimitive > TriggerPrimitives(const std::vector< raw::OpDetWaveform > &waveforms, double tick_period, std::pair< double, double > &window, int thresh, bool is_sbnd)
art::InputTag fWaveformLabel
std::vector< sbn::FlashTriggerPrimitive > TriggerPrimitives(const std::vector< raw::OpDetWaveform > &waveforms, double tick_period, std::pair< double, double > &window, int thresh)
This is the interface class for a tool to handle PD mapping in SBN detectors, used for flash matching...
std::vector< Trig > triggers
fTriggerThreshold(p.get< int >("TriggerThreshold"))
std::pair< double, double > fTriggerWindow
void produce(art::Event &e) override
std::unique_ptr< opdet::PDMapAlg > fPDMapAlgPtr
PMTFlashTriggerMaker & operator=(PMTFlashTriggerMaker const &)=delete