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 {
11 public:
13  m_fraction = iConfig.getParameter<double>("fraction");
14  m_expo = iConfig.getParameter<double>("exponent");
15  }
16 
17  std::pair<float,float> dedx(const reco::DeDxHitCollection& Hits) override{
18  int first = 0, last = Hits.size();
19  if (m_fraction > 0) { // truncate high charge ones
20  last -= int(Hits.size()*m_fraction);
21  } else {
22  first += int(Hits.size()*(-m_fraction));
23  }
24  double sumdedx = 0;
25  for(int i = first; i < last; i++){
26  sumdedx+=pow(Hits[i].charge(),m_expo);
27  }
28  double avrdedx = (last-first) ? pow(sumdedx/(last-first),1.0/m_expo) :0.0;
29  return std::make_pair(avrdedx,-1);
30  }
31 
32 private:
34 
35 };
36 
37 #endif
T getParameter(std::string const &) const
std::vector< DeDxHit > DeDxHitCollection
Definition: DeDxHit.h:58
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:40