Rivet  3.1.0
BinnedHistogram.hh
1 // -*- C++ -*-
2 #ifndef RIVET_BINNEDHISTOGRAM_HH
3 #define RIVET_BINNEDHISTOGRAM_HH
4 
7 
8 
9 #include "Rivet/Config/RivetCommon.hh"
10 #include "Rivet/Tools/RivetYODA.hh"
11 
12 namespace Rivet {
13 
14  class Analysis;
15 
16 
24  public:
25 
27  BinnedHistogram() = default;
28 
30  BinnedHistogram(const vector<double>& edges, const vector<Histo1DPtr>& histos) {
31  assert(edges.size() == histos.size()+1);
32  for (size_t i = 0; i < histos.size(); ++i)
33  add(edges[i], edges[i+1], histos[i]);
34  }
35 
37 
38 
40  const BinnedHistogram & add(double binMin, double binMax, Histo1DPtr histo);
41 
42 
44  void fill(double binval, double val, double weight = 1.0);
45 
46 
49  const Histo1DPtr histo(double binval) const;
52  Histo1DPtr histo(double binval);
53 
55  const vector<Histo1DPtr>& histos() const { return _histos; }
57  vector<Histo1DPtr>& histos() { return _histos; }
58 
59 
60 
63  void scale(double scale, Analysis* ana);
64 
65 
66  private:
67 
68  map<double, Histo1DPtr> _histosByUpperBound, _histosByLowerBound;
69  vector<Histo1DPtr> _histos;
70  map<Histo1DPtr, double> _binWidths;
71 
72  };
73 
74 
75 }
76 
77 #endif
const Histo1DPtr histo(double binval) const
Get the histogram in the same bin as binval (const)
Definition: MC_Cent_pPb.hh:10
void fill(double binval, double val, double weight=1.0)
Fill the histogram in the same bin as binval with value val and weight weight.
void scale(double scale, Analysis *ana)
BinnedHistogram(const vector< double > &edges, const vector< Histo1DPtr > &histos)
Create a new BinnedHistogram with the given bin edges and contents.
Definition: BinnedHistogram.hh:30
const BinnedHistogram & add(double binMin, double binMax, Histo1DPtr histo)
Add a histogram in the T bin between binMin and binMax.
This is the base class of all analysis classes in Rivet.
Definition: Analysis.hh:64
BinnedHistogram()=default
Create a new empty BinnedHistogram.
vector< Histo1DPtr > & histos()
Get the contained histograms.
Definition: BinnedHistogram.hh:57
const vector< Histo1DPtr > & histos() const
Get the contained histograms (const)
Definition: BinnedHistogram.hh:55
A set of booked Histo1DPtr, each in a bin of a second variable.
Definition: BinnedHistogram.hh:23