CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Weight.h
Go to the documentation of this file.
1 //-*-c++-*-
2 //-*-Weight.h-*-
3 // Written by James Monk and Andrew Pilkington
5 #ifndef WEIGHT_HH
6 #define WEIGHT_HH
7 
8 #include <iostream>
9 #include <map>
10 #include <vector>
11 
12 namespace Exhume {
13 
14  class Weight {
15  public:
16  Weight() { NPoints = 1000; };
17  virtual ~Weight(){};
18  inline std::map<double, double> GetFuncMap() { return (FuncMap); };
19  inline double GetTotalIntegral() { return (TotalIntegral); };
20 
21  inline std::map<double, double> GetLineShape() { return (LineShape); };
22 
23  protected:
24  virtual double WeightFunc(const double &) = 0;
25 
26  void AddPoint(const double &, const double &);
27  inline double GetFunc(const double &xx_) {
28  if (xx_ > Max_) {
29  return (WeightFunc(xx_));
30  }
31 
32  std::map<double, double>::iterator high_, low_;
33  high_ = FuncMap.upper_bound(xx_);
34  low_ = high_;
35  low_--;
36 
37  return (low_->second + (high_->second - low_->second) * (xx_ - low_->first) / (high_->first - low_->first));
38  };
39 
40  inline double GetValue(const double &xx_) {
41  std::map<double, double>::iterator high_, low_;
42  high_ = LineShape.upper_bound(xx_);
43 
44  if (high_ == LineShape.end())
45  high_--;
46 
47  low_ = high_;
48  low_--;
49 
50  return (low_->second + (high_->second - low_->second) * (xx_ - low_->first) / (high_->first - low_->first));
51  };
52  void WeightInit(const double &, const double &);
53 
54  double Max_;
55  double TotalIntegral;
56 
57  private:
58  unsigned int NPoints;
59  std::map<double, double> FuncMap;
60  std::map<double, double> LineShape;
61  };
62 } // namespace Exhume
63 
64 #endif
std::map< double, double > GetLineShape()
Definition: Weight.h:21
void AddPoint(const double &, const double &)
unsigned int NPoints
Definition: Weight.h:58
double TotalIntegral
Definition: Weight.h:55
void WeightInit(const double &, const double &)
double Max_
Definition: Weight.h:54
std::map< double, double > GetFuncMap()
Definition: Weight.h:18
std::map< double, double > FuncMap
Definition: Weight.h:59
double GetValue(const double &xx_)
Definition: Weight.h:40
virtual double WeightFunc(const double &)=0
virtual ~Weight()
Definition: Weight.h:17
std::map< double, double > LineShape
Definition: Weight.h:60
double GetTotalIntegral()
Definition: Weight.h:19
double GetFunc(const double &xx_)
Definition: Weight.h:27