CombineHarvester
Process.h
Go to the documentation of this file.
1 #ifndef CombineTools_Process_h
2 #define CombineTools_Process_h
3 #include <memory>
4 #include <string>
5 #include "TH1.h"
6 #include "RooAbsPdf.h"
7 #include "RooAbsReal.h"
8 #include "RooAbsData.h"
9 #include "RooRealVar.h"
12 
13 namespace ch {
14 
15 class Process : public Object {
16  public:
17  Process();
18  ~Process();
19  Process(Process const& other);
20  Process(Process&& other);
21  Process& operator=(Process other);
22 
23 
24  void set_rate(double const& rate) { rate_ = rate; }
25  double rate() const {
26  double base = 1.;
27  if (pdf_ && !dynamic_cast<RooAbsPdf*>(pdf_) && cached_obs_) {
28  if (!cached_int_) {
29  cached_int_ = pdf_->createIntegral(RooArgSet(*cached_obs_));
30  }
31  base = cached_int_->getVal();
32  }
33  return norm_ ? base * norm_->getVal() * rate_ : base * rate_;
34  }
35 
46  double no_norm_rate() const { return rate_; }
47 
48  void set_shape(std::unique_ptr<TH1> shape, bool set_rate);
49 
50  void set_shape(TH1 const& shape, bool set_rate);
51 
52  TH1 const* shape() const { return shape_.get(); }
53 
54  std::unique_ptr<TH1> ClonedShape() const;
55  std::unique_ptr<TH1> ClonedScaledShape() const;
56 
57  TH1F ShapeAsTH1F() const;
58 
59  void set_pdf(RooAbsReal* pdf) { pdf_ = pdf; }
60  RooAbsReal const* pdf() const { return pdf_; }
61 
62  void set_data(RooAbsData* data) { data_ = data; }
63  RooAbsData const* data() const { return data_; }
64 
65  void set_norm(RooAbsReal* norm) { norm_ = norm; }
66  RooAbsReal const* norm() const { return norm_; }
67 
68  void set_observable(RooRealVar* obs) { cached_obs_ = obs; }
69  RooRealVar * observable() const { return cached_obs_; }
70 
71  std::string to_string() const;
72  friend std::ostream& operator<< (std::ostream &out, Process const& val);
73  static std::ostream& PrintHeader(std::ostream &out);
74 
75  private:
76  double rate_;
77  std::unique_ptr<TH1> shape_;
78  RooAbsReal* pdf_;
79  RooAbsData* data_;
80  RooAbsReal* norm_;
81  RooRealVar* cached_obs_;
82  mutable RooAbsReal* cached_int_;
83 
84  friend void swap(Process& first, Process& second);
85 };
86 }
87 
88 #endif
double no_norm_rate() const
Get the process normalisation without multiplying by the RooAbsReal value (in the case that it's pres...
Definition: Process.h:46
TH1F ShapeAsTH1F() const
Definition: Process.cc:124
void set_norm(RooAbsReal *norm)
Definition: Process.h:65
RooAbsReal const * pdf() const
Definition: Process.h:60
void set_rate(double const &rate)
Definition: Process.h:24
std::unique_ptr< TH1 > ClonedScaledShape() const
Definition: Process.cc:117
double rate() const
Definition: Process.h:25
void set_shape(std::unique_ptr< TH1 > shape, bool set_rate)
Definition: Process.cc:81
RooAbsReal const * norm() const
Definition: Process.h:66
std::string to_string() const
Definition: Process.cc:166
RooAbsData const * data() const
Definition: Process.h:63
void set_data(RooAbsData *data)
Definition: Process.h:62
RooRealVar * observable() const
Definition: Process.h:69
static std::ostream & PrintHeader(std::ostream &out)
Definition: Process.cc:153
friend void swap(Process &first, Process &second)
Definition: Process.cc:36
friend std::ostream & operator<<(std::ostream &out, Process const &val)
Definition: Process.cc:170
TH1 const * shape() const
Definition: Process.h:52
void set_pdf(RooAbsReal *pdf)
Definition: Process.h:59
Process & operator=(Process other)
Definition: Process.cc:76
void set_observable(RooRealVar *obs)
Definition: Process.h:68
std::unique_ptr< TH1 > ClonedShape() const
Definition: Process.cc:110
Definition: Algorithm.h:10