meerkat is hosted by Hepforge, IPPP Durham
Meerkat  v1r3
Multidimensional kernel density estimation package
OneDimPhaseSpace.cpp
Go to the documentation of this file.
1 #include "OneDimPhaseSpace.hh"
2 #include <stdio.h>
3 #include <stdlib.h>
4 
5 #include <vector>
6 
7 #include "TMath.h"
8 
9 // Define some tolerance to be used to make sure that the lower and upper limits
10 // fall into the phase space
11 #define TOLERANCE 1e-30
12 
13 #include "Logger.hh"
14 
15 OneDimPhaseSpace::OneDimPhaseSpace(const char* phspName,
16  Double_t lower,
17  Double_t upper) : AbsPhaseSpace(phspName) {
18 
19  Logger::print(0,"%20.20s INFO: Creating 1D phase space in range (%f, %f)\n", m_name, lower, upper);
20 
21  m_lowerLimit = lower;
22  m_upperLimit = upper;
23 
24  if (m_upperLimit <= m_lowerLimit) {
25  Logger::print(2,"%20.20s ERROR: Upper limit (%f) <= lowerLimit (%f) for flat phase space\n",
27  abort();
28  }
29 
30 }
31 
33 
34 }
35 
36 Bool_t OneDimPhaseSpace::withinLimits(std::vector<Double_t> &x) {
37  Double_t x1 = x[0];
38 // if (x1 > m_upperLimit + TOLERANCE || x1 < m_lowerLimit - TOLERANCE) return 0;
39  if (x1 > m_upperLimit || x1 < m_lowerLimit) return 0;
40  return 1;
41 }
42 
43 Double_t OneDimPhaseSpace::lowerLimit(UInt_t var) {
44  if (var == 0) return m_lowerLimit;
45  Logger::print(2,"%20.20s ERROR: var=%d for lower limit of 1D phase space\n", m_name, var);
46  abort();
47  return 0;
48 }
49 
50 Double_t OneDimPhaseSpace::upperLimit(UInt_t var) {
51  if (var == 0) return m_upperLimit;
52  Logger::print(2,"%20.20s ERROR: var=%d for upper limit of 1D phase space\n", m_name, var);
53  abort();
54  return 0;
55 
56 }
57 
58 Bool_t OneDimPhaseSpace::limits(UInt_t var, __attribute__((unused)) std::vector<Double_t> &x,
59  Double_t* lower, Double_t* upper) {
60 
61  if (var == 0) {
62  *lower = m_lowerLimit;
63  *upper = m_upperLimit;
64  return 1;
65  }
66  Logger::print(2,"%20.20s ERROR: var=%d for limits of 1D phase space\n", m_name, var);
67  abort();
68  return 0;
69 }
Bool_t limits(UInt_t var, std::vector< Double_t > &x, Double_t *lower, Double_t *upper)
Return limits (lower and upper) for the variable at the certain point of the phase space...
Double_t m_lowerLimit
Lower limit.
Bool_t withinLimits(std::vector< Double_t > &x)
Check if the point is within the phase space limits.
Double_t m_upperLimit
Upper limit.
char m_name[256]
Phase space name.
Double_t lowerLimit(UInt_t var)
Get lower limit.
virtual ~OneDimPhaseSpace()
Destructor.
void print(int level, const char *format,...)
Definition: Logger.cpp:27
OneDimPhaseSpace(const char *phaseSpaceName, Double_t lowerLimit, Double_t upperLimit)
Constructor.
Abstract class which defines phase space interface.
Double_t upperLimit(UInt_t var)
Get upper limit.