LArSoft  v06_85_00
Liquid Argon Software toolkit - http://larsoft.org/
RFFHitFinderAlg.cxx
Go to the documentation of this file.
1 
13 #include "RFFHitFinderAlg.h"
14 #include <numeric>
15 
17 {
18  fMatchThresholdVec = p.get< std::vector<float> >("MeanMatchThreshold");
19  fMergeMultiplicityVec = p.get< std::vector<unsigned int> >("MinMergeMultiplicity");
20  fAmpThresholdVec = p.get< std::vector<float> >("AmplitudeThreshold",std::vector<float>(1,0.0));
21 }
22 
24 {
25  const unsigned int n_planes = geo.Nplanes();
26 
27  //If size zero, throw. If size one, assume same for all planes.
28  //If size > 1 but < n_planes, throw. If size = n_plane, good.
29 
30  if(fMatchThresholdVec.size()==0 ||
31  fMergeMultiplicityVec.size()==0 ||
32  fAmpThresholdVec.size()==0)
33  throw std::runtime_error("Error in RFFHitFinderAlg: Configured with zero planes.");
34 
35  if( (fMatchThresholdVec.size()>1 && fMatchThresholdVec.size()<n_planes) ||
36  (fMergeMultiplicityVec.size()>1 && fMergeMultiplicityVec.size()<n_planes) ||
37  (fAmpThresholdVec.size()>1 && fAmpThresholdVec.size()<n_planes) )
38  throw std::runtime_error("Error in RFFHitFinderAlg: Configured with incorrect n_planes.");
39 
40  if(fMatchThresholdVec.size()==1)
41  fMatchThresholdVec.resize(n_planes,fMatchThresholdVec[0]);
42 
43  if(fMergeMultiplicityVec.size()==1)
44  fMergeMultiplicityVec.resize(n_planes,fMergeMultiplicityVec[0]);
45 
46  if(fAmpThresholdVec.size()==1)
47  fAmpThresholdVec.resize(n_planes,fAmpThresholdVec[0]);
48 }
49 
51 {
53 }
54 
55 void hit::RFFHitFinderAlg::Run(std::vector<recob::Wire> const& wireVector,
56  std::vector<recob::Hit>& hitVector,
57  geo::Geometry const& geo)
58 {
59  hitVector.reserve(wireVector.size());
60  for(auto const& wire : wireVector)
61  {
62  geo::SigType_t const& sigtype = geo.SignalType(wire.Channel());
63  geo::WireID const& wireID = geo.ChannelToWire(wire.Channel()).at(0);
64 
65  SetFitterParams(wire.View());
66 
67  for(auto const& roi : wire.SignalROI().get_ranges())
68  {
69  fFitter.RunFitter(roi.data());
70 
71  const float summedADCTotal = std::accumulate(roi.data().begin(),roi.data().end(),0.0);
72  const raw::TDCtick_t startTick = roi.begin_index();
73  const raw::TDCtick_t endTick = roi.begin_index()+roi.size();
74 
75  EmplaceHit(hitVector,wire,summedADCTotal,startTick,endTick,sigtype,wireID);
76  }//end loop over ROIs on wire
77 
78  }//end loop over wires
79 
80 }
81 
82 void hit::RFFHitFinderAlg::EmplaceHit(std::vector<recob::Hit>& hitVector,
83  recob::Wire const& wire,
84  float const& summedADCTotal,
85  raw::TDCtick_t const& startTick, raw::TDCtick_t const& endTick,
86  geo::SigType_t const& sigtype, geo::WireID const& wireID)
87 {
88 
89  float totalArea = 0.0;
90  std::vector<float> areaVector(fFitter.NHits());
91  std::vector<float> areaErrorVector(fFitter.NHits());
92  std::vector<float> areaFracVector(fFitter.NHits());
93 
94  for(size_t ihit=0; ihit < fFitter.NHits(); ihit++){
95  areaVector[ihit] = fFitter.AmplitudeVector()[ihit]*fFitter.SigmaVector()[ihit]*SQRT_TWO_PI;
96  areaErrorVector[ihit] =
99  totalArea += areaVector[ihit];
100  }
101 
102  for(size_t ihit=0; ihit < fFitter.NHits(); ihit++)
103  {
104  areaFracVector[ihit] = areaVector[ihit]/totalArea;
105 
106  hitVector.emplace_back(wire.Channel(),
107  startTick,
108  endTick,
109  fFitter.MeanVector()[ihit]+(float)startTick,
110  fFitter.MeanErrorVector()[ihit],
111  fFitter.SigmaVector()[ihit],
112  fFitter.AmplitudeVector()[ihit],
114  summedADCTotal*areaFracVector[ihit],
115  areaVector[ihit],
116  areaErrorVector[ihit],
117  fFitter.NHits(),
118  ihit,
119  -999.,
120  -999,
121  wire.View(),
122  sigtype,
123  wireID);
124  }
125 
126 }
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.
void SetFitterParamsVectors(geo::Geometry const &)
int TDCtick_t
Type representing a TDC tick.
Definition: RawTypes.h:24
geo::View_t View() const
Returns the view the channel belongs to.
Definition: Wire.h:163
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:164
enum geo::_plane_sigtype SigType_t
Enumerate the possible plane projections.
std::vector< float > fAmpThresholdVec
std::vector< float > fMatchThresholdVec
T get(std::string const &key) const
Definition: ParameterSet.h:231
The geometry of one entire detector, as served by art.
Definition: Geometry.h:110
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 deconvoluted signals from a channel.
Definition: Wire.h:80
unsigned int NHits()
Definition: RFFHitFitter.h:49
Namespace collecting geometry-related classes utilities.
const std::vector< float > & AmplitudeErrorVector()
Definition: RFFHitFitter.h:48
const std::vector< float > & SigmaErrorVector()
Definition: RFFHitFitter.h:46