Chain.h
Go to the documentation of this file.
1 ////////////////////////////////////////////////////////////////////////
2 // \file Chain.h
3 // \version $Id: Chain.h,v 1.15 2012-10-31 00:05:29 bckhouse Exp $
4 // \author Christopher Backhouse - bckhouse@caltech.edu
5 ////////////////////////////////////////////////////////////////////////
6 
7 #ifndef DTCHAIN_H
8 #define DTCHAIN_H
9 
10 #include <list>
11 
13 
14 #include "DiscreteTracker/Types.h"
15 #include "DiscreteTracker/View.h" // To get ChunkMap
16 
18 #include "Geometry/Geometry.h"
19 
20 namespace rb{class CellHit; class Track;}
21 
22 namespace dt
23 {
24  class Cand;
25  class Chunk;
26  struct Segment;
27 
28  /// Collection of overlapping Cands forming a 2D track
29  class Chain
30  {
31  public:
32  Chain() {}
33  Chain(const Cand& c);
34  rb::Track ToTrack() const;
35  std::vector<rb::Track> ToDebugTracks() const;
36  void Add(const Cand& c);
37  void Add(const Cand& c, Direction dir);
38  void AddFront(const Cand& c);
39  unsigned int FirstPlane() const;
40  unsigned int LastPlane() const;
41  unsigned int ExtremalPlane(Direction dir) const;
42  unsigned int ExtremalHitPlane(Direction dir) const;
43  unsigned int ExtentPlane() const {return LastPlane()-FirstPlane();}
44  unsigned int NCands() const {return fCands.size();}
45  const Cand& FirstCand() const {return fCands.front();}
46  const Cand& LastCand() const {return fCands.back();}
47  const Cand& ExtremalCand(Direction dir) const
48  {
49  if(dir == kUpstream) return FirstCand();
50  return LastCand();
51  }
52  const Chunk& FirstChunk() const;
53  const Chunk& LastChunk() 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  art::PtrVector<rb::CellHit> AllHits() const;
62  std::vector<Chunk> AllChunks() const;
63  int NHitPlanes() const;
64 
65  /// Remove Cands that add no actual hits. After building but before writing
66  void TrimEnds();
67 
68  // Truncates up to but not including \a plane
69  void Truncate(unsigned int plane, Direction end);
70 
71  void Add(const Chain& c, Direction dir)
72  {
73  if(dir == kDownstream)
74  fCands.insert(fCands.end(), c.fCands.begin(), c.fCands.end());
75  else
76  fCands.insert(fCands.begin(), c.fCands.begin(), c.fCands.end());
77  }
78  dt::View::ChunkMap AsChunkMap() const;
79  protected:
80  std::list<Cand> fCands;
81  };
82 
83  bool compareByLength(const Chain& a, const Chain& b);
84  bool compareByStart(const Chain& a, const Chain& b);
85  bool compareByEnd(const Chain& a, const Chain& b);
86 } // namespace
87 
88 #endif
bool compareByLength(const Chain &a, const Chain &b)
Definition: Chain.cxx:349
void Add(const Chain &c, Direction dir)
Definition: Chain.h:71
bool compareByStart(const Chain &a, const Chain &b)
Definition: Chain.cxx:355
Sequence of contiguous hits and dead cells all on the same plane.
Definition: Chunk.h:17
const Segment & ExtremalSeg(Direction dir) const
Definition: Chain.h:56
Definition: Chain.py:1
std::map< int, std::vector< Chunk > > ChunkMap
Definition: View.h:27
A rb::Prong with full reconstructed trajectory.
Definition: Track.h:20
Chain()
Definition: Chain.h:32
Definition: Cand.cxx:23
Calculation and representation of a straight line passing through several "segment" windows...
Definition: Cand.h:25
const double a
Direction
Definition: Types.h:5
Perform a "2 point" Hough transform on a collection of hits.
TDirectory * dir
Definition: macro.C:5
const hit & b
Definition: hits.cxx:21
unsigned int ExtentPlane() const
Definition: Chain.h:43
const Cand & FirstCand() const
Definition: Chain.h:45
Window the line must pass through from (z,y0)-(z,y1)
Definition: Segment.h:24
const Cand & ExtremalCand(Direction dir) const
Definition: Chain.h:47
const Cand & LastCand() const
Definition: Chain.h:46
std::list< Cand > fCands
Definition: Chain.h:80
unsigned int NCands() const
Definition: Chain.h:44
Encapsulate the geometry of one entire detector (near, far, ndos)
bool compareByEnd(const Chain &a, const Chain &b)
Definition: Chain.cxx:361