CMS 3D CMS Logo

/afs/cern.ch/work/a/aaltunda/public/www/CMSSW_6_2_5/src/RecoTracker/DeDx/interface/TruncatedAverageDeDxEstimator.h

Go to the documentation of this file.
00001 #ifndef RecoTrackerDeDx_TruncatedAverageDeDxEstimator_h
00002 #define RecoTrackerDeDx_TruncatedAverageDeDxEstimator_h
00003 
00004 #include "RecoTracker/DeDx/interface/DeDxTools.h"
00005 #include "DataFormats/TrackReco/interface/DeDxHit.h"
00006 #include <numeric>
00007 
00008 class TruncatedAverageDeDxEstimator: public BaseDeDxEstimator
00009 {
00010 public: 
00011  TruncatedAverageDeDxEstimator(float fraction): m_fraction(fraction) {}
00012 
00013  virtual std::pair<float,float> dedx(const reco::DeDxHitCollection& Hits){
00014     int nTrunc = int( Hits.size()*m_fraction);
00015     double sumdedx = 0;
00016     for(size_t i=0;i + nTrunc <  Hits.size() ; i++){
00017        sumdedx+=Hits[i].charge();
00018     } 
00019    double avrdedx = (Hits.size()) ? sumdedx/(Hits.size()-nTrunc) :0.0;
00020    return  std::make_pair(avrdedx,-1);
00021  } 
00022 
00023 private:
00024  float m_fraction;
00025 
00026 };
00027 
00028 #endif