rivet is hosted by Hepforge, IPPP Durham
Rivet  2.7.0
BinnedHistogram.hh
1 // -*- C++ -*-
2 #ifndef RIVET_BINNEDHISTOGRAM_HH
3 #define RIVET_BINNEDHISTOGRAM_HH
4 
5 #include "Rivet/Config/RivetCommon.hh"
6 #include "Rivet/Tools/RivetYODA.hh"
7 
8 namespace Rivet {
9 
10  class Analysis;
11 
12 
19  template<typename T>
21  public:
22 
25 
27  BinnedHistogram(const vector<T>& edges, const vector<Histo1DPtr>& histos) {
28  assert(edges.size() == histos.size()+1);
29  for (size_t i = 0; i < histos.size(); ++i)
30  addHistogram(edges[i], edges[i+1], histos[i]);
31  }
32 
34 
35 
37  const BinnedHistogram<T>& add(const T& binMin, const T& binMax, Histo1DPtr histo);
40  const BinnedHistogram<T>& addHistogram(const T& binMin, const T& binMax, Histo1DPtr histo) {
41  return add(binMin, binMax, histo);
42  }
43 
44 
46  void fill(const T& binval, double val, double weight);
47 
48 
51  const Histo1DPtr histo(const T& binval) const;
54  Histo1DPtr histo(const T& binval);
55 
57  const vector<Histo1DPtr>& histos() const { return _histos; }
59  vector<Histo1DPtr>& histos() { return _histos; }
61  const vector<Histo1DPtr>& getHistograms() const { return _histos; }
63  vector<Histo1DPtr>& getHistograms() { return _histos; }
64 
65 
68  void scale(const T& scale, Analysis* ana);
69 
70 
71  private:
72 
73  map<T, Histo1DPtr> _histosByUpperBound, _histosByLowerBound;
74  vector<Histo1DPtr> _histos;
75  map<Histo1DPtr, T> _binWidths;
76 
77  };
78 
79 
80 }
81 
82 #endif
Definition: ALICE_2010_I880049.cc:13
void scale(const T &scale, Analysis *ana)
Definition: BinnedHistogram.cc:71
const BinnedHistogram< T > & add(const T &binMin, const T &binMax, Histo1DPtr histo)
Add a histogram in the T bin between binMin and binMax.
Definition: BinnedHistogram.cc:10
const BinnedHistogram< T > & addHistogram(const T &binMin, const T &binMax, Histo1DPtr histo)
Definition: BinnedHistogram.hh:40
vector< Histo1DPtr > & histos()
Get the contained histograms.
Definition: BinnedHistogram.hh:59
void fill(const T &binval, double val, double weight)
Fill the histogram in the same bin as binval with value val and weight weight.
Definition: BinnedHistogram.cc:61
This is the base class of all analysis classes in Rivet.
Definition: Analysis.hh:52
vector< Histo1DPtr > & getHistograms()
Definition: BinnedHistogram.hh:63
BinnedHistogram(const vector< T > &edges, const vector< Histo1DPtr > &histos)
Create a new BinnedHistogram with the given bin edges and contents.
Definition: BinnedHistogram.hh:27
const Histo1DPtr histo(const T &binval) const
Get the histogram in the same bin as binval (const)
Definition: BinnedHistogram.cc:32
Definition: BinnedHistogram.hh:20
BinnedHistogram()
Create a new empty BinnedHistogram.
Definition: BinnedHistogram.hh:24
const vector< Histo1DPtr > & histos() const
Get the contained histograms (const)
Definition: BinnedHistogram.hh:57
const vector< Histo1DPtr > & getHistograms() const
Definition: BinnedHistogram.hh:61