Classes | Typedefs | Functions
pmtana Namespace Reference

Classes

class  AlgoCFD
 
class  AlgoFixedWindow
 
class  AlgoSiPM
 
class  AlgoSlidingWindow
 
class  AlgoSSPLeadingEdge
 
class  AlgoThreshold
 
class  OpticalRecoException
 
class  PedAlgoEdges
 
class  PedAlgoRmsSlider
 
class  PedAlgoRollingMean
 
class  PedAlgoUB
 
class  PMTAna
 
class  PMTPedestalBase
 
class  PMTPulseRecoBase
 
struct  pulse_param
 
class  PulseRecoManager
 

Typedefs

typedef std::vector< short > Waveform_t
 
typedef std::vector< double > PedestalMean_t
 
typedef std::vector< double > PedestalSigma_t
 
typedef std::vector< pmtana::pulse_parampulse_param_array
 

Functions

bool CheckIndex (const std::vector< short > &wf, const size_t &begin, size_t &end)
 
double mean (const std::vector< short > &wf, size_t start, size_t nsample)
 
double edge_aware_mean (const std::vector< short > &wf, int start, int end)
 
double std (const std::vector< short > &wf, const double ped_mean, size_t start, size_t nsample)
 
double BinnedMaxOccurrence (const PedestalMean_t &mean_v, const size_t nbins)
 
int sign (double val)
 
double BinnedMaxTH1D (const std::vector< double > &v, int bins)
 

Typedef Documentation

Definition at line 9 of file OpticalRecoTypes.h.

Definition at line 10 of file OpticalRecoTypes.h.

Definition at line 49 of file PMTPulseRecoBase.h.

typedef std::vector< short > pmtana::Waveform_t

Definition at line 8 of file OpticalRecoTypes.h.

Function Documentation

double pmtana::BinnedMaxOccurrence ( const PedestalMean_t mean_v,
const size_t  nbins 
)

Definition at line 59 of file UtilFunc.cxx.

60  {
61  if(nbins<1) throw OpticalRecoException("Cannot have 0 binning");
62 
63  auto res = std::minmax_element(std::begin(mean_v),std::end(mean_v));
64 
65  double bin_width = ((*res.second) - (*res.first)) / ((double)nbins);
66 
67  if(nbins==1 || bin_width == 0) return ((*res.first) + bin_width /2.);
68 
69  //std::cout<<"Min: "<<(*res.first)<<" Max: "<<(*res.second)<<" Width: "<<bin_width<<std::endl;
70 
71  // Construct array of nbins
72  static std::vector<size_t> ctr_v(nbins,0);
73  for(auto& v : ctr_v) v=0;
74  for(auto const& v : mean_v) {
75 
76  size_t index = int((v - (*res.first))/bin_width);
77  //std::cout<<"adc = "<<v<<" width = "<<bin_width<< " ... "
78  //<<index<<" / "<<ctr_v.size()<<std::endl;
79 
80  ctr_v[index]++;
81 
82  }
83 
84  // Find max occurrence
85  auto max_it = std::max_element(std::begin(ctr_v),std::end(ctr_v));
86 
87  // Get the mean of max-occurrence bins
88  double mean_max_occurrence = 0;
89  double num_occurrence = 0;
90  for(size_t bin=0; bin<ctr_v.size(); ++bin) {
91 
92  if(ctr_v[bin] != (*max_it)) continue;
93 
94  mean_max_occurrence += ((*res.first) + bin_width / 2. + bin_width * bin);
95 
96  num_occurrence += 1.0;
97  }
98 
99  return (mean_max_occurrence / num_occurrence);
100  }
end
while True: pbar.update(maxval-len(onlies[E][S])) #print iS, "/", len(onlies[E][S]) found = False for...
QTextStream & bin(QTextStream &s)
decltype(auto) constexpr begin(T &&obj)
ADL-aware version of std::begin.
Definition: StdUtils.h:72
double pmtana::BinnedMaxTH1D ( const std::vector< double > &  v,
int  bins 
)

Definition at line 112 of file UtilFunc.cxx.

112  {
113 
114  auto max_it = std::max_element(std::begin(v), std::end(v));
115  auto min_it = std::min_element(std::begin(v), std::end(v));
116 
117  TH1D th("th",";;",bins,*min_it,*max_it);
118 
119  for (const auto & m : v) th.Fill(m);
120 
121  return th.GetXaxis()->GetBinCenter(th.GetMaximumBin());
122  }
end
while True: pbar.update(maxval-len(onlies[E][S])) #print iS, "/", len(onlies[E][S]) found = False for...
decltype(auto) constexpr begin(T &&obj)
ADL-aware version of std::begin.
Definition: StdUtils.h:72
bool pmtana::CheckIndex ( const std::vector< short > &  wf,
const size_t &  begin,
size_t &  end 
)

Definition at line 41 of file PMTPulseRecoBase.cxx.

43  {
44  if(begin >= wf.size() || end >= wf.size() || begin > end){
45 
46  std::cerr <<"Invalid arguments: waveform length = " << wf.size() << " begin = " << begin << " end = " << end << std::endl;
47 
48  return false;
49  }
50 
51  if(!end) end = wf.size() - 1;
52 
53  return true;
54  }
end
while True: pbar.update(maxval-len(onlies[E][S])) #print iS, "/", len(onlies[E][S]) found = False for...
decltype(auto) constexpr begin(T &&obj)
ADL-aware version of std::begin.
Definition: StdUtils.h:72
QTextStream & endl(QTextStream &s)
double pmtana::edge_aware_mean ( const std::vector< short > &  wf,
int  start,
int  end 
)

Definition at line 25 of file UtilFunc.cxx.

25  {
26 
27  auto m = double{0.0};
28  auto n_t = unsigned{0};
29 
30  for(int k = start; k < end; ++k) {
31  if (k < 0 or k > (int)(wf.size()) - 1) continue;
32  m += wf.at(k);
33  ++n_t;
34  }
35 
36  if( n_t > 0 ) m /= n_t;
37  n_t = 0;
38 
39  return m;
40  }
end
while True: pbar.update(maxval-len(onlies[E][S])) #print iS, "/", len(onlies[E][S]) found = False for...
double pmtana::mean ( const std::vector< short > &  wf,
size_t  start,
size_t  nsample 
)

Definition at line 13 of file UtilFunc.cxx.

14  {
15  if(!nsample) nsample = wf.size();
16  if(start > wf.size() || (start+nsample) > wf.size())
17  throw OpticalRecoException("Invalid start/end index!");
18 
19  double sum = std::accumulate(wf.begin()+start,wf.begin()+start+nsample,0.0) / ((double)nsample);
20 
21  return sum;
22  }
int pmtana::sign ( double  val)

Definition at line 104 of file UtilFunc.cxx.

104  {
105 
106  if (val > 0) return 1;
107  if (val < 0) return -1;
108  return 0;
109 
110  }
double pmtana::std ( const std::vector< short > &  wf,
const double  ped_mean,
size_t  start,
size_t  nsample 
)

Definition at line 42 of file UtilFunc.cxx.

43  {
44  if(!nsample) nsample = wf.size();
45  if(start > wf.size() || (start+nsample) > wf.size())
46  throw OpticalRecoException("Invalid start/end index!");
47 
48  double sigma = 0;
49 
50  for(size_t index=start; index < (start+nsample); ++index)
51 
52  sigma += pow( (wf[index] - ped_mean), 2 );
53 
54  sigma = sqrt(sigma/((double)(nsample)));
55 
56  return sigma;
57  }
constexpr T pow(T x)
Definition: pow.h:72