Hit.h
Go to the documentation of this file.
1 /** ****************************************************************************
2  * @file lardataobj/RecoBase/Hit.h
3  * @brief Declaration of signal hit object.
4  * @author mitchell.soderberg@yale.edu
5  * @see lardataobj/RecoBase/Hit.cxx
6  *
7  * Changes:
8  * 20141212 Gianluca Petrillo (petrillo@fnal.gov)
9  * data architecture revision changes (v13 -> v14):
10  * - fRawDigit and RawDigit() removed
11  * - fWire and Wire() removed
12  * - fSignalType and SignalType() removed
13  * - fChannel and Channel() added
14  * - constructors now take directly a RawDigit, not its art::Ptr
15  * 20150129 Gianluca Petrillo (petrillo@fnal.gov)
16  * data architecture revision changes (v14 -> v15):
17  * - removed fHitSignal
18  *
19  * ****************************************************************************/
20 
21 #ifndef LARDATAOBJ_RECOBASE_HIT_H
22 #define LARDATAOBJ_RECOBASE_HIT_H
23 
24 
25 // C/C++ standard librraies
26 #include <iosfwd>
27 
28 // LArSoft libraries
29 #include "larcoreobj/SimpleTypesAndConstants/geo_types.h" // geo::View_t, geo::SignalType, geo::WireID
30 #include "larcoreobj/SimpleTypesAndConstants/RawTypes.h" // raw::ChannelID_t
31 
32 
33 namespace recob {
34 
35  /**
36  * @brief 2D representation of charge deposited in the TDC/wire plane
37  *
38  * Hits are assumed to be made from deconvoluted, unipolar, calibrated
39  * signals.
40  * They identify a charge deposit in a specific location and time;
41  * the location is absolute and unique in the detector, while the time is
42  * relative to the start of sampling (tick time).
43  *
44  * The version 14 of recob::Hit introduces the following changes:
45  * - StartTime() becomes StartTick(), StopTime() becomes StopTick()
46  * - Charge(true) is now PeakAmplitude(), Charge(false) (default) is Integral()
47  */
48  class Hit {
49  public:
50  /// Default constructor: a hit with no signal
51  Hit();
52 
53  private:
54 
55  raw::ChannelID_t fChannel; ///< ID of the readout channel the hit was extracted from
56  raw::TDCtick_t fStartTick; ///< initial tdc tick for hit
57  raw::TDCtick_t fEndTick; ///< final tdc tick for hit
58  float fPeakTime; ///< time of the signal peak, in tick units
59  float fSigmaPeakTime; ///< uncertainty for the signal peak, in tick units
60  float fRMS; ///< RMS of the hit shape, in tick units
61  float fPeakAmplitude; ///< the estimated amplitude of the hit at its peak, in ADC units
62  float fSigmaPeakAmplitude; ///< uncertainty on estimated amplitude of the hit at its peak, in ADC units
63  float fSummedADC; ///< the sum of calibrated ADC counts of the hit
64  float fIntegral; ///< the integral under the calibrated signal waveform of the hit, in tick x ADC units
65  float fSigmaIntegral; ///< the uncertainty of integral under the calibrated signal waveform of the hit, in ADC units
66  short int fMultiplicity; ///< how many hits could this one be shared with
67  short int fLocalIndex; ///< index of this hit among the Multiplicity() hits in the signal window
68  float fGoodnessOfFit; ///< how well do we believe we know this hit?
69  int fNDF; ///< degrees of freedom in the determination of the hit shape
70  geo::View_t fView; ///< view for the plane of the hit
71  geo::SigType_t fSignalType; ///< signal type for the plane of the hit
72  geo::WireID fWireID; ///< WireID for the hit (Cryostat, TPC, Plane, Wire)
73 
74  friend class HitCreator; // helper to create hits
75 
76  public:
77  /**
78  * @brief Constructor: directly sets all the fields
79  * @param channel ID of the readout channel the hit was extracted from
80  * @param start_tick initial tdc tick for hit
81  * @param end_tick final tdc tick for hit
82  * @param peak_time tdc for the peak charge deposition
83  * @param sigma_peak_time uncertainty for tdc of the peak
84  * @param rms RMS of the hit shape
85  * @param peak_amplitude the estimated amplitude of the hit at its peak
86  * @param sigma_peak_amplitude the uncertainty on the estimated amplitude of the hit at its peak
87  * @param summedADC the sum of calibrated ADC counts of the hit
88  * @param hit_integral the integral under the calibrated signal waveform of the hit
89  * @param hit_sigma_integral uncertainty on the integral under the calibrated signal waveform of the hit
90  * @param multiplicity how many hits could this one be shared with
91  * @param local_index index of this hit among the Multiplicity() hits in the signal window
92  * @param goodness_of_fit how well do we believe we know this hit?
93  * @param dof number of degrees of freedom in the determination of hit shape
94  * @param view view for the plane of the hit
95  * @param signal_type signal type for the plane of the hit
96  * @param wireID WireID for the hit (Cryostat TPC Plane Wire)
97  *
98  * The tick parameters are real numbers, since they can in principle come
99  * from some processing.
100  */
101  Hit(
103  raw::TDCtick_t start_tick,
104  raw::TDCtick_t end_tick,
105  float peak_time,
106  float sigma_peak_time,
107  float rms,
108  float peak_amplitude,
109  float sigma_peak_amplitude,
110  float summedADC,
111  float hit_integral,
112  float hit_sigma_integral,
113  short int multiplicity,
114  short int local_index,
115  float goodness_of_fit,
116  int dof,
117  geo::View_t view,
118  geo::SigType_t signal_type,
119  geo::WireID wireID
120  );
121 
122  /// @{
123  /// @name Accessors
124 
125  /// Initial tdc tick for hit
126  raw::TDCtick_t StartTick() const;
127 
128  /// Final tdc tick for hit
129  raw::TDCtick_t EndTick() const;
130 
131  /// Time of the signal peak, in tick units
132  float PeakTime() const;
133 
134  /// Uncertainty for the signal peak, in tick units
135  float SigmaPeakTime() const;
136 
137  /// RMS of the hit shape, in tick units
138  float RMS() const;
139 
140  /// The estimated amplitude of the hit at its peak, in ADC units
141  float PeakAmplitude() const;
142 
143  /// Uncertainty on estimated amplitude of the hit at its peak, in ADC units
144  float SigmaPeakAmplitude() const;
145 
146  /// The sum of calibrated ADC counts of the hit (0. by default)
147  float SummedADC() const;
148 
149  /// Integral under the calibrated signal waveform of the hit, in tick x ADC units
150  float Integral() const;
151 
152  ///< Uncertainty of integral under the calibrated signal waveform of the hit, in ADC units
153  float SigmaIntegral() const;
154 
155  /// How many hits could this one be shared with
156  short int Multiplicity() const;
157 
158  ///< Index of this hit among the Multiplicity() hits in the signal window (-1 by default)
159  short int LocalIndex() const;
160 
161  ///< How well do we believe we know this hit?
162  float GoodnessOfFit() const;
163 
164  ///< Degrees of freedom in the determination of the hit signal shape (-1 by default)
165  int DegreesOfFreedom() const;
166 
167  /// ID of the readout channel the hit was extracted from
168  raw::ChannelID_t Channel() const;
169 
170  /// View for the plane of the hit
171  geo::View_t View() const;
172 
173  /// Signal type for the plane of the hit
174  geo::SigType_t SignalType() const;
175 
176  ///< ID of the wire the hit is on (Cryostat, TPC, Plane, Wire)
177  geo::WireID WireID() const;
178 
179  /// @}
180 
181  //@{
182  /**
183  * @brief Returns a time sigmas RMS away from the peak time
184  * @param sigmas the number of RMS units to move away
185  * @return the shifted time in TDC ticks
186  *
187  * PeakTimePlusRMS() returns PeakTime() + sigmas x RMS();
188  * PeakTimeMinusRMS() returns PeakTime() - sigmas x RMS().
189  *
190  * @note StartTime() of recob::Hit version <=13 was defined by
191  * GausHitFinder to be PeakTimePlusRMS(-1.), and EndTime() was
192  * PeakTimePlusRMS(+1.).
193  */
194  float PeakTimePlusRMS(float sigmas = +1.) const;
195  float PeakTimeMinusRMS(float sigmas = +1.) const;
196  //@}
197 
198  /**
199  * @brief Returns the distance of the specified time from peak, in RMS units
200  * @param time the time, in TDC tick units
201  * @return the distance of the specified time from peak, in RMS units
202  *
203  * This returns (ticks - PeakTime()) / RMS().
204  * There is no protection in case RMS is 0!
205  */
206  float TimeDistanceAsRMS(float time) const;
207 
208 
209  friend std::ostream& operator << (std::ostream & o, const Hit & a);
210  friend bool operator < (const Hit & a, const Hit & b);
211 
212  }; // class Hit
213 } // namespace recob
214 
215 
217 inline raw::TDCtick_t recob::Hit::EndTick() const { return fEndTick; }
218 inline float recob::Hit::PeakTime() const { return fPeakTime; }
219 inline float recob::Hit::SigmaPeakTime() const { return fSigmaPeakTime; }
220 inline float recob::Hit::RMS() const { return fRMS; }
221 inline float recob::Hit::PeakAmplitude() const { return fPeakAmplitude; }
222 inline float recob::Hit::SigmaPeakAmplitude() const { return fSigmaPeakAmplitude; }
223 inline float recob::Hit::SummedADC() const { return fSummedADC; }
224 inline float recob::Hit::Integral() const { return fIntegral; }
225 inline float recob::Hit::SigmaIntegral() const { return fSigmaIntegral; }
226 inline short int recob::Hit::Multiplicity() const { return fMultiplicity; }
227 inline short int recob::Hit::LocalIndex() const { return fLocalIndex; }
228 inline float recob::Hit::GoodnessOfFit() const { return fGoodnessOfFit; }
229 inline int recob::Hit::DegreesOfFreedom() const { return fNDF; }
232 inline geo::View_t recob::Hit::View() const { return fView; }
233 inline geo::WireID recob::Hit::WireID() const { return fWireID; }
234 
235 
236 inline float recob::Hit::PeakTimePlusRMS(float sigmas /* = +1. */) const
237  { return PeakTime() + sigmas * RMS(); }
238 
239 inline float recob::Hit::PeakTimeMinusRMS(float sigmas /* = +1. */) const
240  { return PeakTimePlusRMS(-sigmas); }
241 
242 inline float recob::Hit::TimeDistanceAsRMS(float time) const
243  { return (time - PeakTime()) / RMS(); }
244 
245 
246 
247 #endif // LARDATAOBJ_RECOBASE_HIT_H
short int LocalIndex() const
How well do we believe we know this hit?
Definition: Hit.h:227
friend bool operator<(const Hit &a, const Hit &b)
Definition: Hit.cxx:112
geo::SigType_t SignalType() const
Signal type for the plane of the hit.
Definition: Hit.h:231
float fPeakAmplitude
the estimated amplitude of the hit at its peak, in ADC units
Definition: Hit.h:61
raw::TDCtick_t fStartTick
initial tdc tick for hit
Definition: Hit.h:56
Reconstruction base classes.
float fSummedADC
the sum of calibrated ADC counts of the hit
Definition: Hit.h:63
double rms(sqlite3 *db, std::string const &table_name, std::string const &column_name)
Definition: statistics.cc:40
enum geo::_plane_proj View_t
Enumerate the possible plane projections.
geo::WireID WireID() const
Definition: Hit.h:233
float RMS() const
RMS of the hit shape, in tick units.
Definition: Hit.h:220
float fSigmaPeakAmplitude
uncertainty on estimated amplitude of the hit at its peak, in ADC units
Definition: Hit.h:62
geo::View_t fView
view for the plane of the hit
Definition: Hit.h:70
geo::SigType_t fSignalType
signal type for the plane of the hit
Definition: Hit.h:71
float SigmaPeakAmplitude() const
Uncertainty on estimated amplitude of the hit at its peak, in ADC units.
Definition: Hit.h:222
float SigmaIntegral() const
Definition: Hit.h:225
int DegreesOfFreedom() const
Definition: Hit.h:229
float Integral() const
Integral under the calibrated signal waveform of the hit, in tick x ADC units.
Definition: Hit.h:224
geo::View_t View() const
View for the plane of the hit.
Definition: Hit.h:232
Hit()
Default constructor: a hit with no signal.
Definition: Hit.cxx:19
uint8_t channel
Definition: CRTFragment.hh:201
float GoodnessOfFit() const
Degrees of freedom in the determination of the hit signal shape (-1 by default)
Definition: Hit.h:228
short int Multiplicity() const
How many hits could this one be shared with.
Definition: Hit.h:226
raw::TDCtick_t fEndTick
final tdc tick for hit
Definition: Hit.h:57
float fSigmaPeakTime
uncertainty for the signal peak, in tick units
Definition: Hit.h:59
float PeakAmplitude() const
The estimated amplitude of the hit at its peak, in ADC units.
Definition: Hit.h:221
int TDCtick_t
Type representing a TDC tick.
Definition: RawTypes.h:25
friend std::ostream & operator<<(std::ostream &o, const Hit &a)
short int fMultiplicity
how many hits could this one be shared with
Definition: Hit.h:66
Class managing the creation of a new recob::Hit object.
Definition: HitCreator.h:83
float TimeDistanceAsRMS(float time) const
Returns the distance of the specified time from peak, in RMS units.
Definition: Hit.h:242
enum geo::_plane_sigtype SigType_t
const double a
float fPeakTime
time of the signal peak, in tick units
Definition: Hit.h:58
raw::ChannelID_t fChannel
ID of the readout channel the hit was extracted from.
Definition: Hit.h:55
int fNDF
degrees of freedom in the determination of the hit shape
Definition: Hit.h:69
float fRMS
RMS of the hit shape, in tick units.
Definition: Hit.h:60
raw::TDCtick_t StartTick() const
Initial tdc tick for hit.
Definition: Hit.h:216
Definition of data types for geometry description.
float PeakTimeMinusRMS(float sigmas=+1.) const
Definition: Hit.h:239
raw::TDCtick_t EndTick() const
Final tdc tick for hit.
Definition: Hit.h:217
float PeakTime() const
Time of the signal peak, in tick units.
Definition: Hit.h:218
geo::WireID fWireID
WireID for the hit (Cryostat, TPC, Plane, Wire)
Definition: Hit.h:72
float fSigmaIntegral
the uncertainty of integral under the calibrated signal waveform of the hit, in ADC units ...
Definition: Hit.h:65
float fGoodnessOfFit
how well do we believe we know this hit?
Definition: Hit.h:68
static bool * b
Definition: config.cpp:1043
float SummedADC() const
The sum of calibrated ADC counts of the hit (0. by default)
Definition: Hit.h:223
short int fLocalIndex
index of this hit among the Multiplicity() hits in the signal window
Definition: Hit.h:67
float SigmaPeakTime() const
Uncertainty for the signal peak, in tick units.
Definition: Hit.h:219
2D representation of charge deposited in the TDC/wire plane
Definition: Hit.h:48
float fIntegral
the integral under the calibrated signal waveform of the hit, in tick x ADC units ...
Definition: Hit.h:64
float PeakTimePlusRMS(float sigmas=+1.) const
Returns a time sigmas RMS away from the peak time.
Definition: Hit.h:236
unsigned int ChannelID_t
Type representing the ID of a readout channel.
Definition: RawTypes.h:28
raw::ChannelID_t Channel() const
ID of the readout channel the hit was extracted from.
Definition: Hit.h:230