34 #include "art/Framework/Core/EDProducer.h"
35 #include "art/Framework/Core/ModuleMacros.h"
36 #include "art/Framework/Principal/Event.h"
37 #include "art/Framework/Principal/Handle.h"
38 #include "art/Utilities/make_tool.h"
39 #include "canvas/Utilities/Exception.h"
40 #include "fhiclcpp/ParameterSet.h"
52 std::optional<fhicl::ParameterSet>
const& rise_alg_pset)
55 return new T(hit_alg_pset, art::make_tool<pmtana::RiseTimeCalculatorBase>(*rise_alg_pset) );
57 return new T(hit_alg_pset,
nullptr);
97 DEFINE_ART_MODULE(OpHitFinder)
107 fInputModule = pset.get<std::string>(
"InputModule");
108 fGenModule = pset.get<std::string>(
"GenModule");
109 fInputLabels = pset.get<std::vector<std::string>>(
"InputLabels");
110 fUseStartTime = pset.get<
bool>(
"UseStartTime",
false);
112 for (
auto const& ch :
113 pset.get<std::vector<unsigned int>>(
"ChannelMasks", std::vector<unsigned int>()))
114 fChannelMasks.insert(ch);
116 fHitThreshold = pset.get<
float>(
"HitThreshold");
117 bool useCalibrator = pset.get<
bool>(
"UseCalibrator",
false);
119 auto const&
geometry(*lar::providerFrom<geo::Geometry>());
124 fCalib = lar::providerFrom<calib::IPhotonCalibratorService>();
129 bool areaToPE = pset.get<
bool>(
"AreaToPE");
130 float SPEArea = pset.get<
float>(
"SPEArea");
131 float SPEShift = pset.get<
float>(
"SPEShift", 0.);
137 if (fCalib) {
delete fCalib; }
143 auto const rise_alg_pset = pset.get_if_present<fhicl::ParameterSet>(
"RiseTimeCalculator");
146 auto const hit_alg_pset = pset.get<fhicl::ParameterSet>(
"HitAlgoPset");
147 std::string threshAlgName = hit_alg_pset.get<std::string>(
"Name");
148 if (threshAlgName ==
"Threshold")
149 fThreshAlg = thresholdAlgorithm<pmtana::AlgoThreshold>(hit_alg_pset, rise_alg_pset);
150 else if (threshAlgName ==
"SiPM")
151 fThreshAlg = thresholdAlgorithm<pmtana::AlgoSiPM>(hit_alg_pset, rise_alg_pset);
152 else if (threshAlgName ==
"SlidingWindow")
153 fThreshAlg = thresholdAlgorithm<pmtana::AlgoSlidingWindow>(hit_alg_pset, rise_alg_pset);
154 else if (threshAlgName ==
"FixedWindow")
155 fThreshAlg = thresholdAlgorithm<pmtana::AlgoFixedWindow>(hit_alg_pset, rise_alg_pset);
156 else if (threshAlgName ==
"CFD")
157 fThreshAlg = thresholdAlgorithm<pmtana::AlgoCFD>(hit_alg_pset, rise_alg_pset);
159 throw art::Exception(art::errors::UnimplementedFeature)
160 <<
"Cannot find implementation for " << threshAlgName <<
" algorithm.\n";
163 auto const ped_alg_pset = pset.get<fhicl::ParameterSet>(
"PedAlgoPset");
164 std::string pedAlgName = ped_alg_pset.get<std::string>(
"Name");
165 if (pedAlgName ==
"Edges")
167 else if (pedAlgName ==
"RollingMean")
169 else if (pedAlgName ==
"UB")
172 throw art::Exception(art::errors::UnimplementedFeature)
173 <<
"Cannot find implementation for " << pedAlgName <<
" algorithm.\n";
175 produces<std::vector<recob::OpHit>>();
177 fPulseRecoMgr.AddRecoAlgo(fThreshAlg);
178 fPulseRecoMgr.SetDefaultPedAlgo(fPedAlg);
196 std::unique_ptr<std::vector<recob::OpHit>> HitPtr(
new std::vector<recob::OpHit>);
198 std::vector<const sim::BeamGateInfo*> beamGateArray;
200 evt.getView(fGenModule, beamGateArray);
202 catch (art::Exception
const&
err) {
203 if (err.categoryCode() != art::errors::ProductNotFound)
throw;
206 auto const&
geometry(*lar::providerFrom<geo::Geometry>());
207 auto const clock_data =
208 art::ServiceHandle<detinfo::DetectorClocksService const>()->DataFor(evt);
209 auto const& calibrator(*
fCalib);
216 art::Handle<std::vector<raw::OpDetWaveform>> wfHandle;
217 if (fInputLabels.empty())
220 evt.getByLabel(
fInputModule, fInputLabels.front(), wfHandle);
221 assert(wfHandle.isValid());
236 for (
auto label : fInputLabels) {
237 art::Handle<std::vector<raw::OpDetWaveform>> wfHandle;
239 if (!wfHandle.isValid())
continue;
240 totalsize += wfHandle->size();
243 std::vector<raw::OpDetWaveform> WaveformVector;
244 WaveformVector.reserve(totalsize);
246 for (
auto label : fInputLabels) {
247 art::Handle<std::vector<raw::OpDetWaveform>> wfHandle;
249 if (!wfHandle.isValid())
continue;
253 for (
auto const& wf : *wfHandle) {
255 WaveformVector.push_back(wf);
270 evt.put(std::move(HitPtr));
Utilities related to art service access.
const geo::GeometryCore * geometry
unsigned int fMaxOpChannel
std::map< int, int > GetChannelMap()
EResult err(const char *call)
OpHitFinder(const fhicl::ParameterSet &)
std::set< unsigned int > fChannelMasks
BEGIN_PROLOG xarapuca_vuv SBNDDecoOpHitFinderXArapuca SPEArea
Class definition file of PedAlgoRollingMean.
Class definition file of AlgoCFD.
std::vector< double > GetSPEShifts()
Class definition file of PedAlgoUB.
unsigned int MaxOpChannel() const
Largest optical channel number.
pmtana::PMTPulseRecoBase * fThreshAlg
void produce(art::Event &)
Class definition file of AlgoFixedWindow.
calib::IPhotonCalibrator const * fCalib
void RunHitFinder(std::vector< raw::OpDetWaveform > const &opDetWaveformVector, std::vector< recob::OpHit > &hitVector, pmtana::PulseRecoManager const &pulseRecoMgr, pmtana::PMTPulseRecoBase const &threshAlg, geo::GeometryCore const &geometry, float hitThreshold, detinfo::DetectorClocksData const &clocksData, calib::IPhotonCalibrator const &calibrator, bool use_start_time)
Class definition file of AlgoSlidingWindow.
Class definition file of AlgoThreshold.
pmtana::PulseRecoManager fPulseRecoMgr
std::vector< double > GetSPEScales()
Class definition file of PMTPulseRecoBase.
Class definition file of PedAlgoEdges.
std::vector< std::string > fInputLabels
art framework interface to geometry description
pmtana::PMTPedestalBase * fPedAlg
Class definition file of PulseRecoManager.