test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros 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 
16  public:
17 
18  Weight(){NPoints = 1000;};
19  virtual ~Weight(){};
20  inline std::map<double, double> GetFuncMap(){
21  return(FuncMap);
22  };
23  inline double GetTotalIntegral(){
24  return(TotalIntegral);
25  };
26 
27  inline std::map<double, double> GetLineShape(){
28  return(LineShape);
29  };
30 
31  protected:
32 
33  virtual double WeightFunc(const double&)=0;
34 
35  void AddPoint(const double&, const double&);
36  inline double GetFunc(const double &xx_){
37  if(xx_ > Max_){
38  return(WeightFunc(xx_) );
39  }
40 
41  std::map<double, double>::iterator high_, low_;
42  high_ = FuncMap.upper_bound(xx_);
43  low_ = high_;
44  low_--;
45 
46  return( low_->second +
47  (high_->second - low_->second) * (xx_ - low_->first)/
48  (high_->first - low_->first));
49  };
50 
51  inline double GetValue(const double &xx_){
52 
53  std::map<double, double>::iterator high_, low_;
54  high_ = LineShape.upper_bound(xx_);
55 
56  if(high_==LineShape.end())high_--;
57 
58  low_ = high_;
59  low_--;
60 
61  return( low_->second +
62  (high_->second - low_->second) * (xx_ - low_->first)/
63  (high_->first - low_->first));
64  };
65  void WeightInit(const double&, const double&);
66 
67  double Max_;
68  double TotalIntegral;
69 
70  private:
71 
72  unsigned int NPoints;
73  std::map<double, double> FuncMap;
74  std::map<double, double> LineShape;
75  };
76 }
77 
78 
79 
80 #endif
std::map< double, double > GetLineShape()
Definition: Weight.h:27
void AddPoint(const double &, const double &)
unsigned int NPoints
Definition: Weight.h:72
double TotalIntegral
Definition: Weight.h:68
void WeightInit(const double &, const double &)
double Max_
Definition: Weight.h:67
std::map< double, double > GetFuncMap()
Definition: Weight.h:20
std::map< double, double > FuncMap
Definition: Weight.h:73
double GetValue(const double &xx_)
Definition: Weight.h:51
virtual double WeightFunc(const double &)=0
virtual ~Weight()
Definition: Weight.h:19
std::map< double, double > LineShape
Definition: Weight.h:74
double GetTotalIntegral()
Definition: Weight.h:23
double GetFunc(const double &xx_)
Definition: Weight.h:36