CMS 3D CMS Logo

List of all members | Public Member Functions | Private Attributes
GenericTruncatedAverageDeDxEstimator Class Reference

#include <GenericTruncatedAverageDeDxEstimator.h>

Inheritance diagram for GenericTruncatedAverageDeDxEstimator:
BaseDeDxEstimator

Public Member Functions

std::pair< float, float > dedx (const reco::DeDxHitCollection &Hits) override
 
 GenericTruncatedAverageDeDxEstimator (const edm::ParameterSet &iConfig)
 
- Public Member Functions inherited from BaseDeDxEstimator
virtual void beginRun (edm::Run const &run, const edm::EventSetup &iSetup)
 
virtual ~BaseDeDxEstimator ()
 

Private Attributes

float expo_
 
float fraction_
 
bool truncate_
 

Detailed Description

Definition at line 9 of file GenericTruncatedAverageDeDxEstimator.h.

Constructor & Destructor Documentation

◆ GenericTruncatedAverageDeDxEstimator()

GenericTruncatedAverageDeDxEstimator::GenericTruncatedAverageDeDxEstimator ( const edm::ParameterSet iConfig)
inline

Definition at line 11 of file GenericTruncatedAverageDeDxEstimator.h.

References expo_, fraction_, edm::ParameterSet::getParameter(), and truncate_.

11  {
12  fraction_ = iConfig.getParameter<double>("fraction");
13  expo_ = iConfig.getParameter<double>("exponent");
14  truncate_ = iConfig.getParameter<bool>("truncate");
15  }
T getParameter(std::string const &) const
Definition: ParameterSet.h:303

Member Function Documentation

◆ dedx()

std::pair<float, float> GenericTruncatedAverageDeDxEstimator::dedx ( const reco::DeDxHitCollection Hits)
inlineoverridevirtual

Implements BaseDeDxEstimator.

Definition at line 17 of file GenericTruncatedAverageDeDxEstimator.h.

References ALCARECOTkAlJpsiMuMu_cff::charge, expo_, first, fraction_, mps_fire::i, createfilelist::int, dqmdumpme::last, funct::pow(), and truncate_.

Referenced by DeDxHitInfoProducer::produce().

17  {
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  }
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:29

Member Data Documentation

◆ expo_

float GenericTruncatedAverageDeDxEstimator::expo_
private

◆ fraction_

float GenericTruncatedAverageDeDxEstimator::fraction_
private

◆ truncate_

bool GenericTruncatedAverageDeDxEstimator::truncate_
private