BinnedDiffusion.h
Go to the documentation of this file.
1 #ifndef WIRECELLGEN_BINNEDDIFFUSION
2 #define WIRECELLGEN_BINNEDDIFFUSION
3 
4 #include "WireCellUtil/Pimpos.h"
5 #include "WireCellUtil/Point.h"
6 #include "WireCellUtil/Units.h"
7 #include "WireCellIface/IDepo.h"
8 
10 
11 #include <deque>
12 
13 namespace WireCell {
14  namespace Gen {
15 
16  /** A BinnedDiffusion maintains an association between impact
17  * positions along the pitch direction of a wire plane and
18  * the diffused depositions that drift to them.
19  *
20  * It covers a fixed and discretely sampled time and pitch
21  * domain.
22  */
24  public:
25 
26  /** Create a BinnedDiffusion.
27 
28  Arguments are:
29 
30  - pimpos :: a Pimpos instance defining the wire and impact binning.
31 
32  - tbins :: a Binning instance defining the time sampling binning.
33 
34  - nsigma :: number of sigma the 2D (transverse X
35  longitudinal) Gaussian extends.
36 
37  - fluctuate :: set to an IRandom if charge-preserving
38  Poisson fluctuations are to be applied.
39 
40  - calcstrat :: set a calculation strategy that gives
41  how the microscopic distribution of charge between
42  two impacts will be interpolated toward either edge.
43 
44  */
45 
46  /// Useful to client code to mark a calculation strategy.
48 
49  BinnedDiffusion(const Pimpos& pimpos, const Binning& tbins,
50  double nsigma=3.0, IRandom::pointer fluctuate=nullptr,
52 
53  const Pimpos& pimpos() const { return m_pimpos; }
54  const Binning& tbins() const { return m_tbins; }
55 
56  /// Add a deposition and its associated diffusion sigmas.
57  /// Return false if no activity falls within the domain.
58  bool add(IDepo::pointer deposition, double sigma_time, double sigma_pitch);
59 
60  /// Unconditionally associate an already built
61  /// GaussianDiffusion to one impact.
62  void add(std::shared_ptr<GaussianDiffusion> gd, int impact_index);
63 
64  /// Drop any stored ImpactData within the half open
65  /// impact index range.
66  void erase(int begin_impact_index, int end_impact_index);
67 
68  /// Return the data in the given impact bin. Note, this
69  /// bin represents drifted charge between two impact
70  /// positions. Take care when using BinnedDiffusion and
71  /// field responses because epsilon above or below the
72  /// impact position exactly in the middle of two wires
73  /// drastically different response.
75 
76  // test ...
77  // void get_charge_vec(std::vector<std::vector<std::tuple<int,int, double> > >& vec_vec_charge, std::vector<int>& vec_impact);
78 
79 
80  /// Return the range of pitch containing depos out to
81  /// given nsigma and without bounds checking.
82  std::pair<double,double> pitch_range(double nsigma=0.0) const;
83 
84  /// Return the half open bin range of impact bins,
85  /// constrained so that either number is in [0,nimpacts].
86  std::pair<int,int> impact_bin_range(double nsigma=0.0) const;
87 
88  /// Return the range of time containing depos out to given
89  /// nsigma and without bounds checking.
90  std::pair<double,double> time_range(double nsigma=0.0) const;
91 
92  /// Return the half open bin range for time bins
93  /// constrained so that either number is in [0,nticks].
94  std::pair<int,int> time_bin_range(double nsigma=0.0) const;
95 
96  double get_nsigma() const {return m_nsigma;};
97 
98  private:
99 
100  const Pimpos& m_pimpos;
101  const Binning& m_tbins;
102 
103  double m_nsigma;
106 
107  // current window set by user.
108  std::pair<int,int> m_window;
109  // the content of the current window
110  std::map<int, ImpactData::mutable_pointer> m_impacts;
111  //std::vector<std::shared_ptr<GaussianDiffusion> > m_diffs;
112  //std::set<std::shared_ptr<GaussianDiffusion>, GausDiffTimeCompare> m_diffs;
113  std::set<std::shared_ptr<GaussianDiffusion> > m_diffs;
114 
117  };
118 
119 
120  }
121 
122 }
123 
124 #endif
std::shared_ptr< const IDepo > pointer
Definition: IData.h:19
ImpactDataCalculationStrategy
Useful to client code to mark a calculation strategy.
bool add(IDepo::pointer deposition, double sigma_time, double sigma_pitch)
std::pair< double, double > pitch_range(double nsigma=0.0) const
std::pair< int, int > m_window
BinnedDiffusion(const Pimpos &pimpos, const Binning &tbins, double nsigma=3.0, IRandom::pointer fluctuate=nullptr, ImpactDataCalculationStrategy calcstrat=linear)
void erase(int begin_impact_index, int end_impact_index)
const Pimpos & pimpos() const
std::shared_ptr< Interface > pointer
Definition: Interface.h:16
ImpactDataCalculationStrategy m_calcstrat
ImpactData::pointer impact_data(int bin) const
Definition: Main.h:22
std::shared_ptr< const ImpactData > pointer
Definition: ImpactData.h:30
Pitch-Impact-Position.
Definition: Pimpos.h:36
const Binning & tbins() const
QTextStream & bin(QTextStream &s)
std::set< std::shared_ptr< GaussianDiffusion > > m_diffs
std::pair< double, double > time_range(double nsigma=0.0) const
std::map< int, ImpactData::mutable_pointer > m_impacts
std::pair< int, int > impact_bin_range(double nsigma=0.0) const
std::pair< int, int > time_bin_range(double nsigma=0.0) const