RFFHitFinderAlg.cxx
Go to the documentation of this file.
1 /*!
2  * Title: RFFHitFinderAlg Class
3  * Author: Wes Ketchum (wketchum@lanl.gov)
4  *
5  * Description:
6  * Class that runs the RFF HitFinder. Implements an RFFHitFitter, and takes
7  * the result and stores it in recob::Hit objects.
8  *
9  * Input: recob::Wire
10  * Output: recob::Hit
11 */
12 
13 #include "fhiclcpp/ParameterSet.h"
16 
17 #include "RFFHitFinderAlg.h"
18 
19 #include <numeric>
20 
22 {
23  fMatchThresholdVec = p.get< std::vector<float> >("MeanMatchThreshold");
24  fMergeMultiplicityVec = p.get< std::vector<unsigned int> >("MinMergeMultiplicity");
25  fAmpThresholdVec = p.get< std::vector<float> >("AmplitudeThreshold",std::vector<float>(1,0.0));
26 }
27 
29 {
30  const unsigned int n_planes = geo.Nplanes();
31 
32  //If size zero, throw. If size one, assume same for all planes.
33  //If size > 1 but < n_planes, throw. If size = n_plane, good.
34 
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.");
39 
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.");
44 
45  if(fMatchThresholdVec.size()==1)
46  fMatchThresholdVec.resize(n_planes,fMatchThresholdVec[0]);
47 
48  if(fMergeMultiplicityVec.size()==1)
49  fMergeMultiplicityVec.resize(n_planes,fMergeMultiplicityVec[0]);
50 
51  if(fAmpThresholdVec.size()==1)
52  fAmpThresholdVec.resize(n_planes,fAmpThresholdVec[0]);
53 }
54 
56 {
58 }
59 
60 void hit::RFFHitFinderAlg::Run(std::vector<recob::Wire> const& wireVector,
61  std::vector<recob::Hit>& hitVector,
62  geo::Geometry const& geo)
63 {
64  hitVector.reserve(wireVector.size());
65  for(auto const& wire : wireVector)
66  {
67  geo::SigType_t const& sigtype = geo.SignalType(wire.Channel());
68  geo::WireID const& wireID = geo.ChannelToWire(wire.Channel()).at(0);
69 
70  SetFitterParams(wire.View());
71 
72  for(auto const& roi : wire.SignalROI().get_ranges())
73  {
74  fFitter.RunFitter(roi.data());
75 
76  const float summedADCTotal = std::accumulate(roi.data().begin(),roi.data().end(),0.0);
77  const raw::TDCtick_t startTick = roi.begin_index();
78  const raw::TDCtick_t endTick = roi.begin_index()+roi.size();
79 
80  EmplaceHit(hitVector,wire,summedADCTotal,startTick,endTick,sigtype,wireID);
81  }//end loop over ROIs on wire
82 
83  }//end loop over wires
84 
85 }
86 
87 void hit::RFFHitFinderAlg::EmplaceHit(std::vector<recob::Hit>& hitVector,
88  recob::Wire const& wire,
89  float const& summedADCTotal,
90  raw::TDCtick_t const& startTick, raw::TDCtick_t const& endTick,
91  geo::SigType_t const& sigtype, geo::WireID const& wireID)
92 {
93 
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());
98 
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] =
104  totalArea += areaVector[ihit];
105  }
106 
107  for(size_t ihit=0; ihit < fFitter.NHits(); ihit++)
108  {
109  areaFracVector[ihit] = areaVector[ihit]/totalArea;
110 
111  hitVector.emplace_back(wire.Channel(),
112  startTick,
113  endTick,
114  fFitter.MeanVector()[ihit]+(float)startTick,
115  fFitter.MeanErrorVector()[ihit],
116  fFitter.SigmaVector()[ihit],
117  fFitter.AmplitudeVector()[ihit],
119  summedADCTotal*areaFracVector[ihit],
120  areaVector[ihit],
121  areaErrorVector[ihit],
122  fFitter.NHits(),
123  ihit,
124  -999.,
125  -999,
126  wire.View(),
127  sigtype,
128  wireID);
129  }
130 
131 }
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 &)
const std::vector< float > & AmplitudeVector()
Definition: RFFHitFitter.h:47
void Run(std::vector< recob::Wire > const &, std::vector< recob::Hit > &, geo::Geometry const &)
void RunFitter(const std::vector< float > &signal)
const std::vector< float > & MeanVector()
Definition: RFFHitFitter.h:43
void SetFitterParams(float, unsigned int, float)
const std::vector< float > & SigmaVector()
Definition: RFFHitFitter.h:44
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.
art framework interface to geometry description
void SetFitterParamsVectors(geo::Geometry const &)
int TDCtick_t
Type representing a TDC tick.
Definition: RawTypes.h:25
geo::View_t View() const
Returns the view the channel belongs to.
Definition: Wire.h:230
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)
Definition: Wire.h:231
enum geo::_plane_sigtype SigType_t
std::vector< float > fAmpThresholdVec
std::vector< float > fMatchThresholdVec
T get(std::string const &key) const
Definition: ParameterSet.h:271
p
Definition: test.py:223
The geometry of one entire detector, as served by art.
Definition: Geometry.h:196
const std::vector< float > & MeanErrorVector()
Definition: RFFHitFitter.h:45
RFFHitFinderAlg(fhicl::ParameterSet const &)
std::vector< unsigned int > fMergeMultiplicityVec
void SetFitterParams(unsigned int)
Class holding the regions of interest of signal from a channel.
Definition: Wire.h:118
unsigned int NHits()
Definition: RFFHitFitter.h:49
LArSoft geometry interface.
Definition: ChannelGeo.h:16
const std::vector< float > & AmplitudeErrorVector()
Definition: RFFHitFitter.h:48
const std::vector< float > & SigmaErrorVector()
Definition: RFFHitFitter.h:46