DepoPlaneX.h
Go to the documentation of this file.
1 #ifndef WIRECELLGEN_DEPOPLANEX
2 #define WIRECELLGEN_DEPOPLANEX
3 
4 #include "WireCellUtil/Point.h"
5 #include "WireCellUtil/Units.h"
6 #include "WireCellIface/IDepo.h"
7 
8 #include <deque>
9 
10 namespace WireCell {
11  namespace Gen {
12 
13  /** A DepoPlaneX collects depositions and drifts them to the
14  * given plane assuming a uniform drift velocity which is in
15  * the negative X direction.
16  *
17  * It is assumed new depositions are added strictly in time
18  * order. They will then be drifted and maintained in the
19  * order of their time at the plane.
20  *
21  * The time of the most recently added depo sets a high water
22  * mark in time at the plane such that all newly added depos
23  * must (causally) come later. Any depos older than this time
24  * are considered "frozen out" as nothing can change their
25  * ordering.
26  */
27 
28  class DepoPlaneX {
29  public:
30  typedef std::deque<IDepo::pointer> frozen_queue_t;
32 
33  DepoPlaneX(double planex = 0.0*units::cm,
34  double speed = 1.6*units::millimeter/units::microsecond);
35 
36  /// Add a deposition and drift it into the queue at the
37  /// plane. Depos must be strictly added in (local) time
38  /// order. The drifted depo is returned (and held).
39  IDepo::pointer add(const IDepo::pointer& depo);
40 
41  /// The time a deposition would have if it drifts to the plane
42  double proper_time(IDepo::pointer depo) const;
43 
44  /// Return the time at the plane before which the order of
45  /// collected depositions are guaranteed (causally) to
46  /// remain unchanged as any new depos are added.
47  double freezeout_time() const;
48 
49  /// Force any remaining "thawed" depos in the queue to be frozen out.
50  void freezeout();
51 
52  /// Return ordered vector of all depositions at the plane
53  /// with times not later than the given time. The given
54  /// time is typically the freezeout time. If a time later
55  /// than the freezout time is given it may cause depos to
56  /// be artificially frozen out.
57  IDepo::vector pop(double time);
58 
59  // Access internal const data structures to assist in debugging
60  const frozen_queue_t& frozen_queue() const { return m_frozen; }
61  const working_queue_t& working_queue() const { return m_queue; }
62 
63  private:
64  double m_planex, m_speed;
65  working_queue_t m_queue;
66  frozen_queue_t m_frozen;
67 
68  /// Move all froze-out depos to the frozen queue
69  void drain(double time);
70  };
71 
72 
73  } // Gen
74 
75 } // WireCell
76 
77 #endif
std::shared_ptr< const IDepo > pointer
Definition: IData.h:19
double freezeout_time() const
Definition: DepoPlaneX.cxx:22
frozen_queue_t m_frozen
Definition: DepoPlaneX.h:66
IDepo::pointer add(const IDepo::pointer &depo)
Definition: DepoPlaneX.cxx:14
std::deque< IDepo::pointer > frozen_queue_t
Definition: DepoPlaneX.h:30
const working_queue_t & working_queue() const
Definition: DepoPlaneX.h:61
double proper_time(IDepo::pointer depo) const
The time a deposition would have if it drifts to the plane.
static const double microsecond
Definition: Units.h:94
std::vector< pointer > vector
Definition: IData.h:21
const frozen_queue_t & frozen_queue() const
Definition: DepoPlaneX.h:60
void drain(double time)
Move all froze-out depos to the frozen queue.
Definition: DepoPlaneX.cxx:30
std::set< IDepo::pointer, IDepoDriftCompare > DepoTauSortedSet
Definition: IDepo.h:77
IDepo::vector pop(double time)
Definition: DepoPlaneX.cxx:57
void freezeout()
Force any remaining "thawed" depos in the queue to be frozen out.
Definition: DepoPlaneX.cxx:44
static const double cm
Definition: Units.h:59
Definition: Main.h:22
static const double millimeter
Definition: Units.h:22
working_queue_t m_queue
Definition: DepoPlaneX.h:65
DepoTauSortedSet working_queue_t
Definition: DepoPlaneX.h:31
DepoPlaneX(double planex=0.0 *units::cm, double speed=1.6 *units::millimeter/units::microsecond)
Definition: DepoPlaneX.cxx:6