13 #include "fhiclcpp/ParameterSet.h"
25 fAmpThresholdVec = p.get< std::vector<float> >(
"AmplitudeThreshold",std::vector<float>(1,0.0));
30 const unsigned int n_planes = geo.
Nplanes();
35 if(fMatchThresholdVec.size()==0 ||
36 fMergeMultiplicityVec.size()==0 ||
37 fAmpThresholdVec.size()==0)
38 throw std::runtime_error(
"Error in RFFHitFinderAlg: Configured with zero planes.");
40 if( (fMatchThresholdVec.size()>1 && fMatchThresholdVec.size()<n_planes) ||
41 (fMergeMultiplicityVec.size()>1 && fMergeMultiplicityVec.size()<n_planes) ||
42 (fAmpThresholdVec.size()>1 && fAmpThresholdVec.size()<n_planes) )
43 throw std::runtime_error(
"Error in RFFHitFinderAlg: Configured with incorrect n_planes.");
45 if(fMatchThresholdVec.size()==1)
46 fMatchThresholdVec.resize(n_planes,fMatchThresholdVec[0]);
48 if(fMergeMultiplicityVec.size()==1)
49 fMergeMultiplicityVec.resize(n_planes,fMergeMultiplicityVec[0]);
51 if(fAmpThresholdVec.size()==1)
52 fAmpThresholdVec.resize(n_planes,fAmpThresholdVec[0]);
57 fFitter.SetFitterParams(fMatchThresholdVec[p],fMergeMultiplicityVec[p],fAmpThresholdVec[p]);
61 std::vector<recob::Hit>& hitVector,
64 hitVector.reserve(wireVector.size());
65 for(
auto const& wire : wireVector)
70 SetFitterParams(wire.View());
72 for(
auto const& roi : wire.SignalROI().get_ranges())
74 fFitter.RunFitter(roi.data());
76 const float summedADCTotal = std::accumulate(roi.data().begin(),roi.data().end(),0.0);
80 EmplaceHit(hitVector,wire,summedADCTotal,startTick,endTick,sigtype,wireID);
89 float const& summedADCTotal,
94 float totalArea = 0.0;
95 std::vector<float> areaVector(fFitter.NHits());
96 std::vector<float> areaErrorVector(fFitter.NHits());
97 std::vector<float> areaFracVector(fFitter.NHits());
99 for(
size_t ihit=0; ihit < fFitter.NHits(); ihit++){
100 areaVector[ihit] = fFitter.AmplitudeVector()[ihit]*fFitter.SigmaVector()[ihit]*
SQRT_TWO_PI;
101 areaErrorVector[ihit] =
102 SQRT_TWO_PI*std::sqrt(fFitter.AmplitudeVector()[ihit]*fFitter.SigmaErrorVector()[ihit]*fFitter.AmplitudeVector()[ihit]*fFitter.SigmaErrorVector()[ihit] +
103 fFitter.AmplitudeErrorVector()[ihit]*fFitter.SigmaVector()[ihit]*fFitter.AmplitudeErrorVector()[ihit]*fFitter.SigmaVector()[ihit]);
104 totalArea += areaVector[ihit];
107 for(
size_t ihit=0; ihit < fFitter.NHits(); ihit++)
109 areaFracVector[ihit] = areaVector[ihit]/totalArea;
111 hitVector.emplace_back(wire.
Channel(),
114 fFitter.MeanVector()[ihit]+(float)startTick,
115 fFitter.MeanErrorVector()[ihit],
116 fFitter.SigmaVector()[ihit],
117 fFitter.AmplitudeVector()[ihit],
118 fFitter.AmplitudeErrorVector()[ihit],
119 summedADCTotal*areaFracVector[ihit],
121 areaErrorVector[ihit],
void EmplaceHit(std::vector< recob::Hit > &, recob::Wire const &, float const &, raw::TDCtick_t const &, raw::TDCtick_t const &, geo::SigType_t const &, geo::WireID const &)
void Run(std::vector< recob::Wire > const &, std::vector< recob::Hit > &, geo::Geometry const &)
std::vector< geo::WireID > ChannelToWire(raw::ChannelID_t const channel) const
Returns a list of wires connected to the specified TPC channel.
SigType_t SignalType(geo::PlaneID const &pid) const
Returns the type of signal on the channels of specified TPC plane.
void SetFitterParamsVectors(geo::Geometry const &)
int TDCtick_t
Type representing a TDC tick.
geo::View_t View() const
Returns the view the channel belongs to.
unsigned int Nplanes(unsigned int tpc=0, unsigned int cstat=0) const
Returns the total number of wire planes in the specified TPC.
raw::ChannelID_t Channel() const
Returns the ID of the channel (or InvalidChannelID)
enum geo::_plane_sigtype SigType_t
std::vector< float > fAmpThresholdVec
std::vector< float > fMatchThresholdVec
The geometry of one entire detector, as served by art.
RFFHitFinderAlg(fhicl::ParameterSet const &)
std::vector< unsigned int > fMergeMultiplicityVec
void SetFitterParams(unsigned int)
Class holding the regions of interest of signal from a channel.
art framework interface to geometry description