ImpactData.cxx
Go to the documentation of this file.
2 
3 #include <iostream> // debugging
4 
5 using namespace WireCell;
6 using namespace std;
7 
9  : m_impact(impact)
10 {
11 }
13 {
14  m_diffusions.push_back(diffusion);
15 }
16 
18 {
19  return m_waveform;
20 }
21 
23 {
24  return m_spectrum;
25 }
26 
28 {
29  return m_weights;
30 }
31 
33 {
34  return m_weight_spectrum;
35 }
36 
38 {
39  if (m_waveform.size() > 0) {
40  return;
41  }
42  m_waveform.resize(nticks, 0.0);
43  m_weights.resize(nticks, 0.0);
44 
45  for (auto diff : m_diffusions) {
46 
47  const auto patch = diff->patch();
48  const auto qweight = diff->weights();
49 
50  const int poffset_bin = diff->poffset_bin();
51  const int pbin = m_impact - poffset_bin;
52  const int np = patch.rows();
53  if (pbin<0 || pbin >= np) {
54  continue;
55  }
56 
57  const int toffset_bin = diff->toffset_bin();
58  const int nt = patch.cols();
59 
60  // std::cout << pbin << " " << poffset_bin << " " << m_impact << std::endl;
61 
62  for (int tbin=0; tbin<nt; ++tbin) {
63  const int absbin = tbin+toffset_bin;
64  m_waveform[absbin] += patch(pbin, tbin);
65 
66  // std::cout << pbin << " " << tbin << " " << patch(pbin,tbin) << std::endl;
67 
68  // for interpolation
69  m_weights[absbin] += qweight[pbin]*patch(pbin, tbin);
70  }
71  }
72 
75 }
76 
77 
78 // std::pair<int,int> Gen::ImpactData::strip() const
79 // {
80 // int imin=-1, imax = -1;
81 // for (int ind=0; ind<m_waveform.size(); ++ind) {
82 // const double val = m_waveform[ind];
83 // if (imin < 0 && val > 0) { imin = ind; }
84 // if (val > 0) { imax = ind; }
85 // }
86 // return std::make_pair(imin, imax+1);
87 // }
88 
89 std::pair<double, double> Gen::ImpactData::span(double nsigma) const
90 {
91  int ncount = -1;
92  double tmin=0, tmax=0;
93  for (auto diff : m_diffusions) {
94  ++ncount;
95 
96  auto td = diff->time_desc();
97 
98  const double ltmin = td.center - td.sigma*nsigma;
99  const double ltmax = td.center + td.sigma*nsigma;
100  if (!ncount) {
101  tmin = ltmin;
102  tmax = ltmax;
103  continue;
104  }
105  tmin = std::min(tmin, ltmin);
106  tmax = std::max(tmax, ltmax);
107  }
108  return std::make_pair(tmin,tmax);
109 }
std::vector< GaussianDiffusion::pointer > m_diffusions
Definition: ImpactData.h:26
Sequence< real_t > realseq_t
Definition: Waveform.h:31
Waveform::compseq_t m_weight_spectrum
Definition: ImpactData.h:23
Waveform::realseq_t & weightform() const
Definition: ImpactData.cxx:27
Waveform::compseq_t & spectrum() const
Definition: ImpactData.cxx:22
STL namespace.
Waveform::realseq_t & waveform() const
Definition: ImpactData.cxx:17
const int nticks
compseq_t dft(realseq_t seq)
Definition: Waveform.cxx:141
G4bool diffusion
Definition: NestAlg.cxx:40
void calculate(int nticks) const
Definition: ImpactData.cxx:37
Waveform::realseq_t m_weights
Definition: ImpactData.h:22
void add(GaussianDiffusion::pointer diffusion)
Definition: ImpactData.cxx:12
std::pair< double, double > span(double nsigma=0.0) const
Definition: ImpactData.cxx:89
static int max(int a, int b)
Definition: Main.h:22
T min(sqlite3 *const db, std::string const &table_name, std::string const &column_name)
Definition: statistics.h:55
Waveform::realseq_t m_waveform
Definition: ImpactData.h:20
Waveform::compseq_t & weight_spectrum() const
Definition: ImpactData.cxx:32
Sequence< complex_t > compseq_t
A complex-valued sequence, eg for discrete spectrum powers.
Definition: Waveform.h:34
std::shared_ptr< GaussianDiffusion > pointer
Waveform::compseq_t m_spectrum
Definition: ImpactData.h:21