Jpp test-rotations-old-533-g2bdbdb559
the software that should make you happy
Loading...
Searching...
No Matches
JRealExperiment.hh
Go to the documentation of this file.
1#ifndef __JASTRONOMY__JREALEXPERIMENT__
2#define __JASTRONOMY__JREALEXPERIMENT__
3
4#include <vector>
5
6#include "TObject.h"
7#include "TH1.h"
8#include "TH2.h"
9#include "TH3.h"
10
12#include "JAstronomy/JAspera.hh"
13
14
15/**
16 * \file
17 *
18 * Real experiment.
19 * \author mdejong
20 */
21namespace JASTRONOMY {}
22namespace JPP { using namespace JASTRONOMY; }
23
24namespace JASTRONOMY {
25
26 /**
27 * Real experiment using PDF of signal and background.
28 */
30 public JExperiment,
31 public JAspera
32 {
33 /**
34 * Default constructor.
35 */
38
39
40 /**
41 * Constructor.
42 *
43 * \param hd histogram with data
44 * \param hs histogram with PDF of signal
45 * \param hb histogram with PDF of background
46 */
47 template<class H_t>
48 JRealExperiment(const H_t& hd,
49 const H_t& hs,
50 const H_t& hb)
51 {
52 add(hd, hs, hb);
53 }
54
55
56 /**
57 * Add objects with data and PDFs of signal and background.
58 *
59 * \param pd pointer to object with data
60 * \param ps pointer to object with PDF of signal
61 * \param pb pointer to object with PDF of background
62 */
63 void add(const TObject* pd,
64 const TObject* ps,
65 const TObject* pb)
66 {
67 if (add<TH3>(pd, ps, pb)) { return; }
68 if (add<TH2>(pd, ps, pb)) { return; }
69 if (add<TH1>(pd, ps, pb)) { return; }
70 }
71
72
73 /**
74 * Add histograms with data and PDFs of signal and background.
75 *
76 * \param hd histogram with data
77 * \param hs histogram with PDF of signal
78 * \param hb histogram with PDF of background
79 */
80 void add(const TH1& hd,
81 const TH1& hs,
82 const TH1& hb)
83 {
84 for (Int_t ix = 1; ix <= hs.GetXaxis()->GetNbins(); ++ix) {
85 add(hd.GetBinContent(ix),
86 hs.GetBinContent(ix),
87 hb.GetBinContent(ix));
88 }
89 }
90
91
92 /**
93 * Add histograms with data and PDFs of signal and background.
94 *
95 * \param hd histogram with data
96 * \param hs histogram with PDF of signal
97 * \param hb histogram with PDF of background
98 */
99 void add(const TH2& hd,
100 const TH2& hs,
101 const TH2& hb)
102 {
103 for (Int_t ix = 1; ix <= hs.GetXaxis()->GetNbins(); ++ix) {
104 for (Int_t iy = 1; iy <= hs.GetYaxis()->GetNbins(); ++iy) {
105 add(hd.GetBinContent(ix, iy),
106 hs.GetBinContent(ix, iy),
107 hb.GetBinContent(ix, iy));
108 }
109 }
110 }
111
112
113 /**
114 * Add histograms with data and PDFs of signal and background.
115 *
116 * \param hd histogram with data
117 * \param hs histogram with PDF of signal
118 * \param hb histogram with PDF of background
119 */
120 void add(const TH3& hd,
121 const TH3& hs,
122 const TH3& hb)
123 {
124 for (Int_t ix = 1; ix <= hs.GetXaxis()->GetNbins(); ++ix) {
125 for (Int_t iy = 1; iy <= hs.GetYaxis()->GetNbins(); ++iy) {
126 for (Int_t iz = 1; iz <= hs.GetZaxis()->GetNbins(); ++iz) {
127 add(hd.GetBinContent(ix, iy, iz),
128 hs.GetBinContent(ix, iy, iz),
129 hb.GetBinContent(ix, iy, iz));
130 }
131 }
132 }
133 }
134
135
136 /**
137 * Add data, signal and background.
138 *
139 * \param n data
140 * \param s signal
141 * \param b background
142 */
143 void add(const size_t n,
144 const double s,
145 const double b)
146 {
147 if (check(s, b)) {
148 put(n, s, b);
149 }
150 }
151
152 protected:
153 /**
154 * Add objects with data and PDFs of signal and background.
155 *
156 * \param pd pointer to object with data
157 * \param ps pointer to object with PDF of signal
158 * \param pb pointer to object with PDF of background
159 * \return true if added; else false
160 */
161 template<class H_t>
162 bool add(const TObject* pd,
163 const TObject* ps,
164 const TObject* pb)
165 {
166 if (dynamic_cast<const H_t*>(pd) != NULL &&
167 dynamic_cast<const H_t*>(ps) != NULL &&
168 dynamic_cast<const H_t*>(pb) != NULL) {
169
170 const H_t& hd = dynamic_cast<const H_t&>(*pd);
171 const H_t& hs = dynamic_cast<const H_t&>(*ps);
172 const H_t& hb = dynamic_cast<const H_t&>(*pb);
173
174 if (check(hd, hs) && check(hs, hb)) {
175
176 add(hd, hs, hb);
177
178 return true;
179 }
180 }
181
182 return false;
183 }
184 };
185}
186
187#endif
Per aspera ad astra.
Experiment.
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
Auxiliary data structure to fit signal strength using likelihood ratio.
Definition JAspera.hh:24
void put(const double s, const double b)
Put signal and background to list of pre-computed N/S values.
Definition JAspera.hh:44
Auxiliary base class for experiment.
static bool check(const double s, const double b)
Check validity of signal and background.
Real experiment using PDF of signal and background.
void add(const TH2 &hd, const TH2 &hs, const TH2 &hb)
Add histograms with data and PDFs of signal and background.
void add(const TH1 &hd, const TH1 &hs, const TH1 &hb)
Add histograms with data and PDFs of signal and background.
void add(const TH3 &hd, const TH3 &hs, const TH3 &hb)
Add histograms with data and PDFs of signal and background.
JRealExperiment()
Default constructor.
void add(const TObject *pd, const TObject *ps, const TObject *pb)
Add objects with data and PDFs of signal and background.
JRealExperiment(const H_t &hd, const H_t &hs, const H_t &hb)
Constructor.
bool add(const TObject *pd, const TObject *ps, const TObject *pb)
Add objects with data and PDFs of signal and background.
void add(const size_t n, const double s, const double b)
Add data, signal and background.