All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Weight_t.h
Go to the documentation of this file.
1 #ifndef _WEIGHT_T_H_
2 #define _WEIGHT_T_H_
3 
4 #include "WeightCalc.h"
5 
6 #include <numeric> // std::accumulate()
7 
8 namespace evwgh {
9  struct Weight_t {
10 
12  fMinWeight(std::numeric_limits<double>::max()),
13  fMaxWeight(std::numeric_limits<double>::min()),
14  fAvgWeight(0),
15  fNcalls(0)
16  {}
17 
18  std::vector<std::vector<double> > GetWeight(art::Event& e) {
19  std::vector<std::vector<double> >wgh=fWeightCalc->GetWeight(e);
20  for (unsigned int inu=0;inu<wgh.size();inu++) {
21  double avgwgh=std::accumulate(wgh[inu].begin(),wgh[inu].end(),0.0)/wgh[inu].size();
22  fAvgWeight=(fAvgWeight*fNcalls+avgwgh)/float(fNcalls+1);
23  fMinWeight=std::min(fMinWeight,
24  *std::min_element(wgh[inu].begin(),wgh[inu].end()));
25  fMaxWeight=std::max(fMaxWeight,
26  *std::max_element(wgh[inu].begin(),wgh[inu].end()));
27  fNcalls++;
28  }
29 
30  return wgh;
31  }
32  std::string fName;
34  std::string fWeightCalcType;
35  double fMinWeight;
36  double fMaxWeight;
37  double fAvgWeight;
38  long fNcalls;
40  };
41 
42 }
43 
44 #endif // _WEIGHT_T_H_
double std(const std::vector< short > &wf, const double ped_mean, size_t start, size_t nsample)
Definition: UtilFunc.cxx:42
WeightCalc * fWeightCalc
Definition: Weight_t.h:33
std::string fName
Definition: Weight_t.h:32
std::vector< std::vector< double > > GetWeight(art::Event &e)
Definition: Weight_t.h:18
std::string fWeightCalcType
Definition: Weight_t.h:34
auto end(FixedBins< T, C > const &) noexcept
Definition: FixedBins.h:585
auto begin(FixedBins< T, C > const &) noexcept
Definition: FixedBins.h:573
double fMaxWeight
Definition: Weight_t.h:36
do i e
virtual std::vector< std::vector< double > > GetWeight(art::Event &e)=0
double fMinWeight
Definition: Weight_t.h:35
double fAvgWeight
Definition: Weight_t.h:37