LArSoft  v07_13_02
Liquid Argon Software toolkit - http://larsoft.org/
util::NormalDistribution Class Reference

#include "PIDAAlg.h"

Public Member Functions

 NormalDistribution ()
 
 NormalDistribution (float, float)
 
float getValue (float)
 

Private Attributes

float fStepSize
 
float fMaxSigma
 
std::vector< float > fValues
 

Detailed Description

Definition at line 21 of file PIDAAlg.h.

Constructor & Destructor Documentation

util::NormalDistribution::NormalDistribution ( )
inline

Definition at line 24 of file PIDAAlg.h.

References getValue().

24 {}
util::NormalDistribution::NormalDistribution ( float  max_sigma,
float  step_size 
)

Definition at line 335 of file PIDAAlg.cxx.

335  {
336 
337  if(step_size==0)
338  throw "util::NormalDistribution --- Cannot have zero step size!";
339 
340  const size_t vector_size = (size_t)(max_sigma / step_size);
341  fValues.resize(vector_size);
342 
343  const float AMPLITUDE = 1. / std::sqrt(2*M_PI);
344 
345  float integral=0;
346  for(size_t i_step=0; i_step<vector_size; i_step++){
347  float diff = i_step*step_size;
348  fValues[i_step] = AMPLITUDE * std::exp(-0.5*diff*diff);
349  integral+= fValues[i_step];
350  }
351 
352  for(size_t i_step=0; i_step<vector_size; i_step++)
353  fValues[i_step] /= (integral*2);
354 
355  fStepSize = step_size;
356  fMaxSigma = fStepSize * vector_size;
357 
358 }
std::vector< float > fValues
Definition: PIDAAlg.h:32

Member Function Documentation

float util::NormalDistribution::getValue ( float  x)

Definition at line 360 of file PIDAAlg.cxx.

Referenced by pid::PIDAAlg::createKDE(), and NormalDistribution().

360  {
361 
362  x = std::abs(x);
363  if(x > fMaxSigma) return 0;
364 
365  size_t bin_low = x / fStepSize;
366  float remainder = (x - (bin_low*fStepSize)) / fStepSize;
367 
368  return fValues[bin_low]*(1-remainder) + remainder*fValues[bin_low+1];
369 
370 }
Float_t x
Definition: compare.C:6
std::vector< float > fValues
Definition: PIDAAlg.h:32

Member Data Documentation

float util::NormalDistribution::fMaxSigma
private

Definition at line 31 of file PIDAAlg.h.

float util::NormalDistribution::fStepSize
private

Definition at line 30 of file PIDAAlg.h.

std::vector<float> util::NormalDistribution::fValues
private

Definition at line 32 of file PIDAAlg.h.


The documentation for this class was generated from the following files: