Cand.h
Go to the documentation of this file.
1 ////////////////////////////////////////////////////////////////////////
2 // \file Cand.h
3 // \version $Id: Cand.h,v 1.21 2012-10-31 00:05:29 bckhouse Exp $
4 // \author Christopher Backhouse - bckhouse@caltech.edu
5 ////////////////////////////////////////////////////////////////////////
6 
7 #ifndef DTCAND_H
8 #define DTCAND_H
9 
11 
12 #include <vector>
13 
14 #include "DiscreteTracker/Chunk.h"
15 #include "DiscreteTracker/Types.h"
16 
17 #include "RecoBase/Track.h"
18 
19 namespace rb{class Cluster;}
20 
21 namespace dt
22 {
23  /// \brief Calculation and representation of a straight line passing through
24  /// several "segment" windows.
25  class Cand
26  {
27  public:
28  Cand(geo::View_t view, bool up);
29  /// Simply store the chunk in the list. Need to call \ref AddSeg too
30  void AddChunk(const Chunk& chunk, Direction dir);
31  void PopFirstChunk();
32  void PopLastChunk();
33  bool operator<(const Cand& rhs) const;
34  void EstimateStraightLine(double& z1, double& y1,
35  double& z2, double& y2) const;
36  double MinGradient() const {return fAllMMin;}
37  double MaxGradient() const {return fAllMMax;}
38  double EstimateGradient() const {return MAvg();}
39  /// \return Number of segs in common, or -1 if requirements aren't met
40  geo::View_t View() const {return fView;}
41  unsigned int NChunks() const {return fNChunks;}
42  unsigned int NDeadChunks() const {return fNDeadChunks;}
43  int NHitPlanes() const;
44  const Chunk& FirstChunk() const;
45  const Chunk& LastChunk() const;
46  const Chunk& ExtremalChunk(Direction dir) const
47  {
48  if(dir == kUpstream) return FirstChunk();
49  return LastChunk();
50  }
51  bool IsExtremalChunkComplete(Direction dir) const;
52  void MarkExtremalChunkShower(Direction dir);
53  bool IsAllShower() const;
54  const Segment& FirstSeg() const;
55  const Segment& LastSeg() const;
56  const Segment& ExtremalSeg(Direction dir) const
57  {
58  if(dir == kUpstream) return FirstSeg();
59  return LastSeg();
60  }
61  bool Up() const {return fUp;}
62  art::PtrVector<rb::CellHit> AllHits() const;
63  rb::Track ToTrack() const; // For debugging
64  /// Sorted in plane order
65  std::list<Chunk> AllChunks() const {return fChunks;}
66  unsigned int FirstPlane() const {return FirstSeg().plane;}
67  unsigned int LastPlane() const {return LastSeg().plane;}
68  unsigned int ExtremalPlane(Direction dir) const
69  {
70  if(dir == kUpstream) return FirstPlane();
71  return LastPlane();
72  }
73 
74  /// \brief Appends \a seg to \ref fSegs and updates internal state
75  /// reflecting limits on the possible straight lines. If the new seg is
76  /// impossible to accomodate, returns false and guarantees not to change
77  /// any state.
78  bool TryAddSeg(const Segment& seg, Direction dir, bool check = true);
79 
80  bool TryAddSegOutOfOrder(const Segment& seg);
81 
82  void PopFirstSeg();
83  void PopLastSeg();
84 
85  int NSegs() const {return fSegs.size();}
86 
87  void TrimFront();
88  void TrimBack();
89 
90  void ShortenOne(Direction dir);
91 
92  Cand MaybeFlip(bool& ok) const;
93 
94  bool FindChunk(int plane, Chunk& chunk) const;
95 
96  bool operator==(const Cand& rhs) const;
97  protected:
98  /// Helper for \ref TryAddSeg
99  void MinMaxLines(const Segment& segi, const Segment& segj,
100  double& mmax, double& mmin,
101  double& cmax, double& cmin) const;
102 
103  void MinMaxLines(const SubSeg& segi, const SubSeg& segj,
104  double& mmax, double& mmin,
105  double& cmax, double& cmin) const;
106 
107  void PopSegHelper(const Segment& segi, Direction end);
108 
109  /// Z position
110  double ClosestToEndCell(bool left) const;
111 
112  double MAvg() const {return (fAllMMin+fAllMMax)/2;}
113  double CAvg() const {return (fAllCMin+fAllCMax)/2;}
114 
116 
117  bool fUp;
118 
119  double fAllMMax, fAllMMin, fAllCMax, fAllCMin;
120 
121  int fNChunks, fNDeadChunks;
122 
123  std::list<Segment> fSegs;
124  std::list<Chunk> fChunks;
125 
126  mutable bool fAllHitsDirty;
127  /// Always access via \ref AllHits
129  };
130 } // namespace
131 
132 #endif
double CAvg() const
Definition: Cand.h:113
bool fUp
Definition: Cand.h:117
bool Up() const
Definition: Cand.h:61
Float_t y1[n_points_granero]
Definition: compare.C:5
const int cmax
Definition: cellShifts.C:14
enum geo::_plane_proj View_t
Enumerate the possible plane projections.
Sequence of contiguous hits and dead cells all on the same plane.
Definition: Chunk.h:17
double MinGradient() const
Definition: Cand.h:36
std::list< Segment > fSegs
Definition: Cand.h:123
const Segment & ExtremalSeg(Direction dir) const
Definition: Cand.h:56
unsigned int ExtremalPlane(Direction dir) const
Definition: Cand.h:68
unsigned int FirstPlane() const
Definition: Cand.h:66
const Chunk & ExtremalChunk(Direction dir) const
Definition: Cand.h:46
geo::View_t View() const
Definition: Cand.h:40
A rb::Prong with full reconstructed trajectory.
Definition: Track.h:20
unsigned int NDeadChunks() const
Definition: Cand.h:42
int fNDeadChunks
Definition: Cand.h:121
unsigned int NChunks() const
Definition: Cand.h:41
geo::View_t fView
Definition: Cand.h:115
Definition: Cand.cxx:23
unsigned int LastPlane() const
Definition: Cand.h:67
Calculation and representation of a straight line passing through several "segment" windows...
Definition: Cand.h:25
bool operator<(StanConfig::Verbosity a, StanConfig::Verbosity b)
Allow for comparing them, since kQuiet is definitely "less" verbose than kVerbose.
Definition: StanConfig.h:95
bool operator==(FC &A, FC &B)
int NSegs() const
Definition: Cand.h:85
double EstimateGradient() const
Definition: Cand.h:38
Direction
Definition: Types.h:5
Perform a "2 point" Hough transform on a collection of hits.
Just the upstream or downstream part, just coordinates.
Definition: Segment.h:17
int plane
Definition: Segment.h:42
constexpr auto const & left(const_AssnsIter< L, R, D, Dir > const &a, const_AssnsIter< L, R, D, Dir > const &b)
Definition: AssnsIter.h:96
TDirectory * dir
Definition: macro.C:5
double MAvg() const
Definition: Cand.h:112
double fAllMMin
Definition: Cand.h:119
bool fAllHitsDirty
Definition: Cand.h:126
Window the line must pass through from (z,y0)-(z,y1)
Definition: Segment.h:24
double MaxGradient() const
Definition: Cand.h:37
std::list< Chunk > fChunks
Definition: Cand.h:124
art::PtrVector< rb::CellHit > fAllHits
Always access via AllHits.
Definition: Cand.h:128
std::list< Chunk > AllChunks() const
Sorted in plane order.
Definition: Cand.h:65