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