Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:28:05

0001 #ifndef RecoTrackerDeDx_TruncatedAverageDeDxEstimator_h
0002 #define RecoTrackerDeDx_TruncatedAverageDeDxEstimator_h
0003 
0004 #include "RecoTracker/DeDx/interface/BaseDeDxEstimator.h"
0005 #include "RecoTracker/DeDx/interface/DeDxTools.h"
0006 #include "DataFormats/TrackReco/interface/DeDxHit.h"
0007 #include <numeric>
0008 
0009 class TruncatedAverageDeDxEstimator : public BaseDeDxEstimator {
0010 public:
0011   TruncatedAverageDeDxEstimator(const edm::ParameterSet& iConfig) {
0012     fraction_ = iConfig.getParameter<double>("fraction");
0013   }
0014 
0015   std::pair<float, float> dedx(const reco::DeDxHitCollection& Hits) override {
0016     int nTrunc = int(Hits.size() * fraction_);
0017     double sumdedx = 0;
0018     for (size_t i = 0; i + nTrunc < Hits.size(); i++) {
0019       sumdedx += Hits[i].charge();
0020     }
0021     double avrdedx = (!Hits.empty()) ? sumdedx / (Hits.size() - nTrunc) : 0.0;
0022     return std::make_pair(avrdedx, -1);
0023   }
0024 
0025 private:
0026   float fraction_;
0027 };
0028 
0029 #endif