All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
SpacePointAlg.h
Go to the documentation of this file.
1 ////////////////////////////////////////////////////////////////////////
2 ///
3 /// \file SpacePointAlg.h
4 ///
5 /// \brief Algorithm for generating space points from hits.
6 ///
7 /// \author H. Greenlee
8 ///
9 /// This class calculates space points (recob::SpacePoint) from an
10 /// unsorted collection of hits (recob::Hit). The resulting space
11 /// points will contain one hit from from two or three views.
12 ///
13 /// FCL parameters:
14 ///
15 /// MaxDT - The maximum time difference (ticks) between any pair of hits.
16 /// MaxS - The maximum 3-view wire separation parameter S (cm).
17 /// MinViews - Minimum number of views to make a space point (2 or 3).
18 /// EnableU - Use U view hits.
19 /// EnableV - Use V view hits.
20 /// EnableW - Use W view hits.
21 /// Filter - Filter space points flag.
22 /// Merge - Merge space points flag.
23 /// PreferColl - Collection view will be used for filtering and merging, and
24 /// space points will be sorted by collection wire.
25 ///
26 /// The parameters fMaxDT and fMaxS are used to implement a notion of whether
27 /// the input hits are compatible with being a space point. Parameter
28 /// MaxS is a cut on the 3-plane wire separation parameter S, which is
29 /// defined as follows:
30 ///
31 /// S = sin(theta_vw)*u + sin(theta_wu)*v + sin(theta_uv)*w
32 ///
33 /// where wire coordinates (u,v,w) are measured in cm with respect to a
34 /// common origin.
35 ///
36 /// The time offsets are subtracted from times embedded in hits before
37 /// comparing times in different planes, and before converting time
38 /// to distance.
39 ///
40 /// If enabled, filtering eliminates multiple space points with similar
41 /// times on the same wire of the most popluated plane.
42 ///
43 /// If enabled, merging combines multiple space points with similar
44 /// times on the same wire of the most populated plane (potentially
45 /// producing space points with more hits than the number of planes).
46 ///
47 /// There should eventually be a better way to specify time offsets.
48 ///
49 /// @bug This algorithm makes specific assumptions about geometry and views,
50 /// and it is *not portable*.
51 ///
52 ///
53 ////////////////////////////////////////////////////////////////////////
54 
55 #ifndef SPACEPOINTALG_H
56 #define SPACEPOINTALG_H
57 
58 #include <map>
59 #include <vector>
60 
61 #include "canvas/Persistency/Common/Ptr.h"
62 #include "canvas/Persistency/Common/PtrVector.h"
63 namespace fhicl {
64  class ParameterSet;
65 }
66 
67 namespace detinfo {
68  class DetectorClocksData;
69  class DetectorPropertiesData;
70 }
71 
72 namespace trkf {
73  class KHitTrack;
74 }
77 
78 namespace trkf {
79 
80  class SpacePointAlg {
81  public:
82  SpacePointAlg(const fhicl::ParameterSet& pset);
83 
84  // Configuration Accessors.
85 
86  bool
87  filter() const noexcept
88  {
89  return fFilter;
90  }
91  bool
92  merge() const noexcept
93  {
94  return fMerge;
95  }
96  double
97  maxDT() const noexcept
98  {
99  return fMaxDT;
100  }
101  double
102  maxS() const noexcept
103  {
104  return fMaxS;
105  }
106  int
107  minViews() const noexcept
108  {
109  return fMinViews;
110  }
111  bool
112  enableU() const noexcept
113  {
114  return fEnableU;
115  }
116  bool
117  enableV() const noexcept
118  {
119  return fEnableV;
120  }
121  bool
122  enableW() const noexcept
123  {
124  return fEnableW;
125  }
126 
127  // Print constants obtained from geometry and properties services.
129 
130  // Corrected time accessors.
132  const recob::Hit& hit) const;
133 
134  // Spatial separation of hits (zero if two or fewer).
135  double separation(const art::PtrVector<recob::Hit>& hits) const;
136 
137  // Test whether the specified hits are compatible with a space point.
138  // The last two arguments can be used to override the default cuts.
140  const art::PtrVector<recob::Hit>& hits,
141  bool useMC = false) const;
142 
143  // Fill a single simple space point using the specified hits.
144  // Hits are assumed to be compatible.
146  const art::PtrVector<recob::Hit>& hits,
147  std::vector<recob::SpacePoint>& sptv,
148  int sptid) const;
149 
150  /// Fill a collection of space points.
152  std::vector<recob::SpacePoint>& spts,
153  std::multimap<double, KHitTrack> const& trackMap) const;
154 
155  // Fill a single complex space point using the specified hits.
156  // Complex space points allow multiple hits in one plane.
157  // Hits are assumed to be compatible.
159  const art::PtrVector<recob::Hit>& hits,
160  std::vector<recob::SpacePoint>& sptv,
161  int sptid) const;
162 
163  // Fill a vector of space points from an unsorted collection of hits.
164  // Space points are generated for all compatible combinations of hits.
165  void makeSpacePoints(detinfo::DetectorClocksData const& clockData,
167  const art::PtrVector<recob::Hit>& hits,
168  std::vector<recob::SpacePoint>& spts) const;
169 
170  // Fill a vector of space points compatible with mc truth information
173  const art::PtrVector<recob::Hit>& hits,
174  std::vector<recob::SpacePoint>& spts) const;
175 
176  // Get hits associated with a particular space point, based on most recent
177  // invocation of any make*SpacePoints method.
178  const art::PtrVector<recob::Hit>& getAssociatedHits(const recob::SpacePoint& spt) const;
179 
180  // Clear space point to Hit associations.
181  void
182  clearHitMap() const
183  {
184  fSptHitMap.clear();
185  }
186 
187  // Return number of space point to Hit associations.
188  int
189  numHitMap() const
190  {
191  return fSptHitMap.size();
192  }
193 
194  private:
195  // This is the real method for calculating space points (each of
196  // the public make*SpacePoints methods comes here).
197  void makeSpacePoints(detinfo::DetectorClocksData const& clockData,
199  const art::PtrVector<recob::Hit>& hits,
200  std::vector<recob::SpacePoint>& spts,
201  bool useMC) const;
202 
203  // Configuration paremeters.
204 
205  double fMaxDT; ///< Maximum time difference between planes.
206  double fMaxS; ///< Maximum space separation between wires.
207  int fMinViews; ///< Mininum number of views per space point.
208  bool fEnableU; ///< Enable flag (U).
209  bool fEnableV; ///< Enable flag (V).
210  bool fEnableW; ///< Enable flag (W).
211  bool fFilter; ///< Filter flag.
212  bool fMerge; ///< Merge flag.
213  bool fPreferColl; ///< Sort by collection wire.
214  double fTickOffsetU; ///< Tick offset for plane U.
215  double fTickOffsetV; ///< Tick offset for plane V.
216  double fTickOffsetW; ///< Tick offset for plane W.
217 
218  // Temporary variables.
219 
220  struct HitMCInfo {
221  std::vector<int> trackIDs; ///< Parent trackIDs.
222  std::vector<double> xyz; ///< Location of ionization (all tracks).
223  std::vector<const recob::Hit*> pchit; ///< Pointer to nearest neighbor hit (indexed by plane).
224  std::vector<double> dist2; ///< Distance to nearest neighbor hit (indexed by plane).
225  };
226  mutable std::map<const recob::Hit*, HitMCInfo> fHitMCMap;
227  mutable std::map<int, art::PtrVector<recob::Hit>> fSptHitMap;
228  };
229 }
230 
231 #endif
bool merge() const noexcept
Definition: SpacePointAlg.h:92
std::vector< const recob::Hit * > pchit
Pointer to nearest neighbor hit (indexed by plane).
std::map< const recob::Hit *, HitMCInfo > fHitMCMap
double fTickOffsetU
Tick offset for plane U.
double fMaxDT
Maximum time difference between planes.
bool fFilter
Filter flag.
Declaration of signal hit object.
void update(detinfo::DetectorPropertiesData const &detProp) const
std::vector< double > dist2
Distance to nearest neighbor hit (indexed by plane).
bool fEnableW
Enable flag (W).
std::vector< int > trackIDs
Parent trackIDs.
bool filter() const noexcept
Definition: SpacePointAlg.h:87
double maxDT() const noexcept
Definition: SpacePointAlg.h:97
process_name hit
Definition: cheaterreco.fcl:51
bool enableV() const noexcept
const art::PtrVector< recob::Hit > & getAssociatedHits(const recob::SpacePoint &spt) const
void makeMCTruthSpacePoints(detinfo::DetectorClocksData const &clockData, detinfo::DetectorPropertiesData const &detProp, const art::PtrVector< recob::Hit > &hits, std::vector< recob::SpacePoint > &spts) const
double separation(const art::PtrVector< recob::Hit > &hits) const
SpacePointAlg(const fhicl::ParameterSet &pset)
bool fEnableU
Enable flag (U).
std::map< int, art::PtrVector< recob::Hit > > fSptHitMap
std::vector< double > xyz
Location of ionization (all tracks).
void makeSpacePoints(detinfo::DetectorClocksData const &clockData, detinfo::DetectorPropertiesData const &detProp, const art::PtrVector< recob::Hit > &hits, std::vector< recob::SpacePoint > &spts) const
bool enableU() const noexcept
void fillComplexSpacePoint(detinfo::DetectorPropertiesData const &detProp, const art::PtrVector< recob::Hit > &hits, std::vector< recob::SpacePoint > &sptv, int sptid) const
double fMaxS
Maximum space separation between wires.
double correctedTime(detinfo::DetectorPropertiesData const &detProp, const recob::Hit &hit) const
bool fPreferColl
Sort by collection wire.
double maxS() const noexcept
void fillSpacePoints(detinfo::DetectorPropertiesData const &detProp, std::vector< recob::SpacePoint > &spts, std::multimap< double, KHitTrack > const &trackMap) const
Fill a collection of space points.
void clearHitMap() const
double fTickOffsetV
Tick offset for plane V.
Contains all timing reference information for the detector.
double fTickOffsetW
Tick offset for plane W.
bool compatible(detinfo::DetectorPropertiesData const &detProp, const art::PtrVector< recob::Hit > &hits, bool useMC=false) const
bool enableW() const noexcept
int fMinViews
Mininum number of views per space point.
int numHitMap() const
2D representation of charge deposited in the TDC/wire plane
Definition: Hit.h:48
bool fMerge
Merge flag.
void fillSpacePoint(detinfo::DetectorPropertiesData const &detProp, const art::PtrVector< recob::Hit > &hits, std::vector< recob::SpacePoint > &sptv, int sptid) const
int minViews() const noexcept
auto const detProp
bool fEnableV
Enable flag (V).