35 #include "art/Framework/Core/EDProducer.h"
36 #include "art/Framework/Core/ModuleMacros.h"
37 #include "art/Framework/Principal/Event.h"
38 #include "art/Utilities/make_tool.h"
39 #include "fhiclcpp/ParameterSet.h"
40 #include "art/Framework/Principal/Handle.h"
41 #include "canvas/Utilities/Exception.h"
58 std::optional<fhicl::ParameterSet>
const& rise_alg_pset)
61 return new T(hit_alg_pset, art::make_tool<pmtana::RiseTimeCalculatorBase>(*rise_alg_pset) );
63 return new T(hit_alg_pset,
nullptr);
110 DEFINE_ART_MODULE(SBNDOpHitFinder)
122 fInputModule = pset.get< std::string >(
"InputModule");
123 fGenModule = pset.get< std::string >(
"GenModule");
124 fInputLabels = pset.get< std::vector< std::string > >(
"InputLabels");
126 for (
auto const& ch : pset.get< std::vector< unsigned int > >
127 (
"ChannelMasks", std::vector< unsigned int >()))
128 fChannelMasks.insert(ch);
130 _pd_to_use = pset.get< std::vector< std::string > >(
"PD", _pd_to_use);
131 fElectronics = pset.get< std::string >(
"Electronics");
134 fDaphne_Freq = pset.get<
float >(
"DaphneFreq");
135 fHitThreshold = pset.get<
float >(
"HitThreshold");
136 bool useCalibrator = pset.get<
bool > (
"UseCalibrator",
false);
138 auto const&
geometry(*lar::providerFrom< geo::Geometry >());
143 fCalib = lar::providerFrom<calib::IPhotonCalibratorService>();
148 bool areaToPE = pset.get<
bool > (
"AreaToPE");
149 float SPEArea = pset.get<
float >(
"SPEArea");
150 float SPEShift = pset.get<
float >(
"SPEShift", 0.);
164 auto const rise_alg_pset = pset.get_if_present<fhicl::ParameterSet>(
"RiseTimeCalculator");
167 auto const hit_alg_pset = pset.get<fhicl::ParameterSet>(
"HitAlgoPset");
168 std::string threshAlgName = hit_alg_pset.get<std::string>(
"Name");
169 if (threshAlgName ==
"Threshold")
170 fThreshAlg = thresholdAlgorithm<pmtana::AlgoThreshold>(hit_alg_pset, rise_alg_pset);
171 else if (threshAlgName ==
"SiPM")
172 fThreshAlg = thresholdAlgorithm<pmtana::AlgoSiPM>(hit_alg_pset, rise_alg_pset);
173 else if (threshAlgName ==
"SlidingWindow")
174 fThreshAlg = thresholdAlgorithm<pmtana::AlgoSlidingWindow>(hit_alg_pset, rise_alg_pset);
175 else if (threshAlgName ==
"FixedWindow")
176 fThreshAlg = thresholdAlgorithm<pmtana::AlgoFixedWindow>(hit_alg_pset, rise_alg_pset);
177 else if (threshAlgName ==
"CFD")
178 fThreshAlg = thresholdAlgorithm<pmtana::AlgoCFD>(hit_alg_pset, rise_alg_pset);
180 throw art::Exception(art::errors::UnimplementedFeature)
181 <<
"Cannot find implementation for " << threshAlgName <<
" algorithm.\n";
184 auto const ped_alg_pset = pset.get< fhicl::ParameterSet >(
"PedAlgoPset");
185 std::string pedAlgName = ped_alg_pset.get< std::string >(
"Name");
186 if (pedAlgName ==
"Edges")
188 else if (pedAlgName ==
"RollingMean")
190 else if (pedAlgName ==
"UB" )
192 else throw art::Exception(art::errors::UnimplementedFeature)
193 <<
"Cannot find implementation for "
194 << pedAlgName <<
" algorithm.\n";
196 produces< std::vector< recob::OpHit > >();
198 fPulseRecoMgr.AddRecoAlgo(fThreshAlg);
199 fPulseRecoMgr.SetDefaultPedAlgo(fPedAlg);
218 std::unique_ptr< std::vector< recob::OpHit > >
219 HitPtrFinal(
new std::vector< recob::OpHit >);
222 std::unique_ptr< std::vector< recob::OpHit > >
223 HitPtr(
new std::vector< recob::OpHit >);
225 std::vector< const sim::BeamGateInfo* > beamGateArray;
228 evt.getView(fGenModule, beamGateArray);
230 catch (art::Exception
const&
err)
232 if ( err.categoryCode() != art::errors::ProductNotFound )
throw;
235 auto const&
geometry(*lar::providerFrom< geo::Geometry >());
236 auto const clockData_CAEN = art::ServiceHandle<detinfo::DetectorClocksService>()->DataFor(evt);
237 auto const& calibrator(*
fCalib);
239 clockData_CAEN.OpticalClock().FramePeriod(),
242 clockData_CAEN.TriggerOffsetTPC(),
243 clockData_CAEN.TriggerTime(),
244 clockData_CAEN.BeamGateTime(),
245 clockData_CAEN.TPCClock(),
246 optical_clock_daphne,
247 clockData_CAEN.TriggerClock(),
248 clockData_CAEN.ExternalClock());
256 if(
fChannelMasks.empty() && _opch_to_use.empty() && fInputLabels.size()<2) {
257 art::Handle< std::vector< raw::OpDetWaveform > > wfHandle;
258 if(fInputLabels.empty())
261 evt.getByLabel(
fInputModule, fInputLabels.front(), wfHandle);
262 assert(wfHandle.isValid());
275 for (
auto label : fInputLabels)
277 art::Handle< std::vector< raw::OpDetWaveform > > wfHandle;
279 if (!wfHandle.isValid())
continue;
280 totalsize += wfHandle->size();
283 std::vector< raw::OpDetWaveform > WaveformVector;
284 WaveformVector.reserve(totalsize);
286 for (
auto label : fInputLabels)
288 art::Handle< std::vector< raw::OpDetWaveform > > wfHandle;
290 if (!wfHandle.isValid())
continue;
292 for(
auto const& wf : *wfHandle)
297 if ( std::find(_opch_to_use.begin(), _opch_to_use.end(), wf.ChannelNumber()) == _opch_to_use.end() )
continue;
299 WaveformVector.push_back(wf);
320 for (
auto h : *HitPtr) {
321 (*HitPtrFinal).emplace_back(
h.OpChannel(),
322 h.PeakTime() + clockData.TriggerTime(),
324 h.StartTime() + clockData.TriggerTime(),
334 evt.put(std::move(HitPtrFinal));
340 std::vector<int> out_ch_v;
342 for (
auto name : pd_names) {
343 std::vector<int> ch_v;
346 if (fElectronics==
"Daphne"){
352 out_ch_v.insert(out_ch_v.end(), ch_v.begin(), ch_v.end());
std::vector< std::string > fInputLabels
Utilities related to art service access.
const geo::GeometryCore * geometry
std::vector< int > PDNamesToList(std::vector< std::string >)
std::set< unsigned int > fChannelMasks
EResult err(const char *call)
std::vector< int > _opch_to_use
List of of opch (will be infered from _pd_to_use)
SBNDOpHitFinder(const fhicl::ParameterSet &)
calib::IPhotonCalibrator const * fCalib
std::vector< double > GetSPEScales()
std::vector< int > PDNamesToList(std::vector< std::string > pd_names)
unsigned int fMaxOpChannel
BEGIN_PROLOG xarapuca_vuv SBNDDecoOpHitFinderXArapuca SPEArea
std::vector< double > GetSPEShifts()
Class definition file of PedAlgoRollingMean.
Class definition file of AlgoCFD.
opdet::sbndPDMapAlg _pds_map
map for photon detector types
virtual ~SBNDOpHitFinder()
Class definition file of PedAlgoUB.
unsigned int MaxOpChannel() const
Largest optical channel number.
std::vector< int > getChannelsOfType(std::string pdname) const
pmtana::PMTPulseRecoBase * fThreshAlg
Class definition file of AlgoFixedWindow.
Contains all timing reference information for the detector.
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.
std::map< int, int > GetChannelMap()
pmtana::PulseRecoManager fPulseRecoMgr
Class definition file of PMTPulseRecoBase.
pmtana::PMTPedestalBase * fPedAlg
Class definition file of PedAlgoEdges.
Class representing the time measured by an electronics clock.
std::vector< std::string > _pd_to_use
PDS to use (ex: "pmt", "barepmt")
void produce(art::Event &)
art framework interface to geometry description
Class definition file of PulseRecoManager.
std::string fElectronics
PDS readouts to use (ex: "CAEN", "Daphne")