CMS 3D CMS Logo

GenericTruncatedAverageDeDxEstimator.h
Go to the documentation of this file.
1 #ifndef RecoTrackerDeDx_GenericTruncatedAverageDeDxEstimator_h
2 #define RecoTrackerDeDx_GenericTruncatedAverageDeDxEstimator_h
3 
7 #include <numeric>
8 
10 public:
12  fraction_ = iConfig.getParameter<double>("fraction");
13  expo_ = iConfig.getParameter<double>("exponent");
14  truncate_ = iConfig.getParameter<bool>("truncate");
15  }
16 
17  std::pair<float, float> dedx(const reco::DeDxHitCollection& Hits) override {
18  int first = 0, last = Hits.size();
19  if (truncate_) {
20  if (fraction_ > 0) { // truncate high charge ones
21  last -= int(Hits.size() * fraction_);
22  } else if (fraction_ < 0) {
23  first += int(Hits.size() * (-fraction_));
24  }
25  }
26  double sumdedx = 0;
27  for (int i = first; i < last; i++) {
28  sumdedx += pow(Hits[i].charge(), expo_);
29  }
30  double avrdedx = (last - first) ? pow(sumdedx / (last - first), 1.0 / expo_) : 0.0;
31  return std::make_pair(avrdedx, -1);
32  }
33 
34 private:
35  float fraction_, expo_;
36  bool truncate_;
37 };
38 
39 #endif
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
std::vector< DeDxHit > DeDxHitCollection
Definition: DeDxHit.h:41
GenericTruncatedAverageDeDxEstimator(const edm::ParameterSet &iConfig)
std::pair< float, float > dedx(const reco::DeDxHitCollection &Hits) override
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:29