GeoModel - GeoModelCore
CellPartitioning.h
1 /*
2  Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 #ifndef GEOMODELKERNEL_CELLPARTITIONING_H
6 #define GEOMODELKERNEL_CELLPARTITIONING_H
7 #include <vector>
8 
10 {
11  public:
12 
13  CellPartitioning(unsigned int firstDivisionNumber = 0);
14 
15  CellPartitioning(const CellPartitioning& right);
16 
17  virtual ~CellPartitioning();
18 
19  CellPartitioning& operator=(const CellPartitioning& right);
20 
21  void addValue(double xVal);
22 
23  double binLower(unsigned int i) const
24  {
25  return m_partition[i-getFirstDivisionNumber()];
26  }
27 
28  double binUpper(unsigned int i) const
29  {
30  return m_partition[i-getFirstDivisionNumber()+1];
31  }
32 
33  double binCenter(unsigned int i) const
34  {
35  return 0.5*(binUpper(i)+binLower(i));
36  }
37 
38  unsigned int getNumDivisions() const
39  {
40  return m_partition.size()-1;
41  }
42 
43  unsigned int getFirstDivisionNumber() const
44  {
45  return m_firstDivisionNumber;
46  }
47 
48  double getStart() const
49  {
50  return m_partition[0];
51  }
52 
53  double getEnd() const
54  {
55  return m_partition[m_partition.size()-1];
56  }
57 
58  private:
59 
60  std::vector<double> m_partition;
61 
62  unsigned int m_firstDivisionNumber;
63 };
64 
65 #endif