CMS 3D CMS Logo

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
Exhume::Weight::Max_
double Max_
Definition: Weight.h:54
Exhume::Weight::GetValue
double GetValue(const double &xx_)
Definition: Weight.h:40
Exhume::Weight::GetFuncMap
std::map< double, double > GetFuncMap()
Definition: Weight.h:18
Exhume::Weight::GetTotalIntegral
double GetTotalIntegral()
Definition: Weight.h:19
Exhume::Weight::WeightFunc
virtual double WeightFunc(const double &)=0
Exhume::Weight::GetFunc
double GetFunc(const double &xx_)
Definition: Weight.h:27
Exhume
Definition: CrossSection.h:37
Exhume::Weight::LineShape
std::map< double, double > LineShape
Definition: Weight.h:60
Exhume::Weight::~Weight
virtual ~Weight()
Definition: Weight.h:17
Exhume::Weight::NPoints
unsigned int NPoints
Definition: Weight.h:58
Exhume::Weight::GetLineShape
std::map< double, double > GetLineShape()
Definition: Weight.h:21
Exhume::Weight::AddPoint
void AddPoint(const double &, const double &)
Exhume::Weight::Weight
Weight()
Definition: Weight.h:16
Exhume::Weight
Definition: Weight.h:14
Exhume::Weight::WeightInit
void WeightInit(const double &, const double &)
Exhume::Weight::TotalIntegral
double TotalIntegral
Definition: Weight.h:55
Exhume::Weight::FuncMap
std::map< double, double > FuncMap
Definition: Weight.h:59